ultimix

- Main Page
- Data Structures
- Files
- Examples

- File List
- Globals

iterator.js
Go to the documentation of this file.
1
6 if( !ultimix )
7 {
8 ultimix = {};
9 }
10
16 if( !ultimix.iterator )
17 {
18 ultimix.iterator = {};
19 }
20
32 ultimix.iterator = function( IteratingElements , BeforeNext , EndIteration )
33 {
34 this.current_position = 0;
35 this.elements = IteratingElements;
36 this.before_next = BeforeNext;
37 this.end_iteration = EndIteration;
38
39 return( this );
40 }
41
47 ultimix.iterator.prototype.next = function()
48 {
49 if( jQuery( this.elements ).eq( this.current_position ).length )
50 {
51 this.before_next();
52 this.current_position++;
53 }
54 else
55 {
56 this.end_iteration();
57 }
58 }
59
67 ultimix.iterator.prototype.current_element = function()
68 {
69 if( jQuery( this.elements ).eq( this.current_position ).length )
70 {
71 return( jQuery( this.elements ).eq( this.current_position ) );
72 }
73
74 return( false );
75 }
76
84 ultimix.iterator.prototype.prev_element = function()
85 {
86 if( this.current_position - 1 >= 0 && jQuery( this.elements ).eq( this.current_position - 1 ).length )
87 {
88 return( jQuery( this.elements ).eq( this.current_position - 1 ) );
89 }
90
91 return( false );
92 }