private void EnsureCloseButton()
    {
        if (ShowCloseButton)
        {
            pnlClose.Attributes.Add("onclick", "return CloseDialog();");
            pnlClose.Style.Add(HtmlTextWriterStyle.Cursor, "pointer");
            pnlClose.ToolTip = GetString("general.close");

            // Do not hide close button on mobile devices (they open a new dialog in a new tab)
            CurrentDeviceInfo device = CMSContext.CurrentDevice;
            if (!device.IsMobile)
            {
                pnlClose.Style.Add(HtmlTextWriterStyle.Display, "none");
            }

            string closeButtonScript = @"

$j(document).ready(function(){
    if(window.wopener && top.visiblePopup)
    {
        var topFrame = GetTop();
        if(top.isTitleWindow(topFrame, window) && !topFrame.closeButtonAvailable)
        {
            $j('#" + pnlClose.ClientID + @"').show();
            topFrame.closeButtonAvailable = true;
            $j(window).unload(function() {
                topFrame.closeButtonAvailable = false;
            });
        }
    }
});
";

            ScriptHelper.RegisterStartupScript(this, typeof(string), "titleClose_" + ClientID, ScriptHelper.GetScript(closeButtonScript));
        }
        else
        {
            cellClose.Visible = false;
        }
    }
예제 #2
0
    protected void Page_Load(object sender, EventArgs e)
    {
        // Display panel with additional controls place holder if required
        if (DisplayControlsPanel)
        {
            pnlAdditionalControls.Visible = true;
        }

        // Display panel with site selector
        if (DisplaySiteSelectorPanel)
        {
            pnlSiteSelector.Visible = true;
        }

        bodyElem.Attributes["class"] = mBodyClass;

        CurrentDeviceInfo device = DeviceContext.CurrentDevice;

        if (!device.IsMobile)
        {
            // Footer - apply fixed position
            pnlFooterContent.Style.Add("position", "fixed");
            pnlFooterContent.Style.Add("width", "100%");
            pnlFooterContent.Style.Add("bottom", "0px");
        }

        StringBuilder resizeScript = new StringBuilder();

        resizeScript.Append(@"
var headerElem = null;
var footerElem = null;
var contentElem = null;
var jIframe = null;
var jIframeContents = null;
var oldClientWidth = 0;
var oldClientHeight = 0;
var dialogCMSHeaderPad = null;
var dialogCKFooter = null;


function ResizeWorkingAreaIE()
{
    ResizeWorkingArea();
    window.onresize = function() { ResizeWorkingArea(); };
}

function ResizeWorkingArea()
{
    if (headerElem == null)
    {
       headerElem = document.getElementById('divHeader');
    }
    if (footerElem == null)
    {
       footerElem = document.getElementById('divFooter');
    }
    if (contentElem == null)
    {
       contentElem = document.getElementById('divContent');
    }

    if (dialogCMSHeaderPad == null)
    {
       dialogCMSHeaderPad = document.getElementById('CMSHeaderPad');
    }

    if (dialogCKFooter == null)
    {
       dialogCKFooter = document.getElementById('CKFooter');
    }

    if ((headerElem != null) && (contentElem != null))
    {
        var headerHeight = headerElem.offsetHeight + ((dialogCMSHeaderPad != null) ? dialogCMSHeaderPad.offsetHeight : 0);
        var footerHeight = ((footerElem != null) ? footerElem.offsetHeight : 0) + ((dialogCKFooter != null) ? dialogCKFooter.offsetHeight : 0);
        var height = ($cmsj(window).height() - headerHeight - footerHeight);
        if (height > 0)
        {
            var h = (height > 0 ? height : '0') + 'px';
            if (contentElem.style.height != h)
            {
                contentElem.style.height = h;
            }
        }");

        if (device.IsMobile)
        {
            resizeScript.Append(@"
        if ((jIframe == null) || (!jIframe.length)) {
            jIframe = $cmsj('.EditableTextEdit iframe:first');
        }
        if ((jIframeContents == null) || (!jIframeContents.length)) {
            jIframeContents = jIframe.contents();
        }

        // Set height of the iframe manually for mobile devices 
        jIframe.css('height', jIframeContents.height());
        // WebKit browsers fix - width of the parent element of the iframe needs to be defined
        jIframe.parent().width(jIframeContents.width());");
        }

        if (BrowserHelper.IsIE())
        {
            resizeScript.Append(@"
        var pnlBody = null;
        var formElem = null;
        var bodyElement = null;
        if (pnlBody == null)
        {
            pnlBody = document.getElementById('", pnlBody.ClientID, @"');
        }
        if (formElem == null)
        {
            formElem = document.getElementById('", form1.ClientID, @"');
        }
        if (bodyElement == null)
        {
            bodyElement = document.getElementById('", bodyElem.ClientID, @"');
        }
        if ((bodyElement != null) && (formElem != null) && (pnlBody != null))
        {
            var newClientWidth = document.documentElement.clientWidth;
            var newClientHeight = document.documentElement.clientHeight;
            if  (newClientWidth != oldClientWidth)
            {
                bodyElement.style.width = newClientWidth;
                formElem.style.width = newClientWidth;
                pnlBody.style.width = newClientWidth;
                headerElem.style.width = newClientWidth;
                contentElem.style.width = newClientWidth;
                oldClientWidth = newClientWidth;
            }
            if  (newClientHeight != oldClientHeight)
            {
                bodyElement.style.height = newClientHeight;
                formElem.style.height = newClientHeight;
                pnlBody.style.height = newClientHeight;
                oldClientHeight = newClientHeight;
            }
        }");
        }

        resizeScript.Append(@"
    }
    if (window.afterResize) {
        window.afterResize();
    }
}");
        if (BrowserHelper.IsIE())
        {
            resizeScript.Append(@"
var timer = setInterval('ResizeWorkingAreaIE();', 50);");
        }
        else
        {
            resizeScript.Append(@"
window.onresize = function() { ResizeWorkingArea(); };
window.onload = function() { ResizeWorkingArea(); };");
        }

        ScriptHelper.RegisterClientScriptBlock(this, typeof(string), "resizeScript", ScriptHelper.GetScript(resizeScript.ToString()));

        if (BrowserHelper.IsIE7())
        {
            ScriptHelper.RegisterStartupScript(this, typeof(string), "ie7ResizeFix", ScriptHelper.GetScript("document.getElementById('divContent').style.height = '0px';"));
        }

        // Register a script that will re-calculate content height when the CKToolbar is displayed
        const string ckEditorScript = @"
if (window.CKEDITOR) {
    CKEDITOR.on('instanceCreated', function(e) {
        e.editor.on('instanceReady', function(e) { setTimeout(function() { ResizeWorkingArea(); }, 200); });
    });
}";

        ScriptHelper.RegisterStartupScript(this, typeof(string), "ckEditorScript", ckEditorScript, true);

        // Register header shadow script
        ScriptHelper.RegisterModule(Page, "CMS/HeaderShadow");
    }
예제 #3
0
    protected override void OnInit(EventArgs e)
    {
        DocumentManager.OnValidateData += DocumentManager_OnValidateData;
        DocumentManager.OnAfterAction  += DocumentManager_OnAfterAction;

        // Process ASPX template parameters
        if (QueryHelper.Contains("regiontype"))
        {
            ucEditableText.RegionType = CMSEditableRegionTypeEnumFunctions.GetRegionTypeEnum(QueryHelper.GetString("regiontype", string.Empty));
            if (ucEditableText.RegionType == CMSEditableRegionTypeEnum.HtmlEditor)
            {
                // HtmlEditor needs toolbar location defined (due to toolbar positioning and editing area padding)
                ucEditableText.HtmlAreaToolbarLocation = "Out:CKToolbar";
            }

            // Min/Max length
            ucEditableText.MaxLength = QueryHelper.GetInteger("maxl", ucEditableText.MaxLength);
            ucEditableText.MinLength = QueryHelper.GetInteger("minl", ucEditableText.MinLength);

            // Editor stylesheet
            ucEditableText.HTMLEditorCssStylesheet = QueryHelper.GetString("editorcss", ucEditableText.HTMLEditorCssStylesheet);

            // Word wrap
            ucEditableText.WordWrap = QueryHelper.GetBoolean("wordwrap", ucEditableText.WordWrap);

            // Upload image dimensions
            ucEditableText.ResizeToHeight      = QueryHelper.GetInteger("resizetoheight", ucEditableText.ResizeToHeight);
            ucEditableText.ResizeToWidth       = QueryHelper.GetInteger("resizetowidth", ucEditableText.ResizeToHeight);
            ucEditableText.ResizeToMaxSideSize = QueryHelper.GetInteger("resizetomaxsidesize", ucEditableText.ResizeToHeight);

            // Toolbar set
            ucEditableText.HtmlAreaToolbar = QueryHelper.GetString("toolbarset", ucEditableText.HtmlAreaToolbar);
        }

        ucEditableText.ViewMode        = CheckPermissions();
        ucEditableText.DataControl     = CurrentWebPartInstance;
        ucEditableText.CurrentPageInfo = CurrentPageInfo;
        ucEditableText.SetupControl();

        CurrentMaster.FooterContainer.Visible = false;
        CurrentMaster.PanelContent.RemoveCssClass("dialog-content");

        string title = GetString("Content.EditTextTitle");

        if (!String.IsNullOrEmpty(PageTitleSuffix))
        {
            title += " - " + HTMLHelper.HTMLEncode(PageTitleSuffix);
        }
        SetTitle(title);

        base.OnInit(e);

        CSSHelper.RegisterCSSLink(Page, "Design", "OnSiteEdit.css");
        ScriptHelper.RegisterJQuery(Page);

        menuElem.ShowSaveAndClose = true;

        String resize = @"function resizeEditor() {$cmsj('.cke_contents').height($cmsj(window).height()-$cmsj('.DialogsPageHeader').height() - $cmsj('.cke_top').height() - $cmsj('.cke_bottom').height() - 20) }
        $cmsj(window).resize(function() {resizeEditor()});";

        ScriptHelper.RegisterClientScriptBlock(this, typeof(Page), "resizeHeight", ScriptHelper.GetScript(resize));

        if (ucEditableText.RegionType == CMSEditableRegionTypeEnum.TextArea)
        {
            const string resizeScript = @"
            var resizeTextAreaTimer;

            // DOM ready
            $cmsj(document).ready( function() { ResizeEditableArea(200); });

            // Window resize
            $cmsj(window).resize(function () { ResizeEditableArea(100); });

            function ResizeEditableArea(timeout) {
                clearTimeout(resizeTextAreaTimer);
                resizeTextAreaTimer = window.setTimeout(function () {
                    var textarea = $cmsj('.EditableTextTextBox');
                    var editableTextContainer = $cmsj('.EditableTextContainer');
                    var editableTextEdit = $cmsj('.EditableTextEdit');
                    var borderMargin1 = textarea.outerHeight(true) - textarea.height();
                    var borderMargin2 = editableTextEdit.outerHeight(true) - editableTextEdit.height();
                    var borderMargin3 = editableTextContainer.outerHeight(true) - editableTextContainer.height();
                    var height = $cmsj('.dialog-content').height() - borderMargin1 - borderMargin2 - borderMargin3;
                    textarea.height(height);
             }, timeout); }";


            ScriptHelper.RegisterClientScriptBlock(this, typeof(Page), "ResizeEditableArea", ScriptHelper.GetScript(resizeScript));
        }

        CurrentDeviceInfo device = DeviceContext.CurrentDevice;

        if (device.IsMobile)
        {
            // Do not use fixed positioning for mobile devices
            (CurrentMaster.HeaderContainer as CMSPanel).FixedPosition = false;
        }
    }
예제 #4
0
    protected override void OnInit(EventArgs e)
    {
        DocumentManager.OnValidateData += new EventHandler <DocumentManagerEventArgs>(DocumentManager_OnValidateData);
        DocumentManager.OnAfterAction  += new EventHandler <DocumentManagerEventArgs>(DocumentManager_OnAfterAction);

        // Set the region type manually for ASPX mode
        if (QueryHelper.Contains("regiontype"))
        {
            ucEditableText.RegionType = CMSEditableRegionTypeEnumFunctions.GetRegionTypeEnum(QueryHelper.GetString("regiontype", string.Empty));
            if (ucEditableText.RegionType == CMSEditableRegionTypeEnum.HtmlEditor)
            {
                // HtmlEditor needs toolbar location defined (due to toolbar positioning and editing area padding)
                ucEditableText.HtmlAreaToolbarLocation = "out:cktoolbar";
            }
        }

        ucEditableText.ViewMode        = CheckPermissions();
        ucEditableText.DataControl     = CurrentWebPartInstance as ISimpleDataContainer;
        ucEditableText.CurrentPageInfo = CurrentPageInfo;
        ucEditableText.IsDialogEdit    = true;
        ucEditableText.SetupControl();

        string title = GetString("Content.EditTextTitle");

        if (!String.IsNullOrEmpty(PageTitleSuffix))
        {
            title += " - " + HTMLHelper.HTMLEncode(PageTitleSuffix);
        }
        SetTitle("CMSModules/CMS_PortalEngine/OnSiteEdit/EditText.png", title, null, null);

        base.OnInit(e);

        CSSHelper.RegisterCSSLink(Page, "Design", "OnSiteEdit.css");
        ScriptHelper.RegisterJQuery(this.Page);

        menuElem.ShowSaveAndClose = true;

        if (ucEditableText.RegionType == CMSEditableRegionTypeEnum.TextArea)
        {
            string resizeScript = @"
            var resizeTextAreaTimer;

            // DOM ready
            jQuery(document).ready( function() { ResizeEditableArea(200); });

            // Window resize
            jQuery(window).resize(function () { ResizeEditableArea(100); });

            function ResizeEditableArea(timeout) {
                clearTimeout(resizeTextAreaTimer);
                resizeTextAreaTimer = window.setTimeout(function () {
                    var textarea = jQuery('.EditableTextTextBox');
                    var editableTextContainer = jQuery('.EditableTextContainer');
                    var editableTextEdit = jQuery('.EditableTextEdit');
                    var borderMargin1 = textarea.outerHeight(true) - textarea.height();
                    var borderMargin2 = editableTextEdit.outerHeight(true) - editableTextEdit.height();
                    var borderMargin3 = editableTextContainer.outerHeight(true) - editableTextContainer.height();
                    var height = jQuery('.ModalDialogContent').height() - borderMargin1 - borderMargin2 - borderMargin3;
                    textarea.height(height);
            }, timeout); }";

            ScriptHelper.RegisterClientScriptBlock(this, typeof(Page), "ResizeEditableArea", ScriptHelper.GetScript(resizeScript));
        }

        CurrentDeviceInfo device = CMSContext.CurrentDevice;

        // Resize of HTML area is handled from editor itself
        if ((ucEditableText.RegionType == CMSEditableRegionTypeEnum.HtmlEditor) && !device.IsMobile)
        {
            // Hide editor area before its fully loaded
            pnlEditor.Style.Add("visibility", "hidden");
        }

        if (device.IsMobile)
        {
            // Do not use fixed positioning for mobile devices
            (CurrentMaster.HeaderContainer as CMSPanel).FixedPosition = false;
        }
    }