1 line
14 KiB
JavaScript
1 line
14 KiB
JavaScript
Type.registerNamespace("Sys.Extended.UI.HtmlEditor"),Sys.Extended.UI.HtmlEditor.LastFocusedEditPanel=null,Sys.Extended.UI.HtmlEditor.EditPanel=function(e){Sys.Extended.UI.HtmlEditor.EditPanel.initializeBase(this,[e]),this._loaded=!1,this._eAfter=null,this._toolbars=null,this._modePanels=null,this._contentChangedElement=null,this._contentElement=null,this._contentForceElement=null,this._activeModeElement=null,this._suppressTabInDesignMode=!1,this._keyboardEnabled=!0,this._noPaste=!1,this._hotkeys=null,this._showAnchors=!1,this._showPlaceHolders=!1,this._startEnd=!0,this._relativeImages=!0,this._documentCssPath=null,this._designPanelCssPath=null,this._imagePath_1x1=null,this._imagePath_flash=null,this._imagePath_media=null,this._imagePath_anchor=null,this._imagePath_placeHolder=null,this._autofocus=!0,this._initialCleanUp=!1,this._noScript=!1,this._noUnicode=!1,this._cachedToolbarIds=null,this._contentPrepared=!1,this._activeMode=null,this._pageRequestManager=null,this._formOnSubmitSaved=null,this._validators=null,this._app_onload$delegate=Function.createDelegate(this,this._app_onload),this._onsubmit$delegate=Function.createDelegate(this,this._onsubmit),this._disposed=!0},Sys.Extended.UI.HtmlEditor.EditPanel.prototype={get_relativeImages:function(){return this._relativeImages},set_relativeImages:function(e){this._relativeImages=e,this._loaded&&this.raisePropertyChanged("relativeImages")},get_startEnd:function(){return this._startEnd},set_startEnd:function(e){this._startEnd=e,this._loaded&&this.raisePropertyChanged("startEnd")},get_showPlaceHolders:function(){return this._showPlaceHolders},set_showPlaceHolders:function(e){this._showPlaceHolders=e,this._loaded&&this.raisePropertyChanged("showPlaceHolders")},get_showAnchors:function(){return this._showAnchors},set_showAnchors:function(e){this._showAnchors=e,this._loaded&&this.raisePropertyChanged("showAnchors")},get_hotkeys:function(){return this._hotkeys},set_hotkeys:function(e){this._hotkeys=e,this._loaded&&this.raisePropertyChanged("noPaste")},get_noPaste:function(){return this._noPaste},set_noPaste:function(e){this._noPaste=e,this._loaded&&this.raisePropertyChanged("noPaste")},get_suppressTabInDesignMode:function(){return this._suppressTabInDesignMode},set_suppressTabInDesignMode:function(e){this._suppressTabInDesignMode=e,this._loaded&&this.raisePropertyChanged("suppressTabInDesignMode")},get_keyboardEnabled:function(){return this._keyboardEnabled},set_keyboardEnabled:function(e){this._keyboardEnabled=e,this._loaded&&this.raisePropertyChanged("keyboardEnabled")},get_noUnicode:function(){return this._noUnicode},set_noUnicode:function(e){this._noUnicode=e,this._loaded&&this.raisePropertyChanged("noUnicode")},get_noScript:function(){return this._noScript},set_noScript:function(e){this._noScript=e,this._loaded&&this.raisePropertyChanged("noScript")},get_initialCleanUp:function(){return this._initialCleanUp},set_initialCleanUp:function(e){this._initialCleanUp=e,this._loaded&&this.raisePropertyChanged("initialCleanUp")},get_imagePath_1x1:function(){return this._imagePath_1x1},set_imagePath_1x1:function(e){this._imagePath_1x1=e},get_imagePath_flash:function(){return this._imagePath_flash},set_imagePath_flash:function(e){this._imagePath_flash=e},get_imagePath_media:function(){return this._imagePath_media},set_imagePath_media:function(e){this._imagePath_media=e},get_imagePath_anchor:function(){return this._imagePath_anchor},set_imagePath_anchor:function(e){this._imagePath_anchor=e},get_imagePath_placeHolder:function(){return this._imagePath_placeHolder},set_imagePath_placeHolder:function(e){this._imagePath_placeHolder=e},get_documentCssPath:function(){return this._documentCssPath},set_documentCssPath:function(e){this._documentCssPath=e,this._loaded&&this.raisePropertyChanged("documentCssPath")},get_designPanelCssPath:function(){return this._designPanelCssPath},set_designPanelCssPath:function(e){this._designPanelCssPath=e,this._loaded&&this.raisePropertyChanged("designPanelCssPath")},get_autofocus:function(){return this._autofocus},set_autofocus:function(e){this._autofocus=e,this._loaded&&this.raisePropertyChanged("autofocus")},get_content:function(){return null==this._activeMode?null!=this.get_contentElement()?this._getContentForPostback():"":this.getContent()},set_content:function(e){return this.get_isInitialized()&&this._loaded?(this.setContent(e),this._contentPrepared=!1,void(this._loaded&&this.raisePropertyChanged("content"))):void(null!=this.get_contentElement()&&(this.get_contentElement().value=e.replace(/\"/g,""")))},get_activeMode:function(){return null==this._activeMode?Sys.Extended.UI.HtmlEditor.ActiveModeType.Design:this._activeMode},set_activeMode:function(e){if(!Sys.Extended.UI.HtmlEditor.ActiveModeType_checkValue(e))throw Error.argumentOutOfRange("value, function: Sys.Extended.UI.HtmlEditor.EditPanel.set_activeMode");var t=this._activeMode,n=!0;if(this._loaded&&null!=t&&t!=e){var i=new Sys.Extended.UI.HtmlEditor.ActiveModeChangedArgs(t,e,this);this.raiseBeforeActiveModeChanged(i),this._eAfter=new Sys.Extended.UI.HtmlEditor.ActiveModeChangedArgs(t,e,this),n=this._setMode(e)}else this._activeMode=e;return this.get_activeModeElement().value=e,n},get_contentChangedElement:function(){return this._contentChangedElement},set_contentChangedElement:function(e){this._contentChangedElement=e},get_contentElement:function(){return this._contentElement},set_contentElement:function(e){this._contentElement=e},get_contentForceElement:function(){return this._contentForceElement},set_contentForceElement:function(e){this._contentForceElement=e},get_activeModeElement:function(){return this._activeModeElement},set_activeModeElement:function(e){this._activeModeElement=e},setCancelOnPostback:function(){this._loaded&&(this.get_contentForceElement().value="")},setAcceptOnPostback:function(){this._loaded&&(this.get_contentForceElement().value="1")},get_toolbars:function(){return null==this._toolbars&&(this._toolbars=[]),this._toolbars},set_toolbars:function(e){this.get_toolbars().push(e)},get_toolbarIds:function(){},set_toolbarIds:function(e){if(!this.get_isInitialized())return void(this._cachedToolbarIds=e);for(var t=e.split(";"),n=0;n<t.length;n++)t[n].length>0&&this.set_toolbars($find(t[n]))},get_modePanels:function(){return null==this._modePanels&&(this._modePanels=[]),this._modePanels},set_modePanel:function(e){this.get_modePanels().push(e)},get_modePanelIds:function(){},set_modePanelIds:function(e){for(var t=e.split(";"),n=0;n<t.length;n++)this.set_modePanel($find(t[n]))},add_focused:function(e){this.get_events().addHandler("focused",e)},remove_focused:function(e){this.get_events().removeHandler("focused",e)},raiseFocused:function(e){var t=this.get_events().getHandler("focused");t&&t(this,e)},add_activeModeChanged:function(e){this.get_events().addHandler("activeModeChanged",e)},remove_activeModeChanged:function(e){this.get_events().removeHandler("activeModeChanged",e)},raiseActiveModeChanged:function(e){var t=this.get_events().getHandler("activeModeChanged");t&&t(this,e)},add_beforeActiveModeChanged:function(e){this.get_events().addHandler("beforeActiveModeChanged",e)},remove_beforeActiveModeChanged:function(e){this.get_events().removeHandler("beforeActiveModeChanged",e)},raiseBeforeActiveModeChanged:function(e){var t=this.get_events().getHandler("beforeActiveModeChanged");t&&t(this,e)},get_activePanel:function(){var e=this.get_modePanels()[this.get_activeMode()];if(null==e||"undefined"==typeof e)throw Error.argumentOutOfRange("activeMode, function: Sys.Extended.UI.HtmlEditor.EditPanel.get_activePanel");return e},initialize:function(){this.__appLoaded__=!1,Sys.Extended.UI.HtmlEditor.EditPanel.callBaseMethod(this,"initialize"),this._disposed=!1,Sys.Application.add_load(this._app_onload$delegate),Sys&&Sys.WebForms&&Sys.WebForms.PageRequestManager&&(this._pageRequestManager=Sys.WebForms.PageRequestManager.getInstance(),this._pageRequestManager&&(this._partialUpdateEndRequestHandler=Function.createDelegate(this,this._partialUpdateEndRequest),this._pageRequestManager.add_endRequest(this._partialUpdateEndRequestHandler),this._invokingRequestHandler=Function.createDelegate(this,this._invokingRequest),Sys.Net.WebRequestManager.add_invokingRequest(this._invokingRequestHandler),this._completedRequestHandler=Function.createDelegate(this,this._completedRequest),Sys.Net.WebRequestManager.add_completedRequest(this._completedRequestHandler))),Sys.Extended.UI.HtmlEditor.addFormOnSubmit(this._onsubmit$delegate,this)},dispose:function(){this._loaded=!1,this._disposed=!0,this._pageRequestManager&&(this._invokingRequestHandler&&(this._pageRequestManager.remove_endRequest(this._partialUpdateEndRequestHandler),this._partialUpdateEndRequestHandler=null,Sys.Net.WebRequestManager.remove_invokingRequest(this._invokingRequestHandler),this._invokingRequestHandler=null,Sys.Net.WebRequestManager.remove_completedRequest(this._completedRequestHandler),this._completedRequestHandler=null),this._pageRequestManager=null),Sys.Extended.UI.HtmlEditor.removeFormOnSubmit(this._onsubmit$delegate),Sys.Application.remove_load(this._app_onload$delegate),this.disableToolbars(),Sys.Extended.UI.HtmlEditor.EditPanel.callBaseMethod(this,"dispose")},_onsubmit:function(e){return this._contentPrepared||(this._prepareContentForPostback(this.get_content()),this._contentPrepared=!0),!0},_invokingRequest:function(e,t){if(!this._contentPrepared){var n=t.get_webRequest(),i=n.get_body(),s=new RegExp("([\\?&])("+this.get_contentElement().name+"=)([^&$]*)([&$])","g");this._prepareContentForPostback(this.get_content()),i=i.replace(s,"$1$2"+escape(this.get_contentElement().value)+"$4"),this._contentPrepared=!0,n.set_body(i)}},_completedRequest:function(e,t){this._contentPrepared=!1},_partialUpdateEndRequest:function(e,t){this._contentPrepared=!1,Sys.Extended.UI.HtmlEditor.isIE&&this.__blured&&(this.__blured=!1,this.get_activePanel()._focus())},_app_onload:function(e,t){if(!this.__appLoaded__&&(this.__appLoaded__=!0,!this._disposed)){if(this._loaded=!0,this.set_activeMode(parseInt(this.get_activeModeElement().value)),null!=this._cachedToolbarIds&&(this.set_toolbarIds(this._cachedToolbarIds),this._cachedToolbarIds=null),this._validators=this.get_modePanels()[Sys.Extended.UI.HtmlEditor.ActiveModeType.Html].get_element().Validators,this._shouldResize=!1,Sys.Extended.UI.HtmlEditor.isIE&&"BackCompat"!=document.compatMode&&(this._shouldResize=!0),this._shouldResize){var n=this.get_modePanels(),i=n[Sys.Extended.UI.HtmlEditor.ActiveModeType.Design];null==i&&(i=n[Sys.Extended.UI.HtmlEditor.ActiveModeType.Preview]);var s=n[Sys.Extended.UI.HtmlEditor.ActiveModeType.Html];if(null!=i&&null!=s){var a=i.get_element();a.style.display="";var o,d=a.offsetHeight,l=!1;0==d&&(l=!0,o=Sys.Extended.UI.HtmlEditor.setElementVisibility(a.parentNode),d=a.offsetHeight),s.get_element().style.height=d+"px",l&&(Sys.Extended.UI.HtmlEditor.restoreElementVisibility(o),delete o),a.style.display="none"}}var r=this.get_contentElement().value.replace(/</g,"<").replace(/>/g,">").replace(/"/g,'"').replace(/&/g,"&");this.setContent(this._initialCleanUp?Sys.Extended.UI.HtmlEditor.cleanUp(r.replace(/[\n\r]+/g," ")):r),this.setAcceptOnPostback()}},_setActive:function(){for(var e=0;e<this.get_toolbars().length;e++)this.get_toolbars()[e].set_activeEditPanel(this,!0);null!=this._eAfter&&(this.raisePropertyChanged("activeMode"),this.raiseActiveModeChanged(this._eAfter),this._eAfter=null)},_focused:function(e){if("undefined"==typeof e||!e)for(var t=0;t<this.get_toolbars().length;t++)this.get_toolbars()[t].set_activeEditPanel(this);Sys.Extended.UI.HtmlEditor.LastFocusedEditPanel=this},_really_focused:function(){this._focused(),this.raiseFocused(new Sys.EventArgs)},updateToolbar:function(){this._focused()},getContent:function(){var e=this.get_activePanel().get_content().replace(/<\/?html(?=\s|>)(?:[^>]*?)>/gi,"").replace(/<\/?head(?=\s|>)(?:[^>]*?)>/gi,"").replace(/<\/?body(?=\s|>)(?:[^>]*?)>/gi,"").replace(/^([\n\r]+)/,"").replace(/([\n\r]+)$/,"");return Sys.Extended.UI.HtmlEditor.isIE||(e=e.replace(/^<br\s*[\/]*>$/,"")),e},setContent:function(e){var t=e;this.get_noScript()&&(t=t.replace(/(<script(?:[^>]*?)>(?:[^<]*?)<\/script(?:[^>]*?)>)/gi,"")),t=t.replace(/<\/?html(?=\s|>)(?:[^>]*?)>/gi,"").replace(/<\/?head(?=\s|>)(?:[^>]*?)>/gi,"").replace(/<\/?body(?=\s|>)(?:[^>]*?)>/gi,"").replace(/^([\n\r]+)/,"").replace(/([\n\r]+)$/,""),this._prepareContentForPostback(t),this.get_activePanel().set_content(t),this._validate(null,t)},_validate:function(e,t){var n=this._validators;if(null!=n&&"undefined"!=typeof n){this._contentForValidation=t;try{for(var i=0;i<n.length;i++)window.ValidatorValidate(n[i],null,e);window.ValidatorUpdateIsValid()}catch(e){}this._contentForValidation=null}},_prepareContentForPostback:function(e){this.get_contentElement().value=e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/\"/g,""")},_getContentForPostback:function(){return this.get_contentElement().value.replace(/</g,"<").replace(/>/g,">").replace(/"/g,'"').replace(/&/g,"&")},_setMode:function(e){var t=this.get_activePanel();if(!t._activated){var n=this;return setTimeout(function(){n._setMode(e)},10),!1}var i=this.get_content();if(Sys.Extended.UI.HtmlEditor.isOpera&&(i=i.replace(/\r/gi,"")),this._shouldResize&&e==Sys.Extended.UI.HtmlEditor.ActiveModeType.Html){var s=this.get_activePanel(),a=this.get_modePanels()[Sys.Extended.UI.HtmlEditor.ActiveModeType.Html];if(null!=s&&null!=a){var o,d=s.get_element(),l=d.offsetHeight,r=!1;0==l&&(r=!0,o=Sys.Extended.UI.HtmlEditor.setElementVisibility(d.parentNode),l=d.offsetHeight),a.get_element().style.height=l+"px",r&&(Sys.Extended.UI.HtmlEditor.restoreElementVisibility(o),delete o)}}return this.disableToolbars(e),t._deactivate(),this._activeMode=e,this.setContent(i),!0},disableToolbars:function(e){for(var t=0;t<this.get_toolbars().length;t++){var n=this.get_toolbars()[t];n._loaded&&n.disable(e)}},openWait:function(){},closeWait:function(){}},Sys.Extended.UI.HtmlEditor.EditPanel.registerClass("Sys.Extended.UI.HtmlEditor.EditPanel",Sys.UI.Control); |