Remove JS libraries

This commit is contained in:
Gregory Trullemans 2024-05-01 14:20:09 +02:00
parent 0c4bdcc738
commit 8c46fd750d
15 changed files with 5 additions and 6590 deletions

View File

@ -212,7 +212,7 @@
<script src="https://cdn.datatables.net/2.0.5/js/dataTables.min.js" crossorigin="anonymous" referrerpolicy="no-referrer"></script> <script src="https://cdn.datatables.net/2.0.5/js/dataTables.min.js" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
<!-- Control Center for Black Dashboard: parallax effects, scripts for the example pages etc --> <!-- Control Center for Black Dashboard: parallax effects, scripts for the example pages etc -->
<script src="{% static "js/black-dashboard.js" %}"></script> <script src="{% static "js/core/black-dashboard.js" %}"></script>
<!-- Jquery UI for autocomplete, etc. --> <!-- Jquery UI for autocomplete, etc. -->
<!-- <script src="{% static "js/plugins/jqueryui/jquery-ui.min.js" %}"></script> --> <!-- <script src="{% static "js/plugins/jqueryui/jquery-ui.min.js" %}"></script> -->
<script src="https://code.jquery.com/ui/1.13.3/jquery-ui.min.js" integrity="sha256-sw0iNNXmOJbQhYFuC9OF2kOlD5KQKe1y5lfBn4C9Sjg=" crossorigin="anonymous"></script> <script src="https://code.jquery.com/ui/1.13.3/jquery-ui.min.js" integrity="sha256-sw0iNNXmOJbQhYFuC9OF2kOlD5KQKe1y5lfBn4C9Sjg=" crossorigin="anonymous"></script>

View File

@ -85,7 +85,7 @@
<!-- Forms Validations Plugin --> <!-- Forms Validations Plugin -->
<script src="{% static "js/plugins/jquery.validate_1.17.0.min.js" %}"></script> <script src="{% static "js/plugins/jquery.validate_1.17.0.min.js" %}"></script>
<!-- Control Center for Black Dashboard: parallax effects, scripts for the example pages etc --> <!-- Control Center for Black Dashboard: parallax effects, scripts for the example pages etc -->
<script src="{% static "js/black-dashboard.js" %}"></script> <script src="{% static "js/core/black-dashboard.js" %}"></script>
<!-- Jquery UI for autocomplete, etc. --> <!-- Jquery UI for autocomplete, etc. -->
<script src="https://code.jquery.com/ui/1.13.3/jquery-ui.min.js" integrity="sha256-sw0iNNXmOJbQhYFuC9OF2kOlD5KQKe1y5lfBn4C9Sjg=" crossorigin="anonymous"></script> <script src="https://code.jquery.com/ui/1.13.3/jquery-ui.min.js" integrity="sha256-sw0iNNXmOJbQhYFuC9OF2kOlD5KQKe1y5lfBn4C9Sjg=" crossorigin="anonymous"></script>

View File

