org.symbian.tools.wrttools.previewer/preview/script/nokia.js
changeset 334 915daddff233
parent 306 42f09aa2b24a
child 337 afe6a53c0ed4
--- a/org.symbian.tools.wrttools.previewer/preview/script/nokia.js	Thu May 13 15:47:02 2010 -0700
+++ b/org.symbian.tools.wrttools.previewer/preview/script/nokia.js	Mon May 17 15:21:01 2010 -0700
@@ -25,6 +25,7 @@
 		version : 'WRT 1.1',
 		currentDevice : '240x320',
 		mode : 'portrait',
+		orientation : 0,
 		resolution : ['240x320', '320x240', '360x640', '800x352'],
 		scriptsLoaded : {
 			loader : false,
@@ -693,7 +694,7 @@
 			if(/dreamweaver/i.test(navigator.userAgent))
 			{
 				$("#dwDeviceHelp")[0].className = '';
-				$("#resSupportLink")[0].className = 'hide';
+//				$("#resSupportLink")[0].className = 'hide';
 			}
 			//	Selecting Resoltion
 			var resOptions = $("#resOptions")[0];
@@ -702,34 +703,33 @@
 				if(NOKIA.resolution[i] == NOKIA.currentDevice)
 				{
 					resOptions.options[i].selected = true;
-					$("#resSupportLink")[0].href = resOptions.options[i].value;
 					break;
 				}				
 			}
 			
-			//	Selecting Orientation
-			if(NOKIA.mode == 'portrait')
-				$('#input_portrait')[0].checked = true;
-			else
-				$('#input_landscape')[0].checked = true;
+//			//	Selecting Orientation
+//			if(NOKIA.mode == 'portrait')
+//				$('#input_portrait')[0].checked = true;
+//			else
+//				$('#input_landscape')[0].checked = true;
 
-			if (!NOKIA.emulator.orientationSupports()) {
-				if (NOKIA.mode == 'portrait') 
-					$("#input_landscape")[0].disabled = true;
-				else 
-					$("#input_portrait")[0].disabled = true;
-					
-				$("#Orientation_Info").html("Not supported");
-				$("#Orientation_Info").show();
-				$("#Orientation_Controls").hide();
-			}
-			else {
-				$("#input_landscape")[0].disabled = false;
-				$("#input_portrait")[0].disabled = false;
-
-				$("#Orientation_Info").hide();
-				$("#Orientation_Controls").show();
-			}
+//			if (!NOKIA.emulator.orientationSupports()) {
+//				if (NOKIA.mode == 'portrait') 
+//					$("#input_landscape")[0].disabled = true;
+//				else 
+//					$("#input_portrait")[0].disabled = true;
+//					
+//				$("#Orientation_Info").html("Not supported");
+//				$("#Orientation_Info").show();
+//				$("#Orientation_Controls").hide();
+//			}
+//			else {
+//				$("#input_landscape")[0].disabled = false;
+//				$("#input_portrait")[0].disabled = false;
+//
+//				$("#Orientation_Info").hide();
+//				$("#Orientation_Controls").show();
+//			}
 			
 			//	Selecting Version
 			if(NOKIA.version == 'WRT 1.0')
@@ -957,21 +957,40 @@
 			return NOKIA.emulator.prefs[name];
 		},
 
-		toggle : function(ele)
-		{
-			if (NOKIA.emulator.orientationSupports()) {
-//				var mode = (NOKIA.mode == 'portrait') ? 'landscape' : 'portrait';
-				NOKIA.emulator.setMode(ele.value);
+		rotateCW : function() {
+			if (NOKIA.orientation == 0) {
+				this.toggle(90);
+			} else if (NOKIA.orientation == 90) {
+				this.toggle(180);
+			} else if (NOKIA.orientation == 180) {
+				this.toggle(-90);
+			} else {
+				this.toggle(0);
 			}
-			else
-			{	
-				ele.checked = false;
-				if(ele.value == 'portrait')
-					$("#input_landscape")[0].checked = true;
-				else
-					$("#input_portrait")[0].checked = true;
+		},
+		rotateCCW : function() {
+			if (NOKIA.orientation == 0) {
+				this.toggle(-90);
+			} else if (NOKIA.orientation == -90) {
+				this.toggle(180);
+			} else if (NOKIA.orientation == 180) {
+				this.toggle(90);
+			} else {
+				this.toggle(0);
 			}
 		},
+		
+		toggle : function(o)
+		{
+			if (NOKIA.emulator.orientationSupports() && (o == 0 || o == -90)) {
+				NOKIA.emulator.setMode(o == 0 ? 'portrait' : 'landscape');
+			}
+			NOKIA.orientation = o;
+			var or = (NOKIA.mode == 'portrait') ? o : (o + 90);
+			var val = "rotate(" + or + "deg)";
+			$("#preview-ui-top").css("-moz-transform", val);
+			$("#preview-ui-top").css("-webkit-transform", val);
+		},
 
 		version : function(ele)
 		{
@@ -1054,19 +1073,16 @@
 				}
 			});
 			
-			$('#input_portrait').change(function(){
-				NOKIA.helper.toggle(this);
+			$('#rotateCW').click(function(){
+				NOKIA.helper.rotateCW();
 			});
-
-			$('#input_landscape').change(function(){
-				NOKIA.helper.toggle(this);
+			$('#rotateCCW').click(function(){
+				NOKIA.helper.rotateCCW();
 			});
-
 			$('#resOptions').change(function(ele){
 				ele = ele.target || this;
 				
 				NOKIA.currentDevice = ele.options[ele.selectedIndex].text;
-				$("#resSupportLink")[0].href = ele.value;
 		
 				//	SAVE the device DATA
 				NOKIA.helper.setPreference('__SYM_NOKIA_EMULATOR_DEVICE', NOKIA.currentDevice);