org.symbian.tools.wrttools.previewer/preview/script/nokia.js
changeset 334 915daddff233
parent 306 42f09aa2b24a
child 337 afe6a53c0ed4
equal deleted inserted replaced
333:895153411a80 334:915daddff233
    23 {
    23 {
    24 	var NOKIA = {
    24 	var NOKIA = {
    25 		version : 'WRT 1.1',
    25 		version : 'WRT 1.1',
    26 		currentDevice : '240x320',
    26 		currentDevice : '240x320',
    27 		mode : 'portrait',
    27 		mode : 'portrait',
       
    28 		orientation : 0,
    28 		resolution : ['240x320', '320x240', '360x640', '800x352'],
    29 		resolution : ['240x320', '320x240', '360x640', '800x352'],
    29 		scriptsLoaded : {
    30 		scriptsLoaded : {
    30 			loader : false,
    31 			loader : false,
    31 			widget : false,
    32 			widget : false,
    32 			systeminfo : false,
    33 			systeminfo : false,
   691 		loadPreferences : function()
   692 		loadPreferences : function()
   692 		{
   693 		{
   693 			if(/dreamweaver/i.test(navigator.userAgent))
   694 			if(/dreamweaver/i.test(navigator.userAgent))
   694 			{
   695 			{
   695 				$("#dwDeviceHelp")[0].className = '';
   696 				$("#dwDeviceHelp")[0].className = '';
   696 				$("#resSupportLink")[0].className = 'hide';
   697 //				$("#resSupportLink")[0].className = 'hide';
   697 			}
   698 			}
   698 			//	Selecting Resoltion
   699 			//	Selecting Resoltion
   699 			var resOptions = $("#resOptions")[0];
   700 			var resOptions = $("#resOptions")[0];
   700 			for(var i=0; i<NOKIA.resolution.length; i++)
   701 			for(var i=0; i<NOKIA.resolution.length; i++)
   701 			{
   702 			{
   702 				if(NOKIA.resolution[i] == NOKIA.currentDevice)
   703 				if(NOKIA.resolution[i] == NOKIA.currentDevice)
   703 				{
   704 				{
   704 					resOptions.options[i].selected = true;
   705 					resOptions.options[i].selected = true;
   705 					$("#resSupportLink")[0].href = resOptions.options[i].value;
       
   706 					break;
   706 					break;
   707 				}				
   707 				}				
   708 			}
   708 			}
   709 			
   709 			
   710 			//	Selecting Orientation
   710 //			//	Selecting Orientation
   711 			if(NOKIA.mode == 'portrait')
   711 //			if(NOKIA.mode == 'portrait')
   712 				$('#input_portrait')[0].checked = true;
   712 //				$('#input_portrait')[0].checked = true;
   713 			else
   713 //			else
   714 				$('#input_landscape')[0].checked = true;
   714 //				$('#input_landscape')[0].checked = true;
   715 
   715 
   716 			if (!NOKIA.emulator.orientationSupports()) {
   716 //			if (!NOKIA.emulator.orientationSupports()) {
   717 				if (NOKIA.mode == 'portrait') 
   717 //				if (NOKIA.mode == 'portrait') 
   718 					$("#input_landscape")[0].disabled = true;
   718 //					$("#input_landscape")[0].disabled = true;
   719 				else 
   719 //				else 
   720 					$("#input_portrait")[0].disabled = true;
   720 //					$("#input_portrait")[0].disabled = true;
   721 					
   721 //					
   722 				$("#Orientation_Info").html("Not supported");
   722 //				$("#Orientation_Info").html("Not supported");
   723 				$("#Orientation_Info").show();
   723 //				$("#Orientation_Info").show();
   724 				$("#Orientation_Controls").hide();
   724 //				$("#Orientation_Controls").hide();
   725 			}
   725 //			}
   726 			else {
   726 //			else {
   727 				$("#input_landscape")[0].disabled = false;
   727 //				$("#input_landscape")[0].disabled = false;
   728 				$("#input_portrait")[0].disabled = false;
   728 //				$("#input_portrait")[0].disabled = false;
   729 
   729 //
   730 				$("#Orientation_Info").hide();
   730 //				$("#Orientation_Info").hide();
   731 				$("#Orientation_Controls").show();
   731 //				$("#Orientation_Controls").show();
   732 			}
   732 //			}
   733 			
   733 			
   734 			//	Selecting Version
   734 			//	Selecting Version
   735 			if(NOKIA.version == 'WRT 1.0')
   735 			if(NOKIA.version == 'WRT 1.0')
   736 				$('#wrt_version_1_0')[0].checked = true;
   736 				$('#wrt_version_1_0')[0].checked = true;
   737 			else
   737 			else
   955 		getPreference : function(name) 
   955 		getPreference : function(name) 
   956 		{
   956 		{
   957 			return NOKIA.emulator.prefs[name];
   957 			return NOKIA.emulator.prefs[name];
   958 		},
   958 		},
   959 
   959 
   960 		toggle : function(ele)
   960 		rotateCW : function() {
   961 		{
   961 			if (NOKIA.orientation == 0) {
   962 			if (NOKIA.emulator.orientationSupports()) {
   962 				this.toggle(90);
   963 //				var mode = (NOKIA.mode == 'portrait') ? 'landscape' : 'portrait';
   963 			} else if (NOKIA.orientation == 90) {
   964 				NOKIA.emulator.setMode(ele.value);
   964 				this.toggle(180);
   965 			}
   965 			} else if (NOKIA.orientation == 180) {
   966 			else
   966 				this.toggle(-90);
   967 			{	
   967 			} else {
   968 				ele.checked = false;
   968 				this.toggle(0);
   969 				if(ele.value == 'portrait')
   969 			}
   970 					$("#input_landscape")[0].checked = true;
   970 		},
   971 				else
   971 		rotateCCW : function() {
   972 					$("#input_portrait")[0].checked = true;
   972 			if (NOKIA.orientation == 0) {
   973 			}
   973 				this.toggle(-90);
       
   974 			} else if (NOKIA.orientation == -90) {
       
   975 				this.toggle(180);
       
   976 			} else if (NOKIA.orientation == 180) {
       
   977 				this.toggle(90);
       
   978 			} else {
       
   979 				this.toggle(0);
       
   980 			}
       
   981 		},
       
   982 		
       
   983 		toggle : function(o)
       
   984 		{
       
   985 			if (NOKIA.emulator.orientationSupports() && (o == 0 || o == -90)) {
       
   986 				NOKIA.emulator.setMode(o == 0 ? 'portrait' : 'landscape');
       
   987 			}
       
   988 			NOKIA.orientation = o;
       
   989 			var or = (NOKIA.mode == 'portrait') ? o : (o + 90);
       
   990 			var val = "rotate(" + or + "deg)";
       
   991 			$("#preview-ui-top").css("-moz-transform", val);
       
   992 			$("#preview-ui-top").css("-webkit-transform", val);
   974 		},
   993 		},
   975 
   994 
   976 		version : function(ele)
   995 		version : function(ele)
   977 		{
   996 		{
   978 			if (confirm('Would you like to reload the widget to apply the changes on the Version settings?')) 
   997 			if (confirm('Would you like to reload the widget to apply the changes on the Version settings?')) 
  1052 				{
  1071 				{
  1053 					$("#WidgetArea iframe").css({overflow:'hidden'});
  1072 					$("#WidgetArea iframe").css({overflow:'hidden'});
  1054 				}
  1073 				}
  1055 			});
  1074 			});
  1056 			
  1075 			
  1057 			$('#input_portrait').change(function(){
  1076 			$('#rotateCW').click(function(){
  1058 				NOKIA.helper.toggle(this);
  1077 				NOKIA.helper.rotateCW();
  1059 			});
  1078 			});
  1060 
  1079 			$('#rotateCCW').click(function(){
  1061 			$('#input_landscape').change(function(){
  1080 				NOKIA.helper.rotateCCW();
  1062 				NOKIA.helper.toggle(this);
  1081 			});
  1063 			});
       
  1064 
       
  1065 			$('#resOptions').change(function(ele){
  1082 			$('#resOptions').change(function(ele){
  1066 				ele = ele.target || this;
  1083 				ele = ele.target || this;
  1067 				
  1084 				
  1068 				NOKIA.currentDevice = ele.options[ele.selectedIndex].text;
  1085 				NOKIA.currentDevice = ele.options[ele.selectedIndex].text;
  1069 				$("#resSupportLink")[0].href = ele.value;
       
  1070 		
  1086 		
  1071 				//	SAVE the device DATA
  1087 				//	SAVE the device DATA
  1072 				NOKIA.helper.setPreference('__SYM_NOKIA_EMULATOR_DEVICE', NOKIA.currentDevice);
  1088 				NOKIA.helper.setPreference('__SYM_NOKIA_EMULATOR_DEVICE', NOKIA.currentDevice);
  1073 		
  1089 		
  1074 				NOKIA.emulator.render();
  1090 				NOKIA.emulator.render();