org.symbian.tools.wrttools.previewer/preview/script/layout.js
changeset 402 f943a50b6689
child 416 461da1f79f43
equal deleted inserted replaced
400:91acf7e95f86 402:f943a50b6689
       
     1 /**
       
     2  * Copyright (c) 2009-2010 Symbian Foundation and/or its subsidiary(-ies). All
       
     3  * rights reserved. This component and the accompanying materials are made
       
     4  * available under the terms of the License "Eclipse Public License v1.0" which
       
     5  * accompanies this distribution, and is available at the URL
       
     6  * "http://www.eclipse.org/legal/epl-v10.html".
       
     7  * 
       
     8  * Initial Contributors: Nokia Corporation - initial contribution.
       
     9  * 
       
    10  * Contributors:
       
    11  * 
       
    12  * Description:
       
    13  * 
       
    14  */
       
    15 function EmulatorLayout() {
       
    16 	this._console_minimized = true;
       
    17 	this._console_enabled = false;
       
    18 	this._consoleWindowHeight = 290;
       
    19 	this._consoleHeaderHeight = 31;
       
    20 	this._tabHeight = 27;
       
    21 }
       
    22 
       
    23 EmulatorLayout.prototype.init = function() {
       
    24 	// Toggle console window
       
    25 	$('#preview-ui-bottom-header')
       
    26 			.click(
       
    27 					function() {
       
    28 						NOKIA.layout._console_minimized = (NOKIA.layout._console_minimized) ? false
       
    29 								: true;
       
    30 						NOKIA.layout.render();
       
    31 						NOKIA.helper.setPreference("__SYM_NOKIA_CONSOLE_OPEN",
       
    32 								!NOKIA.layout._console_minimized);
       
    33 					});
       
    34 
       
    35 	// clear Log
       
    36 	$("#Console-Clear-Button").click(function() {
       
    37 		$("#preview-ui-bottom-body")[0].innerHTML = '';
       
    38 	});
       
    39 
       
    40 	$('#preview-ui-bottom').show();
       
    41 	NOKIA.layout.render();
       
    42 };
       
    43 
       
    44 EmulatorLayout.prototype.log = function(type, msg) {
       
    45 	var p = document.createElement('p');
       
    46 	p.className = type;
       
    47 	p.innerHTML = msg;
       
    48 	var divBody = $('#preview-ui-bottom-body');
       
    49 	divBody.append(p);
       
    50 	divBody[0].scrollTop = divBody[0].scrollHeight;
       
    51 };
       
    52 
       
    53 EmulatorLayout.prototype.render = function() {
       
    54 	var _width = parseInt(window.innerWidth);
       
    55 	var _height = parseInt(window.innerHeight);
       
    56 
       
    57 	if (!NOKIA.layout._console_enabled) {
       
    58 		$('#preview-ui-bottom').css( {
       
    59 			display : 'none'
       
    60 		});
       
    61 
       
    62 		$('#preview-ui-top').css( {
       
    63 			height : _height + 'px'
       
    64 		});
       
    65 
       
    66 		return false;
       
    67 	}
       
    68 
       
    69 	if (!NOKIA.layout._console_minimized) {
       
    70 		$('#Console-Toggle-Button')[0].className = 'open';
       
    71 
       
    72 		// set STYLE details for TOP window
       
    73 		$('#preview-ui-top').css(
       
    74 				{
       
    75 					height : parseInt(_height
       
    76 							- NOKIA.layout._consoleWindowHeight)
       
    77 							+ 'px'
       
    78 				});
       
    79 
       
    80 		// set STYLE details for Bottom window
       
    81 		$('#preview-ui-bottom').css( {
       
    82 			height : NOKIA.layout._consoleWindowHeight + 'px',
       
    83 			display : 'block'
       
    84 		});
       
    85 
       
    86 		$('#preview-ui-bottom-header').css( {
       
    87 			height : NOKIA.layout._consoleHeaderHeight + 'px'
       
    88 		});
       
    89 
       
    90 		$('#tabs').css(
       
    91 				{
       
    92 					height : parseInt(NOKIA.layout._consoleWindowHeight
       
    93 							- NOKIA.layout._consoleHeaderHeight)
       
    94 							+ 'px',
       
    95 					display : 'block'
       
    96 				});
       
    97 		$('#console').css(
       
    98 				{
       
    99 					height : parseInt(NOKIA.layout._consoleWindowHeight
       
   100 							- NOKIA.layout._consoleHeaderHeight
       
   101 							- NOKIA.layout._tabHeight * 2)
       
   102 							+ 'px',
       
   103 					display : 'block'
       
   104 				});
       
   105 
       
   106 		// Auto scroll when console window opened from MINIMIZED =>
       
   107 		// MAXIMIZED state
       
   108 		window
       
   109 				.setTimeout(
       
   110 						function() {
       
   111 							$('#preview-ui-bottom-body')[0].scrollTop = $('#preview-ui-bottom-body')[0].scrollHeight;
       
   112 						}, 100);
       
   113 
       
   114 	} else {
       
   115 		$('#Console-Toggle-Button')[0].className = 'close';
       
   116 
       
   117 		// set STYLE details for TOP window
       
   118 		$('#preview-ui-top').css(
       
   119 				{
       
   120 					height : parseInt(_height
       
   121 							- NOKIA.layout._consoleHeaderHeight)
       
   122 							+ 'px'
       
   123 				});
       
   124 
       
   125 		// set STYLE details for Bottom window
       
   126 		$('#preview-ui-bottom').css( {
       
   127 			height : NOKIA.layout._consoleHeaderHeight + 'px',
       
   128 			display : 'block'
       
   129 		});
       
   130 
       
   131 		$('#preview-ui-bottom-header').css( {
       
   132 			height : NOKIA.layout._consoleHeaderHeight + 'px',
       
   133 			display : 'block'
       
   134 		});
       
   135 	}
       
   136 };