diff -r d3fff58a7af9 -r 3a1db8573f1e Symbian.org/preview/script/build.js --- a/Symbian.org/preview/script/build.js Tue Jul 21 12:23:44 2009 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,681 +0,0 @@ -/* - * Call this function when window is ready - */ - window.onload = function() - { - - // Attach events to Resolution Options & Orientation select - $('deviceResolution').onchange = function(ele){ - if(ele.target != undefined) - ele = ele.target; - - Emulator.cur_device = ele.options[ele.selectedIndex].value; - Emulator.setDeviceLabels(SUPPORTED_DEVICES[Emulator.cur_device]); - - // save the selected device details - createCookie('DEVICE_NAME', Emulator.cur_device); - } - - /* - * Toggle b/w Portrait / Landscape mode - */ - $('DisplayOrientation_portrait').onclick = function(ele){ - - if(ele.target != undefined) - ele = ele.target; - if(Emulator.orientation_mode != 'portrait') - Emulator.changeOrientation(ele); - } - - $('DisplayOrientation_landscape').onclick = function(ele){ - - if(ele.target != undefined) - ele = ele.target; - if(Emulator.orientation_mode != 'landscape') - Emulator.changeOrientation(ele); - } - $('Toolbar').style.right = "-320px"; - - - // Toggle ToolBar Show/Hide - $('pullDown').onclick = function() - { - if(is_toolbar_hidden) - { - showDeviceSettings(); - } - else - { - hideDeviceSettings(); - } - } - - // Toggle ToolBar Show/Hide - $('WrapperDiv').onmouseover = function(){ - if(!is_scrolling && !is_toolbar_hidden) - window.setTimeout('hideDeviceSettings()', 1); - } - - // Assign Soft-keys trigger to Textual links - $("leftSoftKey").onclick = function(){ - Emulator.triggerChildLSK(); - } - $("rightSoftKey").onclick = function(){ - Emulator.triggerChildRSK(); - } - - - // Assign Soft-keys trigger to Image links - $("leftSoftKeyImg").onclick = function(){ - Emulator.triggerChildLSK(); - } - - $("rightSoftKeyImg").onclick = function(){ - Emulator.triggerChildRSK(); - } - - // Preload Device Information - Emulator.loadDeviceSettings(); - - // set the Default size to device - Emulator.setDeviceSize(); - - // set the Menu Pane position - Emulator.setMenuPane(); - } - - -/* - * Helper function - */ - function $(str) - { - return document.getElementById(str); - } - - -/* - * Emulator, which manages the device interacations - */ - - var Emulator = {}; - - // Default, device screen resolution - Emulator.cur_device = 'n78'; - Emulator.cur_resolution = '240x320'; - Emulator.device_cover_width = 17; - Emulator.device_cover_height = 8; - - Emulator.orientation_changed = false; - Emulator.orientation_mode = 'portrait'; // { portrait | landscape } - - // Flag, inidcates Menu Object created/exists in the child window - Emulator.is_widgetMenuIntiated = false; - - // Used as a bridge between, Parent window & Child widget - Emulator.parentToChild_Reference = null; - - // Interval ID for X-Resize - Emulator.interval_X = null; - - // Interval ID for Y-Resize - Emulator.interval_Y = null; - - Emulator.path = document.location.pathname; - -/* - * Change the device resolution - */ - - Emulator.changeResolution = function(cur_val, to_val) - { - - if(!SUPPORTED_DEVICES[this.cur_device]['orientation']){ - - // check the Portrait mode - $("DisplayOrientation_portrait").checked = true; - - $("DisplayOrientation_landscape").checked = false; - $("DisplayOrientation_landscape").disabled = true; - - // update the orientation-mode - this.orientation_mode = 'portrait'; - - - // Toggle the Orientation Flag - this.orientation_changed = false; - - } - else - $("DisplayOrientation_landscape").disabled = false; - - if(cur_val == to_val) - return false; - - cur_val = cur_val.split('x'); - cur_val[0] = parseInt(cur_val[0]); - cur_val[1] = parseInt(cur_val[1]); - - to_val = to_val.split('x'); - to_val[0] = parseInt(to_val[0]); - to_val[1] = parseInt(to_val[1]); - - // hide the keys, if the OPTION menu is OPEN - this.hideDeviceSoftKeys(); - - $('widgetIframeWindow').style.height = '100%'; - $('menuItemsPane').style.width = to_val[0]+'px'; - - - // for X - var adjust_x = 0; - if(cur_val[0]%10) - { - // decrease these many pixels - adjust_x = ((cur_val[0]%10) * (-1)); - } - else if(to_val[0]%10){ - // increase these many pixels - adjust_x = (to_val[0]%10); - } - - cur_val[0] = cur_val[0] + adjust_x; - $('iframePreviewWindow').style.width = parseInt(cur_val[0] + adjust_x) + 'px'; - $('device').style.width = parseInt(cur_val[0] + adjust_x) + this.device_cover_width+'px'; - - - if (cur_val[0] < to_val[0]) - { - this.resizeDivX(cur_val[0], to_val[0], true); - } - else - { - this.resizeDivX(cur_val[0], to_val[0], false); - } - - - // for Y - var adjust_y = 0; - if(cur_val[1]%10) - { - // decrease these many pixels - adjust_y = ((cur_val[1]%10) * (-1)); - } - else if(to_val[1]%10){ - // increase these many pixels - adjust_y = (to_val[1]%10); - } - cur_val[1] = cur_val[1] + adjust_y; - - $('iframePreviewWindow').style.height = parseInt(cur_val[1] + adjust_y) + 'px'; - $('device').style.height = parseInt(cur_val[1] + adjust_y) + this.device_cover_height+'px'; - - if (cur_val[1] < to_val[1]) - { - this.resizeDivY(cur_val[1], to_val[1], true); - } - else - { - this.resizeDivY(cur_val[1], to_val[1], false); - } - - } - -/* - * Resize the device on Horizontally - */ - - Emulator.resizeDivX = function(from, to, flag) - { - if(from != to) - { - var curWidth = $('iframePreviewWindow').style.width; - curWidth = parseInt(curWidth.substr(0, (curWidth.length-2))); - if(flag) - { - curWidth = curWidth + 10; - to = parseInt(to) - 10; - } - else - { - curWidth = curWidth - 10; - to = parseInt(to) + 10; - } - $('iframePreviewWindow').style.width = curWidth + 'px'; - $('device').style.width = parseInt(curWidth + this.device_cover_width)+'px'; - - if(this.interval_X) - clearInterval(this.interval_X); - this.interval_X = setInterval(function(){ Emulator.resizeDivX(from, to, flag); }, 10); - } - else{ - clearInterval(this.interval_X); - } - } - -/* - * Resize the device on Vertically - */ - - Emulator.resizeDivY = function(from, to, flag) - { - if(from != to) - { - var curHeight = $('iframePreviewWindow').style.height; - curHeight = parseInt(curHeight.substr(0, (curHeight.length-2))); - if(flag) - { - curHeight = curHeight + 10; - to = parseInt(to) - 10; - } - else - { - curHeight = curHeight - 10; - to = parseInt(to) + 10; - } - $('iframePreviewWindow').style.height = curHeight + 'px'; - $('device').style.height = parseInt(curHeight+this.device_cover_height)+'px'; - - if(this.interval_Y) - clearInterval(this.interval_Y); - this.interval_Y = setInterval(function(){ Emulator.resizeDivY(from, to, flag); }, 10); - } - else - { - clearInterval(this.interval_Y); - - /* - * Cross check, why i have written these lines @P-1 - */ - if(!this.parentToChild_Reference.menu.is_sfk_disabled) - { - // show menu Pane - Emulator.setMenuPane(); - $('menuPane').style.display = 'block'; - } - - } - } - -/* - * Toggle device orienation b/w Landscape & Portrait - */ - Emulator.changeOrientation = function(ele) - { - if(SUPPORTED_DEVICES[this.cur_device]['orientation']) - { - // If the device supports Orientation, perform - if(this.parentToChild_Reference.widget.isrotationsupported) - { - // Swap the current resolution value - // Width -> Height - // height -> Width - var cur_val = this.cur_resolution; - this.cur_resolution = this.cur_resolution.split('x'); - this.cur_resolution = this.cur_resolution[1]+'x'+this.cur_resolution[0]; - - // Toggle the Orientation Flag - this.orientation_changed = (this.orientation_changed) ? false : true; - - // Toggle the Orientation value - this.orientation_mode = (this.orientation_mode == 'portrait') ? 'landscape' : 'portrait'; - - // Apply the new resolution to the device - this.changeResolution(cur_val, this.cur_resolution); - } - } - else{ - // update the orientation-mode - this.orientation_mode = 'portrait'; - - // Toggle the Orientation Flag - this.orientation_changed = false; - } - } - - -/* - * Set the Device size - */ - Emulator.setDeviceSize = function() - { - var cur_val; - try - { - this.cur_device = readCookie('DEVICE_NAME'); - if(this.cur_device == undefined) - { - this.cur_device = $('deviceResolution').options[0].value; - } - } - catch(e) - { - this.cur_device = $('deviceResolution').options[0].value; - } - - // get Device resolution - this.cur_resolution = SUPPORTED_DEVICES[this.cur_device]['display'] - - - // update the Device label values - this.setDeviceLabels(SUPPORTED_DEVICES[this.cur_device]); - - // select the corresponding option on the list - var select = $('deviceResolution'); - for(var i=0; i