--- a/integration/js/model.js Fri Nov 09 18:56:29 2012 +0100
+++ b/integration/js/model.js Fri Nov 16 19:23:20 2012 +0100
@@ -25,6 +25,13 @@
getUID : function() {
return uidbase + pad(4, (++uidincrement % 0x10000), 16) + "-" + rand16(4) + "-" + rand16(6) + rand16(6);
},
+ isLocalURL : function(url) {
+ var matches = url.match(/^(\w+:)\/\/([^/]+)/);
+ if (matches) {
+ return(matches[1] === document.location.protocol && matches[2] === document.location.host)
+ }
+ return true;
+ },
regexpFromTextOrArray : function(_textOrArray, _testOnly, _iexact) {
var _testOnly = _testOnly || false,
_iexact = _iexact || false;
@@ -1057,10 +1064,18 @@
Model.RemoteSource.prototype.get = function() {
this.status = Model._SOURCE_STATUS_WAITING;
- var _this = this;
- this.serializer.loadData(this.url, function(_result) {
- _this.deSerialize(_result);
- _this.handleCallbacks();
+ var _this = this,
+ urlparams = this.url_params || {},
+ dataType = (Model.isLocalURL(this.url) ? "json" : "jsonp");
+ urlparams.format = dataType;
+ ns.jQuery.ajax({
+ url: this.url,
+ dataType: dataType,
+ data: urlparams,
+ success: function(_result) {
+ _this.deSerialize(_result);
+ _this.handleCallbacks();
+ }
});
}
@@ -1076,10 +1091,12 @@
throw "Error : Model.Directory.remoteSource(configuration): configuration.url is undefined";
}
var _config = ns._({ directory: this }).extend(_properties);
- if (typeof this.remoteSources[_properties.url] === "undefined") {
- this.remoteSources[_properties.url] = new Model.RemoteSource(_config);
+ _config.url_params = _config.url_params || {};
+ var _hash = _config.url + "?" + ns.jQuery.param(_config.url_params);
+ if (typeof this.remoteSources[_hash] === "undefined") {
+ this.remoteSources[_hash] = new Model.RemoteSource(_config);
}
- return this.remoteSources[_properties.url];
+ return this.remoteSources[_hash];
}
Model.Directory.prototype.newLocalSource = function(_properties) {