X-Git-Url: http://git.roojs.org/?a=blobdiff_plain;f=roojs-ui-debug.js;h=d9cf68f9bf49ec8f367ea7c66ad6f68bda852e15;hb=248c5cdd0fe1c3012360d530f5fd34ef516a79fb;hp=e76a862c52a965d2aa5c7cd698eef65f10b86762;hpb=89b03a0009ad29be68bd417551948042c2b146b3;p=roojs1 diff --git a/roojs-ui-debug.js b/roojs-ui-debug.js index e76a862c52..d9cf68f9bf 100644 --- a/roojs-ui-debug.js +++ b/roojs-ui-debug.js @@ -481,8 +481,8 @@ Roo.data.Store = function(config){ * If you return Json { data: [] , success: false, .... } then this will be thrown with the following args * * @param {Proxy} - * @param {Object} return from JsonData.reader() - success, totalRecords, records - * @param {Object} load options + * @param {Object} ret return data from JsonData.reader() - success, totalRecords, records + * @param {Object} opts - load Options * @param {Object} jsonData from your request (normally this contains the Exception) */ loadexception : true @@ -1488,24 +1488,24 @@ Roo.extend(Roo.data.HttpProxy, Roo.data.DataProxy, { // thse are take from connection... /** - * @cfg {String} url (Optional) The default URL to be used for requests to the server. (defaults to undefined) + * @cfg {String} url The default URL to be used for requests to the server. (defaults to undefined) */ /** - * @cfg {Object} extraParams (Optional) An object containing properties which are used as + * @cfg {Object} extraParams An object containing properties which are used as * extra parameters to each request made by this object. (defaults to undefined) */ /** - * @cfg {Object} defaultHeaders (Optional) An object containing request headers which are added + * @cfg {Object} defaultHeaders An object containing request headers which are added * to each request made by this object. (defaults to undefined) */ /** - * @cfg {String} method (Optional) The default HTTP method to be used for requests. (defaults to undefined; if not set but parms are present will use POST, otherwise GET) + * @cfg {String} method (GET|POST) The default HTTP method to be used for requests. (defaults to undefined; if not set but parms are present will use POST, otherwise GET) */ /** - * @cfg {Number} timeout (Optional) The timeout in milliseconds to be used for requests. (defaults to 30000) + * @cfg {Number} timeout The timeout in milliseconds to be used for requests. (defaults to 30000) */ /** - * @cfg {Boolean} autoAbort (Optional) Whether this request should abort any pending requests. (defaults to false) + * @cfg {Boolean} autoAbort Whether this request should abort any pending requests. (defaults to false) * @type Boolean */ @@ -20526,7 +20526,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; }, @@ -20617,9 +20619,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) { @@ -21619,7 +21661,7 @@ Roo.htmleditor.FilterWord = function(cfg) this.replaceAname(cfg.node); // this is disabled as the removal is done by other filters; // this.walk(cfg.node); - + this.replaceImageTable(cfg.node); } @@ -21772,44 +21814,44 @@ Roo.extend(Roo.htmleditor.FilterWord, Roo.htmleditor.Filter, // this is a bit odd - but it appears some indents use ql-indent-1 //Roo.log(doc.innerHTML); - var listpara = doc.getElementsByClassName('MsoListParagraphCxSpFirst'); + var listpara = Array.from(doc.getElementsByClassName('MsoListParagraphCxSpFirst')); for( var i = 0; i < listpara.length; i ++) { - listpara.item(i).className = "MsoListParagraph"; + listpara[i].className = "MsoListParagraph"; } - listpara = doc.getElementsByClassName('MsoListParagraphCxSpMiddle'); + listpara = Array.from(doc.getElementsByClassName('MsoListParagraphCxSpMiddle')); for( var i = 0; i < listpara.length; i ++) { - listpara.item(i).className = "MsoListParagraph"; + listpara[i].className = "MsoListParagraph"; } - listpara = doc.getElementsByClassName('MsoListParagraphCxSpLast'); + listpara = Array.from(doc.getElementsByClassName('MsoListParagraphCxSpLast')); for( var i = 0; i < listpara.length; i ++) { - listpara.item(i).className = "MsoListParagraph"; + listpara[i].className = "MsoListParagraph"; } - listpara = doc.getElementsByClassName('ql-indent-1'); + listpara = Array.from(doc.getElementsByClassName('ql-indent-1')); for( var i = 0; i < listpara.length; i ++) { - listpara.item(i).className = "MsoListParagraph"; + listpara[i].className = "MsoListParagraph"; } // this is a bit hacky - we had one word document where h2 had a miso-list attribute. - var htwo = doc.getElementsByTagName('h2'); + var htwo = Array.from(doc.getElementsByTagName('h2')); for( var i = 0; i < htwo.length; i ++) { - if (htwo.item(i).hasAttribute('style') && htwo.item(i).getAttribute('style').match(/mso-list:/)) { - htwo.item(i).className = "MsoListParagraph"; + if (htwo[i].hasAttribute('style') && htwo[i].getAttribute('style').match(/mso-list:/)) { + htwo[i].className = "MsoListParagraph"; } } - listpara = doc.getElementsByClassName('MsoNormal'); - while(listpara.length) { - if (listpara.item(0).hasAttribute('style') && listpara.item(0).getAttribute('style').match(/mso-list:/)) { - listpara.item(0).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.item(0).className = "MsoNormalx"; + listpara[i].className = "MsoNormalx"; } } listpara = doc.getElementsByClassName('MsoListParagraph'); + // Roo.log(doc.innerHTML); - //Roo.log(doc.innerHTML); while(listpara.length) { @@ -21827,7 +21869,8 @@ Roo.extend(Roo.htmleditor.FilterWord, Roo.htmleditor.Filter, parent = p.parentNode, doc = parent.ownerDocument, items = []; - + + //Roo.log("Parsing: " + p.innerText) ; var listtype = 'ul'; while (ns) { if (ns.nodeType != 1) { @@ -21835,22 +21878,38 @@ Roo.extend(Roo.htmleditor.FilterWord, Roo.htmleditor.Filter, continue; } if (!ns.className.match(/(MsoListParagraph|ql-indent-1)/i)) { + //Roo.log("Missing para r q1indent - got:" + ns.className); 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'; + if (!spans.length) { + continue; + } + var ff = ''; + var se = spans[0]; + for (var i = 0; i < spans.length;i++) { + se = spans[i]; + if (se.hasAttribute('style') && se.hasAttribute('style') && se.style.fontFamily != '') { + ff = se.style.fontFamily; + break; } } + + + //Roo.log("got font family: " + ff); + if (typeof(ff) != 'undefined' && !ff.match(/(Symbol|Wingdings)/) && "·o".indexOf(se.innerText.trim()) < 0) { + listtype = 'ol'; + } continue; } + //Roo.log("no mso-list?"); + var spans = ns.getElementsByTagName('span'); if (!spans.length) { break; @@ -21943,7 +22002,7 @@ Roo.extend(Roo.htmleditor.FilterWord, Roo.htmleditor.Filter, lvl = nlvl; // not starting at 1.. - if (!stack[nlvl].hasAttribute("start") && num > 1) { + if (!stack[nlvl].hasAttribute("start") && listtype == "ol") { stack[nlvl].setAttribute("start", num); } @@ -21961,9 +22020,63 @@ Roo.extend(Roo.htmleditor.FilterWord, Roo.htmleditor.Filter, - } - + }, + replaceImageTable : function(doc) + { + /* + + + + + + + + +
+ */ + var imgs = Array.from(doc.getElementsByTagName('img')); + Roo.each(imgs, function(img) { + var td = img.parentNode; + if (td.nodeName != 'TD') { + return; + } + var tr = td.parentNode; + if (tr.nodeName != 'TR') { + return; + } + var tbody = tr.parentNode; + if (tbody.nodeName != 'TBODY') { + return; + } + var table = tbody.parentNode; + if (table.nodeName != 'TABLE') { + return; + } + // first row.. + + if (table.getElementsByTagName('tr').length != 2) { + return; + } + if (table.getElementsByTagName('td').length != 3) { + return; + } + if (table.innerText.trim() != '') { + return; + } + var p = table.parentNode; + img.parentNode.removeChild(img); + p.insertBefore(img, table); + p.removeChild(table); + + + + }); + + + } }); /** @@ -23881,7 +23994,7 @@ Roo.extend(Roo.htmleditor.BlockFigure, Roo.htmleditor.Block, { } }, - + { xtype : 'Button', text: 'Hide Caption', @@ -25420,10 +25533,9 @@ Roo.extend(Roo.HtmlEditorCore, Roo.Component, { owner : false, /** - * @cfg {String} resizable 's' or 'se' or 'e' - wrapps the element in a - * Roo.resizable. + * @cfg {String} css styling for resizing. (used on bootstrap only) */ - resizable : false, + resize : false, /** * @cfg {Number} height (in pixels) */ @@ -25556,17 +25668,19 @@ Roo.extend(Roo.HtmlEditorCore, Roo.Component, { this.frameId = Roo.id(); - - - var iframe = this.owner.wrap.createChild({ + var ifcfg = { tag: 'iframe', cls: 'form-control', // bootstrap.. id: this.frameId, name: this.frameId, frameBorder : 'no', 'src' : Roo.SSL_SECURE_URL ? Roo.SSL_SECURE_URL : "javascript:false" - }, this.el - ); + }; + if (this.resize) { + ifcfg.style = { resize : this.resize }; + } + + var iframe = this.owner.wrap.createChild(ifcfg, this.el); this.iframe = iframe.dom; @@ -25701,11 +25815,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){ @@ -25898,9 +26043,34 @@ Roo.extend(Roo.HtmlEditorCore, Roo.Component, { var urlAPI = (window.createObjectURL && window) || (window.URL && URL.revokeObjectURL && URL) || (window.webkitURL && webkitURL); - - var url = urlAPI.createObjectURL( cd.files[0]); - this.insertAtCursor(''); + + var r = new FileReader(); + var t = this; + r.addEventListener('load',function() + { + + var d = (new DOMParser().parseFromString('', 'text/html')).body; + // is insert asycn? + if (t.enableBlocks) { + + Array.from(d.getElementsByTagName('img')).forEach(function(img) { + if (img.closest('figure')) { // assume!! that it's aready + return; + } + var fig = new Roo.htmleditor.BlockFigure({ + image_src : img.src + }); + fig.updateElement(img); // replace it.. + + }); + } + t.insertAtCursor(d.innerHTML.replace(/ /g,' ')); + t.owner.fireEvent('paste', this); + }); + r.readAsDataURL(cd.files[0]); + + e.preventDefault(); + return false; } if (cd.types.indexOf('text/html') < 0 ) { @@ -25993,6 +26163,7 @@ Roo.extend(Roo.HtmlEditorCore, Roo.Component, { e.preventDefault(); + this.owner.fireEvent('paste', this); return false; // default behaveiour should be our local cleanup paste? (optional?) // for simple editor - we want to hammer the paste and get rid of everything... - so over-rideable.. @@ -26069,6 +26240,8 @@ Roo.extend(Roo.HtmlEditorCore, Roo.Component, { if (e && (e.ctrlKey || e.metaKey) && e.keyCode === 90) { return; // we do not handle this.. (undo manager does..) } + // clicking a 'block'? + // in theory this detects if the last element is not a br, then we try and do that. // its so clicking in space at bottom triggers adding a br and moving the cursor. if (e && @@ -26171,6 +26344,7 @@ Roo.extend(Roo.HtmlEditorCore, Roo.Component, { break; case 'bold': case 'italic': + case 'underline': // if there is no selection, then we insert, and set the curson inside it.. this.execCmd('styleWithCSS', false); break; @@ -29760,6 +29934,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 && @@ -29774,6 +29951,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]); } @@ -29799,7 +29979,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) @@ -30879,7 +31059,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(/^\