Pinch: Fix jslint errors
authorPrzemyslaw Ciezkowski <p.ciezkowski@samsung.com>
Thu, 9 May 2013 15:48:13 +0000 (17:48 +0200)
committerheeju.joo <heeju.joo@samsung.com>
Mon, 29 Jul 2013 00:52:46 +0000 (09:52 +0900)
Fixed jslint errors.
Removed unnecessary variables, changed scope of
'current' variable to be available in touchend event.

Change-Id: Ic20b523547e4c6549ed792d7a2457b8a6bca0d5e

src/js/jquery.mobile.tizen.pinch.js

index cece62a..7b10c6e 100644 (file)
@@ -249,124 +249,123 @@ define( [
 
 //>>excludeEnd("jqmBuildExclude");
 
-( function( $, window, undefined ) {
+( function ( $, undefined ) {
 
-pinch_event = {
-       setup: function () {
-               var thisObject = this,
-                       $this = $( thisObject );
+       var pinch_event = {
+               setup: function () {
+                       var thisObject = this,
+                               $this = $( thisObject );
 
-               if ( !$.mobile.support.touch ) {
-                       return;
-               }
-
-               function getSize( point ) {
-                       var x = point[0].x - point[1].x,
-                               y = point[0].y - point[1].y;
-
-                       return Math.abs( x * y );
-               }
-
-               function getParameter( point, ratio ) {
-                       return { point: point, ratio: ratio };
-               }
-
-               $this.bind( "touchstart", function ( event ) {
-                       var data = event.originalEvent.touches,
-                               origin,
-                               last_ratio = 1,
-                               processing = false;
-
-                       if ( !$.mobile.pinch.enabled ) {
+                       if ( !$.mobile.support.touch ) {
                                return;
                        }
 
-                       if ( data.length != 2 ) {
-                               return;
-                       }
+                       function getSize( point ) {
+                               var x = point[0].x - point[1].x,
+                                       y = point[0].y - point[1].y;
 
-                       origin = [
-                                       { x: data[0].pageX, y: data[0].pageY },
-                                       { x: data[1].pageX, y: data[1].pageY }
-                       ];
+                               return Math.abs( x * y );
+                       }
 
-                       $( event.target ).trigger( "pinchstart", getParameter( origin, undefined ) );
+                       function getParameter( point, ratio ) {
+                               return { point: point, ratio: ratio };
+                       }
 
-                       function pinchHandler( event ) {
+                       $this.bind( "touchstart", function ( event ) {
                                var data = event.originalEvent.touches,
-                                       current,
-                                       ratio,
-                                       delta,
-                                       factor = $( window ).width() / $.mobile.pinch.factor;
+                                       origin,
+                                       last_ratio = 1,
+                                       processing = false,
+                                       current;
 
-                               if ( processing ) {
+                               if ( !$.mobile.pinch.enabled ) {
                                        return;
                                }
 
-                               if ( !origin ) {
+                               if ( data.length != 2 ) {
                                        return;
                                }
 
-                               current = [
+                               origin = [
+                                       { x: data[0].pageX, y: data[0].pageY },
+                                       { x: data[1].pageX, y: data[1].pageY }
+                               ];
+
+                               $( event.target ).trigger( "pinchstart", getParameter( origin, undefined ) );
+
+                               function pinchHandler( event ) {
+                                       var data = event.originalEvent.touches,
+                                               ratio,
+                                               delta;
+
+                                       if ( processing ) {
+                                               return;
+                                       }
+
+                                       if ( !origin ) {
+                                               return;
+                                       }
+
+                                       current = [
                                                { x: data[0].pageX, y: data[0].pageY },
                                                { x: data[1].pageX, y: data[1].pageY }
-                               ];
+                                       ];
 
-                               delta = Math.sqrt( getSize( current ) / getSize( origin )  ) ;
-                               if( delta ) {
-                                       ratio = delta;
-                               }
+                                       delta = Math.sqrt( getSize( current ) / getSize( origin )  ) ;
+                                       if ( delta ) {
+                                               ratio = delta;
+                                       }
 
-                               if ( ratio < $.mobile.pinch.min ) {
-                                       ratio = $.mobile.pinch.min;
-                               } else if ( ratio > $.mobile.pinch.max ) {
-                                       ratio = $.mobile.pinch.max;
-                               }
+                                       if ( ratio < $.mobile.pinch.min ) {
+                                               ratio = $.mobile.pinch.min;
+                                       } else if ( ratio > $.mobile.pinch.max ) {
+                                               ratio = $.mobile.pinch.max;
+                                       }
 
-                               if ( Math.abs( ratio - last_ratio ) < $.mobile.pinch.threshold ) {
-                                       return;
-                               }
+                                       if ( Math.abs( ratio - last_ratio ) < $.mobile.pinch.threshold ) {
+                                               return;
+                                       }
 
-                               $( event.target ).trigger( "pinch", getParameter( current, ratio ) );
+                                       $( event.target ).trigger( "pinch", getParameter( current, ratio ) );
 
-                               last_ratio = ratio;
+                                       last_ratio = ratio;
 
-                               if ( $.mobile.pinch.interval ) {
-                                       processing = true;
+                                       if ( $.mobile.pinch.interval ) {
+                                               processing = true;
 
-                                       setTimeout( function () {
-                                               processing = false;
-                                       }, $.mobile.pinch.interval );
+                                               setTimeout( function () {
+                                                       processing = false;
+                                               }, $.mobile.pinch.interval );
+                                       }
                                }
-                       }
 
-                       $this.bind( "touchmove", pinchHandler )
-                               .one( "touchend", function ( event ) {
-                                       $this.unbind( "touchmove", pinchHandler );
-                                       $( event.target ).trigger( "pinchend",
-                                                               getParameter( undefined, last_ratio ) );
-
-                                       origin = undefined;
-                                       current = undefined;
-                                       last_ratio = 1;
-                                       processing = false;
-                               });
-               });
-       }
-};
-
-$.event.special["pinch"] = pinch_event;
-
-$.mobile.pinch = {
-       enabled: true,
-       min: 0.1,
-       max: 3,
-       factor: 4,
-       threshold: 0.01,
-       interval: 50
-};
-
-})( jQuery, this );
+                               $this.bind( "touchmove", pinchHandler )
+                                       .one( "touchend", function ( event ) {
+                                               $this.unbind( "touchmove", pinchHandler );
+                                               $( event.target ).trigger( "pinchend",
+                                                                       getParameter( undefined, last_ratio ) );
+
+                                               origin = undefined;
+                                               current = undefined;
+                                               last_ratio = 1;
+                                               processing = false;
+                                       });
+                       });
+               }
+       };
+
+       $.event.special.pinch = pinch_event;
+
+       $.mobile.pinch = {
+               enabled: true,
+               min: 0.1,
+               max: 3,
+               factor: 4,
+               threshold: 0.01,
+               interval: 50
+       };
+
+}( jQuery, this ) );
 
 //>>excludeStart("jqmBuildExclude", pragmas.jqmBuildExclude);
 } );