ultimix

- Main Page
- Data Structures
- Files
- Examples

- File List
- Globals

wizard.js
Go to the documentation of this file.
1
6 if( !ultimix )
7 {
8 ultimix = {};
9 }
10
16 if( !ultimix.wizard )
17 {
18 ultimix.wizard = {};
19 }
20
26 ultimix.wizard.Steps = new Array();
27
33 ultimix.wizard.CurrentStep = -1;
34
46 ultimix.wizard._CreateWizardDialogs = function( RawSteps , SuccessFunction , DialogOptions )
47 {
48 ultimix.wizard.Steps = RawSteps;
49
50 DialogOptions = jQuery.extend(
51 {
52 width : 640 ,
53 height : 480 ,
54 modal : true ,
55 autoOpen : true ,
56 resizable : false ,
57 closeOnEscape : false ,
58 title : ''
59 } ,
60 DialogOptions
61 );
62 DialogOptions.autoOpen = false;
63 if( DialogOptions.title )
64 {
65 DialogOptions.title = ultimix.get_string( DialogOptions.title );
66 }
67
68 for( var i = 0 ; i < ultimix.wizard.Steps.length ; i++ )
69 {
70 var Buttons = new Array();
71 var CurrentSelector = ultimix.wizard.Steps[ i ].selector;
72
73 if( i + 1 < ultimix.wizard.Steps.length )
74 {
75 var CreateNextButton = function( i , CurrentSelector )
76 {
77 return(
78 function()
79 {
80 jQuery( CurrentSelector ).dialog( 'close' );
81 jQuery( ultimix.wizard.Steps[ i + 1 ].selector ).dialog( 'open' );
82 jQuery( ultimix.wizard.Steps[ i + 1 ].selector ).dialog(
83 'option' , 'title' , DialogOptions.title + ' ' + ultimix.get_string( 'step' ) + ' ' +
84 ( i + 2 ) + ' ' + ultimix.get_string( 'of' ) + ' ' + ultimix.wizard.Steps.length
85 );
86 }
87 );
88 }
89 Buttons[ ultimix.get_string( 'Next' ) ] = CreateNextButton( i , CurrentSelector );
90 }
91
92 if( i + 1 == ultimix.wizard.Steps.length )
93 {
94 var CreateFinishButton = function( i , CurrentSelector )
95 {
96 return(
97 function()
98 {
99 SuccessFunction();
100 jQuery( CurrentSelector ).dialog( 'close' );
101 }
102 );
103 }
104 Buttons[ ultimix.get_string( 'Finish' ) ] = CreateFinishButton( i , CurrentSelector );
105 }
106
107 if( i > 0 )
108 {
109 var CreateBackButton = function( i , CurrentSelector )
110 {
111 return(
112 function()
113 {
114 jQuery( CurrentSelector ).dialog( 'close' );
115 jQuery( ultimix.wizard.Steps[ i - 1 ].selector ).dialog( 'open' );
116 jQuery( ultimix.wizard.Steps[ i - 1 ].selector ).dialog(
117 'option' , 'title' , DialogOptions.title + ' ' + ultimix.get_string( 'step' ) + ' ' + i +
118 ' ' + ultimix.get_string( 'of' ) + ' ' + ultimix.wizard.Steps.length
119 );
120 }
121 );
122 }
123 Buttons[ ultimix.get_string( 'Back' ) ] = CreateBackButton( i , CurrentSelector );
124 }
125
126 var CreateCancelButton = function( CurrentSelector )
127 {
128 return(
129 function()
130 {
131 jQuery( CurrentSelector ).dialog( 'close' );
132 }
133 );
134 };
135 Buttons[ ultimix.get_string( 'Cancel' ) ] = CreateCancelButton( CurrentSelector );
136
137 DialogOptions.buttons = Buttons;
138
139 jQuery( ultimix.wizard.Steps[ i ].selector ).dialog( DialogOptions );
140 }
141 }
142
154 ultimix.wizard.Wizard = function( RawSteps , SuccessFunction , DialogOptions )
155 {
156 ultimix.wizard.CurrentStep = -1;
157
158 ultimix.wizard._CreateWizardDialogs( RawSteps , SuccessFunction , DialogOptions );
159
160 jQuery( ultimix.wizard.Steps[ 0 ].selector ).dialog( 'open' );
161
162 jQuery( ultimix.wizard.Steps[ 0 ].selector ).dialog(
163 'option' , 'title' , DialogOptions.title + ' ' + ultimix.get_string( 'step' ) + ' ' + 1 + ' ' +
164 ultimix.get_string( 'of' ) + ' ' + ultimix.wizard.Steps.length
165 );
166 }