org.symbian.tools.wrttools.previewer/preview/script/nokia.js
changeset 402 f943a50b6689
parent 396 11ff5aef0e96
child 403 ba20dd5983c7
equal deleted inserted replaced
400:91acf7e95f86 402:f943a50b6689
   125 
   125 
   126 		//	validating Info.plist
   126 		//	validating Info.plist
   127 		this.helper.getInfo('Info.plist', NOKIA.helper.getInfoCallback);	
   127 		this.helper.getInfo('Info.plist', NOKIA.helper.getInfoCallback);	
   128 
   128 
   129 		//	For getting Icon.png
   129 		//	For getting Icon.png
   130 		this.helper.getInfo('Icon.png', NOKIA.helper.getIconCallback);	
   130 		this.helper.getInfo('Icon.png', NOKIA.helper.getIconCallback);
       
   131 		
       
   132 		new RotationSupport(accelerationCallback);
   131 	};
   133 	};
   132 
   134 
   133 	/*
   135 	/*
   134 	 * NOKIA.data
   136 	 * NOKIA.data
   135 	 */
   137 	 */
   137 
   139 
   138 	NOKIA.data.load = function(data){
   140 	NOKIA.data.load = function(data){
   139 		NOKIA.deviceList = data;
   141 		NOKIA.deviceList = data;
   140 	};
   142 	};
   141 
   143 
   142 
       
   143 
       
   144 	/*
   144 	/*
   145 	 * NOKIA.emulator
   145 	 * NOKIA.emulator
   146 	 */
   146 	 */
   147 	NOKIA.namespace('menu');
   147 	NOKIA.namespace('menu');
   148 	NOKIA.menu = {
   148 	NOKIA.menu = new EmulatorMenu();
   149 		is_menu_visible : false,		// true/false
       
   150 		is_softkeys_visible : false,	// true : only when MenuItem's are displayed
       
   151 		softkeys_visibility : true,		// true/false : for hide/show SFK's
       
   152 		is_dimmed : false,
       
   153 		is_rsk_overridden : false,
       
   154 		log_counter : 1,
       
   155 		enable_log : false,
       
   156 		rsk_label : '',
       
   157 		rsk_event : false,
       
   158 		highlighted_item : null,
       
   159 		
       
   160 		hide : function()
       
   161 		{
       
   162 			$("#MenuItemsArea").fadeIn("slow");
       
   163 
       
   164 			//	Hide the SFK's If user hidden them from his code
       
   165 			if(NOKIA.menu.softkeys_visibility)
       
   166 				$("#SoftKeysArea").fadeIn("slow");
       
   167 			
       
   168 			NOKIA.menu.is_softkeys_visible = false;
       
   169 		},
       
   170 
       
   171 		log : function(str)
       
   172 		{
       
   173 			if(!this.enable_log)
       
   174 				return false;
       
   175 			NOKIA.layout.log("log", NOKIA.menu.log_counter + ' ' +str);
       
   176 			NOKIA.layout.log("log", 'is_rsk_overridden: '+NOKIA.menu.is_rsk_overridden);
       
   177 			NOKIA.layout.log("log", 'rsk_label: '+NOKIA.menu.rsk_label);
       
   178 			NOKIA.layout.log("log", 'rsk_event: '+NOKIA.menu.rsk_event);
       
   179 			
       
   180 			NOKIA.menu.log_counter++;
       
   181 		},
       
   182 
       
   183 		show : function()
       
   184 		{
       
   185 			if(NOKIA.menu.is_dimmed)
       
   186 				return false;
       
   187 				
       
   188 			NOKIA.menu.showSoftKeys();
       
   189 			
       
   190 			NOKIA.menu.is_menu_visible = true;
       
   191 			$("#MenuItemsArea").show();
       
   192 			
       
   193 			NOKIA.menu.highlighted_item = $("#MenuItemsArea > ul > li")[0];
       
   194 			NOKIA.menu.highlighted_item.className = 'active';
       
   195 
       
   196 
       
   197 			$("#MenuItemsArea > ul > li").mouseover(function(){
       
   198 				if(NOKIA.menu.highlighted_item != null)
       
   199 				{
       
   200 					NOKIA.menu.highlighted_item.className = '';
       
   201 					NOKIA.menu.highlighted_item = null;
       
   202 				}
       
   203 
       
   204 				NOKIA.menu.highlighted_item = this;
       
   205 				NOKIA.menu.highlighted_item.className = 'active';
       
   206 			});
       
   207 
       
   208 			$("#SoftKeysArea").mouseout(function(){
       
   209 				if (!NOKIA.menu.is_menu_visible) {
       
   210 					return false;
       
   211 				}
       
   212 				
       
   213 				if (NOKIA.helper.intervalId) {
       
   214 					clearInterval(NOKIA.helper.intervalId);
       
   215 				}
       
   216 				NOKIA.helper.intervalId = setTimeout(function(){
       
   217 					NOKIA.menu.cancel();
       
   218 				}, 500);
       
   219 			});
       
   220 
       
   221 
       
   222 			//	Change the label "Options" to "Select" to LSK
       
   223 			$("#LskLabel > a")[0].innerHTML = "Select";
       
   224 			NOKIA.menu.setLsk(NOKIA.menu.selectMenu);
       
   225 			
       
   226 			//	Change the label "Exit" to "Cancel" to RSK
       
   227 			$("#RskLabel > a")[0].innerHTML = 'Cancel';
       
   228 			NOKIA.menu.setRsk(NOKIA.menu.cancel);
       
   229 			
       
   230 
       
   231 			NOKIA.emulator.setMenuItemsStyle();
       
   232 			
       
   233 		},
       
   234 		
       
   235 		selectMenu : function(){
       
   236 			try {
       
   237 				if(typeof NOKIA.menu.highlighted_item.onclick != 'undefined'){
       
   238 					eval(NOKIA.menu.highlighted_item.onclick)();
       
   239 				}
       
   240 			} catch (e) {
       
   241 				
       
   242 			}
       
   243 //			NOKIA.menu.cancel();
       
   244 		},
       
   245 
       
   246 		
       
   247 		cancel : function()
       
   248 		{
       
   249 			if(NOKIA.menu.is_dimmed)
       
   250 				return false;
       
   251 				
       
   252 			NOKIA.menu.hideSoftKeys();
       
   253 
       
   254 			NOKIA.menu.is_menu_visible = false;
       
   255 			$("#MenuItemsArea").hide();
       
   256 
       
   257 			//	Reset the "OPTION" label to LSK
       
   258 			$("#LskLabel > a")[0].innerHTML = 'Options';
       
   259 			NOKIA.menu.setLsk(NOKIA.emulator.child.menu.show);
       
   260 
       
   261 			//	Change the label "CANCEL" to "EXIT" to RSK
       
   262 			if(!NOKIA.menu.is_rsk_overridden)
       
   263 			{
       
   264 				$("#RskLabel > a")[0].innerHTML = 'Exit';
       
   265 				NOKIA.menu.setRsk(NOKIA.menu.exit);	
       
   266 			}
       
   267 			else
       
   268 			{
       
   269 				$("#RskLabel > a")[0].innerHTML = NOKIA.menu.rsk_label;
       
   270 				NOKIA.menu.setRsk(NOKIA.menu.rsk_event);	
       
   271 			}
       
   272 			
       
   273 		},
       
   274 
       
   275 		exit : function()
       
   276 		{
       
   277 			if(NOKIA.menu.is_dimmed)
       
   278 				return false;
       
   279 				
       
   280 			if(NOKIA.helper.setHomeScreen())
       
   281 				return false;
       
   282 
       
   283 			//	clear the Menu Settings
       
   284 			NOKIA.menu.cancel();
       
   285 			NOKIA.emulator.child.menu.setRightSoftkeyLabel('', null);
       
   286 			NOKIA.emulator.child.menu.items = [];
       
   287 			NOKIA.menu.softkeys_visibility = false;
       
   288 			
       
   289 			// Hide Widget DIV
       
   290 			NOKIA.menu.hideSoftKeys();
       
   291 			NOKIA.menu.setLsk(function(){});
       
   292 			NOKIA.menu.setRsk(function(){});
       
   293 			
       
   294 			$("#WidgetArea").hide();
       
   295 
       
   296 			//	Show Icon
       
   297 			var style = NOKIA.deviceList[NOKIA.currentDevice][NOKIA.mode]['style'];
       
   298 			$('#IconArea').css({
       
   299 				'width' 	:	'100%',
       
   300 				'height'	:	style['widget']['height']+'px',
       
   301 				'float' 	:	style['widget']['float']
       
   302 			});
       
   303 			
       
   304 			$('#IconArea')[0].className = NOKIA.mode+NOKIA.currentDevice;
       
   305 			
       
   306 			var img = document.createElement('img');
       
   307 			img.src = NOKIA.emulator.iconFile;
       
   308 			img.border = 0;
       
   309 			
       
   310 			var div = document.createElement('div');
       
   311 			var p = document.createElement('p');
       
   312 			
       
   313 			if(NOKIA.emulator.plist.DisplayName.length <= 12)
       
   314 				p.innerHTML = NOKIA.emulator.plist.DisplayName; 
       
   315 			else
       
   316 				p.innerHTML = NOKIA.emulator.plist.DisplayName.substr(0, 11) + '...';
       
   317 
       
   318 			div.className = 'IconFile';
       
   319 			div.style.marginTop = parseInt(parseInt(style['widget']['height']/2)-80) + 'px';
       
   320 			div.appendChild(img);
       
   321 			img.onclick = function(){
       
   322 				
       
   323 				//	close the console DIV
       
   324 				NOKIA.layout._console_enabled = false;
       
   325 				NOKIA.layout.render();
       
   326 				
       
   327 				$("#loaderDiv").html("Widget is loading. Please wait...");
       
   328 				$("#loaderDiv")[0].className = 'green';
       
   329 				$("#loaderDiv").show();
       
   330 				window.setTimeout(function(){
       
   331 					document.location = document.location;
       
   332 				}, 3000);
       
   333 				
       
   334 			};
       
   335 			
       
   336 			div.appendChild(p);
       
   337 
       
   338 			$("#loaderDiv").html("Click on Icon to Launch Widget");
       
   339 			$("#loaderDiv").show();
       
   340 			$("#loaderDiv")[0].className = 'yellow';
       
   341 
       
   342 			$('#IconArea').append(div);
       
   343 			$('#IconArea').show();
       
   344 
       
   345 			NOKIA.menu.is_dimmed = true;
       
   346 			
       
   347 		},
       
   348 		
       
   349 		setLsk : function(func)
       
   350 		{
       
   351 			//	for RSK
       
   352 			$('#LskArea')[0].onclick = function(){
       
   353 				if(!NOKIA.menu.is_dimmed)
       
   354 					func();
       
   355 			};
       
   356 		
       
   357 			$('#LskLabel > a')[0].onclick = function(){
       
   358 				if(!NOKIA.menu.is_dimmed)
       
   359 					func();
       
   360 			};
       
   361 
       
   362 			return true;
       
   363 		},
       
   364 		
       
   365 		setRsk : function(func)
       
   366 		{
       
   367 			//	for RSK
       
   368 			$('#RskArea')[0].onclick = function(){
       
   369 				if(!NOKIA.menu.is_dimmed)
       
   370 					func();
       
   371 			};
       
   372 			
       
   373 			$('#RskLabel > a')[0].onclick = function(){
       
   374 				if(!NOKIA.menu.is_dimmed)
       
   375 					func();
       
   376 			};
       
   377 			
       
   378 			return true;
       
   379 		},
       
   380 
       
   381 
       
   382 		triggerLsk : function(event)
       
   383 		{
       
   384 			var callback;
       
   385 			if(NOKIA.mode == 'portrait')
       
   386 				callback = NOKIA.menu.lsk_event;
       
   387 			else if( (NOKIA.mode == 'landscape') && (event.id =='LskLabel') )
       
   388 				callback = NOKIA.menu.lsk_event;
       
   389 			else
       
   390 				callback = NOKIA.menu.rsk_event;
       
   391 			
       
   392 			if(typeof callback == 'function' && !NOKIA.menu.is_dimmed)
       
   393 			{
       
   394 				callback();
       
   395 			}
       
   396 		},
       
   397 
       
   398 		triggerRsk : function(event)
       
   399 		{
       
   400 			var callback;
       
   401 			if(NOKIA.mode == 'portrait')
       
   402 				callback = NOKIA.menu.rsk_event;
       
   403 			else if( (NOKIA.mode == 'landscape') && (event.id =='RskLabel') )
       
   404 				callback = NOKIA.menu.rsk_event;
       
   405 			else
       
   406 				callback = NOKIA.menu.lsk_event;
       
   407 			
       
   408 			if(typeof callback == 'function')
       
   409 			{
       
   410 				if(!NOKIA.menu.is_dimmed)
       
   411 				{
       
   412 					callback();
       
   413 					NOKIA.menu.cancel();
       
   414 				}
       
   415 			}
       
   416 		},
       
   417 		
       
   418 		render : function()
       
   419 		{
       
   420 			if(!NOKIA.menu.softkeys_visibility)
       
   421 				NOKIA.menu.hideSoftKeys();
       
   422 			else
       
   423 				NOKIA.menu.showSoftKeys();
       
   424 			
       
   425 			NOKIA.emulator.setWidgetStyle();
       
   426 		},
       
   427 		
       
   428 
       
   429 		init : function()
       
   430 		{
       
   431 			NOKIA.menu.render();
       
   432 		},
       
   433 		
       
   434 		createSFKArea : function()
       
   435 		{
       
   436 			var a = $('#SoftKeys > a');
       
   437 			a.html('');
       
   438 			
       
   439 			var preferences = NOKIA.deviceList[NOKIA.currentDevice][NOKIA.mode];
       
   440 			
       
   441 			var lsk = document.createElement('img');
       
   442 			lsk.border="0";
       
   443 			lsk.id = "LskArea";
       
   444 			lsk.name ="LskArea";
       
   445 			lsk.src = "preview/images/TransperantImage.png";
       
   446 			lsk.style.width = preferences.style.softkeysImg.width; 
       
   447 			lsk.style.height = preferences.style.softkeysImg.height;
       
   448 			
       
   449 			var rsk = document.createElement('img');
       
   450 			rsk.border = 0;
       
   451 			rsk.id = "RskArea";
       
   452 			rsk.name = "RskArea";
       
   453 			rsk.src = "preview/images/TransperantImage.png";
       
   454 			rsk.style.width = preferences.style.softkeysImg.width; 
       
   455 			rsk.style.height = preferences.style.softkeysImg.height;
       
   456 
       
   457 			if(NOKIA.mode == 'portrait')
       
   458 			{	
       
   459 				lsk.onclick = function(){
       
   460 					$("#LskLabel > a").trigger('click');
       
   461 				};
       
   462 				a[0].appendChild(lsk);
       
   463 
       
   464 				rsk.onclick = function(){
       
   465 					$("#RskLabel > a").trigger('click');
       
   466 				};
       
   467 				a[1].appendChild(rsk);
       
   468 
       
   469 			}else{
       
   470 
       
   471 				rsk.onclick = function(){
       
   472 					$("#RskLabel > a").trigger('click');
       
   473 				};
       
   474 				a[0].appendChild(rsk);
       
   475 
       
   476 				lsk.onclick = function(){
       
   477 					$("#LskLabel > a").trigger('click');
       
   478 				};
       
   479 				a[1].appendChild(lsk);
       
   480 			}
       
   481 			
       
   482 			
       
   483 		},
       
   484 
       
   485 		showSoftKeys : function()
       
   486 		{
       
   487 			NOKIA.menu.is_softkeys_visible = true;
       
   488 
       
   489 			NOKIA.emulator.setWidgetStyle();
       
   490 			$("#SoftKeysArea").show();
       
   491 		},
       
   492 		
       
   493 		hideSoftKeys : function()
       
   494 		{
       
   495 			//	Hide the SFK's If user hidden them from his code
       
   496 			if(!NOKIA.menu.softkeys_visibility)
       
   497 				$("#SoftKeysArea").hide();
       
   498 			
       
   499 			NOKIA.menu.is_softkeys_visible = false;
       
   500 
       
   501 			NOKIA.emulator.setWidgetStyle();
       
   502 		}
       
   503 	};
       
   504 
       
   505 
       
   506 
   149 
   507 	/*
   150 	/*
   508 	 * NOKIA.emulator
   151 	 * NOKIA.emulator
   509 	 */
   152 	 */
   510 	NOKIA.namespace('emulator');
   153 	NOKIA.namespace('emulator');
   511 	NOKIA.emulator = {
   154 	NOKIA.emulator = new Emulator();
   512 		child : false,
       
   513 		iconFile : 'preview/images/default-Icon.png',
       
   514 		loaded : false,
       
   515 		plist : {
       
   516 			DisplayName	:	'',
       
   517 			Identifier	:	'',
       
   518 			MainHTML	:	'',
       
   519 			AllowNetworkAccess	:	"false",
       
   520 			Version		:	'',
       
   521 			MiniViewEnabled		:	"false",
       
   522 			is_browserReady : false
       
   523 		},
       
   524 		
       
   525 		load : function()
       
   526 		{
       
   527 			if(this.loaded)
       
   528 				return false;
       
   529 			NOKIA.layout._console_minimized = (NOKIA.helper.getPreference('__SYM_NOKIA_CONSOLE_OPEN') != "true");
       
   530 			//	load the saved device Info
       
   531 			var device = NOKIA.helper.getPreference('__SYM_NOKIA_EMULATOR_DEVICE');
       
   532 			NOKIA.currentDevice = device || NOKIA.currentDevice;
       
   533 
       
   534 			//	load the saved device mode
       
   535 			var mode = NOKIA.helper.getPreference('__SYM_NOKIA_EMULATOR_DEVICE_MODE');
       
   536 			if(mode != null)
       
   537 				NOKIA.mode = mode;
       
   538 
       
   539 			var orientation = Number(NOKIA.helper.getPreference('__SYM_NOKIA_EMULATOR_ORIENTATION'));
       
   540 			if (typeof orientation == "number" && orientation >= -90 && orientation <= 180)
       
   541 				NOKIA.orientation = orientation;
       
   542 			
       
   543 			//	SAVE the device DATA
       
   544 			NOKIA.helper.setPreference('__SYM_NOKIA_EMULATOR_DEVICE', NOKIA.currentDevice);
       
   545 			NOKIA.helper.setPreference('__SYM_NOKIA_EMULATOR_DEVICE_MODE', NOKIA.mode);
       
   546 			NOKIA.helper.setPreference('__SYM_NOKIA_EMULATOR_ORIENTATION', NOKIA.orientation);
       
   547 			
       
   548 			this.loaded = true;
       
   549 			
       
   550 		},
       
   551 	
       
   552 		render : function()
       
   553 		{
       
   554 			this.load();
       
   555 			//	Selecting Resoltion
       
   556 			var resOptions = $("#resOptions")[0];
       
   557 			for(var i=0; i<NOKIA.resolution.length; i++)
       
   558 			{
       
   559 				if(NOKIA.resolution[i] == NOKIA.currentDevice)
       
   560 				{
       
   561 					resOptions.options[i].selected = true;
       
   562 					break;
       
   563 				}				
       
   564 			}
       
   565 
       
   566 			if(!NOKIA.emulator.orientationSupports())
       
   567 				NOKIA.mode = NOKIA.deviceList[NOKIA.currentDevice]['default'];
       
   568 			
       
   569 			if(typeof NOKIA.deviceList == 'undefined' || typeof NOKIA.deviceList[NOKIA.currentDevice] == 'undefined' || typeof NOKIA.deviceList[NOKIA.currentDevice][NOKIA.mode] == 'undefined')
       
   570 			{
       
   571 				alert('Deive resolution: '+NOKIA.currentDevice+' or the mode: '+NOKIA.mode+' not found');
       
   572 				return false;
       
   573 			}
       
   574 			
       
   575 			this.setStyle();
       
   576 			var or = (NOKIA.mode == 'portrait') ? NOKIA.orientation : (NOKIA.orientation + 90);
       
   577 			var val = "rotate(" + or + "deg)";
       
   578 			$("#DeviceDisplayLayout").css("-moz-transform", val);
       
   579 			$("#DeviceDisplayLayout").css("-webkit-transform", val);
       
   580 		},
       
   581 		
       
   582 		setMode : function(mode)
       
   583 		{
       
   584 			NOKIA.mode = mode;
       
   585 
       
   586 			//	SAVE the device DATA
       
   587 			NOKIA.helper.setPreference('__SYM_NOKIA_EMULATOR_DEVICE_MODE', NOKIA.mode);
       
   588 
       
   589 			NOKIA.emulator.render();
       
   590 		},
       
   591 		
       
   592 		toggle : function(o)
       
   593 		{
       
   594 			NOKIA.orientation = o;
       
   595 			NOKIA.helper.setPreference('__SYM_NOKIA_EMULATOR_ORIENTATION', NOKIA.orientation);
       
   596 			NOKIA.emulator.child.device.implementation.setOrientation(o, 0);
       
   597 			if (NOKIA.emulator.orientationSupports() && (o == 0 || o == -90)) {
       
   598 				NOKIA.emulator.setMode(o == 0 ? 'portrait' : 'landscape');
       
   599 			} else {
       
   600 				NOKIA.emulator.render();
       
   601 			}
       
   602 		},
       
   603 		
       
   604 		orientationSupports : function()
       
   605 		{
       
   606 			return NOKIA.deviceList[NOKIA.currentDevice]['orientation'];
       
   607 		},
       
   608 		
       
   609 		setStyle:function()
       
   610 		{
       
   611 			if(!NOKIA.helper.checkDependencies())
       
   612 			{
       
   613 				setTimeout(NOKIA.emulator.setStyle, 1000);
       
   614 			}
       
   615 			
       
   616 			var deviceProperties = NOKIA.deviceList[NOKIA.currentDevice][NOKIA.mode];
       
   617 			var style = deviceProperties['style'];
       
   618 
       
   619 			//	Apply Style and propertis to Device layers
       
   620 			$("#DeviceDisplayLayout").css(style['layout']);
       
   621 			$('#DisplayArea').css(style['display']);
       
   622 			
       
   623 			NOKIA.emulator.setWidgetStyle();
       
   624 			
       
   625 			$('#SoftKeysArea').css({
       
   626 				'width'	:	style['menu']['width']+'px',
       
   627 				'height'	:	style['menu']['height']+'px',
       
   628 				'float' 	:	style['menu']['float']
       
   629 			});
       
   630 			
       
   631 			$('#SoftKeysArea > ul > li').css('width', parseInt(style['menu']['width']/2)-10);
       
   632 
       
   633 			
       
   634 			NOKIA.emulator.setMenuItemsStyle();
       
   635 			
       
   636 			$('#SoftKeys').css(style['softkeys']);
       
   637 //			$('#SoftKeys > a > img').css(style['softkeysImg']);
       
   638 
       
   639 			NOKIA.menu.createSFKArea();
       
   640 			
       
   641 			$("#DeviceDisplayLayout").show();
       
   642 			$("#InspectorTab").show();
       
   643 			
       
   644 			if (/chrome/.test( navigator.userAgent.toLowerCase())) {
       
   645 				$("#InspectorBtn").show();
       
   646 			}
       
   647 			if (/mac/.test( navigator.userAgent.toLowerCase())) {
       
   648 				$("#MacShortcut").show();
       
   649 			} else {
       
   650 				$("#UniversalShortcut").show();
       
   651 			}
       
   652 		},
       
   653 		
       
   654 		setWidgetStyle : function()
       
   655 		{
       
   656 			var style = NOKIA.deviceList[NOKIA.currentDevice][NOKIA.mode]['style'];
       
   657 			var height;
       
   658 			if(NOKIA.menu.softkeys_visibility || NOKIA.menu.is_softkeys_visible)
       
   659 				height = parseInt(style['widget']['height'] - style['menu']['height']);
       
   660 			else
       
   661 				height = style['widget']['height'];
       
   662 
       
   663 			$('#WidgetArea').css({
       
   664 				'width' 	:	style['widget']['width']+'px',
       
   665 				'height'	:	height+'px',
       
   666 				'float' 	:	style['widget']['float']
       
   667 			});
       
   668 		},
       
   669 		
       
   670 		setMenuItemsStyle : function()
       
   671 		{
       
   672 			var style 	= NOKIA.deviceList[NOKIA.currentDevice][NOKIA.mode]['style'];
       
   673 			var count = 1;
       
   674 			try {
       
   675 				if (NOKIA.emulator.child.menu) {
       
   676 					count = parseInt(NOKIA.helper.getElementsLengthInObject(NOKIA.emulator.child.menu.items)) + 1;
       
   677 				}
       
   678 			} catch (e) {
       
   679 				count = 1;
       
   680 			}
       
   681 			var height 	= parseInt(count*style['menu']['optionKeysheight']) + 10;
       
   682 			var top 	= parseInt(style['widget']['height'] - height); 
       
   683 
       
   684 			$('#MenuItemsArea').css({
       
   685 				'width'		:	style['widget']['width']+'px',
       
   686 				'height'	:	height+'px',
       
   687 				'marginTop'	:	'-2px',
       
   688 				'top'		:	(style['widget']['height']-height-style['menu']['height']+2)+'px',
       
   689 				'position'	: 	'relative'
       
   690 			});
       
   691 		}
       
   692 	};
       
   693 
   155 
   694 	/*
   156 	/*
   695 	 * NOKIA.helper functions
   157 	 * NOKIA.helper functions
   696 	 */
   158 	 */
   697 	NOKIA.namespace('helper.loadScript');
   159 	NOKIA.namespace('helper.loadScript');
   698 	NOKIA.helper = {
   160 	NOKIA.helper = new EmulatorHelper();
   699 		path : document.location.pathname,
       
   700 		errorDailog	: null,
       
   701 		prefDailog : null,
       
   702 		inspectorDailog : null,
       
   703 		intervalId : null,
       
   704 		infoPlistCounter : false,
       
   705 		IconFileCounter  : false,
       
   706 		loadScript : function(path)
       
   707 		{
       
   708 			var head = document.getElementsByTagName("head")[0] || document.documentElement;
       
   709 			var script = document.createElement("script");
       
   710 	
       
   711 			script.type = "text/javascript";
       
   712 			script.src = src;
       
   713 			head.appendChild( script );
       
   714 		},
       
   715 
       
   716 		loadPreferences : function()
       
   717 		{
       
   718 			if(/dreamweaver/i.test(navigator.userAgent))
       
   719 			{
       
   720 				$("#dwDeviceHelp")[0].className = '';
       
   721 //				$("#resSupportLink")[0].className = 'hide';
       
   722 			}
       
   723 			//	Selecting Resoltion
       
   724 			var resOptions = $("#resOptions")[0];
       
   725 			for(var i=0; i<NOKIA.resolution.length; i++)
       
   726 			{
       
   727 				if(NOKIA.resolution[i] == NOKIA.currentDevice)
       
   728 				{
       
   729 					resOptions.options[i].selected = true;
       
   730 					break;
       
   731 				}				
       
   732 			}
       
   733 			
       
   734 			//	Selecting Version
       
   735 			if(NOKIA.version == 'WRT 1.0')
       
   736 				$('#wrt_version_1_0')[0].checked = true;
       
   737 			else
       
   738 				$('#wrt_version_1_1')[0].checked = true;
       
   739 				
       
   740 			//	HomeScreen Support
       
   741 			if(NOKIA.deviceList[NOKIA.currentDevice].homeScreenSupport)
       
   742 			{
       
   743 				if (typeof NOKIA.emulator.plist.MiniViewEnabled != 'undefined') {
       
   744 					if (NOKIA.emulator.plist.MiniViewEnabled == 'false') 
       
   745 						$('#HS_Control_Info').html("<span id='wrt-help' onclick='javascipt:NOKIA.helper.showMiniviewHelp();'></span><strong>Not Enabled</strong><br/><small>Click on help to read more about enabling Mini view support</small>");
       
   746 					else 
       
   747 						$('#HS_Control_Info').html("Supported");
       
   748 				}
       
   749 				else
       
   750 					$('#HS_Control_Info').html("<span id='wrt-help'></span>Not Supported");
       
   751 
       
   752 				$('#HS_Control_Info').show();
       
   753 
       
   754 			}
       
   755 			else
       
   756 			{
       
   757 				$('#HS_Control_Info').html("Not Supported for the selected Device resolution");
       
   758 				$('#HS_Control_Info').show();
       
   759 			}
       
   760 		},
       
   761 
       
   762 		getInfo : function(url, callback)
       
   763 		{
       
   764 			try {
       
   765 				var xhr = this.ajax();
       
   766 				
       
   767 				if ((/AppleWebKit/i.test(navigator.userAgent)))
       
   768 					xhr.open("GET", url, false);
       
   769 				else
       
   770 					xhr.open("GET", url, true);
       
   771 				
       
   772 				
       
   773 				xhr.onreadystatechange = function() 
       
   774 				{
       
   775 						// readyState = 4 ; "complete"
       
   776 						if (xhr.readyState==4)
       
   777 						{
       
   778 							// status = 200 ; "ok"
       
   779 							if( (xhr.status == 200) || (!xhr.status) )
       
   780 							{
       
   781 								callback(true, xhr);
       
   782 							}
       
   783 							else
       
   784 							{ 
       
   785 								callback(false, xhr);
       
   786 							}
       
   787 						}
       
   788 	
       
   789 				};
       
   790 				xhr.send(null);
       
   791 			} catch (e) {
       
   792 				if (e.name == 'NS_ERROR_FILE_NOT_FOUND') {
       
   793 					callback(false, xhr);
       
   794 				}			
       
   795 			}
       
   796 		},
       
   797 
       
   798 		getInfoCallback : function(flag, xhr)
       
   799 		{
       
   800 			//	If Info.plis NOT FOUND / FAILED LOAD
       
   801 			//	an ERROR!, unable to proceed further
       
   802 			// 	STOP there
       
   803 			if(!flag)
       
   804 			{
       
   805 				if(!NOKIA.helper.infoPlistCounter)
       
   806 				{
       
   807 					NOKIA.helper.infoPlistCounter = true;
       
   808 					NOKIA.helper.getInfo('info.plist', NOKIA.helper.getInfoCallback);
       
   809 					return false;
       
   810 				}
       
   811 
       
   812 				NOKIA.helper.error('WRT Previewer: Initialization failed. Could not open Info.plist file.<br/>Please ensure <strong style="color:#efe352;">Info.plist</strong> file exists in the project root folder and that it is named properly.');
       
   813 				return false;
       
   814 			}
       
   815 			else{
       
   816 				
       
   817 				var xmlString = xhr.responseText;
       
   818 				
       
   819 				// do some cheating here
       
   820 				xmlString = xmlString.replace(/<!--(.|[\n\r])*?-->/gm, "");
       
   821 				xmlString = xmlString.replace(/<\s*true\s*\/>/gi, "<string>true</string>");
       
   822 				xmlString = xmlString.replace(/<\s*false\s*\/>/gi, "<string>false</string>");
       
   823 				xmlString = xmlString.replace(/[\n\r]/gi, "");
       
   824 				//	return the JSON Object
       
   825 				NOKIA.helper.validate(xmlString);
       
   826 			}
       
   827 			
       
   828 		},
       
   829 		
       
   830 		getIconCallback : function(flag, xhr)
       
   831 		{
       
   832 			
       
   833 			if(!flag)
       
   834 			{
       
   835 				if(!NOKIA.helper.IconFileCounter)
       
   836 				{
       
   837 					NOKIA.helper.IconFileCounter = true;
       
   838 					NOKIA.helper.getInfo('icon.png', NOKIA.helper.getIconCallback);
       
   839 					return false;	
       
   840 				}
       
   841 			}
       
   842 			else
       
   843 				NOKIA.emulator.iconFile =  (NOKIA.helper.IconFileCounter) ? "icon.png" : "Icon.png";
       
   844 		},
       
   845 		
       
   846 
       
   847 		validate : function(xmlObject)
       
   848 		{
       
   849 			var values = xmlObject.match(/.*<plist.*?(<dict.*?>\s*(<key[^>]*?>[^<]*?<\/key>\s*<string[^>]*?>[^<]*?<\/string>)*\s*<\/dict>)\s*<\/plist>/)[1];
       
   850 			if(values == null || values == undefined)
       
   851 			{
       
   852 				NOKIA.helper.error('Corrupted Info.plist file');
       
   853 				return false;
       
   854 			}
       
   855 			values = values.replace(/<dict.*?(<key.*?>\s*.*\s*<\/string>)\s*<\/dict>/, "{ $1 }");
       
   856 			values = values.replace(/\s*<key.*?>\s*(.*?)\s*<\/key>\s*<string.*?>\s*(.*?)\s*<\/string>\s*/g, "\"$1\" : \"$2\", ");
       
   857 			values = values.replace(/"\s*?,\s*?}/g, "\" }");
       
   858 			try {
       
   859 				NOKIA.emulator.plist = JSON.parse(values);
       
   860 			} catch (exception) {
       
   861 				NOKIA.helper.error('Corrupted Info.plist file');
       
   862 				return false;
       
   863 			}
       
   864 
       
   865 			try {
       
   866 				if(typeof NOKIA.emulator.plist.DisplayName != 'undefined'){
       
   867 					document.title = NOKIA.emulator.plist.DisplayName + ' - ' + document.title;
       
   868 				}
       
   869 			} catch (e) {}
       
   870 
       
   871 			//	Add UI-Event listeners
       
   872 			NOKIA.helper.addListeners();
       
   873 			NOKIA.layout.init();
       
   874 			NOKIA.emulator.render();
       
   875 		},
       
   876 
       
   877 
       
   878 		ajax : function() 
       
   879 		{
       
   880 			//	xmlHttpRequest object	
       
   881 			var request = null;
       
   882 		
       
   883 		    // branch for native XMLHttpRequest object
       
   884 		    if(window.XMLHttpRequest && !(window.ActiveXObject)) {
       
   885 		    	try 
       
   886 				{
       
   887 					request = new XMLHttpRequest();
       
   888 					try
       
   889 					{
       
   890 						//	attach the Bypass code, if the browser is firefox
       
   891 						if(netscape.security.PrivilegeManager.enablePrivilege)
       
   892 						{
       
   893 							//	duplicate the function
       
   894 							request._open = request.open;
       
   895 							
       
   896 							//	redefine the function definition
       
   897 							request.open = function(method, url, flag)
       
   898 							{
       
   899 								try
       
   900 								{
       
   901 									// Enable Universal Browser Read
       
   902 									netscape.security.PrivilegeManager.enablePrivilege("UniversalBrowserRead");
       
   903 		
       
   904 									//	call the native XmlHttpRequest.open method
       
   905 									this._open(method, url, flag);
       
   906 								}catch(e)
       
   907 								{
       
   908 									//	call the native XmlHttpRequest.open method
       
   909 									this._open(method, url, flag);
       
   910 								}
       
   911 							};
       
   912 						}
       
   913 					}
       
   914 					catch(e)
       
   915 					{
       
   916 						//	eatup all exceptions
       
   917 					}
       
   918 				} 
       
   919 				catch(e) {
       
   920 					request = null;
       
   921 		        }
       
   922 		    // branch for IE/Windows ActiveX version
       
   923 		    } else if(window.ActiveXObject) {
       
   924 		       	try {
       
   925 		        	request = new ActiveXObject("Msxml2.XMLHTTP");
       
   926 		      	} catch(e) {
       
   927 		        	try {
       
   928 		          		request = new ActiveXObject("Microsoft.XMLHTTP");
       
   929 		        	} catch(e) {
       
   930 		          		alert('Failed to create XmlHttprequest');
       
   931 						return null;
       
   932 		        	}
       
   933 				}
       
   934 		    }
       
   935 			
       
   936 			return (request);
       
   937 		},
       
   938 
       
   939 		error : function(msg)
       
   940 		{
       
   941 			if(NOKIA.menu.enable_log)
       
   942 				NOKIA.layout.log("log", msg);
       
   943 			
       
   944 			$("#Dialog").html(msg);
       
   945 			$("#Dialog").dialog('open');
       
   946 		},
       
   947 
       
   948 		setPreference : function(name,value) 
       
   949 		{
       
   950 			if (NOKIA.emulator.prefs[name] != value) {
       
   951 				NOKIA.emulator.prefs[name] = value;
       
   952 				$.post("preview/preferences.js", JSON.stringify({ "key" : name, "value" : value }), undefined, "json");
       
   953 			}
       
   954 		},
       
   955 		
       
   956 		getPreference : function(name) 
       
   957 		{
       
   958 			return NOKIA.emulator.prefs[name];
       
   959 		},
       
   960 
       
   961 		rotateCW : function() {
       
   962 			var newOrient = NOKIA.orientation + 90;
       
   963 			NOKIA.emulator.toggle(newOrient - (newOrient > 180 ? 360 : 0));
       
   964 		},
       
   965 		rotateCCW : function() {
       
   966 			var newOrient = NOKIA.orientation - 90;
       
   967 			NOKIA.emulator.toggle(newOrient + (newOrient <= -180 ? 360 : 0));
       
   968 		},
       
   969 
       
   970 		version : function(ele)
       
   971 		{
       
   972 			if (confirm('Would you like to reload the widget to apply the changes on the Version settings?')) 
       
   973 			{
       
   974 				NOKIA.helper.setPreference('__SYM_WRT_VERSION', ele.value);
       
   975 				$("#loaderDiv").html("Applying the " + ele.value + ", please wait...");
       
   976 				$("#loaderDiv").show();
       
   977 				$("#loaderDiv")[0].className = 'green';
       
   978 				
       
   979 				window.setTimeout(function(){
       
   980 					document.location = document.location;
       
   981 				}, 3000);
       
   982 			}
       
   983 			else
       
   984 			{
       
   985 				ele.checked = false;
       
   986 				if(ele.value != 'WRT 1.0')
       
   987 					$("#wrt_version_1_0")[0].checked = true;
       
   988 				else
       
   989 					$("#wrt_version_1_1")[0].checked = true;
       
   990 			}
       
   991 		},
       
   992 
       
   993 		addListeners : function()
       
   994 		{
       
   995 			NOKIA.helper.loadPreferences();
       
   996 			/*
       
   997 			 * Render Emulator for Interaction
       
   998 			 */
       
   999 			NOKIA.helper.inspectorDailog = $("#InspectorTab").dialog({
       
  1000 				width: 370,	minWidth: 300, minHeight: 200, height: 250, autoOpen: false, position : top, title : '&nbsp;',
       
  1001 				buttons : {
       
  1002 				"Close" : function(){
       
  1003 				$("#InspectorTab").dialog('close');
       
  1004 				},			
       
  1005 				"Disconnect Debugger" : function(){
       
  1006 				$.ajax({url : "__sym_command/terminateDebug"});
       
  1007 			}}
       
  1008 			});
       
  1009 				
       
  1010 			$('#InspectorBtn').click(function(){
       
  1011 				$('#InspectorTab').dialog('open');
       
  1012 				//	Hack for Mac firefox
       
  1013 				if(/Mac/i.test(navigator.userAgent))
       
  1014 				{
       
  1015 					$("#WidgetArea iframe").css({overflow:'hidden'});
       
  1016 				}
       
  1017 			});
       
  1018 			
       
  1019 			$('#rotateCW').click(function(){
       
  1020 				NOKIA.helper.rotateCW();
       
  1021 			});
       
  1022 			$('#rotateCCW').click(function(){
       
  1023 				NOKIA.helper.rotateCCW();
       
  1024 			});
       
  1025 			$('#resOptions').change(function(ele){
       
  1026 				ele = ele.target || this;
       
  1027 				
       
  1028 				NOKIA.currentDevice = ele.options[ele.selectedIndex].text;
       
  1029 		
       
  1030 				//	SAVE the device DATA
       
  1031 				NOKIA.helper.setPreference('__SYM_NOKIA_EMULATOR_DEVICE', NOKIA.currentDevice);
       
  1032 		
       
  1033 				NOKIA.emulator.render();
       
  1034 				NOKIA.helper.loadPreferences();
       
  1035 			});
       
  1036 
       
  1037 			//	Hack for Mac firefox
       
  1038 			if (/Mac/i.test(navigator.userAgent)) {
       
  1039 				if (!(/AppleWebKit/i.test(navigator.userAgent))) {
       
  1040 					$("#resOptions")[0].size = '4';
       
  1041 				}
       
  1042 			}
       
  1043 
       
  1044 
       
  1045 			//	WRT Version controls
       
  1046 			$('#wrt_version_1_0').change(function(){
       
  1047 				NOKIA.helper.version(this);
       
  1048 			});
       
  1049 			
       
  1050 			$('#wrt_version_1_1').change(function(){
       
  1051 				NOKIA.helper.version(this);
       
  1052 			});
       
  1053 
       
  1054 
       
  1055 			$("#orientationIcon").click(function(){
       
  1056 				var mode = (NOKIA.mode == 'portrait') ? 'landscape' : 'portrait';
       
  1057 				NOKIA.emulator.setMode(mode);
       
  1058 				$("#WidgetArea")[0].className = 'hs_'+NOKIA.mode;
       
  1059 			});
       
  1060 
       
  1061 
       
  1062 			$("#iframeMask").click(function(){
       
  1063 				$("#orientationIcon").hide();
       
  1064 				$("#iframeMask").hide();
       
  1065 				$("#loaderDiv").hide();
       
  1066 
       
  1067 				NOKIA.menu.is_dimmed = false;
       
  1068 				
       
  1069 				$("#WidgetArea")[0].className = '';
       
  1070 				
       
  1071 				NOKIA.menu.softkeys_visibility = true;
       
  1072 				NOKIA.menu.showSoftKeys();
       
  1073 
       
  1074 			});
       
  1075 
       
  1076 
       
  1077 			//	MenuItems DIV events
       
  1078 			$("#MenuItemsArea").mouseover(function(){
       
  1079 				if(NOKIA.helper.intervalId)
       
  1080 					clearInterval(NOKIA.helper.intervalId);
       
  1081 
       
  1082 				$("#MenuItemsArea").show();
       
  1083 			});
       
  1084 
       
  1085 			$("#MenuItemsArea").mouseout(function(){
       
  1086 				if(NOKIA.helper.intervalId)
       
  1087 					clearInterval(NOKIA.helper.intervalId);
       
  1088 
       
  1089 				NOKIA.helper.intervalId = setTimeout(function(){
       
  1090 					NOKIA.menu.cancel();
       
  1091 				}, 500);
       
  1092 			});
       
  1093 
       
  1094 
       
  1095 			// Tabs
       
  1096 			$('#tabs').tabs({
       
  1097 //				select : function(event, ui){
       
  1098 //					switch (ui.index) {
       
  1099 //					case 1:
       
  1100 //						$("event-battery-info").show();
       
  1101 //						break;
       
  1102 //					case 2:
       
  1103 //						$("event-messaging-info").show();
       
  1104 //						break;
       
  1105 //					case 3:
       
  1106 //						$("event-memory-info").show();
       
  1107 //						break;
       
  1108 //					case 4:
       
  1109 //						$("settings-view").show();
       
  1110 //						break;
       
  1111 //					
       
  1112 //				}}
       
  1113 			});
       
  1114 			$(".tabs-bottom .ui-tabs-nav, .tabs-bottom .ui-tabs-nav > *") 
       
  1115 	 			.removeClass("ui-corner-all ui-corner-top") 
       
  1116 	 			.addClass("ui-corner-bottom");
       
  1117 			
       
  1118 			/*	
       
  1119 			 * 	Event triggering
       
  1120 			 */
       
  1121 			
       
  1122 			//	for battery
       
  1123 			$("#event-battery").click(function(event){
       
  1124 				if(event.target.className == 'active')
       
  1125 				{
       
  1126 					$("#event-icons").hide();
       
  1127 					$("#event-battery-info").show();
       
  1128 
       
  1129 /*
       
  1130 				$('#slider').slider('option', 'value', NOKIA.emulator.child._BRIDGE_REF.helper.getBatteryStrength());
       
  1131 				NOKIA.emulator.child._BRIDGE_REF.helper.getBatteryStrength()
       
  1132 				$('#slider').slider('option', 'value', 10);
       
  1133 				$('#slider').slider();
       
  1134 */
       
  1135 				}
       
  1136 			});
       
  1137 
       
  1138 			$("#event-battery-back").click(function(event){
       
  1139 				$("#event-icons").show();
       
  1140 				$("#event-battery-info").hide();
       
  1141 			});
       
  1142 
       
  1143 
       
  1144 			//	for messaging
       
  1145 			$("#event-messaging").click(function(event){
       
  1146 				if(event.target.className == 'active')
       
  1147 				{
       
  1148 					$("#event-icons").hide();
       
  1149 					$("#event-messaging-info").show();
       
  1150 				}
       
  1151 			});
       
  1152 
       
  1153 			$("#event-messaging-back").click(function(event){
       
  1154 				$("#event-icons").show();
       
  1155 				$("#event-messaging-info").hide();
       
  1156 			});
       
  1157 
       
  1158 
       
  1159 			//	for memory
       
  1160 			$("#event-memory").click(function(event){
       
  1161 				if(event.target.className == 'active')
       
  1162 				{
       
  1163 					$("#event-icons").hide();
       
  1164 					$("#event-memory-info").show();
       
  1165 				}
       
  1166 			});
       
  1167 
       
  1168 			$("#event-memory-back").click(function(event){
       
  1169 				$("#event-icons").show();
       
  1170 				$("#event-memory-info").hide();
       
  1171 			});
       
  1172 
       
  1173 
       
  1174 			//	for minView more info
       
  1175 			$("#mini-view-back").click(function(event){
       
  1176 				$("#settings-view").show();
       
  1177 				$("#mini-view-info").hide();
       
  1178 			});
       
  1179 
       
  1180 
       
  1181 			// Slider
       
  1182 			$('#slider').slider({
       
  1183 				min : 0,
       
  1184 				max : 100,
       
  1185 				step : 1,
       
  1186 				value : 10,
       
  1187 				animate: true,
       
  1188 				slide: function(event, ui) {
       
  1189 					$("#slider-value-panel > span").html(ui.value.toString() + "%");
       
  1190 				},
       
  1191 				change: function(event, ui) {
       
  1192 					var chargeValue = ui.value;
       
  1193 					NOKIA.helper.trigger("power", "chargelevel", chargeValue);
       
  1194 					if(NOKIA.version == 'WRT 1.1')
       
  1195 						NOKIA.helper.triggerSapi("Service.SysInfo", "Battery.BatteryStrength", {Status: chargeValue});
       
  1196 				}
       
  1197 				});
       
  1198 			$("#slider-value-panel > span").html("10%");
       
  1199 
       
  1200 			var cc = $("#close-camera");
       
  1201 			cc.click(NOKIA.helper.hideCamera);
       
  1202 			//	Bind Buttons to trigger values to WRT 1.0 / 1.1 bindings
       
  1203 			
       
  1204 			$("#connect-charger").click(NOKIA.helper.triggerEvents);
       
  1205 			$("#disconnect-charger").click(NOKIA.helper.triggerEvents);
       
  1206 
       
  1207 			$("#send-sms").click(NOKIA.helper.triggerEvents);
       
  1208 			$("#send-mms").click(NOKIA.helper.triggerEvents);
       
  1209 
       
  1210 			$("#connect-memory-card").click(NOKIA.helper.triggerEvents);
       
  1211 			$("#disconnect-memory-card").click(NOKIA.helper.triggerEvents);
       
  1212 			
       
  1213 			
       
  1214 		},
       
  1215 		
       
  1216 		setHomeScreen : function()
       
  1217 		{
       
  1218 			//	HomeScreen Support
       
  1219 			if (NOKIA.deviceList[NOKIA.currentDevice].homeScreenSupport) {
       
  1220 
       
  1221 				if (typeof NOKIA.emulator.plist.MiniViewEnabled != 'undefined') {
       
  1222 					if (NOKIA.emulator.plist.MiniViewEnabled != 'false') 
       
  1223 					{
       
  1224 						$("#WidgetArea")[0].className = 'hs_' + NOKIA.mode;
       
  1225 						
       
  1226 						//	menu handlining
       
  1227 						NOKIA.menu.softkeys_visibility = false;
       
  1228 						NOKIA.menu.cancel();
       
  1229 						NOKIA.menu.is_dimmed = true;
       
  1230 						
       
  1231 
       
  1232 						$("#loaderDiv").html("Click on widget for Return to Full view");
       
  1233 						$("#loaderDiv")[0].className = 'green';
       
  1234 						$("#loaderDiv").show();
       
  1235 
       
  1236 						$("#iframeMask").show();
       
  1237 						$("#orientationIcon").show();
       
  1238 
       
  1239 						return true;
       
  1240 					}
       
  1241 				}
       
  1242 			}
       
  1243 			return false;			
       
  1244 		},
       
  1245 		
       
  1246 		getElementsLengthInObject : function(items){
       
  1247 			var count = 0;
       
  1248 			for (var i in items) 
       
  1249 			{
       
  1250 				if(!items[i].isDimmed)
       
  1251 					count++;
       
  1252 			}
       
  1253 			
       
  1254 			return count;
       
  1255 		},
       
  1256 		
       
  1257 		showCamera : function() {
       
  1258 			$("#camera").show();
       
  1259 			$("#WidgetArea").hide();
       
  1260 		},		
       
  1261 
       
  1262 		hideCamera : function() {
       
  1263 			$("#camera").hide();
       
  1264 			$("#WidgetArea").show();
       
  1265 		},		
       
  1266 		
       
  1267 		triggerEvents : function(event)
       
  1268 		{
       
  1269 			if(typeof event.target.id == 'undefined')
       
  1270 			return false;
       
  1271 			
       
  1272 			switch(event.target.id)
       
  1273 			{
       
  1274 				//	for battery
       
  1275 				case 'connect-charger': 
       
  1276 										NOKIA.helper.trigger("power", "chargerconnected", 1);
       
  1277 										if(NOKIA.version == 'WRT 1.1')
       
  1278 											NOKIA.helper.triggerSapi("Service.SysInfo", "Battery.ChargingStatus", {Status: 1});
       
  1279 										break;
       
  1280 
       
  1281 				case 'disconnect-charger': 
       
  1282 										NOKIA.helper.trigger("power", "chargerconnected", 0);
       
  1283 										if(NOKIA.version == 'WRT 1.1')
       
  1284 											NOKIA.helper.triggerSapi("Service.SysInfo", "Battery.ChargingStatus", {Status: 0});
       
  1285 										break;
       
  1286 
       
  1287 				//	for messaging
       
  1288 				case 'send-sms': 
       
  1289 										if(NOKIA.version == 'WRT 1.1')
       
  1290 											NOKIA.helper.triggerSapi("Service.Messaging", "NewMessage", {MessageType: 'SMS'});
       
  1291 										break;
       
  1292 				case 'send-mms': 
       
  1293 										if(NOKIA.version == 'WRT 1.1')
       
  1294 											NOKIA.helper.triggerSapi("Service.Messaging", "NewMessage", {MessageType: 'MMS'});
       
  1295 										break;
       
  1296 
       
  1297 				//	for memory
       
  1298 				case 'connect-memory-card': 
       
  1299 										if(NOKIA.version == 'WRT 1.1')
       
  1300 											NOKIA.helper.triggerSapi("Service.SysInfo", "Memory.MemoryCard", {Status: 1});
       
  1301 										break;
       
  1302 				case 'disconnect-memory-card': 
       
  1303 										if(NOKIA.version == 'WRT 1.1')
       
  1304 											NOKIA.helper.triggerSapi("Service.SysInfo", "Memory.MemoryCard", {Status: 0});
       
  1305 										break;
       
  1306 			}
       
  1307 		},	
       
  1308 
       
  1309 		triggerSapi : function(provider, eventType, data){
       
  1310 			NOKIA.emulator.child.device.implementation.triggerListener(provider, eventType, data);
       
  1311 		},	
       
  1312 
       
  1313 		trigger : function(provider, eventType, data){
       
  1314 			NOKIA.emulator.child.widget.triggerListener(provider, eventType, data);
       
  1315 		},
       
  1316 		
       
  1317 		showMiniviewHelp : function(){
       
  1318 			$("#settings-view").hide();
       
  1319 			$("#mini-view-info").show();
       
  1320 		},
       
  1321 		
       
  1322 		checkDependencies : function(){
       
  1323 			
       
  1324 			for(var key in NOKIA.scriptsLoaded)
       
  1325 			{
       
  1326 				if(!NOKIA.scriptsLoaded[key])
       
  1327 					return false;
       
  1328 			}
       
  1329 
       
  1330 			//	for LSK
       
  1331 			NOKIA.menu.setLsk(NOKIA.emulator.child.menu.show);
       
  1332 		
       
  1333 			//	for RSK
       
  1334 			NOKIA.menu.setRsk(NOKIA.menu.exit);
       
  1335 
       
  1336 			return true;
       
  1337 		}
       
  1338 	};
       
  1339 	
   161 	
  1340 
   162 
  1341 	/*
   163 	/*
  1342 	 * NOKIA.layout functions
   164 	 * NOKIA.layout functions
  1343 	 */
   165 	 */
  1344 	NOKIA.namespace('layout');
   166 	NOKIA.namespace('layout');
  1345 	NOKIA.layout = {
   167 	NOKIA.layout = new EmulatorLayout();
  1346 		_console_minimized : true,
       
  1347 		_console_enabled : false,
       
  1348 		_consoleWindowHeight : 290,
       
  1349 		_consoleHeaderHeight : 31,
       
  1350 		_tabHeight : 27,
       
  1351 
       
  1352 		init : function(){
       
  1353 			
       
  1354 			//	Toggle console window
       
  1355 			$('#preview-ui-bottom-header').click(function(){
       
  1356 				NOKIA.layout._console_minimized = (NOKIA.layout._console_minimized) ? false : true;
       
  1357 				NOKIA.layout.render();
       
  1358 				NOKIA.helper.setPreference("__SYM_NOKIA_CONSOLE_OPEN", !NOKIA.layout._console_minimized);
       
  1359 			});
       
  1360 			
       
  1361 			// clear Log
       
  1362 			$("#Console-Clear-Button").click(function(){
       
  1363 				$("#preview-ui-bottom-body")[0].innerHTML = '';
       
  1364 			});
       
  1365 
       
  1366 
       
  1367 			$('#preview-ui-bottom').show();
       
  1368 			NOKIA.layout.render();
       
  1369 		},
       
  1370 		
       
  1371 		log : function(type, msg){
       
  1372 			var p = document.createElement('p');
       
  1373 			p.className = type;
       
  1374 			p.innerHTML = msg;
       
  1375 			var divBody = $('#preview-ui-bottom-body');
       
  1376 			divBody.append(p);
       
  1377 			divBody[0].scrollTop = divBody[0].scrollHeight;
       
  1378 		},
       
  1379 		
       
  1380 		
       
  1381 		render : function(){
       
  1382 			var _width = parseInt(window.innerWidth);
       
  1383 			var _height = parseInt(window.innerHeight);
       
  1384 			
       
  1385 			if(!NOKIA.layout._console_enabled)
       
  1386 			{
       
  1387 				$('#preview-ui-bottom').css({
       
  1388 					display: 'none'
       
  1389 				});
       
  1390 				
       
  1391 				$('#preview-ui-top').css({
       
  1392 					height: _height+'px'
       
  1393 				});
       
  1394 
       
  1395 				return false;
       
  1396 			}
       
  1397 			
       
  1398 			
       
  1399 			if(!NOKIA.layout._console_minimized)
       
  1400 			{
       
  1401 				$('#Console-Toggle-Button')[0].className = 'open';
       
  1402 				
       
  1403 				//	set STYLE details for TOP window
       
  1404 				$('#preview-ui-top').css({
       
  1405 					height: parseInt(_height - NOKIA.layout._consoleWindowHeight) + 'px'
       
  1406 				});
       
  1407 				
       
  1408 				//	set STYLE details for Bottom window
       
  1409 				$('#preview-ui-bottom').css({
       
  1410 					height: NOKIA.layout._consoleWindowHeight + 'px',
       
  1411 					display : 'block'
       
  1412 				});
       
  1413 
       
  1414 				$('#preview-ui-bottom-header').css({
       
  1415 					height: NOKIA.layout._consoleHeaderHeight + 'px'
       
  1416 				});
       
  1417 
       
  1418 				$('#tabs').css({
       
  1419 					height: parseInt(NOKIA.layout._consoleWindowHeight - NOKIA.layout._consoleHeaderHeight) + 'px',
       
  1420 					display : 'block'
       
  1421 				});
       
  1422 				$('#console').css({
       
  1423 					height : parseInt(NOKIA.layout._consoleWindowHeight
       
  1424 									- NOKIA.layout._consoleHeaderHeight
       
  1425 									- NOKIA.layout._tabHeight * 2)
       
  1426 									+ 'px',
       
  1427 					display : 'block'
       
  1428 				});
       
  1429 				
       
  1430 				// Auto scroll when console window opened from MINIMIZED => MAXIMIZED state
       
  1431 				window.setTimeout(function(){
       
  1432 					$('#preview-ui-bottom-body')[0].scrollTop = $('#preview-ui-bottom-body')[0].scrollHeight;
       
  1433 				}, 100);
       
  1434 				
       
  1435 			}else{
       
  1436 				$('#Console-Toggle-Button')[0].className = 'close';
       
  1437 
       
  1438 				//	set STYLE details for TOP window
       
  1439 				$('#preview-ui-top').css({
       
  1440 					height: parseInt(_height - NOKIA.layout._consoleHeaderHeight) + 'px'
       
  1441 				});
       
  1442 				
       
  1443 				//	set STYLE details for Bottom window
       
  1444 				$('#preview-ui-bottom').css({
       
  1445 					height: NOKIA.layout._consoleHeaderHeight + 'px',
       
  1446 					display : 'block'
       
  1447 				});
       
  1448 
       
  1449 				$('#preview-ui-bottom-header').css({
       
  1450 					height: NOKIA.layout._consoleHeaderHeight + 'px',
       
  1451 					display : 'block'
       
  1452 				});
       
  1453 // TODO
       
  1454 //				$('#preview-ui-bottom-body').css({
       
  1455 //					display : 'none'
       
  1456 //				});
       
  1457 			}
       
  1458 		}
       
  1459 		
       
  1460 	};
       
  1461 }
   168 }
  1462 
   169 
  1463 $(document).ready(function () {
   170 $(document).ready(function () {
  1464 	NOKIA.init();	
   171 	NOKIA.init();	
  1465 });
   172 });