first commit
This commit is contained in:
@@ -0,0 +1,150 @@
|
||||
/**
|
||||
* @preserve
|
||||
* Project: Bootstrap Hover Dropdown
|
||||
* Author: Cameron Spear
|
||||
* Version: v2.2.1
|
||||
* Contributors: Mattia Larentis
|
||||
* Dependencies: Bootstrap's Dropdown plugin, jQuery
|
||||
* Description: A simple plugin to enable Bootstrap dropdowns to active on hover and provide a nice user experience.
|
||||
* License: MIT
|
||||
* Homepage: http://cameronspear.com/blog/bootstrap-dropdown-on-hover-plugin/
|
||||
*/
|
||||
;(function ($, window, undefined) {
|
||||
// outside the scope of the jQuery plugin to
|
||||
// keep track of all dropdowns
|
||||
var $allDropdowns = $();
|
||||
|
||||
// if instantlyCloseOthers is true, then it will instantly
|
||||
// shut other nav items when a new one is hovered over
|
||||
$.fn.dropdownHover = function (options) {
|
||||
// don't do anything if touch is supported
|
||||
// (plugin causes some issues on mobile)
|
||||
if('ontouchstart' in document) return this; // don't want to affect chaining
|
||||
|
||||
// the element we really care about
|
||||
// is the dropdown-toggle's parent
|
||||
$allDropdowns = $allDropdowns.add(this.parent()).add(this.parent().children('.dropdown-menu'));
|
||||
|
||||
return this.each(function () {
|
||||
var $this = $(this),
|
||||
$parent = $this.parent(),
|
||||
defaults = {
|
||||
delay: 500,
|
||||
hoverDelay: 0,
|
||||
instantlyCloseOthers: true
|
||||
},
|
||||
data = {
|
||||
delay: $(this).data('delay'),
|
||||
hoverDelay: $(this).data('hover-delay'),
|
||||
instantlyCloseOthers: $(this).data('close-others')
|
||||
},
|
||||
showEvent = 'show.bs.dropdown',
|
||||
hideEvent = 'hide.bs.dropdown',
|
||||
// shownEvent = 'shown.bs.dropdown',
|
||||
// hiddenEvent = 'hidden.bs.dropdown',
|
||||
settings = $.extend(true, {}, defaults, options, data),
|
||||
timeout, timeoutHover;
|
||||
|
||||
$parent.hover(function (event) {
|
||||
// so a neighbor can't open the dropdown
|
||||
if(!$parent.hasClass('show') && !$this.is(event.target)) {
|
||||
// stop this event, stop executing any code
|
||||
// in this callback but continue to propagate
|
||||
return true;
|
||||
}
|
||||
|
||||
openDropdown(event);
|
||||
}, function () {
|
||||
if($this.parents(".navbar").find(".navbar-toggler").is(":visible")) {
|
||||
// If we're inside a navbar, don't do anything when the
|
||||
// navbar is collapsed, as it makes the navbar pretty unusable.
|
||||
return;
|
||||
}
|
||||
|
||||
// clear timer for hover event
|
||||
window.clearTimeout(timeoutHover)
|
||||
timeout = window.setTimeout(function () {
|
||||
$this.attr('aria-expanded', 'false');
|
||||
$parent.removeClass('show');
|
||||
$parent.children('.dropdown-menu').removeClass('show');
|
||||
$this.trigger(hideEvent);
|
||||
}, settings.delay);
|
||||
});
|
||||
|
||||
// this helps with button groups!
|
||||
$this.hover(function (event) {
|
||||
// this helps prevent a double event from firing.
|
||||
// see https://github.com/CWSpear/bootstrap-hover-dropdown/issues/55
|
||||
if(!$parent.hasClass('show') && !$parent.is(event.target)) {
|
||||
// stop this event, stop executing any code
|
||||
// in this callback but continue to propagate
|
||||
return true;
|
||||
}
|
||||
|
||||
openDropdown(event);
|
||||
});
|
||||
|
||||
// handle submenus
|
||||
$parent.find('.dropdown-submenu').each(function (){
|
||||
var $this = $(this);
|
||||
var subTimeout;
|
||||
|
||||
if($this.parents(".navbar").find(".navbar-toggler").is(":visible")) {
|
||||
// If we're inside a navbar, don't do anything when the
|
||||
// navbar is collapsed, as it makes the navbar pretty unusable.
|
||||
return;
|
||||
}
|
||||
|
||||
$this.hover(function () {
|
||||
window.clearTimeout(subTimeout);
|
||||
$this.addClass('show');
|
||||
$this.children('.dropdown-menu').addClass('show');
|
||||
// always close submenu siblings instantly
|
||||
$this.siblings().children('.dropdown-menu').removeClass('show');
|
||||
}, function () {
|
||||
var $submenu = $this.children('.dropdown-menu'),
|
||||
// $parent = $this.parent('dropdown-submenu');
|
||||
subTimeout = window.setTimeout(function () {
|
||||
$submenu.removeClass('show');
|
||||
$this.removeClass('show');
|
||||
}, settings.delay);
|
||||
});
|
||||
});
|
||||
|
||||
function openDropdown(event) {
|
||||
if($this.parents(".navbar").find(".navbar-toggler").is(":visible")) {
|
||||
// If we're inside a navbar, don't do anything when the
|
||||
// navbar is collapsed, as it makes the navbar pretty unusable.
|
||||
return;
|
||||
}
|
||||
|
||||
// clear dropdown timeout here so it doesnt close before it should
|
||||
window.clearTimeout(timeout);
|
||||
// restart hover timer
|
||||
window.clearTimeout(timeoutHover);
|
||||
|
||||
// delay for hover event.
|
||||
timeoutHover = window.setTimeout(function () {
|
||||
$allDropdowns.find(':focus').blur();
|
||||
|
||||
if(settings.instantlyCloseOthers === true) {
|
||||
$allDropdowns.removeClass('show');
|
||||
// $allDropdowns.children('.dropdown-menu').removeClass('show');
|
||||
}
|
||||
|
||||
// clear timer for hover event
|
||||
window.clearTimeout(timeoutHover);
|
||||
$this.attr('aria-expanded', 'true');
|
||||
$parent.addClass('show');
|
||||
$parent.children('.dropdown-menu').addClass('show');
|
||||
$this.trigger(showEvent);
|
||||
}, settings.hoverDelay);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
$(document).ready(function () {
|
||||
// apply dropdownHover to all elements with the data-hover="dropdown" attribute
|
||||
$('[data-hover="dropdown"]').dropdownHover();
|
||||
});
|
||||
})(jQuery, window);
|
||||
@@ -0,0 +1,9 @@
|
||||
/*!
|
||||
* Ladda 1.0.6 (2018-02-04, 13:15)
|
||||
* http://lab.hakim.se/ladda
|
||||
* MIT licensed
|
||||
*
|
||||
* Copyright (C) 2017 Hakim El Hattab, http://hakim.se
|
||||
*/
|
||||
|
||||
!function(t,e){"use strict";"object"==typeof exports?module.exports=e(require("spin.js")):"function"==typeof define&&define.amd?define(["spin"],e):t.Ladda=e(t.Spinner)}(this,function(t){"use strict";var e=[];function a(a){if(void 0!==a){if(/ladda-button/i.test(a.className)||(a.className+=" ladda-button"),a.hasAttribute("data-style")||a.setAttribute("data-style","expand-right"),!a.querySelector(".ladda-label")){var u=document.createElement("span");u.className="ladda-label",n=a,i=u,(r=document.createRange()).selectNodeContents(n),r.surroundContents(i),n.appendChild(i)}var n,i,r,d,o,s=a.querySelector(".ladda-spinner");s||((s=document.createElement("span")).className="ladda-spinner"),a.appendChild(s);var F={start:function(){return d||(d=function(e){var a,u,n=e.offsetHeight;0===n&&(n=parseFloat(window.getComputedStyle(e).height));n>32&&(n*=.8);e.hasAttribute("data-spinner-size")&&(n=parseInt(e.getAttribute("data-spinner-size"),10));e.hasAttribute("data-spinner-color")&&(a=e.getAttribute("data-spinner-color"));e.hasAttribute("data-spinner-lines")&&(u=parseInt(e.getAttribute("data-spinner-lines"),10));var i=.2*n;return new t({color:a||"#fff",lines:u||12,radius:i,length:.6*i,width:i<7?2:3,zIndex:"auto",top:"auto",left:"auto",className:""})}(a)),a.disabled=!0,a.setAttribute("data-loading",""),clearTimeout(o),d.spin(s),this.setProgress(0),this},startAfter:function(t){return clearTimeout(o),o=setTimeout(function(){F.start()},t),this},stop:function(){return F.isLoading()&&(a.disabled=!1,a.removeAttribute("data-loading")),clearTimeout(o),d&&(o=setTimeout(function(){d.stop()},1e3)),this},toggle:function(){return this.isLoading()?this.stop():this.start()},setProgress:function(t){t=Math.max(Math.min(t,1),0);var e=a.querySelector(".ladda-progress");0===t&&e&&e.parentNode?e.parentNode.removeChild(e):(e||((e=document.createElement("div")).className="ladda-progress",a.appendChild(e)),e.style.width=(t||0)*a.offsetWidth+"px")},enable:function(){return this.stop()},disable:function(){return this.stop(),a.disabled=!0,this},isLoading:function(){return a.hasAttribute("data-loading")},remove:function(){clearTimeout(o),a.disabled=!1,a.removeAttribute("data-loading"),d&&(d.stop(),d=null),e.splice(e.indexOf(F),1)}};return e.push(F),F}console.warn("Ladda button target must be defined.")}function u(t,e){if("function"==typeof t.addEventListener){var u=a(t),n=-1;t.addEventListener("click",function(){var a,i,r=!0,d=function(t,e){for(;t.parentNode&&t.tagName!==e;)t=t.parentNode;return e===t.tagName?t:void 0}(t,"FORM");if(void 0!==d&&!d.hasAttribute("novalidate"))if("function"==typeof d.checkValidity)r=d.checkValidity();else for(var o=(a=d,i=[],["input","textarea","select"].forEach(function(t){for(var e=a.getElementsByTagName(t),u=0;u<e.length;u++)e[u].hasAttribute("required")&&i.push(e[u])}),i),s=0;s<o.length;s++){var F=o[s],l=F.getAttribute("type");if(""===F.value.replace(/^\s+|\s+$/g,"")&&(r=!1),"checkbox"!==l&&"radio"!==l||F.checked||(r=!1),"email"===l&&(r=/^[a-z0-9!#$%&'*+/=?^_`{|}~.-]+@[a-z0-9-]+(\.[a-z0-9-]+)*$/i.test(F.value)),"url"===l&&(r=/^([a-z]([a-z]|\d|\+|-|\.)*):(\/\/(((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:)*@)?((\[(|(v[\da-f]{1,}\.(([a-z]|\d|-|\.|_|~)|[!\$&'\(\)\*\+,;=]|:)+))\])|((\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5]))|(([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=])*)(:\d*)?)(\/(([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)*)*|(\/((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)+(\/(([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)*)*)?)|((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)+(\/(([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)*)*)|((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)){0})(\?((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|[\uE000-\uF8FF]|\/|\?)*)?(\#((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|\/|\?)*)?$/i.test(F.value)),!r)break}r&&(u.startAfter(1),"number"==typeof e.timeout&&(clearTimeout(n),n=setTimeout(u.stop,e.timeout)),"function"==typeof e.callback&&e.callback.apply(null,[u]))},!1)}}return{bind:function(t,e){var a;if("string"==typeof t)a=document.querySelectorAll(t);else{if("object"!=typeof t)throw new Error("target must be string or object");a=[t]}e=e||{};for(var n=0;n<a.length;n++)u(a[n],e)},create:a,stopAll:function(){for(var t=0,a=e.length;t<a;t++)e[t].stop()}}});
|
||||
@@ -0,0 +1 @@
|
||||
!function(t,i){"object"==typeof exports?module.exports=i():"function"==typeof define&&define.amd?define(i):t.Spinner=i()}(this,function(){"use strict";function t(t,i){var e,o=document.createElement(t||"div");for(e in i)o[e]=i[e];return o}function i(t){for(var i=1,e=arguments.length;i<e;i++)t.appendChild(arguments[i]);return t}function e(t,i,e,o){var n=["opacity",i,~~(100*t),e,o].join("-"),r=.01+e/o*100,s=Math.max(1-(1-t)/i*(100-r),t),a=l.substring(0,l.indexOf("Animation")).toLowerCase(),c=a&&"-"+a+"-"||"";return d[n]||(p.insertRule("@"+c+"keyframes "+n+"{0%{opacity:"+s+"}"+r+"%{opacity:"+t+"}"+(r+.01)+"%{opacity:1}"+(r+i)%100+"%{opacity:"+t+"}100%{opacity:"+s+"}}",p.cssRules.length),d[n]=1),n}function o(t,i){var e,o,n=t.style;for(i=i.charAt(0).toUpperCase()+i.slice(1),o=0;o<c.length;o++)if(e=c[o]+i,void 0!==n[e])return e;if(void 0!==n[i])return i}function n(t,i){for(var e in i)t.style[o(t,e)||e]=i[e];return t}function r(t){for(var i=1;i<arguments.length;i++){var e=arguments[i];for(var o in e)void 0===t[o]&&(t[o]=e[o])}return t}function s(t,i){return"string"==typeof t?t:t[i%t.length]}function a(t){this.opts=r(t||{},a.defaults,u)}var l,c=["webkit","Moz","ms","O"],d={},p=function(){var e=t("style",{type:"text/css"});return i(document.getElementsByTagName("head")[0],e),e.sheet||e.styleSheet}(),u={lines:12,length:7,width:5,radius:10,rotate:0,corners:1,color:"#000",direction:1,speed:1,trail:100,opacity:.25,fps:20,zIndex:2e9,className:"spinner",top:"50%",left:"50%",position:"absolute"};a.defaults={},r(a.prototype,{spin:function(i){this.stop();var e=this,o=e.opts,r=e.el=n(t(0,{className:o.className}),{position:o.position,width:0,zIndex:o.zIndex});o.radius,o.length,o.width;if(n(r,{left:o.left,top:o.top}),i&&i.insertBefore(r,i.firstChild||null),r.setAttribute("role","progressbar"),e.lines(r,e.opts),!l){var s,a=0,c=(o.lines-1)*(1-o.direction)/2,d=o.fps,p=d/o.speed,u=(1-o.opacity)/(p*o.trail/100),f=p/o.lines;!function t(){a++;for(var i=0;i<o.lines;i++)s=Math.max(1-(a+(o.lines-i)*f)%p*u,o.opacity),e.opacity(r,i*o.direction+c,s,o);e.timeout=e.el&&setTimeout(t,~~(1e3/d))}()}return e},stop:function(){var t=this.el;return t&&(clearTimeout(this.timeout),t.parentNode&&t.parentNode.removeChild(t),this.el=void 0),this},lines:function(o,r){function a(i,e){return n(t(),{position:"absolute",width:r.length+r.width+"px",height:r.width+"px",background:i,boxShadow:e,transformOrigin:"left",transform:"rotate("+~~(360/r.lines*d+r.rotate)+"deg) translate("+r.radius+"px,0)",borderRadius:(r.corners*r.width>>1)+"px"})}for(var c,d=0,p=(r.lines-1)*(1-r.direction)/2;d<r.lines;d++)c=n(t(),{position:"absolute",top:1+~(r.width/2)+"px",transform:r.hwaccel?"translate3d(0,0,0)":"",opacity:r.opacity,animation:l&&e(r.opacity,r.trail,p+d*r.direction,r.lines)+" "+1/r.speed+"s linear infinite"}),r.shadow&&i(c,n(a("#000","0 0 4px #000"),{top:"2px"})),i(o,i(c,a(s(r.color,d),"0 0 1px rgba(0,0,0,.1)")));return o},opacity:function(t,i,e){i<t.childNodes.length&&(t.childNodes[i].style.opacity=e)}});var f=n(t("group"),{behavior:"url(#default#VML)"});return!o(f,"transform")&&f.adj?function(){function e(i,e){return t("<"+i+' xmlns="urn:schemas-microsoft.com:vml" class="spin-vml">',e)}p.addRule(".spin-vml","behavior:url(#default#VML)"),a.prototype.lines=function(t,o){function r(){return n(e("group",{coordsize:d+" "+d,coordorigin:-c+" "+-c}),{width:d,height:d})}function a(t,a,l){i(u,i(n(r(),{rotation:360/o.lines*t+"deg",left:~~a}),i(n(e("roundrect",{arcsize:o.corners}),{width:c,height:o.width,left:o.radius,top:-o.width>>1,filter:l}),e("fill",{color:s(o.color,t),opacity:o.opacity}),e("stroke",{opacity:0}))))}var l,c=o.length+o.width,d=2*c,p=2*-(o.width+o.length)+"px",u=n(r(),{position:"absolute",top:p,left:p});if(o.shadow)for(l=1;l<=o.lines;l++)a(l,-2,"progid:DXImageTransform.Microsoft.Blur(pixelradius=2,makeshadow=1,shadowopacity=.3)");for(l=1;l<=o.lines;l++)a(l);return i(t,u)},a.prototype.opacity=function(t,i,e,o){var n=t.firstChild;o=o.shadow&&o.lines||0,n&&i+o<n.childNodes.length&&(n=(n=(n=n.childNodes[i+o])&&n.firstChild)&&n.firstChild)&&(n.opacity=e)}}():l=o(f,"animation"),a});
|
||||
Reference in New Issue
Block a user