forgejo/public/js/bootstrap.min.js

265 lines
36 KiB
JavaScript
Raw Normal View History

2014-02-13 06:18:05 +09:00
/*!
* Bootstrap v3.1.0 (http://getbootstrap.com)
* Copyright 2011-2014 Twitter, Inc.
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
*/
if("undefined"==typeof jQuery)throw new Error("Bootstrap requires jQuery");+function(a){"use strict";function b(){var a=document.createElement("bootstrap"),b={WebkitTransition:"webkitTransitionEnd",MozTransition:"transitionend",OTransition:"oTransitionEnd otransitionend",transition:"transitionend"};for(var c in b)if(void 0!==a.style[c])return{end:b[c]};return!1}a.fn.emulateTransitionEnd=function(b){var c=!1,d=this;a(this).one(a.support.transition.end,function(){c=!0});var e=function(){c||a(d).trigger(a.support.transition.end)};return setTimeout(e,b),this},a(function(){a.support.transition=b()})}(jQuery),+function(a){"use strict";var b='[data-dismiss="alert"]',c=function(c){a(c).on("click",b,this.close)};c.prototype.close=function(b){function c(){f.trigger("closed.bs.alert").remove()}var d=a(this),e=d.attr("data-target");e||(e=d.attr("href"),e=e&&e.replace(/.*(?=#[^\s]*$)/,""));var f=a(e);b&&b.preventDefault(),f.length||(f=d.hasClass("alert")?d:d.parent()),f.trigger(b=a.Event("close.bs.alert")),b.isDefaultPrevented()||(f.removeClass("in"),a.support.transition&&f.hasClass("fade")?f.one(a.support.transition.end,c).emulateTransitionEnd(150):c())};var d=a.fn.alert;a.fn.alert=function(b){return this.each(function(){var d=a(this),e=d.data("bs.alert");e||d.data("bs.alert",e=new c(this)),"string"==typeof b&&e[b].call(d)})},a.fn.alert.Constructor=c,a.fn.alert.noConflict=function(){return a.fn.alert=d,this},a(document).on("click.bs.alert.data-api",b,c.prototype.close)}(jQuery),+function(a){"use strict";var b=function(c,d){this.$element=a(c),this.options=a.extend({},b.DEFAULTS,d),this.isLoading=!1};b.DEFAULTS={loadingText:"loading..."},b.prototype.setState=function(b){var c="disabled",d=this.$element,e=d.is("input")?"val":"html",f=d.data();b+="Text",f.resetText||d.data("resetText",d[e]()),d[e](f[b]||this.options[b]),setTimeout(a.proxy(function(){"loadingText"==b?(this.isLoading=!0,d.addClass(c).attr(c,c)):this.isLoading&&(this.isLoading=!1,d.removeClass(c).removeAttr(c))},this),0)},b.prototype.toggle=function(){var a=!0,b=this.$element.closest('[data-toggle="buttons"]');if(b.length){var c=this.$element.find("input");"radio"==c.prop("type")&&(c.prop("checked")&&this.$element.hasClass("active")?a=!1:b.find(".active").removeClass("active")),a&&c.prop("checked",!this.$element.hasClass("active")).trigger("change")}a&&this.$element.toggleClass("active")};var c=a.fn.button;a.fn.button=function(c){return this.each(function(){var d=a(this),e=d.data("bs.button"),f="object"==typeof c&&c;e||d.data("bs.button",e=new b(this,f)),"toggle"==c?e.toggle():c&&e.setState(c)})},a.fn.button.Constructor=b,a.fn.button.noConflict=function(){return a.fn.button=c,this},a(document).on("click.bs.button.data-api","[data-toggle^=button]",function(b){var c=a(b.target);c.hasClass("btn")||(c=c.closest(".btn")),c.button("toggle"),b.preventDefault()})}(jQuery),+function(a){"use strict";var b=function(b,c){this.$element=a(b),this.$indicators=this.$element.find(".carousel-indicators"),this.options=c,this.paused=this.sliding=this.interval=this.$active=this.$items=null,"hover"==this.options.pause&&this.$element.on("mouseenter",a.proxy(this.pause,this)).on("mouseleave",a.proxy(this.cycle,this))};b.DEFAULTS={interval:5e3,pause:"hover",wrap:!0},b.prototype.cycle=function(b){return b||(this.paused=!1),this.interval&&clearInterval(this.interval),this.options.interval&&!this.paused&&(this.interval=setInterval(a.proxy(this.next,this),this.options.interval)),this},b.prototype.getActiveIndex=function(){return this.$active=this.$element.find(".item.active"),this.$items=this.$active.parent().children(),this.$items.index(this.$active)},b.prototype.to=function(b){var c=this,d=this.getActiveIndex();return b>this.$items.length-1||0>b?void 0:this.sliding?this.$element.one("slid.bs.carousel",function(){c.to(b)}):d==b?this.pause().cycle():this.slide(b>d?"next":"prev",a(this.$items[b]))},b.prototype.pause=function(b){return b||(this.paused=!0),this.$element.find(".next, .prev").length&&a.support.transition&&(this.$element.trigger(a.support.transition.end),this.cycle(!0)),this.interval=clear
/* ===========================================================
* forked from bootstrap-confirmation.js
* http://ethaizone.github.io/Bootstrap-Confirmation/
* ===========================================================
* Copyright 2013 Nimit Suwannagate <ethaizone@hotmail.com>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =========================================================== */
!function ($) {
'use strict';
//var for check event at body can have only one.
var event_body = false;
// CONFIRMATION PUBLIC CLASS DEFINITION
// ===============================
var Confirmation = function (element, options) {
var that = this;
this.init('confirmation', element, options);
$(element).on('show.bs.confirmation', function(e) {
that.options.onShow(e, this);
$(this).addClass('open');
var options = that.options;
var all = options.all_selector;
if(options.singleton) {
$(all+'.in').not(that.$element).confirmation('hide');
}
});
$(element).on('hide.bs.confirmation', function(e) {
that.options.onHide(e, this);
$(this).removeClass('open');
});
$(element).on('shown.bs.confirmation', function(e) {
var options = that.options;
var all = options.all_selector;
that.$element.on('click.dismiss.bs.confirmation', '[data-dismiss="confirmation"]', $.proxy(that.hide, that));
if(that.isPopout()) {
if(!event_body) {
event_body = $('body').on('click', function (e) {
if(that.$element.is(e.target)) return;
if(that.$element.has(e.target).length) return;
if($('.popover').has(e.target).length) return;
that.$element.confirmation('hide');
$('body').unbind(e);
event_body = false;
return;
});
}
}
});
$(element).on('click', function(e) {
e.preventDefault();
});
}
if (!$.fn.popover || !$.fn.tooltip) throw new Error('Confirmation requires popover.js and tooltip.js');
Confirmation.DEFAULTS = $.extend({}, $.fn.popover.Constructor.DEFAULTS, {
placement : 'top',
title : 'Are you sure?',
btnOkClass : 'btn btn-danger btn-sm',
btnOkLabel : 'Yes',
btnOkIcon : '',
btnCancelClass : 'btn btn-default btn-sm',
btnCancelLabel : 'Cancel',
btnCancelIcon : '',
href : '#',
target : '_self',
singleton : true,
popout : true,
onShow : function(event, element){},
onHide : function(event, element){},
onConfirm : function(event, element){},
onCancel : function(event, element){},
template : '<div class="popover"><div class="arrow"></div>'
+ '<h3 class="popover-title"></h3>'
+ '<div class="popover-content">'
+ '<div class="btn-group"><a data-apply="confirmation">Yes</a>'
+ ' <a data-dismiss="confirmation">No</a></div>'
+ '</div>'
+ '</div>'
});
// NOTE: CONFIRMATION EXTENDS popover.js
// ================================
Confirmation.prototype = $.extend({}, $.fn.popover.Constructor.prototype);
Confirmation.prototype.constructor = Confirmation;
Confirmation.prototype.getDefaults = function () {
return Confirmation.DEFAULTS;
}
Confirmation.prototype.setContent = function () {
var that = this;
var $tip = this.tip();
var title = this.getTitle();
var $btnOk = $tip.find('[data-apply="confirmation"]');
var $btnCancel = $tip.find('[data-dismiss="confirmation"]');
var options = this.options
$btnOk.addClass(this.getBtnOkClass())
.html(this.getBtnOkLabel())
.prepend($('<i></i>').addClass(this.getBtnOkIcon()), " ")
.attr('href', this.getHref())
.attr('target', this.getTarget())
.off('click').on('click', function(event) {
options.onConfirm(event, that.$element);
that.$element.confirmation('hide');
});
$btnCancel.addClass(this.getBtnCancelClass())
.html(this.getBtnCancelLabel())
.prepend($('<i></i>').addClass(this.getBtnCancelIcon()), " ")
.off('click').on('click', function(event){
options.onCancel(event, that.$element);
that.$element.confirmation('hide');
});
$tip.find('.popover-title')[this.options.html ? 'html' : 'text'](title);
$tip.removeClass('fade top bottom left right in');
// IE8 doesn't accept hiding via the `:empty` pseudo selector, we have to do
// this manually by checking the contents.
if (!$tip.find('.popover-title').html()) $tip.find('.popover-title').hide();
}
Confirmation.prototype.getBtnOkClass = function () {
var $e = this.$element;
var o = this.options;
return $e.attr('data-btnOkClass') || (typeof o.btnOkClass == 'function' ? o.btnOkClass.call($e[0]) : o.btnOkClass);
}
Confirmation.prototype.getBtnOkLabel = function () {
var $e = this.$element;
var o = this.options;
return $e.attr('data-btnOkLabel') || (typeof o.btnOkLabel == 'function' ? o.btnOkLabel.call($e[0]) : o.btnOkLabel);
}
Confirmation.prototype.getBtnOkIcon = function () {
var $e = this.$element;
var o = this.options;
return $e.attr('data-btnOkIcon') || (typeof o.btnOkIcon == 'function' ? o.btnOkIcon.call($e[0]) : o.btnOkIcon);
}
Confirmation.prototype.getBtnCancelClass = function () {
var $e = this.$element;
var o = this.options;
return $e.attr('data-btnCancelClass') || (typeof o.btnCancelClass == 'function' ? o.btnCancelClass.call($e[0]) : o.btnCancelClass);
}
Confirmation.prototype.getBtnCancelLabel = function () {
var $e = this.$element;
var o = this.options;
return $e.attr('data-btnCancelLabel') || (typeof o.btnCancelLabel == 'function' ? o.btnCancelLabel.call($e[0]) : o.btnCancelLabel);
}
Confirmation.prototype.getBtnCancelIcon = function () {
var $e = this.$element;
var o = this.options;
return $e.attr('data-btnCancelIcon') || (typeof o.btnCancelIcon == 'function' ? o.btnCancelIcon.call($e[0]) : o.btnCancelIcon);
}
Confirmation.prototype.getHref = function () {
var $e = this.$element;
var o = this.options;
return $e.attr('data-href') || (typeof o.href == 'function' ? o.href.call($e[0]) : o.href);
}
Confirmation.prototype.getTarget = function () {
var $e = this.$element;
var o = this.options;
return $e.attr('data-target') || (typeof o.target == 'function' ? o.target.call($e[0]) : o.target);
}
Confirmation.prototype.isPopout = function () {
var popout;
var $e = this.$element;
var o = this.options;
popout = $e.attr('data-popout') || (typeof o.popout == 'function' ? o.popout.call($e[0]) : o.popout);
if(popout == 'false') popout = false;
return popout
}
// CONFIRMATION PLUGIN DEFINITION
// =========================
var old = $.fn.confirmation;
$.fn.confirmation = function (option) {
var that = this;
return this.each(function () {
var $this = $(this);
var data = $this.data('bs.confirmation');
var options = typeof option == 'object' && option;
options = options || {};
options.all_selector = that.selector;
if (!data && option == 'destroy') return;
if (!data) $this.data('bs.confirmation', (data = new Confirmation(this, options)));
if (typeof option == 'string') data[option]();
});
}
$.fn.confirmation.Constructor = Confirmation
// CONFIRMATION NO CONFLICT
// ===================
$.fn.confirmation.noConflict = function () {
$.fn.confirmation = old;
return this;
}
}(jQuery);