roojs-bootstrap.js
authorleon <leon@roojs.com>
Fri, 14 Oct 2022 05:24:03 +0000 (13:24 +0800)
committerleon <leon@roojs.com>
Fri, 14 Oct 2022 05:24:03 +0000 (13:24 +0800)
roojs-bootstrap-debug.js

roojs-bootstrap-debug.js
roojs-bootstrap.js

index 184111c..80df430 100644 (file)
@@ -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('<p>text</p>'));
+    * @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..
index bd81ff6..83731a0 100644 (file)
@@ -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.length<this.minLength){return false;}if(A.length>this.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<ar.length;i++){ar[i].removeAttribute(A);}}});
+// Roo/htmleditor/TidySerializer.js
+Roo.htmleditor.TidySerializer=function(A){Roo.apply(this,A);this.writer=new Roo.htmleditor.TidyWriter(A);};Roo.htmleditor.TidySerializer.prototype={inner:false,writer:false,serialize:function(A){var B=this.writer;var C=this;this.handlers={3:function(D){B.text(D.nodeValue,D);
+},8:function(D){B.comment(D.nodeValue);},7:function(D){B.pi(D.name,D.nodeValue);},10:function(D){B.doctype(D.nodeValue);},4:function(D){B.cdata(D.nodeValue);},11:function(D){D=D.firstChild;if(!D){return;}while(D){C.walk(D);D=D.nextSibling}}};B.reset();1!=A.nodeType||this.inner?this.handlers[11](A):this.walk(A);
+return B.getContent();},walk:function(A){var B,C,D,i,l,E,F=this.handlers[A.nodeType];if(F){F(A);return;}var G=A.nodeName;var H=A.childNodes.length<1;var I=this.writer;var J=A.attributes;I.start(A.nodeName,J,H,A);if(H){return;}A=A.firstChild;if(!A){I.end(G);
+return;}while(A){this.walk(A);A=A.nextSibling;}I.end(G);}};
 // Roo/htmleditor/KeyEnter.js
 Roo.htmleditor.KeyEnter=function(A){Roo.apply(this,A);Roo.get(this.core.doc.body).on('keypress',this.keypress,this);};Roo.htmleditor.KeyEnter.prototype={core:false,keypress:function(e){if(e.charCode!=13&&e.charCode!=10){Roo.log([e.charCode,e]);return true;
 }e.preventDefault();var A=this.core.doc;var B=this.core.getSelection();var C=B.getRangeAt(0);var n=C.commonAncestorContainer;var pc=C.closest(['ol','ul']);var D=C.closest('li');if(!pc||e.ctrlKey){if(!e.ctrlKey){B.insertNode('br','after');}else{var br=A.createElement('br');