mirror of
				https://git.code.sf.net/p/seeddms/code
				synced 2025-10-31 05:11:27 +00:00 
			
		
		
		
	add bootbox
This commit is contained in:
		
							parent
							
								
									d76cc6d3d4
								
							
						
					
					
						commit
						c80d579072
					
				
							
								
								
									
										551
									
								
								styles/bootstrap/bootbox/bootbox.js
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										551
									
								
								styles/bootstrap/bootbox/bootbox.js
									
									
									
									
										vendored
									
									
										Normal file
									
								
							|  | @ -0,0 +1,551 @@ | |||
| /** | ||||
|  * bootbox.js v2.5.1 | ||||
|  * | ||||
|  * http://bootboxjs.com/license.txt
 | ||||
|  */ | ||||
| var bootbox = window.bootbox || (function($) { | ||||
| 
 | ||||
|     var _locale        = 'en', | ||||
|         _defaultLocale = 'en', | ||||
|         _animate       = true, | ||||
|         _backdrop      = 'static', | ||||
|         _defaultHref   = 'javascript:;', | ||||
|         _classes       = '', | ||||
|         _icons         = {}, | ||||
|         /* last var should always be the public object we'll return */ | ||||
|         that           = {}; | ||||
| 
 | ||||
|     /** | ||||
|      * standard locales. Please add more according to ISO 639-1 standard. Multiple language variants are | ||||
|      * unlikely to be required. If this gets too large it can be split out into separate JS files. | ||||
|      */ | ||||
|     var _locales = { | ||||
|         'en' : { | ||||
|             OK      : 'OK', | ||||
|             CANCEL  : 'Cancel', | ||||
|             CONFIRM : 'OK' | ||||
|         }, | ||||
|         'fr' : { | ||||
|             OK      : 'OK', | ||||
|             CANCEL  : 'Annuler', | ||||
|             CONFIRM : 'D\'accord' | ||||
|         }, | ||||
|         'de' : { | ||||
|             OK      : 'OK', | ||||
|             CANCEL  : 'Abbrechen', | ||||
|             CONFIRM : 'Akzeptieren' | ||||
|         }, | ||||
|         'es' : { | ||||
|             OK      : 'OK', | ||||
|             CANCEL  : 'Cancelar', | ||||
|             CONFIRM : 'Aceptar' | ||||
|         }, | ||||
|         'br' : { | ||||
|             OK      : 'OK', | ||||
|             CANCEL  : 'Cancelar', | ||||
|             CONFIRM : 'Sim' | ||||
|         }, | ||||
|         'nl' : { | ||||
|             OK      : 'OK', | ||||
|             CANCEL  : 'Annuleren', | ||||
|             CONFIRM : 'Accepteren' | ||||
|         }, | ||||
|         'ru' : { | ||||
|             OK      : 'OK', | ||||
|             CANCEL  : 'Отмена', | ||||
|             CONFIRM : 'Применить' | ||||
|         }, | ||||
|         'it' : { | ||||
|             OK      : 'OK', | ||||
|             CANCEL  : 'Annulla', | ||||
|             CONFIRM : 'Conferma' | ||||
|         } | ||||
|     }; | ||||
| 
 | ||||
|     /** | ||||
|      * private methods | ||||
|      */ | ||||
|     function _translate(str, locale) { | ||||
|         // we assume if no target locale is probided then we should take it from current setting
 | ||||
|         if (locale == null) { | ||||
|             locale = _locale; | ||||
|         } | ||||
|         if (typeof _locales[locale][str] == 'string') { | ||||
|             return _locales[locale][str]; | ||||
|         } | ||||
| 
 | ||||
|         // if we couldn't find a lookup then try and fallback to a default translation
 | ||||
| 
 | ||||
|         if (locale != _defaultLocale) { | ||||
|             return _translate(str, _defaultLocale); | ||||
|         } | ||||
| 
 | ||||
|         // if we can't do anything then bail out with whatever string was passed in - last resort
 | ||||
|         return str; | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|      * public API | ||||
|      */ | ||||
|     that.setLocale = function(locale) { | ||||
|         for (var i in _locales) { | ||||
|             if (i == locale) { | ||||
|                 _locale = locale; | ||||
|                 return; | ||||
|             } | ||||
|         } | ||||
|         throw new Error('Invalid locale: '+locale); | ||||
|     }; | ||||
| 
 | ||||
|     that.addLocale = function(locale, translations) { | ||||
|         if (typeof _locales[locale] == 'undefined') { | ||||
|             _locales[locale] = {}; | ||||
|         } | ||||
|         for (var str in translations) { | ||||
|             _locales[locale][str] = translations[str]; | ||||
|         } | ||||
|     }; | ||||
| 
 | ||||
|     that.setIcons = function(icons) { | ||||
|         _icons = icons; | ||||
|         if (typeof _icons !== 'object' || _icons == null) { | ||||
|             _icons = {}; | ||||
|         } | ||||
|     }; | ||||
| 
 | ||||
|     that.alert = function(/*str, label, cb*/) { | ||||
|         var str   = "", | ||||
|             label = _translate('OK'), | ||||
|             cb    = null; | ||||
| 
 | ||||
|         switch (arguments.length) { | ||||
|             case 1: | ||||
|                 // no callback, default button label
 | ||||
|                 str = arguments[0]; | ||||
|                 break; | ||||
|             case 2: | ||||
|                 // callback *or* custom button label dependent on type
 | ||||
|                 str = arguments[0]; | ||||
|                 if (typeof arguments[1] == 'function') { | ||||
|                     cb = arguments[1]; | ||||
|                 } else { | ||||
|                     label = arguments[1]; | ||||
|                 } | ||||
|                 break; | ||||
|             case 3: | ||||
|                 // callback and custom button label
 | ||||
|                 str   = arguments[0]; | ||||
|                 label = arguments[1]; | ||||
|                 cb    = arguments[2]; | ||||
|                 break; | ||||
|             default: | ||||
|                 throw new Error("Incorrect number of arguments: expected 1-3"); | ||||
|                 break; | ||||
|         } | ||||
| 
 | ||||
|         return that.dialog(str, { | ||||
|             "label": label, | ||||
|             "icon" : _icons.OK, | ||||
|             "callback": cb | ||||
|         }, { | ||||
|             "onEscape": cb | ||||
|         }); | ||||
|     }; | ||||
| 
 | ||||
|     that.confirm = function(/*str, labelCancel, labelOk, cb*/) { | ||||
|         var str         = "", | ||||
|             labelCancel = _translate('CANCEL'), | ||||
|             labelOk     = _translate('CONFIRM'), | ||||
|             cb          = null; | ||||
| 
 | ||||
|         switch (arguments.length) { | ||||
|             case 1: | ||||
|                 str = arguments[0]; | ||||
|                 break; | ||||
|             case 2: | ||||
|                 str = arguments[0]; | ||||
|                 if (typeof arguments[1] == 'function') { | ||||
|                     cb = arguments[1]; | ||||
|                 } else { | ||||
|                     labelCancel = arguments[1]; | ||||
|                 } | ||||
|                 break; | ||||
|             case 3: | ||||
|                 str         = arguments[0]; | ||||
|                 labelCancel = arguments[1]; | ||||
|                 if (typeof arguments[2] == 'function') { | ||||
|                     cb = arguments[2]; | ||||
|                 } else { | ||||
|                     labelOk = arguments[2]; | ||||
|                 } | ||||
|                 break; | ||||
|             case 4: | ||||
|                 str         = arguments[0]; | ||||
|                 labelCancel = arguments[1]; | ||||
|                 labelOk     = arguments[2]; | ||||
|                 cb          = arguments[3]; | ||||
|                 break; | ||||
|             default: | ||||
|                 throw new Error("Incorrect number of arguments: expected 1-4"); | ||||
|                 break; | ||||
|         } | ||||
| 
 | ||||
|         return that.dialog(str, [{ | ||||
|             "label": labelCancel, | ||||
|             "icon" : _icons.CANCEL, | ||||
|             "callback": function() { | ||||
|                 if (typeof cb == 'function') { | ||||
|                     cb(false); | ||||
|                 } | ||||
|             } | ||||
|         }, { | ||||
|             "label": labelOk, | ||||
|             "icon" : _icons.CONFIRM, | ||||
|             "callback": function() { | ||||
|                 if (typeof cb == 'function') { | ||||
|                     cb(true); | ||||
|                 } | ||||
|             } | ||||
|         }]); | ||||
|     }; | ||||
| 
 | ||||
|     that.prompt = function(/*str, labelCancel, labelOk, cb, defaultVal*/) { | ||||
|         var str         = "", | ||||
|             labelCancel = _translate('CANCEL'), | ||||
|             labelOk     = _translate('CONFIRM'), | ||||
|             cb          = null, | ||||
|             defaultVal  = ""; | ||||
| 
 | ||||
|         switch (arguments.length) { | ||||
|             case 1: | ||||
|                 str = arguments[0]; | ||||
|                 break; | ||||
|             case 2: | ||||
|                 str = arguments[0]; | ||||
|                 if (typeof arguments[1] == 'function') { | ||||
|                     cb = arguments[1]; | ||||
|                 } else { | ||||
|                     labelCancel = arguments[1]; | ||||
|                 } | ||||
|                 break; | ||||
|             case 3: | ||||
|                 str         = arguments[0]; | ||||
|                 labelCancel = arguments[1]; | ||||
|                 if (typeof arguments[2] == 'function') { | ||||
|                     cb = arguments[2]; | ||||
|                 } else { | ||||
|                     labelOk = arguments[2]; | ||||
|                 } | ||||
|                 break; | ||||
|             case 4: | ||||
|                 str         = arguments[0]; | ||||
|                 labelCancel = arguments[1]; | ||||
|                 labelOk     = arguments[2]; | ||||
|                 cb          = arguments[3]; | ||||
|                 break; | ||||
|             case 5: | ||||
|                 str         = arguments[0]; | ||||
|                 labelCancel = arguments[1]; | ||||
|                 labelOk     = arguments[2]; | ||||
|                 cb          = arguments[3]; | ||||
|                 defaultVal  = arguments[4]; | ||||
|                 break; | ||||
|             default: | ||||
|                 throw new Error("Incorrect number of arguments: expected 1-5"); | ||||
|                 break; | ||||
|         } | ||||
| 
 | ||||
|         var header = str; | ||||
| 
 | ||||
|         // let's keep a reference to the form object for later
 | ||||
|         var form = $("<form></form>"); | ||||
|         form.append("<input autocomplete=off type=text value='" + defaultVal + "' />"); | ||||
| 
 | ||||
|         var div = that.dialog(form, [{ | ||||
|             "label": labelCancel, | ||||
|             "icon" : _icons.CANCEL, | ||||
|             "callback": function() { | ||||
|                 if (typeof cb == 'function') { | ||||
|                     cb(null); | ||||
|                 } | ||||
|             } | ||||
|         }, { | ||||
|             "label": labelOk, | ||||
|             "icon" : _icons.CONFIRM, | ||||
|             "callback": function() { | ||||
|                 if (typeof cb == 'function') { | ||||
|                     cb( | ||||
|                         form.find("input[type=text]").val() | ||||
|                     ); | ||||
|                 } | ||||
|             } | ||||
|         }], { | ||||
|             "header": header | ||||
|         }); | ||||
| 
 | ||||
|         div.on("shown", function() { | ||||
|             form.find("input[type=text]").focus(); | ||||
| 
 | ||||
|             // ensure that submitting the form (e.g. with the enter key)
 | ||||
|             // replicates the behaviour of a normal prompt()
 | ||||
|             form.on("submit", function(e) { | ||||
|                 e.preventDefault(); | ||||
|                 div.find(".btn-primary").click(); | ||||
|             }); | ||||
|         }); | ||||
| 
 | ||||
|         return div; | ||||
|     }; | ||||
| 
 | ||||
|     that.modal = function(/*str, label, options*/) { | ||||
|         var str; | ||||
|         var label; | ||||
|         var options; | ||||
| 
 | ||||
|         var defaultOptions = { | ||||
|             "onEscape": null, | ||||
|             "keyboard": true, | ||||
|             "backdrop": _backdrop | ||||
|         }; | ||||
| 
 | ||||
|         switch (arguments.length) { | ||||
|             case 1: | ||||
|                 str = arguments[0]; | ||||
|                 break; | ||||
|             case 2: | ||||
|                 str = arguments[0]; | ||||
|                 if (typeof arguments[1] == 'object') { | ||||
|                     options = arguments[1]; | ||||
|                 } else { | ||||
|                     label = arguments[1]; | ||||
|                 } | ||||
|                 break; | ||||
|             case 3: | ||||
|                 str     = arguments[0]; | ||||
|                 label   = arguments[1]; | ||||
|                 options = arguments[2]; | ||||
|                 break; | ||||
|             default: | ||||
|                 throw new Error("Incorrect number of arguments: expected 1-3"); | ||||
|                 break; | ||||
|         } | ||||
| 
 | ||||
|         defaultOptions['header'] = label; | ||||
| 
 | ||||
|         if (typeof options == 'object') { | ||||
|             options = $.extend(defaultOptions, options); | ||||
|         } else { | ||||
|             options = defaultOptions; | ||||
|         } | ||||
| 
 | ||||
|         return that.dialog(str, [], options); | ||||
|     }; | ||||
| 
 | ||||
|     that.dialog = function(str, handlers, options) { | ||||
|         var hideSource = null, | ||||
|             buttons    = "", | ||||
|             callbacks  = [], | ||||
|             options    = options || {}; | ||||
| 
 | ||||
|         // check for single object and convert to array if necessary
 | ||||
|         if (handlers == null) { | ||||
|             handlers = []; | ||||
|         } else if (typeof handlers.length == 'undefined') { | ||||
|             handlers = [handlers]; | ||||
|         } | ||||
| 
 | ||||
|         var i = handlers.length; | ||||
|         while (i--) { | ||||
|             var label    = null, | ||||
|                 href     = null, | ||||
|                 _class   = null, | ||||
|                 icon     = '', | ||||
|                 callback = null; | ||||
| 
 | ||||
|             if (typeof handlers[i]['label']    == 'undefined' && | ||||
|                 typeof handlers[i]['class']    == 'undefined' && | ||||
|                 typeof handlers[i]['callback'] == 'undefined') { | ||||
|                 // if we've got nothing we expect, check for condensed format
 | ||||
| 
 | ||||
|                 var propCount = 0,      // condensed will only match if this == 1
 | ||||
|                     property  = null;   // save the last property we found
 | ||||
| 
 | ||||
|                 // be nicer to count the properties without this, but don't think it's possible...
 | ||||
|                 for (var j in handlers[i]) { | ||||
|                     property = j; | ||||
|                     if (++propCount > 1) { | ||||
|                         // forget it, too many properties
 | ||||
|                         break; | ||||
|                     } | ||||
|                 } | ||||
| 
 | ||||
|                 if (propCount == 1 && typeof handlers[i][j] == 'function') { | ||||
|                     // matches condensed format of label -> function
 | ||||
|                     handlers[i]['label']    = property; | ||||
|                     handlers[i]['callback'] = handlers[i][j]; | ||||
|                 } | ||||
|             } | ||||
| 
 | ||||
|             if (typeof handlers[i]['callback']== 'function') { | ||||
|                 callback = handlers[i]['callback']; | ||||
|             } | ||||
| 
 | ||||
|             if (handlers[i]['class']) { | ||||
|                 _class = handlers[i]['class']; | ||||
|             } else if (i == handlers.length -1 && handlers.length <= 2) { | ||||
|                 // always add a primary to the main option in a two-button dialog
 | ||||
|                 _class = 'btn-primary'; | ||||
|             } | ||||
| 
 | ||||
|             if (handlers[i]['label']) { | ||||
|                 label = handlers[i]['label']; | ||||
|             } else { | ||||
|                 label = "Option "+(i+1); | ||||
|             } | ||||
| 
 | ||||
|             if (handlers[i]['icon']) { | ||||
|                 icon = "<i class='"+handlers[i]['icon']+"'></i> "; | ||||
|             } | ||||
| 
 | ||||
|             if (handlers[i]['href']) { | ||||
|                 href = handlers[i]['href']; | ||||
|             } | ||||
|             else { | ||||
|                 href = _defaultHref; | ||||
|             } | ||||
| 
 | ||||
|             buttons += "<a data-handler='"+i+"' class='btn "+_class+"' href='" + href + "'>"+icon+""+label+"</a>"; | ||||
| 
 | ||||
|             callbacks[i] = callback; | ||||
|         } | ||||
| 
 | ||||
|         // @see https://github.com/makeusabrew/bootbox/issues/46#issuecomment-8235302
 | ||||
|         // and https://github.com/twitter/bootstrap/issues/4474
 | ||||
|         // for an explanation of the inline overflow: hidden
 | ||||
| 
 | ||||
|         var parts = ["<div class='bootbox modal' style='overflow:hidden;'>"]; | ||||
| 
 | ||||
|         if (options['header']) { | ||||
|             var closeButton = ''; | ||||
|             if (typeof options['headerCloseButton'] == 'undefined' || options['headerCloseButton']) { | ||||
|                 closeButton = "<a href='"+_defaultHref+"' class='close'>×</a>"; | ||||
|             } | ||||
| 
 | ||||
|             parts.push("<div class='modal-header'>"+closeButton+"<h3>"+options['header']+"</h3></div>"); | ||||
|         } | ||||
| 
 | ||||
|         // push an empty body into which we'll inject the proper content later
 | ||||
|         parts.push("<div class='modal-body'></div>"); | ||||
| 
 | ||||
|         if (buttons) { | ||||
|             parts.push("<div class='modal-footer'>"+buttons+"</div>"); | ||||
|         } | ||||
| 
 | ||||
|         parts.push("</div>"); | ||||
| 
 | ||||
|         var div = $(parts.join("\n")); | ||||
| 
 | ||||
|         // check whether we should fade in/out
 | ||||
|         var shouldFade = (typeof options.animate === 'undefined') ? _animate : options.animate; | ||||
| 
 | ||||
|         if (shouldFade) { | ||||
|             div.addClass("fade"); | ||||
|         } | ||||
| 
 | ||||
|         var optionalClasses = (typeof options.classes === 'undefined') ? _classes : options.classes; | ||||
|         if( optionalClasses )  { | ||||
|           div.addClass( optionalClasses ); | ||||
|         } | ||||
| 
 | ||||
|         // now we've built up the div properly we can inject the content whether it was a string or a jQuery object
 | ||||
|         $(".modal-body", div).html(str); | ||||
| 
 | ||||
|         div.bind('hidden', function() { | ||||
|             div.remove(); | ||||
|         }); | ||||
| 
 | ||||
|         div.bind('hide', function() { | ||||
|             if (hideSource == 'escape' && | ||||
|                 typeof options.onEscape == 'function') { | ||||
|                 options.onEscape(); | ||||
|             } | ||||
|         }); | ||||
| 
 | ||||
|         // hook into the modal's keyup trigger to check for the escape key
 | ||||
|         $(document).bind('keyup.modal', function ( e ) { | ||||
|             if (e.which == 27) { | ||||
|                 hideSource = 'escape'; | ||||
|             } | ||||
|         }); | ||||
| 
 | ||||
|         // well, *if* we have a primary - give the last dom element (first displayed) focus
 | ||||
|         div.bind('shown', function() { | ||||
|             $("a.btn-primary:last", div).focus(); | ||||
|         }); | ||||
| 
 | ||||
|         // wire up button handlers
 | ||||
|         div.on('click', '.modal-footer a, a.close', function(e) { | ||||
| 
 | ||||
|             var handler   = $(this).data("handler"), | ||||
|                 cb        = callbacks[handler], | ||||
|                 hideModal = null; | ||||
| 
 | ||||
|             // sort of @see https://github.com/makeusabrew/bootbox/pull/68 - heavily adapted
 | ||||
|             // if we've got a custom href attribute, all bets are off
 | ||||
|             if (typeof handler                   !== 'undefined' && | ||||
|                 typeof handlers[handler]['href'] !== 'undefined') { | ||||
| 
 | ||||
|                 return; | ||||
|             } | ||||
| 
 | ||||
|             e.preventDefault(); | ||||
| 
 | ||||
|             if (typeof cb == 'function') { | ||||
|                 hideModal = cb(); | ||||
|             } | ||||
| 
 | ||||
|             // the only way hideModal *will* be false is if a callback exists and
 | ||||
|             // returns it as a value. in those situations, don't hide the dialog
 | ||||
|             // @see https://github.com/makeusabrew/bootbox/pull/25
 | ||||
|             if (hideModal !== false) { | ||||
|                 hideSource = 'button'; | ||||
|                 div.modal("hide"); | ||||
|             } | ||||
|         }); | ||||
| 
 | ||||
|         if (options.keyboard == null) { | ||||
|             options.keyboard = (typeof options.onEscape == 'function'); | ||||
|         } | ||||
| 
 | ||||
|         $("body").append(div); | ||||
| 
 | ||||
|         div.modal({ | ||||
|             "backdrop" : (typeof options.backdrop  === 'undefined') ? _backdrop : options.backdrop, | ||||
|             "keyboard" : options.keyboard | ||||
|         }); | ||||
| 
 | ||||
|         return div; | ||||
|     }; | ||||
| 
 | ||||
|     that.hideAll = function() { | ||||
|         $(".bootbox").modal("hide"); | ||||
|     }; | ||||
| 
 | ||||
|     that.animate = function(animate) { | ||||
|         _animate = animate; | ||||
|     }; | ||||
| 
 | ||||
|     that.backdrop = function(backdrop) { | ||||
|         _backdrop = backdrop; | ||||
|     }; | ||||
| 
 | ||||
|     that.classes = function(classes) { | ||||
|         _classes = classes; | ||||
|     }; | ||||
| 
 | ||||
|     return that; | ||||
| 
 | ||||
| })( window.jQuery ); | ||||
| 
 | ||||
| // @see https://github.com/makeusabrew/bootbox/issues/71
 | ||||
| window.bootbox = bootbox; | ||||
							
								
								
									
										16
									
								
								styles/bootstrap/bootbox/bootbox.min.js
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										16
									
								
								styles/bootstrap/bootbox/bootbox.min.js
									
									
									
									
										vendored
									
									
										Normal file
									
								
							|  | @ -0,0 +1,16 @@ | |||
| /** | ||||
|  * bootbox.js v2.5.1 | ||||
|  * | ||||
|  * http://bootboxjs.com/license.txt
 | ||||
|  */ | ||||
| var bootbox=window.bootbox||function(k){function h(b,a){null==a&&(a=m);return"string"==typeof i[a][b]?i[a][b]:a!=n?h(b,n):b}var m="en",n="en",s=!0,r="static",t="",j={},e={},i={en:{OK:"OK",CANCEL:"Cancel",CONFIRM:"OK"},fr:{OK:"OK",CANCEL:"Annuler",CONFIRM:"D'accord"},de:{OK:"OK",CANCEL:"Abbrechen",CONFIRM:"Akzeptieren"},es:{OK:"OK",CANCEL:"Cancelar",CONFIRM:"Aceptar"},br:{OK:"OK",CANCEL:"Cancelar",CONFIRM:"Sim"},nl:{OK:"OK",CANCEL:"Annuleren",CONFIRM:"Accepteren"},ru:{OK:"OK",CANCEL:"\u041e\u0442\u043c\u0435\u043d\u0430", | ||||
| CONFIRM:"\u041f\u0440\u0438\u043c\u0435\u043d\u0438\u0442\u044c"},it:{OK:"OK",CANCEL:"Annulla",CONFIRM:"Conferma"}};e.setLocale=function(b){for(var a in i)if(a==b){m=b;return}throw Error("Invalid locale: "+b);};e.addLocale=function(b,a){"undefined"==typeof i[b]&&(i[b]={});for(var c in a)i[b][c]=a[c]};e.setIcons=function(b){j=b;if("object"!==typeof j||null==j)j={}};e.alert=function(){var b="",a=h("OK"),c=null;switch(arguments.length){case 1:b=arguments[0];break;case 2:b=arguments[0];"function"==typeof arguments[1]? | ||||
| c=arguments[1]:a=arguments[1];break;case 3:b=arguments[0];a=arguments[1];c=arguments[2];break;default:throw Error("Incorrect number of arguments: expected 1-3");}return e.dialog(b,{label:a,icon:j.OK,callback:c},{onEscape:c})};e.confirm=function(){var b="",a=h("CANCEL"),c=h("CONFIRM"),f=null;switch(arguments.length){case 1:b=arguments[0];break;case 2:b=arguments[0];"function"==typeof arguments[1]?f=arguments[1]:a=arguments[1];break;case 3:b=arguments[0];a=arguments[1];"function"==typeof arguments[2]? | ||||
| f=arguments[2]:c=arguments[2];break;case 4:b=arguments[0];a=arguments[1];c=arguments[2];f=arguments[3];break;default:throw Error("Incorrect number of arguments: expected 1-4");}return e.dialog(b,[{label:a,icon:j.CANCEL,callback:function(){"function"==typeof f&&f(!1)}},{label:c,icon:j.CONFIRM,callback:function(){"function"==typeof f&&f(!0)}}])};e.prompt=function(){var b="",a=h("CANCEL"),c=h("CONFIRM"),f=null,u="";switch(arguments.length){case 1:b=arguments[0];break;case 2:b=arguments[0];"function"== | ||||
| typeof arguments[1]?f=arguments[1]:a=arguments[1];break;case 3:b=arguments[0];a=arguments[1];"function"==typeof arguments[2]?f=arguments[2]:c=arguments[2];break;case 4:b=arguments[0];a=arguments[1];c=arguments[2];f=arguments[3];break;case 5:b=arguments[0];a=arguments[1];c=arguments[2];f=arguments[3];u=arguments[4];break;default:throw Error("Incorrect number of arguments: expected 1-5");}var p=k("<form></form>");p.append("<input autocomplete=off type=text value='"+u+"' />");var d=e.dialog(p,[{label:a, | ||||
| icon:j.CANCEL,callback:function(){"function"==typeof f&&f(null)}},{label:c,icon:j.CONFIRM,callback:function(){"function"==typeof f&&f(p.find("input[type=text]").val())}}],{header:b});d.on("shown",function(){p.find("input[type=text]").focus();p.on("submit",function(a){a.preventDefault();d.find(".btn-primary").click()})});return d};e.modal=function(){var b,a,c,f={onEscape:null,keyboard:!0,backdrop:r};switch(arguments.length){case 1:b=arguments[0];break;case 2:b=arguments[0];"object"==typeof arguments[1]? | ||||
| c=arguments[1]:a=arguments[1];break;case 3:b=arguments[0];a=arguments[1];c=arguments[2];break;default:throw Error("Incorrect number of arguments: expected 1-3");}f.header=a;c="object"==typeof c?k.extend(f,c):f;return e.dialog(b,[],c)};e.dialog=function(b,a,c){var f=null,e="",j=[],c=c||{};null==a?a=[]:"undefined"==typeof a.length&&(a=[a]);for(var d=a.length;d--;){var h=null,i=null,l=null,m="",n=null;if("undefined"==typeof a[d].label&&"undefined"==typeof a[d]["class"]&&"undefined"==typeof a[d].callback){var h= | ||||
| 0,i=null,q;for(q in a[d])if(i=q,1<++h)break;1==h&&"function"==typeof a[d][q]&&(a[d].label=i,a[d].callback=a[d][q])}"function"==typeof a[d].callback&&(n=a[d].callback);a[d]["class"]?l=a[d]["class"]:d==a.length-1&&2>=a.length&&(l="btn-primary");h=a[d].label?a[d].label:"Option "+(d+1);a[d].icon&&(m="<i class='"+a[d].icon+"'></i> ");i=a[d].href?a[d].href:"javascript:;";e+="<a data-handler='"+d+"' class='btn "+l+"' href='"+i+"'>"+m+""+h+"</a>";j[d]=n}d=["<div class='bootbox modal' style='overflow:hidden;'>"]; | ||||
| if(c.header){l="";if("undefined"==typeof c.headerCloseButton||c.headerCloseButton)l="<a href='javascript:;' class='close'>×</a>";d.push("<div class='modal-header'>"+l+"<h3>"+c.header+"</h3></div>")}d.push("<div class='modal-body'></div>");e&&d.push("<div class='modal-footer'>"+e+"</div>");d.push("</div>");var g=k(d.join("\n"));("undefined"===typeof c.animate?s:c.animate)&&g.addClass("fade");(e="undefined"===typeof c.classes?t:c.classes)&&g.addClass(e);k(".modal-body",g).html(b);g.bind("hidden", | ||||
| function(){g.remove()});g.bind("hide",function(){if("escape"==f&&"function"==typeof c.onEscape)c.onEscape()});k(document).bind("keyup.modal",function(a){27==a.which&&(f="escape")});g.bind("shown",function(){k("a.btn-primary:last",g).focus()});g.on("click",".modal-footer a, a.close",function(b){var c=k(this).data("handler"),d=j[c],e=null;"undefined"!==typeof c&&"undefined"!==typeof a[c].href||(b.preventDefault(),"function"==typeof d&&(e=d()),!1!==e&&(f="button",g.modal("hide")))});null==c.keyboard&& | ||||
| (c.keyboard="function"==typeof c.onEscape);k("body").append(g);g.modal({backdrop:"undefined"===typeof c.backdrop?r:c.backdrop,keyboard:c.keyboard});return g};e.hideAll=function(){k(".bootbox").modal("hide")};e.animate=function(b){s=b};e.backdrop=function(b){r=b};e.classes=function(b){t=b};return e}(window.jQuery);window.bootbox=bootbox; | ||||
		Loading…
	
		Reference in New Issue
	
	Block a user
	 Uwe Steinmann
						Uwe Steinmann