in content/js/tree.jquery.js [2660:2747]
JqTreeWidget.prototype._loadDataFromUrl = function(url_info, parent_node, on_finished) {
var $el, addLoadingClass, handeLoadData, handleError, handleSuccess, loadDataFromUrlInfo, parseUrlInfo, removeLoadingClass;
$el = null;
addLoadingClass = (function(_this) {
return function() {
if (parent_node) {
$el = $(parent_node.element);
} else {
$el = _this.element;
}
$el.addClass('jqtree-loading');
return _this._notifyLoading(true, parent_node, $el);
};
})(this);
removeLoadingClass = (function(_this) {
return function() {
if ($el) {
$el.removeClass('jqtree-loading');
return _this._notifyLoading(false, parent_node, $el);
}
};
})(this);
parseUrlInfo = function() {
if ($.type(url_info) === 'string') {
return {
url: url_info
};
}
if (!url_info.method) {
url_info.method = 'get';
}
return url_info;
};
handeLoadData = (function(_this) {
return function(data) {
removeLoadingClass();
_this._loadData(data, parent_node);
if (on_finished && $.isFunction(on_finished)) {
return on_finished();
}
};
})(this);
handleSuccess = (function(_this) {
return function(response) {
var data;
if ($.isArray(response) || typeof response === 'object') {
data = response;
} else if (data != null) {
data = $.parseJSON(response);
} else {
data = [];
}
if (_this.options.dataFilter) {
data = _this.options.dataFilter(data);
}
return handeLoadData(data);
};
})(this);
handleError = (function(_this) {
return function(response) {
removeLoadingClass();
if (_this.options.onLoadFailed) {
return _this.options.onLoadFailed(response);
}
};
})(this);
loadDataFromUrlInfo = function() {
url_info = parseUrlInfo();
return $.ajax($.extend({}, url_info, {
method: url_info.method != null ? url_info.method.toUpperCase() : 'GET',
cache: false,
dataType: 'json',
success: handleSuccess,
error: handleError
}));
};
if (!url_info) {
url_info = this._getDataUrlInfo(parent_node);
}
addLoadingClass();
if (!url_info) {
removeLoadingClass();
} else if ($.isArray(url_info)) {
handeLoadData(url_info);
} else {
loadDataFromUrlInfo();
}
};