10 lines
22 KiB
JavaScript
10 lines
22 KiB
JavaScript
|
/*!
|
||
|
* jquery-confirm v3.0.2 (http://craftpip.github.io/jquery-confirm/)
|
||
|
* Author: Boniface Pereira
|
||
|
* Website: www.craftpip.com
|
||
|
* Contact: hey@craftpip.com
|
||
|
*
|
||
|
* Copyright 2013-2016 jquery-confirm
|
||
|
* Licensed under MIT (https://github.com/craftpip/jquery-confirm/blob/master/LICENSE)
|
||
|
*/
|
||
|
if(typeof jQuery==="undefined"){throw new Error("jquery-confirm requires jQuery");}var jconfirm,Jconfirm;(function($){$.fn.confirm=function(options,option2){if(typeof options==="undefined"){options={};}if(typeof options==="string"){options={content:options,title:(option2)?option2:false};}$(this).each(function(){var $this=$(this);$this.on("click",function(e){e.preventDefault();var jcOption=$.extend({},options);if($this.attr("data-title")){jcOption.title=$this.attr("data-title");}if($this.attr("data-content")){jcOption.content=$this.attr("data-content");}if(typeof jcOption.buttons=="undefined"){jcOption.buttons={};}jcOption["$target"]=$this;if($this.attr("href")&&Object.keys(jcOption.buttons).length==0){var buttons={};if(jconfirm.defaults&&jconfirm.defaults.defaultButtons){buttons=$.extend({},jconfirm.pluginDefaults.defaultButtons,jconfirm.defaults.defaultButtons||{});}else{buttons=$.extend({},jconfirm.pluginDefaults.defaultButtons);}var firstBtn=Object.keys(buttons)[0];jcOption.buttons=buttons;jcOption.buttons[firstBtn].action=function(){location.href=$this.attr("href");};}jcOption.closeIcon=false;$.confirm(jcOption);});});return $(this);};$.confirm=function(options,option2){if(typeof options==="undefined"){options={};}if(typeof options==="string"){options={content:options,title:(option2)?option2:false,};}if(typeof options.buttons!="object"){options.buttons={};}if(Object.keys(options.buttons).length==0){var buttons={};if(jconfirm.defaults&&jconfirm.defaults.defaultButtons){buttons=$.extend({},jconfirm.pluginDefaults.defaultButtons,jconfirm.defaults.defaultButtons||{});}else{buttons=$.extend({},jconfirm.pluginDefaults.defaultButtons);}options.buttons=buttons;}return jconfirm(options);};$.alert=function(options,option2){if(typeof options==="undefined"){options={};}if(typeof options==="string"){options={content:options,title:(option2)?option2:false,};}if(typeof options.buttons!="object"){options.buttons={};}if(Object.keys(options.buttons).length==0){var buttons={};if(jconfirm.defaults&&jconfirm.defaults.defaultButtons){buttons=$.extend({},jconfirm.pluginDefaults.defaultButtons,jconfirm.defaults.defaultButtons||{});}else{buttons=$.extend({},jconfirm.pluginDefaults.defaultButtons);}var firstBtn=Object.keys(buttons)[0];options.buttons[firstBtn]=buttons[firstBtn];}return jconfirm(options);};$.dialog=function(options,option2){if(typeof options==="undefined"){options={};}if(typeof options==="string"){options={content:options,title:(option2)?option2:false,closeIcon:function(){}};}options.buttons={};if(typeof options.closeIcon=="undefined"){options.closeIcon=function(){};}options.confirmKeys=[13];return jconfirm(options);};jconfirm=function(options){if(typeof options==="undefined"){options={};}if(jconfirm.defaults){$.extend(jconfirm.pluginDefaults,jconfirm.defaults);}options=$.extend({},jconfirm.pluginDefaults,options);var instance=new Jconfirm(options);jconfirm.instances.push(instance);return instance;};Jconfirm=function(options){$.extend(this,options);this._init();};Jconfirm.prototype={_init:function(){var that=this;this._lastFocused=$("body").find(":focus");this._id=Math.round(Math.random()*99999);setTimeout(function(){that.open();},0);},_buildHTML:function(){var that=this;this._parseAnimation(this.animation,"o");this._parseAnimation(this.closeAnimation,"c");this._parseBgDismissAnimation(this.backgroundDismissAnimation);this._parseColumnClass(this.columnClass);this._parseTheme(this.theme);var template=$(this.template);var type="";switch(this.type){case"default":case"blue":case"green":case"red":case"orange":case"purple":case"dark":type="jconfirm-"+this.type;break;default:console.warn("Invalid dialog type: "+this.type);}template.find(".jconfirm-box").addClass(this.animationParsed).addClass(this.backgroundDismissAnimationParsed).addClass(type);if(this.typeAnimated){template.find(".jconfirm-box").addClass("jconfirm-type-animated");}if(this.useBootstrap){template.find(".jc-bs3-row").addClass(this.bootstrapClasses.row);template.find(".jconfirm-box-container").addClass(this.columnClassParsed);if(this.containerFluid){template.find(".jc-
|