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