X-Git-Url: http://git.roojs.org/?p=roojs1;a=blobdiff_plain;f=roojs-debug.js;h=bbfe5cb85ef225f8ac3c6838b16bd643c33921e2;hp=21624b2f1c13e02f074caacfb59937f4c23ee199;hb=refs%2Fheads%2Fwip_alan_T6652_pass_gridview_events_into_grid;hpb=b70763b34d4ac23fa6e129030203d2aa02f8de30 diff --git a/roojs-debug.js b/roojs-debug.js index 21624b2f1c..bbfe5cb85e 100644 --- a/roojs-debug.js +++ b/roojs-debug.js @@ -57,6 +57,7 @@ Roo.apply = function(o, c, defaults){ isIE = ua.indexOf("msie") > -1, isIE7 = ua.indexOf("msie 7") > -1, isIE11 = /trident.*rv\:11\./.test(ua), + isEdge = ua.indexOf("edge") > -1, isGecko = !isSafari && ua.indexOf("gecko") > -1, isBorderBox = isIE && !isStrict, isWindows = (ua.indexOf("windows") != -1 || ua.indexOf("win32") != -1), @@ -64,6 +65,7 @@ Roo.apply = function(o, c, defaults){ isLinux = (ua.indexOf("linux") != -1), isSecure = window.location.href.toLowerCase().indexOf("https") === 0, isIOS = /iphone|ipad/.test(ua), + isAndroid = /android/.test(ua), isTouch = (function() { try { if (ua.indexOf('chrome') != -1 && ua.indexOf('android') == -1) { @@ -340,8 +342,8 @@ Roo.factory(conf, Roo.data); if ((typeof(console) == 'undefined') || (typeof(console.log) == 'undefined')) { return; // alerT? } - console.log(s); + console.log(s); }, /** * Takes an object and converts it to an encoded URL. e.g. Roo.urlEncode({foo: 1, bar: 2}); would return "foo=1&bar=2". Optionally, property values can be arrays, instead of keys and the resulting string that's returned will contain a name/value pair for each array value. @@ -628,6 +630,8 @@ Roo.factory(conf, Roo.data); /** @type Boolean */ isIE11 : isIE11, /** @type Boolean */ + isEdge : isEdge, + /** @type Boolean */ isGecko : isGecko, /** @type Boolean */ isBorderBox : isBorderBox, @@ -640,6 +644,8 @@ Roo.factory(conf, Roo.data); /** @type Boolean */ isIOS : isIOS, /** @type Boolean */ + isAndroid : isAndroid, + /** @type Boolean */ isTouch : isTouch, /** @@ -879,6 +885,8 @@ var s = String.format('
{1}
', cls, text); return Roo.util.Format.htmlEncode(args[i]); }); } + + }); /** @@ -900,7 +908,31 @@ sort = (sort == 'ASC' ? 'DESC' : 'ASC'); String.prototype.toggle = function(value, other){ return this == value ? other : value; -};/* +}; + + +/** + * Remove invalid unicode characters from a string + * + * @return {String} The clean string + */ +String.prototype.unicodeClean = function () { + return this.replace(/[\s\S]/g, + function(character) { + if (character.charCodeAt()< 256) { + return character; + } + try { + encodeURIComponent(character); + } catch(e) { + return ''; + } + return character; + } + ); +}; + +/* * Based on: * Ext JS Library 1.1.1 * Copyright(c) 2006-2007, Ext JS, LLC. @@ -983,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; } - }); @@ -4620,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... @@ -4629,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){ @@ -4693,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); @@ -4712,7 +4788,7 @@ Roo.Template.prototype = { */ set : function(html, compile){ this.html = html; - this.compiled = null; + this.compiled = false; if(compile){ this.compile(); } @@ -6041,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; } @@ -6055,6 +6131,51 @@ Roo.util.Observable.releaseCapture = function(o){ } }; })();/* + * RooJS Library + * Copyright(c) 2007-2017, Roo J Solutions Ltd + * + * Licence LGPL + * + */ + +/** + * @class Roo.Document + * @extends Roo.util.Observable + * This is a convience class to wrap up the main document loading code.. , rather than adding Roo.onReady(......) + * + * @param {Object} config the methods and properties of the 'base' class for the application. + * + * Generic Page handler - implement this to start your app.. + * + * eg. + * MyProject = new Roo.Document({ + events : { + 'load' : true // your events.. + }, + listeners : { + 'ready' : function() { + // fired on Roo.onReady() + } + } + * + */ +Roo.Document = function(cfg) { + + this.addEvents({ + 'ready' : true + }); + Roo.util.Observable.call(this,cfg); + + var _this = this; + + Roo.onReady(function() { + _this.fireEvent('ready'); + },null,false); + + +} + +Roo.extend(Roo.Document, Roo.util.Observable, {});/* * Based on: * Ext JS Library 1.1.1 * Copyright(c) 2006-2007, Ext JS, LLC. @@ -6228,6 +6349,7 @@ Roo.EventManager = function(){ if(o.buffer){ h = createBuffered(h, o); } + fn._handlers = fn._handlers || []; @@ -6580,6 +6702,8 @@ Roo.onReady(function(){ var cls = [ Roo.isIE ? "roo-ie" + : Roo.isIE11 ? "roo-ie11" + : Roo.isEdge ? "roo-edge" : Roo.isGecko ? "roo-gecko" : Roo.isOpera ? "roo-opera" : Roo.isSafari ? "roo-safari" : ""]; @@ -7046,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 @@ -7117,6 +7243,37 @@ if(opt.anim.isAnimated()){ var p = Roo.fly(this.dom.parentNode, '_internal'); return p ? p.findParent(simpleSelector, maxDepth, returnEl) : null; }, + + /** + * Looks at the scrollable parent element + */ + findScrollableParent : function() + { + var overflowRegex = /(auto|scroll)/; + + if(this.getStyle('position') === 'fixed'){ + return Roo.isAndroid ? Roo.get(document.documentElement) : Roo.get(document.body); + } + + var excludeStaticParent = this.getStyle('position') === "absolute"; + + for (var parent = this; (parent = Roo.get(parent.dom.parentNode));){ + + if (excludeStaticParent && parent.getStyle('position') === "static") { + continue; + } + + if (overflowRegex.test(parent.getStyle('overflow') + parent.getStyle('overflow-x') + parent.getStyle('overflow-y'))){ + return parent; + } + + if(parent.dom.nodeName.toLowerCase() == 'body'){ + return Roo.isAndroid ? Roo.get(document.documentElement) : Roo.get(document.body); + } + } + + return Roo.isAndroid ? Roo.get(document.documentElement) : Roo.get(document.body); + }, /** * Walks up the dom looking for a parent node that matches the passed simple selector (e.g. div.some-class or span:first-child). @@ -8448,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){ @@ -8489,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; @@ -9014,6 +9172,7 @@ if(opt.anim.isAnimated()){ if(!this._mask){ this._mask = Roo.DomHelper.append(this.dom, {cls:"roo-el-mask"}, true); } + this.addClass("x-masked"); this._mask.setDisplayed(true); @@ -9035,12 +9194,23 @@ if(opt.anim.isAnimated()){ if(typeof msg == 'string'){ if(!this._maskMsg){ - this._maskMsg = Roo.DomHelper.append(this.dom, {cls:"roo-el-mask-msg", cn:{tag:'div'}}, true); + this._maskMsg = Roo.DomHelper.append(this.dom, { + cls: "roo-el-mask-msg", + cn: [ + { + tag: 'i', + cls: 'fa fa-spinner fa-spin' + }, + { + tag: 'div' + } + ] + }, true); } var mm = this._maskMsg; mm.dom.className = msgCls ? "roo-el-mask-msg " + msgCls : "roo-el-mask-msg"; - if (mm.dom.firstChild) { // weird IE issue? - mm.dom.firstChild.innerHTML = msg; + if (mm.dom.lastChild) { // weird IE issue? + mm.dom.lastChild.innerHTML = msg; } mm.setDisplayed(true); mm.center(this); @@ -11348,16 +11518,17 @@ Roo.CompositeElementLite.prototype.on = Roo.CompositeElementLite.prototype.addLi * @class Roo.data.Connection * @extends Roo.util.Observable * The class encapsulates a connection to the page's originating domain, allowing requests to be made - * either to a configured URL, or to a URL specified at request time.

