diff --git a/.idea/vcs.xml b/.idea/vcs.xml deleted file mode 100644 index 35eb1dd..0000000 --- a/.idea/vcs.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/amd/build/alert.min.js b/amd/build/alert.min.js new file mode 100644 index 0000000..353d0e1 --- /dev/null +++ b/amd/build/alert.min.js @@ -0,0 +1 @@ +define(["exports","jquery","./util"],function(a,b,c){"use strict";function d(a){return a&&a.__esModule?a:{"default":a}}function e(a,b){if(!(a instanceof b))throw new TypeError("Cannot call a class as a function")}function f(a,b){for(var c=0;c0&&(g=e()?d[d.length-1]:d[0]),g&&f(g)}),a('.dropdown [role="menu"] [role="menuitem"]').keypress(function(b){var c,d,e=String.fromCharCode(b.which||b.keyCode),g=a(b.target).closest('[role="menu"]'),h=0,i=!1;if(g&&(i=a(g).find('[role="menuitem"]')))for(e=e.toLowerCase(),h=0;h0&&(a(c[0]).attr("tabindex","0"),a(c[0]).focus()),b.resolve()},300,new b("core/aria:delayed-focus"))})}}}); \ No newline at end of file diff --git a/amd/build/button.min.js b/amd/build/button.min.js new file mode 100644 index 0000000..c6accae --- /dev/null +++ b/amd/build/button.min.js @@ -0,0 +1 @@ +define(["exports","jquery"],function(a,b){"use strict";function c(a){return a&&a.__esModule?a:{"default":a}}function d(a,b){if(!(a instanceof b))throw new TypeError("Cannot call a class as a function")}function e(a,b){for(var c=0;cthis._items.length-1||b<0)){if(this._isSliding)return void a(this._element).one(t.SLID,function(){return c.to(b)});if(d===b)return this.pause(),void this.cycle();var e=b>d?s.NEXT:s.PREV;this._slide(e,this._items[b])}}},{key:"dispose",value:function(){a(this._element).off(h),a.removeData(this._element,d),this._items=null,this._config=null,this._element=null,this._interval=null,this._isPaused=null,this._isSliding=null,this._activeElement=null,this._indicatorsElement=null}},{key:"_getConfig",value:function(a){return a=f({},q,a),k["default"].typeCheckConfig(b,a,r),a}},{key:"_addEventListeners",value:function(){var b=this;this._config.keyboard&&a(this._element).on(t.KEYDOWN,function(a){return b._keydown(a)}),"hover"===this._config.pause&&(a(this._element).on(t.MOUSEENTER,function(a){return b.pause(a)}).on(t.MOUSELEAVE,function(a){return b.cycle(a)}),"ontouchstart"in document.documentElement&&a(this._element).on(t.TOUCHEND,function(){b.pause(),b.touchTimeout&&clearTimeout(b.touchTimeout),b.touchTimeout=setTimeout(function(a){return b.cycle(a)},p+b._config.interval)}))}},{key:"_keydown",value:function(a){if(!/input|textarea/i.test(a.target.tagName))switch(a.which){case n:a.preventDefault(),this.prev();break;case o:a.preventDefault(),this.next()}}},{key:"_getItemIndex",value:function(b){return this._items=a.makeArray(a(b).parent().find(v.ITEM)),this._items.indexOf(b)}},{key:"_getItemByDirection",value:function(a,b){var c=a===s.NEXT,d=a===s.PREV,e=this._getItemIndex(b),f=this._items.length-1,g=d&&0===e||c&&e===f;if(g&&!this._config.wrap)return b;var h=a===s.PREV?-1:1,i=(e+h)%this._items.length;return i===-1?this._items[this._items.length-1]:this._items[i]}},{key:"_triggerSlideEvent",value:function(b,c){var d=this._getItemIndex(b),e=this._getItemIndex(a(this._element).find(v.ACTIVE_ITEM)[0]),f=a.Event(t.SLIDE,{relatedTarget:b,direction:c,from:e,to:d});return a(this._element).trigger(f),f}},{key:"_setActiveIndicatorElement",value:function(b){if(this._indicatorsElement){a(this._indicatorsElement).find(v.ACTIVE).removeClass(u.ACTIVE);var c=this._indicatorsElement.children[this._getItemIndex(b)];c&&a(c).addClass(u.ACTIVE)}}},{key:"_slide",value:function(b,c){var d,e,f,g=this,h=a(this._element).find(v.ACTIVE_ITEM)[0],i=this._getItemIndex(h),j=c||h&&this._getItemByDirection(b,h),l=this._getItemIndex(j),n=Boolean(this._interval);if(b===s.NEXT?(d=u.LEFT,e=u.NEXT,f=s.LEFT):(d=u.RIGHT,e=u.PREV,f=s.RIGHT),j&&a(j).hasClass(u.ACTIVE))return void(this._isSliding=!1);var o=this._triggerSlideEvent(j,f);if(!o.isDefaultPrevented()&&h&&j){this._isSliding=!0,n&&this.pause(),this._setActiveIndicatorElement(j);var p=a.Event(t.SLID,{relatedTarget:j,direction:f,from:i,to:l});k["default"].supportsTransitionEnd()&&a(this._element).hasClass(u.SLIDE)?(a(j).addClass(e),k["default"].reflow(j),a(h).addClass(d),a(j).addClass(d),a(h).one(k["default"].TRANSITION_END,function(){a(j).removeClass("".concat(d," ").concat(e)).addClass(u.ACTIVE),a(h).removeClass("".concat(u.ACTIVE," ").concat(e," ").concat(d)),g._isSliding=!1,setTimeout(function(){return a(g._element).trigger(p)},0)}).emulateTransitionEnd(m)):(a(h).removeClass(u.ACTIVE),a(j).addClass(u.ACTIVE),this._isSliding=!1,a(this._element).trigger(p)),n&&this.cycle()}}}],[{key:"_jQueryInterface",value:function(b){return this.each(function(){var c=a(this).data(d),g=f({},q,a(this).data());"object"===e(b)&&(g=f({},g,b));var h="string"==typeof b?b:g.slide;if(c||(c=new j(this,g),a(this).data(d,c)),"number"==typeof b)c.to(b);else if("string"==typeof h){if("undefined"==typeof c[h])throw new TypeError('No method named "'.concat(h,'"'));c[h]()}else g.interval&&(c.pause(),c.cycle())})}},{key:"_dataApiClickHandler",value:function(b){var c=k["default"].getSelectorFromElement(this);if(c){var e=a(c)[0];if(e&&a(e).hasClass(u.CAROUSEL)){var g=f({},a(e).data(),a(this).data()),h=this.getAttribute("data-slide-to");h&&(g.interval=!1),j._jQueryInterface.call(a(e),g),h&&a(e).data(d).to(h),b.preventDefault()}}}},{key:"VERSION",get:function(){return c}},{key:"Default",get:function(){return q}}]),j}();return a(document).on(t.CLICK_DATA_API,v.DATA_SLIDE,w._dataApiClickHandler),a(window).on(t.LOAD_DATA_API,function(){a(v.DATA_RIDE).each(function(){var b=a(this);w._jQueryInterface.call(b,b.data())})}),a.fn[b]=w._jQueryInterface,a.fn[b].Constructor=w,a.fn[b].noConflict=function(){return a.fn[b]=l,w._jQueryInterface},w}(j["default"]);a["default"]=l}); \ No newline at end of file diff --git a/amd/build/collapse.min.js b/amd/build/collapse.min.js new file mode 100644 index 0000000..8a8c513 --- /dev/null +++ b/amd/build/collapse.min.js @@ -0,0 +1 @@ +define(["exports","jquery","./util"],function(a,b,c){"use strict";function d(a){return a&&a.__esModule?a:{"default":a}}function e(a){return(e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(a){return typeof a}:function(a){return a&&"function"==typeof Symbol&&a.constructor===Symbol&&a!==Symbol.prototype?"symbol":typeof a})(a)}function f(){return f=Object.assign||function(a){for(var b=1;b0&&(this._selector=i,this._triggerArray.push(f))}this._parent=this._config.parent?this._getParent():null,this._config.parent||this._addAriaAndCollapsedClass(this._element,this._triggerArray),this._config.toggle&&this.toggle()}return i(h,[{key:"toggle",value:function(){a(this._element).hasClass(q.SHOW)?this.hide():this.show()}},{key:"show",value:function(){var b=this;if(!this._isTransitioning&&!a(this._element).hasClass(q.SHOW)){var c,e;if(this._parent&&(c=a.makeArray(a(this._parent).find(s.ACTIVES).filter('[data-parent="'.concat(this._config.parent,'"]'))),0===c.length&&(c=null)),!(c&&(e=a(c).not(this._selector).data(d),e&&e._isTransitioning))){var f=a.Event(p.SHOW);if(a(this._element).trigger(f),!f.isDefaultPrevented()){c&&(h._jQueryInterface.call(a(c).not(this._selector),"hide"),e||a(c).data(d,null));var g=this._getDimension();a(this._element).removeClass(q.COLLAPSE).addClass(q.COLLAPSING),this._element.style[g]=0,this._triggerArray.length>0&&a(this._triggerArray).removeClass(q.COLLAPSED).attr("aria-expanded",!0),this.setTransitioning(!0);var i=function(){a(b._element).removeClass(q.COLLAPSING).addClass(q.COLLAPSE).addClass(q.SHOW),b._element.style[g]="",b.setTransitioning(!1),a(b._element).trigger(p.SHOWN)};if(!k["default"].supportsTransitionEnd())return void i();var j=g[0].toUpperCase()+g.slice(1),l="scroll".concat(j);a(this._element).one(k["default"].TRANSITION_END,i).emulateTransitionEnd(m),this._element.style[g]="".concat(this._element[l],"px")}}}}},{key:"hide",value:function(){var b=this;if(!this._isTransitioning&&a(this._element).hasClass(q.SHOW)){var c=a.Event(p.HIDE);if(a(this._element).trigger(c),!c.isDefaultPrevented()){var d=this._getDimension();if(this._element.style[d]="".concat(this._element.getBoundingClientRect()[d],"px"),k["default"].reflow(this._element),a(this._element).addClass(q.COLLAPSING).removeClass(q.COLLAPSE).removeClass(q.SHOW),this._triggerArray.length>0)for(var e=0;e0&&a(c).toggleClass(q.COLLAPSED,!d).attr("aria-expanded",d)}}}],[{key:"_getTargetFromElement",value:function(b){var c=k["default"].getSelectorFromElement(b);return c?a(c)[0]:null}},{key:"_jQueryInterface",value:function(b){return this.each(function(){var c=a(this),g=c.data(d),i=f({},n,c.data(),"object"===e(b)&&b);if(!g&&i.toggle&&/show|hide/.test(b)&&(i.toggle=!1),g||(g=new h(this,i),c.data(d,g)),"string"==typeof b){if("undefined"==typeof g[b])throw new TypeError('No method named "'.concat(b,'"'));g[b]()}})}},{key:"VERSION",get:function(){return c}},{key:"Default",get:function(){return n}}]),h}();return a(document).on(p.CLICK_DATA_API,s.DATA_TOGGLE,function(b){"A"===b.currentTarget.tagName&&b.preventDefault();var c=a(this),e=k["default"].getSelectorFromElement(this);a(e).each(function(){var b=a(this),e=b.data(d),f=e?"toggle":c.data();t._jQueryInterface.call(b,f)})}),a.fn[b]=t._jQueryInterface,a.fn[b].Constructor=t,a.fn[b].noConflict=function(){return a.fn[b]=l,t._jQueryInterface},t}(j["default"]);a["default"]=l}); \ No newline at end of file diff --git a/amd/build/drawer.min.js b/amd/build/drawer.min.js new file mode 100644 index 0000000..fe36c9b --- /dev/null +++ b/amd/build/drawer.min.js @@ -0,0 +1 @@ +define(["jquery","core/custom_interaction_events","core/log"],function(a,b,c){var d={TOGGLE_REGION:'[data-region="drawer-toggle"]',TOGGLE_ACTION:'[data-action="toggle-drawer"]',TOGGLE_TARGET:"aria-controls",TOGGLE_SIDE:"left",BODY:"body",SECTION:'.list-group-item[href*="#section-"]'},e=a(document).width()<768,f=function(){a(d.TOGGLE_REGION).length||c.debug("Page is missing a drawer region"),a(d.TOGGLE_ACTION).length||c.debug("Page is missing a drawer toggle link"),a(d.TOGGLE_REGION).each(function(b,c){var f=a(c).find(d.TOGGLE_ACTION),g=f.attr("aria-controls"),h=a(document.getElementById(g)),i="false"==f.attr("aria-expanded"),j=f.attr("data-side"),k=a(d.BODY),l=f.attr("data-preference");e&&M.util.set_user_preference(l,"false"),h.on("mousewheel DOMMouseScroll",this.preventPageScroll),i?f.attr("aria-expanded","false"):(k.addClass("drawer-open-"+j),f.attr("aria-expanded","true"))}.bind(this)),this.registerEventListeners(),e&&this.closeAll()};return f.prototype.closeAll=function(){a(d.TOGGLE_REGION).each(function(b,c){var f=a(c).find(d.TOGGLE_ACTION),g=f.attr("data-side"),h=a(d.BODY),i=f.attr("aria-controls"),j=a(document.getElementById(i)),k=f.attr("data-preference");f.attr("aria-expanded","false"),h.removeClass("drawer-open-"+g),j.attr("aria-hidden","true"),j.addClass("closed"),e||M.util.set_user_preference(k,"false")})},f.prototype.toggleDrawer=function(b){var c=a(b.target).closest("[data-action=toggle-drawer]"),f=c.attr("aria-controls"),g=a(document.getElementById(f)),h=a(d.BODY),i=c.attr("data-side"),j=c.attr("data-preference");e&&M.util.set_user_preference(j,"false"),h.addClass("drawer-ease");var k="true"==c.attr("aria-expanded");k?(h.removeClass("drawer-open-"+i),c.attr("aria-expanded","false"),g.attr("aria-hidden","true"),g.addClass("closed"),e||M.util.set_user_preference(j,"false")):(c.attr("aria-expanded","true"),g.attr("aria-hidden","false"),g.focus(),h.addClass("drawer-open-"+i),g.removeClass("closed"),e||M.util.set_user_preference(j,"true"))},f.prototype.preventPageScroll=function(b){var c=b.wheelDelta||b.originalEvent&&b.originalEvent.wheelDelta||-b.originalEvent.detail,d=this.scrollTop+a(this).outerHeight()-this.scrollHeight>=0,e=this.scrollTop<=0;(c<0&&d||c>0&&e)&&b.preventDefault()},f.prototype.registerEventListeners=function(){a(d.TOGGLE_ACTION).each(function(c,d){b.define(a(d),[b.events.activate]),a(d).on(b.events.activate,function(a,b){this.toggleDrawer(b.originalEvent),b.originalEvent.preventDefault()}.bind(this))}.bind(this)),a(d.SECTION).click(function(){e&&this.closeAll()}.bind(this))},{init:function(){return new f}}}); \ No newline at end of file diff --git a/amd/build/dropdown.min.js b/amd/build/dropdown.min.js new file mode 100644 index 0000000..a16ef02 --- /dev/null +++ b/amd/build/dropdown.min.js @@ -0,0 +1 @@ +define(["exports","jquery","core/popper","./util"],function(a,b,c,d){"use strict";function e(a){return a&&a.__esModule?a:{"default":a}}function f(a){return(f="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(a){return typeof a}:function(a){return a&&"function"==typeof Symbol&&a.constructor===Symbol&&a!==Symbol.prototype?"symbol":typeof a})(a)}function g(){return g=Object.assign||function(a){for(var b=1;b0}},{key:"_getPopperConfig",value:function(){var a=this,b={};"function"==typeof this._config.offset?b.fn=function(b){return b.offsets=g({},b.offsets,a._config.offset(b.offsets)||{}),b}:b.offset=this._config.offset;var c={placement:this._getPlacement(),modifiers:{offset:b,flip:{enabled:this._config.flip},preventOverflow:{boundariesElement:this._config.boundary}}};return c}}],[{key:"_jQueryInterface",value:function(b){return this.each(function(){var c=a(this).data(d),e="object"===f(b)?b:null;if(c||(c=new i(this,e),a(this).data(d,c)),"string"==typeof b){if("undefined"==typeof c[b])throw new TypeError('No method named "'.concat(b,'"'));c[b]()}})}},{key:"_clearMenus",value:function(b){if(!b||b.which!==s&&("keyup"!==b.type||b.which===p))for(var c=a.makeArray(a(w.DATA_TOGGLE)),e=0;e0&&g--,b.which===r&&gdocument.documentElement.clientHeight;!this._isBodyOverflowing&&a&&(this._element.style.paddingLeft="".concat(this._scrollbarWidth,"px")),this._isBodyOverflowing&&!a&&(this._element.style.paddingRight="".concat(this._scrollbarWidth,"px"))}},{key:"_resetAdjustments",value:function(){this._element.style.paddingLeft="",this._element.style.paddingRight=""}},{key:"_checkScrollbar",value:function(){var a=document.body.getBoundingClientRect();this._isBodyOverflowing=a.left+a.right

'}),q=k({},m["default"].DefaultType,{content:"(string|element|function)"}),r={FADE:"fade",SHOW:"show"},s={TITLE:".popover-header",CONTENT:".popover-body"},t={HIDE:"hide".concat(g),HIDDEN:"hidden".concat(g),SHOW:"show".concat(g),SHOWN:"shown".concat(g),INSERTED:"inserted".concat(g),CLICK:"click".concat(g),FOCUSIN:"focusin".concat(g),FOCUSOUT:"focusout".concat(g),MOUSEENTER:"mouseenter".concat(g),MOUSELEAVE:"mouseleave".concat(g)},u=function(k){function l(){return f(this,l),i(this,(l.__proto__||Object.getPrototypeOf(l)).apply(this,arguments))}return j(l,k),h(l,[{key:"isWithContent",value:function(){return this.getTitle()||this._getContent()}},{key:"addAttachmentClass",value:function(b){a(this.getTipElement()).addClass("".concat(n,"-").concat(b))}},{key:"getTipElement",value:function(){return this.tip=this.tip||a(this.config.template)[0],this.tip}},{key:"setContent",value:function(){var b=a(this.getTipElement());this.setElementContent(b.find(s.TITLE),this.getTitle());var c=this._getContent();"function"==typeof c&&(c=c.call(this.element)),this.setElementContent(b.find(s.CONTENT),c),b.removeClass("".concat(r.FADE," ").concat(r.SHOW))}},{key:"_getContent",value:function(){return this.element.getAttribute("data-content")||this.config.content}},{key:"_cleanTipClass",value:function(){var b=a(this.getTipElement()),c=b.attr("class").match(o);null!==c&&c.length>0&&b.removeClass(c.join(""))}}],[{key:"_jQueryInterface",value:function(b){return this.each(function(){var c=a(this).data(d),f="object"===e(b)?b:null;if((c||!/destroy|hide/.test(b))&&(c||(c=new l(this,f),a(this).data(d,c)),"string"==typeof b)){if("undefined"==typeof c[b])throw new TypeError('No method named "'.concat(b,'"'));c[b]()}})}},{key:"VERSION",get:function(){return c}},{key:"Default",get:function(){return p}},{key:"NAME",get:function(){return b}},{key:"DATA_KEY",get:function(){return d}},{key:"Event",get:function(){return t}},{key:"EVENT_KEY",get:function(){return g}},{key:"DefaultType",get:function(){return q}}]),l}(m["default"]);return a.fn[b]=u._jQueryInterface,a.fn[b].Constructor=u,a.fn[b].noConflict=function(){return a.fn[b]=l,u._jQueryInterface},u}(l["default"]);a["default"]=n}); \ No newline at end of file diff --git a/amd/build/scrollspy.min.js b/amd/build/scrollspy.min.js new file mode 100644 index 0000000..fa81832 --- /dev/null +++ b/amd/build/scrollspy.min.js @@ -0,0 +1 @@ +define(["exports","jquery","./util"],function(a,b,c){"use strict";function d(a){return a&&a.__esModule?a:{"default":a}}function e(a){return(e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(a){return typeof a}:function(a){return a&&"function"==typeof Symbol&&a.constructor===Symbol&&a!==Symbol.prototype?"symbol":typeof a})(a)}function f(){return f=Object.assign||function(a){for(var b=1;b=c){var d=this._targets[this._targets.length-1];return void(this._activeTarget!==d&&this._activate(d))}if(this._activeTarget&&a0)return this._activeTarget=null,void this._clear();for(var e=this._offsets.length;e--;){var f=this._activeTarget!==this._targets[e]&&a>=this._offsets[e]&&("undefined"==typeof this._offsets[e+1]||a li > .active",DATA_TOGGLE:'[data-toggle="tab"], [data-toggle="pill"], [data-toggle="list"]',DROPDOWN_TOGGLE:".dropdown-toggle",DROPDOWN_ACTIVE_CHILD:"> .dropdown-menu .active"},o=function(){function b(a){e(this,b),this._element=a}return g(b,[{key:"show",value:function(){var b=this;if(!(this._element.parentNode&&this._element.parentNode.nodeType===Node.ELEMENT_NODE&&a(this._element).hasClass(m.ACTIVE)||a(this._element).hasClass(m.DISABLED))){var c,d,e=a(this._element).closest(n.NAV_LIST_GROUP)[0],f=i["default"].getSelectorFromElement(this._element);if(e){var g="UL"===e.nodeName?n.ACTIVE_UL:n.ACTIVE;d=a.makeArray(a(e).find(g)),d=d[d.length-1]}var h=a.Event(l.HIDE,{relatedTarget:this._element}),j=a.Event(l.SHOW,{relatedTarget:d});if(d&&a(d).trigger(h),a(this._element).trigger(j),!j.isDefaultPrevented()&&!h.isDefaultPrevented()){f&&(c=a(f)[0]),this._activate(this._element,e);var k=function(){var c=a.Event(l.HIDDEN,{relatedTarget:b._element}),e=a.Event(l.SHOWN,{relatedTarget:d});a(d).trigger(c),a(b._element).trigger(e)};c?this._activate(c,c.parentNode,k):k()}}}},{key:"dispose",value:function(){a.removeData(this._element,d),this._element=null}},{key:"_activate",value:function(b,c,d){var e,f=this;e="UL"===c.nodeName?a(c).find(n.ACTIVE_UL):a(c).children(n.ACTIVE);var g=e[0],h=d&&i["default"].supportsTransitionEnd()&&g&&a(g).hasClass(m.FADE),j=function(){return f._transitionComplete(b,g,d)};g&&h?a(g).one(i["default"].TRANSITION_END,j).emulateTransitionEnd(k):j()}},{key:"_transitionComplete",value:function(b,c,d){if(c){a(c).removeClass("".concat(m.SHOW," ").concat(m.ACTIVE));var e=a(c.parentNode).find(n.DROPDOWN_ACTIVE_CHILD)[0];e&&a(e).removeClass(m.ACTIVE),"tab"===c.getAttribute("role")&&c.setAttribute("aria-selected",!1)}if(a(b).addClass(m.ACTIVE),"tab"===b.getAttribute("role")&&b.setAttribute("aria-selected",!0),i["default"].reflow(b),a(b).addClass(m.SHOW),b.parentNode&&a(b.parentNode).hasClass(m.DROPDOWN_MENU)){var f=a(b).closest(n.DROPDOWN)[0];f&&a(f).find(n.DROPDOWN_TOGGLE).addClass(m.ACTIVE),b.setAttribute("aria-expanded",!0)}d&&d()}}],[{key:"_jQueryInterface",value:function(c){return this.each(function(){var e=a(this),f=e.data(d);if(f||(f=new b(this),e.data(d,f)),"string"==typeof c){if("undefined"==typeof f[c])throw new TypeError('No method named "'.concat(c,'"'));f[c]()}})}},{key:"VERSION",get:function(){return c}}]),b}();return a(document).on(l.CLICK_DATA_API,n.DATA_TOGGLE,function(b){b.preventDefault(),o._jQueryInterface.call(a(this),"show")}),a.fn[b]=o._jQueryInterface,a.fn[b].Constructor=o,a.fn[b].noConflict=function(){return a.fn[b]=j,o._jQueryInterface},o}(h["default"]);a["default"]=j}); \ No newline at end of file diff --git a/amd/build/tether.min.js b/amd/build/tether.min.js new file mode 100644 index 0000000..261e672 --- /dev/null +++ b/amd/build/tether.min.js @@ -0,0 +1 @@ +!function(a,b){"function"==typeof define&&define.amd?define(b):"object"==typeof exports?module.exports=b(require,exports,module):a.Tether=b()}(this,function(a,b,c){"use strict";function d(a,b){if(!(a instanceof b))throw new TypeError("Cannot call a class as a function")}function e(a){var b=a.getBoundingClientRect(),c={};for(var d in b)c[d]=b[d];if(a.ownerDocument!==document){var f=a.ownerDocument.defaultView.frameElement;if(f){var g=e(f);c.top+=g.top,c.bottom+=g.top,c.left+=g.left,c.right+=g.left}}return c}function f(a){var b=getComputedStyle(a)||{},c=b.position,d=[];if("fixed"===c)return[a];for(var e=a;(e=e.parentNode)&&e&&1===e.nodeType;){var f=void 0;try{f=getComputedStyle(e)}catch(g){}if("undefined"==typeof f||null===f)return d.push(e),d;var h=f,i=h.overflow,j=h.overflowX,k=h.overflowY;/(auto|scroll)/.test(i+k+j)&&("absolute"!==c||["relative","absolute","fixed"].indexOf(f.position)>=0)&&d.push(e)}return d.push(a.ownerDocument.body),a.ownerDocument!==document&&d.push(a.ownerDocument.defaultView),d}function g(){z&&document.body.removeChild(z),z=null}function h(a){var b=void 0;a===document?(b=document,a=document.documentElement):b=a.ownerDocument;var c=b.documentElement,d=e(a),f=C();return d.top-=f.top,d.left-=f.left,"undefined"==typeof d.width&&(d.width=document.body.scrollWidth-d.left-d.right),"undefined"==typeof d.height&&(d.height=document.body.scrollHeight-d.top-d.bottom),d.top=d.top-c.clientTop,d.left=d.left-c.clientLeft,d.right=b.body.clientWidth-d.width-d.left,d.bottom=b.body.clientHeight-d.height-d.top,d}function i(a){return a.offsetParent||document.documentElement}function j(){var a=document.createElement("div");a.style.width="100%",a.style.height="200px";var b=document.createElement("div");k(b.style,{position:"absolute",top:0,left:0,pointerEvents:"none",visibility:"hidden",width:"200px",height:"150px",overflow:"hidden"}),b.appendChild(a),document.body.appendChild(b);var c=a.offsetWidth;b.style.overflow="scroll";var d=a.offsetWidth;c===d&&(d=b.clientWidth),document.body.removeChild(b);var e=c-d;return{width:e,height:e}}function k(){var a=arguments.length<=0||void 0===arguments[0]?{}:arguments[0],b=[];return Array.prototype.push.apply(b,arguments),b.slice(1).forEach(function(b){if(b)for(var c in b)({}).hasOwnProperty.call(b,c)&&(a[c]=b[c])}),a}function l(a,b){if("undefined"!=typeof a.classList)b.split(" ").forEach(function(b){b.trim()&&a.classList.remove(b)});else{var c=new RegExp("(^| )"+b.split(" ").join("|")+"( |$)","gi"),d=o(a).replace(c," ");p(a,d)}}function m(a,b){if("undefined"!=typeof a.classList)b.split(" ").forEach(function(b){b.trim()&&a.classList.add(b)});else{l(a,b);var c=o(a)+(" "+b);p(a,c)}}function n(a,b){if("undefined"!=typeof a.classList)return a.classList.contains(b);var c=o(a);return new RegExp("(^| )"+b+"( |$)","gi").test(c)}function o(a){return a.className instanceof a.ownerDocument.defaultView.SVGAnimatedString?a.className.baseVal:a.className}function p(a,b){a.setAttribute("class",b)}function q(a,b,c){c.forEach(function(c){b.indexOf(c)===-1&&n(a,c)&&l(a,c)}),b.forEach(function(b){n(a,b)||m(a,b)})}function d(a,b){if(!(a instanceof b))throw new TypeError("Cannot call a class as a function")}function r(a,b){if("function"!=typeof b&&null!==b)throw new TypeError("Super expression must either be null or a function, not "+typeof b);a.prototype=Object.create(b&&b.prototype,{constructor:{value:a,enumerable:!1,writable:!0,configurable:!0}}),b&&(Object.setPrototypeOf?Object.setPrototypeOf(a,b):a.__proto__=b)}function s(a,b){var c=arguments.length<=2||void 0===arguments[2]?1:arguments[2];return a+c>=b&&b>=a-c}function t(){return"undefined"!=typeof performance&&"undefined"!=typeof performance.now?performance.now():+new Date}function u(){for(var a={top:0,left:0},b=arguments.length,c=Array(b),d=0;d1?c-1:0),e=1;e16?(b=Math.min(b-16,250),void(c=setTimeout(e,250))):void("undefined"!=typeof a&&t()-a<10||(null!=c&&(clearTimeout(c),c=null),a=t(),M(),b=t()-a))};"undefined"!=typeof window&&"undefined"!=typeof window.addEventListener&&["resize","scroll","touchmove"].forEach(function(a){window.addEventListener(a,d)})}();var N={center:"center",left:"right",right:"left"},O={middle:"middle",top:"bottom",bottom:"top"},P={top:0,left:0,middle:"50%",center:"50%",bottom:"100%",right:"100%"},Q=function(a,b){var c=a.left,d=a.top;return"auto"===c&&(c=N[b.left]),"auto"===d&&(d=O[b.top]),{left:c,top:d}},R=function(a){var b=a.left,c=a.top;return"undefined"!=typeof P[a.left]&&(b=P[a.left]),"undefined"!=typeof P[a.top]&&(c=P[a.top]),{left:b,top:c}},S=function(a){var b=a.split(" "),c=H(b,2),d=c[0],e=c[1];return{top:d,left:e}},T=S,U=function(a){function b(a){var c=this;d(this,b),I(Object.getPrototypeOf(b.prototype),"constructor",this).call(this),this.position=this.position.bind(this),L.push(this),this.history=[],this.setOptions(a,!1),y.modules.forEach(function(a){"undefined"!=typeof a.initialize&&a.initialize.call(c)}),this.position()}return r(b,a),x(b,[{key:"getClass",value:function(){var a=arguments.length<=0||void 0===arguments[0]?"":arguments[0],b=this.options.classes;return"undefined"!=typeof b&&b[a]?this.options.classes[a]:this.options.classPrefix?this.options.classPrefix+"-"+a:a}},{key:"setOptions",value:function(a){var b=this,c=arguments.length<=1||void 0===arguments[1]||arguments[1],d={offset:"0 0",targetOffset:"0 0",targetAttachment:"auto auto",classPrefix:"tether"};this.options=k(d,a);var e=this.options,g=e.element,h=e.target,i=e.targetModifier;if(this.element=g,this.target=h,this.targetModifier=i,"viewport"===this.target?(this.target=document.body,this.targetModifier="visible"):"scroll-handle"===this.target&&(this.target=document.body,this.targetModifier="scroll-handle"),["element","target"].forEach(function(a){if("undefined"==typeof b[a])throw new Error("Tether Error: Both element and target must be defined");"undefined"!=typeof b[a].jquery?b[a]=b[a][0]:"string"==typeof b[a]&&(b[a]=document.querySelector(b[a]))}),m(this.element,this.getClass("element")),this.options.addTargetClasses!==!1&&m(this.target,this.getClass("target")),!this.options.attachment)throw new Error("Tether Error: You must provide an attachment");this.targetAttachment=T(this.options.targetAttachment),this.attachment=T(this.options.attachment),this.offset=S(this.options.offset),this.targetOffset=S(this.options.targetOffset),"undefined"!=typeof this.scrollParents&&this.disable(),"scroll-handle"===this.targetModifier?this.scrollParents=[this.target]:this.scrollParents=f(this.target),this.options.enabled!==!1&&this.enable(c)}},{key:"getTargetBounds",value:function(){if("undefined"==typeof this.targetModifier)return h(this.target);if("visible"===this.targetModifier){if(this.target===document.body)return{top:pageYOffset,left:pageXOffset,height:innerHeight,width:innerWidth};var a=h(this.target),b={height:a.height,width:a.width,top:a.top,left:a.left};return b.height=Math.min(b.height,a.height-(pageYOffset-a.top)),b.height=Math.min(b.height,a.height-(a.top+a.height-(pageYOffset+innerHeight))),b.height=Math.min(innerHeight,b.height),b.height-=2,b.width=Math.min(b.width,a.width-(pageXOffset-a.left)),b.width=Math.min(b.width,a.width-(a.left+a.width-(pageXOffset+innerWidth))),b.width=Math.min(innerWidth,b.width),b.width-=2,b.topc.clientWidth||[d.overflow,d.overflowX].indexOf("scroll")>=0||this.target!==document.body,f=0;e&&(f=15);var g=a.height-parseFloat(d.borderTopWidth)-parseFloat(d.borderBottomWidth)-f,b={width:15,height:.975*g*(g/c.scrollHeight),left:a.left+a.width-parseFloat(d.borderLeftWidth)-15},i=0;g<408&&this.target===document.body&&(i=-11e-5*Math.pow(g,2)-.00727*g+22.58),this.target!==document.body&&(b.height=Math.max(b.height,24));var j=this.target.scrollTop/(c.scrollHeight-g);return b.top=j*(g-b.height-i)+a.top+parseFloat(d.borderTopWidth),this.target===document.body&&(b.height=Math.max(b.height,24)),b}}},{key:"clearCache",value:function(){this._cache={}}},{key:"cache",value:function(a,b){return"undefined"==typeof this._cache&&(this._cache={}),"undefined"==typeof this._cache[a]&&(this._cache[a]=b.call(this)),this._cache[a]}},{key:"enable",value:function(){var a=this,b=arguments.length<=0||void 0===arguments[0]||arguments[0];this.options.addTargetClasses!==!1&&m(this.target,this.getClass("enabled")),m(this.element,this.getClass("enabled")),this.enabled=!0,this.scrollParents.forEach(function(b){b!==a.target.ownerDocument&&b.addEventListener("scroll",a.position)}),b&&this.position()}},{key:"disable",value:function(){var a=this;l(this.target,this.getClass("enabled")),l(this.element,this.getClass("enabled")),this.enabled=!1,"undefined"!=typeof this.scrollParents&&this.scrollParents.forEach(function(b){b.removeEventListener("scroll",a.position)})}},{key:"destroy",value:function(){var a=this;this.disable(),L.forEach(function(b,c){b===a&&L.splice(c,1)}),0===L.length&&g()}},{key:"updateAttachClasses",value:function(a,b){var c=this;a=a||this.attachment,b=b||this.targetAttachment;var d=["left","top","bottom","right","middle","center"];"undefined"!=typeof this._addAttachClasses&&this._addAttachClasses.length&&this._addAttachClasses.splice(0,this._addAttachClasses.length),"undefined"==typeof this._addAttachClasses&&(this._addAttachClasses=[]);var e=this._addAttachClasses;a.top&&e.push(this.getClass("element-attached")+"-"+a.top),a.left&&e.push(this.getClass("element-attached")+"-"+a.left),b.top&&e.push(this.getClass("target-attached")+"-"+b.top),b.left&&e.push(this.getClass("target-attached")+"-"+b.left);var f=[];d.forEach(function(a){f.push(c.getClass("element-attached")+"-"+a),f.push(c.getClass("target-attached")+"-"+a)}),E(function(){"undefined"!=typeof c._addAttachClasses&&(q(c.element,c._addAttachClasses,f),c.options.addTargetClasses!==!1&&q(c.target,c._addAttachClasses,f),delete c._addAttachClasses)})}},{key:"position",value:function(){var a=this,b=arguments.length<=0||void 0===arguments[0]||arguments[0];if(this.enabled){this.clearCache();var c=Q(this.targetAttachment,this.attachment);this.updateAttachClasses(this.attachment,c);var d=this.cache("element-bounds",function(){return h(a.element)}),e=d.width,f=d.height;if(0===e&&0===f&&"undefined"!=typeof this.lastSize){var g=this.lastSize;e=g.width,f=g.height}else this.lastSize={width:e,height:f};var k=this.cache("target-bounds",function(){return a.getTargetBounds()}),l=k,m=v(R(this.attachment),{width:e,height:f}),n=v(R(c),l),o=v(this.offset,{width:e,height:f}),p=v(this.targetOffset,l);m=u(m,o),n=u(n,p);for(var q=k.left+n.left-m.left,r=k.top+n.top-m.top,s=0;sA.innerWidth&&(B=this.cache("scrollbar-size",j),x.viewport.bottom-=B.height),z.body.scrollHeight>A.innerHeight&&(B=this.cache("scrollbar-size",j),x.viewport.right-=B.width),["","static"].indexOf(z.body.style.position)!==-1&&["","static"].indexOf(z.body.parentElement.style.position)!==-1||(x.page.bottom=z.body.scrollHeight-r-f,x.page.right=z.body.scrollWidth-q-e),"undefined"!=typeof this.options.optimizations&&this.options.optimizations.moveElement!==!1&&"undefined"==typeof this.targetModifier&&!function(){var b=a.cache("target-offsetparent",function(){return i(a.target)}),c=a.cache("target-offsetparent-bounds",function(){return h(b)}),d=getComputedStyle(b),e=c,f={};if(["Top","Left","Bottom","Right"].forEach(function(a){f[a.toLowerCase()]=parseFloat(d["border"+a+"Width"])}),c.right=z.body.scrollWidth-c.left-e.width+f.right,c.bottom=z.body.scrollHeight-c.top-e.height+f.bottom,x.page.top>=c.top+f.top&&x.page.bottom>=c.bottom&&x.page.left>=c.left+f.left&&x.page.right>=c.right){var g=b.scrollTop,j=b.scrollLeft;x.offset={top:x.page.top-c.top+g-f.top,left:x.page.left-c.left+j-f.left}}}(),this.move(x),this.history.unshift(x),this.history.length>3&&this.history.pop(),b&&F(),!0}}},{key:"move",value:function(a){var b=this;if("undefined"!=typeof this.element.parentNode){var c={};for(var d in a){c[d]={};for(var e in a[d]){for(var f=!1,g=0;g=0){var o=h.split(" "),q=H(o,2);l=q[0],k=q[1]}else k=l=h;var t=w(b,f);"target"!==l&&"both"!==l||(ct[3]&&"bottom"===r.top&&(c-=m,r.top="top")),"together"===l&&("top"===r.top&&("bottom"===s.top&&ct[3]&&c-(g-m)>=t[1]&&(c-=g-m,r.top="bottom",s.top="bottom")),"bottom"===r.top&&("top"===s.top&&c+g>t[3]?(c-=m,r.top="top",c-=g,s.top="bottom"):"bottom"===s.top&&ct[3]&&"top"===s.top?(c-=g,s.top="bottom"):ct[2]&&"right"===r.left&&(d-=n,r.left="left")),"together"===k&&(dt[2]&&"right"===r.left?"left"===s.left?(d-=n,r.left="left",d-=i,s.left="right"):"right"===s.left&&(d-=n,r.left="left",d+=i,s.left="left"):"center"===r.left&&(d+i>t[2]&&"left"===s.left?(d-=i,s.left="right"):dt[3]&&"top"===s.top&&(c-=g,s.top="bottom")),"element"!==k&&"both"!==k||(dt[2]&&("left"===s.left?(d-=i,s.left="right"):"center"===s.left&&(d-=i/2,s.left="right"))),"string"==typeof j?j=j.split(",").map(function(a){return a.trim()}):j===!0&&(j=["top","left","right","bottom"]),j=j||[];var u=[],v=[];c=0?(c=t[1],u.push("top")):v.push("top")),c+g>t[3]&&(j.indexOf("bottom")>=0?(c=t[3]-g,u.push("bottom")):v.push("bottom")),d=0?(d=t[0],u.push("left")):v.push("left")),d+i>t[2]&&(j.indexOf("right")>=0?(d=t[2]-i,u.push("right")):v.push("right")),u.length&&!function(){var a=void 0;a="undefined"!=typeof b.options.pinnedClass?b.options.pinnedClass:b.getClass("pinned"),p.push(a),u.forEach(function(b){p.push(a+"-"+b)})}(),v.length&&!function(){var a=void 0;a="undefined"!=typeof b.options.outOfBoundsClass?b.options.outOfBoundsClass:b.getClass("out-of-bounds"),p.push(a),v.forEach(function(b){p.push(a+"-"+b)})}(),(u.indexOf("left")>=0||u.indexOf("right")>=0)&&(s.left=r.left=!1),(u.indexOf("top")>=0||u.indexOf("bottom")>=0)&&(s.top=r.top=!1),r.top===e.top&&r.left===e.left&&s.top===b.attachment.top&&s.left===b.attachment.left||(b.updateAttachClasses(s,r),b.trigger("update",{attachment:s,targetAttachment:r}))}),E(function(){b.options.addTargetClasses!==!1&&q(b.target,p,o),q(b.element,p,o)}),{top:c,left:d}}});var J=y.Utils,h=J.getBounds,q=J.updateClasses,E=J.defer;y.modules.push({position:function(a){var b=this,c=a.top,d=a.left,e=this.cache("element-bounds",function(){return h(b.element)}),f=e.height,g=e.width,i=this.getTargetBounds(),j=c+f,k=d+g,l=[];c<=i.bottom&&j>=i.top&&["left","right"].forEach(function(a){var b=i[a];b!==d&&b!==k||l.push(a)}),d<=i.right&&k>=i.left&&["top","bottom"].forEach(function(a){var b=i[a];b!==c&&b!==j||l.push(a)});var m=[],n=[],o=["left","top","right","bottom"];return m.push(this.getClass("abutted")),o.forEach(function(a){m.push(b.getClass("abutted")+"-"+a)}),l.length&&n.push(this.getClass("abutted")),l.forEach(function(a){n.push(b.getClass("abutted")+"-"+a)}),E(function(){b.options.addTargetClasses!==!1&&q(b.target,n,m),q(b.element,n,m)}),!0}});var H=function(){function a(a,b){var c=[],d=!0,e=!1,f=void 0;try{for(var g,h=a[Symbol.iterator]();!(d=(g=h.next()).done)&&(c.push(g.value),!b||c.length!==b);d=!0);}catch(i){e=!0,f=i}finally{try{!d&&h["return"]&&h["return"]()}finally{if(e)throw f}}return c}return function(b,c){if(Array.isArray(b))return b;if(Symbol.iterator in Object(b))return a(b,c);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}();return y.modules.push({position:function(a){var b=a.top,c=a.left;if(this.options.shift){var d=this.options.shift;"function"==typeof this.options.shift&&(d=this.options.shift.call(this,{top:b,left:c}));var e=void 0,f=void 0;if("string"==typeof d){d=d.split(" "),d[1]=d[1]||d[0];var g=d,h=H(g,2);e=h[0],f=h[1],e=parseFloat(e,10),f=parseFloat(f,10)}else e=d.top,f=d.left;return b+=e,c+=f,{top:b,left:c}}}}),V}); \ No newline at end of file diff --git a/amd/build/tooltip.min.js b/amd/build/tooltip.min.js new file mode 100644 index 0000000..01e07a1 --- /dev/null +++ b/amd/build/tooltip.min.js @@ -0,0 +1 @@ +define(["exports","jquery","core/popper","./util"],function(a,b,c,d){"use strict";function e(a){return a&&a.__esModule?a:{"default":a}}function f(){return f=Object.assign||function(a){for(var b=1;b
',trigger:"hover focus",title:"",delay:0,html:!1,selector:!1,placement:"top",offset:0,container:!1,fallbackPlacement:"flip",boundary:"scrollParent"},s={SHOW:"show",OUT:"out"},t={HIDE:"hide".concat(e),HIDDEN:"hidden".concat(e),SHOW:"show".concat(e),SHOWN:"shown".concat(e),INSERTED:"inserted".concat(e),CLICK:"click".concat(e),FOCUSIN:"focusin".concat(e),FOCUSOUT:"focusout".concat(e),MOUSEENTER:"mouseenter".concat(e),MOUSELEAVE:"mouseleave".concat(e)},u={FADE:"fade",SHOW:"show"},v={TOOLTIP:".tooltip",TOOLTIP_INNER:".tooltip-inner",ARROW:".arrow"},w={HOVER:"hover",FOCUS:"focus",CLICK:"click",MANUAL:"manual"},x=function(){function i(a,b){if(h(this,i),"undefined"==typeof l["default"])throw new TypeError("Bootstrap tooltips require Popper.js (https://popper.js.org)");this._isEnabled=!0,this._timeout=0,this._hoverState="",this._activeTrigger={},this._popper=null,this.element=a,this.config=this._getConfig(b),this.tip=null,this._setListeners()}return j(i,[{key:"enable",value:function(){this._isEnabled=!0}},{key:"disable",value:function(){this._isEnabled=!1}},{key:"toggleEnabled",value:function(){this._isEnabled=!this._isEnabled}},{key:"toggle",value:function(b){if(this._isEnabled)if(b){var c=this.constructor.DATA_KEY,d=a(b.currentTarget).data(c);d||(d=new this.constructor(b.currentTarget,this._getDelegateConfig()),a(b.currentTarget).data(c,d)),d._activeTrigger.click=!d._activeTrigger.click,d._isWithActiveTrigger()?d._enter(null,d):d._leave(null,d)}else{if(a(this.getTipElement()).hasClass(u.SHOW))return void this._leave(null,this);this._enter(null,this)}}},{key:"dispose",value:function(){clearTimeout(this._timeout),a.removeData(this.element,this.constructor.DATA_KEY),a(this.element).off(this.constructor.EVENT_KEY),a(this.element).closest(".modal").off("hide.bs.modal"),this.tip&&a(this.tip).remove(),this._isEnabled=null,this._timeout=null,this._hoverState=null,this._activeTrigger=null,null!==this._popper&&this._popper.destroy(),this._popper=null,this.element=null,this.config=null,this.tip=null}},{key:"show",value:function(){var b=this;if("none"===a(this.element).css("display"))throw new Error("Please use show on visible elements");var c=a.Event(this.constructor.Event.SHOW);if(this.isWithContent()&&this._isEnabled){a(this.element).trigger(c);var d=a.contains(this.element.ownerDocument.documentElement,this.element);if(c.isDefaultPrevented()||!d)return;var e=this.getTipElement(),f=m["default"].getUID(this.constructor.NAME);e.setAttribute("id",f),this.element.setAttribute("aria-describedby",f),this.setContent(),this.config.animation&&a(e).addClass(u.FADE);var g="function"==typeof this.config.placement?this.config.placement.call(this,e,this.element):this.config.placement,h=this._getAttachment(g);this.addAttachmentClass(h);var j=this.config.container===!1?document.body:a(this.config.container);a(e).data(this.constructor.DATA_KEY,this),a.contains(this.element.ownerDocument.documentElement,this.tip)||a(e).appendTo(j),a(this.element).trigger(this.constructor.Event.INSERTED),this._popper=new l["default"](this.element,e,{placement:h,modifiers:{offset:{offset:this.config.offset},flip:{behavior:this.config.fallbackPlacement},arrow:{element:v.ARROW},preventOverflow:{boundariesElement:this.config.boundary}},onCreate:function(a){a.originalPlacement!==a.placement&&b._handlePopperPlacementChange(a)},onUpdate:function(a){b._handlePopperPlacementChange(a)}}),a(e).addClass(u.SHOW),"ontouchstart"in document.documentElement&&a("body").children().on("mouseover",null,a.noop);var k=function(){b.config.animation&&b._fixTransition();var c=b._hoverState;b._hoverState=null,a(b.element).trigger(b.constructor.Event.SHOWN),c===s.OUT&&b._leave(null,b)};m["default"].supportsTransitionEnd()&&a(this.tip).hasClass(u.FADE)?a(this.tip).one(m["default"].TRANSITION_END,k).emulateTransitionEnd(i._TRANSITION_DURATION):k()}}},{key:"hide",value:function(b){var c=this,d=this.getTipElement(),e=a.Event(this.constructor.Event.HIDE),f=function(){c._hoverState!==s.SHOW&&d.parentNode&&d.parentNode.removeChild(d),c._cleanTipClass(),c.element.removeAttribute("aria-describedby"),a(c.element).trigger(c.constructor.Event.HIDDEN),null!==c._popper&&c._popper.destroy(),b&&b()};a(this.element).trigger(e),e.isDefaultPrevented()||(a(d).removeClass(u.SHOW),"ontouchstart"in document.documentElement&&a("body").children().off("mouseover",null,a.noop),this._activeTrigger[w.CLICK]=!1,this._activeTrigger[w.FOCUS]=!1,this._activeTrigger[w.HOVER]=!1,m["default"].supportsTransitionEnd()&&a(this.tip).hasClass(u.FADE)?a(d).one(m["default"].TRANSITION_END,f).emulateTransitionEnd(k):f(),this._hoverState="")}},{key:"update",value:function(){null!==this._popper&&this._popper.scheduleUpdate()}},{key:"isWithContent",value:function(){return Boolean(this.getTitle())}},{key:"addAttachmentClass",value:function(b){a(this.getTipElement()).addClass("".concat(n,"-").concat(b))}},{key:"getTipElement",value:function(){return this.tip=this.tip||a(this.config.template)[0],this.tip}},{key:"setContent",value:function(){var b=a(this.getTipElement());this.setElementContent(b.find(v.TOOLTIP_INNER),this.getTitle()),b.removeClass("".concat(u.FADE," ").concat(u.SHOW))}},{key:"setElementContent",value:function(b,c){var d=this.config.html;"object"===g(c)&&(c.nodeType||c.jquery)?d?a(c).parent().is(b)||b.empty().append(c):b.text(a(c).text()):b[d?"html":"text"](c)}},{key:"getTitle",value:function(){var a=this.element.getAttribute("data-original-title");return a||(a="function"==typeof this.config.title?this.config.title.call(this.element):this.config.title),a}},{key:"_getAttachment",value:function(a){return q[a.toUpperCase()]}},{key:"_setListeners",value:function(){var b=this,c=this.config.trigger.split(" ");c.forEach(function(c){if("click"===c)a(b.element).on(b.constructor.Event.CLICK,b.config.selector,function(a){return b.toggle(a)});else if(c!==w.MANUAL){var d=c===w.HOVER?b.constructor.Event.MOUSEENTER:b.constructor.Event.FOCUSIN,e=c===w.HOVER?b.constructor.Event.MOUSELEAVE:b.constructor.Event.FOCUSOUT;a(b.element).on(d,b.config.selector,function(a){return b._enter(a)}).on(e,b.config.selector,function(a){return b._leave(a)})}a(b.element).closest(".modal").on("hide.bs.modal",function(){return b.hide()})}),this.config.selector?this.config=f({},this.config,{trigger:"manual",selector:""}):this._fixTitle()}},{key:"_fixTitle",value:function(){var a=g(this.element.getAttribute("data-original-title"));(this.element.getAttribute("title")||"string"!==a)&&(this.element.setAttribute("data-original-title",this.element.getAttribute("title")||""),this.element.setAttribute("title",""))}},{key:"_enter",value:function(b,c){var d=this.constructor.DATA_KEY;return c=c||a(b.currentTarget).data(d),c||(c=new this.constructor(b.currentTarget,this._getDelegateConfig()),a(b.currentTarget).data(d,c)),b&&(c._activeTrigger["focusin"===b.type?w.FOCUS:w.HOVER]=!0),a(c.getTipElement()).hasClass(u.SHOW)||c._hoverState===s.SHOW?void(c._hoverState=s.SHOW):(clearTimeout(c._timeout),c._hoverState=s.SHOW,c.config.delay&&c.config.delay.show?void(c._timeout=setTimeout(function(){c._hoverState===s.SHOW&&c.show()},c.config.delay.show)):void c.show())}},{key:"_leave",value:function(b,c){var d=this.constructor.DATA_KEY;if(c=c||a(b.currentTarget).data(d),c||(c=new this.constructor(b.currentTarget,this._getDelegateConfig()),a(b.currentTarget).data(d,c)),b&&(c._activeTrigger["focusout"===b.type?w.FOCUS:w.HOVER]=!1),!c._isWithActiveTrigger())return clearTimeout(c._timeout),c._hoverState=s.OUT,c.config.delay&&c.config.delay.hide?void(c._timeout=setTimeout(function(){c._hoverState===s.OUT&&c.hide()},c.config.delay.hide)):void c.hide()}},{key:"_isWithActiveTrigger",value:function(){for(var a in this._activeTrigger)if(this._activeTrigger[a])return!0;return!1}},{key:"_getConfig",value:function(c){return c=f({},this.constructor.Default,a(this.element).data(),c),"number"==typeof c.delay&&(c.delay={show:c.delay,hide:c.delay}),"number"==typeof c.title&&(c.title=c.title.toString()),"number"==typeof c.content&&(c.content=c.content.toString()),m["default"].typeCheckConfig(b,c,this.constructor.DefaultType),c}},{key:"_getDelegateConfig",value:function(){var a={};if(this.config)for(var b in this.config)this.constructor.Default[b]!==this.config[b]&&(a[b]=this.config[b]);return a}},{key:"_cleanTipClass",value:function(){var b=a(this.getTipElement()),c=b.attr("class").match(o);null!==c&&c.length>0&&b.removeClass(c.join(""))}},{key:"_handlePopperPlacementChange",value:function(a){this._cleanTipClass(),this.addAttachmentClass(this._getAttachment(a.placement))}},{key:"_fixTransition",value:function(){var b=this.getTipElement(),c=this.config.animation;null===b.getAttribute("x-placement")&&(a(b).removeClass(u.FADE),this.config.animation=!1,this.hide(),this.show(),this.config.animation=c)}}],[{key:"_jQueryInterface",value:function(b){return this.each(function(){var c=a(this).data(d),e="object"===g(b)&&b;if((c||!/dispose|hide/.test(b))&&(c||(c=new i(this,e),a(this).data(d,c)),"string"==typeof b)){if("undefined"==typeof c[b])throw new TypeError('No method named "'.concat(b,'"'));c[b]()}})}},{key:"VERSION",get:function(){return c}},{key:"Default",get:function(){return r}},{key:"NAME",get:function(){return b}},{key:"DATA_KEY",get:function(){return d}},{key:"Event",get:function(){return t}},{key:"EVENT_KEY",get:function(){return e}},{key:"DefaultType",get:function(){return p}}]),i}();return a.fn[b]=x._jQueryInterface,a.fn[b].Constructor=x,a.fn[b].noConflict=function(){return a.fn[b]=i,x._jQueryInterface},x}(k["default"],l["default"]);a["default"]=n}); \ No newline at end of file diff --git a/amd/build/util.min.js b/amd/build/util.min.js new file mode 100644 index 0000000..3ecdb77 --- /dev/null +++ b/amd/build/util.min.js @@ -0,0 +1 @@ +define(["exports","jquery"],function(a,b){"use strict";function c(a){return a&&a.__esModule?a:{"default":a}}Object.defineProperty(a,"__esModule",{value:!0});var d=c(b),e=function(a){function b(a){return{}.toString.call(a).match(/\s([a-zA-Z]+)/)[1].toLowerCase()}function c(){return{bindType:h.end,delegateType:h.end,handle:function(b){if(a(b.target).is(this))return b.handleObj.handler.apply(this,arguments)}}}function d(){return("undefined"==typeof window||!window.QUnit)&&{end:"transitionend"}}function e(b){var c=this,d=!1;return a(this).one(j.TRANSITION_END,function(){d=!0}),setTimeout(function(){d||j.triggerTransitionEnd(c)},b),this}function f(){h=d(),a.fn.emulateTransitionEnd=e,j.supportsTransitionEnd()&&(a.event.special[j.TRANSITION_END]=c())}function g(b){return b="function"==typeof a.escapeSelector?a.escapeSelector(b).substr(1):b.replace(/(:|\.|\[|\]|,|=|@)/g,"\\$1")}var h=!1,i=1e6,j={TRANSITION_END:"bsTransitionEnd",getUID:function(a){do a+=~~(Math.random()*i);while(document.getElementById(a));return a},getSelectorFromElement:function(b){var c=b.getAttribute("data-target");c&&"#"!==c||(c=b.getAttribute("href")||""),"#"===c.charAt(0)&&(c=g(c));try{var d=a(document).find(c);return d.length>0?c:null}catch(e){return null}},reflow:function(a){return a.offsetHeight},triggerTransitionEnd:function(b){a(b).trigger(h.end)},supportsTransitionEnd:function(){return Boolean(h)},isElement:function(a){return(a[0]||a).nodeType},typeCheckConfig:function(a,c,d){for(var e in d)if(Object.prototype.hasOwnProperty.call(d,e)){var f=d[e],g=c[e],h=g&&j.isElement(g)?"element":b(g);if(!new RegExp(f).test(h))throw new Error("".concat(a.toUpperCase(),": ")+'Option "'.concat(e,'" provided type "').concat(h,'" ')+'but expected type "'.concat(f,'".'))}}};return f(),j}(d["default"]);a["default"]=e}); \ No newline at end of file diff --git a/amd/src/alert.js b/amd/src/alert.js new file mode 100644 index 0000000..4d3065e --- /dev/null +++ b/amd/src/alert.js @@ -0,0 +1,216 @@ +define(["exports", "jquery", "./util"], function (exports, _jquery, _util) { + "use strict"; + + Object.defineProperty(exports, "__esModule", { + value: true + }); + + var _jquery2 = _interopRequireDefault(_jquery); + + var _util2 = _interopRequireDefault(_util); + + function _interopRequireDefault(obj) { + return obj && obj.__esModule ? obj : { + default: obj + }; + } + + function _classCallCheck(instance, Constructor) { + if (!(instance instanceof Constructor)) { + throw new TypeError("Cannot call a class as a function"); + } + } + + function _defineProperties(target, props) { + for (var i = 0; i < props.length; i++) { + var descriptor = props[i]; + descriptor.enumerable = descriptor.enumerable || false; + descriptor.configurable = true; + if ("value" in descriptor) descriptor.writable = true; + Object.defineProperty(target, descriptor.key, descriptor); + } + } + + function _createClass(Constructor, protoProps, staticProps) { + if (protoProps) _defineProperties(Constructor.prototype, protoProps); + if (staticProps) _defineProperties(Constructor, staticProps); + return Constructor; + } + + /** + * -------------------------------------------------------------------------- + * Bootstrap (v4.0.0): alert.js + * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE) + * -------------------------------------------------------------------------- + */ + var Alert = function ($) { + /** + * ------------------------------------------------------------------------ + * Constants + * ------------------------------------------------------------------------ + */ + var NAME = 'alert'; + var VERSION = '4.0.0'; + var DATA_KEY = 'bs.alert'; + var EVENT_KEY = ".".concat(DATA_KEY); + var DATA_API_KEY = '.data-api'; + var JQUERY_NO_CONFLICT = $.fn[NAME]; + var TRANSITION_DURATION = 150; + var Selector = { + DISMISS: '[data-dismiss="alert"]' + }; + var Event = { + CLOSE: "close".concat(EVENT_KEY), + CLOSED: "closed".concat(EVENT_KEY), + CLICK_DATA_API: "click".concat(EVENT_KEY).concat(DATA_API_KEY) + }; + var ClassName = { + ALERT: 'alert', + FADE: 'fade', + SHOW: 'show' + /** + * ------------------------------------------------------------------------ + * Class Definition + * ------------------------------------------------------------------------ + */ + + }; + + var Alert = function () { + function Alert(element) { + _classCallCheck(this, Alert); + + this._element = element; + } // Getters + + + _createClass(Alert, [{ + key: "close", + value: function close(element) { + element = element || this._element; + + var rootElement = this._getRootElement(element); + + var customEvent = this._triggerCloseEvent(rootElement); + + if (customEvent.isDefaultPrevented()) { + return; + } + + this._removeElement(rootElement); + } + }, { + key: "dispose", + value: function dispose() { + $.removeData(this._element, DATA_KEY); + this._element = null; + } + }, { + key: "_getRootElement", + value: function _getRootElement(element) { + var selector = _util2.default.getSelectorFromElement(element); + + var parent = false; + + if (selector) { + parent = $(selector)[0]; + } + + if (!parent) { + parent = $(element).closest(".".concat(ClassName.ALERT))[0]; + } + + return parent; + } + }, { + key: "_triggerCloseEvent", + value: function _triggerCloseEvent(element) { + var closeEvent = $.Event(Event.CLOSE); + $(element).trigger(closeEvent); + return closeEvent; + } + }, { + key: "_removeElement", + value: function _removeElement(element) { + var _this = this; + + $(element).removeClass(ClassName.SHOW); + + if (!_util2.default.supportsTransitionEnd() || !$(element).hasClass(ClassName.FADE)) { + this._destroyElement(element); + + return; + } + + $(element).one(_util2.default.TRANSITION_END, function (event) { + return _this._destroyElement(element, event); + }).emulateTransitionEnd(TRANSITION_DURATION); + } + }, { + key: "_destroyElement", + value: function _destroyElement(element) { + $(element).detach().trigger(Event.CLOSED).remove(); + } + }], [{ + key: "_jQueryInterface", + value: function _jQueryInterface(config) { + return this.each(function () { + var $element = $(this); + var data = $element.data(DATA_KEY); + + if (!data) { + data = new Alert(this); + $element.data(DATA_KEY, data); + } + + if (config === 'close') { + data[config](this); + } + }); + } + }, { + key: "_handleDismiss", + value: function _handleDismiss(alertInstance) { + return function (event) { + if (event) { + event.preventDefault(); + } + + alertInstance.close(this); + }; + } + }, { + key: "VERSION", + get: function get() { + return VERSION; + } + }]); + + return Alert; + }(); + + /** + * ------------------------------------------------------------------------ + * Data Api implementation + * ------------------------------------------------------------------------ + */ + $(document).on(Event.CLICK_DATA_API, Selector.DISMISS, Alert._handleDismiss(new Alert())); + /** + * ------------------------------------------------------------------------ + * jQuery + * ------------------------------------------------------------------------ + */ + + $.fn[NAME] = Alert._jQueryInterface; + $.fn[NAME].Constructor = Alert; + + $.fn[NAME].noConflict = function () { + $.fn[NAME] = JQUERY_NO_CONFLICT; + return Alert._jQueryInterface; + }; + + return Alert; + }(_jquery2.default); + + exports.default = Alert; +}); \ No newline at end of file diff --git a/amd/src/aria.js b/amd/src/aria.js new file mode 100644 index 0000000..bee1379 --- /dev/null +++ b/amd/src/aria.js @@ -0,0 +1,201 @@ +// This file is part of Moodle - http://moodle.org/ +// +// Moodle is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// Moodle is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with Moodle. If not, see . + +/** + * Enhancements to Bootstrap components for accessibility. + * + * @module theme_ilb/aria + * @copyright 2018 Damyon Wiese + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ +define(['jquery', 'core/pending'], function($, Pending) { + return { + init: function() { + // Drop downs from bootstrap don't support keyboard accessibility by default. + var focusEnd = false, + setFocusEnd = function() { + focusEnd = true; + }, + getFocusEnd = function() { + var result = focusEnd; + focusEnd = false; + return result; + }; + + // Special handling for "up" keyboard control. + $('[data-toggle="dropdown"]').keydown(function(e) { + var trigger = e.which || e.keyCode, + expanded; + + // Up key opens the menu at the end. + if (trigger == 38) { + // Focus the end of the menu, not the beginning. + setFocusEnd(); + } + + // Escape key only closes the menu, it doesn't open it. + if (trigger == 27) { + expanded = $(e.target).attr('aria-expanded'); + e.preventDefault(); + if (expanded == "false") { + $(e.target).click(); + } + } + + // Space key or Enter key opens the menu. + if (trigger == 32 || trigger == 13) { + // Cancel random scroll. + e.preventDefault(); + // Open the menu instead. + $(e.target).click(); + } + }); + + // Special handling for navigation keys when menu is open. + var shiftFocus = function(element) { + var delayedFocus = function(pendingPromise) { + $(this).focus(); + pendingPromise.resolve(); + }.bind(element); + setTimeout(delayedFocus, 50, new Pending('core/aria:delayed-focus')); + }; + + $('.dropdown').on('shown.bs.dropdown', function(e) { + // We need to focus on the first menuitem. + var menu = $(e.target).find('[role="menu"]'), + menuItems = false, + foundMenuItem = false; + + if (menu) { + menuItems = $(menu).find('[role="menuitem"]'); + } + if (menuItems && menuItems.length > 0) { + if (getFocusEnd()) { + foundMenuItem = menuItems[menuItems.length - 1]; + } else { + // The first menu entry, pretty reasonable. + foundMenuItem = menuItems[0]; + } + } + if (foundMenuItem) { + shiftFocus(foundMenuItem); + } + }); + // Search for menu items by finding the first item that has + // text starting with the typed character (case insensitive). + $('.dropdown [role="menu"] [role="menuitem"]').keypress(function(e) { + var trigger = String.fromCharCode(e.which || e.keyCode), + menu = $(e.target).closest('[role="menu"]'), + i = 0, + menuItems = false, + item, + itemText; + + if (!menu) { + return; + } + menuItems = $(menu).find('[role="menuitem"]'); + if (!menuItems) { + return; + } + + trigger = trigger.toLowerCase(); + for (i = 0; i < menuItems.length; i++) { + item = $(menuItems[i]); + itemText = item.text().trim().toLowerCase(); + if (itemText.indexOf(trigger) == 0) { + shiftFocus(item); + break; + } + } + }); + + // Keyboard navigation for arrow keys, home and end keys. + $('.dropdown [role="menu"] [role="menuitem"]').keydown(function(e) { + var trigger = e.which || e.keyCode, + next = false, + menu = $(e.target).closest('[role="menu"]'), + i = 0, + menuItems = false; + if (!menu) { + return; + } + menuItems = $(menu).find('[role="menuitem"]'); + if (!menuItems) { + return; + } + // Down key. + if (trigger == 40) { + for (i = 0; i < menuItems.length - 1; i++) { + if (menuItems[i] == e.target) { + next = menuItems[i + 1]; + break; + } + } + if (!next) { + // Wrap to first item. + next = menuItems[0]; + } + + } else if (trigger == 38) { + // Up key. + for (i = 1; i < menuItems.length; i++) { + if (menuItems[i] == e.target) { + next = menuItems[i - 1]; + break; + } + } + if (!next) { + // Wrap to last item. + next = menuItems[menuItems.length - 1]; + } + + } else if (trigger == 36) { + // Home key. + next = menuItems[0]; + + } else if (trigger == 35) { + // End key. + next = menuItems[menuItems.length - 1]; + } + // Variable next is set if we do want to act on the keypress. + if (next) { + e.preventDefault(); + shiftFocus(next); + } + return; + }); + $('.dropdown').on('hidden.bs.dropdown', function(e) { + // We need to focus on the menu trigger. + var trigger = $(e.target).find('[data-toggle="dropdown"]'); + if (trigger) { + shiftFocus(trigger); + } + }); + + // After page load, focus on any element with special autofocus attribute. + $(function() { + window.setTimeout(function(pendingPromise) { + var alerts = $('[role="alert"][data-aria-autofocus="true"]'); + if (alerts.length > 0) { + $(alerts[0]).attr('tabindex', '0'); + $(alerts[0]).focus(); + } + pendingPromise.resolve(); + }, 300, new Pending('core/aria:delayed-focus')); + }); + } + }; +}); diff --git a/amd/src/button.js b/amd/src/button.js new file mode 100644 index 0000000..00a407a --- /dev/null +++ b/amd/src/button.js @@ -0,0 +1,200 @@ +define(["exports", "jquery"], function (exports, _jquery) { + "use strict"; + + Object.defineProperty(exports, "__esModule", { + value: true + }); + + var _jquery2 = _interopRequireDefault(_jquery); + + function _interopRequireDefault(obj) { + return obj && obj.__esModule ? obj : { + default: obj + }; + } + + function _classCallCheck(instance, Constructor) { + if (!(instance instanceof Constructor)) { + throw new TypeError("Cannot call a class as a function"); + } + } + + function _defineProperties(target, props) { + for (var i = 0; i < props.length; i++) { + var descriptor = props[i]; + descriptor.enumerable = descriptor.enumerable || false; + descriptor.configurable = true; + if ("value" in descriptor) descriptor.writable = true; + Object.defineProperty(target, descriptor.key, descriptor); + } + } + + function _createClass(Constructor, protoProps, staticProps) { + if (protoProps) _defineProperties(Constructor.prototype, protoProps); + if (staticProps) _defineProperties(Constructor, staticProps); + return Constructor; + } + + /** + * -------------------------------------------------------------------------- + * Bootstrap (v4.0.0): button.js + * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE) + * -------------------------------------------------------------------------- + */ + var Button = function ($) { + /** + * ------------------------------------------------------------------------ + * Constants + * ------------------------------------------------------------------------ + */ + var NAME = 'button'; + var VERSION = '4.0.0'; + var DATA_KEY = 'bs.button'; + var EVENT_KEY = ".".concat(DATA_KEY); + var DATA_API_KEY = '.data-api'; + var JQUERY_NO_CONFLICT = $.fn[NAME]; + var ClassName = { + ACTIVE: 'active', + BUTTON: 'btn', + FOCUS: 'focus' + }; + var Selector = { + DATA_TOGGLE_CARROT: '[data-toggle^="button"]', + DATA_TOGGLE: '[data-toggle="buttons"]', + INPUT: 'input', + ACTIVE: '.active', + BUTTON: '.btn' + }; + var Event = { + CLICK_DATA_API: "click".concat(EVENT_KEY).concat(DATA_API_KEY), + FOCUS_BLUR_DATA_API: "focus".concat(EVENT_KEY).concat(DATA_API_KEY, " ") + "blur".concat(EVENT_KEY).concat(DATA_API_KEY) + /** + * ------------------------------------------------------------------------ + * Class Definition + * ------------------------------------------------------------------------ + */ + + }; + + var Button = function () { + function Button(element) { + _classCallCheck(this, Button); + + this._element = element; + } // Getters + + + _createClass(Button, [{ + key: "toggle", + value: function toggle() { + var triggerChangeEvent = true; + var addAriaPressed = true; + var rootElement = $(this._element).closest(Selector.DATA_TOGGLE)[0]; + + if (rootElement) { + var input = $(this._element).find(Selector.INPUT)[0]; + + if (input) { + if (input.type === 'radio') { + if (input.checked && $(this._element).hasClass(ClassName.ACTIVE)) { + triggerChangeEvent = false; + } else { + var activeElement = $(rootElement).find(Selector.ACTIVE)[0]; + + if (activeElement) { + $(activeElement).removeClass(ClassName.ACTIVE); + } + } + } + + if (triggerChangeEvent) { + if (input.hasAttribute('disabled') || rootElement.hasAttribute('disabled') || input.classList.contains('disabled') || rootElement.classList.contains('disabled')) { + return; + } + + input.checked = !$(this._element).hasClass(ClassName.ACTIVE); + $(input).trigger('change'); + } + + input.focus(); + addAriaPressed = false; + } + } + + if (addAriaPressed) { + this._element.setAttribute('aria-pressed', !$(this._element).hasClass(ClassName.ACTIVE)); + } + + if (triggerChangeEvent) { + $(this._element).toggleClass(ClassName.ACTIVE); + } + } + }, { + key: "dispose", + value: function dispose() { + $.removeData(this._element, DATA_KEY); + this._element = null; + } + }], [{ + key: "_jQueryInterface", + value: function _jQueryInterface(config) { + return this.each(function () { + var data = $(this).data(DATA_KEY); + + if (!data) { + data = new Button(this); + $(this).data(DATA_KEY, data); + } + + if (config === 'toggle') { + data[config](); + } + }); + } + }, { + key: "VERSION", + get: function get() { + return VERSION; + } + }]); + + return Button; + }(); + + /** + * ------------------------------------------------------------------------ + * Data Api implementation + * ------------------------------------------------------------------------ + */ + $(document).on(Event.CLICK_DATA_API, Selector.DATA_TOGGLE_CARROT, function (event) { + event.preventDefault(); + var button = event.target; + + if (!$(button).hasClass(ClassName.BUTTON)) { + button = $(button).closest(Selector.BUTTON); + } + + Button._jQueryInterface.call($(button), 'toggle'); + }).on(Event.FOCUS_BLUR_DATA_API, Selector.DATA_TOGGLE_CARROT, function (event) { + var button = $(event.target).closest(Selector.BUTTON)[0]; + $(button).toggleClass(ClassName.FOCUS, /^focus(in)?$/.test(event.type)); + }); + /** + * ------------------------------------------------------------------------ + * jQuery + * ------------------------------------------------------------------------ + */ + + $.fn[NAME] = Button._jQueryInterface; + $.fn[NAME].Constructor = Button; + + $.fn[NAME].noConflict = function () { + $.fn[NAME] = JQUERY_NO_CONFLICT; + return Button._jQueryInterface; + }; + + return Button; + }(_jquery2.default); + + exports.default = Button; +}); \ No newline at end of file diff --git a/amd/src/carousel.js b/amd/src/carousel.js new file mode 100644 index 0000000..c1a9e67 --- /dev/null +++ b/amd/src/carousel.js @@ -0,0 +1,589 @@ +define(["exports", "jquery", "./util"], function (exports, _jquery, _util) { + "use strict"; + + Object.defineProperty(exports, "__esModule", { + value: true + }); + + var _jquery2 = _interopRequireDefault(_jquery); + + var _util2 = _interopRequireDefault(_util); + + function _interopRequireDefault(obj) { + return obj && obj.__esModule ? obj : { + default: obj + }; + } + + function _typeof(obj) { + if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { + _typeof = function _typeof(obj) { + return typeof obj; + }; + } else { + _typeof = function _typeof(obj) { + return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; + }; + } + + return _typeof(obj); + } + + function _extends() { + _extends = Object.assign || function (target) { + for (var i = 1; i < arguments.length; i++) { + var source = arguments[i]; + + for (var key in source) { + if (Object.prototype.hasOwnProperty.call(source, key)) { + target[key] = source[key]; + } + } + } + + return target; + }; + + return _extends.apply(this, arguments); + } + + function _classCallCheck(instance, Constructor) { + if (!(instance instanceof Constructor)) { + throw new TypeError("Cannot call a class as a function"); + } + } + + function _defineProperties(target, props) { + for (var i = 0; i < props.length; i++) { + var descriptor = props[i]; + descriptor.enumerable = descriptor.enumerable || false; + descriptor.configurable = true; + if ("value" in descriptor) descriptor.writable = true; + Object.defineProperty(target, descriptor.key, descriptor); + } + } + + function _createClass(Constructor, protoProps, staticProps) { + if (protoProps) _defineProperties(Constructor.prototype, protoProps); + if (staticProps) _defineProperties(Constructor, staticProps); + return Constructor; + } + + /** + * -------------------------------------------------------------------------- + * Bootstrap (v4.0.0): carousel.js + * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE) + * -------------------------------------------------------------------------- + */ + var Carousel = function ($) { + /** + * ------------------------------------------------------------------------ + * Constants + * ------------------------------------------------------------------------ + */ + var NAME = 'carousel'; + var VERSION = '4.0.0'; + var DATA_KEY = 'bs.carousel'; + var EVENT_KEY = ".".concat(DATA_KEY); + var DATA_API_KEY = '.data-api'; + var JQUERY_NO_CONFLICT = $.fn[NAME]; + var TRANSITION_DURATION = 600; + var ARROW_LEFT_KEYCODE = 37; // KeyboardEvent.which value for left arrow key + + var ARROW_RIGHT_KEYCODE = 39; // KeyboardEvent.which value for right arrow key + + var TOUCHEVENT_COMPAT_WAIT = 500; // Time for mouse compat events to fire after touch + + var Default = { + interval: 5000, + keyboard: true, + slide: false, + pause: 'hover', + wrap: true + }; + var DefaultType = { + interval: '(number|boolean)', + keyboard: 'boolean', + slide: '(boolean|string)', + pause: '(string|boolean)', + wrap: 'boolean' + }; + var Direction = { + NEXT: 'next', + PREV: 'prev', + LEFT: 'left', + RIGHT: 'right' + }; + var Event = { + SLIDE: "slide".concat(EVENT_KEY), + SLID: "slid".concat(EVENT_KEY), + KEYDOWN: "keydown".concat(EVENT_KEY), + MOUSEENTER: "mouseenter".concat(EVENT_KEY), + MOUSELEAVE: "mouseleave".concat(EVENT_KEY), + TOUCHEND: "touchend".concat(EVENT_KEY), + LOAD_DATA_API: "load".concat(EVENT_KEY).concat(DATA_API_KEY), + CLICK_DATA_API: "click".concat(EVENT_KEY).concat(DATA_API_KEY) + }; + var ClassName = { + CAROUSEL: 'carousel', + ACTIVE: 'active', + SLIDE: 'slide', + RIGHT: 'carousel-item-right', + LEFT: 'carousel-item-left', + NEXT: 'carousel-item-next', + PREV: 'carousel-item-prev', + ITEM: 'carousel-item' + }; + var Selector = { + ACTIVE: '.active', + ACTIVE_ITEM: '.active.carousel-item', + ITEM: '.carousel-item', + NEXT_PREV: '.carousel-item-next, .carousel-item-prev', + INDICATORS: '.carousel-indicators', + DATA_SLIDE: '[data-slide], [data-slide-to]', + DATA_RIDE: '[data-ride="carousel"]' + /** + * ------------------------------------------------------------------------ + * Class Definition + * ------------------------------------------------------------------------ + */ + + }; + + var Carousel = function () { + function Carousel(element, config) { + _classCallCheck(this, Carousel); + + this._items = null; + this._interval = null; + this._activeElement = null; + this._isPaused = false; + this._isSliding = false; + this.touchTimeout = null; + this._config = this._getConfig(config); + this._element = $(element)[0]; + this._indicatorsElement = $(this._element).find(Selector.INDICATORS)[0]; + + this._addEventListeners(); + } // Getters + + + _createClass(Carousel, [{ + key: "next", + value: function next() { + if (!this._isSliding) { + this._slide(Direction.NEXT); + } + } + }, { + key: "nextWhenVisible", + value: function nextWhenVisible() { + // Don't call next when the page isn't visible + // or the carousel or its parent isn't visible + if (!document.hidden && $(this._element).is(':visible') && $(this._element).css('visibility') !== 'hidden') { + this.next(); + } + } + }, { + key: "prev", + value: function prev() { + if (!this._isSliding) { + this._slide(Direction.PREV); + } + } + }, { + key: "pause", + value: function pause(event) { + if (!event) { + this._isPaused = true; + } + + if ($(this._element).find(Selector.NEXT_PREV)[0] && _util2.default.supportsTransitionEnd()) { + _util2.default.triggerTransitionEnd(this._element); + + this.cycle(true); + } + + clearInterval(this._interval); + this._interval = null; + } + }, { + key: "cycle", + value: function cycle(event) { + if (!event) { + this._isPaused = false; + } + + if (this._interval) { + clearInterval(this._interval); + this._interval = null; + } + + if (this._config.interval && !this._isPaused) { + this._interval = setInterval((document.visibilityState ? this.nextWhenVisible : this.next).bind(this), this._config.interval); + } + } + }, { + key: "to", + value: function to(index) { + var _this = this; + + this._activeElement = $(this._element).find(Selector.ACTIVE_ITEM)[0]; + + var activeIndex = this._getItemIndex(this._activeElement); + + if (index > this._items.length - 1 || index < 0) { + return; + } + + if (this._isSliding) { + $(this._element).one(Event.SLID, function () { + return _this.to(index); + }); + return; + } + + if (activeIndex === index) { + this.pause(); + this.cycle(); + return; + } + + var direction = index > activeIndex ? Direction.NEXT : Direction.PREV; + + this._slide(direction, this._items[index]); + } + }, { + key: "dispose", + value: function dispose() { + $(this._element).off(EVENT_KEY); + $.removeData(this._element, DATA_KEY); + this._items = null; + this._config = null; + this._element = null; + this._interval = null; + this._isPaused = null; + this._isSliding = null; + this._activeElement = null; + this._indicatorsElement = null; + } + }, { + key: "_getConfig", + value: function _getConfig(config) { + config = _extends({}, Default, config); + + _util2.default.typeCheckConfig(NAME, config, DefaultType); + + return config; + } + }, { + key: "_addEventListeners", + value: function _addEventListeners() { + var _this2 = this; + + if (this._config.keyboard) { + $(this._element).on(Event.KEYDOWN, function (event) { + return _this2._keydown(event); + }); + } + + if (this._config.pause === 'hover') { + $(this._element).on(Event.MOUSEENTER, function (event) { + return _this2.pause(event); + }).on(Event.MOUSELEAVE, function (event) { + return _this2.cycle(event); + }); + + if ('ontouchstart' in document.documentElement) { + // If it's a touch-enabled device, mouseenter/leave are fired as + // part of the mouse compatibility events on first tap - the carousel + // would stop cycling until user tapped out of it; + // here, we listen for touchend, explicitly pause the carousel + // (as if it's the second time we tap on it, mouseenter compat event + // is NOT fired) and after a timeout (to allow for mouse compatibility + // events to fire) we explicitly restart cycling + $(this._element).on(Event.TOUCHEND, function () { + _this2.pause(); + + if (_this2.touchTimeout) { + clearTimeout(_this2.touchTimeout); + } + + _this2.touchTimeout = setTimeout(function (event) { + return _this2.cycle(event); + }, TOUCHEVENT_COMPAT_WAIT + _this2._config.interval); + }); + } + } + } + }, { + key: "_keydown", + value: function _keydown(event) { + if (/input|textarea/i.test(event.target.tagName)) { + return; + } + + switch (event.which) { + case ARROW_LEFT_KEYCODE: + event.preventDefault(); + this.prev(); + break; + + case ARROW_RIGHT_KEYCODE: + event.preventDefault(); + this.next(); + break; + + default: + } + } + }, { + key: "_getItemIndex", + value: function _getItemIndex(element) { + this._items = $.makeArray($(element).parent().find(Selector.ITEM)); + return this._items.indexOf(element); + } + }, { + key: "_getItemByDirection", + value: function _getItemByDirection(direction, activeElement) { + var isNextDirection = direction === Direction.NEXT; + var isPrevDirection = direction === Direction.PREV; + + var activeIndex = this._getItemIndex(activeElement); + + var lastItemIndex = this._items.length - 1; + var isGoingToWrap = isPrevDirection && activeIndex === 0 || isNextDirection && activeIndex === lastItemIndex; + + if (isGoingToWrap && !this._config.wrap) { + return activeElement; + } + + var delta = direction === Direction.PREV ? -1 : 1; + var itemIndex = (activeIndex + delta) % this._items.length; + return itemIndex === -1 ? this._items[this._items.length - 1] : this._items[itemIndex]; + } + }, { + key: "_triggerSlideEvent", + value: function _triggerSlideEvent(relatedTarget, eventDirectionName) { + var targetIndex = this._getItemIndex(relatedTarget); + + var fromIndex = this._getItemIndex($(this._element).find(Selector.ACTIVE_ITEM)[0]); + + var slideEvent = $.Event(Event.SLIDE, { + relatedTarget: relatedTarget, + direction: eventDirectionName, + from: fromIndex, + to: targetIndex + }); + $(this._element).trigger(slideEvent); + return slideEvent; + } + }, { + key: "_setActiveIndicatorElement", + value: function _setActiveIndicatorElement(element) { + if (this._indicatorsElement) { + $(this._indicatorsElement).find(Selector.ACTIVE).removeClass(ClassName.ACTIVE); + + var nextIndicator = this._indicatorsElement.children[this._getItemIndex(element)]; + + if (nextIndicator) { + $(nextIndicator).addClass(ClassName.ACTIVE); + } + } + } + }, { + key: "_slide", + value: function _slide(direction, element) { + var _this3 = this; + + var activeElement = $(this._element).find(Selector.ACTIVE_ITEM)[0]; + + var activeElementIndex = this._getItemIndex(activeElement); + + var nextElement = element || activeElement && this._getItemByDirection(direction, activeElement); + + var nextElementIndex = this._getItemIndex(nextElement); + + var isCycling = Boolean(this._interval); + var directionalClassName; + var orderClassName; + var eventDirectionName; + + if (direction === Direction.NEXT) { + directionalClassName = ClassName.LEFT; + orderClassName = ClassName.NEXT; + eventDirectionName = Direction.LEFT; + } else { + directionalClassName = ClassName.RIGHT; + orderClassName = ClassName.PREV; + eventDirectionName = Direction.RIGHT; + } + + if (nextElement && $(nextElement).hasClass(ClassName.ACTIVE)) { + this._isSliding = false; + return; + } + + var slideEvent = this._triggerSlideEvent(nextElement, eventDirectionName); + + if (slideEvent.isDefaultPrevented()) { + return; + } + + if (!activeElement || !nextElement) { + // Some weirdness is happening, so we bail + return; + } + + this._isSliding = true; + + if (isCycling) { + this.pause(); + } + + this._setActiveIndicatorElement(nextElement); + + var slidEvent = $.Event(Event.SLID, { + relatedTarget: nextElement, + direction: eventDirectionName, + from: activeElementIndex, + to: nextElementIndex + }); + + if (_util2.default.supportsTransitionEnd() && $(this._element).hasClass(ClassName.SLIDE)) { + $(nextElement).addClass(orderClassName); + + _util2.default.reflow(nextElement); + + $(activeElement).addClass(directionalClassName); + $(nextElement).addClass(directionalClassName); + $(activeElement).one(_util2.default.TRANSITION_END, function () { + $(nextElement).removeClass("".concat(directionalClassName, " ").concat(orderClassName)).addClass(ClassName.ACTIVE); + $(activeElement).removeClass("".concat(ClassName.ACTIVE, " ").concat(orderClassName, " ").concat(directionalClassName)); + _this3._isSliding = false; + setTimeout(function () { + return $(_this3._element).trigger(slidEvent); + }, 0); + }).emulateTransitionEnd(TRANSITION_DURATION); + } else { + $(activeElement).removeClass(ClassName.ACTIVE); + $(nextElement).addClass(ClassName.ACTIVE); + this._isSliding = false; + $(this._element).trigger(slidEvent); + } + + if (isCycling) { + this.cycle(); + } + } + }], [{ + key: "_jQueryInterface", + value: function _jQueryInterface(config) { + return this.each(function () { + var data = $(this).data(DATA_KEY); + + var _config = _extends({}, Default, $(this).data()); + + if (_typeof(config) === 'object') { + _config = _extends({}, _config, config); + } + + var action = typeof config === 'string' ? config : _config.slide; + + if (!data) { + data = new Carousel(this, _config); + $(this).data(DATA_KEY, data); + } + + if (typeof config === 'number') { + data.to(config); + } else if (typeof action === 'string') { + if (typeof data[action] === 'undefined') { + throw new TypeError("No method named \"".concat(action, "\"")); + } + + data[action](); + } else if (_config.interval) { + data.pause(); + data.cycle(); + } + }); + } + }, { + key: "_dataApiClickHandler", + value: function _dataApiClickHandler(event) { + var selector = _util2.default.getSelectorFromElement(this); + + if (!selector) { + return; + } + + var target = $(selector)[0]; + + if (!target || !$(target).hasClass(ClassName.CAROUSEL)) { + return; + } + + var config = _extends({}, $(target).data(), $(this).data()); + + var slideIndex = this.getAttribute('data-slide-to'); + + if (slideIndex) { + config.interval = false; + } + + Carousel._jQueryInterface.call($(target), config); + + if (slideIndex) { + $(target).data(DATA_KEY).to(slideIndex); + } + + event.preventDefault(); + } + }, { + key: "VERSION", + get: function get() { + return VERSION; + } + }, { + key: "Default", + get: function get() { + return Default; + } + }]); + + return Carousel; + }(); + + /** + * ------------------------------------------------------------------------ + * Data Api implementation + * ------------------------------------------------------------------------ + */ + $(document).on(Event.CLICK_DATA_API, Selector.DATA_SLIDE, Carousel._dataApiClickHandler); + $(window).on(Event.LOAD_DATA_API, function () { + $(Selector.DATA_RIDE).each(function () { + var $carousel = $(this); + + Carousel._jQueryInterface.call($carousel, $carousel.data()); + }); + }); + /** + * ------------------------------------------------------------------------ + * jQuery + * ------------------------------------------------------------------------ + */ + + $.fn[NAME] = Carousel._jQueryInterface; + $.fn[NAME].Constructor = Carousel; + + $.fn[NAME].noConflict = function () { + $.fn[NAME] = JQUERY_NO_CONFLICT; + return Carousel._jQueryInterface; + }; + + return Carousel; + }(_jquery2.default); + + exports.default = Carousel; +}); \ No newline at end of file diff --git a/amd/src/collapse.js b/amd/src/collapse.js new file mode 100644 index 0000000..636cd5f --- /dev/null +++ b/amd/src/collapse.js @@ -0,0 +1,455 @@ +define(["exports", "jquery", "./util"], function (exports, _jquery, _util) { + "use strict"; + + Object.defineProperty(exports, "__esModule", { + value: true + }); + + var _jquery2 = _interopRequireDefault(_jquery); + + var _util2 = _interopRequireDefault(_util); + + function _interopRequireDefault(obj) { + return obj && obj.__esModule ? obj : { + default: obj + }; + } + + function _typeof(obj) { + if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { + _typeof = function _typeof(obj) { + return typeof obj; + }; + } else { + _typeof = function _typeof(obj) { + return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; + }; + } + + return _typeof(obj); + } + + function _extends() { + _extends = Object.assign || function (target) { + for (var i = 1; i < arguments.length; i++) { + var source = arguments[i]; + + for (var key in source) { + if (Object.prototype.hasOwnProperty.call(source, key)) { + target[key] = source[key]; + } + } + } + + return target; + }; + + return _extends.apply(this, arguments); + } + + function _classCallCheck(instance, Constructor) { + if (!(instance instanceof Constructor)) { + throw new TypeError("Cannot call a class as a function"); + } + } + + function _defineProperties(target, props) { + for (var i = 0; i < props.length; i++) { + var descriptor = props[i]; + descriptor.enumerable = descriptor.enumerable || false; + descriptor.configurable = true; + if ("value" in descriptor) descriptor.writable = true; + Object.defineProperty(target, descriptor.key, descriptor); + } + } + + function _createClass(Constructor, protoProps, staticProps) { + if (protoProps) _defineProperties(Constructor.prototype, protoProps); + if (staticProps) _defineProperties(Constructor, staticProps); + return Constructor; + } + + /** + * -------------------------------------------------------------------------- + * Bootstrap (v4.0.0): collapse.js + * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE) + * -------------------------------------------------------------------------- + */ + var Collapse = function ($) { + /** + * ------------------------------------------------------------------------ + * Constants + * ------------------------------------------------------------------------ + */ + var NAME = 'collapse'; + var VERSION = '4.0.0'; + var DATA_KEY = 'bs.collapse'; + var EVENT_KEY = ".".concat(DATA_KEY); + var DATA_API_KEY = '.data-api'; + var JQUERY_NO_CONFLICT = $.fn[NAME]; + var TRANSITION_DURATION = 600; + var Default = { + toggle: true, + parent: '' + }; + var DefaultType = { + toggle: 'boolean', + parent: '(string|element)' + }; + var Event = { + SHOW: "show".concat(EVENT_KEY), + SHOWN: "shown".concat(EVENT_KEY), + HIDE: "hide".concat(EVENT_KEY), + HIDDEN: "hidden".concat(EVENT_KEY), + CLICK_DATA_API: "click".concat(EVENT_KEY).concat(DATA_API_KEY) + }; + var ClassName = { + SHOW: 'show', + COLLAPSE: 'collapse', + COLLAPSING: 'collapsing', + COLLAPSED: 'collapsed' + }; + var Dimension = { + WIDTH: 'width', + HEIGHT: 'height' + }; + var Selector = { + ACTIVES: '.show, .collapsing', + DATA_TOGGLE: '[data-toggle="collapse"]' + /** + * ------------------------------------------------------------------------ + * Class Definition + * ------------------------------------------------------------------------ + */ + + }; + + var Collapse = function () { + function Collapse(element, config) { + _classCallCheck(this, Collapse); + + this._isTransitioning = false; + this._element = element; + this._config = this._getConfig(config); + this._triggerArray = $.makeArray($("[data-toggle=\"collapse\"][href=\"#".concat(element.id, "\"],") + "[data-toggle=\"collapse\"][data-target=\"#".concat(element.id, "\"]"))); + var tabToggles = $(Selector.DATA_TOGGLE); + + for (var i = 0; i < tabToggles.length; i++) { + var elem = tabToggles[i]; + + var selector = _util2.default.getSelectorFromElement(elem); + + if (selector !== null && $(selector).filter(element).length > 0) { + this._selector = selector; + + this._triggerArray.push(elem); + } + } + + this._parent = this._config.parent ? this._getParent() : null; + + if (!this._config.parent) { + this._addAriaAndCollapsedClass(this._element, this._triggerArray); + } + + if (this._config.toggle) { + this.toggle(); + } + } // Getters + + + _createClass(Collapse, [{ + key: "toggle", + value: function toggle() { + if ($(this._element).hasClass(ClassName.SHOW)) { + this.hide(); + } else { + this.show(); + } + } + }, { + key: "show", + value: function show() { + var _this = this; + + if (this._isTransitioning || $(this._element).hasClass(ClassName.SHOW)) { + return; + } + + var actives; + var activesData; + + if (this._parent) { + actives = $.makeArray($(this._parent).find(Selector.ACTIVES).filter("[data-parent=\"".concat(this._config.parent, "\"]"))); + + if (actives.length === 0) { + actives = null; + } + } + + if (actives) { + activesData = $(actives).not(this._selector).data(DATA_KEY); + + if (activesData && activesData._isTransitioning) { + return; + } + } + + var startEvent = $.Event(Event.SHOW); + $(this._element).trigger(startEvent); + + if (startEvent.isDefaultPrevented()) { + return; + } + + if (actives) { + Collapse._jQueryInterface.call($(actives).not(this._selector), 'hide'); + + if (!activesData) { + $(actives).data(DATA_KEY, null); + } + } + + var dimension = this._getDimension(); + + $(this._element).removeClass(ClassName.COLLAPSE).addClass(ClassName.COLLAPSING); + this._element.style[dimension] = 0; + + if (this._triggerArray.length > 0) { + $(this._triggerArray).removeClass(ClassName.COLLAPSED).attr('aria-expanded', true); + } + + this.setTransitioning(true); + + var complete = function complete() { + $(_this._element).removeClass(ClassName.COLLAPSING).addClass(ClassName.COLLAPSE).addClass(ClassName.SHOW); + _this._element.style[dimension] = ''; + + _this.setTransitioning(false); + + $(_this._element).trigger(Event.SHOWN); + }; + + if (!_util2.default.supportsTransitionEnd()) { + complete(); + return; + } + + var capitalizedDimension = dimension[0].toUpperCase() + dimension.slice(1); + var scrollSize = "scroll".concat(capitalizedDimension); + $(this._element).one(_util2.default.TRANSITION_END, complete).emulateTransitionEnd(TRANSITION_DURATION); + this._element.style[dimension] = "".concat(this._element[scrollSize], "px"); + } + }, { + key: "hide", + value: function hide() { + var _this2 = this; + + if (this._isTransitioning || !$(this._element).hasClass(ClassName.SHOW)) { + return; + } + + var startEvent = $.Event(Event.HIDE); + $(this._element).trigger(startEvent); + + if (startEvent.isDefaultPrevented()) { + return; + } + + var dimension = this._getDimension(); + + this._element.style[dimension] = "".concat(this._element.getBoundingClientRect()[dimension], "px"); + + _util2.default.reflow(this._element); + + $(this._element).addClass(ClassName.COLLAPSING).removeClass(ClassName.COLLAPSE).removeClass(ClassName.SHOW); + + if (this._triggerArray.length > 0) { + for (var i = 0; i < this._triggerArray.length; i++) { + var trigger = this._triggerArray[i]; + + var selector = _util2.default.getSelectorFromElement(trigger); + + if (selector !== null) { + var $elem = $(selector); + + if (!$elem.hasClass(ClassName.SHOW)) { + $(trigger).addClass(ClassName.COLLAPSED).attr('aria-expanded', false); + } + } + } + } + + this.setTransitioning(true); + + var complete = function complete() { + _this2.setTransitioning(false); + + $(_this2._element).removeClass(ClassName.COLLAPSING).addClass(ClassName.COLLAPSE).trigger(Event.HIDDEN); + }; + + this._element.style[dimension] = ''; + + if (!_util2.default.supportsTransitionEnd()) { + complete(); + return; + } + + $(this._element).one(_util2.default.TRANSITION_END, complete).emulateTransitionEnd(TRANSITION_DURATION); + } + }, { + key: "setTransitioning", + value: function setTransitioning(isTransitioning) { + this._isTransitioning = isTransitioning; + } + }, { + key: "dispose", + value: function dispose() { + $.removeData(this._element, DATA_KEY); + this._config = null; + this._parent = null; + this._element = null; + this._triggerArray = null; + this._isTransitioning = null; + } + }, { + key: "_getConfig", + value: function _getConfig(config) { + config = _extends({}, Default, config); + config.toggle = Boolean(config.toggle); // Coerce string values + + _util2.default.typeCheckConfig(NAME, config, DefaultType); + + return config; + } + }, { + key: "_getDimension", + value: function _getDimension() { + var hasWidth = $(this._element).hasClass(Dimension.WIDTH); + return hasWidth ? Dimension.WIDTH : Dimension.HEIGHT; + } + }, { + key: "_getParent", + value: function _getParent() { + var _this3 = this; + + var parent = null; + + if (_util2.default.isElement(this._config.parent)) { + parent = this._config.parent; // It's a jQuery object + + if (typeof this._config.parent.jquery !== 'undefined') { + parent = this._config.parent[0]; + } + } else { + parent = $(this._config.parent)[0]; + } + + var selector = "[data-toggle=\"collapse\"][data-parent=\"".concat(this._config.parent, "\"]"); + $(parent).find(selector).each(function (i, element) { + _this3._addAriaAndCollapsedClass(Collapse._getTargetFromElement(element), [element]); + }); + return parent; + } + }, { + key: "_addAriaAndCollapsedClass", + value: function _addAriaAndCollapsedClass(element, triggerArray) { + if (element) { + var isOpen = $(element).hasClass(ClassName.SHOW); + + if (triggerArray.length > 0) { + $(triggerArray).toggleClass(ClassName.COLLAPSED, !isOpen).attr('aria-expanded', isOpen); + } + } + } + }], [{ + key: "_getTargetFromElement", + value: function _getTargetFromElement(element) { + var selector = _util2.default.getSelectorFromElement(element); + + return selector ? $(selector)[0] : null; + } + }, { + key: "_jQueryInterface", + value: function _jQueryInterface(config) { + return this.each(function () { + var $this = $(this); + var data = $this.data(DATA_KEY); + + var _config = _extends({}, Default, $this.data(), _typeof(config) === 'object' && config); + + if (!data && _config.toggle && /show|hide/.test(config)) { + _config.toggle = false; + } + + if (!data) { + data = new Collapse(this, _config); + $this.data(DATA_KEY, data); + } + + if (typeof config === 'string') { + if (typeof data[config] === 'undefined') { + throw new TypeError("No method named \"".concat(config, "\"")); + } + + data[config](); + } + }); + } + }, { + key: "VERSION", + get: function get() { + return VERSION; + } + }, { + key: "Default", + get: function get() { + return Default; + } + }]); + + return Collapse; + }(); + + /** + * ------------------------------------------------------------------------ + * Data Api implementation + * ------------------------------------------------------------------------ + */ + $(document).on(Event.CLICK_DATA_API, Selector.DATA_TOGGLE, function (event) { + // preventDefault only for elements (which change the URL) not inside the collapsible element + if (event.currentTarget.tagName === 'A') { + event.preventDefault(); + } + + var $trigger = $(this); + + var selector = _util2.default.getSelectorFromElement(this); + + $(selector).each(function () { + var $target = $(this); + var data = $target.data(DATA_KEY); + var config = data ? 'toggle' : $trigger.data(); + + Collapse._jQueryInterface.call($target, config); + }); + }); + /** + * ------------------------------------------------------------------------ + * jQuery + * ------------------------------------------------------------------------ + */ + + $.fn[NAME] = Collapse._jQueryInterface; + $.fn[NAME].Constructor = Collapse; + + $.fn[NAME].noConflict = function () { + $.fn[NAME] = JQUERY_NO_CONFLICT; + return Collapse._jQueryInterface; + }; + + return Collapse; + }(_jquery2.default); + + exports.default = Collapse; +}); \ No newline at end of file diff --git a/amd/src/drawer.js b/amd/src/drawer.js new file mode 100644 index 0000000..802795a --- /dev/null +++ b/amd/src/drawer.js @@ -0,0 +1,181 @@ +// This file is part of Moodle - http://moodle.org/ +// +// Moodle is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// Moodle is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with Moodle. If not, see . + +/** + * Contain the logic for a drawer. + * + * @package theme_ilb + * @copyright 2016 Damyon Wiese + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ +define(['jquery', 'core/custom_interaction_events', 'core/log'], + function($, CustomEvents, Log) { + + var SELECTORS = { + TOGGLE_REGION: '[data-region="drawer-toggle"]', + TOGGLE_ACTION: '[data-action="toggle-drawer"]', + TOGGLE_TARGET: 'aria-controls', + TOGGLE_SIDE: 'left', + BODY: 'body', + SECTION: '.list-group-item[href*="#section-"]' + }; + + var small = $(document).width() < 768; + + /** + * Constructor for the Drawer. + * + * @param {object} root The root jQuery element for the modal + */ + var Drawer = function() { + + if (!$(SELECTORS.TOGGLE_REGION).length) { + Log.debug('Page is missing a drawer region'); + } + if (!$(SELECTORS.TOGGLE_ACTION).length) { + Log.debug('Page is missing a drawer toggle link'); + } + $(SELECTORS.TOGGLE_REGION).each(function(index, ele) { + var trigger = $(ele).find(SELECTORS.TOGGLE_ACTION); + var drawerid = trigger.attr('aria-controls'); + var drawer = $(document.getElementById(drawerid)); + var hidden = trigger.attr('aria-expanded') == 'false'; + var side = trigger.attr('data-side'); + var body = $(SELECTORS.BODY); + var preference = trigger.attr('data-preference'); + if (small) { + M.util.set_user_preference(preference, 'false'); + } + + drawer.on('mousewheel DOMMouseScroll', this.preventPageScroll); + + if (!hidden) { + body.addClass('drawer-open-' + side); + trigger.attr('aria-expanded', 'true'); + } else { + trigger.attr('aria-expanded', 'false'); + } + }.bind(this)); + + this.registerEventListeners(); + if (small) { + this.closeAll(); + } + }; + + Drawer.prototype.closeAll = function() { + $(SELECTORS.TOGGLE_REGION).each(function(index, ele) { + var trigger = $(ele).find(SELECTORS.TOGGLE_ACTION); + var side = trigger.attr('data-side'); + var body = $(SELECTORS.BODY); + var drawerid = trigger.attr('aria-controls'); + var drawer = $(document.getElementById(drawerid)); + var preference = trigger.attr('data-preference'); + + trigger.attr('aria-expanded', 'false'); + body.removeClass('drawer-open-' + side); + drawer.attr('aria-hidden', 'true'); + drawer.addClass('closed'); + if (!small) { + M.util.set_user_preference(preference, 'false'); + } + }); + }; + + /** + * Open / close the blocks drawer. + * + * @method toggleDrawer + * @param {Event} e + */ + Drawer.prototype.toggleDrawer = function(e) { + var trigger = $(e.target).closest('[data-action=toggle-drawer]'); + var drawerid = trigger.attr('aria-controls'); + var drawer = $(document.getElementById(drawerid)); + var body = $(SELECTORS.BODY); + var side = trigger.attr('data-side'); + var preference = trigger.attr('data-preference'); + if (small) { + M.util.set_user_preference(preference, 'false'); + } + + body.addClass('drawer-ease'); + var open = trigger.attr('aria-expanded') == 'true'; + if (!open) { + // Open. + trigger.attr('aria-expanded', 'true'); + drawer.attr('aria-hidden', 'false'); + drawer.focus(); + body.addClass('drawer-open-' + side); + drawer.removeClass('closed'); + if (!small) { + M.util.set_user_preference(preference, 'true'); + } + } else { + // Close. + body.removeClass('drawer-open-' + side); + trigger.attr('aria-expanded', 'false'); + drawer.attr('aria-hidden', 'true'); + drawer.addClass('closed'); + if (!small) { + M.util.set_user_preference(preference, 'false'); + } + } + }; + + /** + * Prevent the page from scrolling when the drawer is at max scroll. + * + * @method preventPageScroll + * @param {Event} e + */ + Drawer.prototype.preventPageScroll = function(e) { + var delta = e.wheelDelta || (e.originalEvent && e.originalEvent.wheelDelta) || -e.originalEvent.detail, + bottomOverflow = (this.scrollTop + $(this).outerHeight() - this.scrollHeight) >= 0, + topOverflow = this.scrollTop <= 0; + + if ((delta < 0 && bottomOverflow) || (delta > 0 && topOverflow)) { + e.preventDefault(); + } + }; + + /** + * Set up all of the event handling for the modal. + * + * @method registerEventListeners + */ + Drawer.prototype.registerEventListeners = function() { + + $(SELECTORS.TOGGLE_ACTION).each(function(index, element) { + CustomEvents.define($(element), [CustomEvents.events.activate]); + $(element).on(CustomEvents.events.activate, function(e, data) { + this.toggleDrawer(data.originalEvent); + data.originalEvent.preventDefault(); + }.bind(this)); + }.bind(this)); + + $(SELECTORS.SECTION).click(function() { + if (small) { + this.closeAll(); + } + }.bind(this)); + }; + + return { + 'init': function() { + return new Drawer(); + } + }; +}); diff --git a/amd/src/dropdown.js b/amd/src/dropdown.js new file mode 100644 index 0000000..6940589 --- /dev/null +++ b/amd/src/dropdown.js @@ -0,0 +1,549 @@ +define(["exports", "jquery", "core/popper", "./util"], function (exports, _jquery, _popper, _util) { + "use strict"; + + Object.defineProperty(exports, "__esModule", { + value: true + }); + + var _jquery2 = _interopRequireDefault(_jquery); + + var _popper2 = _interopRequireDefault(_popper); + + var _util2 = _interopRequireDefault(_util); + + function _interopRequireDefault(obj) { + return obj && obj.__esModule ? obj : { + default: obj + }; + } + + function _typeof(obj) { + if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { + _typeof = function _typeof(obj) { + return typeof obj; + }; + } else { + _typeof = function _typeof(obj) { + return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; + }; + } + + return _typeof(obj); + } + + function _extends() { + _extends = Object.assign || function (target) { + for (var i = 1; i < arguments.length; i++) { + var source = arguments[i]; + + for (var key in source) { + if (Object.prototype.hasOwnProperty.call(source, key)) { + target[key] = source[key]; + } + } + } + + return target; + }; + + return _extends.apply(this, arguments); + } + + function _classCallCheck(instance, Constructor) { + if (!(instance instanceof Constructor)) { + throw new TypeError("Cannot call a class as a function"); + } + } + + function _defineProperties(target, props) { + for (var i = 0; i < props.length; i++) { + var descriptor = props[i]; + descriptor.enumerable = descriptor.enumerable || false; + descriptor.configurable = true; + if ("value" in descriptor) descriptor.writable = true; + Object.defineProperty(target, descriptor.key, descriptor); + } + } + + function _createClass(Constructor, protoProps, staticProps) { + if (protoProps) _defineProperties(Constructor.prototype, protoProps); + if (staticProps) _defineProperties(Constructor, staticProps); + return Constructor; + } + + /** + * -------------------------------------------------------------------------- + * Bootstrap (v4.0.0): dropdown.js + * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE) + * -------------------------------------------------------------------------- + */ + var Dropdown = function ($) { + /** + * ------------------------------------------------------------------------ + * Constants + * ------------------------------------------------------------------------ + */ + var NAME = 'dropdown'; + var VERSION = '4.0.0'; + var DATA_KEY = 'bs.dropdown'; + var EVENT_KEY = ".".concat(DATA_KEY); + var DATA_API_KEY = '.data-api'; + var JQUERY_NO_CONFLICT = $.fn[NAME]; + var ESCAPE_KEYCODE = 27; // KeyboardEvent.which value for Escape (Esc) key + + var SPACE_KEYCODE = 32; // KeyboardEvent.which value for space key + + var TAB_KEYCODE = 9; // KeyboardEvent.which value for tab key + + var ARROW_UP_KEYCODE = 38; // KeyboardEvent.which value for up arrow key + + var ARROW_DOWN_KEYCODE = 40; // KeyboardEvent.which value for down arrow key + + var RIGHT_MOUSE_BUTTON_WHICH = 3; // MouseEvent.which value for the right button (assuming a right-handed mouse) + + var REGEXP_KEYDOWN = new RegExp("".concat(ARROW_UP_KEYCODE, "|").concat(ARROW_DOWN_KEYCODE, "|").concat(ESCAPE_KEYCODE)); + var Event = { + HIDE: "hide".concat(EVENT_KEY), + HIDDEN: "hidden".concat(EVENT_KEY), + SHOW: "show".concat(EVENT_KEY), + SHOWN: "shown".concat(EVENT_KEY), + CLICK: "click".concat(EVENT_KEY), + CLICK_DATA_API: "click".concat(EVENT_KEY).concat(DATA_API_KEY), + KEYDOWN_DATA_API: "keydown".concat(EVENT_KEY).concat(DATA_API_KEY), + KEYUP_DATA_API: "keyup".concat(EVENT_KEY).concat(DATA_API_KEY) + }; + var ClassName = { + DISABLED: 'disabled', + SHOW: 'show', + DROPUP: 'dropup', + DROPRIGHT: 'dropright', + DROPLEFT: 'dropleft', + MENURIGHT: 'dropdown-menu-right', + MENULEFT: 'dropdown-menu-left', + POSITION_STATIC: 'position-static' + }; + var Selector = { + DATA_TOGGLE: '[data-toggle="dropdown"]', + FORM_CHILD: '.dropdown form', + MENU: '.dropdown-menu', + NAVBAR_NAV: '.navbar-nav', + VISIBLE_ITEMS: '.dropdown-menu .dropdown-item:not(.disabled)' + }; + var AttachmentMap = { + TOP: 'top-start', + TOPEND: 'top-end', + BOTTOM: 'bottom-start', + BOTTOMEND: 'bottom-end', + RIGHT: 'right-start', + RIGHTEND: 'right-end', + LEFT: 'left-start', + LEFTEND: 'left-end' + }; + var Default = { + offset: 0, + flip: false, + boundary: 'scrollParent' + }; + var DefaultType = { + offset: '(number|string|function)', + flip: 'boolean', + boundary: '(string|element)' + /** + * ------------------------------------------------------------------------ + * Class Definition + * ------------------------------------------------------------------------ + */ + + }; + + var Dropdown = function () { + function Dropdown(element, config) { + _classCallCheck(this, Dropdown); + + this._element = element; + this._popper = null; + this._config = this._getConfig(config); + this._menu = this._getMenuElement(); + this._inNavbar = this._detectNavbar(); + + this._addEventListeners(); + } // Getters + + + _createClass(Dropdown, [{ + key: "toggle", + value: function toggle() { + if (this._element.disabled || $(this._element).hasClass(ClassName.DISABLED)) { + return; + } + + var parent = Dropdown._getParentFromElement(this._element); + + var isActive = $(this._menu).hasClass(ClassName.SHOW); + + Dropdown._clearMenus(); + + if (isActive) { + return; + } + + var relatedTarget = { + relatedTarget: this._element + }; + var showEvent = $.Event(Event.SHOW, relatedTarget); + $(parent).trigger(showEvent); + + if (showEvent.isDefaultPrevented()) { + return; + } // Disable totally Popper.js for Dropdown in Navbar + + + if (!this._inNavbar) { + /** + * Check for Popper dependency + * Popper - https://popper.js.org + */ + if (typeof _popper2.default === 'undefined') { + throw new TypeError('Bootstrap dropdown require Popper.js (https://popper.js.org)'); + } + + var element = this._element; // For dropup with alignment we use the parent as popper container + + if ($(parent).hasClass(ClassName.DROPUP)) { + if ($(this._menu).hasClass(ClassName.MENULEFT) || $(this._menu).hasClass(ClassName.MENURIGHT)) { + element = parent; + } + } // If boundary is not `scrollParent`, then set position to `static` + // to allow the menu to "escape" the scroll parent's boundaries + // https://github.com/twbs/bootstrap/issues/24251 + + + if (this._config.boundary !== 'scrollParent') { + $(parent).addClass(ClassName.POSITION_STATIC); + } + + this._popper = new _popper2.default(element, this._menu, this._getPopperConfig()); + } // If this is a touch-enabled device we add extra + // empty mouseover listeners to the body's immediate children; + // only needed because of broken event delegation on iOS + // https://www.quirksmode.org/blog/archives/2014/02/mouse_event_bub.html + + + if ('ontouchstart' in document.documentElement && $(parent).closest(Selector.NAVBAR_NAV).length === 0) { + $('body').children().on('mouseover', null, $.noop); + } + + this._element.focus(); + + this._element.setAttribute('aria-expanded', true); + + $(this._menu).toggleClass(ClassName.SHOW); + $(parent).toggleClass(ClassName.SHOW).trigger($.Event(Event.SHOWN, relatedTarget)); + } + }, { + key: "dispose", + value: function dispose() { + $.removeData(this._element, DATA_KEY); + $(this._element).off(EVENT_KEY); + this._element = null; + this._menu = null; + + if (this._popper !== null) { + this._popper.destroy(); + + this._popper = null; + } + } + }, { + key: "update", + value: function update() { + this._inNavbar = this._detectNavbar(); + + if (this._popper !== null) { + this._popper.scheduleUpdate(); + } + } + }, { + key: "_addEventListeners", + value: function _addEventListeners() { + var _this = this; + + $(this._element).on(Event.CLICK, function (event) { + event.preventDefault(); + event.stopPropagation(); + + _this.toggle(); + }); + } + }, { + key: "_getConfig", + value: function _getConfig(config) { + config = _extends({}, this.constructor.Default, $(this._element).data(), config); + + _util2.default.typeCheckConfig(NAME, config, this.constructor.DefaultType); + + return config; + } + }, { + key: "_getMenuElement", + value: function _getMenuElement() { + if (!this._menu) { + var parent = Dropdown._getParentFromElement(this._element); + + this._menu = $(parent).find(Selector.MENU)[0]; + } + + return this._menu; + } + }, { + key: "_getPlacement", + value: function _getPlacement() { + var $parentDropdown = $(this._element).parent(); + var placement = AttachmentMap.BOTTOM; // Handle dropup + + if ($parentDropdown.hasClass(ClassName.DROPUP)) { + placement = AttachmentMap.TOP; + + if ($(this._menu).hasClass(ClassName.MENURIGHT)) { + placement = AttachmentMap.TOPEND; + } + } else if ($parentDropdown.hasClass(ClassName.DROPRIGHT)) { + placement = AttachmentMap.RIGHT; + } else if ($parentDropdown.hasClass(ClassName.DROPLEFT)) { + placement = AttachmentMap.LEFT; + } else if ($(this._menu).hasClass(ClassName.MENURIGHT)) { + placement = AttachmentMap.BOTTOMEND; + } + + return placement; + } + }, { + key: "_detectNavbar", + value: function _detectNavbar() { + return $(this._element).closest('.navbar').length > 0; + } + }, { + key: "_getPopperConfig", + value: function _getPopperConfig() { + var _this2 = this; + + var offsetConf = {}; + + if (typeof this._config.offset === 'function') { + offsetConf.fn = function (data) { + data.offsets = _extends({}, data.offsets, _this2._config.offset(data.offsets) || {}); + return data; + }; + } else { + offsetConf.offset = this._config.offset; + } + + var popperConfig = { + placement: this._getPlacement(), + modifiers: { + offset: offsetConf, + flip: { + enabled: this._config.flip + }, + preventOverflow: { + boundariesElement: this._config.boundary + } + } + }; + return popperConfig; + } + }], [{ + key: "_jQueryInterface", + value: function _jQueryInterface(config) { + return this.each(function () { + var data = $(this).data(DATA_KEY); + + var _config = _typeof(config) === 'object' ? config : null; + + if (!data) { + data = new Dropdown(this, _config); + $(this).data(DATA_KEY, data); + } + + if (typeof config === 'string') { + if (typeof data[config] === 'undefined') { + throw new TypeError("No method named \"".concat(config, "\"")); + } + + data[config](); + } + }); + } + }, { + key: "_clearMenus", + value: function _clearMenus(event) { + if (event && (event.which === RIGHT_MOUSE_BUTTON_WHICH || event.type === 'keyup' && event.which !== TAB_KEYCODE)) { + return; + } + + var toggles = $.makeArray($(Selector.DATA_TOGGLE)); + + for (var i = 0; i < toggles.length; i++) { + var parent = Dropdown._getParentFromElement(toggles[i]); + + var context = $(toggles[i]).data(DATA_KEY); + var relatedTarget = { + relatedTarget: toggles[i] + }; + + if (!context) { + continue; + } + + var dropdownMenu = context._menu; + + if (!$(parent).hasClass(ClassName.SHOW)) { + continue; + } + + if (event && (event.type === 'click' && /input|textarea/i.test(event.target.tagName) || event.type === 'keyup' && event.which === TAB_KEYCODE) && $.contains(parent, event.target)) { + continue; + } + + var hideEvent = $.Event(Event.HIDE, relatedTarget); + $(parent).trigger(hideEvent); + + if (hideEvent.isDefaultPrevented()) { + continue; + } // If this is a touch-enabled device we remove the extra + // empty mouseover listeners we added for iOS support + + + if ('ontouchstart' in document.documentElement) { + $('body').children().off('mouseover', null, $.noop); + } + + toggles[i].setAttribute('aria-expanded', 'false'); + $(dropdownMenu).removeClass(ClassName.SHOW); + $(parent).removeClass(ClassName.SHOW).trigger($.Event(Event.HIDDEN, relatedTarget)); + } + } + }, { + key: "_getParentFromElement", + value: function _getParentFromElement(element) { + var parent; + + var selector = _util2.default.getSelectorFromElement(element); + + if (selector) { + parent = $(selector)[0]; + } + + return parent || element.parentNode; + } + }, { + key: "_dataApiKeydownHandler", + value: function _dataApiKeydownHandler(event) { + // If not input/textarea: + // - And not a key in REGEXP_KEYDOWN => not a dropdown command + // If input/textarea: + // - If space key => not a dropdown command + // - If key is other than escape + // - If key is not up or down => not a dropdown command + // - If trigger inside the menu => not a dropdown command + if (/input|textarea/i.test(event.target.tagName) ? event.which === SPACE_KEYCODE || event.which !== ESCAPE_KEYCODE && (event.which !== ARROW_DOWN_KEYCODE && event.which !== ARROW_UP_KEYCODE || $(event.target).closest(Selector.MENU).length) : !REGEXP_KEYDOWN.test(event.which)) { + return; + } + + event.preventDefault(); + event.stopPropagation(); + + if (this.disabled || $(this).hasClass(ClassName.DISABLED)) { + return; + } + + var parent = Dropdown._getParentFromElement(this); + + var isActive = $(parent).hasClass(ClassName.SHOW); + + if (!isActive && (event.which !== ESCAPE_KEYCODE || event.which !== SPACE_KEYCODE) || isActive && (event.which === ESCAPE_KEYCODE || event.which === SPACE_KEYCODE)) { + if (event.which === ESCAPE_KEYCODE) { + var toggle = $(parent).find(Selector.DATA_TOGGLE)[0]; + $(toggle).trigger('focus'); + } + + $(this).trigger('click'); + return; + } + + var items = $(parent).find(Selector.VISIBLE_ITEMS).get(); + + if (items.length === 0) { + return; + } + + var index = items.indexOf(event.target); + + if (event.which === ARROW_UP_KEYCODE && index > 0) { + // Up + index--; + } + + if (event.which === ARROW_DOWN_KEYCODE && index < items.length - 1) { + // Down + index++; + } + + if (index < 0) { + index = 0; + } + + items[index].focus(); + } + }, { + key: "VERSION", + get: function get() { + return VERSION; + } + }, { + key: "Default", + get: function get() { + return Default; + } + }, { + key: "DefaultType", + get: function get() { + return DefaultType; + } + }]); + + return Dropdown; + }(); + + /** + * ------------------------------------------------------------------------ + * Data Api implementation + * ------------------------------------------------------------------------ + */ + $(document).on(Event.KEYDOWN_DATA_API, Selector.DATA_TOGGLE, Dropdown._dataApiKeydownHandler).on(Event.KEYDOWN_DATA_API, Selector.MENU, Dropdown._dataApiKeydownHandler).on("".concat(Event.CLICK_DATA_API, " ").concat(Event.KEYUP_DATA_API), Dropdown._clearMenus).on(Event.CLICK_DATA_API, Selector.DATA_TOGGLE, function (event) { + event.preventDefault(); + event.stopPropagation(); + + Dropdown._jQueryInterface.call($(this), 'toggle'); + }).on(Event.CLICK_DATA_API, Selector.FORM_CHILD, function (e) { + e.stopPropagation(); + }); + /** + * ------------------------------------------------------------------------ + * jQuery + * ------------------------------------------------------------------------ + */ + + $.fn[NAME] = Dropdown._jQueryInterface; + $.fn[NAME].Constructor = Dropdown; + + $.fn[NAME].noConflict = function () { + $.fn[NAME] = JQUERY_NO_CONFLICT; + return Dropdown._jQueryInterface; + }; + + return Dropdown; + }(_jquery2.default, _popper2.default); + + exports.default = Dropdown; +}); \ No newline at end of file diff --git a/amd/src/form-display-errors.js b/amd/src/form-display-errors.js new file mode 100644 index 0000000..86afd60 --- /dev/null +++ b/amd/src/form-display-errors.js @@ -0,0 +1,65 @@ +// This file is part of Moodle - http://moodle.org/ +// +// Moodle is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// Moodle is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with Moodle. If not, see . + +/** + * Custom form error event handler to manipulate the bootstrap markup and show + * nicely styled errors in an mform. + * + * @module theme_ilb/form-display-errors + * @copyright 2016 Damyon Wiese + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ +define(['jquery', 'core/event'], function($, Event) { + return { + enhance: function(elementid) { + var element = document.getElementById(elementid); + $(element).on(Event.Events.FORM_FIELD_VALIDATION, function(event, msg) { + event.preventDefault(); + var parent = $(element).closest('.form-group'); + var feedback = parent.find('.form-control-feedback'); + + // Sometimes (atto) we have a hidden textarea backed by a real contenteditable div. + if (($(element).prop("tagName") == 'TEXTAREA') && parent.find('[contenteditable]')) { + element = parent.find('[contenteditable]'); + } + if (msg !== '') { + parent.addClass('has-danger'); + parent.data('client-validation-error', true); + $(element).addClass('is-invalid'); + $(element).attr('aria-describedby', feedback.attr('id')); + $(element).attr('aria-invalid', true); + feedback.attr('tabindex', 0); + feedback.html(msg); + + // Only display and focus when the error was not already visible. + if (!feedback.is(':visible')) { + feedback.show(); + feedback.focus(); + } + + } else { + if (parent.data('client-validation-error') === true) { + parent.removeClass('has-danger'); + parent.data('client-validation-error', false); + $(element).removeClass('is-invalid'); + $(element).removeAttr('aria-describedby'); + $(element).attr('aria-invalid', false); + feedback.hide(); + } + } + }); + } + }; +}); diff --git a/amd/src/loader.js b/amd/src/loader.js new file mode 100644 index 0000000..0782f38 --- /dev/null +++ b/amd/src/loader.js @@ -0,0 +1,76 @@ +// This file is part of Moodle - http://moodle.org/ +// +// Moodle is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// Moodle is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with Moodle. If not, see . + +/** + * Template renderer for Moodle. Load and render Moodle templates with Mustache. + * + * @module core/templates + * @package core + * @class templates + * @copyright 2015 Damyon Wiese + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + * @since 2.9 + */ +define(['jquery', './tether', 'core/event'], function(jQuery, Tether, Event) { + + window.jQuery = jQuery; + window.Tether = Tether; + + require(['theme_ilb/aria', + 'theme_ilb/util', + 'theme_ilb/alert', + 'theme_ilb/button', + 'theme_ilb/carousel', + 'theme_ilb/collapse', + 'theme_ilb/dropdown', + 'theme_ilb/modal', + 'theme_ilb/scrollspy', + 'theme_ilb/tab', + 'theme_ilb/tooltip', + 'theme_ilb/popover'], + function(Aria) { + + // We do twice because: https://github.com/twbs/bootstrap/issues/10547 + jQuery('body').popover({ + trigger: 'focus', + selector: "[data-toggle=popover][data-trigger!=hover]" + }); + + jQuery("html").popover({ + container: "body", + selector: "[data-toggle=popover][data-trigger=hover]", + trigger: "hover", + delay: { + hide: 500 + } + }); + + // We need to call popover automatically if nodes are added to the page later. + Event.getLegacyEvents().done(function(events) { + jQuery(document).on(events.FILTER_CONTENT_UPDATED, function() { + jQuery('body').popover({ + selector: '[data-toggle="popover"]', + trigger: 'focus' + }); + + }); + }); + + Aria.init(); + }); + + + return {}; +}); diff --git a/amd/src/modal.js b/amd/src/modal.js new file mode 100644 index 0000000..e173538 --- /dev/null +++ b/amd/src/modal.js @@ -0,0 +1,662 @@ +define(["exports", "jquery", "./util"], function (exports, _jquery, _util) { + "use strict"; + + Object.defineProperty(exports, "__esModule", { + value: true + }); + + var _jquery2 = _interopRequireDefault(_jquery); + + var _util2 = _interopRequireDefault(_util); + + function _interopRequireDefault(obj) { + return obj && obj.__esModule ? obj : { + default: obj + }; + } + + function _typeof(obj) { + if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { + _typeof = function _typeof(obj) { + return typeof obj; + }; + } else { + _typeof = function _typeof(obj) { + return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; + }; + } + + return _typeof(obj); + } + + function _extends() { + _extends = Object.assign || function (target) { + for (var i = 1; i < arguments.length; i++) { + var source = arguments[i]; + + for (var key in source) { + if (Object.prototype.hasOwnProperty.call(source, key)) { + target[key] = source[key]; + } + } + } + + return target; + }; + + return _extends.apply(this, arguments); + } + + function _classCallCheck(instance, Constructor) { + if (!(instance instanceof Constructor)) { + throw new TypeError("Cannot call a class as a function"); + } + } + + function _defineProperties(target, props) { + for (var i = 0; i < props.length; i++) { + var descriptor = props[i]; + descriptor.enumerable = descriptor.enumerable || false; + descriptor.configurable = true; + if ("value" in descriptor) descriptor.writable = true; + Object.defineProperty(target, descriptor.key, descriptor); + } + } + + function _createClass(Constructor, protoProps, staticProps) { + if (protoProps) _defineProperties(Constructor.prototype, protoProps); + if (staticProps) _defineProperties(Constructor, staticProps); + return Constructor; + } + + /** + * -------------------------------------------------------------------------- + * Bootstrap (v4.0.0): modal.js + * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE) + * -------------------------------------------------------------------------- + */ + var Modal = function ($) { + /** + * ------------------------------------------------------------------------ + * Constants + * ------------------------------------------------------------------------ + */ + var NAME = 'modal'; + var VERSION = '4.0.0'; + var DATA_KEY = 'bs.modal'; + var EVENT_KEY = ".".concat(DATA_KEY); + var DATA_API_KEY = '.data-api'; + var JQUERY_NO_CONFLICT = $.fn[NAME]; + var TRANSITION_DURATION = 300; + var BACKDROP_TRANSITION_DURATION = 150; + var ESCAPE_KEYCODE = 27; // KeyboardEvent.which value for Escape (Esc) key + + var Default = { + backdrop: true, + keyboard: true, + focus: true, + show: true + }; + var DefaultType = { + backdrop: '(boolean|string)', + keyboard: 'boolean', + focus: 'boolean', + show: 'boolean' + }; + var Event = { + HIDE: "hide".concat(EVENT_KEY), + HIDDEN: "hidden".concat(EVENT_KEY), + SHOW: "show".concat(EVENT_KEY), + SHOWN: "shown".concat(EVENT_KEY), + FOCUSIN: "focusin".concat(EVENT_KEY), + RESIZE: "resize".concat(EVENT_KEY), + CLICK_DISMISS: "click.dismiss".concat(EVENT_KEY), + KEYDOWN_DISMISS: "keydown.dismiss".concat(EVENT_KEY), + MOUSEUP_DISMISS: "mouseup.dismiss".concat(EVENT_KEY), + MOUSEDOWN_DISMISS: "mousedown.dismiss".concat(EVENT_KEY), + CLICK_DATA_API: "click".concat(EVENT_KEY).concat(DATA_API_KEY) + }; + var ClassName = { + SCROLLBAR_MEASURER: 'modal-scrollbar-measure', + BACKDROP: 'modal-backdrop', + OPEN: 'modal-open', + FADE: 'fade', + SHOW: 'show' + }; + var Selector = { + DIALOG: '.modal-dialog', + DATA_TOGGLE: '[data-toggle="modal"]', + DATA_DISMISS: '[data-dismiss="modal"]', + FIXED_CONTENT: '.fixed-top, .fixed-bottom, .is-fixed, .sticky-top', + STICKY_CONTENT: '.sticky-top', + NAVBAR_TOGGLER: '.navbar-toggler' + /** + * ------------------------------------------------------------------------ + * Class Definition + * ------------------------------------------------------------------------ + */ + + }; + + var Modal = function () { + function Modal(element, config) { + _classCallCheck(this, Modal); + + this._config = this._getConfig(config); + this._element = element; + this._dialog = $(element).find(Selector.DIALOG)[0]; + this._backdrop = null; + this._isShown = false; + this._isBodyOverflowing = false; + this._ignoreBackdropClick = false; + this._originalBodyPadding = 0; + this._scrollbarWidth = 0; + } // Getters + + + _createClass(Modal, [{ + key: "toggle", + value: function toggle(relatedTarget) { + return this._isShown ? this.hide() : this.show(relatedTarget); + } + }, { + key: "show", + value: function show(relatedTarget) { + var _this = this; + + if (this._isTransitioning || this._isShown) { + return; + } + + if (_util2.default.supportsTransitionEnd() && $(this._element).hasClass(ClassName.FADE)) { + this._isTransitioning = true; + } + + var showEvent = $.Event(Event.SHOW, { + relatedTarget: relatedTarget + }); + $(this._element).trigger(showEvent); + + if (this._isShown || showEvent.isDefaultPrevented()) { + return; + } + + this._isShown = true; + + this._checkScrollbar(); + + this._setScrollbar(); + + this._adjustDialog(); + + $(document.body).addClass(ClassName.OPEN); + + this._setEscapeEvent(); + + this._setResizeEvent(); + + $(this._element).on(Event.CLICK_DISMISS, Selector.DATA_DISMISS, function (event) { + return _this.hide(event); + }); + $(this._dialog).on(Event.MOUSEDOWN_DISMISS, function () { + $(_this._element).one(Event.MOUSEUP_DISMISS, function (event) { + if ($(event.target).is(_this._element)) { + _this._ignoreBackdropClick = true; + } + }); + }); + + this._showBackdrop(function () { + return _this._showElement(relatedTarget); + }); + } + }, { + key: "hide", + value: function hide(event) { + var _this2 = this; + + if (event) { + event.preventDefault(); + } + + if (this._isTransitioning || !this._isShown) { + return; + } + + var hideEvent = $.Event(Event.HIDE); + $(this._element).trigger(hideEvent); + + if (!this._isShown || hideEvent.isDefaultPrevented()) { + return; + } + + this._isShown = false; + var transition = _util2.default.supportsTransitionEnd() && $(this._element).hasClass(ClassName.FADE); + + if (transition) { + this._isTransitioning = true; + } + + this._setEscapeEvent(); + + this._setResizeEvent(); + + $(document).off(Event.FOCUSIN); + $(this._element).removeClass(ClassName.SHOW); + $(this._element).off(Event.CLICK_DISMISS); + $(this._dialog).off(Event.MOUSEDOWN_DISMISS); + + if (transition) { + $(this._element).one(_util2.default.TRANSITION_END, function (event) { + return _this2._hideModal(event); + }).emulateTransitionEnd(TRANSITION_DURATION); + } else { + this._hideModal(); + } + } + }, { + key: "dispose", + value: function dispose() { + $.removeData(this._element, DATA_KEY); + $(window, document, this._element, this._backdrop).off(EVENT_KEY); + this._config = null; + this._element = null; + this._dialog = null; + this._backdrop = null; + this._isShown = null; + this._isBodyOverflowing = null; + this._ignoreBackdropClick = null; + this._scrollbarWidth = null; + } + }, { + key: "handleUpdate", + value: function handleUpdate() { + this._adjustDialog(); + } + }, { + key: "_getConfig", + value: function _getConfig(config) { + config = _extends({}, Default, config); + + _util2.default.typeCheckConfig(NAME, config, DefaultType); + + return config; + } + }, { + key: "_showElement", + value: function _showElement(relatedTarget) { + var _this3 = this; + + var transition = _util2.default.supportsTransitionEnd() && $(this._element).hasClass(ClassName.FADE); + + if (!this._element.parentNode || this._element.parentNode.nodeType !== Node.ELEMENT_NODE) { + // Don't move modal's DOM position + document.body.appendChild(this._element); + } + + this._element.style.display = 'block'; + + this._element.removeAttribute('aria-hidden'); + + this._element.scrollTop = 0; + + if (transition) { + _util2.default.reflow(this._element); + } + + $(this._element).addClass(ClassName.SHOW); + + if (this._config.focus) { + this._enforceFocus(); + } + + var shownEvent = $.Event(Event.SHOWN, { + relatedTarget: relatedTarget + }); + + var transitionComplete = function transitionComplete() { + if (_this3._config.focus) { + _this3._element.focus(); + } + + _this3._isTransitioning = false; + $(_this3._element).trigger(shownEvent); + }; + + if (transition) { + $(this._dialog).one(_util2.default.TRANSITION_END, transitionComplete).emulateTransitionEnd(TRANSITION_DURATION); + } else { + transitionComplete(); + } + } + }, { + key: "_enforceFocus", + value: function _enforceFocus() { + var _this4 = this; + + $(document).off(Event.FOCUSIN) // Guard against infinite focus loop + .on(Event.FOCUSIN, function (event) { + if (document !== event.target && _this4._element !== event.target && $(_this4._element).has(event.target).length === 0) { + _this4._element.focus(); + } + }); + } + }, { + key: "_setEscapeEvent", + value: function _setEscapeEvent() { + var _this5 = this; + + if (this._isShown && this._config.keyboard) { + $(this._element).on(Event.KEYDOWN_DISMISS, function (event) { + if (event.which === ESCAPE_KEYCODE) { + event.preventDefault(); + + _this5.hide(); + } + }); + } else if (!this._isShown) { + $(this._element).off(Event.KEYDOWN_DISMISS); + } + } + }, { + key: "_setResizeEvent", + value: function _setResizeEvent() { + var _this6 = this; + + if (this._isShown) { + $(window).on(Event.RESIZE, function (event) { + return _this6.handleUpdate(event); + }); + } else { + $(window).off(Event.RESIZE); + } + } + }, { + key: "_hideModal", + value: function _hideModal() { + var _this7 = this; + + this._element.style.display = 'none'; + + this._element.setAttribute('aria-hidden', true); + + this._isTransitioning = false; + + this._showBackdrop(function () { + $(document.body).removeClass(ClassName.OPEN); + + _this7._resetAdjustments(); + + _this7._resetScrollbar(); + + $(_this7._element).trigger(Event.HIDDEN); + }); + } + }, { + key: "_removeBackdrop", + value: function _removeBackdrop() { + if (this._backdrop) { + $(this._backdrop).remove(); + this._backdrop = null; + } + } + }, { + key: "_showBackdrop", + value: function _showBackdrop(callback) { + var _this8 = this; + + var animate = $(this._element).hasClass(ClassName.FADE) ? ClassName.FADE : ''; + + if (this._isShown && this._config.backdrop) { + var doAnimate = _util2.default.supportsTransitionEnd() && animate; + this._backdrop = document.createElement('div'); + this._backdrop.className = ClassName.BACKDROP; + + if (animate) { + $(this._backdrop).addClass(animate); + } + + $(this._backdrop).appendTo(document.body); + $(this._element).on(Event.CLICK_DISMISS, function (event) { + if (_this8._ignoreBackdropClick) { + _this8._ignoreBackdropClick = false; + return; + } + + if (event.target !== event.currentTarget) { + return; + } + + if (_this8._config.backdrop === 'static') { + _this8._element.focus(); + } else { + _this8.hide(); + } + }); + + if (doAnimate) { + _util2.default.reflow(this._backdrop); + } + + $(this._backdrop).addClass(ClassName.SHOW); + + if (!callback) { + return; + } + + if (!doAnimate) { + callback(); + return; + } + + $(this._backdrop).one(_util2.default.TRANSITION_END, callback).emulateTransitionEnd(BACKDROP_TRANSITION_DURATION); + } else if (!this._isShown && this._backdrop) { + $(this._backdrop).removeClass(ClassName.SHOW); + + var callbackRemove = function callbackRemove() { + _this8._removeBackdrop(); + + if (callback) { + callback(); + } + }; + + if (_util2.default.supportsTransitionEnd() && $(this._element).hasClass(ClassName.FADE)) { + $(this._backdrop).one(_util2.default.TRANSITION_END, callbackRemove).emulateTransitionEnd(BACKDROP_TRANSITION_DURATION); + } else { + callbackRemove(); + } + } else if (callback) { + callback(); + } + } + }, { + key: "_adjustDialog", + value: function _adjustDialog() { + var isModalOverflowing = this._element.scrollHeight > document.documentElement.clientHeight; + + if (!this._isBodyOverflowing && isModalOverflowing) { + this._element.style.paddingLeft = "".concat(this._scrollbarWidth, "px"); + } + + if (this._isBodyOverflowing && !isModalOverflowing) { + this._element.style.paddingRight = "".concat(this._scrollbarWidth, "px"); + } + } + }, { + key: "_resetAdjustments", + value: function _resetAdjustments() { + this._element.style.paddingLeft = ''; + this._element.style.paddingRight = ''; + } + }, { + key: "_checkScrollbar", + value: function _checkScrollbar() { + var rect = document.body.getBoundingClientRect(); + this._isBodyOverflowing = rect.left + rect.right < window.innerWidth; + this._scrollbarWidth = this._getScrollbarWidth(); + } + }, { + key: "_setScrollbar", + value: function _setScrollbar() { + var _this9 = this; + + if (this._isBodyOverflowing) { + // Note: DOMNode.style.paddingRight returns the actual value or '' if not set + // while $(DOMNode).css('padding-right') returns the calculated value or 0 if not set + // Adjust fixed content padding + $(Selector.FIXED_CONTENT).each(function (index, element) { + var actualPadding = $(element)[0].style.paddingRight; + var calculatedPadding = $(element).css('padding-right'); + $(element).data('padding-right', actualPadding).css('padding-right', "".concat(parseFloat(calculatedPadding) + _this9._scrollbarWidth, "px")); + }); // Adjust sticky content margin + + $(Selector.STICKY_CONTENT).each(function (index, element) { + var actualMargin = $(element)[0].style.marginRight; + var calculatedMargin = $(element).css('margin-right'); + $(element).data('margin-right', actualMargin).css('margin-right', "".concat(parseFloat(calculatedMargin) - _this9._scrollbarWidth, "px")); + }); // Adjust navbar-toggler margin + + $(Selector.NAVBAR_TOGGLER).each(function (index, element) { + var actualMargin = $(element)[0].style.marginRight; + var calculatedMargin = $(element).css('margin-right'); + $(element).data('margin-right', actualMargin).css('margin-right', "".concat(parseFloat(calculatedMargin) + _this9._scrollbarWidth, "px")); + }); // Adjust body padding + + var actualPadding = document.body.style.paddingRight; + var calculatedPadding = $('body').css('padding-right'); + $('body').data('padding-right', actualPadding).css('padding-right', "".concat(parseFloat(calculatedPadding) + this._scrollbarWidth, "px")); + } + } + }, { + key: "_resetScrollbar", + value: function _resetScrollbar() { + // Restore fixed content padding + $(Selector.FIXED_CONTENT).each(function (index, element) { + var padding = $(element).data('padding-right'); + + if (typeof padding !== 'undefined') { + $(element).css('padding-right', padding).removeData('padding-right'); + } + }); // Restore sticky content and navbar-toggler margin + + $("".concat(Selector.STICKY_CONTENT, ", ").concat(Selector.NAVBAR_TOGGLER)).each(function (index, element) { + var margin = $(element).data('margin-right'); + + if (typeof margin !== 'undefined') { + $(element).css('margin-right', margin).removeData('margin-right'); + } + }); // Restore body padding + + var padding = $('body').data('padding-right'); + + if (typeof padding !== 'undefined') { + $('body').css('padding-right', padding).removeData('padding-right'); + } + } + }, { + key: "_getScrollbarWidth", + value: function _getScrollbarWidth() { + // thx d.walsh + var scrollDiv = document.createElement('div'); + scrollDiv.className = ClassName.SCROLLBAR_MEASURER; + document.body.appendChild(scrollDiv); + var scrollbarWidth = scrollDiv.getBoundingClientRect().width - scrollDiv.clientWidth; + document.body.removeChild(scrollDiv); + return scrollbarWidth; + } + }], [{ + key: "_jQueryInterface", + value: function _jQueryInterface(config, relatedTarget) { + return this.each(function () { + var data = $(this).data(DATA_KEY); + + var _config = _extends({}, Modal.Default, $(this).data(), _typeof(config) === 'object' && config); + + if (!data) { + data = new Modal(this, _config); + $(this).data(DATA_KEY, data); + } + + if (typeof config === 'string') { + if (typeof data[config] === 'undefined') { + throw new TypeError("No method named \"".concat(config, "\"")); + } + + data[config](relatedTarget); + } else if (_config.show) { + data.show(relatedTarget); + } + }); + } + }, { + key: "VERSION", + get: function get() { + return VERSION; + } + }, { + key: "Default", + get: function get() { + return Default; + } + }]); + + return Modal; + }(); + + /** + * ------------------------------------------------------------------------ + * Data Api implementation + * ------------------------------------------------------------------------ + */ + $(document).on(Event.CLICK_DATA_API, Selector.DATA_TOGGLE, function (event) { + var _this10 = this; + + var target; + + var selector = _util2.default.getSelectorFromElement(this); + + if (selector) { + target = $(selector)[0]; + } + + var config = $(target).data(DATA_KEY) ? 'toggle' : _extends({}, $(target).data(), $(this).data()); + + if (this.tagName === 'A' || this.tagName === 'AREA') { + event.preventDefault(); + } + + var $target = $(target).one(Event.SHOW, function (showEvent) { + if (showEvent.isDefaultPrevented()) { + // Only register focus restorer if modal will actually get shown + return; + } + + $target.one(Event.HIDDEN, function () { + if ($(_this10).is(':visible')) { + _this10.focus(); + } + }); + }); + + Modal._jQueryInterface.call($(target), config, this); + }); + /** + * ------------------------------------------------------------------------ + * jQuery + * ------------------------------------------------------------------------ + */ + + $.fn[NAME] = Modal._jQueryInterface; + $.fn[NAME].Constructor = Modal; + + $.fn[NAME].noConflict = function () { + $.fn[NAME] = JQUERY_NO_CONFLICT; + return Modal._jQueryInterface; + }; + + return Modal; + }(_jquery2.default); + + exports.default = Modal; +}); \ No newline at end of file diff --git a/amd/src/popover.js b/amd/src/popover.js new file mode 100644 index 0000000..bc88d80 --- /dev/null +++ b/amd/src/popover.js @@ -0,0 +1,297 @@ +define(["exports", "jquery", "./tooltip"], function (exports, _jquery, _tooltip) { + "use strict"; + + Object.defineProperty(exports, "__esModule", { + value: true + }); + + var _jquery2 = _interopRequireDefault(_jquery); + + var _tooltip2 = _interopRequireDefault(_tooltip); + + function _interopRequireDefault(obj) { + return obj && obj.__esModule ? obj : { + default: obj + }; + } + + function _typeof(obj) { + if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { + _typeof = function _typeof(obj) { + return typeof obj; + }; + } else { + _typeof = function _typeof(obj) { + return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; + }; + } + + return _typeof(obj); + } + + function _classCallCheck(instance, Constructor) { + if (!(instance instanceof Constructor)) { + throw new TypeError("Cannot call a class as a function"); + } + } + + function _defineProperties(target, props) { + for (var i = 0; i < props.length; i++) { + var descriptor = props[i]; + descriptor.enumerable = descriptor.enumerable || false; + descriptor.configurable = true; + if ("value" in descriptor) descriptor.writable = true; + Object.defineProperty(target, descriptor.key, descriptor); + } + } + + function _createClass(Constructor, protoProps, staticProps) { + if (protoProps) _defineProperties(Constructor.prototype, protoProps); + if (staticProps) _defineProperties(Constructor, staticProps); + return Constructor; + } + + function _possibleConstructorReturn(self, call) { + if (call && (_typeof(call) === "object" || typeof call === "function")) { + return call; + } + + if (self === void 0) { + throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); + } + + return self; + } + + function _inherits(subClass, superClass) { + if (typeof superClass !== "function" && superClass !== null) { + throw new TypeError("Super expression must either be null or a function"); + } + + subClass.prototype = Object.create(superClass && superClass.prototype, { + constructor: { + value: subClass, + enumerable: false, + writable: true, + configurable: true + } + }); + if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; + } + + function _extends() { + _extends = Object.assign || function (target) { + for (var i = 1; i < arguments.length; i++) { + var source = arguments[i]; + + for (var key in source) { + if (Object.prototype.hasOwnProperty.call(source, key)) { + target[key] = source[key]; + } + } + } + + return target; + }; + + return _extends.apply(this, arguments); + } + + /** + * -------------------------------------------------------------------------- + * Bootstrap (v4.0.0): popover.js + * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE) + * -------------------------------------------------------------------------- + */ + var Popover = function ($) { + /** + * ------------------------------------------------------------------------ + * Constants + * ------------------------------------------------------------------------ + */ + var NAME = 'popover'; + var VERSION = '4.0.0'; + var DATA_KEY = 'bs.popover'; + var EVENT_KEY = ".".concat(DATA_KEY); + var JQUERY_NO_CONFLICT = $.fn[NAME]; + var CLASS_PREFIX = 'bs-popover'; + var BSCLS_PREFIX_REGEX = new RegExp("(^|\\s)".concat(CLASS_PREFIX, "\\S+"), 'g'); + + var Default = _extends({}, _tooltip2.default.Default, { + placement: 'right', + trigger: 'click', + content: '', + template: '' + }); + + var DefaultType = _extends({}, _tooltip2.default.DefaultType, { + content: '(string|element|function)' + }); + + var ClassName = { + FADE: 'fade', + SHOW: 'show' + }; + var Selector = { + TITLE: '.popover-header', + CONTENT: '.popover-body' + }; + var Event = { + HIDE: "hide".concat(EVENT_KEY), + HIDDEN: "hidden".concat(EVENT_KEY), + SHOW: "show".concat(EVENT_KEY), + SHOWN: "shown".concat(EVENT_KEY), + INSERTED: "inserted".concat(EVENT_KEY), + CLICK: "click".concat(EVENT_KEY), + FOCUSIN: "focusin".concat(EVENT_KEY), + FOCUSOUT: "focusout".concat(EVENT_KEY), + MOUSEENTER: "mouseenter".concat(EVENT_KEY), + MOUSELEAVE: "mouseleave".concat(EVENT_KEY) + /** + * ------------------------------------------------------------------------ + * Class Definition + * ------------------------------------------------------------------------ + */ + + }; + + var Popover = function (_Tooltip) { + _inherits(Popover, _Tooltip); + + function Popover() { + _classCallCheck(this, Popover); + + return _possibleConstructorReturn(this, (Popover.__proto__ || Object.getPrototypeOf(Popover)).apply(this, arguments)); + } + + _createClass(Popover, [{ + key: "isWithContent", + value: function isWithContent() { + return this.getTitle() || this._getContent(); + } + }, { + key: "addAttachmentClass", + value: function addAttachmentClass(attachment) { + $(this.getTipElement()).addClass("".concat(CLASS_PREFIX, "-").concat(attachment)); + } + }, { + key: "getTipElement", + value: function getTipElement() { + this.tip = this.tip || $(this.config.template)[0]; + return this.tip; + } + }, { + key: "setContent", + value: function setContent() { + var $tip = $(this.getTipElement()); // We use append for html objects to maintain js events + + this.setElementContent($tip.find(Selector.TITLE), this.getTitle()); + + var content = this._getContent(); + + if (typeof content === 'function') { + content = content.call(this.element); + } + + this.setElementContent($tip.find(Selector.CONTENT), content); + $tip.removeClass("".concat(ClassName.FADE, " ").concat(ClassName.SHOW)); + } + }, { + key: "_getContent", + value: function _getContent() { + return this.element.getAttribute('data-content') || this.config.content; + } + }, { + key: "_cleanTipClass", + value: function _cleanTipClass() { + var $tip = $(this.getTipElement()); + var tabClass = $tip.attr('class').match(BSCLS_PREFIX_REGEX); + + if (tabClass !== null && tabClass.length > 0) { + $tip.removeClass(tabClass.join('')); + } + } + }], [{ + key: "_jQueryInterface", + value: function _jQueryInterface(config) { + return this.each(function () { + var data = $(this).data(DATA_KEY); + + var _config = _typeof(config) === 'object' ? config : null; + + if (!data && /destroy|hide/.test(config)) { + return; + } + + if (!data) { + data = new Popover(this, _config); + $(this).data(DATA_KEY, data); + } + + if (typeof config === 'string') { + if (typeof data[config] === 'undefined') { + throw new TypeError("No method named \"".concat(config, "\"")); + } + + data[config](); + } + }); + } + }, { + key: "VERSION", + get: function get() { + return VERSION; + } + }, { + key: "Default", + get: function get() { + return Default; + } + }, { + key: "NAME", + get: function get() { + return NAME; + } + }, { + key: "DATA_KEY", + get: function get() { + return DATA_KEY; + } + }, { + key: "Event", + get: function get() { + return Event; + } + }, { + key: "EVENT_KEY", + get: function get() { + return EVENT_KEY; + } + }, { + key: "DefaultType", + get: function get() { + return DefaultType; + } + }]); + + return Popover; + }(_tooltip2.default); + + /** + * ------------------------------------------------------------------------ + * jQuery + * ------------------------------------------------------------------------ + */ + $.fn[NAME] = Popover._jQueryInterface; + $.fn[NAME].Constructor = Popover; + + $.fn[NAME].noConflict = function () { + $.fn[NAME] = JQUERY_NO_CONFLICT; + return Popover._jQueryInterface; + }; + + return Popover; + }(_jquery2.default); + + exports.default = Popover; +}); \ No newline at end of file diff --git a/amd/src/scrollspy.js b/amd/src/scrollspy.js new file mode 100644 index 0000000..dc6f96e --- /dev/null +++ b/amd/src/scrollspy.js @@ -0,0 +1,390 @@ +define(["exports", "jquery", "./util"], function (exports, _jquery, _util) { + "use strict"; + + Object.defineProperty(exports, "__esModule", { + value: true + }); + + var _jquery2 = _interopRequireDefault(_jquery); + + var _util2 = _interopRequireDefault(_util); + + function _interopRequireDefault(obj) { + return obj && obj.__esModule ? obj : { + default: obj + }; + } + + function _typeof(obj) { + if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { + _typeof = function _typeof(obj) { + return typeof obj; + }; + } else { + _typeof = function _typeof(obj) { + return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; + }; + } + + return _typeof(obj); + } + + function _extends() { + _extends = Object.assign || function (target) { + for (var i = 1; i < arguments.length; i++) { + var source = arguments[i]; + + for (var key in source) { + if (Object.prototype.hasOwnProperty.call(source, key)) { + target[key] = source[key]; + } + } + } + + return target; + }; + + return _extends.apply(this, arguments); + } + + function _classCallCheck(instance, Constructor) { + if (!(instance instanceof Constructor)) { + throw new TypeError("Cannot call a class as a function"); + } + } + + function _defineProperties(target, props) { + for (var i = 0; i < props.length; i++) { + var descriptor = props[i]; + descriptor.enumerable = descriptor.enumerable || false; + descriptor.configurable = true; + if ("value" in descriptor) descriptor.writable = true; + Object.defineProperty(target, descriptor.key, descriptor); + } + } + + function _createClass(Constructor, protoProps, staticProps) { + if (protoProps) _defineProperties(Constructor.prototype, protoProps); + if (staticProps) _defineProperties(Constructor, staticProps); + return Constructor; + } + + /** + * -------------------------------------------------------------------------- + * Bootstrap (v4.0.0): scrollspy.js + * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE) + * -------------------------------------------------------------------------- + */ + var ScrollSpy = function ($) { + /** + * ------------------------------------------------------------------------ + * Constants + * ------------------------------------------------------------------------ + */ + var NAME = 'scrollspy'; + var VERSION = '4.0.0'; + var DATA_KEY = 'bs.scrollspy'; + var EVENT_KEY = ".".concat(DATA_KEY); + var DATA_API_KEY = '.data-api'; + var JQUERY_NO_CONFLICT = $.fn[NAME]; + var Default = { + offset: 10, + method: 'auto', + target: '' + }; + var DefaultType = { + offset: 'number', + method: 'string', + target: '(string|element)' + }; + var Event = { + ACTIVATE: "activate".concat(EVENT_KEY), + SCROLL: "scroll".concat(EVENT_KEY), + LOAD_DATA_API: "load".concat(EVENT_KEY).concat(DATA_API_KEY) + }; + var ClassName = { + DROPDOWN_ITEM: 'dropdown-item', + DROPDOWN_MENU: 'dropdown-menu', + ACTIVE: 'active' + }; + var Selector = { + DATA_SPY: '[data-spy="scroll"]', + ACTIVE: '.active', + NAV_LIST_GROUP: '.nav, .list-group', + NAV_LINKS: '.nav-link', + NAV_ITEMS: '.nav-item', + LIST_ITEMS: '.list-group-item', + DROPDOWN: '.dropdown', + DROPDOWN_ITEMS: '.dropdown-item', + DROPDOWN_TOGGLE: '.dropdown-toggle' + }; + var OffsetMethod = { + OFFSET: 'offset', + POSITION: 'position' + /** + * ------------------------------------------------------------------------ + * Class Definition + * ------------------------------------------------------------------------ + */ + + }; + + var ScrollSpy = function () { + function ScrollSpy(element, config) { + var _this = this; + + _classCallCheck(this, ScrollSpy); + + this._element = element; + this._scrollElement = element.tagName === 'BODY' ? window : element; + this._config = this._getConfig(config); + this._selector = "".concat(this._config.target, " ").concat(Selector.NAV_LINKS, ",") + "".concat(this._config.target, " ").concat(Selector.LIST_ITEMS, ",") + "".concat(this._config.target, " ").concat(Selector.DROPDOWN_ITEMS); + this._offsets = []; + this._targets = []; + this._activeTarget = null; + this._scrollHeight = 0; + $(this._scrollElement).on(Event.SCROLL, function (event) { + return _this._process(event); + }); + this.refresh(); + + this._process(); + } // Getters + + + _createClass(ScrollSpy, [{ + key: "refresh", + value: function refresh() { + var _this2 = this; + + var autoMethod = this._scrollElement === this._scrollElement.window ? OffsetMethod.OFFSET : OffsetMethod.POSITION; + var offsetMethod = this._config.method === 'auto' ? autoMethod : this._config.method; + var offsetBase = offsetMethod === OffsetMethod.POSITION ? this._getScrollTop() : 0; + this._offsets = []; + this._targets = []; + this._scrollHeight = this._getScrollHeight(); + var targets = $.makeArray($(this._selector)); + targets.map(function (element) { + var target; + + var targetSelector = _util2.default.getSelectorFromElement(element); + + if (targetSelector) { + target = $(targetSelector)[0]; + } + + if (target) { + var targetBCR = target.getBoundingClientRect(); + + if (targetBCR.width || targetBCR.height) { + // TODO (fat): remove sketch reliance on jQuery position/offset + return [$(target)[offsetMethod]().top + offsetBase, targetSelector]; + } + } + + return null; + }).filter(function (item) { + return item; + }).sort(function (a, b) { + return a[0] - b[0]; + }).forEach(function (item) { + _this2._offsets.push(item[0]); + + _this2._targets.push(item[1]); + }); + } + }, { + key: "dispose", + value: function dispose() { + $.removeData(this._element, DATA_KEY); + $(this._scrollElement).off(EVENT_KEY); + this._element = null; + this._scrollElement = null; + this._config = null; + this._selector = null; + this._offsets = null; + this._targets = null; + this._activeTarget = null; + this._scrollHeight = null; + } + }, { + key: "_getConfig", + value: function _getConfig(config) { + config = _extends({}, Default, config); + + if (typeof config.target !== 'string') { + var id = $(config.target).attr('id'); + + if (!id) { + id = _util2.default.getUID(NAME); + $(config.target).attr('id', id); + } + + config.target = "#".concat(id); + } + + _util2.default.typeCheckConfig(NAME, config, DefaultType); + + return config; + } + }, { + key: "_getScrollTop", + value: function _getScrollTop() { + return this._scrollElement === window ? this._scrollElement.pageYOffset : this._scrollElement.scrollTop; + } + }, { + key: "_getScrollHeight", + value: function _getScrollHeight() { + return this._scrollElement.scrollHeight || Math.max(document.body.scrollHeight, document.documentElement.scrollHeight); + } + }, { + key: "_getOffsetHeight", + value: function _getOffsetHeight() { + return this._scrollElement === window ? window.innerHeight : this._scrollElement.getBoundingClientRect().height; + } + }, { + key: "_process", + value: function _process() { + var scrollTop = this._getScrollTop() + this._config.offset; + + var scrollHeight = this._getScrollHeight(); + + var maxScroll = this._config.offset + scrollHeight - this._getOffsetHeight(); + + if (this._scrollHeight !== scrollHeight) { + this.refresh(); + } + + if (scrollTop >= maxScroll) { + var target = this._targets[this._targets.length - 1]; + + if (this._activeTarget !== target) { + this._activate(target); + } + + return; + } + + if (this._activeTarget && scrollTop < this._offsets[0] && this._offsets[0] > 0) { + this._activeTarget = null; + + this._clear(); + + return; + } + + for (var i = this._offsets.length; i--;) { + var isActiveTarget = this._activeTarget !== this._targets[i] && scrollTop >= this._offsets[i] && (typeof this._offsets[i + 1] === 'undefined' || scrollTop < this._offsets[i + 1]); + + if (isActiveTarget) { + this._activate(this._targets[i]); + } + } + } + }, { + key: "_activate", + value: function _activate(target) { + this._activeTarget = target; + + this._clear(); + + var queries = this._selector.split(','); // eslint-disable-next-line arrow-body-style + + + queries = queries.map(function (selector) { + return "".concat(selector, "[data-target=\"").concat(target, "\"],") + "".concat(selector, "[href=\"").concat(target, "\"]"); + }); + var $link = $(queries.join(',')); + + if ($link.hasClass(ClassName.DROPDOWN_ITEM)) { + $link.closest(Selector.DROPDOWN).find(Selector.DROPDOWN_TOGGLE).addClass(ClassName.ACTIVE); + $link.addClass(ClassName.ACTIVE); + } else { + // Set triggered link as active + $link.addClass(ClassName.ACTIVE); // Set triggered links parents as active + // With both
    and