@@ -101,22 +101,39 @@ BaseDialog.prototype = new function()
101101/**
102102 * @constructor
103103 */
104- function ConfirmDialog ( template , ok_callback , cancel_callback , ok_label , cancel_label ) {
105- this . _init ( template , ok_callback , cancel_callback , ok_label , cancel_label ) ;
104+ function ConfirmDialog ( template , ok_callback_or_callback_list , cancel_callback_or_type , type ) {
105+ this . _init ( template , ok_callback_or_callback_list , cancel_callback_or_type , type ) ;
106106} ;
107107
108108function ConfirmDialogPrototype ( )
109109{
110- this . _init = function ( template , ok_callback , cancel_callback , ok_label , cancel_label )
110+ this . _init = function ( template , ok_callback_or_callback_list , cancel_callback_or_type , type )
111111 {
112+ var ACCEPT = 0 ;
113+ var REJECT = 1 ;
114+ var accept_cb = ok_callback_or_callback_list ;
115+ var reject_cb = cancel_callback_or_type ;
116+ if ( Array . isArray ( ok_callback_or_callback_list ) )
117+ {
118+ accept_cb = ok_callback_or_callback_list [ 0 ] ;
119+ reject_cb = ok_callback_or_callback_list [ 1 ] ;
120+ type = cancel_callback_or_type ;
121+ }
122+
123+ if ( ! type )
124+ type = ConfirmDialog . OK_CANCEL ;
125+
126+ if ( ! ConfirmDialog . labels [ type ] )
127+ throw "Not a valid type in ConfirmDialog" ;
128+
112129 var buttons = [
113130 {
114- label : ok_label || ui_strings . S_BUTTON_OK ,
115- handler : ok_callback ,
131+ label : ConfirmDialog . labels [ type ] [ ACCEPT ] ,
132+ handler : accept_cb ,
116133 } ,
117134 {
118- label : cancel_label || ui_strings . S_BUTTON_CANCEL ,
119- handler : cancel_callback ,
135+ label : ConfirmDialog . labels [ type ] [ REJECT ] ,
136+ handler : reject_cb ,
120137 }
121138 ] ;
122139 BaseDialog . prototype . _init . call ( this , template , buttons ) ;
@@ -125,6 +142,11 @@ function ConfirmDialogPrototype()
125142
126143ConfirmDialogPrototype . prototype = new BaseDialog ( ) ;
127144ConfirmDialog . prototype = new ConfirmDialogPrototype ( ) ;
145+ ConfirmDialog . YES_NO = 1 ;
146+ ConfirmDialog . OK_CANCEL = 2 ;
147+ ConfirmDialog . labels = { } ;
148+ ConfirmDialog . labels [ ConfirmDialog . YES_NO ] = [ ui_strings . S_BUTTON_YES , ui_strings . S_BUTTON_NO ] ;
149+ ConfirmDialog . labels [ ConfirmDialog . OK_CANCEL ] = [ ui_strings . S_BUTTON_OK , ui_strings . S_BUTTON_CANCEL ] ;
128150
129151/**
130152 * @constructor
0 commit comments