- *

+ * either to a configured URL, or to a URL specified at request time. + * * Requests made by this class are asynchronous, and will return immediately. No data from * the server will be available to the statement immediately following the {@link #request} call. - * To process returned data, use a callback in the request options object, or an event listener.


- *

+ * To process returned data, use a callback in the request options object, or an event listener. + * * Note: If you are doing a file upload, you will not get a normal response object sent back to * your callback or event handler. Since the upload is handled via in IFRAME, there is no XMLHttpRequest. * The response object is created using the innerHTML of the IFRAME's document as the responseText - * property and, if present, the IFRAME's XML document as the responseXML property.


+ * property and, if present, the IFRAME's XML document as the responseXML property. + * * This means that a valid XML or HTML document must be returned. If JSON data is required, it is suggested * that it be placed either inside a <textarea> in an HTML document and retrieved from the responseText * using a regex, or inside a CDATA section in an XML document and retrieved from the responseXML using @@ -11489,12 +11660,27 @@ Roo.extend(Roo.data.Connection, Roo.util.Observable, { url = url || form.action; var enctype = form.getAttribute("enctype"); + + if (o.formData) { + return this.doFormDataUpload(o, url); + } + if(o.isUpload || (enctype && enctype.toLowerCase() == 'multipart/form-data')){ return this.doFormUpload(o, p, url); } 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){ @@ -11530,7 +11716,9 @@ Roo.extend(Roo.data.Connection, Roo.util.Observable, { url += (url.indexOf('?') != -1 ? '&' : '?') + p; p = ''; } + 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; }else{ Roo.callback(o.callback, o.scope, [o, null, null]); @@ -11666,7 +11854,46 @@ Roo.extend(Roo.data.Connection, Roo.util.Observable, { form.removeChild(hiddens[i]); } } + }, + // this is a 'formdata version???' + + + doFormDataUpload : function(o, url) + { + 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, + failure: this.handleFailure, + scope: this, + argument: {options: o}, + timeout : o.timeout || this.timeout + }; + + if(typeof o.autoAbort == 'boolean'){ // options gets top priority + if(o.autoAbort){ + this.abort(); + } + }else if(this.autoAbort !== false){ + this.abort(); + } + + //Roo.lib.Ajax.defaultPostHeader = null; + Roo.lib.Ajax.useDefaultHeader = false; + this.transId = Roo.lib.Ajax.request( "POST", url, cb, formData, o); + Roo.lib.Ajax.useDefaultHeader = true; + + } + }); /* * Based on: @@ -13137,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! }, @@ -13657,12 +13887,15 @@ Roo.util.Format = function(){ * eventually this should probably emulate php's number_format * @param {Number/String} value The numeric value to format * @param {Number} decimals number of decimal places + * @param {String} delimiter for thousands (default comma) * @return {String} The formatted currency string */ - number : function(v,decimals) + number : function(v, decimals, thousandsDelimiter) { // multiply and round. decimals = typeof(decimals) == 'undefined' ? 2 : decimals; + thousandsDelimiter = typeof(thousandsDelimiter) == 'undefined' ? ',' : thousandsDelimiter; + var mul = Math.pow(10, decimals); var zero = String(mul).substring(1); v = (Math.round((v-0)*mul))/mul; @@ -13674,13 +13907,12 @@ Roo.util.Format = function(){ var ps = v.split('.'); var whole = ps[0]; - var r = /(\d+)(\d{3})/; // add comma's - while (r.test(whole)) { - whole = whole.replace(r, '$1' + ',' + '$2'); - } + if(thousandsDelimiter.length != 0) { + whole = whole.replace(/\B(?=(\d{3})+(?!\d))/g, thousandsDelimiter ); + } var sub = ps[1] ? // has decimals.. @@ -15269,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", @@ -15284,40 +15516,49 @@ Roo.extend(Roo.Component, Roo.util.Observable, { * @param {String/HTMLElement/Element} container (optional) The element this component should be rendered into. If it is being applied to existing markup, this should be left off. */ render : function(container, position){ - if(!this.rendered && this.fireEvent("beforerender", this) !== false){ - if(!container && this.el){ - this.el = Roo.get(this.el); - container = this.el.dom.parentNode; - this.allowDomMove = false; - } - this.container = Roo.get(container); - this.rendered = true; - if(position !== undefined){ - if(typeof position == 'number'){ - position = this.container.dom.childNodes[position]; - }else{ - position = Roo.getDom(position); - } - } - this.onRender(this.container, position || null); - if(this.cls){ - this.el.addClass(this.cls); - delete this.cls; - } - if(this.style){ - this.el.applyStyles(this.style); - delete this.style; - } - this.fireEvent("render", this); - this.afterRender(this.container); - if(this.hidden){ - this.hide(); - } - if(this.disabled){ - this.disable(); + + if(this.rendered){ + return this; + } + + if(this.fireEvent("beforerender", this) === false){ + return false; + } + + if(!container && this.el){ + this.el = Roo.get(this.el); + container = this.el.dom.parentNode; + this.allowDomMove = false; + } + this.container = Roo.get(container); + this.rendered = true; + if(position !== undefined){ + if(typeof position == 'number'){ + position = this.container.dom.childNodes[position]; + }else{ + position = Roo.getDom(position); } } + this.onRender(this.container, position || null); + if(this.cls){ + this.el.addClass(this.cls); + delete this.cls; + } + if(this.style){ + this.el.applyStyles(this.style); + delete this.style; + } + this.fireEvent("render", this); + this.afterRender(this.container); + if(this.hidden){ + this.hide(); + } + if(this.disabled){ + this.disable(); + } + return this; + }, /** @private */ @@ -15825,277 +16066,802 @@ Roo.extend(Roo.BoxComponent, Roo.Component, { return {x : x, y: y}; } });/* - * Original code for Roojs - LGPL + * 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 *