1(function(root,factory){if(typeof define==='function'&&define.amd){define(factory)}else if(typeof exports==='object'){module.exports=factory()}else{root.tingle=factory()}}(this,function(){var isBusy=!1 2function Modal(options){var defaults={onClose:null,onOpen:null,beforeOpen:null,beforeClose:null,stickyFooter:!1,footer:!1,cssClass:[],closeLabel:'Close',closeMethods:['overlay','button','escape']} 3this.opts=extend({},defaults,options) 4this.init()} 5Modal.prototype.init=function(){if(this.modal){return} 6_build.call(this) 7_bindEvents.call(this) 8document.body.appendChild(this.modal,document.body.firstChild) 9if(this.opts.footer){this.addFooter()} 10return this} 11Modal.prototype._busy=function(state){isBusy=state} 12Modal.prototype._isBusy=function(){return isBusy} 13Modal.prototype.destroy=function(){if(this.modal===null){return} 14if(this.isOpen()){this.close(!0)} 15_unbindEvents.call(this) 16this.modal.parentNode.removeChild(this.modal) 17this.modal=null} 18Modal.prototype.isOpen=function(){return!!this.modal.classList.contains('tingle-modal--visible')} 19Modal.prototype.open=function(){if(this._isBusy())return 20this._busy(!0) 21var self=this 22if(typeof self.opts.beforeOpen==='function'){self.opts.beforeOpen()} 23if(this.modal.style.removeProperty){this.modal.style.removeProperty('display')}else{this.modal.style.removeAttribute('display')} 24this._scrollPosition=window.pageYOffset 25document.body.classList.add('tingle-enabled') 26document.body.style.top=-this._scrollPosition+'px' 27this.setStickyFooter(this.opts.stickyFooter) 28this.modal.classList.add('tingle-modal--visible') 29if(typeof self.opts.onOpen==='function'){self.opts.onOpen.call(self)} 30self._busy(!1) 31this.checkOverflow() 32return this} 33Modal.prototype.close=function(force){if(this._isBusy())return 34this._busy(!0) 35force=force||!1 36if(typeof this.opts.beforeClose==='function'){var close=this.opts.beforeClose.call(this) 37if(!close){this._busy(!1) 38return}} 39document.body.classList.remove('tingle-enabled') 40document.body.style.top=null 41window.scrollTo({top:this._scrollPosition,behavior:'instant'}) 42this.modal.classList.remove('tingle-modal--visible') 43var self=this 44self.modal.style.display='none' 45if(typeof self.opts.onClose==='function'){self.opts.onClose.call(this)} 46self._busy(!1)} 47Modal.prototype.setContent=function(content){if(typeof content==='string'){this.modalBoxContent.innerHTML=content}else{this.modalBoxContent.innerHTML='' 48this.modalBoxContent.appendChild(content)} 49if(this.isOpen()){this.checkOverflow()} 50return this} 51Modal.prototype.getContent=function(){return this.modalBoxContent} 52Modal.prototype.addFooter=function(){_buildFooter.call(this) 53return this} 54Modal.prototype.setFooterContent=function(content){this.modalBoxFooter.innerHTML=content 55return this} 56Modal.prototype.getFooterContent=function(){return this.modalBoxFooter} 57Modal.prototype.setStickyFooter=function(isSticky){if(!this.isOverflow()){isSticky=!1} 58if(isSticky){if(this.modalBox.contains(this.modalBoxFooter)){this.modalBox.removeChild(this.modalBoxFooter) 59this.modal.appendChild(this.modalBoxFooter) 60this.modalBoxFooter.classList.add('tingle-modal-box__footer--sticky') 61_recalculateFooterPosition.call(this) 62this.modalBoxContent.style['padding-bottom']=this.modalBoxFooter.clientHeight+20+'px'}}else if(this.modalBoxFooter){if(!this.modalBox.contains(this.modalBoxFooter)){this.modal.removeChild(this.modalBoxFooter) 63this.modalBox.appendChild(this.modalBoxFooter) 64this.modalBoxFooter.style.width='auto' 65this.modalBoxFooter.style.left='' 66this.modalBoxContent.style['padding-bottom']='' 67this.modalBoxFooter.classList.remove('tingle-modal-box__footer--sticky')}} 68return this} 69Modal.prototype.addFooterBtn=function(label,cssClass,callback){var btn=document.createElement('button') 70btn.innerHTML=label 71btn.addEventListener('click',callback) 72if(typeof cssClass==='string'&&cssClass.length){cssClass.split(' ').forEach(function(item){btn.classList.add(item)})} 73this.modalBoxFooter.appendChild(btn) 74return btn} 75Modal.prototype.resize=function(){console.warn('Resize is deprecated and will be removed in version 1.0')} 76Modal.prototype.isOverflow=function(){var viewportHeight=window.innerHeight
vendor: 4,413 bytes, lines 77-130
77var modalHeight=this.modalBox.clientHeight 78return modalHeight>=viewportHeight} 79Modal.prototype.checkOverflow=function(){if(this.modal.classList.contains('tingle-modal--visible')){if(this.isOverflow()){this.modal.classList.add('tingle-modal--overflow')}else{this.modal.classList.remove('tingle-modal--overflow')} 80if(!this.isOverflow()&&this.opts.stickyFooter){this.setStickyFooter(!1)}else if(this.isOverflow()&&this.opts.stickyFooter){_recalculateFooterPosition.call(this) 81this.setStickyFooter(!0)}}} 82function closeIcon(){return'<svg viewBox="0 0 10 10" xmlns="http://www.w3.org/2000/svg"><path d="M.3 9.7c.2.2.4.3.7.3.3 0 .5-.1.7-.3L5 6.4l3.3 3.3c.2.2.5.3.7.3.2 0 .5-.1.7-.3.4-.4.4-1 0-1.4L6.4 5l3.3-3.3c.4-.4.4-1 0-1.4-.4-.4-1-.4-1.4 0L5 3.6 1.7.3C1.3-.1.7-.1.3.3c-.4.4-.4 1 0 1.4L3.6 5 .3 8.3c-.4.4-.4 1 0 1.4z" fill="#000" fill-rule="nonzero"/></svg>'} 83function _recalculateFooterPosition(){if(!this.modalBoxFooter){return} 84this.modalBoxFooter.style.width=this.modalBox.clientWidth+'px' 85this.modalBoxFooter.style.left=this.modalBox.offsetLeft+'px'} 86function _build(){this.modal=document.createElement('div') 87this.modal.classList.add('tingle-modal') 88if(this.opts.closeMethods.length===0||this.opts.closeMethods.indexOf('overlay')===-1){this.modal.classList.add('tingle-modal--noOverlayClose')} 89this.modal.style.display='none' 90this.opts.cssClass.forEach(function(item){if(typeof item==='string'){this.modal.classList.add(item)}},this) 91if(this.opts.closeMethods.indexOf('button')!==-1){this.modalCloseBtn=document.createElement('button') 92this.modalCloseBtn.type='button' 93this.modalCloseBtn.classList.add('tingle-modal__close') 94this.modalCloseBtnIcon=document.createElement('span') 95this.modalCloseBtnIcon.classList.add('tingle-modal__closeIcon') 96this.modalCloseBtnIcon.innerHTML=closeIcon() 97this.modalCloseBtnLabel=document.createElement('span') 98this.modalCloseBtnLabel.classList.add('tingle-modal__closeLabel') 99this.modalCloseBtnLabel.innerHTML=this.opts.closeLabel 100this.modalCloseBtn.appendChild(this.modalCloseBtnIcon) 101this.modalCloseBtn.appendChild(this.modalCloseBtnLabel)} 102this.modalBox=document.createElement('div') 103this.modalBox.classList.add('tingle-modal-box') 104this.modalBoxContent=document.createElement('div') 105this.modalBoxContent.classList.add('tingle-modal-box__content') 106this.modalBox.appendChild(this.modalBoxContent) 107if(this.opts.closeMethods.indexOf('button')!==-1){this.modal.appendChild(this.modalCloseBtn)} 108this.modal.appendChild(this.modalBox)} 109function _buildFooter(){this.modalBoxFooter=document.createElement('div') 110this.modalBoxFooter.classList.add('tingle-modal-box__footer') 111this.modalBox.appendChild(this.modalBoxFooter)} 112function _bindEvents(){this._events={clickCloseBtn:this.close.bind(this),clickOverlay:_handleClickOutside.bind(this),resize:this.checkOverflow.bind(this),keyboardNav:_handleKeyboardNav.bind(this)} 113if(this.opts.closeMethods.indexOf('button')!==-1){this.modalCloseBtn.addEventListener('click',this._events.clickCloseBtn)} 114this.modal.addEventListener('mousedown',this._events.clickOverlay) 115window.addEventListener('resize',this._events.resize) 116document.addEventListener('keydown',this._events.keyboardNav)} 117function _handleKeyboardNav(event){if(this.opts.closeMethods.indexOf('escape')!==-1&&event.which===27&&this.isOpen()){this.close()}} 118function _handleClickOutside(event){var scrollbarWidth=this.modal.offsetWidth-this.modal.clientWidth 119var clickedOnScrollbar=event.clientX>=this.modal.offsetWidth-15 120var isScrollable=this.modal.scrollHeight!==this.modal.offsetHeight 121if(navigator.platform==='MacIntel'&&scrollbarWidth===0&&clickedOnScrollbar&&isScrollable){return} 122if(this.opts.closeMethods.indexOf('overlay')!==-1&&!_findAncestor(event.target,'tingle-modal')&&event.clientX<this.modal.clientWidth){this.close()}} 123function _findAncestor(el,cls){while((el=el.parentElement)&&!el.classList.contains(cls));return el} 124function _unbindEvents(){if(this.opts.closeMethods.indexOf('button')!==-1){this.modalCloseBtn.removeEventListener('click',this._events.clickCloseBtn)} 125this.modal.removeEventListener('mousedown',this._events.clickOverlay) 126window.removeEventListener('resize',this._events.resize) 127document.removeEventListener('keydown',this._events.keyboardNav)} 128function extend(){for(var i=1;i<arguments.length;i++){for(var key in arguments[i]){if(arguments[i].hasOwnProperty(key)){arguments[0][key]=arguments[i][key]}}} 129return arguments[0]} 130return{modal:Modal}}))
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.