@ -28,8 +28,9 @@
{% endblock %} {% endblock %}
{% block footerscript %} {% block footerscript %}
<script src="{% static "js/plugins/D3-dag/d3_7.9.0.min.js" %}"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/d3/7.9.0/d3.min.js" integrity="sha512-vc58qvvBdrDR4etbxMdlTt4GBQk1qjvyORR2nrsPsFPyrs+/u5c3+1Ct6upOgdZoIl7eq6k3a1UPDSNAQi/32A==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
<script src="{% static "js/plugins/D3-dag/d3-dag_0.11.1.min.js" %}"></script> <script src="https://cdn.jsdelivr.net/npm/d3-dag@0.11.1/bundle/d3-dag.iife.min.js" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
<script> <script>
function compute_font_size(string) function compute_font_size(string)
{ {

View File

@ -1,432 +0,0 @@
"use strict";
/*!
=========================================================
* Black Dashboard Pro - v1.1.1
=========================================================
* Product Page: https://themes.getbootstrap.com/product/black-dashboard-pro-premium-bootstrap-4-admin/
* Copyright 2019 Creative Tim (https://www.creative-tim.com)
* Coded by Creative Tim
=========================================================
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
*/
var transparent = true;
var transparentDemo = true;
var fixedTop = false;
var navbar_initialized = false;
var backgroundOrange = false;
var sidebar_mini_active = false;
var toggle_initialized = false;
var $html = $('html');
var $body = $('body');
var $navbar_minimize_fixed = $('.navbar-minimize-fixed');
var $collapse = $('.collapse');
var $navbar = $('.navbar');
var $tagsinput = $('.tagsinput');
var $selectpicker = $('.selectpicker');
var $navbar_color = $('.navbar[color-on-scroll]');
var $full_screen_map = $('.full-screen-map');
var $datetimepicker = $('.datetimepicker');
var $datepicker = $('.datepicker');
var $timepicker = $('.timepicker');
var seq = 0,
delays = 80,
durations = 500;
var seq2 = 0,
delays2 = 80,
durations2 = 500;
// Returns a function, that, as long as it continues to be invoked, will not
// be triggered. The function will be called after it stops being called for
// N milliseconds. If `immediate` is passed, trigger the function on the
// leading edge, instead of the trailing.
function debounce(func, wait, immediate) {
var timeout;
return function() {
var context = this,
args = arguments;
clearTimeout(timeout);
timeout = setTimeout(function() {
timeout = null;
if (!immediate) func.apply(context, args);
}, wait);
if (immediate && !timeout) func.apply(context, args);
};
};
(function() {
var isWindows = navigator.platform.indexOf('Win') > -1 ? true : false;
if (isWindows) {
// if we are on windows OS we activate the perfectScrollbar function
if ($('.main-panel').length != 0) {
var ps = new PerfectScrollbar('.main-panel', {
wheelSpeed: 2,
wheelPropagation: true,
minScrollbarLength: 20,
suppressScrollX: true
});
}
if ($('.sidebar .sidebar-wrapper').length != 0) {
var ps1 = new PerfectScrollbar('.sidebar .sidebar-wrapper');
$('.table-responsive').each(function() {
var ps2 = new PerfectScrollbar($(this)[0]);
});
}
$html.addClass('perfect-scrollbar-on');
} else {
$html.addClass('perfect-scrollbar-off');
}
})();
$(document).ready(function() {
var scroll_start = 0;
var startchange = $('.row');
var offset = startchange.offset();
var scrollElement = navigator.platform.indexOf('Win') > -1 ? $(".ps") : $(window);
scrollElement.scroll(function() {
scroll_start = $(this).scrollTop();
if (scroll_start > 50) {
$navbar_minimize_fixed.css('opacity', '1');
} else {
$navbar_minimize_fixed.css('opacity', '0');
}
});
// hide the siblings opened collapse
$collapse.on('show.bs.collapse', function() {
$(this).parent().siblings().children('.collapse').each(function() {
$(this).collapse('hide');
});
});
// Activate the Tooltips
$('[data-toggle="tooltip"], [rel="tooltip"]').tooltip();
// Activate Popovers and set color for popovers
$('[data-toggle="popover"]').each(function() {
color_class = $(this).data('color');
$(this).popover({
template: '<div class="popover popover-' + color_class + '" role="tooltip"><div class="arrow"></div><h3 class="popover-header"></h3><div class="popover-body"></div></div>'
});
});
var tagClass = $tagsinput.data('color');
if ($tagsinput.length != 0) {
$tagsinput.tagsinput();
}
$('.bootstrap-tagsinput').find('.tag').addClass('badge-' + tagClass);
// Activate bootstrap-select
if ($selectpicker.length != 0) {
$selectpicker.selectpicker({
iconBase: "tim-icons",
tickIcon: "icon-check-2"
});
}
//when you click the modal search button the navbar will not be collapsed
$("#search-button").click(function() {
$(this).closest('.navbar-collapse').removeClass('show');
$navbar.addClass('navbar-transparent').removeClass('bg-white');
$('#inlineFormInputGroup').focus();
});
blackDashboard.initMinimizeSidebar();
var scroll_distance = $navbar_color.attr('color-on-scroll') || 500;
// Check if we have the class "navbar-color-on-scroll" then add the function to remove the class "navbar-transparent" so it will transform to a plain color.
if ($navbar_color.length != 0) {
blackDashboard.checkScrollForTransparentNavbar();
$(window).on('scroll', blackDashboard.checkScrollForTransparentNavbar)
}
if ($full_screen_map.length == 0 && $('.bd-docs').length == 0) {
// On click navbar-collapse the menu will be white not transparent
$('.navbar-toggler').click(function() {
$collapse.on('show.bs.collapse', function() {
$(this).closest('.navbar').removeClass('navbar-transparent').addClass('bg-white');
}).on('hide.bs.collapse', function() {
$(this).closest('.navbar').addClass('navbar-transparent').removeClass('bg-white');
});
$navbar.css('transition', '');
});
}
$navbar.css({
'top': '0',
'transition': 'all .5s linear'
});
$('.form-control').on("focus", function() {
$(this).parent('.input-group').addClass("input-group-focus");
}).on("blur", function() {
$(this).parent(".input-group").removeClass("input-group-focus");
});
// Activate bootstrapSwitch
$('.bootstrap-switch').each(function() {
var data_on_label = $(this).data('on-label') || '';
var data_off_label = $(this).data('off-label') || '';
$(this).bootstrapSwitch({
onText: data_on_label,
offText: data_off_label
});
});
});
$(document).on('click', '.navbar-toggle', function() {
var $toggle = $(this);
if (blackDashboard.misc.navbar_menu_visible == 1) {
$html.removeClass('nav-open');
blackDashboard.misc.navbar_menu_visible = 0;
setTimeout(function() {
$toggle.removeClass('toggled');
$('.bodyClick').remove();
}, 550);
} else {
setTimeout(function() {
$toggle.addClass('toggled');
}, 580);
var div = '<div class="bodyClick"></div>';
$(div).appendTo('body').click(function() {
$html.removeClass('nav-open');
blackDashboard.misc.navbar_menu_visible = 0;
setTimeout(function() {
$toggle.removeClass('toggled');
$('.bodyClick').remove();
}, 550);
});
$html.addClass('nav-open');
blackDashboard.misc.navbar_menu_visible = 1;
}
});
$(window).resize(function() {
// reset the seq for charts drawing animations
seq = seq2 = 0;
if ($full_screen_map.length == 0 && $('.bd-docs').length == 0) {
var isExpanded = $navbar.find('[data-toggle="collapse"]').attr("aria-expanded");
if ($navbar.hasClass('bg-white') && $(window).width() > 991) {
$navbar.removeClass('bg-white').addClass('navbar-transparent');
} else if ($navbar.hasClass('navbar-transparent') && $(window).width() < 991 && isExpanded != "false") {
$navbar.addClass('bg-white').removeClass('navbar-transparent');
}
}
});
var blackDashboard = {
misc: {
navbar_menu_visible: 0
},
checkScrollForTransparentNavbar: debounce(function() {
if ($(document).scrollTop() > scroll_distance) {
if (transparent) {
transparent = false;
$navbar_color.removeClass('navbar-transparent');
}
} else {
if (!transparent) {
transparent = true;
$navbar_color.addClass('navbar-transparent');
}
}
}, 17),
// Activate DateTimePicker
initDateTimePicker: function() {
if ($datetimepicker.length != 0) {
$datetimepicker.datetimepicker({
format: 'YYYY-MM-DD H:mm',
icons: {
time: "tim-icons icon-watch-time",
date: "tim-icons icon-calendar-60",
up: "fa fa-chevron-up",
down: "fa fa-chevron-down",
previous: 'tim-icons icon-minimal-left',
next: 'tim-icons icon-minimal-right',
today: 'fa fa-screenshot',
clear: 'fa fa-trash',
close: 'fa fa-remove'
}
});
}
if ($datepicker.length != 0) {
$datepicker.datetimepicker({
format: 'YYYY-MM-DD',
icons: {
time: "tim-icons icon-watch-time",
date: "tim-icons icon-calendar-60",
up: "fa fa-chevron-up",
down: "fa fa-chevron-down",
previous: 'tim-icons icon-minimal-left',
next: 'tim-icons icon-minimal-right',
today: 'fa fa-screenshot',
clear: 'fa fa-trash',
close: 'fa fa-remove'
}
});
}
if ($timepicker.length != 0) {
$timepicker.datetimepicker({
format: 'H:mm', // use this format if you want the 24hours timepicker
// format: 'h:mm A', //use this format if you want the 12hours timpiecker with AM/PM toggle
icons: {
time: "tim-icons icon-watch-time",
date: "tim-icons icon-calendar-60",
up: "fa fa-chevron-up",
down: "fa fa-chevron-down",
previous: 'tim-icons icon-minimal-left',
next: 'tim-icons icon-minimal-right',
today: 'fa fa-screenshot',
clear: 'fa fa-trash',
close: 'fa fa-remove'
}
});
}
},
initMinimizeSidebar: function() {
if ($('.sidebar-mini').length != 0) {
sidebar_mini_active = true;
}
$('.minimize-sidebar').click(function() {
if (sidebar_mini_active == true) {
$body.removeClass('sidebar-mini');
sidebar_mini_active = false;
blackDashboard.showSidebarMessage('Sidebar mini deactivated...');
} else {
$body.addClass('sidebar-mini');
sidebar_mini_active = true;
blackDashboard.showSidebarMessage('Sidebar mini activated...');
}
// we simulate the window Resize so the charts will get updated in realtime.
var simulateWindowResize = setInterval(function() {
window.dispatchEvent(new Event('resize'));
}, 180);
// we stop the simulation of Window Resize after the animations are completed
setTimeout(function() {
clearInterval(simulateWindowResize);
}, 1000);
});
},
startAnimationForLineChart: function(chart) {
chart.on('draw', function(data) {
if (data.type === 'line' || data.type === 'area') {
data.element.animate({
d: {
begin: 600,
dur: 700,
from: data.path.clone().scale(1, 0).translate(0, data.chartRect.height()).stringify(),
to: data.path.clone().stringify(),
easing: Chartist.Svg.Easing.easeOutQuint
}
});
} else if (data.type === 'point') {
seq++;
data.element.animate({
opacity: {
begin: seq * delays,
dur: durations,
from: 0,
to: 1,
easing: 'ease'
}
});
}
});
seq = 0;
},
startAnimationForBarChart: function(chart) {
chart.on('draw', function(data) {
if (data.type === 'bar') {
seq2++;
data.element.animate({
opacity: {
begin: seq2 * delays2,
dur: durations2,
from: 0,
to: 1,
easing: 'ease'
}
});
}
});
seq2 = 0;
},
showSidebarMessage: function(message) {
try {
$.notify({
icon: "tim-icons icon-bell-55",
message: message
}, {
type: 'primary',
timer: 4000,
placement: {
from: 'top',
align: 'right'
}
});
} catch (e) {
console.log('Notify library is missing, please make sure you have the notifications library added.');
}
}
};
function hexToRGB(hex, alpha) {
var r = parseInt(hex.slice(1, 3), 16),
g = parseInt(hex.slice(3, 5), 16),
b = parseInt(hex.slice(5, 7), 16);
if (alpha) {
return "rgba(" + r + ", " + g + ", " + b + ", " + alpha + ")";
} else {
return "rgb(" + r + ", " + g + ", " + b + ")";
}
}

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -1,432 +0,0 @@
/*
Creative Tim Modifications
Lines: 238, 239 was changed from top: 5px to top: 50% and we added margin-top: -13px. In this way the close button will be aligned vertically
Line:222 - modified when the icon is set, we add the class "alert-with-icon", so there will be enough space for the icon.
*/
/*
* Project: Bootstrap Notify = v3.1.5
* Description: Turns standard Bootstrap alerts into "Growl-like" notifications.
* Author: Mouse0270 aka Robert McIntosh
* License: MIT License
* Website: https://github.com/mouse0270/bootstrap-growl
*/
/* global define:false, require: false, jQuery:false */
(function(factory) {
if (typeof define === 'function' && define.amd) {
// AMD. Register as an anonymous module.
define(['jquery'], factory);
} else if (typeof exports === 'object') {
// Node/CommonJS
factory(require('jquery'));
} else {
// Browser globals
factory(jQuery);
}
}(function($) {
// Create the defaults once
var defaults = {
element: 'body',
position: null,
type: "info",
allow_dismiss: true,
allow_duplicates: true,
newest_on_top: false,
showProgressbar: false,
placement: {
from: "top",
align: "right"
},
offset: 20,
spacing: 10,
z_index: 1060,
delay: 5000,
timer: 1000,
url_target: '_blank',
mouse_over: null,
animate: {
enter: 'animated fadeInDown',
exit: 'animated fadeOutUp'
},
onShow: null,
onShown: null,
onClose: null,
onClosed: null,
onClick: null,
icon_type: 'class',
template: '<div data-notify="container" class="col-11 col-md-4 alert alert-{0}" role="alert"><button type="button" aria-hidden="true" class="close" data-notify="dismiss"><i class="tim-icons icon-simple-remove"></i></button><span data-notify="icon"></span> <span data-notify="title">{1}</span> <span data-notify="message">{2}</span><div class="progress" data-notify="progressbar"><div class="progress-bar progress-bar-{0}" role="progressbar" aria-valuenow="0" aria-valuemin="0" aria-valuemax="100" style="width: 0%;"></div></div><a href="{3}" target="{4}" data-notify="url"></a></div>'
};
String.format = function() {
var args = arguments;
var str = arguments[0];
return str.replace(/(\{\{\d\}\}|\{\d\})/g, function(str) {
if (str.substring(0, 2) === "{{") return str;
var num = parseInt(str.match(/\d/)[0]);
return args[num + 1];
});
};
function isDuplicateNotification(notification) {
var isDupe = false;
$('[data-notify="container"]').each(function(i, el) {
var $el = $(el);
var title = $el.find('[data-notify="title"]').html().trim();
var message = $el.find('[data-notify="message"]').html().trim();
// The input string might be different than the actual parsed HTML string!
// (<br> vs <br /> for example)
// So we have to force-parse this as HTML here!
var isSameTitle = title === $("<div>" + notification.settings.content.title + "</div>").html().trim();
var isSameMsg = message === $("<div>" + notification.settings.content.message + "</div>").html().trim();
var isSameType = $el.hasClass('alert-' + notification.settings.type);
if (isSameTitle && isSameMsg && isSameType) {
//we found the dupe. Set the var and stop checking.
isDupe = true;
}
return !isDupe;
});
return isDupe;
}
function Notify(element, content, options) {
// Setup Content of Notify
var contentObj = {
content: {
message: typeof content === 'object' ? content.message : content,
title: content.title ? content.title : '',
icon: content.icon ? content.icon : '',
url: content.url ? content.url : '#',
target: content.target ? content.target : '-'
}
};
options = $.extend(true, {}, contentObj, options);
this.settings = $.extend(true, {}, defaults, options);
this._defaults = defaults;
if (this.settings.content.target === "-") {
this.settings.content.target = this.settings.url_target;
}
this.animations = {
start: 'webkitAnimationStart oanimationstart MSAnimationStart animationstart',
end: 'webkitAnimationEnd oanimationend MSAnimationEnd animationend'
};
if (typeof this.settings.offset === 'number') {
this.settings.offset = {
x: this.settings.offset,
y: this.settings.offset
};
}
//if duplicate messages are not allowed, then only continue if this new message is not a duplicate of one that it already showing
if (this.settings.allow_duplicates || (!this.settings.allow_duplicates && !isDuplicateNotification(this))) {
this.init();
}
}
$.extend(Notify.prototype, {
init: function() {
var self = this;
this.buildNotify();
if (this.settings.content.icon) {
this.setIcon();
}
if (this.settings.content.url != "#") {
this.styleURL();
}
this.styleDismiss();
this.placement();
this.bind();
this.notify = {
$ele: this.$ele,
update: function(command, update) {
var commands = {};
if (typeof command === "string") {
commands[command] = update;
} else {
commands = command;
}
for (var cmd in commands) {
switch (cmd) {
case "type":
this.$ele.removeClass('alert-' + self.settings.type);
this.$ele.find('[data-notify="progressbar"] > .progress-bar').removeClass('progress-bar-' + self.settings.type);
self.settings.type = commands[cmd];
this.$ele.addClass('alert-' + commands[cmd]).find('[data-notify="progressbar"] > .progress-bar').addClass('progress-bar-' + commands[cmd]);
break;
case "icon":
var $icon = this.$ele.find('[data-notify="icon"]');
if (self.settings.icon_type.toLowerCase() === 'class') {
$icon.removeClass(self.settings.content.icon).addClass(commands[cmd]);
} else {
if (!$icon.is('img')) {
$icon.find('img');
}
$icon.attr('src', commands[cmd]);
}
self.settings.content.icon = commands[command];
break;
case "progress":
var newDelay = self.settings.delay - (self.settings.delay * (commands[cmd] / 100));
this.$ele.data('notify-delay', newDelay);
this.$ele.find('[data-notify="progressbar"] > div').attr('aria-valuenow', commands[cmd]).css('width', commands[cmd] + '%');
break;
case "url":
this.$ele.find('[data-notify="url"]').attr('href', commands[cmd]);
break;
case "target":
this.$ele.find('[data-notify="url"]').attr('target', commands[cmd]);
break;
default:
this.$ele.find('[data-notify="' + cmd + '"]').html(commands[cmd]);
}
}
var posX = this.$ele.outerHeight() + parseInt(self.settings.spacing) + parseInt(self.settings.offset.y);
self.reposition(posX);
},
close: function() {
self.close();
}
};
},
buildNotify: function() {
var content = this.settings.content;
this.$ele = $(String.format(this.settings.template, this.settings.type, content.title, content.message, content.url, content.target));
this.$ele.attr('data-notify-position', this.settings.placement.from + '-' + this.settings.placement.align);
if (!this.settings.allow_dismiss) {
this.$ele.find('[data-notify="dismiss"]').css('display', 'none');
}
if ((this.settings.delay <= 0 && !this.settings.showProgressbar) || !this.settings.showProgressbar) {
this.$ele.find('[data-notify="progressbar"]').remove();
}
},
setIcon: function() {
this.$ele.addClass('alert-with-icon');
if (this.settings.icon_type.toLowerCase() === 'class') {
this.$ele.find('[data-notify="icon"]').addClass(this.settings.content.icon);
} else {
if (this.$ele.find('[data-notify="icon"]').is('img')) {
this.$ele.find('[data-notify="icon"]').attr('src', this.settings.content.icon);
} else {
this.$ele.find('[data-notify="icon"]').append('<img src="' + this.settings.content.icon + '" alt="Notify Icon" />');
}
}
},
styleDismiss: function() {
this.$ele.find('[data-notify="dismiss"]').css({
position: 'absolute',
right: '10px',
top: '50%',
marginTop: '-13px',
zIndex: this.settings.z_index + 2
});
},
styleURL: function() {
this.$ele.find('[data-notify="url"]').css({
backgroundImage: 'url(data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7)',
height: '100%',
left: 0,
position: 'absolute',
top: 0,
width: '100%',
zIndex: this.settings.z_index + 1
});
},
placement: function() {
var self = this,
offsetAmt = this.settings.offset.y,
css = {
display: 'inline-block',
margin: '0px auto',
position: this.settings.position ? this.settings.position : (this.settings.element === 'body' ? 'fixed' : 'absolute'),
transition: 'all .5s ease-in-out',
zIndex: this.settings.z_index
},
hasAnimation = false,
settings = this.settings;
$('[data-notify-position="' + this.settings.placement.from + '-' + this.settings.placement.align + '"]:not([data-closing="true"])').each(function() {
offsetAmt = Math.max(offsetAmt, parseInt($(this).css(settings.placement.from)) + parseInt($(this).outerHeight()) + parseInt(settings.spacing));
});
if (this.settings.newest_on_top === true) {
offsetAmt = this.settings.offset.y;
}
css[this.settings.placement.from] = offsetAmt + 'px';
switch (this.settings.placement.align) {
case "left":
case "right":
css[this.settings.placement.align] = this.settings.offset.x + 'px';
break;
case "center":
css.left = 0;
css.right = 0;
break;
}
this.$ele.css(css).addClass(this.settings.animate.enter);
$.each(Array('webkit-', 'moz-', 'o-', 'ms-', ''), function(index, prefix) {
self.$ele[0].style[prefix + 'AnimationIterationCount'] = 1;
});
$(this.settings.element).append(this.$ele);
if (this.settings.newest_on_top === true) {
offsetAmt = (parseInt(offsetAmt) + parseInt(this.settings.spacing)) + this.$ele.outerHeight();
this.reposition(offsetAmt);
}
if ($.isFunction(self.settings.onShow)) {
self.settings.onShow.call(this.$ele);
}
this.$ele.one(this.animations.start, function() {
hasAnimation = true;
}).one(this.animations.end, function() {
self.$ele.removeClass(self.settings.animate.enter);
if ($.isFunction(self.settings.onShown)) {
self.settings.onShown.call(this);
}
});
setTimeout(function() {
if (!hasAnimation) {
if ($.isFunction(self.settings.onShown)) {
self.settings.onShown.call(this);
}
}
}, 600);
},
bind: function() {
var self = this;
this.$ele.find('[data-notify="dismiss"]').on('click', function() {
self.close();
});
if ($.isFunction(self.settings.onClick)) {
this.$ele.on('click', function(event) {
if (event.target != self.$ele.find('[data-notify="dismiss"]')[0]) {
self.settings.onClick.call(this, event);
}
});
}
this.$ele.mouseover(function() {
$(this).data('data-hover', "true");
}).mouseout(function() {
$(this).data('data-hover', "false");
});
this.$ele.data('data-hover', "false");
if (this.settings.delay > 0) {
self.$ele.data('notify-delay', self.settings.delay);
var timer = setInterval(function() {
var delay = parseInt(self.$ele.data('notify-delay')) - self.settings.timer;
if ((self.$ele.data('data-hover') === 'false' && self.settings.mouse_over === "pause") || self.settings.mouse_over != "pause") {
var percent = ((self.settings.delay - delay) / self.settings.delay) * 100;
self.$ele.data('notify-delay', delay);
self.$ele.find('[data-notify="progressbar"] > div').attr('aria-valuenow', percent).css('width', percent + '%');
}
if (delay <= -(self.settings.timer)) {
clearInterval(timer);
self.close();
}
}, self.settings.timer);
}
},
close: function() {
var self = this,
posX = parseInt(this.$ele.css(this.settings.placement.from)),
hasAnimation = false;
this.$ele.attr('data-closing', 'true').addClass(this.settings.animate.exit);
self.reposition(posX);
if ($.isFunction(self.settings.onClose)) {
self.settings.onClose.call(this.$ele);
}
this.$ele.one(this.animations.start, function() {
hasAnimation = true;
}).one(this.animations.end, function() {
$(this).remove();
if ($.isFunction(self.settings.onClosed)) {
self.settings.onClosed.call(this);
}
});
setTimeout(function() {
if (!hasAnimation) {
self.$ele.remove();
if (self.settings.onClosed) {
self.settings.onClosed(self.$ele);
}
}
}, 600);
},
reposition: function(posX) {
var self = this,
notifies = '[data-notify-position="' + this.settings.placement.from + '-' + this.settings.placement.align + '"]:not([data-closing="true"])',
$elements = this.$ele.nextAll(notifies);
if (this.settings.newest_on_top === true) {
$elements = this.$ele.prevAll(notifies);
}
$elements.each(function() {
$(this).css(self.settings.placement.from, posX);
posX = (parseInt(posX) + parseInt(self.settings.spacing)) + $(this).outerHeight();
});
}
});
$.notify = function(content, options) {
var plugin = new Notify(this, content, options);
return plugin.notify;
};
$.notifyDefaults = function(options) {
defaults = $.extend(true, {}, defaults, options);
return defaults;
};
$.notifyClose = function(selector) {
if (typeof selector === "undefined" || selector === "all") {
$('[data-notify]').find('[data-notify="dismiss"]').trigger('click');
} else if (selector === 'success' || selector === 'info' || selector === 'warning' || selector === 'danger') {
$('.alert-' + selector + '[data-notify]').find('[data-notify="dismiss"]').trigger('click');
} else if (selector) {
$(selector + '[data-notify]').find('[data-notify="dismiss"]').trigger('click');
} else {
$('[data-notify-position="' + selector + '"]').find('[data-notify="dismiss"]').trigger('click');
}
};
$.notifyCloseExcept = function(selector) {
if (selector === 'success' || selector === 'info' || selector === 'warning' || selector === 'danger') {
$('[data-notify]').not('.alert-' + selector).find('[data-notify="dismiss"]').trigger('click');
} else {
$('[data-notify]').not(selector).find('[data-notify="dismiss"]').trigger('click');
}
};
}));

View File

@ -1,786 +0,0 @@
/**
* bootstrap-switch - Turn checkboxes and radio buttons into toggle switches.
*
* @version v3.3.4
* @homepage https://bttstrp.github.io/bootstrap-switch
* @author Mattia Larentis <mattia@larentis.eu> (http://larentis.eu)
* @license Apache-2.0
*/
(function(global, factory) {
if (typeof define === "function" && define.amd) {
define(['jquery'], factory);
} else if (typeof exports !== "undefined") {
factory(require('jquery'));
} else {
var mod = {
exports: {}
};
factory(global.jquery);
global.bootstrapSwitch = mod.exports;
}
})(this, function(_jquery) {
'use strict';
var _jquery2 = _interopRequireDefault(_jquery);
function _interopRequireDefault(obj) {
return obj && obj.__esModule ? obj : {
default: obj
};
}
var _extends = Object.assign || function(target) {
for (var i = 1; i < arguments.length; i++) {
var source = arguments[i];
for (var key in source) {
if (Object.prototype.hasOwnProperty.call(source, key)) {
target[key] = source[key];
}
}
}
return target;
};
function _classCallCheck(instance, Constructor) {
if (!(instance instanceof Constructor)) {
throw new TypeError("Cannot call a class as a function");
}
}
var _createClass = function() {
function defineProperties(target, props) {
for (var i = 0; i < props.length; i++) {
var descriptor = props[i];
descriptor.enumerable = descriptor.enumerable || false;
descriptor.configurable = true;
if ("value" in descriptor) descriptor.writable = true;
Object.defineProperty(target, descriptor.key, descriptor);
}
}
return function(Constructor, protoProps, staticProps) {
if (protoProps) defineProperties(Constructor.prototype, protoProps);
if (staticProps) defineProperties(Constructor, staticProps);
return Constructor;
};
}();
var $ = _jquery2.default || window.jQuery || window.$;
var BootstrapSwitch = function() {
function BootstrapSwitch(element) {
var _this = this;
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
_classCallCheck(this, BootstrapSwitch);
this.$element = $(element);
this.options = $.extend({}, $.fn.bootstrapSwitch.defaults, this._getElementOptions(), options);
this.prevOptions = {};
this.$wrapper = $('<div>', {
class: function _class() {
var classes = [];
classes.push(_this.options.state ? 'on' : 'off');
if (_this.options.size) {
classes.push(_this.options.size);
}
if (_this.options.disabled) {
classes.push('disabled');
}
if (_this.options.readonly) {
classes.push('readonly');
}
if (_this.options.indeterminate) {
classes.push('indeterminate');
}
if (_this.options.inverse) {
classes.push('inverse');
}
if (_this.$element.attr('id')) {
classes.push('id-' + _this.$element.attr('id'));
}
return classes.map(_this._getClass.bind(_this)).concat([_this.options.baseClass], _this._getClasses(_this.options.wrapperClass)).join(' ');
}
});
this.$container = $('<div>', {
class: this._getClass('container')
});
this.$on = $('<span>', {
html: this.options.onText,
class: this._getClass('handle-on') + ' ' + this._getClass(this.options.onColor)
});
this.$off = $('<span>', {
html: this.options.offText,
class: this._getClass('handle-off') + ' ' + this._getClass(this.options.offColor)
});
this.$label = $('<span>', {
html: this.options.labelText,
class: this._getClass('label')
});
this.$element.on('init.bootstrapSwitch', this.options.onInit.bind(this, element));
this.$element.on('switchChange.bootstrapSwitch', function() {
for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
args[_key] = arguments[_key];
}
if (_this.options.onSwitchChange.apply(element, args) === false) {
if (_this.$element.is(':radio')) {
$('[name="' + _this.$element.attr('name') + '"]').trigger('previousState.bootstrapSwitch', true);
} else {
_this.$element.trigger('previousState.bootstrapSwitch', true);
}
}
});
this.$container = this.$element.wrap(this.$container).parent();
this.$wrapper = this.$container.wrap(this.$wrapper).parent();
this.$element.before(this.options.inverse ? this.$off : this.$on).before(this.$label).before(this.options.inverse ? this.$on : this.$off);
if (this.options.indeterminate) {
this.$element.prop('indeterminate', true);
}
this._init();
this._elementHandlers();
this._handleHandlers();
this._labelHandlers();
this._formHandler();
this._externalLabelHandler();
this.$element.trigger('init.bootstrapSwitch', this.options.state);
}
_createClass(BootstrapSwitch, [{
key: 'setPrevOptions',
value: function setPrevOptions() {
this.prevOptions = _extends({}, this.options);
}
}, {
key: 'state',
value: function state(value, skip) {
if (typeof value === 'undefined') {
return this.options.state;
}
if (this.options.disabled || this.options.readonly || this.options.state && !this.options.radioAllOff && this.$element.is(':radio')) {
return this.$element;
}
if (this.$element.is(':radio')) {
$('[name="' + this.$element.attr('name') + '"]').trigger('setPreviousOptions.bootstrapSwitch');
} else {
this.$element.trigger('setPreviousOptions.bootstrapSwitch');
}
if (this.options.indeterminate) {
this.indeterminate(false);
}
this.$element.prop('checked', Boolean(value)).trigger('change.bootstrapSwitch', skip);
return this.$element;
}
}, {
key: 'toggleState',
value: function toggleState(skip) {
if (this.options.disabled || this.options.readonly) {
return this.$element;
}
if (this.options.indeterminate) {
this.indeterminate(false);
return this.state(true);
} else {
return this.$element.prop('checked', !this.options.state).trigger('change.bootstrapSwitch', skip);
}
}
}, {
key: 'size',
value: function size(value) {
if (typeof value === 'undefined') {
return this.options.size;
}
if (this.options.size != null) {
this.$wrapper.removeClass(this._getClass(this.options.size));
}
if (value) {
this.$wrapper.addClass(this._getClass(value));
}
this._width();
this._containerPosition();
this.options.size = value;
return this.$element;
}
}, {
key: 'animate',
value: function animate(value) {
if (typeof value === 'undefined') {
return this.options.animate;
}
if (this.options.animate === Boolean(value)) {
return this.$element;
}
return this.toggleAnimate();
}
}, {
key: 'toggleAnimate',
value: function toggleAnimate() {
this.options.animate = !this.options.animate;
this.$wrapper.toggleClass(this._getClass('animate'));
return this.$element;
}
}, {
key: 'disabled',
value: function disabled(value) {
if (typeof value === 'undefined') {
return this.options.disabled;
}
if (this.options.disabled === Boolean(value)) {
return this.$element;
}
return this.toggleDisabled();
}
}, {
key: 'toggleDisabled',
value: function toggleDisabled() {
this.options.disabled = !this.options.disabled;
this.$element.prop('disabled', this.options.disabled);
this.$wrapper.toggleClass(this._getClass('disabled'));
return this.$element;
}
}, {
key: 'readonly',
value: function readonly(value) {
if (typeof value === 'undefined') {
return this.options.readonly;
}
if (this.options.readonly === Boolean(value)) {
return this.$element;
}
return this.toggleReadonly();
}
}, {
key: 'toggleReadonly',
value: function toggleReadonly() {
this.options.readonly = !this.options.readonly;
this.$element.prop('readonly', this.options.readonly);
this.$wrapper.toggleClass(this._getClass('readonly'));
return this.$element;
}
}, {
key: 'indeterminate',
value: function indeterminate(value) {
if (typeof value === 'undefined') {
return this.options.indeterminate;
}
if (this.options.indeterminate === Boolean(value)) {
return this.$element;
}
return this.toggleIndeterminate();
}
}, {
key: 'toggleIndeterminate',
value: function toggleIndeterminate() {
this.options.indeterminate = !this.options.indeterminate;
this.$element.prop('indeterminate', this.options.indeterminate);
this.$wrapper.toggleClass(this._getClass('indeterminate'));
this._containerPosition();
return this.$element;
}
}, {
key: 'inverse',
value: function inverse(value) {
if (typeof value === 'undefined') {
return this.options.inverse;
}
if (this.options.inverse === Boolean(value)) {
return this.$element;
}
return this.toggleInverse();
}
}, {
key: 'toggleInverse',
value: function toggleInverse() {
this.$wrapper.toggleClass(this._getClass('inverse'));
var $on = this.$on.clone(true);
var $off = this.$off.clone(true);
this.$on.replaceWith($off);
this.$off.replaceWith($on);
this.$on = $off;
this.$off = $on;
this.options.inverse = !this.options.inverse;
return this.$element;
}
}, {
key: 'onColor',
value: function onColor(value) {
if (typeof value === 'undefined') {
return this.options.onColor;
}
if (this.options.onColor) {
this.$on.removeClass(this._getClass(this.options.onColor));
}
this.$on.addClass(this._getClass(value));
this.options.onColor = value;
return this.$element;
}
}, {
key: 'offColor',
value: function offColor(value) {
if (typeof value === 'undefined') {
return this.options.offColor;
}
if (this.options.offColor) {
this.$off.removeClass(this._getClass(this.options.offColor));
}
this.$off.addClass(this._getClass(value));
this.options.offColor = value;
return this.$element;
}
}, {
key: 'onText',
value: function onText(value) {
if (typeof value === 'undefined') {
return this.options.onText;
}
this.$on.html(value);
this._width();
this._containerPosition();
this.options.onText = value;
return this.$element;
}
}, {
key: 'offText',
value: function offText(value) {
if (typeof value === 'undefined') {
return this.options.offText;
}
this.$off.html(value);
this._width();
this._containerPosition();
this.options.offText = value;
return this.$element;
}
}, {
key: 'labelText',
value: function labelText(value) {
if (typeof value === 'undefined') {
return this.options.labelText;
}
this.$label.html(value);
this._width();
this.options.labelText = value;
return this.$element;
}
}, {
key: 'handleWidth',
value: function handleWidth(value) {
if (typeof value === 'undefined') {
return this.options.handleWidth;
}
this.options.handleWidth = value;
this._width();
this._containerPosition();
return this.$element;
}
}, {
key: 'labelWidth',
value: function labelWidth(value) {
if (typeof value === 'undefined') {
return this.options.labelWidth;
}
this.options.labelWidth = value;
this._width();
this._containerPosition();
return this.$element;
}
}, {
key: 'baseClass',
value: function baseClass(value) {
return this.options.baseClass;
}
}, {
key: 'wrapperClass',
value: function wrapperClass(value) {
if (typeof value === 'undefined') {
return this.options.wrapperClass;
}
if (!value) {
value = $.fn.bootstrapSwitch.defaults.wrapperClass;
}
this.$wrapper.removeClass(this._getClasses(this.options.wrapperClass).join(' '));
this.$wrapper.addClass(this._getClasses(value).join(' '));
this.options.wrapperClass = value;
return this.$element;
}
}, {
key: 'radioAllOff',
value: function radioAllOff(value) {
if (typeof value === 'undefined') {
return this.options.radioAllOff;
}
var val = Boolean(value);
if (this.options.radioAllOff === val) {
return this.$element;
}
this.options.radioAllOff = val;
return this.$element;
}
}, {
key: 'onInit',
value: function onInit(value) {
if (typeof value === 'undefined') {
return this.options.onInit;
}
if (!value) {
value = $.fn.bootstrapSwitch.defaults.onInit;
}
this.options.onInit = value;
return this.$element;
}
}, {
key: 'onSwitchChange',
value: function onSwitchChange(value) {
if (typeof value === 'undefined') {
return this.options.onSwitchChange;
}
if (!value) {
value = $.fn.bootstrapSwitch.defaults.onSwitchChange;
}
this.options.onSwitchChange = value;
return this.$element;
}
}, {
key: 'destroy',
value: function destroy() {
var $form = this.$element.closest('form');
if ($form.length) {
$form.off('reset.bootstrapSwitch').removeData('bootstrap-switch');
}
this.$container.children().not(this.$element).remove();
this.$element.unwrap().unwrap().off('.bootstrapSwitch').removeData('bootstrap-switch');
return this.$element;
}
}, {
key: '_getElementOptions',
value: function _getElementOptions() {
return {
state: this.$element.is(':checked'),
size: this.$element.data('size'),
animate: this.$element.data('animate'),
disabled: this.$element.is(':disabled'),
readonly: this.$element.is('[readonly]'),
indeterminate: this.$element.data('indeterminate'),
inverse: this.$element.data('inverse'),
radioAllOff: this.$element.data('radio-all-off'),
onColor: this.$element.data('on-color'),
offColor: this.$element.data('off-color'),
onText: this.$element.data('on-text'),
offText: this.$element.data('off-text'),
labelText: this.$element.data('label-text'),
handleWidth: this.$element.data('handle-width'),
labelWidth: this.$element.data('label-width'),
baseClass: this.$element.data('base-class'),
wrapperClass: this.$element.data('wrapper-class')
};
}
}, {
key: '_width',
value: function _width() {
var _this2 = this;
var $handles = this.$on.add(this.$off).add(this.$label).css('width', '');
var handleWidth = this.options.handleWidth === 'auto' ? Math.round(Math.max(this.$on.width(), this.$off.width())) : this.options.handleWidth;
$handles.width(handleWidth);
this.$label.width(function(index, width) {
if (_this2.options.labelWidth !== 'auto') {
return _this2.options.labelWidth;
}
if (width < handleWidth) {
return handleWidth;
}
return width;
});
this._handleWidth = this.$on.outerWidth();
this._labelWidth = this.$label.outerWidth();
this.$container.width(this._handleWidth * 2 + this._labelWidth);
return this.$wrapper.width(this._handleWidth + this._labelWidth);
}
}, {
key: '_containerPosition',
value: function _containerPosition() {
var _this3 = this;
var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : this.options.state;
var callback = arguments[1];
this.$container.css('margin-left', function() {
var values = [0, '-' + _this3._handleWidth + 'px'];
if (_this3.options.indeterminate) {
return '-' + _this3._handleWidth / 2 + 'px';
}
if (state) {
if (_this3.options.inverse) {
return values[1];
} else {
return values[0];
}
} else {
if (_this3.options.inverse) {
return values[0];
} else {
return values[1];
}
}
});
}
}, {
key: '_init',
value: function _init() {
var _this4 = this;
var init = function init() {
_this4.setPrevOptions();
_this4._width();
_this4._containerPosition();
setTimeout(function() {
if (_this4.options.animate) {
return _this4.$wrapper.addClass(_this4._getClass('animate'));
}
}, 50);
};
if (this.$wrapper.is(':visible')) {
init();
return;
}
var initInterval = window.setInterval(function() {
if (_this4.$wrapper.is(':visible')) {
init();
return window.clearInterval(initInterval);
}
}, 50);
}
}, {
key: '_elementHandlers',
value: function _elementHandlers() {
var _this5 = this;
return this.$element.on({
'setPreviousOptions.bootstrapSwitch': this.setPrevOptions.bind(this),
'previousState.bootstrapSwitch': function previousStateBootstrapSwitch() {
_this5.options = _this5.prevOptions;
if (_this5.options.indeterminate) {
_this5.$wrapper.addClass(_this5._getClass('indeterminate'));
}
_this5.$element.prop('checked', _this5.options.state).trigger('change.bootstrapSwitch', true);
},
'change.bootstrapSwitch': function changeBootstrapSwitch(event, skip) {
event.preventDefault();
event.stopImmediatePropagation();
var state = _this5.$element.is(':checked');
_this5._containerPosition(state);
if (state === _this5.options.state) {
return;
}
_this5.options.state = state;
_this5.$wrapper.toggleClass(_this5._getClass('off')).toggleClass(_this5._getClass('on'));
if (!skip) {
if (_this5.$element.is(':radio')) {
$('[name="' + _this5.$element.attr('name') + '"]').not(_this5.$element).prop('checked', false).trigger('change.bootstrapSwitch', true);
}
_this5.$element.trigger('switchChange.bootstrapSwitch', [state]);
}
},
'focus.bootstrapSwitch': function focusBootstrapSwitch(event) {
event.preventDefault();
_this5.$wrapper.addClass(_this5._getClass('focused'));
},
'blur.bootstrapSwitch': function blurBootstrapSwitch(event) {
event.preventDefault();
_this5.$wrapper.removeClass(_this5._getClass('focused'));
},
'keydown.bootstrapSwitch': function keydownBootstrapSwitch(event) {
if (!event.which || _this5.options.disabled || _this5.options.readonly) {
return;
}
if (event.which === 37 || event.which === 39) {
event.preventDefault();
event.stopImmediatePropagation();
_this5.state(event.which === 39);
}
}
});
}
}, {
key: '_handleHandlers',
value: function _handleHandlers() {
var _this6 = this;
this.$on.on('click.bootstrapSwitch', function(event) {
event.preventDefault();
event.stopPropagation();
_this6.state(false);
return _this6.$element.trigger('focus.bootstrapSwitch');
});
return this.$off.on('click.bootstrapSwitch', function(event) {
event.preventDefault();
event.stopPropagation();
_this6.state(true);
return _this6.$element.trigger('focus.bootstrapSwitch');
});
}
}, {
key: '_labelHandlers',
value: function _labelHandlers() {
var _this7 = this;
var handlers = {
click: function click(event) {
event.stopPropagation();
},
'mousedown.bootstrapSwitch touchstart.bootstrapSwitch': function mousedownBootstrapSwitchTouchstartBootstrapSwitch(event) {
if (_this7._dragStart || _this7.options.disabled || _this7.options.readonly) {
return;
}
event.preventDefault();
event.stopPropagation();
_this7._dragStart = (event.pageX || event.originalEvent.touches[0].pageX) - parseInt(_this7.$container.css('margin-left'), 10);
if (_this7.options.animate) {
_this7.$wrapper.removeClass(_this7._getClass('animate'));
}
_this7.$element.trigger('focus.bootstrapSwitch');
},
'mousemove.bootstrapSwitch touchmove.bootstrapSwitch': function mousemoveBootstrapSwitchTouchmoveBootstrapSwitch(event) {
if (_this7._dragStart == null) {
return;
}
var difference = (event.pageX || event.originalEvent.touches[0].pageX) - _this7._dragStart;
event.preventDefault();
if (difference < -_this7._handleWidth || difference > 0) {
return;
}
_this7._dragEnd = difference;
_this7.$container.css('margin-left', _this7._dragEnd + 'px');
},
'mouseup.bootstrapSwitch touchend.bootstrapSwitch': function mouseupBootstrapSwitchTouchendBootstrapSwitch(event) {
if (!_this7._dragStart) {
return;
}
event.preventDefault();
if (_this7.options.animate) {
_this7.$wrapper.addClass(_this7._getClass('animate'));
}
if (_this7._dragEnd) {
var state = _this7._dragEnd > -(_this7._handleWidth / 2);
_this7._dragEnd = false;
_this7.state(_this7.options.inverse ? !state : state);
} else {
_this7.state(!_this7.options.state);
}
_this7._dragStart = false;
},
'mouseleave.bootstrapSwitch': function mouseleaveBootstrapSwitch() {
_this7.$label.trigger('mouseup.bootstrapSwitch');
}
};
this.$label.on(handlers);
}
}, {
key: '_externalLabelHandler',
value: function _externalLabelHandler() {
var _this8 = this;
var $externalLabel = this.$element.closest('label');
$externalLabel.on('click', function(event) {
event.preventDefault();
event.stopImmediatePropagation();
if (event.target === $externalLabel[0]) {
_this8.toggleState();
}
});
}
}, {
key: '_formHandler',
value: function _formHandler() {
var $form = this.$element.closest('form');
if ($form.data('bootstrap-switch')) {
return;
}
$form.on('reset.bootstrapSwitch', function() {
window.setTimeout(function() {
$form.find('input').filter(function() {
return $(this).data('bootstrap-switch');
}).each(function() {
return $(this).bootstrapSwitch('state', this.checked);
});
}, 1);
}).data('bootstrap-switch', true);
}
}, {
key: '_getClass',
value: function _getClass(name) {
return this.options.baseClass + '-' + name;
}
}, {
key: '_getClasses',
value: function _getClasses(classes) {
if (!$.isArray(classes)) {
return [this._getClass(classes)];
}
return classes.map(this._getClass.bind(this));
}
}]);
return BootstrapSwitch;
}();
$.fn.bootstrapSwitch = function(option) {
for (var _len2 = arguments.length, args = Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
args[_key2 - 1] = arguments[_key2];
}
function reducer(ret, next) {
var $this = $(next);
var existingData = $this.data('bootstrap-switch');
var data = existingData || new BootstrapSwitch(next, option);
if (!existingData) {
$this.data('bootstrap-switch', data);
}
if (typeof option === 'string') {
return data[option].apply(data, args);
}
return ret;
}
return Array.prototype.reduce.call(this, reducer, this);
};
$.fn.bootstrapSwitch.Constructor = BootstrapSwitch;
$.fn.bootstrapSwitch.defaults = {
state: true,
size: null,
animate: true,
disabled: false,
readonly: false,
indeterminate: false,
inverse: false,
radioAllOff: false,
onColor: 'primary',
offColor: 'default',
onText: 'ON',
offText: 'OFF',
labelText: '&nbsp',
handleWidth: 'auto',
labelWidth: 'auto',
baseClass: 'bootstrap-switch',
wrapperClass: 'wrapper',
onInit: function onInit() {},
onSwitchChange: function onSwitchChange() {}
};
});

View File

@ -1,685 +0,0 @@
/*
* bootstrap-tagsinput v0.8.0
*
*/
(function($) {
"use strict";
var defaultOptions = {
tagClass: function(item) {
return 'badge badge-danger';
},
itemValue: function(item) {
return item ? item.toString() : item;
},
itemText: function(item) {
return this.itemValue(item);
},
itemTitle: function(item) {
return null;
},
freeInput: true,
addOnBlur: true,
maxTags: undefined,
maxChars: undefined,
confirmKeys: [13, 44],
delimiter: ',',
delimiterRegex: null,
cancelConfirmKeysOnEmpty: true,
onTagExists: function(item, $tag) {
$tag.hide().fadeIn();
},
trimValue: false,
allowDuplicates: false
};
/**
* Constructor function
*/
function TagsInput(element, options) {
this.itemsArray = [];
this.$element = $(element);
this.$element.hide();
this.isSelect = (element.tagName === 'SELECT');
this.multiple = (this.isSelect && element.hasAttribute('multiple'));
this.objectItems = options && options.itemValue;
this.placeholderText = element.hasAttribute('placeholder') ? this.$element.attr('placeholder') : '';
this.inputSize = Math.max(1, this.placeholderText.length);
this.$container = $('<div class="bootstrap-tagsinput"></div>');
this.$input = $('<input type="text" placeholder="' + this.placeholderText + '"/>').appendTo(this.$container);
this.$element.before(this.$container);
this.build(options);
}
TagsInput.prototype = {
constructor: TagsInput,
/**
* Adds the given item as a new tag. Pass true to dontPushVal to prevent
* updating the elements val()
*/
add: function(item, dontPushVal, options) {
var self = this;
if (self.options.maxTags && self.itemsArray.length >= self.options.maxTags)
return;
// Ignore falsey values, except false
if (item !== false && !item)
return;
// Trim value
if (typeof item === "string" && self.options.trimValue) {
item = $.trim(item);
}
// Throw an error when trying to add an object while the itemValue option was not set
if (typeof item === "object" && !self.objectItems)
throw ("Can't add objects when itemValue option is not set");
// Ignore strings only containg whitespace
if (item.toString().match(/^\s*$/))
return;
// If SELECT but not multiple, remove current tag
if (self.isSelect && !self.multiple && self.itemsArray.length > 0)
self.remove(self.itemsArray[0]);
if (typeof item === "string" && this.$element[0].tagName === 'INPUT') {
var delimiter = (self.options.delimiterRegex) ? self.options.delimiterRegex : self.options.delimiter;
var items = item.split(delimiter);
if (items.length > 1) {
for (var i = 0; i < items.length; i++) {
this.add(items[i], true);
}
if (!dontPushVal)
self.pushVal();
return;
}
}
var itemValue = self.options.itemValue(item),
itemText = self.options.itemText(item),
tagClass = self.options.tagClass(item),
itemTitle = self.options.itemTitle(item);
// Ignore items allready added
var existing = $.grep(self.itemsArray, function(item) {
return self.options.itemValue(item) === itemValue;
})[0];
if (existing && !self.options.allowDuplicates) {
// Invoke onTagExists
if (self.options.onTagExists) {
var $existingTag = $(".tag", self.$container).filter(function() {
return $(this).data("item") === existing;
});
self.options.onTagExists(item, $existingTag);
}
return;
}
// if length greater than limit
if (self.items().toString().length + item.length + 1 > self.options.maxInputLength)
return;
// raise beforeItemAdd arg
var beforeItemAddEvent = $.Event('beforeItemAdd', {
item: item,
cancel: false,
options: options
});
self.$element.trigger(beforeItemAddEvent);
if (beforeItemAddEvent.cancel)
return;
// register item in internal array and map
self.itemsArray.push(item);
// add a tag element
var $tag = $('<span class="tag ' + htmlEncode(tagClass) + (itemTitle !== null ? ('" title="' + itemTitle) : '') + '">' + htmlEncode(itemText) + '<span data-role="remove"></span></span>');
$tag.data('item', item);
self.findInputWrapper().before($tag);
$tag.after(' ');
// add <option /> if item represents a value not present in one of the <select />'s options
if (self.isSelect && !$('option[value="' + encodeURIComponent(itemValue) + '"]', self.$element)[0]) {
var $option = $('<option selected>' + htmlEncode(itemText) + '</option>');
$option.data('item', item);
$option.attr('value', itemValue);
self.$element.append($option);
}
if (!dontPushVal)
self.pushVal();
// Add class when reached maxTags
if (self.options.maxTags === self.itemsArray.length || self.items().toString().length === self.options.maxInputLength)
self.$container.addClass('bootstrap-tagsinput-max');
self.$element.trigger($.Event('itemAdded', {
item: item,
options: options
}));
},
/**
* Removes the given item. Pass true to dontPushVal to prevent updating the
* elements val()
*/
remove: function(item, dontPushVal, options) {
var self = this;
if (self.objectItems) {
if (typeof item === "object")
item = $.grep(self.itemsArray, function(other) {
return self.options.itemValue(other) == self.options.itemValue(item);
});
else
item = $.grep(self.itemsArray, function(other) {
return self.options.itemValue(other) == item;
});
item = item[item.length - 1];
}
if (item) {
var beforeItemRemoveEvent = $.Event('beforeItemRemove', {
item: item,
cancel: false,
options: options
});
self.$element.trigger(beforeItemRemoveEvent);
if (beforeItemRemoveEvent.cancel)
return;
$('.tag', self.$container).filter(function() {
return $(this).data('item') === item;
}).remove();
$('option', self.$element).filter(function() {
return $(this).data('item') === item;
}).remove();
if ($.inArray(item, self.itemsArray) !== -1)
self.itemsArray.splice($.inArray(item, self.itemsArray), 1);
}
if (!dontPushVal)
self.pushVal();
// Remove class when reached maxTags
if (self.options.maxTags > self.itemsArray.length)
self.$container.removeClass('bootstrap-tagsinput-max');
self.$element.trigger($.Event('itemRemoved', {
item: item,
options: options
}));
},
/**
* Removes all items
*/
removeAll: function() {
var self = this;
$('.tag', self.$container).remove();
$('option', self.$element).remove();
while (self.itemsArray.length > 0)
self.itemsArray.pop();
self.pushVal();
},
/**
* Refreshes the tags so they match the text/value of their corresponding
* item.
*/
refresh: function() {
var self = this;
$('.tag', self.$container).each(function() {
var $tag = $(this),
item = $tag.data('item'),
itemValue = self.options.itemValue(item),
itemText = self.options.itemText(item),
tagClass = self.options.tagClass(item);
// Update tag's class and inner text
$tag.attr('class', null);
$tag.addClass('tag ' + htmlEncode(tagClass));
$tag.contents().filter(function() {
return this.nodeType == 3;
})[0].nodeValue = htmlEncode(itemText);
if (self.isSelect) {
var option = $('option', self.$element).filter(function() {
return $(this).data('item') === item;
});
option.attr('value', itemValue);
}
});
},
/**
* Returns the items added as tags
*/
items: function() {
return this.itemsArray;
},
/**
* Assembly value by retrieving the value of each item, and set it on the
* element.
*/
pushVal: function() {
var self = this,
val = $.map(self.items(), function(item) {
return self.options.itemValue(item).toString();
});
self.$element.val(val, true).trigger('change');
},
/**
* Initializes the tags input behaviour on the element
*/
build: function(options) {
var self = this;
self.options = $.extend({}, defaultOptions, options);
// When itemValue is set, freeInput should always be false
if (self.objectItems)
self.options.freeInput = false;
makeOptionItemFunction(self.options, 'itemValue');
makeOptionItemFunction(self.options, 'itemText');
makeOptionFunction(self.options, 'tagClass');
// Typeahead Bootstrap version 2.3.2
if (self.options.typeahead) {
var typeahead = self.options.typeahead || {};
makeOptionFunction(typeahead, 'source');
self.$input.typeahead($.extend({}, typeahead, {
source: function(query, process) {
function processItems(items) {
var texts = [];
for (var i = 0; i < items.length; i++) {
var text = self.options.itemText(items[i]);
map[text] = items[i];
texts.push(text);
}
process(texts);
}
this.map = {};
var map = this.map,
data = typeahead.source(query);
if ($.isFunction(data.success)) {
// support for Angular callbacks
data.success(processItems);
} else if ($.isFunction(data.then)) {
// support for Angular promises
data.then(processItems);
} else {
// support for functions and jquery promises
$.when(data)
.then(processItems);
}
},
updater: function(text) {
self.add(this.map[text]);
return this.map[text];
},
matcher: function(text) {
return (text.toLowerCase().indexOf(this.query.trim().toLowerCase()) !== -1);
},
sorter: function(texts) {
return texts.sort();
},
highlighter: function(text) {
var regex = new RegExp('(' + this.query + ')', 'gi');
return text.replace(regex, "<strong>$1</strong>");
}
}));
}
// typeahead.js
if (self.options.typeaheadjs) {
var typeaheadConfig = null;
var typeaheadDatasets = {};
// Determine if main configurations were passed or simply a dataset
var typeaheadjs = self.options.typeaheadjs;
if ($.isArray(typeaheadjs)) {
typeaheadConfig = typeaheadjs[0];
typeaheadDatasets = typeaheadjs[1];
} else {
typeaheadDatasets = typeaheadjs;
}
self.$input.typeahead(typeaheadConfig, typeaheadDatasets).on('typeahead:selected', $.proxy(function(obj, datum) {
if (typeaheadDatasets.valueKey)
self.add(datum[typeaheadDatasets.valueKey]);
else
self.add(datum);
self.$input.typeahead('val', '');
}, self));
}
self.$container.on('click', $.proxy(function(event) {
if (!self.$element.attr('disabled')) {
self.$input.removeAttr('disabled');
}
self.$input.focus();
}, self));
if (self.options.addOnBlur && self.options.freeInput) {
self.$input.on('focusout', $.proxy(function(event) {
// HACK: only process on focusout when no typeahead opened, to
// avoid adding the typeahead text as tag
if ($('.typeahead, .twitter-typeahead', self.$container).length === 0) {
self.add(self.$input.val());
self.$input.val('');
}
}, self));
}
self.$container.on('keydown', 'input', $.proxy(function(event) {
var $input = $(event.target),
$inputWrapper = self.findInputWrapper();
if (self.$element.attr('disabled')) {
self.$input.attr('disabled', 'disabled');
return;
}
switch (event.which) {
// BACKSPACE
case 8:
if (doGetCaretPosition($input[0]) === 0) {
var prev = $inputWrapper.prev();
if (prev.length) {
self.remove(prev.data('item'));
}
}
break;
// DELETE
case 46:
if (doGetCaretPosition($input[0]) === 0) {
var next = $inputWrapper.next();
if (next.length) {
self.remove(next.data('item'));
}
}
break;
// LEFT ARROW
case 37:
// Try to move the input before the previous tag
var $prevTag = $inputWrapper.prev();
if ($input.val().length === 0 && $prevTag[0]) {
$prevTag.before($inputWrapper);
$input.focus();
}
break;
// RIGHT ARROW
case 39:
// Try to move the input after the next tag
var $nextTag = $inputWrapper.next();
if ($input.val().length === 0 && $nextTag[0]) {
$nextTag.after($inputWrapper);
$input.focus();
}
break;
default:
// ignore
}
// Reset internal input's size
var textLength = $input.val().length,
wordSpace = Math.ceil(textLength / 5),
size = textLength + wordSpace + 1;
$input.attr('size', Math.max(this.inputSize, $input.val().length));
}, self));
self.$container.on('keypress', 'input', $.proxy(function(event) {
var $input = $(event.target);
if (self.$element.attr('disabled')) {
self.$input.attr('disabled', 'disabled');
return;
}
var text = $input.val(),
maxLengthReached = self.options.maxChars && text.length >= self.options.maxChars;
if (self.options.freeInput && (keyCombinationInList(event, self.options.confirmKeys) || maxLengthReached)) {
// Only attempt to add a tag if there is data in the field
if (text.length !== 0) {
self.add(maxLengthReached ? text.substr(0, self.options.maxChars) : text);
$input.val('');
}
// If the field is empty, let the event triggered fire as usual
if (self.options.cancelConfirmKeysOnEmpty === false) {
event.preventDefault();
}
}
// Reset internal input's size
var textLength = $input.val().length,
wordSpace = Math.ceil(textLength / 5),
size = textLength + wordSpace + 1;
$input.attr('size', Math.max(this.inputSize, $input.val().length));
}, self));
// Remove icon clicked
self.$container.on('click', '[data-role=remove]', $.proxy(function(event) {
if (self.$element.attr('disabled')) {
return;
}
self.remove($(event.target).closest('.tag').data('item'));
}, self));
// Only add existing value as tags when using strings as tags
if (self.options.itemValue === defaultOptions.itemValue) {
if (self.$element[0].tagName === 'INPUT') {
self.add(self.$element.val());
} else {
$('option', self.$element).each(function() {
self.add($(this).attr('value'), true);
});
}
}
},
/**
* Removes all tagsinput behaviour and unregsiter all event handlers
*/
destroy: function() {
var self = this;
// Unbind events
self.$container.off('keypress', 'input');
self.$container.off('click', '[role=remove]');
self.$container.remove();
self.$element.removeData('tagsinput');
self.$element.show();
},
/**
* Sets focus on the tagsinput
*/
focus: function() {
this.$input.focus();
},
/**
* Returns the internal input element
*/
input: function() {
return this.$input;
},
/**
* Returns the element which is wrapped around the internal input. This
* is normally the $container, but typeahead.js moves the $input element.
*/
findInputWrapper: function() {
var elt = this.$input[0],
container = this.$container[0];
while (elt && elt.parentNode !== container)
elt = elt.parentNode;
return $(elt);
}
};
/**
* Register JQuery plugin
*/
$.fn.tagsinput = function(arg1, arg2, arg3) {
var results = [];
this.each(function() {
var tagsinput = $(this).data('tagsinput');
// Initialize a new tags input
if (!tagsinput) {
tagsinput = new TagsInput(this, arg1);
$(this).data('tagsinput', tagsinput);
results.push(tagsinput);
if (this.tagName === 'SELECT') {
$('option', $(this)).attr('selected', 'selected');
}
// Init tags from $(this).val()
$(this).val($(this).val());
} else if (!arg1 && !arg2) {
// tagsinput already exists
// no function, trying to init
results.push(tagsinput);
} else if (tagsinput[arg1] !== undefined) {
// Invoke function on existing tags input
if (tagsinput[arg1].length === 3 && arg3 !== undefined) {
var retVal = tagsinput[arg1](arg2, null, arg3);
} else {
var retVal = tagsinput[arg1](arg2);
}
if (retVal !== undefined)
results.push(retVal);
}
});
if (typeof arg1 == 'string') {
// Return the results from the invoked function calls
return results.length > 1 ? results : results[0];
} else {
return results;
}
};
$.fn.tagsinput.Constructor = TagsInput;
/**
* Most options support both a string or number as well as a function as
* option value. This function makes sure that the option with the given
* key in the given options is wrapped in a function
*/
function makeOptionItemFunction(options, key) {
if (typeof options[key] !== 'function') {
var propertyName = options[key];
options[key] = function(item) {
return item[propertyName];
};
}
}
function makeOptionFunction(options, key) {
if (typeof options[key] !== 'function') {
var value = options[key];
options[key] = function() {
return value;
};
}
}
/**
* HtmlEncodes the given value
*/
var htmlEncodeContainer = $('<div />');
function htmlEncode(value) {
if (value) {
return htmlEncodeContainer.text(value).html();
} else {
return '';
}
}
/**
* Returns the position of the caret in the given input field
* http://flightschool.acylt.com/devnotes/caret-position-woes/
*/
function doGetCaretPosition(oField) {
var iCaretPos = 0;
if (document.selection) {
oField.focus();
var oSel = document.selection.createRange();
oSel.moveStart('character', -oField.value.length);
iCaretPos = oSel.text.length;
} else if (oField.selectionStart || oField.selectionStart == '0') {
iCaretPos = oField.selectionStart;
}
return (iCaretPos);
}
/**
* Returns boolean indicates whether user has pressed an expected key combination.
* @param object keyPressEvent: JavaScript event object, refer
* http://www.w3.org/TR/2003/WD-DOM-Level-3-Events-20030331/ecma-script-binding.html
* @param object lookupList: expected key combinations, as in:
* [13, {which: 188, shiftKey: true}]
*/
function keyCombinationInList(keyPressEvent, lookupList) {
var found = false;
$.each(lookupList, function(index, keyCombination) {
if (typeof(keyCombination) === 'number' && keyPressEvent.which === keyCombination) {
found = true;
return false;
}
if (keyPressEvent.which === keyCombination.which) {
var alt = !keyCombination.hasOwnProperty('altKey') || keyPressEvent.altKey === keyCombination.altKey,
shift = !keyCombination.hasOwnProperty('shiftKey') || keyPressEvent.shiftKey === keyCombination.shiftKey,
ctrl = !keyCombination.hasOwnProperty('ctrlKey') || keyPressEvent.ctrlKey === keyCombination.ctrlKey;
if (alt && shift && ctrl) {
found = true;
return false;
}
}
});
return found;
}
/**
* Initialize tagsinput behaviour on inputs and selects which have
* data-role=tagsinput
*/
$(function() {
$("input[data-role=tagsinput], select[multiple][data-role=tagsinput]").tagsinput();
});
})(window.jQuery);

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long