X-Git-Url: http://git.roojs.org/?p=roojs1;a=blobdiff_plain;f=roojs-debug.js;h=1cda431fb38d359f9d8f612814b13f88fd44ef92;hp=4e48176b841debd219ed472d6cc67304f9d72f01;hb=8673c23959602f121d1fb75c6a7ec7a656352897;hpb=ae8b53cdb46beadb17959cbb30e797ccedda31fa diff --git a/roojs-debug.js b/roojs-debug.js index 4e48176b84..1cda431fb3 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. @@ -4635,6 +4667,7 @@ Roo.Template.prototype = { * @return {String} The HTML fragment */ applyTemplate : function(values){ + Roo.log(["applyTemplate", values]); try { if(this.compiled){ @@ -6041,10 +6074,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; } @@ -6273,6 +6306,7 @@ Roo.EventManager = function(){ if(o.buffer){ h = createBuffered(h, o); } + fn._handlers = fn._handlers || []; @@ -6625,6 +6659,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" : ""]; @@ -7166,12 +7202,12 @@ if(opt.anim.isAnimated()){ /** * Looks at the scrollable parent element */ - findScrollableParent : function(){ - + findScrollableParent : function() + { var overflowRegex = /(auto|scroll)/; if(this.getStyle('position') === 'fixed'){ - return Roo.get(document.body); + return Roo.isAndroid ? Roo.get(document.documentElement) : Roo.get(document.body); } var excludeStaticParent = this.getStyle('position') === "absolute"; @@ -7182,15 +7218,16 @@ if(opt.anim.isAnimated()){ continue; } - if ( - parent.dom.nodeName.toLowerCase() == 'body' || - overflowRegex.test(parent.getStyle('overflow') + parent.getStyle('overflow-x') + parent.getStyle('overflow-y')) - ){ + 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.get(document.body); + return Roo.isAndroid ? Roo.get(document.documentElement) : Roo.get(document.body); }, /** @@ -9089,6 +9126,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); @@ -9110,12 +9148,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); @@ -11423,16 +11472,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 @@ -11564,6 +11614,11 @@ Roo.extend(Roo.data.Connection, Roo.util.Observable, { url = url || form.action; var enctype = form.getAttribute("enctype"); + + if (o.formData) { + return this.doFormDataUpload(o,p,url); + } + if(o.isUpload || (enctype && enctype.toLowerCase() == 'multipart/form-data')){ return this.doFormUpload(o, p, url); } @@ -11605,7 +11660,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]); @@ -11741,7 +11798,40 @@ Roo.extend(Roo.data.Connection, Roo.util.Observable, { form.removeChild(hiddens[i]); } } + }, + // this is a 'formdata version???' + + + doFormDataUpload : function(o, ps, 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 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, o.formData, o); + Roo.lib.Ajax.useDefaultHeader = true; + + } + }); /* * Based on: @@ -13212,6 +13302,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! }, @@ -13732,12 +13825,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; @@ -13749,13 +13845,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.. @@ -15344,7 +15439,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", @@ -15359,40 +15454,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 */ @@ -15964,6 +16068,12 @@ Roo.extend(Roo.BoxComponent, Roo.Component, { * Our builder application needs the ability to preview these sub compoennts. They will normally have parent=false set, * hence confusing the component builder as it thinks there are multiple top level elements. * + * String Over-ride & Translations + * + * Our builder application writes all the strings as _strings and _named_strings. This is to enable the translation of elements, + * and also the 'overlaying of string values - needed when different versions of the same application with different text content + * are needed. @see Roo.XComponent.overlayString + * * * * @extends Roo.util.Observable @@ -16315,7 +16425,7 @@ Roo.apply(Roo.XComponent, { break; default: - if (obj.disabled) { + if (obj.disabled || obj.region == '#disabled') { return; } break; @@ -16508,6 +16618,7 @@ Roo.apply(Roo.XComponent, { msg: msg, width:450, progress:true, + buttons : false, closable:false, modal: false @@ -16573,7 +16684,32 @@ Roo.apply(Roo.XComponent, { }, - + /** + * Overlay a set of modified strings onto a component + * This is dependant on our builder exporting the strings and 'named strings' elements. + * + * @param {Object} element to overlay on - eg. Pman.Dialog.Login + * @param {Object} associative array of 'named' string and it's new value. + * + */ + overlayStrings : function( component, strings ) + { + if (typeof(component['_named_strings']) == 'undefined') { + throw "ERROR: component does not have _named_strings"; + } + for ( var k in strings ) { + var md = typeof(component['_named_strings'][k]) == 'undefined' ? false : component['_named_strings'][k]; + if (md !== false) { + component['_strings'][md] = strings[k]; + } else { + Roo.log('could not find named string: ' + k + ' in'); + Roo.log(component); + } + + } + + }, + /** * Event Object. @@ -16670,10 +16806,86 @@ Roo.Markdown.toHtml = function(text) { // (function() { + /** + * eval:var:escape + * eval:var:unescape + * eval:var:replace + */ + + /** + * Helpers + */ + + var escape = function (html, encode) { + return html + .replace(!encode ? /&(?!#?\w+;)/g : /&/g, '&') + .replace(//g, '>') + .replace(/"/g, '"') + .replace(/'/g, '''); + } + + var unescape = function (html) { + // explicitly match decimal, hex, and named HTML entities + return html.replace(/&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/g, function(_, n) { + n = n.toLowerCase(); + if (n === 'colon') { return ':'; } + if (n.charAt(0) === '#') { + return n.charAt(1) === 'x' + ? String.fromCharCode(parseInt(n.substring(2), 16)) + : String.fromCharCode(+n.substring(1)); + } + return ''; + }); + } + + var replace = function (regex, opt) { + regex = regex.source; + opt = opt || ''; + return function self(name, val) { + if (!name) { return new RegExp(regex, opt); } + val = val.source || val; + val = val.replace(/(^|[^\[])\^/g, '$1'); + regex = regex.replace(name, val); + return self; + }; + } + + + /** + * eval:var:noop + */ + var noop = function () {} + noop.exec = noop; + + /** + * eval:var:merge + */ + var merge = function (obj) { + var i = 1 + , target + , key; + + for (; i < arguments.length; i++) { + target = arguments[i]; + for (key in target) { + if (Object.prototype.hasOwnProperty.call(target, key)) { + obj[key] = target[key]; + } + } + } + + return obj; + } + + /** * Block-Level Grammar */ + + + var block = { newline: /^\n+/, code: /^( {4}[^\n]+\n*)+/, @@ -16763,7 +16975,7 @@ Roo.Markdown.toHtml = function(text) { * Block Lexer */ - function Lexer(options) { + var Lexer = function (options) { this.tokens = []; this.tokens.links = {}; this.options = options || marked.defaults; @@ -17181,7 +17393,7 @@ Roo.Markdown.toHtml = function(text) { * Inline Lexer & Compiler */ - function InlineLexer(links, options) { + var InlineLexer = function (links, options) { this.options = options || marked.defaults; this.links = links; this.rules = inline.normal; @@ -17421,7 +17633,11 @@ Roo.Markdown.toHtml = function(text) { * Renderer */ - function Renderer(options) { + /** + * eval:var:Renderer + */ + + var Renderer = function (options) { this.options = options || {}; } @@ -17570,8 +17786,11 @@ Roo.Markdown.toHtml = function(text) { /** * Parsing & Compiling */ + /** + * eval:var:Parser + */ - function Parser(options) { + var Parser= function (options) { this.tokens = []; this.token = null; this.options = options || marked.defaults; @@ -17746,72 +17965,15 @@ Roo.Markdown.toHtml = function(text) { } } }; - - /** - * Helpers - */ - - function escape(html, encode) { - return html - .replace(!encode ? /&(?!#?\w+;)/g : /&/g, '&') - .replace(//g, '>') - .replace(/"/g, '"') - .replace(/'/g, '''); - } - - function unescape(html) { - // explicitly match decimal, hex, and named HTML entities - return html.replace(/&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/g, function(_, n) { - n = n.toLowerCase(); - if (n === 'colon') { return ':'; } - if (n.charAt(0) === '#') { - return n.charAt(1) === 'x' - ? String.fromCharCode(parseInt(n.substring(2), 16)) - : String.fromCharCode(+n.substring(1)); - } - return ''; - }); - } - - function replace(regex, opt) { - regex = regex.source; - opt = opt || ''; - return function self(name, val) { - if (!name) { return new RegExp(regex, opt); } - val = val.source || val; - val = val.replace(/(^|[^\[])\^/g, '$1'); - regex = regex.replace(name, val); - return self; - }; - } - - function noop() {} - noop.exec = noop; - - function merge(obj) { - var i = 1 - , target - , key; - - for (; i < arguments.length; i++) { - target = arguments[i]; - for (key in target) { - if (Object.prototype.hasOwnProperty.call(target, key)) { - obj[key] = target[key]; - } - } - } - - return obj; - } - + /** * Marked */ - - function marked(src, opt, callback) { + /** + * eval:var:marked + */ + var marked = function (src, opt, callback) { if (callback || typeof opt === 'function') { if (!callback) { callback = opt; @@ -17832,7 +17994,9 @@ Roo.Markdown.toHtml = function(text) { } pending = tokens.length; - + /** + * eval:var:done + */ var done = function(err) { if (err) { opt.highlight = highlight; @@ -20965,8 +21129,8 @@ Roo.dd.DDTarget = function(id, sGroup, config) { if (id) { this.initTarget(id, sGroup, config); } - if (config.listeners || config.events) { - Roo.dd.DragDrop.superclass.constructor.call(this, { + if (config && (config.listeners || config.events)) { + Roo.dd.DragDrop.superclass.constructor.call(this, { listeners : config.listeners || {}, events : config.events || {} }); @@ -22888,6 +23052,7 @@ Roo.extend(Roo.data.Store, Roo.util.Observable, { remove : function(record){ var index = this.data.indexOf(record); this.data.removeAt(index); + if(this.pruneModifiedRecords){ this.modified.remove(record); } @@ -23075,6 +23240,17 @@ Roo.extend(Roo.data.Store, Roo.util.Observable, { this.totalLength = Math.max(t, this.data.length+r.length); this.add(r); } + + if(this.parent && !Roo.isIOS && !this.useNativeIOS && this.parent.emptyTitle.length) { + + var e = new Roo.data.Record({}); + + e.set(this.parent.displayField, this.parent.emptyTitle); + e.set(this.parent.valueField, ''); + + this.insert(0, e); + } + this.fireEvent("load", this, r, options, o); if(options.callback){ options.callback.call(options.scope || this, r, options, true); @@ -23093,6 +23269,16 @@ Roo.extend(Roo.data.Store, Roo.util.Observable, { var r = this.reader.readRecords(o); this.loadRecords(r, {add: append}, true); }, + + /** + * using 'cn' the nested child reader read the child array into it's child stores. + * @param {Object} rec The record with a 'children array + */ + loadDataFromChildren : function(rec) + { + this.loadData(this.reader.toLoadData(rec)); + }, + /** * Gets the number of cached records. @@ -23397,14 +23583,16 @@ Roo.extend(Roo.data.Store, Roo.util.Observable, { * Small helper class to make creating Stores from Array data easier. * @cfg {Number} id The array index of the record id. Leave blank to auto generate ids. * @cfg {Array} fields An array of field definition objects, or field name strings. + * @cfg {Object} an existing reader (eg. copied from another store) * @cfg {Array} data The multi-dimensional array of data * @constructor * @param {Object} config */ -Roo.data.SimpleStore = function(config){ +Roo.data.SimpleStore = function(config) +{ Roo.data.SimpleStore.superclass.constructor.call(this, { isLocal : true, - reader: new Roo.data.ArrayReader({ + reader: typeof(config.reader) != 'undefined' ? config.reader : new Roo.data.ArrayReader({ id: config.id }, Roo.data.Record.create(config.fields) @@ -23581,6 +23769,9 @@ Roo.data.DataReader = function(meta, recordType){ }; Roo.data.DataReader.prototype = { + + + readerType : 'Data', /** * Create an empty record * @param {Object} data (optional) - overlay some values @@ -23601,6 +23792,7 @@ Roo.data.DataReader.prototype = { return new this.recordType(Roo.apply(da, d)); } + };/* * Based on: * Ext JS Library 1.1.1 @@ -23708,7 +23900,7 @@ Roo.extend(Roo.data.MemoryProxy, Roo.data.DataProxy, { params = params || {}; var result; try { - result = reader.readRecords(this.data); + result = reader.readRecords(params.data ? params.data :this.data); }catch(e){ this.fireEvent("loadexception", this, arg, null, e); callback.call(scope, null, arg, false); @@ -24139,6 +24331,8 @@ Roo.data.JsonReader = function(meta, recordType){ }; Roo.extend(Roo.data.JsonReader, Roo.data.DataReader, { + readerType : 'Json', + /** * @prop {Boolean} metaFromRemote - if the meta data was loaded from the remote source. * Used by Store query builder to append _requestMeta to params. @@ -24280,6 +24474,14 @@ Roo.extend(Roo.data.JsonReader, Roo.data.DataReader, { records : records, totalRecords : totalRecords }; + }, + // used when loading children.. @see loadDataFromChildren + toLoadData: function(rec) + { + // expect rec just to be an array.. eg [a,b,c, [...] << cn ] + var data = typeof(rec.data.cn) == 'undefined' ? [] : rec.data.cn; + return { data : data, total : data.length }; + } });/* * Based on: @@ -24350,6 +24552,9 @@ Roo.data.XmlReader = function(meta, recordType){ Roo.data.XmlReader.superclass.constructor.call(this, meta, recordType||meta.fields); }; Roo.extend(Roo.data.XmlReader, Roo.data.DataReader, { + + readerType : 'Xml', + /** * This method is only used by a DataProxy which has retrieved data from a remote server. * @param {Object} response The XHR object which contains the parsed XML document. The response is expected @@ -24447,51 +24652,68 @@ var myReader = new Roo.data.ArrayReader({ *

 [ [1, 'Bill', 'Gardener'], [2, 'Ben', 'Horticulturalist'] ]
   
