[Title] common-eplugin: improved back button process
authorJihoon Song <jihoon80.song@samsung.com>
Fri, 13 Sep 2013 07:06:56 +0000 (16:06 +0900)
committerJihoon Song <jihoon80.song@samsung.com>
Fri, 13 Sep 2013 07:06:56 +0000 (16:06 +0900)
[Desc.]
[Issue] N_SE-51752

Change-Id: Iccf8a3db966012e8871a022d06de10f92aa92174

org.tizen.common.verrari/templates/cli/jqm-common-resources/js/main.js
org.tizen.common.verrari/templates/cli/tizenwebuifw-common-resources/js/main.js
org.tizen.common.verrari/templates/jar/jqm-common-resources.jar
org.tizen.common.verrari/templates/jar/tizenwebuifw-common-resources.jar

index 56db226..7f1368a 100644 (file)
@@ -7,10 +7,21 @@ var init = function () {
     // TODO:: Do your initialization job
     console.log("init() called");
 
-    // add eventListener for tizenhwkey
+    // add eventListener for tizenhwkey (Back Button)
     document.addEventListener('tizenhwkey', function(e) {
-        if(e.keyName == "back")
-            tizen.application.getCurrentApplication().exit();
+        if ( e.keyName == "back" ) {
+            try {
+                if ( $.mobile.urlHistory.activeIndex === 0 ) {
+                    document.removeEventListener( 'tizenhwkey', this );
+                    window.tizen.application.getCurrentApplication().exit();
+                } else {
+                    window.history.back();
+                }
+            } catch( ex ) {
+                document.removeEventListener( 'tizenhwkey', this );
+                window.tizen.application.getCurrentApplication().exit();
+            }
+        }
     });
 };
 $(document).bind('pageinit', init);
index 56db226..7f1368a 100644 (file)
@@ -7,10 +7,21 @@ var init = function () {
     // TODO:: Do your initialization job
     console.log("init() called");
 
-    // add eventListener for tizenhwkey
+    // add eventListener for tizenhwkey (Back Button)
     document.addEventListener('tizenhwkey', function(e) {
-        if(e.keyName == "back")
-            tizen.application.getCurrentApplication().exit();
+        if ( e.keyName == "back" ) {
+            try {
+                if ( $.mobile.urlHistory.activeIndex === 0 ) {
+                    document.removeEventListener( 'tizenhwkey', this );
+                    window.tizen.application.getCurrentApplication().exit();
+                } else {
+                    window.history.back();
+                }
+            } catch( ex ) {
+                document.removeEventListener( 'tizenhwkey', this );
+                window.tizen.application.getCurrentApplication().exit();
+            }
+        }
     });
 };
 $(document).bind('pageinit', init);
index 33cc778..1e60450 100644 (file)
Binary files a/org.tizen.common.verrari/templates/jar/jqm-common-resources.jar and b/org.tizen.common.verrari/templates/jar/jqm-common-resources.jar differ
index deae7ec..03270dd 100644 (file)
Binary files a/org.tizen.common.verrari/templates/jar/tizenwebuifw-common-resources.jar and b/org.tizen.common.verrari/templates/jar/tizenwebuifw-common-resources.jar differ