From: Edward Date: Tue, 23 Apr 2019 08:58:50 +0000 (+0800) Subject: roojs-ui.js X-Git-Url: http://git.roojs.org/?p=roojs1;a=commitdiff_plain;h=5df720f8861f989d06323ff4068e81d30e6b8b21 roojs-ui.js roojs-ui-debug.js roojs-all.js roojs-debug.js Roo/form/Form.js Roo/form/BasicForm.js --- diff --git a/Roo/form/BasicForm.js b/Roo/form/BasicForm.js index 303b5af568..6ae12e9d10 100644 --- a/Roo/form/BasicForm.js +++ b/Roo/form/BasicForm.js @@ -681,4 +681,190 @@ clientValidation Boolean Applies to submit only. Pass true to call fo }); // back compat -Roo.BasicForm = Roo.form.BasicForm; \ No newline at end of file +Roo.BasicForm = Roo.form.BasicForm; + +Roo.apply(Roo.form.BasicForm, { + + popover : { + + padding : 5, + + isApplied : false, + + isMasked : false, + + form : false, + + target : false, + + toolTip : 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"); + + this.toolTip = new Roo.bootstrap.Tooltip({ + cls : 'roo-form-error-popover', + alignment : { + 'left' : ['r-l', [-2,0], 'right'], + 'right' : ['l-r', [2,0], 'left'], + 'bottom' : ['tl-bl', [0,2], 'top'], + 'top' : [ 'bl-tl', [0,-2], 'bottom'] + } + }); + + this.toolTip.render(Roo.get(document.body)); + + this.toolTip.el.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.modal', 100, true) || Roo.get(document.body); + + Roo.log(scrollable); + + 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 box = this.target.el.getBox(); + Roo.log(box); + var zIndex = Roo.bootstrap.Modal.zIndex++; + + + this.maskEl.top.setStyle('position', 'absolute'); + this.maskEl.top.setStyle('z-index', zIndex); + 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', zIndex); + 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', zIndex); + 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', zIndex); + 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.toolTip.bindEl = this.target.el; + + this.toolTip.el.setStyle('z-index', Roo.bootstrap.Modal.zIndex++); + + var tip = this.target.blankText; + + if(this.target.getValue() !== '' ) { + + if (this.target.invalidText.length) { + tip = this.target.invalidText; + } else if (this.target.regexText.length){ + tip = this.target.regexText; + } + } + + this.toolTip.show(tip); + + this.intervalID = window.setInterval(function() { + Roo.bootstrap.Form.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(); + + this.toolTip.hide(); + + this.toolTip.el.hide(); + + window.onwheel = function(){ return true;}; + + if(this.intervalID){ + window.clearInterval(this.intervalID); + this.intervalID = false; + } + + this.isMasked = false; + + } + + } + +}); \ No newline at end of file diff --git a/Roo/form/Form.js b/Roo/form/Form.js index 130c634e74..c25f4c6f3c 100644 --- a/Roo/form/Form.js +++ b/Roo/form/Form.js @@ -442,190 +442,3 @@ Roo.extend(Roo.form.Form, Roo.form.BasicForm, { // back compat Roo.Form = Roo.form.Form; - - -Roo.apply(Roo.form.Form, { - - popover : { - - padding : 5, - - isApplied : false, - - isMasked : false, - - form : false, - - target : false, - - toolTip : 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"); - - this.toolTip = new Roo.bootstrap.Tooltip({ - cls : 'roo-form-error-popover', - alignment : { - 'left' : ['r-l', [-2,0], 'right'], - 'right' : ['l-r', [2,0], 'left'], - 'bottom' : ['tl-bl', [0,2], 'top'], - 'top' : [ 'bl-tl', [0,-2], 'bottom'] - } - }); - - this.toolTip.render(Roo.get(document.body)); - - this.toolTip.el.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.modal', 100, true) || Roo.get(document.body); - - Roo.log(scrollable); - - 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 box = this.target.el.getBox(); - Roo.log(box); - var zIndex = Roo.bootstrap.Modal.zIndex++; - - - this.maskEl.top.setStyle('position', 'absolute'); - this.maskEl.top.setStyle('z-index', zIndex); - 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', zIndex); - 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', zIndex); - 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', zIndex); - 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.toolTip.bindEl = this.target.el; - - this.toolTip.el.setStyle('z-index', Roo.bootstrap.Modal.zIndex++); - - var tip = this.target.blankText; - - if(this.target.getValue() !== '' ) { - - if (this.target.invalidText.length) { - tip = this.target.invalidText; - } else if (this.target.regexText.length){ - tip = this.target.regexText; - } - } - - this.toolTip.show(tip); - - this.intervalID = window.setInterval(function() { - Roo.bootstrap.Form.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(); - - this.toolTip.hide(); - - this.toolTip.el.hide(); - - window.onwheel = function(){ return true;}; - - if(this.intervalID){ - window.clearInterval(this.intervalID); - this.intervalID = false; - } - - this.isMasked = false; - - } - - } - -}); \ No newline at end of file diff --git a/roojs-all.js b/roojs-all.js index b05ff54432..900ba5ec56 100644 --- a/roojs-all.js +++ b/roojs-all.js @@ -1919,7 +1919,7 @@ if(!cn.match(/x-ed-loc-/)){return;}var n=cn.split('-').pop();var B=this.footerEl }}); // Roo/form/BasicForm.js Roo.form.BasicForm=function(el,A){this.allItems=[];this.childForms=[];Roo.apply(this,A);this.items=new Roo.util.MixedCollection(false,function(o){return o.id||(o.id=Roo.id());});this.addEvents({beforeaction:true,actionfailed:true,actioncomplete:true});if(el){this.initEl(el); -}Roo.form.BasicForm.superclass.constructor.call(this);};Roo.extend(Roo.form.BasicForm,Roo.util.Observable,{timeout:30,activeAction:null,trackResetOnLoad:false,childForms:false,allItems:false,waitMsgTarget:false,disableMask:false,initEl:function(el){this.el=Roo.get(el); +}Roo.form.BasicForm.superclass.constructor.call(this);Roo.form.BasicForm.popover.apply();};Roo.extend(Roo.form.BasicForm,Roo.util.Observable,{timeout:30,activeAction:null,trackResetOnLoad:false,childForms:false,allItems:false,waitMsgTarget:false,disableMask:false,initEl:function(el){this.el=Roo.get(el); this.id=this.el.id||Roo.id();this.el.on('submit',this.onSubmit,this);this.el.addClass('x-form');},onSubmit:function(e){e.stopEvent();},isValid:function(){var A=true;var B=false;this.items.each(function(f){if(f.validate()){A=false;if(!B&&f.el.isVisible(true)){B=f; }}});if(this.errorMask&&!A){Roo.form.BasicForm.popover.mask(this,B);}return A;},isDirty:function(){var A=false;this.items.each(function(f){if(f.isDirty()){A=true;return false;}});return A;},hasChanged:function(){var A=false;this.items.each(function(f){if(f.hasChanged()){A=true; return false;}});return A;},resetHasChanged:function(){this.items.each(function(f){f.resetHasChanged();});},doAction:function(A,B){if(typeof A=='string'){A=new Roo.form.Action.ACTION_TYPES[A](this,B);}if(this.fireEvent('beforeaction',this,A)!==false){this.beforeAction(A); @@ -1953,20 +1953,7 @@ for(var i=0,A=this.buttons.length;i