@sygnas/tabs
Advanced tools
Comparing version 1.1.1 to 1.1.2
(function (global, factory) { | ||
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() : | ||
typeof define === 'function' && define.amd ? define(factory) : | ||
(global.tabs = factory()); | ||
(global['syg-tabs'] = factory()); | ||
}(this, (function () { 'use strict'; | ||
@@ -6,0 +6,0 @@ |
@@ -1,2 +0,2 @@ | ||
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):t.tabs=e()}(this,function(){"use strict";function t(t){return Array.prototype.slice.call(t,0)}var e=function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")},n=function(){function t(t,e){for(var n=0;n<e.length;n++){var i=e[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,i.key,i)}}return function(e,n,i){return n&&t(e.prototype,n),i&&t(e,i),e}}(),i={tab_selector:"a",use_url_hash:!1},a="data-tabs-content",r="data-tabs-prev",o="data-tabs-next",u="data-tabs-active";return function(){function s(t,n){e(this,s),this.opt=Object.assign(i,n),this.tab_group=document.querySelector(t),this.tab_buttons=this.tab_group.querySelectorAll(this.opt.tab_selector),this.contents=document.querySelectorAll(this.tab_group.getAttribute(a)),this.prev_button=document.querySelector(this.tab_group.getAttribute(r)),this.next_button=document.querySelector(this.tab_group.getAttribute(o)),this._init_event(),this.active=0,this._set_initial_page()}return n(s,[{key:"set_active_from_index",value:function(e){t(this.tab_buttons).forEach(function(t,n){e===n?t.setAttribute(u,"true"):t.setAttribute(u,"false")}),t(this.contents).forEach(function(t,n){e===n?t.setAttribute(u,"true"):t.setAttribute(u,"false")}),this.opt.use_url_hash&&(window.location.hash=e),this.active=e}},{key:"_init_event",value:function(){var e=this;t(this.tab_buttons).forEach(function(t){e._init_event_tab_button(t)}),this.prev_button&&this.prev_button.addEventListener("click",function(t){e._init_event_prev_button(t)}),this.next_button&&this.next_button.addEventListener("click",function(t){e._init_event_next_button(t)})}},{key:"_init_event_tab_button",value:function(t){var e=this;t.addEventListener("click",function(t){var n=Number.parseInt(t.target.hash.substr(1),10);e.set_active_from_index(n),t.preventDefault()})}},{key:"_init_event_prev_button",value:function(t){var e=this.active-1>=0?this.active-1:this.contents.length-1;this.set_active_from_index(e),t.preventDefault()}},{key:"_init_event_next_button",value:function(t){var e=(this.active+1)%this.contents.length;this.set_active_from_index(e),t.preventDefault()}},{key:"_set_initial_page",value:function(){var t=0;if(t=Number.parseInt(this.tab_group.getAttribute("data-tabs-initial"),10)||0,this.opt.use_url_hash){var e=window.location.hash.substr(1),n=Number.parseInt(e,10);n>=1&&(t=n)}this.set_active_from_index(t)}}]),s}()}); | ||
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):t["syg-tabs"]=e()}(this,function(){"use strict";function t(t){return Array.prototype.slice.call(t,0)}var e=function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")},n=function(){function t(t,e){for(var n=0;n<e.length;n++){var i=e[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,i.key,i)}}return function(e,n,i){return n&&t(e.prototype,n),i&&t(e,i),e}}(),i={tab_selector:"a",use_url_hash:!1},a="data-tabs-content",r="data-tabs-prev",o="data-tabs-next",s="data-tabs-active";return function(){function u(t,n){e(this,u),this.opt=Object.assign(i,n),this.tab_group=document.querySelector(t),this.tab_buttons=this.tab_group.querySelectorAll(this.opt.tab_selector),this.contents=document.querySelectorAll(this.tab_group.getAttribute(a)),this.prev_button=document.querySelector(this.tab_group.getAttribute(r)),this.next_button=document.querySelector(this.tab_group.getAttribute(o)),this._init_event(),this.active=0,this._set_initial_page()}return n(u,[{key:"set_active_from_index",value:function(e){t(this.tab_buttons).forEach(function(t,n){e===n?t.setAttribute(s,"true"):t.setAttribute(s,"false")}),t(this.contents).forEach(function(t,n){e===n?t.setAttribute(s,"true"):t.setAttribute(s,"false")}),this.opt.use_url_hash&&(window.location.hash=e),this.active=e}},{key:"_init_event",value:function(){var e=this;t(this.tab_buttons).forEach(function(t){e._init_event_tab_button(t)}),this.prev_button&&this.prev_button.addEventListener("click",function(t){e._init_event_prev_button(t)}),this.next_button&&this.next_button.addEventListener("click",function(t){e._init_event_next_button(t)})}},{key:"_init_event_tab_button",value:function(t){var e=this;t.addEventListener("click",function(t){var n=Number.parseInt(t.target.hash.substr(1),10);e.set_active_from_index(n),t.preventDefault()})}},{key:"_init_event_prev_button",value:function(t){var e=this.active-1>=0?this.active-1:this.contents.length-1;this.set_active_from_index(e),t.preventDefault()}},{key:"_init_event_next_button",value:function(t){var e=(this.active+1)%this.contents.length;this.set_active_from_index(e),t.preventDefault()}},{key:"_set_initial_page",value:function(){var t=0;if(t=Number.parseInt(this.tab_group.getAttribute("data-tabs-initial"),10)||0,this.opt.use_url_hash){var e=window.location.hash.substr(1),n=Number.parseInt(e,10);n>=1&&(t=n)}this.set_active_from_index(t)}}]),u}()}); | ||
//# sourceMappingURL=tabs.min.js.map |
{ | ||
"name": "@sygnas/tabs", | ||
"version": "1.1.1", | ||
"version": "1.1.2", | ||
"description": "Simple tab script. シンプルなタブ", | ||
"main": "dist/tabs.js", | ||
"module": "dist/tabs.es.js", | ||
"moduleName": "syg-tabs", | ||
"private": false, | ||
@@ -8,0 +9,0 @@ "repository": { |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
68708