- * @cfg {String} id (optional) The subscript within row Array that provides an ID for the Record + * @constructor * Create a new JsonReader * @param {Object} meta Metadata configuration options. - * @param {Object} recordType Either an Array of field definition objects + * @param {Object|Array} recordType Either an Array of field definition objects + * + * @cfg {Array} fields Array of field definition objects + * @cfg {String} id Name of the property within a row object that contains a record identifier value. * as specified to {@link Roo.data.Record#create}, * or an {@link Roo.data.Record} object + * + * * created using {@link Roo.data.Record#create}. */ -Roo.data.ArrayReader = function(meta, recordType){ - Roo.data.ArrayReader.superclass.constructor.call(this, meta, recordType); +Roo.data.ArrayReader = function(meta, recordType) +{ + Roo.data.ArrayReader.superclass.constructor.call(this, meta, recordType||meta.fields); }; Roo.extend(Roo.data.ArrayReader, Roo.data.JsonReader, { - /** + + /** * Create a data block containing Roo.data.Records from an XML document. * @param {Object} o An Array of row objects which represents the dataset. - * @return {Object} data A data block which is used by an Roo.data.Store object as + * @return {Object} A data block which is used by an {@link Roo.data.Store} object as * a cache of Roo.data.Records. */ - readRecords : function(o){ + readRecords : function(o) + { var sid = this.meta ? this.meta.id : null; var recordType = this.recordType, fields = recordType.prototype.fields; var records = []; var root = o; - for(var i = 0; i < root.length; i++){ - var n = root[i]; - var values = {}; - var id = ((sid || sid === 0) && n[sid] !== undefined && n[sid] !== "" ? n[sid] : null); - for(var j = 0, jlen = fields.length; j < jlen; j++){ - var f = fields.items[j]; - var k = f.mapping !== undefined && f.mapping !== null ? f.mapping : j; - var v = n[k] !== undefined ? n[k] : f.defaultValue; - v = f.convert(v); - values[f.name] = v; - } - var record = new recordType(values, id); - record.json = n; - records[records.length] = record; + for(var i = 0; i < root.length; i++){ + var n = root[i]; + var values = {}; + var id = ((sid || sid === 0) && n[sid] !== undefined && n[sid] !== "" ? n[sid] : null); + for(var j = 0, jlen = fields.length; j < jlen; j++){ + var f = fields.items[j]; + var k = f.mapping !== undefined && f.mapping !== null ? f.mapping : j; + var v = n[k] !== undefined ? n[k] : f.defaultValue; + v = f.convert(v); + values[f.name] = v; } - return { - records : records, - totalRecords : records.length - }; + var record = new recordType(values, id); + record.json = n; + records[records.length] = record; + } + return { + records : records, + totalRecords : records.length + }; + }, + // used when loading children.. @see loadDataFromChildren + toLoadData: function(rec) + { + // expect rec just to be an array.. eg [a,b,c, [...] << cn ] + return typeof(rec.data.cn) == 'undefined' ? [] : rec.data.cn; + } + + });/* * Based on: * Ext JS Library 1.1.1 @@ -24853,6 +25075,7 @@ Roo.extend(Roo.data.Node, Roo.util.Observable, { }else if(arguments.length > 1){ multi = arguments; } + // if passed an array or multiple args do them one by one if(multi){ for(var i = 0, len = multi.length; i < len; i++) { @@ -24871,6 +25094,7 @@ Roo.extend(Roo.data.Node, Roo.util.Observable, { } oldParent.removeChild(node); } + index = this.childNodes.length; if(index == 0){ this.setFirstChild(node); @@ -24888,6 +25112,9 @@ Roo.extend(Roo.data.Node, Roo.util.Observable, { this.setLastChild(node); node.setOwnerTree(this.getOwnerTree()); this.fireEvent("append", this.ownerTree, this, node, index); + if(this.ownerTree) { + this.ownerTree.fireEvent("appendnode", this, node, index); + } if(oldParent){ node.fireEvent("move", this.ownerTree, node, oldParent, this, index); } @@ -33535,7 +33762,7 @@ Roo.QuickTips = function(){ if(ttp){ showProc = show.defer(tm.showDelay, tm, [{ el: t, - text: ttp, + text: ttp.replace(/\\n/g,'
'), width: et.getAttributeNS(ns, cfg.width), autoHide: et.getAttributeNS(ns, cfg.hide) != "user", title: et.getAttributeNS(ns, cfg.title), @@ -34125,7 +34352,15 @@ Roo.tree.TreePanel = function(el, config){ * * @param {Object} dragOverEvent */ - "nodedragover" : true + "nodedragover" : true, + /** + * @event appendnode + * Fires when append node to the tree + * @param {Roo.tree.TreePanel} this + * @param {Roo.tree.TreeNode} node + * @param {Number} index The index of the newly appended node + */ + "appendnode" : true }); if(this.singleExpand){ @@ -34703,7 +34938,7 @@ Roo.extend(Roo.tree.MultiSelectionModel, Roo.util.Observable, { * @cfg {Boolean} allowDrop false if this node cannot be drop on * @cfg {Boolean} disabled true to start the node disabled * @cfg {String} icon The path to an icon for the node. The preferred way to do this - * is to use the cls or iconCls attributes and add the icon via a CSS background image. + * is to use the cls or iconCls attributes and add the icon via a CSS background image. * @cfg {String} cls A css class to be added to the node * @cfg {String} iconCls A css class to be added to the nodes icon element for applying css background images * @cfg {String} href URL of the link used for the node (defaults to #) @@ -34986,7 +35221,8 @@ Roo.extend(Roo.tree.TreeNode, Roo.data.Node, { this.renderChildren(); } this.expanded = true; - if(!this.isHiddenRoot() && (this.getOwnerTree().animate && anim !== false) || anim){ + + if(!this.isHiddenRoot() && (this.getOwnerTree() && this.getOwnerTree().animate && anim !== false) || anim){ this.ui.animExpand(function(){ this.fireEvent("expand", this); if(typeof callback == "function"){ @@ -35437,7 +35673,7 @@ Roo.tree.TreeNodeUI.prototype = { this.addClass("x-tree-node-disabled"); } var ot = this.node.getOwnerTree(); - var dd = ot.enableDD || ot.enableDrag || ot.enableDrop; + var dd = ot ? (ot.enableDD || ot.enableDrag || ot.enableDrop) : false; if(dd && (!this.node.isRoot || ot.rootVisible)){ Roo.dd.Registry.register(this.elNode, { node: this.node, @@ -35680,11 +35916,11 @@ Roo.tree.TreeNodeUI.prototype = { // add some indent caching, this helps performance when rendering a large tree this.indentMarkup = n.parentNode ? n.parentNode.ui.getChildIndent() : ''; var t = n.getOwnerTree(); - var txt = t.renderer ? t.renderer(n.attributes) : Roo.util.Format.htmlEncode(n.text); + var txt = t && t.renderer ? t.renderer(n.attributes) : Roo.util.Format.htmlEncode(n.text); if (typeof(n.attributes.html) != 'undefined') { txt = n.attributes.html; } - var tip = t.rendererTip ? t.rendererTip(n.attributes) : txt; + var tip = t && t.rendererTip ? t.rendererTip(n.attributes) : txt; var cb = typeof a.checked == 'boolean'; var href = a.href ? a.href : Roo.isGecko ? "" : "#"; var buf = ['
  • ', @@ -35870,7 +36106,9 @@ Roo.extend(Roo.tree.RootTreeNodeUI, Roo.tree.TreeNodeUI, { myTreeLoader.on("beforeload", function(treeLoader, node) { this.baseParams.category = node.attributes.category; }, this); -< + + + * * This would pass an HTTP parameter called "category" to the server containing * the value of the Node's "category" attribute. * @constructor @@ -37075,7 +37313,9 @@ Roo.extend(Roo.tree.ColumnTree, Roo.tree.TreePanel, { * @param {Object} config Configuration options */ Roo.menu.Menu = function(config){ - Roo.apply(this, config); + + Roo.menu.Menu.superclass.constructor.call(this, config); + this.id = this.id || Roo.id(); this.addEvents({ /** @@ -38556,6 +38796,69 @@ Roo.extend(Roo.menu.ColorMenu, Roo.menu.Menu);/* *