/// <summary> /// Handles the PreRender event of the Page control. /// </summary> protected void Page_PreRender(object sender, EventArgs e) { DeviceProfileInfo oldDevice = (currentDevice != null ? currentDevice.Clone() : null); currentDevice = DeviceProfileInfoProvider.GetCurrentDeviceProfileInfo(SiteContext.CurrentSiteName, true); // Reload device menu if profile changed by postback. Apply this, only if no device was selected from outside environment via 'SelectedDevice' property. if ((SelectedDevice == null) && DeviceChanged(oldDevice, currentDevice)) { buttons.Buttons.Clear(); LoadDevicesMenu(); buttons.ReloadButtons(); } }
/// <summary> /// Handles the Load event of the Page control. /// </summary> protected void Page_Load(object sender, EventArgs e) { currentDevice = (SelectedDevice == null) ? DeviceProfileInfoProvider.GetCurrentDeviceProfileInfo(SiteContext.CurrentSiteName, true) : DeviceProfileInfoProvider.GetDeviceProfileInfo(SelectedDevice); LoadDevicesMenu(); if (UseSmallButton && (currentDevice != null) && ((PortalContext.ViewMode == ViewModeEnum.Preview) || DisplayRotateButtons) ) { bool isHorizontalDevice = (currentDevice.ProfilePreviewWidth > currentDevice.ProfilePreviewHeight); bool isHorizontalOrientation = isHorizontalDevice; // Define the rotation buttons CMSButtonGroupAction hButton = new CMSButtonGroupAction { UseIconButton = true, Name = LAYOUT_HORIZONTAL, OnClientClick = "return false;", IconCssClass = "icon-rectangle-o-h", ToolTip = GetString("device.landscape") }; CMSButtonGroupAction vButton = new CMSButtonGroupAction { UseIconButton = true, Name = LAYOUT_VERTICAL, OnClientClick = "return false;", IconCssClass = "icon-rectangle-o-v", ToolTip = GetString("device.portrait") }; // Append the rotation buttons rotationButtons.Actions.Add(hButton); rotationButtons.Actions.Add(vButton); rotationButtons.Visible = true; // Get the current device rotation state isRotated = ValidationHelper.GetBoolean(CookieHelper.GetValue(CookieName.CurrentDeviceProfileRotate), false); if (isRotated) { isHorizontalOrientation = !isHorizontalOrientation; } // Highlight the currently selected rotation button rotationButtons.SelectedActionName = (isHorizontalOrientation) ? LAYOUT_HORIZONTAL : LAYOUT_VERTICAL; StringBuilder sb = new StringBuilder(); sb.Append(@" var CMSDeviceProfile = { Rotated: ", isRotated.ToString().ToLower(), @", Initialized: false, OnRotationFunction: null, PreviewUrl: null, Init: function () { if (!this.Initialized) { this.Initialized = true; var rotateBtns = $cmsj('.device-rotation').find('button'); var activeClass = '", activeButtonCssClass, @"'; rotateBtns.bind('click', function () { var jThis = $cmsj(this); var selected = jThis.hasClass(activeClass); if (!selected) { rotateBtns.removeClass(activeClass); jThis.addClass(activeClass); $cmsj.cookie('", CookieName.CurrentDeviceProfileRotate, @"', !CMSDeviceProfile.Rotated, { path: '/' } ); if (CMSDeviceProfile.OnRotationFunction != null) { CMSDeviceProfile.OnRotationFunction(this, !CMSDeviceProfile.Rotated); } } }); } } } $cmsj(document).ready(function () { CMSDeviceProfile.Init(); });"); ScriptHelper.RegisterClientScriptBlock(this, typeof(String), "deviceProfileScript", sb.ToString(), true); } }
protected void Page_Load(object sender, EventArgs e) { currentDevice = (SelectedDevice == null) ? DeviceProfileInfoProvider.GetCurrentDeviceProfileInfo(CMSContext.CurrentSiteName, true) : DeviceProfileInfoProvider.GetDeviceProfileInfo(SelectedDevice); LoadDevicesMenu(); }