Core: Performance fix for disableSelection and enableSelection
authorPrzemyslaw Ciezkowski <p.ciezkowski@samsung.com>
Fri, 5 Apr 2013 16:17:33 +0000 (18:17 +0200)
committerYoumin Ha <youmin.ha@samsung.com>
Wed, 10 Apr 2013 14:57:34 +0000 (23:57 +0900)
Also fixed variable declaration - 'val' was global.

Change-Id: I0ad692059bcad4c16628d3b7a7e28e2f91db34bd
Tests: /tests/unit-tests/core/

src/js/jquery.mobile.tizen.core.js

index 28adb3c..f045273 100644 (file)
@@ -43,39 +43,33 @@ ensureNS("jQuery.mobile.tizen");
 
 (function () {
 jQuery.extend(jQuery.mobile.tizen, {
-    disableSelection: function (element) {
-       var self = this;
-       $(element).find('*').each( function() {
-               if( ( $(this).get(0).tagName !== 'INPUT' &&
-                       $(this).attr("type") !== 'text' ) &&
-                       $(this).get(0).tagName !== 'TEXTAREA' ) {
-                       self.enableSelection( this, 'none' );
-               }
-       } );
-       return true;
-    },
-
-    enableSelection: function (element, value) {
-        return $(element).each( function () {
-               switch( value ) {
+       disableSelection: function (element) {
+               this.enableSelection(
+                       $(element).find('*').not( 'input, [type="text"], textarea' ),
+                       'none'
+               );
+               return true;
+       },
+
+       enableSelection: function (element, value) {
+               var val;
+               switch ( value ) {
                        case 'text' :
                        case 'auto' :
                        case 'none' :
                                val = value;
                        break;
-
                        default :
                                val = 'auto';
                        break;
                }
-            $(this).css( {
+               return $(element).css( {
                        'user-select': val,
                        '-moz-user-select': val,
                        '-webkit-user-select': val,
                        '-o-user-select': val,
                        '-ms-transform': val
-                       } );
-        } );
+               } );
     },
 
     disableContextMenu: function(element) {