From 0a0ab3a718f10b57ef0c2f7fc5b58e9187df8fbf Mon Sep 17 00:00:00 2001 From: leon Date: Fri, 14 Oct 2022 13:24:03 +0800 Subject: [PATCH] roojs-bootstrap.js roojs-bootstrap-debug.js --- roojs-bootstrap-debug.js | 126 ++++++++++++++++++++++++++++++++++++++- roojs-bootstrap.js | 7 ++- 2 files changed, 129 insertions(+), 4 deletions(-) diff --git a/roojs-bootstrap-debug.js b/roojs-bootstrap-debug.js index 184111c7cd..80df430113 100644 --- a/roojs-bootstrap-debug.js +++ b/roojs-bootstrap-debug.js @@ -12940,12 +12940,12 @@ Roo.extend(Roo.bootstrap.form.Input, Roo.bootstrap.Component, { } if(typeof this.validator == "function"){ var msg = this.validator(value); - if(msg !== true){ - return false; - } if (typeof(msg) == 'string') { this.invalidText = msg; } + if(msg !== true){ + return false; + } } if(this.regex && !this.regex.test(value)){ @@ -27030,6 +27030,126 @@ Roo.apply(Roo.htmleditor.FilterBlock.prototype, }); +/*** + * This is based loosely on tinymce + * @class Roo.htmleditor.TidySerializer + * https://github.com/thorn0/tinymce.html/blob/master/tinymce.html.js + * @constructor + * @method Serializer + * @param {Object} settings Name/value settings object. + */ + + +Roo.htmleditor.TidySerializer = function(settings) +{ + Roo.apply(this, settings); + + this.writer = new Roo.htmleditor.TidyWriter(settings); + + + +}; +Roo.htmleditor.TidySerializer.prototype = { + + /** + * @param {boolean} inner do the inner of the node. + */ + inner : false, + + writer : false, + + /** + * Serializes the specified node into a string. + * + * @example + * new tinymce.html.Serializer().serialize(new tinymce.html.DomParser().parse('

text

')); + * @method serialize + * @param {DomElement} node Node instance to serialize. + * @return {String} String with HTML based on DOM tree. + */ + serialize : function(node) { + + // = settings.validate; + var writer = this.writer; + var self = this; + this.handlers = { + // #text + 3: function(node) { + + writer.text(node.nodeValue, node); + }, + // #comment + 8: function(node) { + writer.comment(node.nodeValue); + }, + // Processing instruction + 7: function(node) { + writer.pi(node.name, node.nodeValue); + }, + // Doctype + 10: function(node) { + writer.doctype(node.nodeValue); + }, + // CDATA + 4: function(node) { + writer.cdata(node.nodeValue); + }, + // Document fragment + 11: function(node) { + node = node.firstChild; + if (!node) { + return; + } + while(node) { + self.walk(node); + node = node.nextSibling + } + } + }; + writer.reset(); + 1 != node.nodeType || this.inner ? this.handlers[11](node) : this.walk(node); + return writer.getContent(); + }, + + walk: function(node) + { + var attrName, attrValue, sortedAttrs, i, l, elementRule, + handler = this.handlers[node.nodeType]; + + if (handler) { + handler(node); + return; + } + + var name = node.nodeName; + var isEmpty = node.childNodes.length < 1; + + var writer = this.writer; + var attrs = node.attributes; + // Sort attributes + + writer.start(node.nodeName, attrs, isEmpty, node); + if (isEmpty) { + return; + } + node = node.firstChild; + if (!node) { + writer.end(name); + return; + } + while (node) { + this.walk(node); + node = node.nextSibling; + } + writer.end(name); + + + } + // Serialize element and treat all non elements as fragments + +}; + + /** * @class Roo.htmleditor.KeyEnter * Handle Enter press.. diff --git a/roojs-bootstrap.js b/roojs-bootstrap.js index bd81ff69e6..83731a0ec8 100644 --- a/roojs-bootstrap.js +++ b/roojs-bootstrap.js @@ -544,7 +544,7 @@ if(this.validationEvent=='keyup'){this.validationTask=new Roo.util.DelayedTask(t }if(this.inputEl().is('input[type=password]')&&Roo.isSafari){this.inputEl().on('keydown',this.SafariOnKeyDown,this);}if(typeof(this.before)=='object'){this.before.render(this.el.select('.roo-input-before',true).first());}if(typeof(this.after)=='object'){this.after.render(this.el.select('.roo-input-after',true).first()); }this.inputEl().on('change',this.onChange,this);},filterValidation:function(e){if(!e.isNavKeyPress()){this.validationTask.delay(this.validationDelay);}},validate:function(){if(this.disabled||this.validateValue(this.getRawValue())){this.markValid();return true; }this.markInvalid();return false;},validateValue:function(A){if(this.getVisibilityEl().hasClass('hidden')){return true;}if(A.length<1){if(this.allowBlank){return true;}return false;}if(A.lengththis.maxLength){return false; -}if(this.vtype){var vt=Roo.form.VTypes;if(!vt[this.vtype](A,this)){return false;}}if(typeof this.validator=="function"){var B=this.validator(A);if(B!==true){return false;}if(typeof(B)=='string'){this.invalidText=B;}}if(this.regex&&!this.regex.test(A)){return false; +}if(this.vtype){var vt=Roo.form.VTypes;if(!vt[this.vtype](A,this)){return false;}}if(typeof this.validator=="function"){var B=this.validator(A);if(typeof(B)=='string'){this.invalidText=B;}if(B!==true){return false;}}if(this.regex&&!this.regex.test(A)){return false; }return true;},fireKey:function(e){if(e.isNavKeyPress()){this.fireEvent("specialkey",this,e);}},focus:function(A){if(this.rendered){this.inputEl().focus();if(A===true){this.inputEl().dom.select();}}return this;},onFocus:function(){if(!Roo.isOpera&&this.focusClass){} if(!this.hasFocus){this.hasFocus=true;this.startValue=this.getValue();this.fireEvent("focus",this);}},beforeBlur:Roo.emptyFn,onBlur:function(){this.beforeBlur();if(!Roo.isOpera&&this.focusClass){}this.hasFocus=false;if(this.validationEvent!==false&&this.validateOnBlur&&this.validationEvent!="blur"){this.validate(); }var v=this.getValue();if(String(v)!==String(this.startValue)){this.fireEvent('change',this,v,this.startValue);}this.fireEvent("blur",this);},onChange:function(e){var v=this.getValue();if(String(v)!==String(this.startValue)){this.fireEvent('change',this,v,this.startValue); @@ -1173,6 +1173,11 @@ return false;}if(!ps||ps.nodeType!=1){return false;}if(!ps||ps.tagName!='BR'){re // Roo/htmleditor/FilterBlock.js Roo.htmleditor.FilterBlock=function(A){Roo.apply(this,A);var qa=A.node.querySelectorAll;this.removeAttributes('data-block');this.removeAttributes('contenteditable');this.removeAttributes('id');};Roo.apply(Roo.htmleditor.FilterBlock.prototype,{node:true,removeAttributes:function(A){var ar=this.node.querySelectorAll('*['+A+']'); for(var i=0;i