From 4a598971b5fcbc3e7bcf83646f2ceccd30f06414 Mon Sep 17 00:00:00 2001 From: thednp Date: Fri, 10 Apr 2015 15:32:30 +0300 Subject: [PATCH] --- assets/css/theme.css | 2 +- dist/bootstrap-native.js | 81 ++++++++++++++++++------------- dist/bootstrap-native.min.js | 2 +- index.html | 7 +-- lib/min/modal-native.min.js | 2 +- lib/modal-native.js | 92 +++++++++++++++++++++--------------- 6 files changed, 111 insertions(+), 75 deletions(-) diff --git a/assets/css/theme.css b/assets/css/theme.css index 2b027bb3..3afd0228 100644 --- a/assets/css/theme.css +++ b/assets/css/theme.css @@ -278,4 +278,4 @@ body .syntaxhighlighter .container:after { content: none } body .syntaxhighlighter .line.alt1, body .syntaxhighlighter .line.alt2 { background: none !important } .syntaxhighlighter code {background: none} -.syntaxhighlighter .container { padding:0; width: auto; min-width: 850px} \ No newline at end of file +.syntaxhighlighter .container { padding:0; width: 100% !important} \ No newline at end of file diff --git a/dist/bootstrap-native.js b/dist/bootstrap-native.js index 38851c93..37d17a87 100644 --- a/dist/bootstrap-native.js +++ b/dist/bootstrap-native.js @@ -18,45 +18,54 @@ this.options.duration = document.documentElement.classList.contains('ie') ? 0 : this.duration; this.dialog = this.modal.querySelector('.modal-dialog'); + this.timer = 0; - if ( this.options.content !== undefined ) { - this.content( this.options.content ); - } - + this.init() + } + + Modal.prototype.init = function() { + if ( this.options.content && this.options.content !== undefined ) { + this.content( this.options.content ); + } this.resize(); this.dismiss(); this.keydown(); - this.trigger(); - } + this.trigger(); + } Modal.prototype.open = function() { this._open(); } + Modal.prototype.close = function() { + this._close(); + } + Modal.prototype._open = function() { var self = this; - - document.body.classList.add('modal-open'); - this.modal.style.display = 'block'; if ( this.options.backdrop ) { this.createOverlay(); - } else { this.overlay = null } - + } else { this.overlay = null } + + document.body.classList.add('modal-open'); + this.modal.style.display = 'block'; - setTimeout(function() { + clearTimeout(self.modal.getAttribute('data-timer')); + this.timer = setTimeout( function() { + + if ( self.overlay !== null ) { + self._resize(); + self.overlay.classList.add('in'); + } self.modal.classList.add('in'); - if ( self.overlay !== null ) { self._resize(); self.overlay.classList.add('in'); } self.modal.setAttribute('aria-hidden', false); }, self.options.duration/2); + this.modal.setAttribute('data-timer',self.timer); this.opened = true; } - Modal.prototype.close = function() { - this._close(); - } - Modal.prototype._close = function() { var self = this; @@ -66,10 +75,13 @@ if ( this.overlay ) this.overlay.classList.remove('in'); document.body.classList.remove('modal-open'); - setTimeout(function() { + clearTimeout(self.modal.getAttribute('data-timer')); + this.timer = setTimeout( function() { self.modal.style.display = 'none'; - if ( self.overlay ) self.removeOverlay(); - }, self.options.duration); + self.removeOverlay(); + }, self.options.duration/2); + this.modal.setAttribute('data-timer',self.timer); + this.opened = false; } @@ -78,17 +90,21 @@ } Modal.prototype.createOverlay = function() { - if (this.overlay === undefined || this.overlay === null ) { - var backdrop = document.createElement('div'); - backdrop.setAttribute('class','modal-backdrop fade'); + var backdrop = document.createElement('div'), overlay = document.querySelector('.modal-backdrop'); + backdrop.setAttribute('class','modal-backdrop fade'); + + if ( overlay ) { + this.overlay = overlay; + } else { this.overlay = backdrop; - document.body.appendChild(backdrop); - } + document.body.appendChild(backdrop); + } } Modal.prototype.removeOverlay = function() { - if ( this.overlay === document.querySelector('.modal-backdrop') ) { - document.body.removeChild(this.overlay) + var overlay = document.querySelector('.modal-backdrop'); + if ( overlay !== null && overlay !== undefined ) { + document.body.removeChild(overlay) } } @@ -117,7 +133,8 @@ } Modal.prototype._resize = function() { - var self = this, overlay = this.overlay||document.querySelector('.modal-backdrop'), dim = { w: document.documentElement.clientWidth + 'px', h: document.documentElement.clientHeight + 'px' }; + var self = this, overlay = this.overlay||document.querySelector('.modal-backdrop'), + dim = { w: document.documentElement.clientWidth + 'px', h: document.documentElement.clientHeight + 'px' }; setTimeout(function() { if ( overlay !== null && overlay.classList.contains('in') ) { overlay.style.height = dim.h; overlay.style.width = dim.w @@ -138,7 +155,7 @@ var self = this; this.modal.addEventListener('click', function(e){ if ( e.target.parentNode.getAttribute('data-dismiss') === 'modal' || e.target.getAttribute('data-dismiss') === 'modal' || e.target === self.modal ) { - self.close() + e.preventDefault(); self.close() } else { e.stopPropagation(); e.preventDefault(); } }) } @@ -146,9 +163,9 @@ var Modals = document.querySelectorAll('.modal'); [].forEach.call(Modals,function(modal,idx) { var options = {}; - options.keyboard = modal.getAttribute('data-keyboard') && modal.getAttribute('data-keyboard'); - options.backdrop = modal.getAttribute('data-backdrop') && modal.getAttribute('data-backdrop'); - options.duration = modal.getAttribute('data-duration') && modal.getAttribute('data-duration'); + options.keyboard = modal.getAttribute('data-keyboard'); + options.backdrop = modal.getAttribute('data-backdrop'); + options.duration = modal.getAttribute('data-duration'); return new Modal(modal,options) }); diff --git a/dist/bootstrap-native.min.js b/dist/bootstrap-native.min.js index b0a88f7a..a35aa8ff 100644 --- a/dist/bootstrap-native.min.js +++ b/dist/bootstrap-native.min.js @@ -1,2 +1,2 @@ // Native Javascript for Bootstrap 3 | All in One Pack | by dnp_theme -var Modal=function(t,e){this.opened=!1,this.modal="object"==typeof t?t:document.querySelector(t),this.options={},this.options.backdrop="false"===e.backdrop?!1:!0,this.options.keyboard="false"===e.keyboard?!1:!0,this.options.content=e.content,this.duration=e.duration||300,this.options.duration=document.documentElement.classList.contains("ie")?0:this.duration,this.dialog=this.modal.querySelector(".modal-dialog"),void 0!==this.options.content&&this.content(this.options.content),this.resize(),this.dismiss(),this.keydown(),this.trigger()};Modal.prototype.open=function(){this._open()},Modal.prototype._open=function(){var t=this;document.body.classList.add("modal-open"),this.modal.style.display="block",this.options.backdrop?this.createOverlay():this.overlay=null,setTimeout(function(){t.modal.classList.add("in"),null!==t.overlay&&(t._resize(),t.overlay.classList.add("in")),t.modal.setAttribute("aria-hidden",!1)},t.options.duration/2),this.opened=!0},Modal.prototype.close=function(){this._close()},Modal.prototype._close=function(){var t=this;this.modal.classList.remove("in"),this.modal.setAttribute("aria-hidden",!0),this.overlay&&this.overlay.classList.remove("in"),document.body.classList.remove("modal-open"),setTimeout(function(){t.modal.style.display="none",t.overlay&&t.removeOverlay()},t.options.duration),this.opened=!1},Modal.prototype.content=function(t){return this.modal.querySelector(".modal-content").innerHTML=t},Modal.prototype.createOverlay=function(){if(void 0===this.overlay||null===this.overlay){var t=document.createElement("div");t.setAttribute("class","modal-backdrop fade"),this.overlay=t,document.body.appendChild(t)}},Modal.prototype.removeOverlay=function(){this.overlay===document.querySelector(".modal-backdrop")&&document.body.removeChild(this.overlay)},Modal.prototype.keydown=function(){var t=this;document.addEventListener("keydown",function(e){t.options.keyboard&&27==e.which&&t.close()},!1)},Modal.prototype.trigger=function(){var t=this,e=document.querySelectorAll('[data-toggle="modal"]');[].forEach.call(e,function(e){e.addEventListener("click",function(e){var i=e.target,o=i.getAttribute("data-target")&&i.getAttribute("data-target").replace("#","")||i.getAttribute("href")&&i.getAttribute("href").replace("#","");document.getElementById(o)===t.modal&&t.open()})})},Modal.prototype._resize=function(){var t=this,e=this.overlay||document.querySelector(".modal-backdrop"),i={w:document.documentElement.clientWidth+"px",h:document.documentElement.clientHeight+"px"};setTimeout(function(){null!==e&&e.classList.contains("in")&&(e.style.height=i.h,e.style.width=i.w)},t.options.duration/2)},Modal.prototype.resize=function(){var t=this;window.addEventListener("resize",function(){setTimeout(function(){t._resize()},50)},!1)},Modal.prototype.dismiss=function(){var t=this;this.modal.addEventListener("click",function(e){"modal"===e.target.parentNode.getAttribute("data-dismiss")||"modal"===e.target.getAttribute("data-dismiss")||e.target===t.modal?t.close():(e.stopPropagation(),e.preventDefault())})};var Modals=document.querySelectorAll(".modal");[].forEach.call(Modals,function(t){var e={};return e.keyboard=t.getAttribute("data-keyboard")&&t.getAttribute("data-keyboard"),e.backdrop=t.getAttribute("data-backdrop")&&t.getAttribute("data-backdrop"),e.duration=t.getAttribute("data-duration")&&t.getAttribute("data-duration"),new Modal(t,e)});var Affix=function(t,e){this.element="object"==typeof t?t:document.querySelector(t),this.options={},this.options.target=e.target?"object"==typeof e.target?e.target:document.querySelector(e.target):null,this.options.offsetTop=e.offsetTop&&e.offsetTop?"function"===e.offsetTop?e.offsetTop():parseInt(e.offsetTop,0):0,this.options.offsetBottom=e.offsetBottom&&e.offsetBottom?"function"===e.offsetBottom?e.offsetBottom():parseInt(e.offsetBottom,0):null,this.element&&(this.options.target||this.options.offsetTop||this.options.offsetBottom)&&this.init()};Affix.prototype={init:function(){this.affixed=!1,this.affixedBottom=!1,this.getPinOffsetTop=0,this.getPinOffsetBottom=null,this.checkPosition(),this.updateAffix(),this.scrollEvent(),this.resizeEvent()},processOffsetTop:function(){return null!==this.options.target?this.targetRect().top+this.scrollOffset():null!==this.options.offsetTop?this.options.offsetTop:void 0},processOffsetBottom:function(){if(null!==this.options.offsetBottom){var t=this.getMaxScroll();return t-this.elementHeight()-this.options.offsetBottom}},offsetTop:function(){return this.processOffsetTop()},offsetBottom:function(){return this.processOffsetBottom()},checkPosition:function(){this.getPinOffsetTop=this.offsetTop,this.getPinOffsetBottom=this.offsetBottom},scrollOffset:function(){return window.pageYOffset||document.documentElement.scrollTop},pinTop:function(){this.element.classList&&!this.element.classList.contains("affix")&&this.element.classList.add("affix"),this.affixed=!0},unPinTop:function(){this.element.classList&&this.element.classList.contains("affix")&&this.element.classList.remove("affix"),this.affixed=!1},pinBottom:function(){this.element.classList&&!this.element.classList.contains("affix-bottom")&&this.element.classList.add("affix-bottom"),this.affixedBottom=!0},unPinBottom:function(){this.element.classList&&this.element.classList.contains("affix-bottom")&&this.element.classList.remove("affix-bottom"),this.affixedBottom=!1},updatePin:function(){this.affixed===!1&&parseInt(this.offsetTop(),0)-parseInt(this.scrollOffset(),0)<0?this.pinTop():this.affixed===!0&&parseInt(this.scrollOffset(),0)<=parseInt(this.getPinOffsetTop(),0)&&this.unPinTop(),this.affixedBottom===!1&&parseInt(this.offsetBottom(),0)-parseInt(this.scrollOffset(),0)<0?this.pinBottom():this.affixedBottom===!0&&parseInt(this.scrollOffset(),0)<=parseInt(this.getPinOffsetBottom(),0)&&this.unPinBottom()},updateAffix:function(){this.unPinTop(),this.unPinBottom(),this.checkPosition(),this.updatePin()},elementHeight:function(){return this.element.offsetHeight},targetRect:function(){return this.options.target.getBoundingClientRect()},getMaxScroll:function(){return Math.max(document.body.scrollHeight,document.body.offsetHeight,document.documentElement.clientHeight,document.documentElement.scrollHeight,document.documentElement.offsetHeight)},scrollEvent:function(){var t=this;window.addEventListener("scroll",affOnScroll=function(){t.updatePin()},!1)},resizeEvent:function(){var t=this;window.addEventListener("resize",affOnResize=function(){setTimeout(function(){t.updateAffix()},100)},!1)}};var Affixes=document.querySelectorAll('[data-spy="affix"]');[].forEach.call(Affixes,function(t){var e={};return e.offsetTop=t.getAttribute("data-offset-top"),e.offsetBottom=t.getAttribute("data-offset-bottom"),e.target=t.getAttribute("data-target"),!t||null===e.offsetTop&&null===e.offsetBottom&&null===e.target?void 0:new Affix(t,e)});var Alert=function(t){this.btn="object"==typeof t?t:document.querySelector(t),this.alert=null,this.duration=150,this.init()};Alert.prototype={init:function(){this.actions(),document.addEventListener("click",this.close,!1)},actions:function(){var t=this;this.close=function(e){var i=e.target;t.btn="alert"===i.getAttribute("data-dismiss")&&"close"===i.className?i:i.parentNode,t.alert=t.btn.parentNode,null!==t.alert&&"alert"===t.btn.getAttribute("data-dismiss")&&t.alert.classList.contains("in")&&(t.alert.classList.remove("in"),setTimeout(function(){t.alert&&t.alert.parentNode.removeChild(t.alert)},t.duration))}}};var Alerts=document.querySelectorAll('[data-dismiss="alert"]');[].forEach.call(Alerts,function(t){return new Alert(t)});var ScrollSpy=function(t,e,i){this.element="object"==typeof t?t:document.querySelector(t),this.options={},this.options.target=i.target?"object"==typeof i.target?i.target:document.querySelector(i.target):null,this.items=this.options.target&&this.options.target.getElementsByTagName("A"),this.item=e,this.parent=this.item.parentNode,this.parentParent=this.parent.parentNode.parentNode,this.tg=this.item.href&&document.getElementById(this.item.getAttribute("href").replace("#","")),this.active=!1,this.topEdge=0,this.bottomEdge=0,this.scrollTarget=this.element.offsetHeight-1&&(this.checkEdges(),this.refresh(),this.scrollEvent(),this.resizeEvent())},topLimit:function(){this.tg.currentStyle||window.getComputedStyle(this.tg),this.element.currentStyle||window.getComputedStyle(this.element);return this.scrollTarget===window?this.tg.getBoundingClientRect().top+this.scrollOffset():this.tg.offsetTop},bottomLimit:function(){this.tg.currentStyle||window.getComputedStyle(this.tg),this.element.currentStyle||window.getComputedStyle(this.element);return this.topLimit()+this.tg.offsetHeight},checkEdges:function(){this.topEdge=this.topLimit(),this.bottomEdge=this.bottomLimit()},scrollOffset:function(){return this.scrollTarget===window?window.pageYOffset||document.documentElement.scrollTop:this.element.scrollTop},activate:function(){this.parent&&"LI"===this.parent.tagName&&!this.parent.classList.contains("active")&&(this.parent.classList.add("active"),this.parentParent&&"LI"===this.parentParent.tagName&&this.parentParent.classList.contains("dropdown")&&!this.parentParent.classList.contains("active")&&this.parentParent.classList.add("active"),this.active=!0)},deactivate:function(){this.parent&&"LI"===this.parent.tagName&&this.parent.classList.contains("active")&&(this.parent.classList.remove("active"),this.parentParent&&"LI"===this.parentParent.tagName&&this.parentParent.classList.contains("dropdown")&&this.parentParent.classList.contains("active")&&this.parentParent.classList.remove("active"),this.active=!1)},toggle:function(){this.active===!1&&this.bottomEdge>this.scrollOffset()&&this.scrollOffset()>=this.topEdge?this.activate():this.active===!0&&this.bottomEdge<=this.scrollOffset()&&this.scrollOffset()1?e[e.length-1]:void console.log(e.length):e[0]},this.getActiveContent=function(){var e=t.getActiveTab().getElementsByTagName("A")[0].getAttribute("href").replace("#","");return e&&document.getElementById(e)}}};var Tabs=document.querySelectorAll("[data-toggle='tab'], [data-toggle='pill']");[].forEach.call(Tabs,function(t){var e={};return e.duration=t.getAttribute("data-duration")&&t.getAttribute("data-duration")||!1,new Tab(t,e)});var Popover=function(t,e){this.link="object"==typeof t?t:document.querySelector(t),this.title=this.link.getAttribute("data-title")||null,this.content=this.link.getAttribute("data-content")||null,this.popover=null,this.options={},this.options.template=e.template?e.template:null,this.options.trigger=e.trigger?e.trigger:"hover",this.options.animation=e.animation&&"true"!==e.animation?e.animation:"true",this.options.placement=e.placement?e.placement:"top",this.options.delay=parseInt(e.delay)||100,this.duration=150,this.options.duration=document.documentElement.classList.contains("ie")?0:e.duration||this.duration,this.options.container=document.body,(this.content||this.options.template)&&this.init(),this.timer=0,this.rect=null};Popover.prototype={init:function(){this.actions(),"hover"===this.options.trigger?(this.link.addEventListener("mouseenter",this.open,!1),this.link.addEventListener("mouseleave",this.close,!1)):"click"===this.options.trigger?(this.link.addEventListener("click",this.toggle,!1),this.link.addEventListener("blur",this.close,!1)):"focus"===this.options.trigger&&(this.link.addEventListener("focus",this.toggle,!1),this.link.addEventListener("blur",this.close,!1)),document.documentElement.classList.contains("ie")||"focus"!==this.options.trigger&&"click"!==this.options.trigger||window.addEventListener("resize",this.close,!1)},actions:function(){var t=this;this.toggle=function(){null===t.popover?t.open():t.close()},this.open=function(){clearTimeout(t.link.getAttribute("data-timer")),t.timer=setTimeout(function(){null===t.popover&&(t.createPopover(),t.stylePopover(),t.updatePopover())},t.options.duration),t.link.setAttribute("data-timer",t.timer)},this.close=function(){clearTimeout(t.link.getAttribute("data-timer")),t.timer=setTimeout(function(){t.popover&&null!==t.popover&&t.popover.classList.contains("in")&&(t.popover.classList.remove("in"),setTimeout(function(){t.removePopover()},t.options.duration))},t.options.delay+t.options.duration),t.link.setAttribute("data-timer",t.timer)},this.removePopover=function(){this.popover&&this.options.container.removeChild(this.popover),this.popover=null,this.timer=null},this.createPopover=function(){if(this.popover=document.createElement("div"),null!==this.content&&null===this.options.template){this.popover.setAttribute("role","tooltip");var t=document.createElement("div");if(t.setAttribute("class","arrow"),null!==this.title){var e=document.createElement("h3");e.setAttribute("class","popover-title"),e.innerHTML=this.title,this.popover.appendChild(e)}var i=document.createElement("div");i.setAttribute("class","popover-content"),this.popover.appendChild(t),this.popover.appendChild(i),i.innerHTML=this.content}else{var o=document.createElement("div");o.innerHTML=this.options.template,this.popover.innerHTML=o.firstChild.innerHTML}this.options.container.appendChild(this.popover),this.popover.style.display="block"},this.stylePopover=function(t){this.rect=this.getRect();var e=t||this.options.placement,i="true"===this.options.animation?"fade":"";this.popover.setAttribute("class","popover "+e+" "+i);var o={w:this.link.offsetWidth,h:this.link.offsetHeight},n=this.popoverDimensions(this.popover),s={w:n.w,h:n.h},r=this.getScroll().y,a=this.getScroll().x;/top/.test(e)?(this.popover.style.top=this.rect.top+r-s.h+"px",this.popover.style.left=this.rect.left+a-s.w/2+o.w/2+"px"):/bottom/.test(e)?(this.popover.style.top=this.rect.top+r+o.h+"px",this.popover.style.left=this.rect.left+a-s.w/2+o.w/2+"px"):/left/.test(e)?(this.popover.style.top=this.rect.top+r-s.h/2+o.h/2+"px",this.popover.style.left=this.rect.left+a-s.w+"px"):/right/.test(e)&&(this.popover.style.top=this.rect.top+r-s.h/2+o.h/2+"px",this.popover.style.left=this.rect.left+a+o.w+"px")},this.updatePopover=function(){var e=null;e=t.isElementInViewport(t.popover)?t.options.placement:t.updatePlacement(),t.stylePopover(e),t.popover.classList.add("in")},this.updatePlacement=function(){var t=this.options.placement;return/top/.test(t)?"bottom":/bottom/.test(t)?"top":/left/.test(t)?"right":/right/.test(t)?"left":void 0},this.getRect=function(){return this.link.getBoundingClientRect()},this.getScroll=function(){return{y:window.pageYOffset||document.documentElement.scrollTop,x:window.pageXOffset||document.documentElement.scrollLeft}},this.popoverDimensions=function(t){return{w:t.offsetWidth,h:t.offsetHeight}},this.isElementInViewport=function(t){var e=t.getBoundingClientRect();return e.top>=0&&e.left>=0&&e.bottom<=(window.innerHeight||document.documentElement.clientHeight)&&e.right<=(window.innerWidth||document.documentElement.clientWidth)}}};var Popovers=document.querySelectorAll("[data-toggle=popover]");[].forEach.call(Popovers,function(t){var e={};return e.trigger=t.getAttribute("data-trigger"),e.animation=t.getAttribute("data-animation"),e.duration=t.getAttribute("data-duration"),e.placement=t.getAttribute("data-placement"),e.delay=t.getAttribute("data-delay"),new Popover(t,e)});var Button=function(t,e){this.btn="object"==typeof t?t:document.querySelector(t),this.option="string"==typeof e?e:null,this.init()};Button.prototype={init:function(){var t=this;this.actions(),this.btn.classList.contains("btn")&&(this.option&&"reset"!==this.option?(this.state=this.btn.getAttribute("data-"+this.option+"-text")||null,!this.btn.getAttribute("data-original-text")&&this.btn.setAttribute("data-original-text",t.btn.innerHTML.replace(/^\s+|\s+$/g,"")),this.setState()):"reset"===this.option&&this.reset()),this.btn.classList.contains("btn-group")&&this.btn.addEventListener("click",this.toggle,!1)},actions:function(){var t=this;this.setState=function(){"loading"===t.option&&(t.btn.classList.add("disabled"),t.btn.setAttribute("disabled","disabled")),t.btn.innerHTML=t.state},this.reset=function(){(t.btn.classList.contains("disabled")||"disabled"===t.btn.getAttribute("disabled"))&&(t.btn.classList.remove("disabled"),t.btn.removeAttribute("disabled")),t.btn.innerHTML=t.btn.getAttribute("data-original-text")},this.toggle=function(e){function i(t){t.dispatchEvent(a)}var o="INPUT"===e.target.tagName?e.target.parentNode:e.target,n=e.currentTarget||e.srcElement,s=n.querySelectorAll(".btn"),r=o.getElementsByTagName("INPUT")[0],a=new Event("change");"checkbox"===r.type&&(r.checked?(o.classList.remove("active"),r.removeAttribute("checked")):(o.classList.add("active"),r.setAttribute("checked","checked")),i(r),i(t.btn)),"radio"===r.type&&(r.checked||(o.classList.add("active"),r.setAttribute("checked","checked"),i(r),i(t.btn),[].forEach.call(s,function(t){if(t!==o&&t.classList.contains("active")){var e=t.getElementsByTagName("INPUT")[0];t.classList.remove("active"),e.removeAttribute("checked"),i(e)}})))}}};var Buttons=document.querySelectorAll("[data-toggle=button]");[].forEach.call(Buttons,function(t){return new Button(t)});var ButtonGroups=document.querySelectorAll("[data-toggle=buttons]");[].forEach.call(ButtonGroups,function(t){return new Button(t)});var Collapse=function(t,e){this.btn="object"==typeof t?t:document.querySelector(t),this.accordion=null,this.collapse=null,this.options={},this.duration=300,this.options.duration=document.documentElement.classList.contains("ie")?0:e.duration||this.duration,this.init()};Collapse.prototype={init:function(){this.actions(),this.btn.addEventListener("click",this.toggle,!1),document.addEventListener("click",this.update,!1),window.addEventListener("resize",this.update,!1)},actions:function(){var t=this;this.toggle=function(e){t.btn=t.getTarget(e).btn,t.collapse=t.getTarget(e).collapse,t.collapse.classList.contains("in")?t.close(e):t.open(e)},this.close=function(e){e.preventDefault(),t.btn=t.getTarget(e).btn,t.collapse=t.getTarget(e).collapse,t._close(t.collapse)},this.open=function(e){if(e.preventDefault(),t.btn=t.getTarget(e).btn,t.collapse=t.getTarget(e).collapse,t.accordion=t.btn.getAttribute("data-parent")&&t.getClosest(t.btn,t.btn.getAttribute("data-parent")),t._open(t.collapse),null!==t.accordion){var i=t.accordion.querySelectorAll(".collapse.in");[].forEach.call(i,function(e){e!==t.collapse&&t._close(e)})}},this._open=function(e){e.classList.add("in"),e.style.height=0,e.style.overflow="hidden",e.setAttribute("area-expanded","true");var i=this.getMaxHeight(e).oh,o=this.getMaxHeight(e).br;e.style.height=i+o+"px",setTimeout(function(){e.style.overflow=""},t.options.duration)},this._close=function(e){e.style.overflow="hidden",e.style.height=0,setTimeout(function(){e.classList.remove("in"),e.style.overflow="",e.setAttribute("area-expanded","false")},t.options.duration)},this.update=function(e){var i=e.type,o=e.target,n=document.querySelectorAll(".collapse.in");[].forEach.call(n,function(e){var n=t.getMaxHeight(e).oh,s=t.getMaxHeight(e).br;("resize"===i||"click"===i&&t.getClosest(o,".collapse")===e)&&setTimeout(function(){e.style.height=n+s+"px"},300)})},this.getMaxHeight=function(t){var e=t.children[0],i=t.currentStyle||window.getComputedStyle(t);return{oh:getOuterHeight(e),br:parseInt(i.borderTop||0)+parseInt(i.borderBottom||0)}},this.getTarget=function(t){var e=t.currentTarget||t.srcElement,i=e.href&&e.getAttribute("href").replace("#",""),o=e.getAttribute("data-target")&&e.getAttribute("data-target"),n=i||o&&/#/.test(o)&&o.replace("#",""),s=o&&"."===o.charAt(0)&&o,r=n&&document.getElementById(n)||s&&document.querySelector(s);return{btn:e,collapse:r}},this.getClosest=function(t,e){for(var i=e.charAt(0);t&&t!==document;t=t.parentNode){if("."===i&&t.classList.contains(e.substr(1)))return t;if("#"===i&&t.id===e.substr(1))return t}return!1}}},getOuterHeight=function(t){var e=t.currentStyle||window.getComputedStyle(t);return t.offsetHeight+parseInt(/px/.test(e.marginTop)?Math.round(e.marginTop.replace("px","")):0)+parseInt(/px/.test(e.marginBottom)?Math.round(e.marginBottom.replace("px","")):0)+parseInt(/em/.test(e.marginTop)?Math.round(e.marginTop.replace("em","")*parseInt(e.fontSize)):0)+parseInt(/em/.test(e.marginBottom)?Math.round(e.marginBottom.replace("em","")*parseInt(e.fontSize)):0)};var Collapses=document.querySelectorAll('[data-toggle="collapse"]');[].forEach.call(Collapses,function(t){var e={};return e.duration=t.getAttribute("data-duration"),new Collapse(t,e)}),window.addEventListener("load",function(){var t=document.querySelectorAll(".collapse");[].forEach.call(t,function(t){if(t.classList.contains("in")){var e=t.currentStyle||window.getComputedStyle(t),i=getOuterHeight(t.children[0]),o=parseInt(e.borderTop||0)+parseInt(e.borderBottom||0);t.style.height=i+o+"px"}})});var Carousel=function(t,e){this.carousel="object"==typeof t?t:document.querySelector(t),this.options={},this.options.keyboard=e&&"true"===e.keyboard?!0:!1,this.options.pause=e&&e.pause?e.pause:"hover",this.duration=600,this.options.duration=document.documentElement.classList.contains("ie")?0:e.duration||this.duration;var i=this.carousel.querySelectorAll(".item"),o=i.length;this.controls=this.carousel.querySelectorAll(".carousel-control"),this.prev=this.controls[0],this.next=this.controls[1],this.slides=[];for(var n=0;o>n;n++)this.slides.push(i[n]);this.indicator=this.carousel.querySelector(".carousel-indicators"),this.indicators=this.carousel.querySelectorAll(".carousel-indicators li"),this.total=this.slides.length,this.timer=null,this.direction=null,this.index=0,this.options.interval="false"===e.interval?!1:parseInt(e.interval)||5e3,this.init()};Carousel.prototype={init:function(){this.options.interval!==!1&&this.cycle(),this.options&&"hover"===this.options.pause&&this.options.interval!==!1&&this.pause(),this.actions(),this._addEventListeners()},cycle:function(t){var e=this;e.direction="left",e.timer=setInterval(function(){e.index++,e.index==e.slides.length&&(e.index=0),e._slideTo(e.index,t)},e.options.interval)},pause:function(){var t=this;pauseHandler=function(){t.options.interval===!1||t.carousel.classList.contains("paused")||(t.carousel.classList.add("paused"),clearInterval(t.timer),t.timer=null)},resumeHandler=function(){t.options.interval!==!1&&t.carousel.classList.contains("paused")&&(t.cycle(),t.carousel.classList.remove("paused"))},t.carousel.addEventListener("mouseenter",pauseHandler,!1),t.carousel.addEventListener("mouseleave",resumeHandler,!1),t.carousel.addEventListener("touchstart",pauseHandler,!1),t.carousel.addEventListener("touchend",resumeHandler,!1)},_slideTo:function(t){var e=this,i=e._getActiveIndex(),o=e.direction,n="left"===o?"next":"prev",s=new CustomEvent("slid.bs.carousel"),r=new CustomEvent("slide.bs.carousel");e.carousel.dispatchEvent(s),e._removeEventListeners(),clearInterval(e.timer),e.timer=null,e._curentPage(e.indicators[t]),this.carousel.classList.contains("slide")&&!document.documentElement.classList.contains("ie")?(e.slides[t].classList.add(n),e.slides[t].offsetWidth,e.slides[t].classList.add(o),e.slides[i].classList.add(o),setTimeout(function(){e._addEventListeners(),e.slides[t].classList.add("active"),e.slides[i].classList.remove("active"),e.slides[t].classList.remove(n),e.slides[t].classList.remove(o),e.slides[i].classList.remove(o),e.options.interval===!1||e.carousel.classList.contains("paused")||(clearInterval(e.timer),e.cycle()),e.carousel.dispatchEvent(r)},e.options.duration+100)):(e.slides[t].classList.add("active"),e.slides[t].offsetWidth,e.slides[i].classList.remove("active"),setTimeout(function(){e._addEventListeners(),e.options.interval===!1||e.carousel.classList.contains("paused")||(clearInterval(e.timer),e.cycle()),e.carousel.dispatchEvent(r)},e.options.duration+100))},_addEventListeners:function(){var t=this;t.next.addEventListener("click",t.controlsHandler,!1),t.prev.addEventListener("click",t.controlsHandler,!1),t.indicator.addEventListener("click",t.indicatorHandler,!1),t.options.keyboard===!0&&window.addEventListener("keydown",t.keyHandler,!1)},_removeEventListeners:function(){var t=this;t.next.removeEventListener("click",t.controlsHandler,!1),t.prev.removeEventListener("click",t.controlsHandler,!1),t.indicator.removeEventListener("click",t.indicatorHandler,!1),t.options.keyboard===!0&&window.removeEventListener("keydown",t.keyHandler,!1)},_getActiveIndex:function(){return this.slides.indexOf(this.carousel.querySelector(".item.active"))},_curentPage:function(t){for(var e=0;et.index||0===o&&t.index===t.total-1)&&(t.direction="right"),t._slideTo(t.index,e)},t.controlsHandler=function(e){var i=e.currentTarget||e.srcElement;e.preventDefault();t._getActiveIndex();i===t.next?(t.index++,t.direction="left",t.index==t.total-1?t.index=t.total-1:t.index==t.total&&(t.index=0)):i===t.prev&&(t.index--,t.direction="right",0==t.index?t.index=0:t.index<0&&(t.index=t.total-1)),t._slideTo(t.index,e)},t.keyHandler=function(e){switch(e.which){case 39:e.preventDefault(),t.index++,t.direction="left",t.index==t.total-1?t.index=t.total-1:t.index==t.total&&(t.index=0);break;case 37:e.preventDefault(),t.index--,t.direction="right",0==t.index?t.index=0:t.index<0&&(t.index=t.total-1);break;default:return}t._slideTo(t.index,e)}}};var Carousels=document.querySelectorAll('[data-ride="carousel"]');[].forEach.call(Carousels,function(t){var e=t,i={};return i.interval=e.getAttribute("data-interval")&&e.getAttribute("data-interval"),i.pause=e.getAttribute("data-pause")&&e.getAttribute("data-pause")||"hover",i.keyboard=e.getAttribute("data-keyboard")&&e.getAttribute("data-keyboard")||!1,i.duration=e.getAttribute("data-duration")&&e.getAttribute("data-duration")||!1,new Carousel(e,i)});var Tooltip=function(t,e){this.link="object"==typeof t?t:document.querySelector(t),this.title=this.link.getAttribute("title")||this.link.getAttribute("data-original-title"),this.tooltip=null,this.options={},this.options.animation=e.animation&&"fade"!==e.animation?e.animation:"fade",this.options.placement=e.placement?e.placement:"top",this.options.delay=parseInt(e.delay)||100,this.duration=150,this.options.duration=document.documentElement.classList.contains("ie")?0:e.duration||this.duration,this.options.container=e.container||document.body,this.title&&this.init(),this.timer=0};Tooltip.prototype={init:function(){this.actions(),this.rect=null,this.link.addEventListener("mouseenter",this.open,!1),this.link.addEventListener("mouseleave",this.close,!1),this.link.setAttribute("data-original-title",this.title),this.link.removeAttribute("title")},actions:function(){var t=this;this.open=function(){clearTimeout(t.link.getAttribute("data-timer")),t.timer=setTimeout(function(){null===t.tooltip&&(t.createToolTip(),t.styleTooltip(),t.updateTooltip())},t.options.duration),t.link.setAttribute("data-timer",t.timer)},this.close=function(){clearTimeout(t.link.getAttribute("data-timer")),t.timer=setTimeout(function(){t.tooltip&&null!==t.tooltip&&(t.tooltip.classList.remove("in"),setTimeout(function(){t.removeToolTip()},t.options.duration))},t.options.delay+t.options.duration),t.link.setAttribute("data-timer",t.timer)},this.removeToolTip=function(){this.tooltip&&this.options.container.removeChild(this.tooltip),this.tooltip=null},this.createToolTip=function(){this.tooltip=document.createElement("div"),this.tooltip.setAttribute("role","tooltip");var t=document.createElement("div");t.setAttribute("class","tooltip-arrow");var e=document.createElement("div");e.setAttribute("class","tooltip-inner"),this.tooltip.appendChild(t),this.tooltip.appendChild(e),e.innerHTML=this.title,this.options.container.appendChild(this.tooltip)},this.styleTooltip=function(t){this.rect=this.getRect();var e=t||this.options.placement;this.tooltip.setAttribute("class","tooltip "+e+" "+this.options.animation);var i={w:this.link.offsetWidth,h:this.link.offsetHeight},o=this.tooltipDimensions(this.tooltip),n={w:o.w,h:o.h},s=this.getScroll().y,r=this.getScroll().x;/top/.test(e)?(this.tooltip.style.top=this.rect.top+s-n.h+"px",this.tooltip.style.left=this.rect.left+r-n.w/2+i.w/2+"px"):/bottom/.test(e)?(this.tooltip.style.top=this.rect.top+s+i.h+"px",this.tooltip.style.left=this.rect.left+r-n.w/2+i.w/2+"px"):/left/.test(e)?(this.tooltip.style.top=this.rect.top+s-n.h/2+i.h/2+"px",this.tooltip.style.left=this.rect.left+r-n.w+"px"):/right/.test(e)&&(this.tooltip.style.top=this.rect.top+s-n.h/2+i.h/2+"px",this.tooltip.style.left=this.rect.left+r+i.w+"px")},this.updateTooltip=function(){var t=null;t=this.isElementInViewport(this.tooltip)?this.options.placement:this.updatePlacement(),this.styleTooltip(t),this.tooltip.classList.add("in")},this.updatePlacement=function(){var t=this.options.placement;return/top/.test(t)?"bottom":/bottom/.test(t)?"top":/left/.test(t)?"right":/right/.test(t)?"left":void 0},this.getRect=function(){return this.link.getBoundingClientRect()},this.getScroll=function(){return{y:window.pageYOffset||document.documentElement.scrollTop,x:window.pageXOffset||document.documentElement.scrollLeft}},this.tooltipDimensions=function(t){return{w:t.offsetWidth,h:t.offsetHeight}},this.isElementInViewport=function(t){var e=t.getBoundingClientRect();return e.top>=0&&e.left>=0&&e.bottom<=(window.innerHeight||document.documentElement.clientHeight)&&e.right<=(window.innerWidth||document.documentElement.clientWidth)}}};var Tooltips=document.querySelectorAll("[data-toggle=tooltip]");[].forEach.call(Tooltips,function(t){var e={};return e.animation=t.getAttribute("data-animation"),e.placement=t.getAttribute("data-placement"),e.duration=t.getAttribute("data-duration"),e.delay=t.getAttribute("data-delay"),new Tooltip(t,e)});var Dropdown=function(t){this.menu="object"==typeof t?t:document.querySelector(t),this.init()};Dropdown.prototype={init:function(){var t=this;t.actions(),t.menu.setAttribute("tabindex","0"),t.menu.addEventListener("click",t.toggle,!1),t.menu.addEventListener("blur",t.close,!1)},actions:function(){var t=this;t.toggle=function(t){var e=t.currentTarget||t.srcElement;return e.parentNode.classList.toggle("open"),t.preventDefault(),!1},t.close=function(t){var e=t.currentTarget||t.srcElement;setTimeout(function(){e.parentNode.classList.remove("open")},200)}}};var Dropdowns=document.querySelectorAll("[data-toggle=dropdown]");[].forEach.call(Dropdowns,function(t){return new Dropdown(t)}); \ No newline at end of file +var Modal=function(t,e){this.opened=!1,this.modal="object"==typeof t?t:document.querySelector(t),this.options={},this.options.backdrop="false"===e.backdrop?!1:!0,this.options.keyboard="false"===e.keyboard?!1:!0,this.options.content=e.content,this.duration=e.duration||300,this.options.duration=document.documentElement.classList.contains("ie")?0:this.duration,this.dialog=this.modal.querySelector(".modal-dialog"),this.timer=0,this.init()};Modal.prototype.init=function(){this.options.content&&void 0!==this.options.content&&this.content(this.options.content),this.resize(),this.dismiss(),this.keydown(),this.trigger()},Modal.prototype.open=function(){this._open()},Modal.prototype.close=function(){this._close()},Modal.prototype._open=function(){var t=this;this.options.backdrop?this.createOverlay():this.overlay=null,document.body.classList.add("modal-open"),this.modal.style.display="block",clearTimeout(t.modal.getAttribute("data-timer")),this.timer=setTimeout(function(){null!==t.overlay&&(t._resize(),t.overlay.classList.add("in")),t.modal.classList.add("in"),t.modal.setAttribute("aria-hidden",!1)},t.options.duration/2),this.modal.setAttribute("data-timer",t.timer),this.opened=!0},Modal.prototype._close=function(){var t=this;this.modal.classList.remove("in"),this.modal.setAttribute("aria-hidden",!0),this.overlay&&this.overlay.classList.remove("in"),document.body.classList.remove("modal-open"),clearTimeout(t.modal.getAttribute("data-timer")),this.timer=setTimeout(function(){t.modal.style.display="none",t.removeOverlay()},t.options.duration/2),this.modal.setAttribute("data-timer",t.timer),this.opened=!1},Modal.prototype.content=function(t){return this.modal.querySelector(".modal-content").innerHTML=t},Modal.prototype.createOverlay=function(){var t=document.createElement("div"),e=document.querySelector(".modal-backdrop");t.setAttribute("class","modal-backdrop fade"),e?this.overlay=e:(this.overlay=t,document.body.appendChild(t))},Modal.prototype.removeOverlay=function(){var t=document.querySelector(".modal-backdrop");null!==t&&void 0!==t&&document.body.removeChild(t)},Modal.prototype.keydown=function(){var t=this;document.addEventListener("keydown",function(e){t.options.keyboard&&27==e.which&&t.close()},!1)},Modal.prototype.trigger=function(){var t=this,e=document.querySelectorAll('[data-toggle="modal"]');[].forEach.call(e,function(e){e.addEventListener("click",function(e){var i=e.target,o=i.getAttribute("data-target")&&i.getAttribute("data-target").replace("#","")||i.getAttribute("href")&&i.getAttribute("href").replace("#","");document.getElementById(o)===t.modal&&t.open()})})},Modal.prototype._resize=function(){var t=this,e=this.overlay||document.querySelector(".modal-backdrop"),i={w:document.documentElement.clientWidth+"px",h:document.documentElement.clientHeight+"px"};setTimeout(function(){null!==e&&e.classList.contains("in")&&(e.style.height=i.h,e.style.width=i.w)},t.options.duration/2)},Modal.prototype.resize=function(){var t=this;window.addEventListener("resize",function(){setTimeout(function(){t._resize()},50)},!1)},Modal.prototype.dismiss=function(){var t=this;this.modal.addEventListener("click",function(e){"modal"===e.target.parentNode.getAttribute("data-dismiss")||"modal"===e.target.getAttribute("data-dismiss")||e.target===t.modal?(e.preventDefault(),t.close()):(e.stopPropagation(),e.preventDefault())})};var Modals=document.querySelectorAll(".modal");[].forEach.call(Modals,function(t){var e={};return e.keyboard=t.getAttribute("data-keyboard"),e.backdrop=t.getAttribute("data-backdrop"),e.duration=t.getAttribute("data-duration"),new Modal(t,e)});var Affix=function(t,e){this.element="object"==typeof t?t:document.querySelector(t),this.options={},this.options.target=e.target?"object"==typeof e.target?e.target:document.querySelector(e.target):null,this.options.offsetTop=e.offsetTop&&e.offsetTop?"function"===e.offsetTop?e.offsetTop():parseInt(e.offsetTop,0):0,this.options.offsetBottom=e.offsetBottom&&e.offsetBottom?"function"===e.offsetBottom?e.offsetBottom():parseInt(e.offsetBottom,0):null,this.element&&(this.options.target||this.options.offsetTop||this.options.offsetBottom)&&this.init()};Affix.prototype={init:function(){this.affixed=!1,this.affixedBottom=!1,this.getPinOffsetTop=0,this.getPinOffsetBottom=null,this.checkPosition(),this.updateAffix(),this.scrollEvent(),this.resizeEvent()},processOffsetTop:function(){return null!==this.options.target?this.targetRect().top+this.scrollOffset():null!==this.options.offsetTop?this.options.offsetTop:void 0},processOffsetBottom:function(){if(null!==this.options.offsetBottom){var t=this.getMaxScroll();return t-this.elementHeight()-this.options.offsetBottom}},offsetTop:function(){return this.processOffsetTop()},offsetBottom:function(){return this.processOffsetBottom()},checkPosition:function(){this.getPinOffsetTop=this.offsetTop,this.getPinOffsetBottom=this.offsetBottom},scrollOffset:function(){return window.pageYOffset||document.documentElement.scrollTop},pinTop:function(){this.element.classList&&!this.element.classList.contains("affix")&&this.element.classList.add("affix"),this.affixed=!0},unPinTop:function(){this.element.classList&&this.element.classList.contains("affix")&&this.element.classList.remove("affix"),this.affixed=!1},pinBottom:function(){this.element.classList&&!this.element.classList.contains("affix-bottom")&&this.element.classList.add("affix-bottom"),this.affixedBottom=!0},unPinBottom:function(){this.element.classList&&this.element.classList.contains("affix-bottom")&&this.element.classList.remove("affix-bottom"),this.affixedBottom=!1},updatePin:function(){this.affixed===!1&&parseInt(this.offsetTop(),0)-parseInt(this.scrollOffset(),0)<0?this.pinTop():this.affixed===!0&&parseInt(this.scrollOffset(),0)<=parseInt(this.getPinOffsetTop(),0)&&this.unPinTop(),this.affixedBottom===!1&&parseInt(this.offsetBottom(),0)-parseInt(this.scrollOffset(),0)<0?this.pinBottom():this.affixedBottom===!0&&parseInt(this.scrollOffset(),0)<=parseInt(this.getPinOffsetBottom(),0)&&this.unPinBottom()},updateAffix:function(){this.unPinTop(),this.unPinBottom(),this.checkPosition(),this.updatePin()},elementHeight:function(){return this.element.offsetHeight},targetRect:function(){return this.options.target.getBoundingClientRect()},getMaxScroll:function(){return Math.max(document.body.scrollHeight,document.body.offsetHeight,document.documentElement.clientHeight,document.documentElement.scrollHeight,document.documentElement.offsetHeight)},scrollEvent:function(){var t=this;window.addEventListener("scroll",affOnScroll=function(){t.updatePin()},!1)},resizeEvent:function(){var t=this;window.addEventListener("resize",affOnResize=function(){setTimeout(function(){t.updateAffix()},100)},!1)}};var Affixes=document.querySelectorAll('[data-spy="affix"]');[].forEach.call(Affixes,function(t){var e={};return e.offsetTop=t.getAttribute("data-offset-top"),e.offsetBottom=t.getAttribute("data-offset-bottom"),e.target=t.getAttribute("data-target"),!t||null===e.offsetTop&&null===e.offsetBottom&&null===e.target?void 0:new Affix(t,e)});var Alert=function(t){this.btn="object"==typeof t?t:document.querySelector(t),this.alert=null,this.duration=150,this.init()};Alert.prototype={init:function(){this.actions(),document.addEventListener("click",this.close,!1)},actions:function(){var t=this;this.close=function(e){var i=e.target;t.btn="alert"===i.getAttribute("data-dismiss")&&"close"===i.className?i:i.parentNode,t.alert=t.btn.parentNode,null!==t.alert&&"alert"===t.btn.getAttribute("data-dismiss")&&t.alert.classList.contains("in")&&(t.alert.classList.remove("in"),setTimeout(function(){t.alert&&t.alert.parentNode.removeChild(t.alert)},t.duration))}}};var Alerts=document.querySelectorAll('[data-dismiss="alert"]');[].forEach.call(Alerts,function(t){return new Alert(t)});var ScrollSpy=function(t,e,i){this.element="object"==typeof t?t:document.querySelector(t),this.options={},this.options.target=i.target?"object"==typeof i.target?i.target:document.querySelector(i.target):null,this.items=this.options.target&&this.options.target.getElementsByTagName("A"),this.item=e,this.parent=this.item.parentNode,this.parentParent=this.parent.parentNode.parentNode,this.tg=this.item.href&&document.getElementById(this.item.getAttribute("href").replace("#","")),this.active=!1,this.topEdge=0,this.bottomEdge=0,this.scrollTarget=this.element.offsetHeight-1&&(this.checkEdges(),this.refresh(),this.scrollEvent(),this.resizeEvent())},topLimit:function(){this.tg.currentStyle||window.getComputedStyle(this.tg),this.element.currentStyle||window.getComputedStyle(this.element);return this.scrollTarget===window?this.tg.getBoundingClientRect().top+this.scrollOffset():this.tg.offsetTop},bottomLimit:function(){this.tg.currentStyle||window.getComputedStyle(this.tg),this.element.currentStyle||window.getComputedStyle(this.element);return this.topLimit()+this.tg.offsetHeight},checkEdges:function(){this.topEdge=this.topLimit(),this.bottomEdge=this.bottomLimit()},scrollOffset:function(){return this.scrollTarget===window?window.pageYOffset||document.documentElement.scrollTop:this.element.scrollTop},activate:function(){this.parent&&"LI"===this.parent.tagName&&!this.parent.classList.contains("active")&&(this.parent.classList.add("active"),this.parentParent&&"LI"===this.parentParent.tagName&&this.parentParent.classList.contains("dropdown")&&!this.parentParent.classList.contains("active")&&this.parentParent.classList.add("active"),this.active=!0)},deactivate:function(){this.parent&&"LI"===this.parent.tagName&&this.parent.classList.contains("active")&&(this.parent.classList.remove("active"),this.parentParent&&"LI"===this.parentParent.tagName&&this.parentParent.classList.contains("dropdown")&&this.parentParent.classList.contains("active")&&this.parentParent.classList.remove("active"),this.active=!1)},toggle:function(){this.active===!1&&this.bottomEdge>this.scrollOffset()&&this.scrollOffset()>=this.topEdge?this.activate():this.active===!0&&this.bottomEdge<=this.scrollOffset()&&this.scrollOffset()1?e[e.length-1]:void console.log(e.length):e[0]},this.getActiveContent=function(){var e=t.getActiveTab().getElementsByTagName("A")[0].getAttribute("href").replace("#","");return e&&document.getElementById(e)}}};var Tabs=document.querySelectorAll("[data-toggle='tab'], [data-toggle='pill']");[].forEach.call(Tabs,function(t){var e={};return e.duration=t.getAttribute("data-duration")&&t.getAttribute("data-duration")||!1,new Tab(t,e)});var Popover=function(t,e){this.link="object"==typeof t?t:document.querySelector(t),this.title=this.link.getAttribute("data-title")||null,this.content=this.link.getAttribute("data-content")||null,this.popover=null,this.options={},this.options.template=e.template?e.template:null,this.options.trigger=e.trigger?e.trigger:"hover",this.options.animation=e.animation&&"true"!==e.animation?e.animation:"true",this.options.placement=e.placement?e.placement:"top",this.options.delay=parseInt(e.delay)||100,this.duration=150,this.options.duration=document.documentElement.classList.contains("ie")?0:e.duration||this.duration,this.options.container=document.body,(this.content||this.options.template)&&this.init(),this.timer=0,this.rect=null};Popover.prototype={init:function(){this.actions(),"hover"===this.options.trigger?(this.link.addEventListener("mouseenter",this.open,!1),this.link.addEventListener("mouseleave",this.close,!1)):"click"===this.options.trigger?(this.link.addEventListener("click",this.toggle,!1),this.link.addEventListener("blur",this.close,!1)):"focus"===this.options.trigger&&(this.link.addEventListener("focus",this.toggle,!1),this.link.addEventListener("blur",this.close,!1)),document.documentElement.classList.contains("ie")||"focus"!==this.options.trigger&&"click"!==this.options.trigger||window.addEventListener("resize",this.close,!1)},actions:function(){var t=this;this.toggle=function(){null===t.popover?t.open():t.close()},this.open=function(){clearTimeout(t.link.getAttribute("data-timer")),t.timer=setTimeout(function(){null===t.popover&&(t.createPopover(),t.stylePopover(),t.updatePopover())},t.options.duration),t.link.setAttribute("data-timer",t.timer)},this.close=function(){clearTimeout(t.link.getAttribute("data-timer")),t.timer=setTimeout(function(){t.popover&&null!==t.popover&&t.popover.classList.contains("in")&&(t.popover.classList.remove("in"),setTimeout(function(){t.removePopover()},t.options.duration))},t.options.delay+t.options.duration),t.link.setAttribute("data-timer",t.timer)},this.removePopover=function(){this.popover&&this.options.container.removeChild(this.popover),this.popover=null,this.timer=null},this.createPopover=function(){if(this.popover=document.createElement("div"),null!==this.content&&null===this.options.template){this.popover.setAttribute("role","tooltip");var t=document.createElement("div");if(t.setAttribute("class","arrow"),null!==this.title){var e=document.createElement("h3");e.setAttribute("class","popover-title"),e.innerHTML=this.title,this.popover.appendChild(e)}var i=document.createElement("div");i.setAttribute("class","popover-content"),this.popover.appendChild(t),this.popover.appendChild(i),i.innerHTML=this.content}else{var o=document.createElement("div");o.innerHTML=this.options.template,this.popover.innerHTML=o.firstChild.innerHTML}this.options.container.appendChild(this.popover),this.popover.style.display="block"},this.stylePopover=function(t){this.rect=this.getRect();var e=t||this.options.placement,i="true"===this.options.animation?"fade":"";this.popover.setAttribute("class","popover "+e+" "+i);var o={w:this.link.offsetWidth,h:this.link.offsetHeight},n=this.popoverDimensions(this.popover),s={w:n.w,h:n.h},r=this.getScroll().y,a=this.getScroll().x;/top/.test(e)?(this.popover.style.top=this.rect.top+r-s.h+"px",this.popover.style.left=this.rect.left+a-s.w/2+o.w/2+"px"):/bottom/.test(e)?(this.popover.style.top=this.rect.top+r+o.h+"px",this.popover.style.left=this.rect.left+a-s.w/2+o.w/2+"px"):/left/.test(e)?(this.popover.style.top=this.rect.top+r-s.h/2+o.h/2+"px",this.popover.style.left=this.rect.left+a-s.w+"px"):/right/.test(e)&&(this.popover.style.top=this.rect.top+r-s.h/2+o.h/2+"px",this.popover.style.left=this.rect.left+a+o.w+"px")},this.updatePopover=function(){var e=null;e=t.isElementInViewport(t.popover)?t.options.placement:t.updatePlacement(),t.stylePopover(e),t.popover.classList.add("in")},this.updatePlacement=function(){var t=this.options.placement;return/top/.test(t)?"bottom":/bottom/.test(t)?"top":/left/.test(t)?"right":/right/.test(t)?"left":void 0},this.getRect=function(){return this.link.getBoundingClientRect()},this.getScroll=function(){return{y:window.pageYOffset||document.documentElement.scrollTop,x:window.pageXOffset||document.documentElement.scrollLeft}},this.popoverDimensions=function(t){return{w:t.offsetWidth,h:t.offsetHeight}},this.isElementInViewport=function(t){var e=t.getBoundingClientRect();return e.top>=0&&e.left>=0&&e.bottom<=(window.innerHeight||document.documentElement.clientHeight)&&e.right<=(window.innerWidth||document.documentElement.clientWidth)}}};var Popovers=document.querySelectorAll("[data-toggle=popover]");[].forEach.call(Popovers,function(t){var e={};return e.trigger=t.getAttribute("data-trigger"),e.animation=t.getAttribute("data-animation"),e.duration=t.getAttribute("data-duration"),e.placement=t.getAttribute("data-placement"),e.delay=t.getAttribute("data-delay"),new Popover(t,e)});var Button=function(t,e){this.btn="object"==typeof t?t:document.querySelector(t),this.option="string"==typeof e?e:null,this.init()};Button.prototype={init:function(){var t=this;this.actions(),this.btn.classList.contains("btn")&&(this.option&&"reset"!==this.option?(this.state=this.btn.getAttribute("data-"+this.option+"-text")||null,!this.btn.getAttribute("data-original-text")&&this.btn.setAttribute("data-original-text",t.btn.innerHTML.replace(/^\s+|\s+$/g,"")),this.setState()):"reset"===this.option&&this.reset()),this.btn.classList.contains("btn-group")&&this.btn.addEventListener("click",this.toggle,!1)},actions:function(){var t=this;this.setState=function(){"loading"===t.option&&(t.btn.classList.add("disabled"),t.btn.setAttribute("disabled","disabled")),t.btn.innerHTML=t.state},this.reset=function(){(t.btn.classList.contains("disabled")||"disabled"===t.btn.getAttribute("disabled"))&&(t.btn.classList.remove("disabled"),t.btn.removeAttribute("disabled")),t.btn.innerHTML=t.btn.getAttribute("data-original-text")},this.toggle=function(e){function i(t){t.dispatchEvent(a)}var o="INPUT"===e.target.tagName?e.target.parentNode:e.target,n=e.currentTarget||e.srcElement,s=n.querySelectorAll(".btn"),r=o.getElementsByTagName("INPUT")[0],a=new Event("change");"checkbox"===r.type&&(r.checked?(o.classList.remove("active"),r.removeAttribute("checked")):(o.classList.add("active"),r.setAttribute("checked","checked")),i(r),i(t.btn)),"radio"===r.type&&(r.checked||(o.classList.add("active"),r.setAttribute("checked","checked"),i(r),i(t.btn),[].forEach.call(s,function(t){if(t!==o&&t.classList.contains("active")){var e=t.getElementsByTagName("INPUT")[0];t.classList.remove("active"),e.removeAttribute("checked"),i(e)}})))}}};var Buttons=document.querySelectorAll("[data-toggle=button]");[].forEach.call(Buttons,function(t){return new Button(t)});var ButtonGroups=document.querySelectorAll("[data-toggle=buttons]");[].forEach.call(ButtonGroups,function(t){return new Button(t)});var Collapse=function(t,e){this.btn="object"==typeof t?t:document.querySelector(t),this.accordion=null,this.collapse=null,this.options={},this.duration=300,this.options.duration=document.documentElement.classList.contains("ie")?0:e.duration||this.duration,this.init()};Collapse.prototype={init:function(){this.actions(),this.btn.addEventListener("click",this.toggle,!1),document.addEventListener("click",this.update,!1),window.addEventListener("resize",this.update,!1)},actions:function(){var t=this;this.toggle=function(e){t.btn=t.getTarget(e).btn,t.collapse=t.getTarget(e).collapse,t.collapse.classList.contains("in")?t.close(e):t.open(e)},this.close=function(e){e.preventDefault(),t.btn=t.getTarget(e).btn,t.collapse=t.getTarget(e).collapse,t._close(t.collapse)},this.open=function(e){if(e.preventDefault(),t.btn=t.getTarget(e).btn,t.collapse=t.getTarget(e).collapse,t.accordion=t.btn.getAttribute("data-parent")&&t.getClosest(t.btn,t.btn.getAttribute("data-parent")),t._open(t.collapse),null!==t.accordion){var i=t.accordion.querySelectorAll(".collapse.in");[].forEach.call(i,function(e){e!==t.collapse&&t._close(e)})}},this._open=function(e){e.classList.add("in"),e.style.height=0,e.style.overflow="hidden",e.setAttribute("area-expanded","true");var i=this.getMaxHeight(e).oh,o=this.getMaxHeight(e).br;e.style.height=i+o+"px",setTimeout(function(){e.style.overflow=""},t.options.duration)},this._close=function(e){e.style.overflow="hidden",e.style.height=0,setTimeout(function(){e.classList.remove("in"),e.style.overflow="",e.setAttribute("area-expanded","false")},t.options.duration)},this.update=function(e){var i=e.type,o=e.target,n=document.querySelectorAll(".collapse.in");[].forEach.call(n,function(e){var n=t.getMaxHeight(e).oh,s=t.getMaxHeight(e).br;("resize"===i||"click"===i&&t.getClosest(o,".collapse")===e)&&setTimeout(function(){e.style.height=n+s+"px"},300)})},this.getMaxHeight=function(t){var e=t.children[0],i=t.currentStyle||window.getComputedStyle(t);return{oh:getOuterHeight(e),br:parseInt(i.borderTop||0)+parseInt(i.borderBottom||0)}},this.getTarget=function(t){var e=t.currentTarget||t.srcElement,i=e.href&&e.getAttribute("href").replace("#",""),o=e.getAttribute("data-target")&&e.getAttribute("data-target"),n=i||o&&/#/.test(o)&&o.replace("#",""),s=o&&"."===o.charAt(0)&&o,r=n&&document.getElementById(n)||s&&document.querySelector(s);return{btn:e,collapse:r}},this.getClosest=function(t,e){for(var i=e.charAt(0);t&&t!==document;t=t.parentNode){if("."===i&&t.classList.contains(e.substr(1)))return t;if("#"===i&&t.id===e.substr(1))return t}return!1}}},getOuterHeight=function(t){var e=t.currentStyle||window.getComputedStyle(t);return t.offsetHeight+parseInt(/px/.test(e.marginTop)?Math.round(e.marginTop.replace("px","")):0)+parseInt(/px/.test(e.marginBottom)?Math.round(e.marginBottom.replace("px","")):0)+parseInt(/em/.test(e.marginTop)?Math.round(e.marginTop.replace("em","")*parseInt(e.fontSize)):0)+parseInt(/em/.test(e.marginBottom)?Math.round(e.marginBottom.replace("em","")*parseInt(e.fontSize)):0)};var Collapses=document.querySelectorAll('[data-toggle="collapse"]');[].forEach.call(Collapses,function(t){var e={};return e.duration=t.getAttribute("data-duration"),new Collapse(t,e)}),window.addEventListener("load",function(){var t=document.querySelectorAll(".collapse");[].forEach.call(t,function(t){if(t.classList.contains("in")){var e=t.currentStyle||window.getComputedStyle(t),i=getOuterHeight(t.children[0]),o=parseInt(e.borderTop||0)+parseInt(e.borderBottom||0);t.style.height=i+o+"px"}})});var Carousel=function(t,e){this.carousel="object"==typeof t?t:document.querySelector(t),this.options={},this.options.keyboard=e&&"true"===e.keyboard?!0:!1,this.options.pause=e&&e.pause?e.pause:"hover",this.duration=600,this.options.duration=document.documentElement.classList.contains("ie")?0:e.duration||this.duration;var i=this.carousel.querySelectorAll(".item"),o=i.length;this.controls=this.carousel.querySelectorAll(".carousel-control"),this.prev=this.controls[0],this.next=this.controls[1],this.slides=[];for(var n=0;o>n;n++)this.slides.push(i[n]);this.indicator=this.carousel.querySelector(".carousel-indicators"),this.indicators=this.carousel.querySelectorAll(".carousel-indicators li"),this.total=this.slides.length,this.timer=null,this.direction=null,this.index=0,this.options.interval="false"===e.interval?!1:parseInt(e.interval)||5e3,this.init()};Carousel.prototype={init:function(){this.options.interval!==!1&&this.cycle(),this.options&&"hover"===this.options.pause&&this.options.interval!==!1&&this.pause(),this.actions(),this._addEventListeners()},cycle:function(t){var e=this;e.direction="left",e.timer=setInterval(function(){e.index++,e.index==e.slides.length&&(e.index=0),e._slideTo(e.index,t)},e.options.interval)},pause:function(){var t=this;pauseHandler=function(){t.options.interval===!1||t.carousel.classList.contains("paused")||(t.carousel.classList.add("paused"),clearInterval(t.timer),t.timer=null)},resumeHandler=function(){t.options.interval!==!1&&t.carousel.classList.contains("paused")&&(t.cycle(),t.carousel.classList.remove("paused"))},t.carousel.addEventListener("mouseenter",pauseHandler,!1),t.carousel.addEventListener("mouseleave",resumeHandler,!1),t.carousel.addEventListener("touchstart",pauseHandler,!1),t.carousel.addEventListener("touchend",resumeHandler,!1)},_slideTo:function(t){var e=this,i=e._getActiveIndex(),o=e.direction,n="left"===o?"next":"prev",s=new CustomEvent("slid.bs.carousel"),r=new CustomEvent("slide.bs.carousel");e.carousel.dispatchEvent(s),e._removeEventListeners(),clearInterval(e.timer),e.timer=null,e._curentPage(e.indicators[t]),this.carousel.classList.contains("slide")&&!document.documentElement.classList.contains("ie")?(e.slides[t].classList.add(n),e.slides[t].offsetWidth,e.slides[t].classList.add(o),e.slides[i].classList.add(o),setTimeout(function(){e._addEventListeners(),e.slides[t].classList.add("active"),e.slides[i].classList.remove("active"),e.slides[t].classList.remove(n),e.slides[t].classList.remove(o),e.slides[i].classList.remove(o),e.options.interval===!1||e.carousel.classList.contains("paused")||(clearInterval(e.timer),e.cycle()),e.carousel.dispatchEvent(r)},e.options.duration+100)):(e.slides[t].classList.add("active"),e.slides[t].offsetWidth,e.slides[i].classList.remove("active"),setTimeout(function(){e._addEventListeners(),e.options.interval===!1||e.carousel.classList.contains("paused")||(clearInterval(e.timer),e.cycle()),e.carousel.dispatchEvent(r)},e.options.duration+100))},_addEventListeners:function(){var t=this;t.next.addEventListener("click",t.controlsHandler,!1),t.prev.addEventListener("click",t.controlsHandler,!1),t.indicator.addEventListener("click",t.indicatorHandler,!1),t.options.keyboard===!0&&window.addEventListener("keydown",t.keyHandler,!1)},_removeEventListeners:function(){var t=this;t.next.removeEventListener("click",t.controlsHandler,!1),t.prev.removeEventListener("click",t.controlsHandler,!1),t.indicator.removeEventListener("click",t.indicatorHandler,!1),t.options.keyboard===!0&&window.removeEventListener("keydown",t.keyHandler,!1)},_getActiveIndex:function(){return this.slides.indexOf(this.carousel.querySelector(".item.active"))},_curentPage:function(t){for(var e=0;et.index||0===o&&t.index===t.total-1)&&(t.direction="right"),t._slideTo(t.index,e)},t.controlsHandler=function(e){var i=e.currentTarget||e.srcElement;e.preventDefault();t._getActiveIndex();i===t.next?(t.index++,t.direction="left",t.index==t.total-1?t.index=t.total-1:t.index==t.total&&(t.index=0)):i===t.prev&&(t.index--,t.direction="right",0==t.index?t.index=0:t.index<0&&(t.index=t.total-1)),t._slideTo(t.index,e)},t.keyHandler=function(e){switch(e.which){case 39:e.preventDefault(),t.index++,t.direction="left",t.index==t.total-1?t.index=t.total-1:t.index==t.total&&(t.index=0);break;case 37:e.preventDefault(),t.index--,t.direction="right",0==t.index?t.index=0:t.index<0&&(t.index=t.total-1);break;default:return}t._slideTo(t.index,e)}}};var Carousels=document.querySelectorAll('[data-ride="carousel"]');[].forEach.call(Carousels,function(t){var e=t,i={};return i.interval=e.getAttribute("data-interval")&&e.getAttribute("data-interval"),i.pause=e.getAttribute("data-pause")&&e.getAttribute("data-pause")||"hover",i.keyboard=e.getAttribute("data-keyboard")&&e.getAttribute("data-keyboard")||!1,i.duration=e.getAttribute("data-duration")&&e.getAttribute("data-duration")||!1,new Carousel(e,i)});var Tooltip=function(t,e){this.link="object"==typeof t?t:document.querySelector(t),this.title=this.link.getAttribute("title")||this.link.getAttribute("data-original-title"),this.tooltip=null,this.options={},this.options.animation=e.animation&&"fade"!==e.animation?e.animation:"fade",this.options.placement=e.placement?e.placement:"top",this.options.delay=parseInt(e.delay)||100,this.duration=150,this.options.duration=document.documentElement.classList.contains("ie")?0:e.duration||this.duration,this.options.container=e.container||document.body,this.title&&this.init(),this.timer=0};Tooltip.prototype={init:function(){this.actions(),this.rect=null,this.link.addEventListener("mouseenter",this.open,!1),this.link.addEventListener("mouseleave",this.close,!1),this.link.setAttribute("data-original-title",this.title),this.link.removeAttribute("title")},actions:function(){var t=this;this.open=function(){clearTimeout(t.link.getAttribute("data-timer")),t.timer=setTimeout(function(){null===t.tooltip&&(t.createToolTip(),t.styleTooltip(),t.updateTooltip())},t.options.duration),t.link.setAttribute("data-timer",t.timer)},this.close=function(){clearTimeout(t.link.getAttribute("data-timer")),t.timer=setTimeout(function(){t.tooltip&&null!==t.tooltip&&(t.tooltip.classList.remove("in"),setTimeout(function(){t.removeToolTip()},t.options.duration))},t.options.delay+t.options.duration),t.link.setAttribute("data-timer",t.timer)},this.removeToolTip=function(){this.tooltip&&this.options.container.removeChild(this.tooltip),this.tooltip=null},this.createToolTip=function(){this.tooltip=document.createElement("div"),this.tooltip.setAttribute("role","tooltip");var t=document.createElement("div");t.setAttribute("class","tooltip-arrow");var e=document.createElement("div");e.setAttribute("class","tooltip-inner"),this.tooltip.appendChild(t),this.tooltip.appendChild(e),e.innerHTML=this.title,this.options.container.appendChild(this.tooltip)},this.styleTooltip=function(t){this.rect=this.getRect();var e=t||this.options.placement;this.tooltip.setAttribute("class","tooltip "+e+" "+this.options.animation);var i={w:this.link.offsetWidth,h:this.link.offsetHeight},o=this.tooltipDimensions(this.tooltip),n={w:o.w,h:o.h},s=this.getScroll().y,r=this.getScroll().x;/top/.test(e)?(this.tooltip.style.top=this.rect.top+s-n.h+"px",this.tooltip.style.left=this.rect.left+r-n.w/2+i.w/2+"px"):/bottom/.test(e)?(this.tooltip.style.top=this.rect.top+s+i.h+"px",this.tooltip.style.left=this.rect.left+r-n.w/2+i.w/2+"px"):/left/.test(e)?(this.tooltip.style.top=this.rect.top+s-n.h/2+i.h/2+"px",this.tooltip.style.left=this.rect.left+r-n.w+"px"):/right/.test(e)&&(this.tooltip.style.top=this.rect.top+s-n.h/2+i.h/2+"px",this.tooltip.style.left=this.rect.left+r+i.w+"px")},this.updateTooltip=function(){var t=null;t=this.isElementInViewport(this.tooltip)?this.options.placement:this.updatePlacement(),this.styleTooltip(t),this.tooltip.classList.add("in")},this.updatePlacement=function(){var t=this.options.placement;return/top/.test(t)?"bottom":/bottom/.test(t)?"top":/left/.test(t)?"right":/right/.test(t)?"left":void 0},this.getRect=function(){return this.link.getBoundingClientRect()},this.getScroll=function(){return{y:window.pageYOffset||document.documentElement.scrollTop,x:window.pageXOffset||document.documentElement.scrollLeft}},this.tooltipDimensions=function(t){return{w:t.offsetWidth,h:t.offsetHeight}},this.isElementInViewport=function(t){var e=t.getBoundingClientRect();return e.top>=0&&e.left>=0&&e.bottom<=(window.innerHeight||document.documentElement.clientHeight)&&e.right<=(window.innerWidth||document.documentElement.clientWidth)}}};var Tooltips=document.querySelectorAll("[data-toggle=tooltip]");[].forEach.call(Tooltips,function(t){var e={};return e.animation=t.getAttribute("data-animation"),e.placement=t.getAttribute("data-placement"),e.duration=t.getAttribute("data-duration"),e.delay=t.getAttribute("data-delay"),new Tooltip(t,e)});var Dropdown=function(t){this.menu="object"==typeof t?t:document.querySelector(t),this.init()};Dropdown.prototype={init:function(){var t=this;t.actions(),t.menu.setAttribute("tabindex","0"),t.menu.addEventListener("click",t.toggle,!1),t.menu.addEventListener("blur",t.close,!1)},actions:function(){var t=this;t.toggle=function(t){var e=t.currentTarget||t.srcElement;return e.parentNode.classList.toggle("open"),t.preventDefault(),!1},t.close=function(t){var e=t.currentTarget||t.srcElement;setTimeout(function(){e.parentNode.classList.remove("open")},200)}}};var Dropdowns=document.querySelectorAll("[data-toggle=dropdown]");[].forEach.call(Dropdowns,function(t){return new Dropdown(t)}); \ No newline at end of file diff --git a/index.html b/index.html index 8b5c1a74..42859c35 100644 --- a/index.html +++ b/index.html @@ -20,7 +20,7 @@ - + @@ -153,7 +153,7 @@

Use

Load from CDN

Thanks to jsdelivr we have a CDN link, so drop this line before your ending </body> tag. Latest releases come here.


-					<script type="text/javascript" src="https://cdn.jsdelivr.net/bootstrap.native/0.9.2/bootstrap-native.min.js"></script>
+					<script type="text/javascript" src="https://cdn.jsdelivr.net/bootstrap.native/0.9.3/bootstrap-native.min.js"></script>
 				

As most of the scripts manipulate the DOM when ready, there is no need to include a document.ready statement or link the script(s) in the <head>. That's your first performance tip if you are new around here.

Working locally

@@ -943,7 +943,8 @@

Navigation

- + + diff --git a/lib/min/modal-native.min.js b/lib/min/modal-native.min.js index 9bfed7de..9944f836 100644 --- a/lib/min/modal-native.min.js +++ b/lib/min/modal-native.min.js @@ -1,4 +1,4 @@ //Vanilla JS script | Modal for Bootstrap 3 //by dnp_theme -var Modal=function(t,e){this.opened=!1,this.modal="object"==typeof t?t:document.querySelector(t),this.options={},this.options.backdrop="false"===e.backdrop?!1:!0,this.options.keyboard="false"===e.keyboard?!1:!0,this.options.content=e.content,this.duration=e.duration||300,this.options.duration=document.documentElement.classList.contains("ie")?0:this.duration,this.dialog=this.modal.querySelector(".modal-dialog"),void 0!==this.options.content&&this.content(this.options.content),this.resize(),this.dismiss(),this.keydown(),this.trigger()};Modal.prototype.open=function(){this._open()},Modal.prototype._open=function(){var t=this;document.body.classList.add("modal-open"),this.modal.style.display="block",this.options.backdrop?this.createOverlay():this.overlay=null,setTimeout(function(){t.modal.classList.add("in"),null!==t.overlay&&(t._resize(),t.overlay.classList.add("in")),t.modal.setAttribute("aria-hidden",!1)},t.options.duration/2),this.opened=!0},Modal.prototype.close=function(){this._close()},Modal.prototype._close=function(){var t=this;this.modal.classList.remove("in"),this.modal.setAttribute("aria-hidden",!0),this.overlay&&this.overlay.classList.remove("in"),document.body.classList.remove("modal-open"),setTimeout(function(){t.modal.style.display="none",t.overlay&&t.removeOverlay()},t.options.duration),this.opened=!1},Modal.prototype.content=function(t){return this.modal.querySelector(".modal-content").innerHTML=t},Modal.prototype.createOverlay=function(){if(void 0===this.overlay||null===this.overlay){var t=document.createElement("div");t.setAttribute("class","modal-backdrop fade"),this.overlay=t,document.body.appendChild(t)}},Modal.prototype.removeOverlay=function(){this.overlay===document.querySelector(".modal-backdrop")&&document.body.removeChild(this.overlay)},Modal.prototype.keydown=function(){var t=this;document.addEventListener("keydown",function(e){t.options.keyboard&&27==e.which&&t.close()},!1)},Modal.prototype.trigger=function(){var t=this,e=document.querySelectorAll('[data-toggle="modal"]');[].forEach.call(e,function(e){e.addEventListener("click",function(e){var o=e.target,i=o.getAttribute("data-target")&&o.getAttribute("data-target").replace("#","")||o.getAttribute("href")&&o.getAttribute("href").replace("#","");document.getElementById(i)===t.modal&&t.open()})})},Modal.prototype._resize=function(){var t=this,e=this.overlay||document.querySelector(".modal-backdrop"),o={w:document.documentElement.clientWidth+"px",h:document.documentElement.clientHeight+"px"};setTimeout(function(){null!==e&&e.classList.contains("in")&&(e.style.height=o.h,e.style.width=o.w)},t.options.duration/2)},Modal.prototype.resize=function(){var t=this;window.addEventListener("resize",function(){setTimeout(function(){t._resize()},50)},!1)},Modal.prototype.dismiss=function(){var t=this;this.modal.addEventListener("click",function(e){"modal"===e.target.parentNode.getAttribute("data-dismiss")||"modal"===e.target.getAttribute("data-dismiss")||e.target===t.modal?t.close():(e.stopPropagation(),e.preventDefault())})};var Modals=document.querySelectorAll(".modal");[].forEach.call(Modals,function(t){var e={};return e.keyboard=t.getAttribute("data-keyboard")&&t.getAttribute("data-keyboard"),e.backdrop=t.getAttribute("data-backdrop")&&t.getAttribute("data-backdrop"),e.duration=t.getAttribute("data-duration")&&t.getAttribute("data-duration"),new Modal(t,e)}); \ No newline at end of file +var Modal=function(t,e){this.opened=!1,this.modal="object"==typeof t?t:document.querySelector(t),this.options={},this.options.backdrop="false"===e.backdrop?!1:!0,this.options.keyboard="false"===e.keyboard?!1:!0,this.options.content=e.content,this.duration=e.duration||300,this.options.duration=document.documentElement.classList.contains("ie")?0:this.duration,this.dialog=this.modal.querySelector(".modal-dialog"),this.timer=0,this.init()};Modal.prototype.init=function(){this.options.content&&void 0!==this.options.content&&this.content(this.options.content),this.resize(),this.dismiss(),this.keydown(),this.trigger()},Modal.prototype.open=function(){this._open()},Modal.prototype.close=function(){this._close()},Modal.prototype._open=function(){var t=this;this.options.backdrop?this.createOverlay():this.overlay=null,document.body.classList.add("modal-open"),this.modal.style.display="block",clearTimeout(t.modal.getAttribute("data-timer")),this.timer=setTimeout(function(){null!==t.overlay&&(t._resize(),t.overlay.classList.add("in")),t.modal.classList.add("in"),t.modal.setAttribute("aria-hidden",!1)},t.options.duration/2),this.modal.setAttribute("data-timer",t.timer),this.opened=!0},Modal.prototype._close=function(){var t=this;this.modal.classList.remove("in"),this.modal.setAttribute("aria-hidden",!0),this.overlay&&this.overlay.classList.remove("in"),document.body.classList.remove("modal-open"),clearTimeout(t.modal.getAttribute("data-timer")),this.timer=setTimeout(function(){t.modal.style.display="none",t.removeOverlay()},t.options.duration/2),this.modal.setAttribute("data-timer",t.timer),this.opened=!1},Modal.prototype.content=function(t){return this.modal.querySelector(".modal-content").innerHTML=t},Modal.prototype.createOverlay=function(){var t=document.createElement("div"),e=document.querySelector(".modal-backdrop");t.setAttribute("class","modal-backdrop fade"),e?this.overlay=e:(this.overlay=t,document.body.appendChild(t))},Modal.prototype.removeOverlay=function(){var t=document.querySelector(".modal-backdrop");null!==t&&void 0!==t&&document.body.removeChild(t)},Modal.prototype.keydown=function(){var t=this;document.addEventListener("keydown",function(e){t.options.keyboard&&27==e.which&&t.close()},!1)},Modal.prototype.trigger=function(){var t=this,e=document.querySelectorAll('[data-toggle="modal"]');[].forEach.call(e,function(e){e.addEventListener("click",function(e){var o=e.target,i=o.getAttribute("data-target")&&o.getAttribute("data-target").replace("#","")||o.getAttribute("href")&&o.getAttribute("href").replace("#","");document.getElementById(i)===t.modal&&t.open()})})},Modal.prototype._resize=function(){var t=this,e=this.overlay||document.querySelector(".modal-backdrop"),o={w:document.documentElement.clientWidth+"px",h:document.documentElement.clientHeight+"px"};setTimeout(function(){null!==e&&e.classList.contains("in")&&(e.style.height=o.h,e.style.width=o.w)},t.options.duration/2)},Modal.prototype.resize=function(){var t=this;window.addEventListener("resize",function(){setTimeout(function(){t._resize()},50)},!1)},Modal.prototype.dismiss=function(){var t=this;this.modal.addEventListener("click",function(e){"modal"===e.target.parentNode.getAttribute("data-dismiss")||"modal"===e.target.getAttribute("data-dismiss")||e.target===t.modal?(e.preventDefault(),t.close()):(e.stopPropagation(),e.preventDefault())})};var Modals=document.querySelectorAll(".modal");[].forEach.call(Modals,function(t){var e={};return e.keyboard=t.getAttribute("data-keyboard"),e.backdrop=t.getAttribute("data-backdrop"),e.duration=t.getAttribute("data-duration"),new Modal(t,e)}); \ No newline at end of file diff --git a/lib/modal-native.js b/lib/modal-native.js index 1ce3d983..8e076c80 100644 --- a/lib/modal-native.js +++ b/lib/modal-native.js @@ -18,45 +18,54 @@ this.options.duration = document.documentElement.classList.contains('ie') ? 0 : this.duration; this.dialog = this.modal.querySelector('.modal-dialog'); + this.timer = 0; - if ( this.options.content !== undefined ) { - this.content( this.options.content ); - } - + this.init() + } + + Modal.prototype.init = function() { + if ( this.options.content && this.options.content !== undefined ) { + this.content( this.options.content ); + } this.resize(); this.dismiss(); this.keydown(); - this.trigger(); - } + this.trigger(); + } Modal.prototype.open = function() { this._open(); } + Modal.prototype.close = function() { + this._close(); + } + Modal.prototype._open = function() { var self = this; - - document.body.classList.add('modal-open'); - this.modal.style.display = 'block'; if ( this.options.backdrop ) { this.createOverlay(); - } else { this.overlay = null } - + } else { this.overlay = null } + + document.body.classList.add('modal-open'); + this.modal.style.display = 'block'; - setTimeout(function() { + clearTimeout(self.modal.getAttribute('data-timer')); + this.timer = setTimeout( function() { + + if ( self.overlay !== null ) { + self._resize(); + self.overlay.classList.add('in'); + } self.modal.classList.add('in'); - if ( self.overlay !== null ) { self._resize(); self.overlay.classList.add('in'); } self.modal.setAttribute('aria-hidden', false); }, self.options.duration/2); + this.modal.setAttribute('data-timer',self.timer); this.opened = true; } - Modal.prototype.close = function() { - this._close(); - } - Modal.prototype._close = function() { var self = this; @@ -66,10 +75,13 @@ if ( this.overlay ) this.overlay.classList.remove('in'); document.body.classList.remove('modal-open'); - setTimeout(function() { + clearTimeout(self.modal.getAttribute('data-timer')); + this.timer = setTimeout( function() { self.modal.style.display = 'none'; - if ( self.overlay ) self.removeOverlay(); - }, self.options.duration); + self.removeOverlay(); + }, self.options.duration/2); + this.modal.setAttribute('data-timer',self.timer); + this.opened = false; } @@ -78,17 +90,21 @@ } Modal.prototype.createOverlay = function() { - if (this.overlay === undefined || this.overlay === null ) { - var backdrop = document.createElement('div'); - backdrop.setAttribute('class','modal-backdrop fade'); + var backdrop = document.createElement('div'), overlay = document.querySelector('.modal-backdrop'); + backdrop.setAttribute('class','modal-backdrop fade'); + + if ( overlay ) { + this.overlay = overlay; + } else { this.overlay = backdrop; - document.body.appendChild(backdrop); - } + document.body.appendChild(backdrop); + } } Modal.prototype.removeOverlay = function() { - if ( this.overlay === document.querySelector('.modal-backdrop') ) { - document.body.removeChild(this.overlay) + var overlay = document.querySelector('.modal-backdrop'); + if ( overlay !== null && overlay !== undefined ) { + document.body.removeChild(overlay) } } @@ -110,14 +126,15 @@ s = b.getAttribute('data-target') && b.getAttribute('data-target').replace('#','') || b.getAttribute('href') && b.getAttribute('href').replace('#',''); if ( document.getElementById( s ) === self.modal ) { - self.open() + self.open() } - }) + }) }) } Modal.prototype._resize = function() { - var self = this, overlay = this.overlay||document.querySelector('.modal-backdrop'), dim = { w: document.documentElement.clientWidth + 'px', h: document.documentElement.clientHeight + 'px' }; + var self = this, overlay = this.overlay||document.querySelector('.modal-backdrop'), + dim = { w: document.documentElement.clientWidth + 'px', h: document.documentElement.clientHeight + 'px' }; setTimeout(function() { if ( overlay !== null && overlay.classList.contains('in') ) { overlay.style.height = dim.h; overlay.style.width = dim.w @@ -130,7 +147,7 @@ window.addEventListener('resize', function() { setTimeout(function() { self._resize() - }, 50) + }, 50) }, false); } @@ -138,17 +155,18 @@ var self = this; this.modal.addEventListener('click', function(e){ if ( e.target.parentNode.getAttribute('data-dismiss') === 'modal' || e.target.getAttribute('data-dismiss') === 'modal' || e.target === self.modal ) { - self.close() - } else { e.stopPropagation(); e.preventDefault(); } + e.preventDefault(); self.close() + } else { e.stopPropagation(); e.preventDefault(); } }) } var Modals = document.querySelectorAll('.modal'); [].forEach.call(Modals,function(modal,idx) { var options = {}; - options.keyboard = modal.getAttribute('data-keyboard') && modal.getAttribute('data-keyboard'); - options.backdrop = modal.getAttribute('data-backdrop') && modal.getAttribute('data-backdrop'); - options.duration = modal.getAttribute('data-duration') && modal.getAttribute('data-duration'); - return new Modal(modal,options) + options.keyboard = modal.getAttribute('data-keyboard'); + options.backdrop = modal.getAttribute('data-backdrop'); + options.duration = modal.getAttribute('data-duration'); + return new Modal(modal,options) }) + // })();