Files
SIG/Scripts/AjaxControlToolkit/Release/HtmlEditor.Popups.Popup.js
JORGE LUIS CAUDILLO ESPARZA c35cf91883 Commit inicial Ventas Productivo
2019-08-14 16:40:54 -07:00

1 line
5.6 KiB
JavaScript

Type.registerNamespace("Sys.Extended.UI.HtmlEditor.Popups");Sys.Extended.UI.HtmlEditor.Popups.Popup=function(n){Sys.Extended.UI.HtmlEditor.Popups.Popup.initializeBase(this,[n]);this._iframe=null;this._top=0;this._left=0;this._doc=null;this._initialContent="";this._cssPath="";this._autoDimensions=!0;this._registeredFields=[];this._registeredHandlers=[];this._app_onload$delegate=Function.createDelegate(this,this._app_onload);this.isOpened=!1;this.isLoaded=!1;this.isLoading=!1};Sys.Extended.UI.HtmlEditor.Popups.Popup.prototype={getDocument:function(){return this._doc},getPopupMediator:function(){return this._iframe.contentWindow&&this._iframe.contentWindow.popupMediator?this._iframe.contentWindow.popupMediator:null},get_registeredFields:function(){return this._registeredFields},set_registeredFields:function(value){this._registeredFields=eval(value)},get_registeredHandlers:function(){return this._registeredHandlers},set_registeredHandlers:function(value){this._registeredHandlers=eval(value)},get_initialContent:function(){return this._initialContent},set_initialContent:function(n){this._initialContent=n},get_cssPath:function(){return this._cssPath},set_cssPath:function(n){this._cssPath=n},get_autoDimensions:function(){return this._autoDimensions},set_autoDimensions:function(n){this._autoDimensions=n},get_iframe:function(){return this._iframe},set_iframe:function(n){this._iframe=n},checkCorrectLoaded:function(n){var t=this;return(t.isLoaded&&(t._iframe.style.height=="0px"||t._iframe.style.width=="0px")&&(this.isLoaded=!1),!this.isLoaded)?(this.isLoading||this.reload(),typeof n!="undefined"&&setTimeout(n,10),!1):!0},_baseOpen:function(n,t,i){var r=this,u;this.checkCorrectLoaded(function(){r._baseOpen(n,t,i)})&&(u=this.get_element(),typeof i!="undefined"&&(this._left=parseInt(i)),typeof t!="undefined"&&(this._top=parseInt(t)),u.style.top=this._top+"px",u.style.left=this._left+"px",setTimeout(function(){typeof n=="function"&&r._onDocumentLoaded(n);r.isOpened=!0},0))},open:function(n,t,i){this._baseOpen(n,t,i)},close:function(n){var t=this.get_element();this.isOpened=!1;t.style.top="-2000px";t.style.left="-2000px";typeof n=="function"&&n()},reload:function(){var t,i,n;this.isLoading=!0;t=this.get_element();i=t.parentNode;document.body.appendChild(t);i.appendChild(this.get_element());this._doc=this._iframe.contentWindow.document;this._doc.open();n=new Sys.StringBuilder;n.append('<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"><html><head>');this._cssPath.length>0&&n.append('<link rel="stylesheet" href="'+this._cssPath+'" media="all" />');n.append("<script>var __loaded__ = false;<\/script><\/head><body style='margin:0px; padding:0px; border-width:0px;' onload='__loaded__ = true;'>");this._autoDimensions&&n.append("<table cellspacing='0' cellpadding='0' border='0'><tr><td>");n.append(this._initialContent);this._autoDimensions&&n.append("<\/td><\/tr><\/table>");n.append("<\/body><\/html>");this._doc.write(n.toString());this._doc.close();this.isLoaded=!1;this._afterReload()},_afterReload:function(){var t=this._iframe.contentWindow,n=this,r,i;if(this.isLoaded=t.__loaded__,n._doc.body&&n._doc.body.innerHTML||(this.isLoaded=!1),!this.isLoaded){setTimeout(function(){n._afterReload()},10);return}for(this.isLoaded=!1,t.popupMediator={},t.popupMediator.registeredFields=this._registeredFields,t.popupMediator.registeredHandlers=this._registeredHandlers,t.popupMediator.get_callMethodByName=function(n){for(var r,u=t.popupMediator.registeredHandlers,i=0;i<u.length;i++)if(r=u[i],r.name==n)return r.callMethod;return null},t.popupMediator.set_callMethodByName=function(n,i){for(var u,f=t.popupMediator.registeredHandlers,r=0;r<f.length;r++)u=f[r],u.name==n&&(u.callMethod=i)},t.popupMediator.getField=function(n){for(var r,u=t.popupMediator.registeredFields,i=0;i<u.length;i++)if(r=u[i],r.name==n)return t.document.getElementById(r.clientID);return null},t.Sys=Sys,i=0;i<this._registeredHandlers.length;i++)$find(this._registeredHandlers[i].clientID).activate(t.document.getElementById(this._registeredHandlers[i].clientID));if(Sys.Extended.UI.HtmlEditor.isIE)n._doc.onselectstart=function(){var i=n._iframe.contentWindow.event,t=i.srcElement.tagName.toUpperCase();return t=="INPUT"||t=="TEXTAREA"?!0:!1};else for(n._doc.onmousedown=function(n){var t=n.target.tagName.toUpperCase();return t=="INPUT"||t=="TEXTAREA"||t=="SELECT"?!0:Sys.Extended.UI.HtmlEditor.isSafari&&(t=="TABLE"||t=="TR"||t=="TD"||t=="DIV")?!0:!1},r=n._doc.getElementsByTagName("input"),i=0;i<r.length;i++)r[i].setAttribute("autocomplete","off");this._autoDimensions?(n._iframe.style.height="1000px",n._iframe.style.width="1000px",setTimeout(function(){n._iframe.style.height=n._doc.body.firstChild.offsetHeight+"px";n._iframe.style.width=n._doc.body.firstChild.offsetWidth+"px";n.isLoaded=!0;n.isLoading=!1},0)):(n.isLoaded=!0,n.isLoading=!1)},_onDocumentLoaded:function(n){var t=this;if(!this.isLoaded){setTimeout(function(){t._onDocumentLoaded(n)},10);return}this.isLoaded=!0;n(this._iframe.contentWindow)},initialize:function(){this.__appLoaded__=!1;Sys.Extended.UI.HtmlEditor.Popups.Popup.callBaseMethod(this,"initialize");Sys.Application.add_load(this._app_onload$delegate)},dispose:function(){Sys.Application.remove_load(this._app_onload$delegate);this.isOpened&&this.close();Sys.Extended.UI.HtmlEditor.Popups.Popup.callBaseMethod(this,"dispose")},_app_onload:function(){if(!this.__appLoaded__){this.__appLoaded__=!0;var n=this.get_element();Sys.Extended.UI.HtmlEditor.isReallyVisible(n)&&(this._parentNode_=n.parentNode,this.reload())}}};Sys.Extended.UI.HtmlEditor.Popups.Popup.registerClass("Sys.Extended.UI.HtmlEditor.Popups.Popup",Sys.UI.Control);