]> source.dussan.org Git - jquery-ui.git/commitdiff
Effects Tests: Fix and format scale visual test
authorMike Sherov <mike.sherov@gmail.com>
Thu, 28 Aug 2014 13:04:20 +0000 (09:04 -0400)
committerMike Sherov <mike.sherov@gmail.com>
Tue, 2 Sep 2014 23:24:18 +0000 (19:24 -0400)
tests/visual/effects/scale.html

index 17744295507fdc6344744ed0ad2c7be78238f0ae..648a7027b8cbcee9bc16148855104f5e7cb77541 100644 (file)
@@ -7,6 +7,7 @@
        <script src="../../../external/jquery/jquery.js"></script>
        <script src="../../../ui/effect.js"></script>
        <script src="../../../ui/effect-scale.js"></script>
+       <script src="../../../ui/effect-size.js"></script>
        <script>
        $(function() {
                var test = $( "#testBox" ),
@@ -14,7 +15,6 @@
                        optsRev = $( opts.get().reverse() ),
                        doer = $( "#doAnim" ),
                        current = $( "#current" ),
-                       cleanStyle = test[0].style,
                        total = 1;
 
                opts.each(function() {
                        optsRev.each(function() {
                                var cur = this.selectedIndex,
                                        next = cur + direction,
-                                       len = this.options.length;
+                                       len = this.options.length,
+                                       newIndex = ( next + len ) % len;
 
-                               this.selectedIndex = ( next + len ) % len;
+                               this.selectedIndex = newIndex;
 
-                               if ( ( next+len ) % len === next ) return false;
+                               if ( newIndex === next ) {
+                                       return false;
+                               }
                        });
                        doAnim();
                }
 
-
                function doAnim() {
                        var cur = 0;
                        opts.each(function() {
-                               cur *= this.options.length
+                               cur *= this.options.length;
                                cur += this.selectedIndex;
                        });
                        cur++;
                        current.text( "Configuration: " + cur + " of " + total );
-                       run.apply(test, opts.map(function() {
-                               return $(this).val();
-                       }).get());
+                       run.apply( test, opts.map(function() {
+                               return $( this ).val();
+                       }).get() );
                }
 
                function run( position, v, h, vo, ho ) {
                        var el = this,
-                               style = el[0].style,
+                               style = el[ 0 ].style,
                                effect = {
                                        effect: "scale",
                                        mode: "effect",
                                        origin: [ vo, ho ],
                                        duration: 500
                                };
-                       el.stop(true, true);
+
+                       el.stop( true, true );
+
                        if ( typeof style === "object" ) {
                                style.cssText = "";
                        } else {
-                               el[0].style = "";
+                               el[ 0 ].style = "";
                        }
+
                        el.css( "position", position )
                                .css( h, 5 )
                                .css( v, 5 )
                border: 10px solid #fff;
                margin: 10px;
                padding: 10px;
+               position: absolute;
+               left: 5px;
+               top: 5px;
        }
        label {
                display: block;
        </style>
 </head>
 <body>
+
        <div id="testArea">
                <div id="testBox">
                </div>
                <button id="doAnim">Run Animation</button>
                <button id="cycleNext">Forward</button>
        </div>
+
 </body>
+</html>