X-Git-Url: http://git.roojs.org/?a=blobdiff_plain;f=roojs-debug.js;h=94b9ff7166aec9739299a61be7bb4cf2b2c55f48;hb=8946284bad10596673ce59afe8ef1ea49ba0b790;hp=92d9e7691d201a87928fc33a30603810d94d14bb;hpb=005e5a076296b98923366bf594e1499fd7af6568;p=roojs1 diff --git a/roojs-debug.js b/roojs-debug.js index 92d9e7691d..94b9ff7166 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(); } @@ -5905,12 +5949,15 @@ Roo.util.Observable.prototype = { relayEvents : function(o, events){ var createHandler = function(ename){ return function(){ + return this.fireEvent.apply(this, Roo.combine(ename, Array.prototype.slice.call(arguments, 0))); }; }; for(var i = 0, len = events.length; i < len; i++){ var ename = events[i]; - if(!this.events[ename]){ this.events[ename] = true; }; + if(!this.events[ename]){ + this.events[ename] = true; + }; o.on(ename, createHandler(ename), this); } }, @@ -6073,10 +6120,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; } @@ -6255,6 +6302,7 @@ Roo.EventManager = function(){ } } + var listen = function(element, ename, opt, fn, scope){ var o = (!opt || typeof opt == "boolean") ? {} : opt; @@ -7126,12 +7174,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 @@ -8183,7 +8233,32 @@ if(opt.anim.isAnimated()){ if (this.dom) { Roo.EventManager.on(this.dom, eventName, fn, scope || this, options); } + if (eventName == 'dblclick') { + this.addListener('touchstart', this.onTapHandler, this); + } }, + tapedTwice : false, + onTapHandler : function(event) + { + if(!this.tapedTwice) { + this.tapedTwice = true; + var s = this; + setTimeout( function() { + s.tapedTwice = false; + }, 300 ); + return; + } + event.preventDefault(); + var revent = new MouseEvent('dblclick', { + view: window, + bubbles: true, + cancelable: true + }); + + this.dom.dispatchEvent(revent); + //action on double tap goes below + + }, /** * Removes an event handler from this element @@ -8559,7 +8634,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 +8676,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; @@ -9314,7 +9390,7 @@ if(opt.anim.isAnimated()){ /** * @private */ - fitToParentDelegate : Roo.emptyFn, // keep a reference to the fitToParent delegate + fitToParentDelegate : Roo.emptyFn, // keep a reference to the fitToParent delegate /** * Sizes this element to its parent element's dimensions performing @@ -11615,7 +11691,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 +11700,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){ @@ -11801,11 +11887,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 +11917,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 +13393,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! }, @@ -13895,7 +13990,26 @@ Roo.util.Format = function(){ */ stripTags : function(v){ return !v ? v : String(v).replace(this.stripTagsRE, ""); + }, + + /** + * Size in Mb,Gb etc. + * @param {Number} value The number to be formated + * @param {number} decimals how many decimal places + * @return {String} the formated string + */ + size : function(value, decimals) + { + var sizes = ['b', 'k', 'M', 'G', 'T']; + if (value == 0) { + return 0; + } + var i = parseInt(Math.floor(Math.log(value) / Math.log(1024))); + return Roo.util.Format.number(value/ Math.pow(1024, i) ,decimals) + sizes[i]; } + + + }; }(); Roo.util.Format.defaults = { @@ -14410,7 +14524,44 @@ Roo.extend(Roo.util.ClickRepeater, Roo.util.Observable, { this.el.removeClass(this.pressClass); this.fireEvent("mouseup", this); } -});/* +});/** + * @class Roo.util.Clipboard + * @static + * + * Clipboard UTILS + * + **/ +Roo.util.Clipboard = { + /** + * Writes a string to the clipboard - using the Clipboard API if https, otherwise using text area. + * @param {String} text to copy to clipboard + */ + write : function(text) { + // navigator clipboard api needs a secure context (https) + if (navigator.clipboard && window.isSecureContext) { + // navigator clipboard api method' + navigator.clipboard.writeText(text); + return ; + } + // text area method + var ta = document.createElement("textarea"); + ta.value = text; + // make the textarea out of viewport + ta.style.position = "fixed"; + ta.style.left = "-999999px"; + ta.style.top = "-999999px"; + document.body.appendChild(ta); + ta.focus(); + ta.select(); + document.execCommand('copy'); + (function() { + ta.remove(); + }).defer(100); + + } + +} + /* * Based on: * Ext JS Library 1.1.1 * Copyright(c) 2006-2007, Ext JS, LLC. @@ -15435,7 +15586,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 +16151,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 + *