Permalink
Browse files

Dryed things around the setup of options

  • Loading branch information...
1 parent d51e1f2 commit d67e90518842459ce8f940690435203964aaacb6 Jesper Lindstroem Nielsen committed May 15, 2011
Showing with 31 additions and 76 deletions.
  1. +31 −76 ui/jquery.effects.split.js
View
@@ -86,6 +86,21 @@
}
}
+
+ //Intern function for setting up standard options
+ function splitOptions( el, defaults, o ) {
+ var opt = $.extend( defaults, o );
+ //Reverse it if it is hidden and mode is toggle
+ if ( el.is( ":hidden" ) && opt.mode === "toggle" ) {
+ opt.reverse = !opt.reverse;
+ }
+
+ //Sets mode for toggle
+ opt.mode = $.effects.setMode( el, opt.mode );
+ opt.show = opt.mode === "show";
+
+ return opt;
+ }
/*
* Options
@@ -174,30 +189,17 @@
*/
return this.queue( function( next ) {
-
- var opt = $.extend( {
+
+ var el = $( this ),
+ opt = splitOptions( el, {
direction: "bottom",
distance: 1,
reverse: false,
random: false,
interval: false,
fade: true,
crop: false
- },
- o
- ),
- el = $( this );
-
-
- //Reverse it if it is hidden and mode is toggle
- if ( el.is( ":hidden" ) && opt.mode === "toggle" ) {
- opt.reverse = !opt.reverse;
- }
-
- //Sets mode for toggle
- opt.mode = $.effects.setMode( el, opt.mode );
-
- opt.show = opt.mode === "show";
+ }, o );
function animate( width, height, interval, duration, row, column, documentCoords, parentCoords, callback ) {
var random = opt.random ? Math.abs( opt.random ) : 0,
@@ -281,29 +283,16 @@
return this.queue( function( next ) {
- var opt = $.extend( {
+ var el = $( this ),
+ opt = splitOptions ( el, {
direction: "bottom",
distance: 1,
reverse: false,
random: false,
interval: 0,
fade: true,
crop: false
- },
- o
- ),
- el = $( this );
-
-
- //Reverse it if it is hidden and mode is toggle
- if ( el.is( ":hidden" ) && opt.mode === "toggle" ) {
- opt.reverse = !opt.reverse;
- }
-
- //Sets mode for toggle
- opt.mode = $.effects.setMode( el, opt.mode );
-
- opt.show = opt.mode === "show";
+ }, o );
function animate( width, height, interval, duration, row, column, documentCoords, parentCoords, callback ) {
var random = opt.random ? Math.abs( opt.random ) : 0,
@@ -384,27 +373,14 @@
*/
return this.queue( function( next ) {
-
- var opt = $.extend( {
+ var el = $( this ),
+ opt = splitOptions( el, {
direction: "bottom",
distance: 1,
reverse: false,
random: false,
interval: false
- },
- o
- ),
- el = $( this );
-
- //Reverse it if it is hidden and mode is toggle
- if ( el.is( ":hidden" ) && opt.mode === "toggle" ) {
- opt.reverse = !opt.reverse;
- }
-
- //Sets mode for toggle
- opt.mode = $.effects.setMode( el, opt.mode );
-
- opt.show = opt.mode === "show";
+ }, o );
function animate( width, height, interval, duration, row, column, documentCoords, parentCoords, callback ) {
var random = opt.random ? Math.abs( opt.random ) : 0,
@@ -446,8 +422,8 @@
*/
return this.queue( function( next ) {
-
- var opt = $.extend( {
+ var el = $( this ),
+ opt = splitOptions( el, {
direction: "bottom",
distance: 1,
reverse: false,
@@ -456,20 +432,7 @@
interval: false,
fade: true,
crop: false
- },
- o
- ),
- el = $( this );
-
- //Support for toggle
- opt.mode = $.effects.setMode( el, opt.mode );
-
- //Reverse it if it is hidden and mode is toggle
- if ( el.is( ":hidden" ) && opt.mode === "toggle" ) {
- opt.reverse = !opt.reverse;
- }
-
- opt.show = opt.mode === "show";
+ }, o );
function animate( width, height, interval, duration, row, column, documentCoords, parentCoords, callback ) {
var el = $( this ),
@@ -545,24 +508,16 @@
*/
return this.queue( function( next ) {
-
- var opt = $.extend( {
+ var el = $( this ),
+ opt = splitOptions( el, {
direction: "bottom",
distance: 1,
reverse: false,
random: false,
interval: false,
fade: true,
crop: false
- },
- o
- ),
- el = $( this );
-
- //Support for toggle
- opt.mode = $.effects.setMode( el, opt.mode );
-
- opt.show = opt.mode === "show";
+ }, o );
function animate( width, height, interval, duration, row, column, documentCoords, parentCoords, callback ) {
var random = opt.random ? Math.abs( opt.random ) : 0,

0 comments on commit d67e905

Please sign in to comment.