diff options
author | Jörn Zaefferer <joern.zaefferer@gmail.com> | 2014-04-24 12:15:51 +0200 |
---|---|---|
committer | Jörn Zaefferer <joern.zaefferer@gmail.com> | 2014-04-24 12:15:51 +0200 |
commit | 16f421fd50c8c9df7c45f75c3bf75ad0aeca515e (patch) | |
tree | 33fe05474364ab1805151176d521fd0ed09ef704 | |
parent | 62c9a9c3eca5ec45ec4b89621af9734a4d458670 (diff) | |
download | jquery-ui-16f421fd50c8c9df7c45f75c3bf75ad0aeca515e.tar.gz jquery-ui-16f421fd50c8c9df7c45f75c3bf75ad0aeca515e.zip |
Position demo: Address todo comment by replacing plugin methods
-rw-r--r-- | demos/position/cycler.html | 43 |
1 files changed, 21 insertions, 22 deletions
diff --git a/demos/position/cycler.html b/demos/position/cycler.html index 83320d94f..873cac58f 100644 --- a/demos/position/cycler.html +++ b/demos/position/cycler.html @@ -25,52 +25,51 @@ </style> <script> $(function() { - // TODO refactor into a widget and get rid of these plugin methods - $.fn.left = function( using ) { - return this.position({ + function left( element, using ) { + element.position({ my: "right middle", at: "left+25 middle", of: "#container", collision: "none", using: using }); - }; - $.fn.right = function( using ) { - return this.position({ + } + function right( element, using ) { + element.position({ my: "left middle", at: "right-25 middle", of: "#container", collision: "none", using: using }); - }; - $.fn.center = function( using ) { - return this.position({ + } + function center( element, using ) { + element.position({ my: "center middle", at: "center middle", of: "#container", using: using }); - }; + } - $( "img:eq(0)" ).left(); - $( "img:eq(1)" ).center(); - $( "img:eq(2)" ).right(); + left( $( "img:eq(0)" ) ); + center( $( "img:eq(1)" ) ); + right( $( "img:eq(2)" ) ); function animate( to ) { $( this ).stop( true, false ).animate( to ); } function next( event ) { event.preventDefault(); - $( "img:eq(2)" ).center( animate ); - $( "img:eq(1)" ).left( animate ); - $( "img:eq(0)" ).right().appendTo( "#container" ); + center( $( "img:eq(2)" ), animate ); + left( $( "img:eq(1)" ), animate ); + right( $( "img:eq(0)" ).appendTo( "#container" ) ); } function previous( event ) { event.preventDefault(); - $( "img:eq(0)" ).center( animate ); - $( "img:eq(1)" ).right( animate ); - $( "img:eq(2)" ).left().prependTo( "#container" ); + center( $( "img:eq(0)" ), animate ); + right( $( "img:eq(1)" ), animate ); + left( $( "img:eq(2)" ).prependTo( "#container" ) ); } $( "#previous" ).click( previous ); $( "#next" ).click( next ); @@ -80,9 +79,9 @@ }); $( window ).resize(function() { - $( "img:eq(0)" ).left( animate ); - $( "img:eq(1)" ).center( animate ); - $( "img:eq(2)" ).right( animate ); + left( $( "img:eq(0)" ), animate ); + center( $( "img:eq(1)" ), animate ); + right( $( "img:eq(2)" ), animate ); }); }); </script> |