X-Git-Url: http://git.roojs.org/?p=roojs1;a=blobdiff_plain;f=roojs-debug.js;h=130983fd41fb57aacdeb475236577cb9a4064767;hp=0c1a5eb07251ab8bdfa000a4e67ef8a9a626e939;hb=refs%2Fheads%2Fwip_alan_T6102_issue_with_word_clean;hpb=47bb3b5d454df077af73b205449dbd4481d22283 diff --git a/roojs-debug.js b/roojs-debug.js index 0c1a5eb072..130983fd41 100644 --- a/roojs-debug.js +++ b/roojs-debug.js @@ -25002,6 +25002,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++) { @@ -25020,6 +25021,7 @@ Roo.extend(Roo.data.Node, Roo.util.Observable, { } oldParent.removeChild(node); } + index = this.childNodes.length; if(index == 0){ this.setFirstChild(node); @@ -25037,6 +25039,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); } @@ -34274,7 +34279,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){ @@ -35135,7 +35148,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"){ @@ -35586,7 +35600,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, @@ -35829,11 +35843,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 = ['
  • ', @@ -39427,6 +39441,10 @@ Roo.extend(Roo.form.TextField, Roo.form.Field, { * @cfg {Boolean} selectOnFocus True to automatically select any existing field text when the field receives input focus (defaults to false) */ selectOnFocus : false, + /** + * @cfg {Boolean} allowLeadingSpace True to prevent the stripping of leading white space + */ + allowLeadingSpace : false, /** * @cfg {String} blankText Error text to display if the allow blank validation fails (defaults to "This field is required") */ @@ -39471,8 +39489,11 @@ Roo.extend(Roo.form.TextField, Roo.form.Field, { if(this.selectOnFocus){ this.on("focus", this.preFocus, this); - } + if (!this.allowLeadingSpace) { + this.on('blur', this.cleanLeadingSpace, this); + } + if(this.maskRe || (this.vtype && this.disableKeyFilter !== true && (this.maskRe = Roo.form.VTypes[this.vtype+'Mask']))){ this.el.on("keypress", this.filterKeys, this); } @@ -39508,7 +39529,15 @@ Roo.extend(Roo.form.TextField, Roo.form.Field, { this.autoSize(); } }, - + // private - clean the leading white space + cleanLeadingSpace : function(e) + { + if ( this.inputType == 'file') { + return; + } + + this.setValue((this.getValue() + '').replace(/^\s+/,'')); + }, /** * Resets the current field value to the originally-loaded value and clears any validation messages. * @@ -39516,9 +39545,7 @@ Roo.extend(Roo.form.TextField, Roo.form.Field, { reset : function(){ Roo.form.TextField.superclass.reset.call(this); - }, - - + }, // private preFocus : function(){ @@ -40270,7 +40297,8 @@ Roo.extend(Roo.form.NumberField, Roo.form.TextField, { * Create a new DateField * @param {Object} config */ -Roo.form.DateField = function(config){ +Roo.form.DateField = function(config) +{ Roo.form.DateField.superclass.constructor.call(this, config); this.addEvents({ @@ -40618,7 +40646,13 @@ dateField.setValue('2006-5-4'); return String(this.getValue()) !== String(this.startValue); + }, + // @overide + cleanLeadingSpace : function(e) + { + return; } + });/* * Based on: * Ext JS Library 1.1.1 @@ -42092,7 +42126,7 @@ Roo.extend(Roo.form.ComboBox, Roo.form.TriggerField, { this.view.select(match); var sn = Roo.get(this.view.getSelectedNodes()[0]); sn.scrollIntoView(sn.dom.parentNode, false); - } + } /** * @cfg {Boolean} grow @@ -42227,7 +42261,7 @@ Roo.extend(Roo.form.ComboBoxArray, Roo.form.TextField, // give fake names to child combo; this.combo.hiddenName = this.hiddenName ? (this.hiddenName+'-subcombo') : this.hiddenName; - this.combo.name = this.name? (this.name+'-subcombo') : this.name; + this.combo.name = this.name ? (this.name+'-subcombo') : this.name; this.combo = Roo.factory(this.combo, Roo.form); this.combo.onRender(ct, position); @@ -42348,6 +42382,7 @@ Roo.extend(Roo.form.ComboBoxArray, Roo.form.TextField, { var valueField = this.combo.valueField; var displayField = this.combo.displayField; + if (this.items.indexOfKey(rec[valueField]) > -1) { //console.log("GOT " + rec.data.id); return; @@ -42379,7 +42414,6 @@ Roo.extend(Roo.form.ComboBoxArray, Roo.form.TextField, this.items.each(function(f) { ar.push(f.data[idField]); - }); this.hiddenEl.dom.value = ar.join(','); this.validate(); @@ -42405,11 +42439,9 @@ Roo.extend(Roo.form.ComboBoxArray, Roo.form.TextField, }, setValue: function(v) // not a valid action - must use addItems.. { - - this.reset(); - - + this.reset(); + if (this.store.isLocal && (typeof(v) == 'string')) { // then we can use the store to find the values.. // comma seperated at present.. this needs to allow JSON based encoding.. @@ -43216,17 +43248,32 @@ Roo.extend(Roo.HtmlEditorCore, Roo.Component, { html = this.cleanHtml(html); // fix up the special chars.. normaly like back quotes in word... // however we do not want to do this with chinese.. - html = html.replace(/([\x80-\uffff])/g, function (a, b) { - var cc = b.charCodeAt(); - if ( + html = html.replace(/[\uD800-\uDBFF][\uDC00-\uDFFF]|[\u0080-\uFFFF]/g, function(match) { + + var cc = match.charCodeAt(); + + // Get the character value, handling surrogate pairs + if (match.length == 2) { + // It's a surrogate pair, calculate the Unicode code point + var high = match.charCodeAt(0) - 0xD800; + var low = match.charCodeAt(1) - 0xDC00; + cc = (high * 0x400) + low + 0x10000; + } else if ( (cc >= 0x4E00 && cc < 0xA000 ) || (cc >= 0x3400 && cc < 0x4E00 ) || (cc >= 0xf900 && cc < 0xfb00 ) ) { - return b; - } - return "&#"+cc+";" + return match; + } + + // No, use a numeric entity. Here we brazenly (and possibly mistakenly) + return "&#" + cc + ";"; + + }); + + + if(this.owner.fireEvent('beforesync', this, html) !== false){ this.el.dom.value = html; this.owner.fireEvent('sync', this, html); @@ -43906,6 +43953,11 @@ Roo.extend(Roo.HtmlEditorCore, Roo.Component, { var remove_keep_children= Roo.HtmlEditorCore.remove.indexOf(node.tagName.toLowerCase()) > -1; + // spans with no attributes - just remove them.. + if ((!node.attributes || !node.attributes.length) && lcname == 'span') { + remove_keep_children = true; + } + // remove as rendering on yahoo mailer is borked with this. // this will have to be flaged elsewhere - perhaps ablack=name... on the mailer.. @@ -43926,6 +43978,10 @@ Roo.extend(Roo.HtmlEditorCore, Roo.Component, { } if (!node.attributes || !node.attributes.length) { + + + + this.cleanUpChildren(node); return; } @@ -44022,11 +44078,11 @@ Roo.extend(Roo.HtmlEditorCore, Roo.Component, { if (a.name == 'class') { if (a.value.match(/^Mso/)) { - node.className = ''; + node.removeAttribute('class'); } if (a.value.match(/^body$/)) { - node.className = ''; + node.removeAttribute('class'); } continue; } @@ -44047,12 +44103,29 @@ Roo.extend(Roo.HtmlEditorCore, Roo.Component, { */ cleanWord : function(node) { - - if (!node) { this.cleanWord(this.doc.body); return; } + + if( + node.nodeName == 'SPAN' && + !node.hasAttributes() && + node.childNodes.length == 1 && + node.firstChild.nodeName == "#text" + ) { + var textNode = node.firstChild; + node.removeChild(textNode); + if (node.getAttribute('lang') != 'zh-CN') { // do not space pad on chinese characters.. + node.parentNode.insertBefore(node.ownerDocument.createTextNode(" "), node); + } + node.parentNode.insertBefore(textNode, node); + if (node.getAttribute('lang') != 'zh-CN') { // do not space pad on chinese characters.. + node.parentNode.insertBefore(node.ownerDocument.createTextNode(" ") , node); + } + node.parentNode.removeChild(node); + } + if (node.nodeName == "#text") { // clean up silly Windows -- stuff? return; @@ -44067,16 +44140,20 @@ Roo.extend(Roo.HtmlEditorCore, Roo.Component, { node.parentNode.removeChild(node); return; } - + //Roo.log(node.tagName); // remove - but keep children.. - if (node.tagName.toLowerCase().match(/^(meta|link|\\?xml:|st1:|o:|font)/)) { + if (node.tagName.toLowerCase().match(/^(meta|link|\\?xml:|st1:|o:|v:|font)/)) { + //Roo.log('-- removed'); while (node.childNodes.length) { var cn = node.childNodes[0]; node.removeChild(cn); node.parentNode.insertBefore(cn, node); + // move node to parent - and clean it.. + this.cleanWord(cn); } node.parentNode.removeChild(node); - this.iterateChildren(node, this.cleanWord); + /// no need to iterate chidlren = it's got none.. + //this.iterateChildren(node, this.cleanWord); return; } // clean styles @@ -45618,8 +45695,9 @@ Roo.apply(Roo.form.HtmlEditor.ToolbarStandard.prototype, { var c = Roo.get(editorcore.doc.body); c.select('[class]').each(function(s) { - s.dom.className = ''; + s.dom.removeAttribute('class'); }); + editorcore.cleanWord(); editorcore.syncValue(); }, tabIndex:-1 @@ -46811,6 +46889,8 @@ Roo.form.BasicForm = function(el, config){ this.initEl(el); } Roo.form.BasicForm.superclass.constructor.call(this); + + Roo.form.BasicForm.popover.apply(); }; Roo.extend(Roo.form.BasicForm, Roo.util.Observable, { @@ -46881,6 +46961,16 @@ Roo.extend(Roo.form.BasicForm, Roo.util.Observable, { * @type Boolean */ disableMask : false, + + /** + * @cfg {Boolean} errorMask (true|false) default false + */ + errorMask : false, + + /** + * @cfg {Number} maskOffset Default 100 + */ + maskOffset : 100, // private initEl : function(el){ @@ -46901,11 +46991,23 @@ Roo.extend(Roo.form.BasicForm, Roo.util.Observable, { */ isValid : function(){ var valid = true; + var target = false; this.items.each(function(f){ - if(!f.validate()){ - valid = false; - } + if(f.validate()){ + return; + } + + valid = false; + + if(!target && f.el.isVisible(true)){ + target = f; + } }); + + if(this.errorMask && !valid){ + Roo.form.BasicForm.popover.mask(this, target); + } + return valid; }, @@ -47253,7 +47355,7 @@ clientValidation Boolean Applies to submit only. Pass true to call fo return this; }, - + /** * Returns the fields in this form as an object with key/value pairs. If multiple fields exist with the same name * they are returned as an array. @@ -47268,6 +47370,17 @@ clientValidation Boolean Applies to submit only. Pass true to call fo }, this); } + // use formdata + if (typeof(FormData) != 'undefined' && asString !== true) { + var fd = (new FormData(this.el.dom)).entries(); + var ret = {}; + var ent = fd.next(); + while (!ent.done) { + ret[ent.value[0]] = ent.value[1]; // not sure how this will handle duplicates.. + ent = fd.next(); + }; + return ret; + } var fs = Roo.lib.Ajax.serializeForm(this.el.dom); @@ -47423,7 +47536,153 @@ clientValidation Boolean Applies to submit only. Pass true to call fo }); // back compat -Roo.BasicForm = Roo.form.BasicForm;/* +Roo.BasicForm = Roo.form.BasicForm; + +Roo.apply(Roo.form.BasicForm, { + + popover : { + + padding : 5, + + isApplied : false, + + isMasked : false, + + form : false, + + target : false, + + intervalID : false, + + maskEl : false, + + apply : function() + { + if(this.isApplied){ + return; + } + + this.maskEl = { + top : Roo.DomHelper.append(Roo.get(document.body), { tag: "div", cls:"x-dlg-mask roo-form-top-mask" }, true), + left : Roo.DomHelper.append(Roo.get(document.body), { tag: "div", cls:"x-dlg-mask roo-form-left-mask" }, true), + bottom : Roo.DomHelper.append(Roo.get(document.body), { tag: "div", cls:"x-dlg-mask roo-form-bottom-mask" }, true), + right : Roo.DomHelper.append(Roo.get(document.body), { tag: "div", cls:"x-dlg-mask roo-form-right-mask" }, true) + }; + + this.maskEl.top.enableDisplayMode("block"); + this.maskEl.left.enableDisplayMode("block"); + this.maskEl.bottom.enableDisplayMode("block"); + this.maskEl.right.enableDisplayMode("block"); + + Roo.get(document.body).on('click', function(){ + this.unmask(); + }, this); + + Roo.get(document.body).on('touchstart', function(){ + this.unmask(); + }, this); + + this.isApplied = true + }, + + mask : function(form, target) + { + this.form = form; + + this.target = target; + + if(!this.form.errorMask || !target.el){ + return; + } + + var scrollable = this.target.el.findScrollableParent() || this.target.el.findParent('div.x-layout-active-content', 100, true) || Roo.get(document.body); + + var ot = this.target.el.calcOffsetsTo(scrollable); + + var scrollTo = ot[1] - this.form.maskOffset; + + scrollTo = Math.min(scrollTo, scrollable.dom.scrollHeight); + + scrollable.scrollTo('top', scrollTo); + + var el = this.target.wrap || this.target.el; + + var box = el.getBox(); + + this.maskEl.top.setStyle('position', 'absolute'); + this.maskEl.top.setStyle('z-index', 10000); + this.maskEl.top.setSize(Roo.lib.Dom.getDocumentWidth(), box.y - this.padding); + this.maskEl.top.setLeft(0); + this.maskEl.top.setTop(0); + this.maskEl.top.show(); + + this.maskEl.left.setStyle('position', 'absolute'); + this.maskEl.left.setStyle('z-index', 10000); + this.maskEl.left.setSize(box.x - this.padding, box.height + this.padding * 2); + this.maskEl.left.setLeft(0); + this.maskEl.left.setTop(box.y - this.padding); + this.maskEl.left.show(); + + this.maskEl.bottom.setStyle('position', 'absolute'); + this.maskEl.bottom.setStyle('z-index', 10000); + this.maskEl.bottom.setSize(Roo.lib.Dom.getDocumentWidth(), Roo.lib.Dom.getDocumentHeight() - box.bottom - this.padding); + this.maskEl.bottom.setLeft(0); + this.maskEl.bottom.setTop(box.bottom + this.padding); + this.maskEl.bottom.show(); + + this.maskEl.right.setStyle('position', 'absolute'); + this.maskEl.right.setStyle('z-index', 10000); + this.maskEl.right.setSize(Roo.lib.Dom.getDocumentWidth() - box.right - this.padding, box.height + this.padding * 2); + this.maskEl.right.setLeft(box.right + this.padding); + this.maskEl.right.setTop(box.y - this.padding); + this.maskEl.right.show(); + + this.intervalID = window.setInterval(function() { + Roo.form.BasicForm.popover.unmask(); + }, 10000); + + window.onwheel = function(){ return false;}; + + (function(){ this.isMasked = true; }).defer(500, this); + + }, + + unmask : function() + { + if(!this.isApplied || !this.isMasked || !this.form || !this.target || !this.form.errorMask){ + return; + } + + this.maskEl.top.setStyle('position', 'absolute'); + this.maskEl.top.setSize(0, 0).setXY([0, 0]); + this.maskEl.top.hide(); + + this.maskEl.left.setStyle('position', 'absolute'); + this.maskEl.left.setSize(0, 0).setXY([0, 0]); + this.maskEl.left.hide(); + + this.maskEl.bottom.setStyle('position', 'absolute'); + this.maskEl.bottom.setSize(0, 0).setXY([0, 0]); + this.maskEl.bottom.hide(); + + this.maskEl.right.setStyle('position', 'absolute'); + this.maskEl.right.setSize(0, 0).setXY([0, 0]); + this.maskEl.right.hide(); + + window.onwheel = function(){ return true;}; + + if(this.intervalID){ + window.clearInterval(this.intervalID); + this.intervalID = false; + } + + this.isMasked = false; + + } + + } + +});/* * Based on: * Ext JS Library 1.1.1 * Copyright(c) 2006-2007, Ext JS, LLC. @@ -47491,8 +47750,6 @@ Roo.form.Form = function(config){ Roo.each(xitems, this.addxtype, this); - - }; Roo.extend(Roo.form.Form, Roo.form.BasicForm, { @@ -52372,7 +52629,7 @@ Roo.extend(Roo.LayoutRegion, Roo.BasicLayoutRegion, { * Collapses this region. * @param {Boolean} skipAnim (optional) true to collapse the element without animation (if animate is true) */ - collapse : function(skipAnim, skipCheck = false){ + collapse : function(skipAnim, skipCheck){ if(this.collapsed) { return; }