X-Git-Url: http://git.roojs.org/?a=blobdiff_plain;f=roojs-debug.js;h=f95b807da4da7f374eab9f9fe0fdc2b2bce9eb17;hb=ff355e12aa44d689f8536251642f2963c7abbf1e;hp=52f214f20efbaf3c75731aa21f1053face96f0fa;hpb=456d56f8dd548af35fe42dd47d66423d1b98805b;p=roojs1 diff --git a/roojs-debug.js b/roojs-debug.js index 52f214f20e..f95b807da4 100644 --- a/roojs-debug.js +++ b/roojs-debug.js @@ -5513,7 +5513,7 @@ Roo.DomHelper = function(){ if (typeof(o) == 'string') { return parentNode.appendChild(document.createTextNode(o)); } - o.tag = o.tag || div; + o.tag = o.tag || 'div'; if (o.ns && Roo.isIE) { ns = false; o.tag = o.ns + ':' + o.tag; @@ -16992,6 +16992,13 @@ Roo.extend(Roo.Component, Roo.util.Observable, { */ actionMode : "el", + /** + * @cfg {String} style + * css styles to add to component + * eg. text-align:right; + */ + style : false, + /** @private */ getActionEl : function(){ return this[this.actionMode]; @@ -45018,7 +45025,9 @@ Roo.extend(Roo.form.Checkbox, Roo.form.Field, { this.fireEvent('check', this, state); } this.inSetChecked = true; - this.el.dom.value = state ? this.inputValue : this.valueOff; + + this.el.dom.value = state ? this.inputValue : this.valueOff; + this.inSetChecked = false; }, @@ -45109,9 +45118,49 @@ Roo.extend(Roo.form.Radio, Roo.form.Checkbox, { this.el.dom.checked = 'checked' ; } + }, + /** + * Sets the checked state of the checkbox. + * On is always based on a string comparison between inputValue and the param. + * @param {Boolean/String} value - the value to set + * @param {Boolean/String} suppressEvent - whether to suppress the checkchange event. + */ + setValue : function(v,suppressEvent){ + + + //this.checked = (v === true || v === 'true' || v == '1' || String(v).toLowerCase() == 'on'); + //if(this.el && this.el.dom){ + // this.el.dom.checked = this.checked; + // this.el.dom.defaultChecked = this.checked; + //} + this.setChecked(String(v) === String(this.inputValue), suppressEvent); + + this.el.dom.form[this.name].value = v; + + //this.fireEvent("check", this, this.checked); + }, + // private.. + setChecked : function(state,suppressEvent) + { + + if(this.wrap){ + this.wrap[state ? 'addClass' : 'removeClass']('x-menu-item-checked'); + } + this.checked = state; + if(suppressEvent !== true){ + this.fireEvent('check', this, state); + } + + + + + }, + reset : function(){ + // this.setValue(this.resetValue); + //this.originalValue = this.getValue(); + this.clearInvalid(); } - });Roo.rtf = {}; // namespace Roo.rtf.Hex = function(hex) { @@ -45672,6 +45721,21 @@ Roo.htmleditor.Filter.prototype = { }, this); + }, + + + removeNodeKeepChildren : function( node) + { + + ar = Array.from(node.childNodes); + for (var i = 0; i < ar.length; i++) { + + node.removeChild(ar[i]); + // what if we need to walk these??? + node.parentNode.insertBefore(ar[i], node); + + } + node.parentNode.removeChild(node); } }; @@ -45884,25 +45948,36 @@ Roo.htmleditor.FilterKeepChildren = function(cfg) if (this.tag === false) { return; // dont walk.. (you can use this to use this just to do a child removal on a single tag ) } + // hacky? + if ((typeof(this.tag) == 'object' && this.tag.indexOf(":") > -1)) { + this.cleanNamespace = true; + } + this.walk(cfg.node); } Roo.extend(Roo.htmleditor.FilterKeepChildren, Roo.htmleditor.FilterBlack, { - + cleanNamespace : false, // should really be an option, rather than using ':' inside of this tag. replaceTag : function(node) { // walk children... - //Roo.log(node); + //Roo.log(node.tagName); var ar = Array.from(node.childNodes); //remove first.. + for (var i = 0; i < ar.length; i++) { - if (ar[i].nodeType == 1) { + var e = ar[i]; + if (e.nodeType == 1) { if ( - (typeof(this.tag) == 'object' && this.tag.indexOf(ar[i].tagName) > -1) + (typeof(this.tag) == 'object' && this.tag.indexOf(e.tagName) > -1) || // array and it matches - (typeof(this.tag) == 'string' && this.tag == ar[i].tagName) + (typeof(this.tag) == 'string' && this.tag == e.tagName) + || + (e.tagName.indexOf(":") > -1 && typeof(this.tag) == 'object' && this.tag.indexOf(":") > -1) + || + (e.tagName.indexOf(":") > -1 && typeof(this.tag) == 'string' && this.tag == ":") ) { this.replaceTag(ar[i]); // child is blacklisted as well... continue; @@ -45920,6 +45995,7 @@ Roo.extend(Roo.htmleditor.FilterKeepChildren, Roo.htmleditor.FilterBlack, } } + //Roo.log("REMOVE:" + node.tagName); node.parentNode.removeChild(node); return false; // don't walk children @@ -46081,6 +46157,7 @@ Roo.htmleditor.FilterWord = function(cfg) // no need to apply config. this.replaceDocBullets(cfg.node); + this.replaceAname(cfg.node); // this is disabled as the removal is done by other filters; // this.walk(cfg.node); @@ -46208,21 +46285,82 @@ Roo.extend(Roo.htmleditor.FilterWord, Roo.htmleditor.Filter, }, + replaceAname : function (doc) + { + // replace all the a/name without.. + var aa = Array.from(doc.getElementsByTagName('a')); + for (var i = 0; i < aa.length; i++) { + var a = aa[i]; + if (a.hasAttribute("name")) { + a.removeAttribute("name"); + } + if (a.hasAttribute("href")) { + continue; + } + // reparent children. + this.removeNodeKeepChildren(a); + + } + + + + }, + + + replaceDocBullets : function(doc) { // this is a bit odd - but it appears some indents use ql-indent-1 + //Roo.log(doc.innerHTML); - var listpara = doc.getElementsByClassName('ql-indent-1'); - while(listpara.length) { - this.replaceDocBullet(listpara.item(0)); + var listpara = Array.from(doc.getElementsByClassName('MsoListParagraphCxSpFirst')); + for( var i = 0; i < listpara.length; i ++) { + listpara[i].className = "MsoListParagraph"; + } + + listpara = Array.from(doc.getElementsByClassName('MsoListParagraphCxSpMiddle')); + for( var i = 0; i < listpara.length; i ++) { + listpara[i].className = "MsoListParagraph"; + } + listpara = Array.from(doc.getElementsByClassName('MsoListParagraphCxSpLast')); + for( var i = 0; i < listpara.length; i ++) { + listpara[i].className = "MsoListParagraph"; } + listpara = Array.from(doc.getElementsByClassName('ql-indent-1')); + for( var i = 0; i < listpara.length; i ++) { + listpara[i].className = "MsoListParagraph"; + } + + // this is a bit hacky - we had one word document where h2 had a miso-list attribute. + var htwo = Array.from(doc.getElementsByTagName('h2')); + for( var i = 0; i < htwo.length; i ++) { + if (htwo[i].hasAttribute('style') && htwo[i].getAttribute('style').match(/mso-list:/)) { + htwo[i].className = "MsoListParagraph"; + } + } + listpara = Array.from(doc.getElementsByClassName('MsoNormal')); + for( var i = 0; i < listpara.length; i ++) { + if (listpara[i].hasAttribute('style') && listpara[i].getAttribute('style').match(/mso-list:/)) { + listpara[i].className = "MsoListParagraph"; + } else { + listpara[i].className = "MsoNormalx"; + } + } + + listpara = doc.getElementsByClassName('MsoListParagraph'); + // Roo.log(doc.innerHTML); + + - var listpara = doc.getElementsByClassName('MsoListParagraph'); while(listpara.length) { + this.replaceDocBullet(listpara.item(0)); } + }, + + replaceDocBullet : function(p) { // gather all the siblings. @@ -46231,7 +46369,7 @@ Roo.extend(Roo.htmleditor.FilterWord, Roo.htmleditor.Filter, doc = parent.ownerDocument, items = []; - + var listtype = 'ul'; while (ns) { if (ns.nodeType != 1) { ns = ns.nextSibling; @@ -46240,30 +46378,68 @@ Roo.extend(Roo.htmleditor.FilterWord, Roo.htmleditor.Filter, if (!ns.className.match(/(MsoListParagraph|ql-indent-1)/i)) { break; } + var spans = ns.getElementsByTagName('span'); + if (ns.hasAttribute('style') && ns.getAttribute('style').match(/mso-list/)) { + items.push(ns); + ns = ns.nextSibling; + has_list = true; + if (spans.length && spans[0].hasAttribute('style')) { + var style = this.styleToObject(spans[0]); + if (typeof(style['font-family']) != 'undefined' && !style['font-family'].match(/Symbol/)) { + listtype = 'ol'; + } + } + + continue; + } + var spans = ns.getElementsByTagName('span'); + if (!spans.length) { + break; + } + var has_list = false; + for(var i = 0; i < spans.length; i++) { + if (spans[i].hasAttribute('style') && spans[i].getAttribute('style').match(/mso-list/)) { + has_list = true; + break; + } + } + if (!has_list) { + break; + } items.push(ns); ns = ns.nextSibling; + + + } + if (!items.length) { + ns.className = ""; + return; } - - var ul = parent.ownerDocument.createElement('ul'); // what about number lists... + var ul = parent.ownerDocument.createElement(listtype); // what about number lists... parent.insertBefore(ul, p); var lvl = 0; var stack = [ ul ]; var last_li = false; + var margin_to_depth = {}; + max_margins = -1; + items.forEach(function(n, ipos) { //Roo.log("got innertHMLT=" + n.innerHTML); var spans = n.getElementsByTagName('span'); if (!spans.length) { //Roo.log("No spans found"); - + parent.removeChild(n); + + return; // skip it... } - + var num = 1; var style = {}; for(var i = 0; i < spans.length; i++) { @@ -46271,7 +46447,9 @@ Roo.extend(Roo.htmleditor.FilterWord, Roo.htmleditor.Filter, if (typeof(style['mso-list']) == 'undefined') { continue; } - + if (listtype == 'ol') { + num = spans[i].innerText.replace(/[^0-9]+]/g,'') * 1; + } spans[i].parentNode.removeChild(spans[i]); // remove the fake bullet. break; } @@ -46279,35 +46457,44 @@ Roo.extend(Roo.htmleditor.FilterWord, Roo.htmleditor.Filter, style = this.styleToObject(n); // mo-list is from the parent node. if (typeof(style['mso-list']) == 'undefined') { //Roo.log("parent is missing level"); + parent.removeChild(n); + return; } - var nlvl = (style['mso-list'].split(' ')[1].replace(/level/,'') *1) - 1 ; - - - + var margin = style['margin-left']; + if (typeof(margin_to_depth[margin]) == 'undefined') { + max_margins++; + margin_to_depth[margin] = max_margins; + } + nlvl = margin_to_depth[margin] ; + if (nlvl > lvl) { //new indent - var nul = doc.createElement('ul'); // what about number lists... + var nul = doc.createElement(listtype); // what about number lists... + if (!last_li) { + last_li = doc.createElement('li'); + stack[lvl].appendChild(last_li); + } last_li.appendChild(nul); stack[nlvl] = nul; } lvl = nlvl; + // not starting at 1.. + if (!stack[nlvl].hasAttribute("start") && listtype == "ol") { + stack[nlvl].setAttribute("start", num); + } + var nli = stack[nlvl].appendChild(doc.createElement('li')); last_li = nli; nli.innerHTML = n.innerHTML; //Roo.log("innerHTML = " + n.innerHTML); parent.removeChild(n); - // copy children of p into nli - /*while(n.firstChild) { - var fc = n.firstChild; - n.removeChild(fc); - nli.appendChild(fc); - }*/ + },this); @@ -49259,7 +49446,6 @@ Roo.extend(Roo.htmleditor.BlockTd, Roo.htmleditor.Block, { */ toObject : function() { - var ret = { tag : 'td', contenteditable : 'true', // this stops cell selection from picking the table. @@ -49300,6 +49486,9 @@ Roo.extend(Roo.htmleditor.BlockTd, Roo.htmleditor.Block, { this.colspan = Math.max(1,1*node.getAttribute('colspan')); this.rowspan = Math.max(1,1*node.getAttribute('rowspan')); this.html = node.innerHTML; + if (node.style.textAlign != '') { + this.textAlign = node.style.textAlign; + } }, @@ -49357,7 +49546,7 @@ Roo.extend(Roo.htmleditor.BlockTd, Roo.htmleditor.Block, { c.col = cn; } - if (typeof(this.colWidths[cn]) == 'undefined') { + if (typeof(this.colWidths[cn]) == 'undefined' && c.colspan < 2) { this.colWidths[cn] = ce.style.width; if (this.colWidths[cn] != '') { all_auto = false; @@ -49426,6 +49615,9 @@ Roo.extend(Roo.htmleditor.BlockTd, Roo.htmleditor.Block, { this.colspan += rc.colspan; this.node.setAttribute('colspan', this.colspan); + var table = this.toTableArray(); + this.normalizeWidths(table); + this.updateWidths(table); }, @@ -49460,19 +49652,17 @@ Roo.extend(Roo.htmleditor.BlockTd, Roo.htmleditor.Block, { this.colspan = 1; for(var r = cd.row; r < cd.row + cd.rowspan; r++) { - - + for(var c = cd.col; c < cd.col + cd.colspan; c++) { if (r == cd.row && c == cd.col) { this.node.removeAttribute('rowspan'); this.node.removeAttribute('colspan'); - continue; } var ntd = this.node.cloneNode(); // which col/row should be 0.. - ntd.removeAttribute('id'); // - //ntd.style.width = ''; + ntd.removeAttribute('id'); + ntd.style.width = this.colWidths[c]; ntd.innerHTML = ''; table[r][c] = { cell : ntd, col : c, row: r , colspan : 1 , rowspan : 1 }; } @@ -49480,8 +49670,6 @@ Roo.extend(Roo.htmleditor.BlockTd, Roo.htmleditor.Block, { } this.redrawAllCells(table); - - }, @@ -49530,13 +49718,21 @@ Roo.extend(Roo.htmleditor.BlockTd, Roo.htmleditor.Block, { el.width = Math.floor(this.colWidths[c]) +'%'; el.updateElement(el.node); } + if (this.colWidths[0] != false && table[r][c].colspan > 1) { + var el = Roo.htmleditor.Block.factory(table[r][c].cell); + var width = 0; + for(var i = 0; i < table[r][c].colspan; i ++) { + width += Math.floor(this.colWidths[c + i]); + } + el.width = width +'%'; + el.updateElement(el.node); + } table[r][c].cell = false; // done } } }, normalizeWidths : function(table) { - if (this.colWidths[0] === false) { var nw = 100.0 / this.colWidths.length; this.colWidths.forEach(function(w,i) { @@ -50046,11 +50242,42 @@ Roo.extend(Roo.HtmlEditorCore, Roo.Component, { if (this.enableBlocks) { new Roo.htmleditor.FilterBlock({ node : div }); } + + var html = div.innerHTML; + //?? tidy? - var tidy = new Roo.htmleditor.TidySerializer({ - inner: true - }); - var html = tidy.serialize(div); + if (this.autoClean) { + + new Roo.htmleditor.FilterAttributes({ + node : div, + attrib_white : [ + 'href', + 'src', + 'name', + 'align', + 'colspan', + 'rowspan', + 'data-display', + 'data-width', + 'start' , + 'style', + // youtube embed. + 'class', + 'allowfullscreen', + 'frameborder', + 'width', + 'height', + 'alt' + ], + attrib_clean : ['href', 'src' ] + }); + + var tidy = new Roo.htmleditor.TidySerializer({ + inner: true + }); + html = tidy.serialize(div); + + } if(Roo.isSafari){ @@ -50264,7 +50491,7 @@ Roo.extend(Roo.HtmlEditorCore, Roo.Component, { .map(function(g) { return g.toDataURL(); }) .filter(function(g) { return g != 'about:blank'; }); - + //Roo.log(html); html = this.cleanWordChars(html); var d = (new DOMParser().parseFromString(html, 'text/html')).body; @@ -50282,7 +50509,17 @@ Roo.extend(Roo.HtmlEditorCore, Roo.Component, { return false; } + + if (images.length > 0) { + // replace all v:imagedata - with img. + var ar = Array.from(d.getElementsByTagName('v:imagedata')); + Roo.each(ar, function(node) { + node.parentNode.insertBefore(d.ownerDocument.createElement('img'), node ); + node.parentNode.removeChild(node); + }); + + Roo.each(d.getElementsByTagName('img'), function(img, i) { img.setAttribute('src', images[i]); }); @@ -50293,7 +50530,7 @@ Roo.extend(Roo.HtmlEditorCore, Roo.Component, { new Roo.htmleditor.FilterStyleToTag({ node : d }); new Roo.htmleditor.FilterAttributes({ node : d, - attrib_white : ['href', 'src', 'name', 'align', 'colspan', 'rowspan', 'data-display', 'data-width'], + attrib_white : ['href', 'src', 'name', 'align', 'colspan', 'rowspan', 'data-display', 'data-width', 'start'], attrib_clean : ['href', 'src' ] }); new Roo.htmleditor.FilterBlack({ node : d, tag : this.black}); @@ -54095,6 +54332,9 @@ clientValidation Boolean Applies to submit only. Pass true to call fo for(id in values){ if(typeof values[id] != 'function' && (field = this.findField(id))){ + + + if (field.setFromData && field.valueField && field.displayField && @@ -54109,6 +54349,9 @@ clientValidation Boolean Applies to submit only. Pass true to call fo sd[field.displayField] = typeof(values[field.name]) == 'undefined' ? '' : values[field.name]; field.setFromData(sd); + } else if (field.inputType && field.inputType == 'radio') { + + field.setValue(values[id]); } else { field.setValue(values[id]); } @@ -54134,7 +54377,7 @@ clientValidation Boolean Applies to submit only. Pass true to call fo /** * 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. - * @param {Boolean} asString + * @param {Boolean} asString (def) * @return {Object} */ getValues : function(asString) @@ -55214,7 +55457,13 @@ Roo.extend(Roo.form.Action.Submit, Roo.form.Action, { } var ret = false; try { - ret = Roo.decode(response.responseText); + var rt = response.responseText; + if (rt.match(/^\