ultimix

- Main Page
- Data Structures
- Files
- Examples

- File List
- Globals

dialogs.js
Go to the documentation of this file.
1
6 if( !ultimix )
7 {
8 ultimix = {};
9 }
10
16 if( !ultimix.std_dialogs )
17 {
18 ultimix.std_dialogs = {};
19 }
20
26 ultimix.std_dialogs.MB_ABORT = 1;
27 ultimix.std_dialogs.MB_RETRY = 2;
28 ultimix.std_dialogs.MB_IGNORE = 4;
29 ultimix.std_dialogs.MB_ABORTRETRYIGNORE = 7;
30 ultimix.std_dialogs.MB_CANCEL = 8;
31 ultimix.std_dialogs.MB_TRY = 16;
32 ultimix.std_dialogs.MB_CONTINUE = 32;
33 ultimix.std_dialogs.MB_CANCELTRYCONTINUE = 56;
34 ultimix.std_dialogs.MB_HELP = 64;
35 ultimix.std_dialogs.MB_OK = 128;
36 ultimix.std_dialogs.MB_OKCANCEL = 136;
37 ultimix.std_dialogs.MB_RETRYCANCEL = 10;
38 ultimix.std_dialogs.MB_YES = 256;
39 ultimix.std_dialogs.MB_NO = 512;
40 ultimix.std_dialogs.MB_YESNO = 768;
41 ultimix.std_dialogs.MB_YESNOCANCEL = 776;
42
48 ultimix.std_dialogs.MB_ICONEXCLAMATION = 2048;
49 ultimix.std_dialogs.MB_ICONWARNING = 4096;
50 ultimix.std_dialogs.MB_ICONINFORMATION = 8192;
51 ultimix.std_dialogs.MB_ICONASTERISK = 16384;
52 ultimix.std_dialogs.MB_ICONQUESTION = 32768;
53 ultimix.std_dialogs.MB_ICONSTOP = 65536;
54 ultimix.std_dialogs.MB_ICONERROR = 131072;
55 ultimix.std_dialogs.MB_ICONHAND = 262144;
56 ultimix.std_dialogs.MB_ICONLOADING = 524288;
57 ultimix.std_dialogs.MB_ICONWAIT = 524288;
58 ultimix.std_dialogs.MB_MODAL = 1048576;
59
60 ultimix.std_dialogs.MessageBoxCounter = 0;
61
69 ultimix.std_dialogs.close_message_box = function( Selector )
70 {
71 jQuery( Selector ).dialog( "close" );
72 jQuery( Selector ).remove();
73 }
74
84 ultimix.std_dialogs.get_class_name = function( Style )
85 {
86 var Class = 'jsdialogs-default';
87 if( Style & ultimix.std_dialogs.MB_ICONEXCLAMATION ) Class = 'jsdialogs-exclamation';
88 if( Style & ultimix.std_dialogs.MB_ICONWARNING ) Class = 'jsdialogs-warning';
89 if( Style & ultimix.std_dialogs.MB_ICONINFORMATION ) Class = 'jsdialogs-information';
90 if( Style & ultimix.std_dialogs.MB_ICONASTERISK ) Class = 'jsdialogs-asterisk';
91 if( Style & ultimix.std_dialogs.MB_ICONQUESTION ) Class = 'jsdialogs-question';
92 if( Style & ultimix.std_dialogs.MB_ICONSTOP ) Class = 'jsdialogs-stop';
93 if( Style & ultimix.std_dialogs.MB_ICONERROR ) Class = 'jsdialogs-error';
94 if( Style & ultimix.std_dialogs.MB_ICONHAND ) Class = 'jsdialogs-hand';
95 if( Style & ultimix.std_dialogs.MB_ICONLOADING ) Class = 'jsdialogs-loading';
96 return( Class );
97 }
98
112 ultimix.std_dialogs.get_handler = function( ButtonCode , AcceptResult , id )
113 {
114 return(
115 function()
116 {
117 if( AcceptResult )
118 {
119 AcceptResult( ButtonCode );
120 }
121 ultimix.std_dialogs.close_message_box( "#" + id );
122 }
123 );
124 }
125
145 ultimix.std_dialogs.add_button = function( Style , Buttons , Name , ButtonCode , AcceptResult , id )
146 {
147 if( Style & ButtonCode )
148 {
149 Buttons[ ultimix.get_string( Name ) ] = ultimix.std_dialogs.get_handler( ButtonCode, AcceptResult , id );
150 }
151
152 return( Buttons );
153 }
154
168 ultimix.std_dialogs.get_buttons = function( Style , AcceptResult , id )
169 {
170 var Buttons = {};
171 var Titles = [
172 'Abort' , 'Retry' , 'Ignore' , 'No' , 'Try' , 'Yes' , 'Cancel' , 'OK' , 'Help' , 'Continue'
173 ];
174 var Codes = [
175 ultimix.std_dialogs.MB_ABORT , ultimix.std_dialogs.MB_RETRY , ultimix.std_dialogs.MB_IGNORE ,
176 ultimix.std_dialogs.MB_NO , ultimix.std_dialogs.MB_TRY , ultimix.std_dialogs.MB_YES ,
177 ultimix.std_dialogs.MB_CANCEL , ultimix.std_dialogs.MB_OK , ultimix.std_dialogs.MB_HELP ,
178 ultimix.std_dialogs.MB_CONTINUE
179 ];
180
181 for( var i = 0 ; i < Titles.length ; i++ )
182 {
183 Buttons = ultimix.std_dialogs.add_button( Style , Buttons , Titles[ i ] , Codes[ i ] , AcceptResult , id );
184 }
185
186 return( Buttons );
187 }
188
202 ultimix.std_dialogs.message_box_create = function( id , DialogData , Class , Text )
203 {
204 jQuery( "#" + id ).dialog( DialogData );
205 jQuery( "#" + id ).html(
206 '<div class="ultimix-MessageBox-content"><div class="' + Class + '"></div>' +
207 ultimix.get_string( Text ) + '</div>'
208 );
209 jQuery( "#" + id ).parent().find( '.ui-dialog-titlebar-close' ).remove();
210 }
211
221 ultimix.std_dialogs.get_caption = function( Caption )
222 {
223 if( !Caption )
224 {
225 Caption = 'MessageBox';
226 }
227
228 return( Caption );
229 }
230
240 ultimix.std_dialogs.get_style = function( Style )
241 {
242 if( !Style )
243 {
244 Style = ultimix.std_dialogs.MB_OK;
245 }
246
247 return( Style );
248 }
249
259 ultimix.std_dialogs.get_modal = function( Style )
260 {
261 var Modal = false;
262
263 if( Style & ultimix.std_dialogs.MB_MODAL )
264 {
265 Modal = true;
266 }
267
268 return( Modal );
269 }
270
278 ultimix.std_dialogs.add_span_div_if_necessary = function( id )
279 {
280 if( !jQuery( "#" + id ).length )
281 {
282 jQuery( "body" ).append( '<span id="' + id + '" style="display:none"></span>' );
283 }
284 }
285
301 ultimix.std_dialogs.MessageBox = function( Text , Caption , Style , AcceptResult )
302 {
303 Caption = ultimix.std_dialogs.get_caption( Caption );
304 Style = ultimix.std_dialogs.get_style( Style );
305 var Class = ultimix.std_dialogs.get_class_name( Style );
306 var id = "ultimix-MessageBox-span-" + ultimix.std_dialogs.MessageBoxCounter++;
307 var Modal = ultimix.std_dialogs.get_modal( Style )
308 ultimix.std_dialogs.add_span_div_if_necessary( id );
309
310 var ExitOnEscape = true;
311 if( Style & ultimix.std_dialogs.MB_ICONLOADING )
312 {
313 ExitOnEscape = false;
314 }
315
316 var Buttons = ultimix.std_dialogs.get_buttons( Style , AcceptResult , id );
317 var DialogData = {
318 width: 480 , modal : Modal , title : ultimix.get_string( Caption ) , buttons : Buttons ,
319 resizable : false , closeOnEscape : ExitOnEscape
320 }
321
322 ultimix.std_dialogs.message_box_create( id , DialogData , Class , Text );
323
324 return( "#" + id );
325 }
326
334 ultimix.std_dialogs.SimpleWaitingMessageBox = function()
335 {
336 return(
337 ultimix.std_dialogs.MessageBox(
338 ultimix.get_string( 'wait_please' ) , ultimix.get_string( 'Info' ) ,
339 ultimix.std_dialogs.MB_ICONLOADING | ultimix.std_dialogs.MB_MODAL
340 )
341 );
342 }
343
355 ultimix.std_dialogs.WaitingMessageBox = function( Text , Caption )
356 {
357 return(
358 ultimix.std_dialogs.MessageBox(
359 ultimix.get_string( Text ) , ultimix.get_string( Caption ) ,
360 ultimix.std_dialogs.MB_ICONLOADING | ultimix.std_dialogs.MB_MODAL
361 )
362 );
363 }
364
374 ultimix.std_dialogs.ErrorMessageBox = function( Text )
375 {
376 return(
377 ultimix.std_dialogs.MessageBox(
378 ultimix.get_string( Text ) , ultimix.get_string( 'Error' ) ,
379 ultimix.std_dialogs.MB_OK | ultimix.std_dialogs.MB_ICONERROR | ultimix.std_dialogs.MB_MODAL
380 )
381 );
382 }
383
395 ultimix.std_dialogs.QuestionMessageBox = function( Text , Success )
396 {
397 return(
398 ultimix.std_dialogs.MessageBox(
399 ultimix.get_string( Text ) , ultimix.get_string( 'Question' ) ,
400 ultimix.std_dialogs.MB_YESNO | ultimix.std_dialogs.MB_ICONQUESTION | ultimix.std_dialogs.MB_MODAL , Success
401 )
402 );
403 }
404
414 ultimix.std_dialogs.InfoMessageBox = function( Text )
415 {
416 return(
417 ultimix.std_dialogs.MessageBox(
418 ultimix.get_string( Text ) , ultimix.get_string( 'Info' ) ,
419 ultimix.std_dialogs.MB_OK | ultimix.std_dialogs.MB_ICONINFORMATION | ultimix.std_dialogs.MB_MODAL
420 )
421 );
422 }
423
431 ultimix.std_dialogs.loading_block = function()
432 {
433 return(
434 '<div class="jsdialogs-loading" style="float: none; margin-right : 0px;"></div>'
435 );
436 }
437
445 ultimix.std_dialogs.loading_img_widget = function()
446 {
447 var LoadingBlock = ultimix.std_dialogs.loading_block();
448
449 var VAlginBlock = ultimix.string_utilities.valign_block( LoadingBlock );
450
451 return( ultimix.string_utilities.halign_block( VAlginBlock , 32 ) );
452 }
453
467 ultimix.std_dialogs.construct_common_dialog = function( id , Caption , Buttons )
468 {
469 var DialogData = {
470 width: 'auto' , modal : true , title : ultimix.get_string( Caption ) , buttons : Buttons ,
471 resizable : false , closeOnEscape : true
472 }
473
474 jQuery( "#" + id ).dialog( DialogData );
475
476 return( "#" + id );
477 }
478
492 ultimix.std_dialogs.common_ok_button = function( id , OkProcessor , AfterOkProcessor )
493 {
494 return(
495 function()
496 {
497 if( OkProcessor == false || OkProcessor( "#" + id ) )
498 {
499 var Data = jQuery( "#" + id ).find( 'textarea' ).val();
500
501 jQuery( "#" + id ).dialog( "close" );
502 jQuery( "#" + id ).remove();
503
504 if( AfterOkProcessor )
505 {
506 AfterOkProcessor( Data );
507 }
508 }
509 }
510 );
511 }
512
528 ultimix.std_dialogs.dialog_buttons = function( id , OkProcessor , AfterOkProcessor , CancelProcessor )
529 {
530 var Buttons = {};
531
532 if( CancelProcessor == 'no button' )
533 {
534 /* no button*/
535 }
536 else
537 {
538 Buttons[ ultimix.get_string( 'Cancel' ) ] = function()
539 {
540 jQuery( "#" + id ).dialog( "close" );
541 jQuery( "#" + id ).remove();
542 }
543 }
544
545 Buttons[ ultimix.get_string( 'OK' ) ] = ultimix.std_dialogs.common_ok_button( id , OkProcessor , AfterOkProcessor );
546
547 return( Buttons );
548 }
549
557 ultimix.std_dialogs.add_textarea_div_if_necessary = function( id )
558 {
559 if( !jQuery( "#" + id ).length )
560 {
561 jQuery( "body" ).append(
562 '<span id="' + id + '" style="display:none">' +
563 '<textarea style="width: 480px; height: 360px; margin: 10px;" class="flat"></textarea></span>'
564 );
565 }
566 }
567
575 ultimix.std_dialogs.add_input_div_if_necessary = function( id )
576 {
577 if( !jQuery( "#" + id ).length )
578 {
579 jQuery( "body" ).append(
580 '<span id="' + id + '" style="display:none"><input class="width_480 flat" style="margin: 10px;"></span>'
581 );
582 }
583 }
584
600 ultimix.std_dialogs.textarea_dialog = function( Caption , OkProcessor , AfterOkProcessor , CancelProcessor )
601 {
602 var id = "ultimix-MessageBox-span-" + ultimix.std_dialogs.MessageBoxCounter++;
603
604 var Buttons = ultimix.std_dialogs.dialog_buttons(
605 id , OkProcessor , AfterOkProcessor , CancelProcessor
606 );
607
608 ultimix.std_dialogs.add_textarea_div_if_necessary( id );
609
610 return( ultimix.std_dialogs.construct_common_dialog( id , Caption , Buttons ) );
611 }
612
628 ultimix.std_dialogs.input_dialog = function( Caption , OkProcessor , AfterOkProcessor , CancelProcessor )
629 {
630 var id = "ultimix-MessageBox-span-" + ultimix.std_dialogs.MessageBoxCounter++;
631
632 var Buttons = ultimix.std_dialogs.dialog_buttons(
633 id , OkProcessor , AfterOkProcessor , CancelProcessor
634 );
635
636 ultimix.std_dialogs.add_input_div_if_necessary( id );
637
638 return( ultimix.std_dialogs.construct_common_dialog( id , Caption , Buttons ) );
639 }