Subversion Repositories SmartDukaan

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
7272 amit.gupta 1
/*
2
 * DDSlider v1.7 - http://codecanyon.net/item/ddslider-10-transitions-inline-content-support/104797
3
 * 
4
 * Copyright © 2010 Guilherme Salum
5
 * All rights reserved.
6
 * 
7
 * You may not modify and/or redistribute this file
8
 * save cases where Extended License has been purchased
9
 *
10
*/
11
 
12
(function($){ 
13
    $.fn.extend({ 
14
        DDSlider: function() { 
15
 
16
			var DDCont = this;
17
 
18
			isPlaying = false;
19
 
20
			var DDefaults = {
21
 
22
				trans: 'fading',
23
				delay: 30,
24
				waitTime: 5000,
25
				duration: 100,
26
				stopSlide: 1,
27
				bars: 1,
28
				columns: 1,
29
				rows: 1,
30
				ease: 'swing'
31
 
32
 
33
			};			
34
 
35
			attr = arguments[0] || {};
36
 
37
			if(attr.trans === undefined) { attr.trans = DDefaults.trans; }
38
			if(attr.delay === undefined) { attr.delay = DDefaults.delay; }
39
			if(attr.duration === undefined) { attr.duration = DDefaults.duration; }
40
			if(attr.waitTime === undefined) { attr.waitTime = DDefaults.waitTime; }
41
			if(attr.stopSlide === undefined) { attr.stopSlide = DDefaults.stopSlide; }
42
			if(attr.bars === undefined) { attr.bars = DDefaults.bars; }
43
			if(attr.columns === undefined) { attr.columns = DDefaults.columns; }
44
			if(attr.rows === undefined) { attr.rows = DDefaults.rows; }
45
			if(attr.ease === undefined) { attr.ease = DDefaults.ease; }
46
 
47
			attr.width = this.width();
48
			attr.height = this.height();			
49
 
50
			//Sets up the slider structure
51
			this.children('li:first').addClass('current');
52
 
53
			var iNum = 1;
54
 
55
				//Add Selector container
56
				if(attr.selector === true) {
57
 
58
					this.append('<ul class="slider_selector"></ul>');
59
 
60
				}
61
 
62
				//Adds Selectors and set slider classes
63
				this.children('li').each(function() {
64
 
65
					$(this).addClass('slider_'+iNum);
66
 
67
					//sets the selectors
68
 
69
					if(attr.selector === undefined) {
70
 
71
					} else {
72
 
73
						if(iNum == 1) {
74
							$(attr.selector).append('<li class="current sel_'+iNum+'"></li>');
75
						} else {
76
							$(attr.selector).append('<li class="sel_'+iNum+'"></li>');
77
						}
78
 
79
					}
80
 
81
					iNum++;
82
 
83
				});	
84
 
85
			var isClicked = 0;
86
 
87
			//If user has only one <li> stops the slide
88
			if(this.children('li').length == 1) {
89
 
90
				stopAll = 1;
91
 
92
			} else {
93
 
94
				stopAll = 0;
95
 
96
			}
97
 
98
			if(stopAll === 0) {
99
 
100
				//Sets arrows events
101
				if(attr.prevSlide === undefined) {  } else {
102
 
103
					$(attr.prevSlide).click(function(){
104
 
105
						if(isPlaying === false) {
106
 
107
							DDCont.prevSlide(attr); isClicked = 1;
108
 
109
						}
110
 
111
					});
112
 
113
				}
114
				if(attr.nextSlide === undefined) {  } else {
115
 
116
					$(attr.nextSlide).click(function(){
117
 
118
						if(isPlaying === false) {
119
 
120
							DDCont.nextSlide(attr); isClicked = 1;
121
 
122
						}
123
 
124
					});
125
 
126
				}
127
 
128
 
129
				$(attr.selector).children('li').click(function() { var itemId = $(this).attr('class').split(' ');
130
 
131
					if(itemId[0] == 'current' || itemId[1] == 'current') {
132
 
133
						//do nothing
134
 
135
					} else {
136
 
137
						itemId = itemId[0].split('_');
138
 
139
						if(isPlaying === false) {
140
 
141
							isClicked = 1;
142
							DDCont.callSlide(itemId[1], attr);
143
 
144
						}
145
 
146
 
147
					}						   
148
				});
149
 
150
				//AutoSlider
151
				var isHovered = 0;
152
				//check if user is hovering the slide
153
				$(this).hover(function() { // Whenever an item is hovered
154
					isHovered = 1; //Setting isHovered 1, we stop the autsliding from going on
155
				}, function() {
156
					isHovered = 0;//Setting isHovered 1, we make the autsliding go on
157
				});
158
 
159
				//Events
160
				setInterval(function() {
161
 
162
					if(attr.stopSlide == 1) {
163
 
164
						if(isHovered === 0 && isClicked === 0) { DDCont.nextSlide(attr); }
165
 
166
					} else {
167
 
168
						 if(isClicked === 0) { DDCont.nextSlide(attr); }
169
 
170
					}
171
 
172
				}, attr.waitTime);
173
 
174
			}
175
 
176
        },
177
 
178
		nextSlide: function() {
179
 
180
			//finds out the current slider and the next one
181
			var currentItem = this.children('li.current');
182
			var nextItem = currentItem.next('li');
183
 
184
 
185
			//finds selectors
186
			var currentSel = $(attr.selector).children('li.current');
187
			var nextSel = $(attr.selector).children('li.current').next();
188
 
189
			//if the is no next one, choose the first
190
			if(nextItem.length > 0) {
191
				//Do nothing. The  $next element exists
192
			} else {
193
				nextItem = this.children('li:first');
194
				nextSel = $(attr.selector).children('li:first');
195
			}
196
 
197
			this.nextTransition(attr, nextItem, currentItem, nextSel, currentSel);
198
 
199
		},
200
 
201
		prevSlide: function() {
202
 
203
			//finds out the current slider and the next one
204
			var currentItem = this.children('li.current');
205
			var prevItem = currentItem.prev('li');
206
 
207
 
208
			//finds selectors
209
			var currentSel = $(attr.selector).children('li.current');
210
			var prevSel = $(attr.selector).children('li.current').prev();
211
 
212
			//if the is no next one, choose the first
213
			if(prevItem.length > 0) {
214
				//Do nothing. The  $next element exists
215
			} else {
216
				prevItem = this.children('li:last');
217
				prevSel = $(attr.selector).children('li:last');
218
			}
219
 
220
			this.nextTransition(attr, prevItem, currentItem, prevSel, currentSel);
221
 
222
		},
223
 
224
		callSlide: function(slideID) {
225
 
226
			var currentItem = this.children('li.current');
227
			var nextItem = this.children('li.slider_'+slideID);
228
 
229
			var currentSel = $(attr.selector).children('li.current');
230
			var nextSel = $(attr.selector).children('li.sel_'+slideID);
231
 
232
			this.nextTransition(attr, nextItem, currentItem, nextSel, currentSel);
233
 
234
		},
235
 
236
		nextTransition: function(attr, transNext, transCur, transSelNext, transSelCur) {
237
 
238
			var nextTransitionTemp = transNext.attr('class').split(' ');
239
			var nextTransition = nextTransitionTemp[0];
240
			if(nextTransition == '') { nextTransition = attr.trans; }
241
 
242
 
243
 
244
			if(nextTransition == 'random' || nextTransition == 'fading' || nextTransition == 'barTop' || nextTransition == 'barBottom' || nextTransition == 'square' || nextTransition == 'squareMoving' || nextTransition == 'barFade' || nextTransition == 'barFadeRandom' || nextTransition == 'squareRandom' || nextTransition == 'squareOut' || nextTransition == 'squareOutMoving' || nextTransition == 'rowInterlaced') {  } else { nextTransition = 'random'; }
245
 
246
			if(nextTransition == 'random') {
247
 
248
				var transitionArray = ['barTop','fading','barBottom','square', 'squareRandom', 'squareMoving', 'barFade', 'barFadeRandom', 'squareOut', 'squareOutMoving', 'rowInterlaced'];
249
				var arr_trans = [0,1,2,3,4,5,6,7,8,9,10];
250
 
251
				var nextTransShuffle = $.shuffle(arr_trans);
252
 
253
				nextTransition = transitionArray[nextTransShuffle[0]];
254
 
255
			}
256
 
257
			if(nextTransition == 'fading') { this.DDFading(attr, transNext, transCur, transSelNext, transSelCur);  }
258
			else if(nextTransition == 'barTop') { this.DDBarTop(attr, transNext, transCur, transSelNext, transSelCur); }
259
			else if(nextTransition == 'barBottom') { this.DDBarBottom(attr, transNext, transCur, transSelNext, transSelCur); }
260
			else if(nextTransition == 'square') { this.DDSquare(attr, transNext, transCur, transSelNext, transSelCur); }
261
			else if(nextTransition == 'squareRandom') { this.DDSquareRandom(attr, transNext, transCur, transSelNext, transSelCur); }
262
			else if(nextTransition == 'squareMoving') { this.DDSquareMoving(attr, transNext, transCur, transSelNext, transSelCur); }
263
			else if(nextTransition == 'barFade') { this.DDBarFade(attr, transNext, transCur, transSelNext, transSelCur); }
264
			else if(nextTransition == 'barFadeRandom') { this.DDBarFadeRandom(attr, transNext, transCur, transSelNext, transSelCur); }
265
			else if(nextTransition == 'squareOut') { this.DDSquareOut(attr, transNext, transCur, transSelNext, transSelCur); }
266
			else if(nextTransition == 'squareOutMoving') { this.DDSquareOutMoving(attr, transNext, transCur, transSelNext, transSelCur); }
267
			else if(nextTransition == 'rowInterlaced') { this.DDRowInterlaced(attr, transNext, transCur, transSelNext, transSelCur); }
268
			else { this.DDFading(attr, transNext, transCur, transSelNext, transSelCur); }
269
 
270
		},
271
 
272
		DDFading: function(attr, fadeNext, fadeCur, nextSel, curSel) {
273
 
274
			var ddx = this;
275
 
276
			//lets disable all buttons
277
			this.disableSelectors();
278
 
279
			fadeNext.css({ opacity: 1 });
280
 
281
 
282
			//adds the next class
283
			fadeNext.addClass('next');
284
 
285
			curSel.removeClass('current');
286
			nextSel.addClass('current');
287
 
288
			//animates the current so it disappears
289
			fadeCur.stop().animate({ opacity: 0 }, attr.duration, function() {
290
 
291
				fadeNext.addClass('current').removeClass('next');
292
				fadeCur.removeClass('current').css({ opacity: 1 });
293
 
294
				//enables all selectors
295
				ddx.enableSelectors();
296
 
297
			});
298
 
299
		},
300
 
301
		DDBarTop: function(attr, barNext, barCur, nextSel, curSel) {
302
 
303
			var ddx = this;
304
 
305
			//lets disable all buttons
306
			this.disableSelectors();
307
 
308
			barNext.css({ opacity: 1 });
309
 
310
			//set vars
311
			var bar_width = Math.round(attr.width / attr.bars);
312
 
313
			var bar_height = attr.height;
314
			var bar_top = (bar_height - (bar_height * 2));
315
 
316
			//Let's create the bar divs
317
			var iNum = 1;
318
			while(iNum <= attr.bars) {
319
 
320
				var position = (iNum * bar_width) - bar_width;
321
				this.append('<div class="slider_bar slider_bar_'+iNum+'" style="position: absolute; overflow: hidden;'+barNext.attr('style')+'"></div>');
322
				this.children('.slider_bar_'+iNum).css({ left: position, height: bar_height, width: bar_width, top: bar_top, 'z-index': 3, 'background-position': '-'+position+'px top' });
323
				iNum++;
324
 
325
			}
326
 
327
			//lets put the content in the bar and animate it
328
 
329
			//set vars
330
			var iNum2 = 1;
331
 
332
			while(iNum2 <= attr.bars) {
333
 
334
				var position2 = (iNum2 * bar_width) - bar_width;
335
				var delay = (iNum2 * attr.delay);
336
				this.children('.slider_bar_'+iNum2).append('<div style="position: absolute; left: -'+position2+'px; width: '+attr.width+'px; height: '+attr.height+'px;">'+barNext.html()+'</div>');
337
				this.children('.slider_bar_'+iNum2).animate({ opacity: 1 }, delay).animate({ top: 0 }, {duration: attr.duration, easing: attr.ease});
338
				iNum2++;
339
 
340
 
341
			}
342
 
343
			curSel.removeClass('current');
344
			nextSel.addClass('current');
345
 
346
			//let's do stuff after the animation is over
347
			var totalDelay = (attr.bars * attr.delay);
348
			barNext.animate({ opacity: 0 }, totalDelay).animate({opacity: 0}, attr.duration, function() {
349
 
350
				$(this).addClass('current').css({ opacity: 1 });
351
 
352
				barCur.animate({ opacity: 0 }, 200, function() {
353
 
354
					$(this).removeClass('current');
355
 
356
					//removes the transition containers
357
					ddx.children('.slider_bar').remove();
358
 
359
					//Enables the selectors
360
					ddx.enableSelectors();
361
 
362
				});
363
 
364
			});
365
 
366
		},
367
 
368
		DDBarBottom: function(attr, barPrev, barCur, nextSel, curSel) {
369
 
370
			var ddx = this;
371
 
372
			//lets disable all buttons
373
			this.disableSelectors();
374
 
375
			barPrev.css({ opacity: 1 });
376
 
377
			//set vars
378
			var bar_width = Math.round(attr.width / attr.bars);
379
			var bar_height = attr.height;
380
			var bar_top = bar_height;
381
 
382
			//Let's create the bar divs
383
			var iNum = 1;
384
			while(iNum <= attr.bars) {
385
 
386
				var position = (iNum * bar_width) - bar_width;	
387
				this.append('<div class="slider_bar slider_bar_'+iNum+'" style="position: absolute; overflow: hidden;'+barPrev.attr('style')+'"></div>');
388
				this.children('.slider_bar_'+iNum).css({ left: position, height: bar_height, width: bar_width, top: bar_top, 'z-index': 3, 'background-position': '-'+position+'px top' });
389
				iNum++;
390
 
391
			}
392
 
393
			//lets put the images in the bar and animate it
394
 
395
			//set vars
396
			var iNum2 = (1);
397
			var iNum3 = attr.bars;
398
			bar_width = Math.round(attr.width / attr.bars);
399
			bar_height = attr.height;
400
 
401
			while(iNum2 <= attr.bars) {
402
 
403
				var position2 = (iNum2 * bar_width) - bar_width;
404
				var delay = (iNum2 * attr.delay);
405
				this.children('.slider_bar_'+iNum2).append('<div style="position: absolute; left: -'+position2+'px; width: '+attr.width+'px; height: '+attr.height+'px;">'+barPrev.html()+'</div>');
406
				this.children('.slider_bar_'+iNum3).animate({ opacity: 1 }, delay).animate({ top: 0 }, {duration: 500, easing: attr.ease});
407
				iNum2++; iNum3--;
408
 
409
 
410
			}
411
 
412
			curSel.removeClass('current');
413
			nextSel.addClass('current');
414
 
415
			//let's do stuff after the animation is over
416
			var totalDelay = (attr.bars * attr.delay);
417
			barPrev.animate({ opacity: 0 }, totalDelay).animate({opacity: 0}, attr.duration, function() {
418
 
419
				$(this).addClass('current').css({ opacity: 1 });
420
 
421
				barCur.animate({ opacity: 0 }, 200, function() {
422
 
423
					$(this).removeClass('current');
424
 
425
					//removes the transition containers
426
					ddx.children('.slider_bar').remove();
427
 
428
					//Enables the selectors
429
					ddx.enableSelectors();
430
 
431
				});	
432
 
433
			});
434
 
435
		},
436
 
437
		DDBarFade: function(attr, barNext, barCur, nextSel, curSel) {
438
 
439
			var ddx = this;
440
 
441
			//lets disable all buttons
442
			this.disableSelectors();
443
 
444
			barNext.css({ opacity: 1 });
445
 
446
			//set vars
447
			var bar_width = Math.round(attr.width / attr.bars);
448
			var bar_height = attr.height;
449
 
450
			//Let's create the bar divs
451
			var i = 1;
452
			while(i <= attr.bars) {
453
 
454
				var position = (i * bar_width) - bar_width;
455
				this.append('<div class="slider_bar slider_bar_'+i+'" style="position: absolute; overflow: hidden;'+barNext.attr('style')+'"></div>');
456
				this.children('.slider_bar_'+i).css({ left: position, opacity: 0, height: bar_height, width: bar_width, 'z-index': 3, 'background-position': '-'+position+'px top' });
457
				i++;
458
 
459
			}
460
 
461
			//lets put the content in the bar and animate it
462
 
463
			//set vars
464
			var ii = 1;
465
 
466
			while(ii <= attr.bars) {
467
 
468
				var position2 = (ii * bar_width) - bar_width;
469
				delay = (ii * attr.delay);
470
				this.children('.slider_bar_'+ii).append('<div style="position: absolute; left: -'+position2+'px; width: '+attr.width+'px; height: '+attr.height+'px;">'+barNext.html()+'</div>');
471
				this.children('.slider_bar_'+ii).animate({opacity: 0}, delay).animate({ opacity: 1 }, {duration: attr.duration, easing: attr.ease});
472
				ii++;
473
 
474
 
475
			}
476
 
477
			curSel.removeClass('current');
478
			nextSel.addClass('current');
479
 
480
			//let's do stuff after the animation is over
481
			var totalDelay = (attr.bars * attr.delay);
482
			barNext.animate({opacity: 0}, totalDelay).animate({opacity: 0}, attr.duration, function() {
483
 
484
				$(this).addClass('current').css({ opacity: 1 });
485
 
486
				barCur.animate({ opacity: 0 }, 200, function() {
487
 
488
					$(this).removeClass('current');
489
 
490
					//removes the transition containers
491
					ddx.children('.slider_bar').remove();
492
 
493
					//Enables the selectors
494
					ddx.enableSelectors();
495
 
496
				});
497
 
498
			});
499
 
500
		},
501
 
502
		DDBarFadeRandom: function(attr, barNext, barCur, nextSel, curSel) {
503
 
504
			var ddx = this;
505
 
506
			//lets disable all buttons
507
			this.disableSelectors();
508
 
509
			barNext.css({ opacity: 1 });
510
 
511
			//set vars
512
			var bar_width = Math.round(attr.width / attr.bars);
513
			var bar_height = attr.height;
514
 
515
			//create array of number of bars so we can shuffle it
516
			var bars_array = [];
517
 
518
			//Let's create the bar divs
519
			var i = 1;
520
			while(i <= attr.bars) {
521
 
522
				var position = (i * bar_width) - bar_width;
523
				this.append('<div class="slider_bar slider_bar_'+i+'" style="position: absolute; overflow: hidden;'+barNext.attr('style')+'"></div>');
524
				this.children('.slider_bar_'+i).css({ left: position, opacity: 0, height: bar_height, width: bar_width, 'z-index': 3, 'background-position': '-'+position+'px top' });
525
 
526
				//inserts content in our array of bars
527
				bars_array[(i- 1)] = [i];
528
 
529
				i++;
530
 
531
			}
532
 
533
 
534
			//shuffles the array of bars
535
			var bars_array_shuffle = $.shuffle(bars_array);
536
 
537
			//lets put the content in the bar and animate it
538
			//set vars
539
			var ii = 1;
540
 
541
			while(ii <= attr.bars) {
542
 
543
				var position2 = (ii * bar_width) - bar_width;
544
				var delay = (ii * attr.delay);
545
				this.children('.slider_bar_'+ii).append('<div style="position: absolute; left: -'+position2+'px; width: '+attr.width+'px; height: '+attr.height+'px;">'+barNext.html()+'</div>');
546
 
547
				this.children('.slider_bar_'+bars_array_shuffle[(ii) - 1]).animate({ opacity: 0 }, delay).animate({ opacity: 1 }, {duration: attr.duration, easing: attr.ease});
548
				ii++;
549
 
550
 
551
 
552
			}
553
 
554
			curSel.removeClass('current');
555
			nextSel.addClass('current');
556
 
557
			//let's do stuff after the animation is over
558
			var totalDelay = (attr.bars * attr.delay);
559
			barNext.animate({opacity: 0}, totalDelay).animate({opacity: 0}, attr.duration, function() {
560
 
561
				$(this).addClass('current').css({ opacity: 1 });
562
 
563
				barCur.animate({ opacity: 0 }, 200, function() {
564
 
565
					$(this).removeClass('current');
566
 
567
					//removes the transition containers
568
					ddx.children('.slider_bar').remove();
569
 
570
					//Enables the selectors
571
					ddx.enableSelectors();
572
 
573
				});
574
 
575
			});
576
 
577
		},
578
 
579
		DDSquare: function(attr, squareNext, squareCur, nextSel, curSel) {
580
 
581
			var ddx = this;
582
 
583
			//lets disable all buttons
584
			this.disableSelectors();
585
 
586
			squareNext.css({ opacity: 1 });
587
 
588
			//set vars
589
			var row_width = Math.round(attr.width / attr.columns);
590
			var row_height = Math.round(attr.height / attr.rows);
591
 
592
			//Let's create the block divs
593
			var i_row_numbers = 1;
594
			var i_column_numbers = (1);
595
 
596
			//create each row
597
			while(i_row_numbers <= attr.rows) {
598
 
599
				var initial = i_row_numbers;
600
				var class_row = 'block_row_'+i_row_numbers;
601
 
602
				//create each column of each row
603
				while(i_column_numbers <= attr.columns) {
604
 
605
					var block_ID_name = 'block_ID_'+((attr.columns * i_row_numbers)-(attr.columns - i_column_numbers));
606
					var class_block = 'slider_block_'+(initial++);
607
					var class_column = 'block_column_'+i_column_numbers;
608
 
609
					var block_top = ((i_row_numbers * row_height) - row_height);
610
					var block_left = ((i_column_numbers * row_width) - row_width);
611
 
612
					var position_left = (row_width * i_column_numbers) - row_width;
613
					var position_top = (row_height * i_row_numbers) - row_height;
614
 
615
					if(squareNext.attr('style') === undefined) {
616
 
617
						this.append('<div class="slider_block '+block_ID_name+' '+class_block+' '+class_row+' '+class_column+'" style="position: absolute; overflow: hidden;"></div>');
618
 
619
					} else {
620
 
621
						this.append('<div class="'+block_ID_name+' slider_block '+class_block+' '+class_row+' '+class_column+'" style="position: absolute; overflow: hidden;'+squareNext.attr('style')+'"></div>');
622
					}
623
 
624
					this.children('.'+block_ID_name).css({ width: row_width, height: row_height, 'z-index': 4, top:block_top+'px', left: block_left+'px', opacity: 0, 'background-position': '-'+position_left+'px -'+position_top+'px' }).append('<div style="position: absolute; left: -'+position_left+'px; top: -'+position_top+'px; width: '+attr.width+'px; height: '+attr.height+'px;">'+squareNext.html()+'</div>');
625
 
626
					i_column_numbers++; initial++;
627
 
628
				}
629
 
630
				i_row_numbers++;
631
				i_column_numbers = 1;
632
			}
633
 
634
			//Let's reset the block divs
635
			i_row_numbers = 1;
636
			i_column_numbers = 1;
637
 
638
 
639
 
640
 
641
			while(i_row_numbers <= attr.rows) {
642
 
643
				var initial2 = i_row_numbers;
644
 
645
				//create each column of each row
646
				while(i_column_numbers <= attr.columns) {
647
 
648
					var animated_class = '.slider_block_'+(initial2++);
649
 
650
					delay = (attr.delay * initial2);
651
 
652
					$(animated_class).animate({ width: row_width }, delay).animate({ opacity: 1 }, {duration: attr.duration, easing: attr.ease});
653
 
654
					i_column_numbers++; initial2++;
655
 
656
				}
657
 
658
				i_row_numbers++;
659
				i_column_numbers = 1;
660
			}
661
 
662
			curSel.removeClass('current');
663
			nextSel.addClass('current');
664
 
665
			var delay_total = (delay + attr.duration);
666
 
667
			squareNext.animate({ opacity: 0 }, delay_total).animate({ opacity: 0 }, 1, function() {
668
 
669
				$(this).addClass('current').css({ opacity: 1 });
670
 
671
				squareCur.animate({ opacity: 0 }, 200, function() {
672
 
673
					$(this).removeClass('current');
674
 
675
					//removes the transition containers
676
					ddx.children('.slider_block').remove();
677
 
678
					//Enables the selectors
679
					ddx.enableSelectors();
680
 
681
				});
682
 
683
			});
684
 
685
		},
686
 
687
		DDSquareRandom: function(attr, squareNext, squareCur, nextSel, curSel) {
688
 
689
			var ddx = this;
690
 
691
			//lets disable all buttons
692
			this.disableSelectors();
693
 
694
			squareNext.css({ opacity: 1 });
695
 
696
			//set vars
697
			var row_width = Math.round(attr.width / attr.columns);
698
			var row_height = Math.round(attr.height / attr.rows);
699
 
700
			//Let's create the block divs
701
			var i_row_numbers = 1;
702
			var i_column_numbers = 1;
703
 
704
			var square_arr = [];
705
			var square_total = 0;
706
 
707
			//create each row
708
			while(i_row_numbers <= attr.rows) {
709
 
710
				var initial = i_row_numbers;
711
				var class_row = 'block_row_'+i_row_numbers;
712
 
713
				//create each column of each row
714
				while(i_column_numbers <= attr.columns) {
715
 
716
					square_arr[square_total] = (square_total + 1);
717
					square_total++;
718
 
719
					var block_ID_name = 'block_ID_'+((attr.columns * i_row_numbers)-(attr.columns - i_column_numbers));
720
					var class_block = 'slider_block_'+(initial++);
721
					var class_column = 'block_column_'+i_column_numbers;
722
 
723
					var block_top = ((i_row_numbers * row_height) - row_height);
724
					var block_left = ((i_column_numbers * row_width) - row_width);
725
 
726
					var position_left = (row_width * i_column_numbers) - row_width;
727
					var position_top = (row_height * i_row_numbers) - row_height;
728
 
729
					if(squareNext.attr('style') === undefined) {
730
 
731
						this.append('<div class="'+block_ID_name+' slider_block '+class_block+' '+class_row+' '+class_column+'" style="position: absolute; overflow: hidden;"></div>');
732
 
733
					} else {
734
 
735
						this.append('<div class="'+block_ID_name+' slider_block '+class_block+' '+class_row+' '+class_column+'" style="position: absolute; overflow: hidden;'+squareNext.attr('style')+'"></div>');
736
					}
737
 
738
					this.children('.'+block_ID_name).css({ width: row_width, height: row_height, 'z-index': 4, top: block_top+'px', left: block_left+'px', opacity: 0, 'background-position': '-'+position_left+'px -'+position_top+'px' }).append('<div style="position: absolute; left: -'+position_left+'px; top: -'+position_top+'px; width: '+attr.width+'px; height: '+attr.height+'px;">'+squareNext.html()+'</div>');
739
 
740
					i_column_numbers++; initial++;
741
 
742
				}
743
 
744
				i_row_numbers++;
745
				i_column_numbers = 1;
746
			}
747
 
748
			var squareArrShuffle = $.shuffle(square_arr);
749
 
750
			//Let's create the block divs
751
			i_row_numbers = 1;
752
			i_column_numbers = 1;
753
			var squareAnimate = 0;		
754
 
755
			while(i_row_numbers <= attr.rows) {
756
 
757
				var initial2 = i_row_numbers;
758
 
759
				//create each column of each row
760
				while(i_column_numbers <= attr.columns) {
761
 
762
					var animated_class = '.block_ID_'+(squareArrShuffle[squareAnimate]);
763
 
764
					delay = (attr.delay * initial2);
765
 
766
					$(animated_class).animate({ width: row_width }, delay).animate({ opacity: 1 }, {duration: attr.duration, easing: attr.ease});
767
 
768
					i_column_numbers++; initial2++; squareAnimate++;
769
 
770
				}
771
 
772
				i_row_numbers++;
773
				i_column_numbers = 1;
774
 
775
			}
776
 
777
			curSel.removeClass('current');
778
			nextSel.addClass('current');
779
 
780
			var delay_total = delay + attr.duration;
781
 
782
			squareNext.animate({ opacity: 0 }, delay_total).animate({ opacity: 0 }, 1, function() {
783
 
784
				$(this).addClass('current').css({ opacity: 1 });
785
 
786
				squareCur.animate({ opacity: 0 }, 200, function() {
787
 
788
					$(this).removeClass('current');
789
 
790
					//removes the transition containers
791
					ddx.children('.slider_block').remove();
792
 
793
					//Enables the selectors
794
					ddx.enableSelectors();
795
 
796
				});
797
 
798
			});
799
 
800
		},
801
 
802
		DDSquareMoving: function(attr, squareNext, squareCur, nextSel, curSel) {
803
 
804
			var ddx = this;
805
 
806
			//lets disable all buttons
807
			this.disableSelectors();
808
 
809
			squareNext.css({ opacity: 1 });
810
 
811
			//set vars
812
			var row_width = Math.round(attr.width / attr.columns);
813
			var row_height = Math.round(attr.height / attr.rows);
814
 
815
			//Let's create the block divs
816
			var i_row_numbers = 1;
817
			var i_column_numbers = 1;
818
 
819
			//create each row
820
			while(i_row_numbers <= attr.rows) {
821
 
822
				var initial = i_row_numbers;
823
				var class_row = 'block_row_'+i_row_numbers;
824
 
825
				//create each column of each row
826
				while(i_column_numbers <= attr.columns) {
827
 
828
					var block_ID_name = 'block_ID_'+((attr.columns * i_row_numbers)-(attr.columns - i_column_numbers));
829
					var class_block = 'slider_block_'+(initial++);
830
					var class_column = 'block_column_'+i_column_numbers;
831
 
832
					var block_top = (i_row_numbers * row_height)+80;
833
					var block_left = (i_column_numbers * row_width)+80;
834
 
835
					var position_left = (row_width * i_column_numbers) - row_width;
836
					var position_top = (row_height * i_row_numbers) - row_height;
837
 
838
					if(squareNext.attr('style') === undefined) {
839
 
840
						this.append('<div class="'+block_ID_name+' slider_block '+class_block+' '+class_row+' '+class_column+'" style="position: absolute; overflow: hidden;"></div>');
841
 
842
					} else {
843
 
844
						this.append('<div class="'+block_ID_name+' slider_block '+class_block+' '+class_row+' '+class_column+'" style="position: absolute; overflow: hidden;'+squareNext.attr('style')+'"></div>');
845
 
846
					}
847
 
848
					this.children('.'+block_ID_name).css({ width: row_width, height: row_height, 'z-index': 4, opacity: 0, top: block_top+'px', left: block_left+'px', 'background-position': '-'+position_left+'px -'+position_top+'px' }).append('<div style="position: absolute; left: -'+position_left+'px; top: -'+position_top+'px; width: '+attr.width+'px; height: '+attr.height+'px;">'+squareNext.html()+'</div>');
849
 
850
					i_column_numbers++; initial++;
851
 
852
				}
853
 
854
				i_row_numbers++;
855
				i_column_numbers = 1;
856
			}
857
 
858
			//Let's create the block divs
859
			i_row_numbers = 1;
860
			i_column_numbers = 1;
861
 
862
 
863
			while(i_row_numbers <= attr.rows) {
864
 
865
				var initial2 = i_row_numbers;
866
 
867
				//create each column of each row
868
				while(i_column_numbers <= attr.columns) {
869
 
870
					var block_ID_name2 = 'block_ID_'+((attr.columns * i_row_numbers)-(attr.columns - i_column_numbers));
871
 
872
					var block_top2 = ((i_row_numbers * row_height) - row_height) + 'px';
873
					var block_left2 = ((i_column_numbers * row_width) - row_width) + 'px';
874
 
875
					delay = (attr.delay * initial2);
876
 
877
					this.children('.'+block_ID_name2).animate({ width: row_width }, delay).animate({ opacity: 1, top: block_top2, left: block_left2 }, {duration: attr.duration, easing: attr.ease});
878
 
879
					i_column_numbers++; initial2++;
880
 
881
				}
882
 
883
				i_row_numbers++;
884
				i_column_numbers = 1;
885
			}
886
 
887
			curSel.removeClass('current');
888
			nextSel.addClass('current');
889
 
890
			//once the animation is finished
891
			var delay_total = delay + attr.duration;
892
			squareNext.animate({ opacity: 0 }, delay_total).animate({ opacity: 0 }, 1, function() {
893
 
894
				$(this).addClass('current').css({ opacity: 1 });
895
 
896
				squareCur.animate({ opacity: 0 }, 200, function() {
897
 
898
					$(this).removeClass('current');
899
 
900
					//removes the transition containers
901
					ddx.children('.slider_block').remove();
902
 
903
					//Enables the selectors
904
					ddx.enableSelectors();
905
 
906
				});
907
 
908
			});
909
 
910
		},
911
 
912
		DDSquareOut: function(attr, squareNext, squareCur, nextSel, curSel) {
913
 
914
			var ddx = this;
915
 
916
			//lets disable all buttons
917
			this.disableSelectors();
918
 
919
			//set vars
920
			var row_width = Math.round(attr.width / attr.columns);
921
			var row_height = Math.round(attr.height / attr.rows);
922
 
923
			//Let's create the block divs
924
			var i_row_numbers = 1;
925
			var i_column_numbers = 1;
926
 
927
			//create each row
928
			while(i_row_numbers <= attr.rows) {
929
 
930
				var initial = i_row_numbers;
931
				var class_row = 'block_row_'+i_row_numbers;
932
 
933
				//create each column of each row
934
				while(i_column_numbers <= attr.columns) {
935
 
936
					var block_ID_name = 'block_ID_'+((attr.columns * i_row_numbers)-(attr.columns - i_column_numbers));
937
					var class_block = 'slider_block_'+(initial++);
938
					var class_column = 'block_column_'+i_column_numbers;
939
 
940
					var block_top = ((i_row_numbers * row_height) - row_height);
941
					var block_left = ((i_column_numbers * row_width) - row_width);
942
 
943
					var position_left = (row_width * i_column_numbers) - row_width;
944
					var position_top = (row_height * i_row_numbers) - row_height;
945
 
946
					if(squareNext.attr('style') === undefined) {
947
 
948
						this.append('<div class="'+block_ID_name+' slider_block '+class_block+' '+class_row+' '+class_column+'" style="position: absolute; overflow: hidden;"></div>');
949
 
950
					} else {
951
 
952
						this.append('<div class="'+block_ID_name+' slider_block '+class_block+' '+class_row+' '+class_column+'" style="position: absolute; overflow: hidden;'+squareCur.attr('style')+'"></div>');
953
 
954
					}
955
 
956
					this.children('.'+block_ID_name).css({ width: row_width, height: row_height, 'z-index': 4, top: block_top+'px', left: block_left+'px', opacity: 1, 'background-position': '-'+position_left+'px -'+position_top+'px' }).append('<div style="position: absolute; left: -'+position_left+'px; top: -'+position_top+'px; width: '+attr.width+'px; height: '+attr.height+'px;">'+squareCur.html()+'</div>');
957
 
958
					i_column_numbers++; initial++;
959
 
960
				}
961
 
962
				i_row_numbers++;
963
				i_column_numbers = 1;
964
			}
965
 
966
			squareNext.addClass('current').css({ opacity: 0 }).animate({ opacity: 1 }, 200);
967
			squareCur.css({ opacity: 0 });
968
 
969
			//Let's create the block divs
970
			i_row_numbers = 1;
971
			i_column_numbers = 1;
972
 
973
 
974
 
975
 
976
			while(i_row_numbers <= attr.rows) {
977
 
978
				var initial2 = i_row_numbers;
979
 
980
 
981
				//create each column of each row
982
				while(i_column_numbers <= attr.columns) {
983
 
984
					var block_ID_name2 = 'block_ID_'+((attr.columns * i_row_numbers)-(attr.columns - i_column_numbers));
985
 
986
					delay = (attr.delay * initial2)*3;
987
 
988
					var position_left2 = (((row_width * i_column_numbers) - row_width)+80)+'px';
989
					var position_top2 = (((row_height * i_row_numbers) - row_height)+80)+'px';
990
 
991
					this.children('.'+block_ID_name2).animate({ width: row_width }, delay).animate({ left: position_left2, top: position_top2, opacity: 0 }, {duration: attr.duration, easing: attr.ease});
992
 
993
					i_column_numbers++; initial2++;
994
 
995
 
996
				}
997
 
998
				i_row_numbers++;
999
				i_column_numbers = 1;
1000
			}
1001
 
1002
			curSel.removeClass('current');
1003
			nextSel.addClass('current');
1004
 
1005
			var delay_total = (delay + attr.duration);
1006
 
1007
			squareNext.animate({ opacity: 1 }, delay_total).animate({ opacity: 0 }, 1, function() {
1008
 
1009
				$(this).addClass('current').css({ opacity: 1 });
1010
				squareCur.removeClass('current').css({ opacity: 1 });
1011
				ddx.children('.slider_block').remove();
1012
 
1013
				//enables all selectors
1014
				ddx.enableSelectors();
1015
 
1016
			});
1017
 
1018
		},
1019
 
1020
		DDSquareOutMoving: function(attr, squareNext, squareCur, nextSel, curSel) {
1021
 
1022
			var ddx = this;
1023
 
1024
			//lets disable all buttons
1025
			this.disableSelectors();
1026
 
1027
			//set vars
1028
			var row_width = Math.round(attr.width / attr.columns);
1029
			var row_height = Math.round(attr.height / attr.rows);
1030
 
1031
			//Let's create the block divs
1032
			var i_row_numbers = 1;
1033
			var i_column_numbers = 1;
1034
 
1035
			//create each row
1036
			while(i_row_numbers <= attr.rows) {
1037
 
1038
				var initial = i_row_numbers;
1039
				var class_row = 'block_row_'+i_row_numbers;
1040
 
1041
				//create each column of each row
1042
				while(i_column_numbers <= attr.columns) {
1043
 
1044
					var block_ID_name = 'block_ID_'+((attr.columns * i_row_numbers)-(attr.columns - i_column_numbers));
1045
					var class_block = 'slider_block_'+(initial++);
1046
					var class_column = 'block_column_'+i_column_numbers;
1047
 
1048
					var block_top = ((i_row_numbers * row_height) - row_height);
1049
					var block_left = ((i_column_numbers * row_width) - row_width);
1050
 
1051
					var position_left = (row_width * i_column_numbers) - row_width;
1052
					var position_top = (row_height * i_row_numbers) - row_height;
1053
 
1054
					if(squareNext.attr('style') === undefined) {
1055
 
1056
						this.append('<div class="'+block_ID_name+' slider_block '+class_block+' '+class_row+' '+class_column+'" style="position: absolute; overflow: hidden;"></div>');
1057
 
1058
					} else {
1059
 
1060
						this.append('<div class="'+block_ID_name+' slider_block '+class_block+' '+class_row+' '+class_column+'" style="position: absolute; overflow: hidden;'+squareCur.attr('style')+'"></div>');
1061
 
1062
					}
1063
 
1064
					this.children('.'+block_ID_name).css({ width: row_width, height: row_height, 'z-index': 4, top: block_top+'px', left: block_left+'px', opacity: 1, 'background-position': '-'+position_left+'px -'+position_top+'px' }).append('<div style="position: absolute; left: -'+position_left+'px; top: -'+position_top+'px; width: '+attr.width+'px; height: '+attr.height+'px;">'+squareCur.html()+'</div>');
1065
 
1066
					i_column_numbers++; initial++;
1067
 
1068
				}
1069
 
1070
				i_row_numbers++;
1071
				i_column_numbers = 1;
1072
			}
1073
 
1074
			squareNext.addClass('current').css({ opacity: 0 }).animate({ opacity: 1 }, 200);
1075
			squareCur.css({ opacity: 0 });
1076
 
1077
			//Let's create the block divs
1078
			i_row_numbers = 1;
1079
			i_column_numbers = 1;
1080
 
1081
 
1082
 
1083
 
1084
			while(i_row_numbers <= attr.rows) {
1085
 
1086
				var initial2 = i_row_numbers;
1087
 
1088
				//create each column of each row
1089
				while(i_column_numbers <= attr.columns) {
1090
 
1091
					var block_ID_name2 = 'block_ID_'+((attr.columns * i_row_numbers)-(attr.columns - i_column_numbers));
1092
 
1093
					delay = (attr.delay * initial2)*2;
1094
 
1095
					var position_left2 = (((row_width * i_column_numbers) - row_width)-80)+'px';
1096
					var position_top2 = (((row_height * i_row_numbers) - row_height)-80)+'px';
1097
 
1098
					this.children('.'+block_ID_name2).animate({ width: row_width }, delay).animate({ left: position_left2, top: position_top2, opacity: 0 }, {duration: attr.duration, easing: attr.ease});
1099
 
1100
					i_column_numbers++; initial2++;
1101
 
1102
 
1103
				}
1104
 
1105
				i_row_numbers++;
1106
				i_column_numbers = 1;
1107
			}
1108
 
1109
			curSel.removeClass('current');
1110
			nextSel.addClass('current');
1111
 
1112
			var delay_total = (delay + attr.duration);
1113
 
1114
			squareNext.animate({ opacity: 1 }, delay_total).animate({ opacity: 0 }, 1, function() {
1115
 
1116
				$(this).addClass('current').css({ opacity: 1 });
1117
				squareCur.removeClass('current').css({ opacity: 1 });
1118
				ddx.children('.slider_block').remove();
1119
 
1120
				//enables all selectors
1121
				ddx.enableSelectors();
1122
 
1123
			});
1124
 
1125
		},
1126
 
1127
		DDRowInterlaced: function(attr, squareNext, squareCur, nextSel, curSel) {
1128
 
1129
			var ddx = this;
1130
 
1131
			//lets disable all buttons
1132
			this.disableSelectors();
1133
 
1134
			squareNext.css({ opacity: 1 });
1135
 
1136
			//set vars
1137
			var row_width = attr.width;
1138
			var row_height = Math.round(attr.height / attr.rows);
1139
 
1140
			//Let's create the block divs
1141
			var i_row_numbers = 1;
1142
 
1143
			var initial = 1;
1144
 
1145
			//create each row
1146
			while(i_row_numbers <= attr.rows) {
1147
 
1148
				var class_row = 'block_row_'+i_row_numbers;
1149
 
1150
				var block_ID_name = 'block_ID_'+initial;
1151
 
1152
				var position_top = (row_height * i_row_numbers) - row_height;
1153
				var position_left = attr.width+'px';
1154
				var block_top = ((i_row_numbers * row_height) - row_height);
1155
 
1156
				if(squareNext.attr('style') === undefined) {
1157
 
1158
					this.append('<div class="slider_row '+block_ID_name+' '+class_row+'" style="position: absolute; overflow: hidden;"></div>');
1159
 
1160
				} else {
1161
 
1162
					this.append('<div class="'+block_ID_name+' slider_row '+class_row+'" style="position: absolute; overflow: hidden;'+squareNext.attr('style')+'"></div>');
1163
 
1164
				}
1165
 
1166
				this.children('.'+block_ID_name).css({ width: row_width, height: row_height, 'z-index': 4, top:block_top+'px', opacity: 0, 'background-position': '0 -'+position_top+'px', left: position_left }).append('<div style="position: absolute; top: -'+position_top+'px; width: '+attr.width+'px; height: '+attr.height+'px;">'+squareNext.html()+'</div>');
1167
 
1168
				initial++; i_row_numbers++;
1169
			}
1170
 
1171
			var interLeft = '-'+attr.width+'px';
1172
			this.children('.slider_row:even').css({ left: interLeft });
1173
 
1174
			//Let's reset the block divs
1175
			i_row_numbers = 1;
1176
			var initial2 = 1;
1177
 
1178
 
1179
			while(i_row_numbers <= attr.rows) {
1180
 
1181
				var animated_class = '.block_ID_'+initial2;
1182
 
1183
				delay = (attr.delay * initial2);
1184
 
1185
				$(animated_class).animate({ opacity: 0 }, delay).animate({ left: 0, opacity: 1 }, {duration: attr.duration, easing: attr.ease});
1186
 
1187
				i_row_numbers++; initial2++;
1188
			}
1189
 
1190
			curSel.removeClass('current');
1191
			nextSel.addClass('current');
1192
 
1193
			var delay_total = (delay + attr.duration);
1194
 
1195
			squareNext.animate({ opacity: 0 }, delay_total).animate({ opacity: 0 }, 1, function() {
1196
 
1197
				$(this).addClass('current').css({ opacity: 1 });
1198
 
1199
				squareCur.animate({ opacity: 0 }, 200, function() {
1200
 
1201
					$(this).removeClass('current');
1202
 
1203
					//removes the transition containers
1204
					ddx.children('.slider_row').remove();
1205
 
1206
					//Enables the selectors
1207
					ddx.enableSelectors();
1208
 
1209
				});
1210
 
1211
			});
1212
 
1213
		},
1214
 
1215
		disableSelectors: function() {
1216
 
1217
			isPlaying = true;
1218
 
1219
		},
1220
 
1221
		enableSelectors: function() {
1222
 
1223
			isPlaying = false;
1224
 
1225
		}
1226
 
1227
    });
1228
 
1229
	$.fn.shuffle = function() {
1230
		return this.each(function(){
1231
			var items = $(this).children();
1232
			return (items.length) ? $(this).html($.shuffle(items)) : this;
1233
		});
1234
	};
1235
 
1236
	$.shuffle = function(arr) {
1237
		for(var j, x, i = arr.length; i; j = parseInt(Math.random() * i, 10), x = arr[--i], arr[i] = arr[j], arr[j] = x) {  }
1238
		return arr;
1239
	};
1240
 
1241
})(jQuery);