1// Name: ConfirmButton.confirmButtonBehavior.debug.js 2// Assembly: AjaxControlToolkit 3// Version: 4.1.7.1213 4// FileVersion: 4.1.7.1213 5// (c) 2010 CodePlex Foundation 6 7 8 9/// <reference name="MicrosoftAjax.debug.js" /> 10/// <reference path="../ExtenderBase/BaseScripts.js" /> 11 12(function() { 13var scriptName = "ExtendedConfirmButton"; 14 15function execute() { 16 17Type.registerNamespace('Sys.Extended.UI'); 18 19Sys.Extended.UI.ConfirmButtonHiddenEventArgs = function(confirmed) { 20 /// <summary> 21 /// Event arguments used when the hidden event is raised 22 /// </summary> 23 /// <param name="confirmed" type="Boolean" mayBeNull="false"> 24 /// Whether or not the user confirmed the prompt 25 /// </param> 26 Sys.Extended.UI.ConfirmButtonHiddenEventArgs.initializeBase(this); 27 28 this._confirmed = confirmed; 29} 30Sys.Extended.UI.ConfirmButtonHiddenEventArgs.prototype = { 31 get_confirmed : function() { 32 /// <value type="Boolean" mayBeNull="false"> 33 /// Whether or not the user confirmed the prompt 34 /// </value> 35 return this._confirmed; 36 } 37} 38Sys.Extended.UI.ConfirmButtonHiddenEventArgs.registerClass('Sys.Extended.UI.ConfirmButtonHiddenEventArgs', Sys.EventArgs); 39 40 41Sys.Extended.UI.ConfirmButtonBehavior = function(element) { 42 /// <summary> 43 /// The ConfirmButtonBehavior extends buttons by providing a confirmation dialog when clicked 44 /// </summary> 45 /// <param name="element" type="Sys.UI.DomElement" domElement="true"> 46 /// Button the behavior is associated with 47 /// </param> 48 Sys.Extended.UI.ConfirmButtonBehavior.initializeBase(this, [element]); 49 50 this._ConfirmTextValue = null; 51 52 this._OnClientCancelValue = null; 53 54 this._ConfirmOnFormSubmit = false; 55 56 this._displayModalPopupID = null; 57 58 this._postBackScript = null; 59 60 this._clickHandler = null; 61 62 this._oldScript = null; 63} 64Sys.Extended.UI.ConfirmButtonBehavior.prototype = { 65 initialize : function() { 66 /// <summary> 67 /// Initialize the behavior 68 /// </summary> 69 Sys.Extended.UI.ConfirmButtonBehavior.callBaseMethod(this, 'initialize'); 70 var element = this.get_element(); 71 72 this._clickHandler = Function.createDelegate(this, this._onClick); 73 $addHandler(element, "click", this._clickHandler); 74 75 this._oldScript = element.getAttribute("onclick"); 76 if (this._oldScript) { 77 element.setAttribute("onclick", null); 78 } 79 80 if (this._ConfirmOnFormSubmit && (typeof(WebForm_OnSubmit) == 'function') && !Sys.Extended.UI.ConfirmButtonBehavior._originalWebForm_OnSubmit) { 81 if (Sys.Extended.UI.TextBoxWatermarkBehavior && Sys.Extended.UI.TextBoxWatermarkBehavior._originalWebForm_OnSubmit) { 82 Sys.Extended.UI.ConfirmButtonBehavior._originalWebForm_OnSubmit = Sys.Extended.UI.TextBoxWatermarkBehavior._originalWebForm_OnSubmit; 83 Sys.Extended.UI.TextBoxWatermarkBehavior._originalWebForm_OnSubmit = Sys.Extended.UI.ConfirmButtonBehavior.WebForm_OnSubmit; 84 } else { 85 Sys.Extended.UI.ConfirmButtonBehavior._originalWebForm_OnSubmit = WebForm_OnSubmit; 86 WebForm_OnSubmit = Sys.Extended.UI.ConfirmButtonBehavior.WebForm_OnSubmit; 87 } 88 } 89 }, 90 91 dispose : function() { 92 /// <summary> 93 /// Dispose the behavior 94 /// </summary> 95 96 if (this._clickHandler) { 97 $removeHandler(this.get_element(), "click", this._clickHandler); 98 this._clickHandler = null; 99 } 100 101 if (this._oldScript) { 102 this.get_element().setAttribute("onclick", this._oldScript); 103 this._oldScript = null; 104 } 105 106 Sys.Extended.UI.ConfirmButtonBehavior.callBaseMethod(this, 'dispose'); 107 }, 108 109 _onClick : function(e) { 110 /// <summary> 111 /// Button's click handler to display the confirmation dialog 112 /// </summary> 113 /// <param name="e" type="Sys.UI.DomEvent"> 114 /// Event info 115 /// </param> 116
117 if (this.get_element() && !this.get_element().disabled) { 118 if (this._ConfirmOnFormSubmit) { 119 Sys.Extended.UI.ConfirmButtonBehavior._clickedBehavior = this; 120 } else { 121 if (!this._displayConfirmDialog()) { 122 e.preventDefault(); 123 return false; 124 } 125 else if (this._oldScript) { 126 127 if (String.isInstanceOfType(this._oldScript)) { 128 eval(this._oldScript); 129 } 130 else if (typeof(this._oldScript) == 'function'){ 131 this._oldScript(); 132 } 133 } 134 } 135 } 136 }, 137 138 _displayConfirmDialog : function() { 139 /// <summary> 140 /// Handle the completion of a confirm dialog (whether by window.confirm or ModalPopupBehavior) 141 /// </summary> 142 /// <value type="Boolean"> 143 /// Result of the confirm dialog or false to cancel 144 /// </value> 145 146 var eventArgs = new Sys.CancelEventArgs(); 147 this.raiseShowing(eventArgs); 148 if (eventArgs.get_cancel()) { 149 return; 150 } 151 152 if(this._displayModalPopupID) { 153 var mpe = $find(this._displayModalPopupID); 154 if (!mpe) { 155 throw Error.argument('displayModalPopupID', String.format(Sys.Extended.UI.Resources.CollapsiblePanel_NoControlID, this._displayModalPopupID)); 156 } 157 mpe.set_OnOkScript("$find('"+this.get_id()+"')._handleConfirmDialogCompletion(true);"); 158 mpe.set_OnCancelScript("$find('"+this.get_id()+"')._handleConfirmDialogCompletion(false);"); 159 mpe.show(); 160 return false; 161 } else { 162 var result = window.confirm(this._ConfirmTextValue); 163 this._handleConfirmDialogCompletion(result); 164 return result; 165 } 166 }, 167 168 _handleConfirmDialogCompletion : function(result) { 169 /// <summary> 170 /// Handle the completion of a confirm dialog (whether by window.confirm or ModalPopupBehavior) 171 /// </summary> 172 /// <param name="result" type="Boolean"> 173 /// Result of the confirm dialog 174 /// </param> 175 this.raiseHidden(new Sys.Extended.UI.ConfirmButtonHiddenEventArgs(result)); 176 if (result) { 177 if (this._postBackScript ) { 178 eval(this._postBackScript); 179 } 180 } else { 181 if (this._OnClientCancelValue) { 182 window[this._OnClientCancelValue](); 183 } 184 } 185 }, 186 187 get_OnClientCancel : function (){ 188 /// <value type="String"> 189 /// The client-side script that executes when the cancel button is clicked on the confirm dialog. 190 /// </value> 191 return this._OnClientCancelValue; 192 }, 193 set_OnClientCancel : function (value) { 194 if (this._OnClientCancelValue != value) { 195 this._OnClientCancelValue = value; 196 this.raisePropertyChanged('OnClientCancel'); 197 } 198 }, 199 200 get_ConfirmText : function() { 201 /// <value type="String"> 202 /// The text to show when you want to confirm the click. (Note: HTML entities can be used here (ex: " " for new-line)) 203 /// </value> 204 return this._ConfirmTextValue; 205 }, 206 set_ConfirmText : function(value) { 207 if (this._ConfirmTextValue != value) { 208 this._ConfirmTextValue = value; 209 this.raisePropertyChanged('ConfirmText'); 210 } 211 }, 212 213 get_ConfirmOnFormSubmit : function() { 214 /// <value type="Boolean"> 215 /// True iff the confirm dialog should run for form submission (i.e., after validators are all satisfied) 216 /// </value> 217 return this._ConfirmOnFormSubmit; 218 }, 219 set_ConfirmOnFormSubmit : function(value) { 220 if (this._ConfirmOnFormSubmit != value) { 221 this._ConfirmOnFormSubmit = value; 222 this.raisePropertyChanged('ConfirmOnFormSubmit'); 223 } 224 }, 225 226 get_displayModalPopupID : function() { 227 /// <value type="String"> 228 /// ID of a ModalPopupBehavior to be used instead of the default window.confirm dialog 229 /// </value> 230 return this._displayModalPopupID; 231 }, 232 set_displayModalPopupID : function(value) { 233 if (this._displayModalPopupID != value) { 234 this._displayModalPopupID = value; 235 this.raisePropertyChanged('displayModalPopupID'); 236 } 237 }, 238 239 get_postBackScript : function() { 240 /// <value type="String"> 241 /// Script to run to initiate a postback 242 /// </value> 243 return this._postBackScript; 244 }, 245 set_postBackScript : function(value) { 246 if (this._postBackScript != value) { 247 this._postBackScript = value; 248 this.raisePropertyChanged('postBackScript'); 249 } 250 }, 251 252 add_showing : function(handler) { 253 /// <summary> 254 /// Add an event handler for the showing event 255 /// </summary> 256 /// <param name="handler" type="Function" mayBeNull="false"> 257 /// Event handler 258 /// </param> 259 /// <returns /> 260 this.get_events().addHandler('showing', handler); 261 }, 262 remove_showing : function(handler) { 263 /// <summary> 264 /// Remove an event handler from the showing event 265 /// </summary> 266 /// <param name="handler" type="Function" mayBeNull="false"> 267 /// Event handler 268 /// </param> 269 /// <returns /> 270 this.get_events().removeHandler('showing', handler); 271 }, 272 raiseShowing : function(eventArgs) { 273 /// <summary> 274 /// Raise the showing event 275 /// </summary> 276 /// <param name="eventArgs" type="Sys.CancelEventArgs" mayBeNull="false"> 277 /// Event arguments for the showing event 278 /// </param> 279 /// <returns /> 280 281 var handler = this.get_events().getHandler('showing'); 282 if (handler) { 283 handler(this, eventArgs); 284 } 285 }, 286 287 add_hidden : function(handler) { 288 /// <summary> 289 /// Add an event handler for the hidden event 290 /// </summary> 291 /// <param name="handler" type="Function" mayBeNull="false"> 292 /// Event handler 293 /// </param> 294 /// <returns /> 295 this.get_events().addHandler('hidden', handler); 296 }, 297 remove_hidden : function(handler) { 298 /// <summary> 299 /// Remove an event handler from the hidden event 300 /// </summary> 301 /// <param name="handler" type="Function" mayBeNull="false"> 302 /// Event handler 303 /// </param> 304 /// <returns /> 305 this.get_events().removeHandler('hidden', handler); 306 }, 307 raiseHidden : function(eventArgs) { 308 /// <summary> 309 /// Raise the hidden event 310 /// </summary> 311 /// <param name="eventArgs" type="Sys.Extended.UI.ConfirmButtonHiddenEventArgs" mayBeNull="false"> 312 /// Event arguments for the hidden event 313 /// </param> 314 /// <returns /> 315 316 var handler = this.get_events().getHandler('hidden'); 317 if (handler) { 318 handler(this, eventArgs); 319 } 320 } 321} 322Sys.Extended.UI.ConfirmButtonBehavior.registerClass('Sys.Extended.UI.ConfirmButtonBehavior', Sys.Extended.UI.BehaviorBase); 323Sys.registerComponent(Sys.Extended.UI.ConfirmButtonBehavior, { name: "confirmButton", parameters: [{name: "ConfirmText", type: "String"}] }); 324 325Sys.Extended.UI.ConfirmButtonBehavior.WebForm_OnSubmit = function() { 326 /// <summary> 327 /// Wraps ASP.NET's WebForm_OnSubmit in order to display the confirm dialog prior to submission 328 /// </summary> 329 /// <returns type="Boolean"> 330 /// Result of original WebForm_OnSubmit 331 /// </returns> 332 var result = Sys.Extended.UI.ConfirmButtonBehavior._originalWebForm_OnSubmit(); 333 if (result && Sys.Extended.UI.ConfirmButtonBehavior._clickedBehavior) { 334 result = Sys.Extended.UI.ConfirmButtonBehavior._clickedBehavior._displayConfirmDialog(); 335 } 336 Sys.Extended.UI.ConfirmButtonBehavior._clickedBehavior = null; 337 return result; 338} 339 340} // execute 341 342if (window.Sys && Sys.loader) { 343 Sys.loader.registerScript(scriptName, ["ExtendedBase"], execute); 344} 345else { 346 execute(); 347} 348 349})();
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.