X-Git-Url: http://git.roojs.org/?a=blobdiff_plain;f=roojs-debug.js;h=257bcc48dca6d05ffd91cf1c9e0e7ce185cf0365;hb=86b8de9b171833430cbdebcd05af0a1240f5832f;hp=724a531f5f1d991b8aaafd7df4d13aed052d7a4f;hpb=0fe569b05443b34eaa12e545d58aa1646e1eb166;p=roojs1 diff --git a/roojs-debug.js b/roojs-debug.js index 724a531f5f..257bcc48dc 100644 --- a/roojs-debug.js +++ b/roojs-debug.js @@ -1015,8 +1015,34 @@ Roo.applyIf(Array.prototype, { } return res; + }, + /** + * equals + * @param {Array} o The array to compare to + * @returns {Boolean} true if the same + */ + equals : function(b) + { + // https://stackoverflow.com/questions/3115982/how-to-check-if-two-arrays-are-equal-with-javascript + if (this === b) { + return true; + } + if (b == null) { + return false; + } + if (this.length !== b.length) { + return false; + } + + // sort?? a.sort().equals(b.sort()); + + for (var i = 0; i < this.length; ++i) { + if (this[i] !== b[i]) { + return false; + } + } + return true; } - }); @@ -4652,6 +4678,12 @@ Roo.Template = function(cfg){ }; Roo.Template.prototype = { + /** + * @cfg {Function} onLoad Called after the template has been loaded and complied (usually from a remove source) + */ + onLoad : false, + + /** * @cfg {String} url The Url to load the template from. beware if you are loading from a url, the data may not be ready if you use it instantly.. * it should be fixed so that template is observable... @@ -4661,12 +4693,20 @@ Roo.Template.prototype = { * @cfg {String} html The HTML fragment or an array of fragments to join("") or multiple arguments to join("") */ html : '', + + + compiled : false, + loaded : false, /** * Returns an HTML fragment of this template with the specified values applied. * @param {Object} values The template values. Can be an array if your params are numeric (i.e. {0}) or an object (i.e. {foo: 'bar'}) * @return {String} The HTML fragment */ + + + applyTemplate : function(values){ + //Roo.log(["applyTemplate", values]); try { if(this.compiled){ @@ -4725,9 +4765,13 @@ Roo.Template.prototype = { method : 'GET', success : function (response) { _t.loading = false; - _t.html = response.responseText; _t.url = false; - _t.compile(); + + _t.set(response.responseText,true); + _t.loaded = true; + if (_t.onLoad) { + _t.onLoad(); + } }, failure : function(response) { Roo.log("Template failed to load from " + _t.url); @@ -4744,7 +4788,7 @@ Roo.Template.prototype = { */ set : function(html, compile){ this.html = html; - this.compiled = null; + this.compiled = false; if(compile){ this.compile(); } @@ -6073,10 +6117,10 @@ Roo.util.Observable.releaseCapture = function(o){ var ls = this.listeners, scope, len = ls.length; if(len > 0){ this.firing = true; - var args = Array.prototype.slice.call(arguments, 0); + var args = Array.prototype.slice.call(arguments, 0); for(var i = 0; i < len; i++){ - var l = ls[i]; - if(l.fireFn.apply(l.scope||this.obj||window, arguments) === false){ + var l = ls[i]; + if(l.fireFn.apply(l.scope||this.obj||window, args) === false){ this.firing = false; return false; } @@ -7126,12 +7170,14 @@ if(opt.anim.isAnimated()){ El.prototype = { /** - * The element's default display mode (defaults to "") + * The element's default display mode (defaults to "") * @type String */ originalDisplay : "", - visibilityMode : 1, + + // note this is overridden in BS version.. + visibilityMode : 1, /** * The default unit to append to CSS values where a unit isn't provided (defaults to px). * @type String @@ -8559,7 +8605,8 @@ if(opt.anim.isAnimated()){ * @param {Array} offsets (optional) Offset the positioning by [x, y] * @return {Array} [x, y] */ - getAlignToXY : function(el, p, o){ + getAlignToXY : function(el, p, o) + { el = Roo.get(el); var d = this.dom; if(!el.dom){ @@ -8600,7 +8647,7 @@ if(opt.anim.isAnimated()){ //otherwise swap the aligned el to the opposite border of the target. var p1y = p1.charAt(0), p1x = p1.charAt(p1.length-1); var p2y = p2.charAt(0), p2x = p2.charAt(p2.length-1); - var swapY = ((p1y=="t" && p2y=="b") || (p1y=="b" && p2y=="t")); + var swapY = ((p1y=="t" && p2y=="b") || (p1y=="b" && p2y=="t") ); var swapX = ((p1x=="r" && p2x=="l") || (p1x=="l" && p2x=="r")); var doc = document; @@ -11615,7 +11662,7 @@ Roo.extend(Roo.data.Connection, Roo.util.Observable, { var enctype = form.getAttribute("enctype"); if (o.formData) { - return this.doFormDataUpload(o,p,url); + return this.doFormDataUpload(o, url); } if(o.isUpload || (enctype && enctype.toLowerCase() == 'multipart/form-data')){ @@ -11624,6 +11671,16 @@ Roo.extend(Roo.data.Connection, Roo.util.Observable, { var f = Roo.lib.Ajax.serializeForm(form); p = p ? (p + '&' + f) : f; } + + if (!o.form && o.formData) { + o.formData = o.formData === true ? new FormData() : o.formData; + for (var k in o.params) { + o.formData.append(k,o.params[k]); + } + + return this.doFormDataUpload(o, url); + } + var hs = o.headers; if(this.defaultHeaders){ @@ -11659,7 +11716,7 @@ Roo.extend(Roo.data.Connection, Roo.util.Observable, { url += (url.indexOf('?') != -1 ? '&' : '?') + p; p = ''; } - Roo.lib.Ajax.useDefaultHeader == typeof(o.headers['Content-Type']) == 'undefined'; + Roo.lib.Ajax.useDefaultHeader = typeof(o.headers) == 'undefined' || typeof(o.headers['Content-Type']) == 'undefined'; this.transId = Roo.lib.Ajax.request(method, url, cb, p, o); Roo.lib.Ajax.useDefaultHeader == true; return this.transId; @@ -11801,11 +11858,17 @@ Roo.extend(Roo.data.Connection, Roo.util.Observable, { // this is a 'formdata version???' - doFormDataUpload : function(o, ps, url) + doFormDataUpload : function(o, url) { - var form = Roo.getDom(o.form); - form.enctype = form.encoding = 'multipart/form-data'; - var formData = o.formData === true ? new FormData(form) : o.formData; + var formData; + if (o.form) { + var form = Roo.getDom(o.form); + form.enctype = form.encoding = 'multipart/form-data'; + formData = o.formData === true ? new FormData(form) : o.formData; + } else { + formData = o.formData === true ? new FormData() : o.formData; + } + var cb = { success: this.handleResponse, @@ -11825,7 +11888,7 @@ Roo.extend(Roo.data.Connection, Roo.util.Observable, { //Roo.lib.Ajax.defaultPostHeader = null; Roo.lib.Ajax.useDefaultHeader = false; - this.transId = Roo.lib.Ajax.request( "POST", url, cb, o.formData, o); + this.transId = Roo.lib.Ajax.request( "POST", url, cb, formData, o); Roo.lib.Ajax.useDefaultHeader = true; @@ -13301,6 +13364,9 @@ mc.add(otherEl); * @return {Object} The item associated with the passed key. */ item : function(key){ + if (key === 'length') { + return null; + } var item = typeof this.map[key] != "undefined" ? this.map[key] : this.items[key]; return typeof item != 'function' || this.allowFunctions ? item : null; // for prototype! }, @@ -15435,7 +15501,7 @@ Roo.extend(Roo.Component, Roo.util.Observable, { /** * @cfg {String} actionMode * which property holds the element that used for hide() / show() / disable() / enable() - * default is 'el' + * default is 'el' for forms you probably want to set this to fieldEl */ actionMode : "el", @@ -16000,6 +16066,463 @@ Roo.extend(Roo.BoxComponent, Roo.Component, { return {x : x, y: y}; } });/* + * Based on: + * Ext JS Library 1.1.1 + * Copyright(c) 2006-2007, Ext JS, LLC. + * + * Originally Released Under LGPL - original licence link has changed is not relivant. + * + * Fork - LGPL + *