11// Copyright © UnlimitDesign 2019
22// Plugin: Timber core
3- // Version: 1.0.0
3+ // Version: 1.0.3
44// URL: @UnlimitDesign
55// Author: UnlimitDesign, Christian Lundgren, Shu Miyao
66// Description: Creates instances of timber plugins
77// License: MIT
88
99// Utilities
1010import tmInView from './utilities/_tm.inview.js' ;
11+ import tmLoadMedia from './utilities/_tm.loadmedia.js' ;
1112
1213// Components
1314import tmAccordion from './components/_tm.accordion.js' ;
14- import tmTabs from './components/_tm.tabs.js' ;
1515import tmCollapsable from './components/_tm.collapsable.js' ;
16- import tmRollover from './components/_tm.rollover.js' ;
1716import tmDismissable from './components/_tm.dismissable.js' ;
1817import tmDropdown from './components/_tm.dropdown.js' ;
18+ import tmOverlayNavigation from './components/_tm.overlaynavigation.js' ;
19+ import tmRollover from './components/_tm.rollover.js' ;
1920import tmScrollTo from './components/_tm.scrollto.js' ;
2021import tmSideNavigation from './components/_tm.sidenavigation.js' ;
21- import tmOverlayNavigation from './components/_tm.overlaynavigation.js' ;
2222import tmToggleSubMenu from './components/_tm.togglesubmenu.js' ;
23+ import tmTabs from './components/_tm.tabs.js' ;
2324
2425// Plugins
25- import tmMasonryGrid from './plugins/_tm.masonrygrid.js' ;
26- import tmFreeze from './plugins/_tm.freeze.js' ;
27- import tmStickyHeader from './plugins/_tm.stickyheader.js' ;
28- import tmLightbox from './plugins/_tm.lightbox.js' ;
2926import tmHorizon from './plugins/_tm.horizon.js' ;
27+ import tmLightbox from './plugins/_tm.lightbox.js' ;
28+ import tmMasonryGrid from './plugins/_tm.masonrygrid.js' ;
3029import tmParallax from './plugins/_tm.parallax.js' ;
3130import tmResponsiveVideo from './plugins/_tm.responsivevideo.js' ;
31+ import tmStickyHeader from './plugins/_tm.stickyheader.js' ;
3232
3333const timberCore = ( function ( ) {
3434
@@ -45,20 +45,20 @@ const timberCore = (function () {
4545 collapsable : '.collapsable' ,
4646 dismissable : '.dismissable' ,
4747 dropdown : '.dropdown' ,
48- freeze : '.freeze' ,
49- horizon : '.horizon' ,
5048 lightbox : '.lightbox' ,
51- grid : '.grid.preload ' ,
49+ horizon : '.horizon ' ,
5250 inview : '.observe' ,
53- overlaynav : '.overlay-nav-show' ,
51+ loadmedia : '.preload-media' ,
52+ masonrygrid : '.masonry' ,
53+ overlaynavigation : '.overlay-nav-show' ,
54+ parallax : '.parallax' ,
5455 rollover : '.thumbnail' ,
5556 scrollto : '.scroll-to' ,
56- sidenav : '.side-nav-show' ,
57+ sidenavigation : '.side-nav-show' ,
5758 stickyheader : '.header' ,
59+ togglesubmenu : '.toggle-sub-menus' ,
5860 tabs : '.tabs' ,
59- subMenus : '.toggle-sub-menus' ,
60- parallax : '.parallax' ,
61- responsiveVideo : '.video'
61+ responsivevideo : '.video'
6262 } ;
6363
6464 // Create an empty plugin object
@@ -71,37 +71,56 @@ const timberCore = (function () {
7171 plugin . defaults = defaults ;
7272 plugin . options = options ;
7373 plugin . settings = Object . assign ( { } , defaults , options ) ;
74- plugin . module = { accordion : null , collapsable : null , dismissable : null , dropdown : null , freeze : null , horizon : null , grid : null , inview : null , overlaynavigation : null , rollover : null , scrollto : null , sidenavigation : null , stickyheader : null , tabs : null , togglesubmenu : null } ;
75-
74+ plugin . module = {
75+ accordion : null ,
76+ collapsable : null ,
77+ dismissable : null ,
78+ dropdown : null ,
79+ lightbox : null ,
80+ horizon : null ,
81+ inview : null ,
82+ loadmedia : null ,
83+ masonrygrid : null ,
84+ overlaynavigation : null ,
85+ parallax : null ,
86+ rollover : null ,
87+ scrollto : null ,
88+ sidenavigation : null ,
89+ stickyheader : null ,
90+ tabs : null ,
91+ togglesubmenu : null ,
92+ responsivevideo : null ,
93+ } ;
94+
7695 // Create instances if module exists
7796 if ( typeof tmAccordion != 'undefined' ) plugin . module . accordion = new tmAccordion ( plugin . settings . accordion ) ;
7897 if ( typeof tmCollapsable != 'undefined' ) plugin . module . collapsable = new tmCollapsable ( plugin . settings . collapsable ) ;
7998 if ( typeof tmDismissable != 'undefined' ) plugin . module . dismissable = new tmDismissable ( plugin . settings . dismissable ) ;
8099 if ( typeof tmDropdown != 'undefined' ) plugin . module . dropdown = new tmDropdown ( plugin . settings . dropdown ) ;
81- if ( typeof tmFreeze != 'undefined' ) plugin . module . freeze = new tmFreeze ( plugin . settings . freeze ) ;
82100 if ( typeof tmLightbox != 'undefined' ) plugin . module . lightbox = new tmLightbox ( plugin . settings . lightbox ) ;
83101 if ( typeof tmHorizon != 'undefined' ) plugin . module . horizon = new tmHorizon ( plugin . settings . horizon ) ;
84- if ( typeof tmMasonryGrid != 'undefined' ) plugin . module . grid = new tmMasonryGrid ( plugin . settings . grid ) ;
85102 if ( typeof tmInView != 'undefined' ) plugin . module . inview = new tmInView ( plugin . settings . inview ) ;
86- if ( typeof tmOverlayNavigation != 'undefined' ) plugin . module . overlaynavigation = new tmOverlayNavigation ( plugin . settings . overlaynav ) ;
103+ if ( typeof tmLoadMedia != 'undefined' ) plugin . module . loadmedia = new tmLoadMedia ( plugin . settings . loadmedia ) ;
104+ if ( typeof tmMasonryGrid != 'undefined' ) plugin . module . masonrygrid = new tmMasonryGrid ( plugin . settings . masonrygrid ) ;
105+ if ( typeof tmOverlayNavigation != 'undefined' ) plugin . module . overlaynavigation = new tmOverlayNavigation ( plugin . settings . overlaynavigation ) ;
87106 if ( typeof tmParallax != 'undefined' ) plugin . module . parallax = new tmParallax ( plugin . settings . parallax ) ;
88107 if ( typeof tmRollover != 'undefined' ) plugin . module . rollover = new tmRollover ( plugin . settings . rollover ) ;
89108 if ( typeof tmScrollTo != 'undefined' ) plugin . module . scrollto = new tmScrollTo ( plugin . settings . scrollto ) ;
90- if ( typeof tmSideNavigation != 'undefined' ) plugin . module . sidenavigation = new tmSideNavigation ( plugin . settings . sidenav ) ;
109+ if ( typeof tmSideNavigation != 'undefined' ) plugin . module . sidenavigation = new tmSideNavigation ( plugin . settings . sidenavigation ) ;
91110 if ( typeof tmStickyHeader != 'undefined' ) plugin . module . stickyheader = new tmStickyHeader ( plugin . settings . stickyheader ) ;
92111 if ( typeof tmTabs != 'undefined' ) plugin . module . tabs = new tmTabs ( plugin . settings . tabs ) ;
93- if ( typeof tmToggleSubMenu != 'undefined' ) plugin . module . togglesubmenu = new tmToggleSubMenu ( plugin . settings . subMenus ) ;
94- if ( typeof tmResponsiveVideo != 'undefined' ) plugin . module . responsivevideo = new tmResponsiveVideo ( plugin . settings . responsiveVideo ) ;
112+ if ( typeof tmToggleSubMenu != 'undefined' ) plugin . module . togglesubmenu = new tmToggleSubMenu ( plugin . settings . togglesubmenu ) ;
113+ if ( typeof tmResponsiveVideo != 'undefined' ) plugin . module . responsivevideo = new tmResponsiveVideo ( plugin . settings . responsivevideo ) ;
95114 } catch ( error ) {
96115 console . log ( `${ error } - ensure module is imported or instantiate specific plugin instead of core, for example: plugin.module.moduleName.initialize();` ) ;
97116 }
98-
117+
99118 /**
100119 * Initialize the plugin.
101120 */
102121 plugin . initialize = ( ) => {
103122 for ( let module in plugin . module ) {
104- if ( plugin . module [ module ] != null && document . querySelector ( plugin . module [ module ] . elements ) ) plugin . module [ module ] . initialize ( ) ;
123+ if ( plugin . module [ module ] != null && document . querySelector ( plugin . settings [ module ] ) ) plugin . module [ module ] . initialize ( ) ;
105124 }
106125 } ;
107126
@@ -110,7 +129,7 @@ const timberCore = (function () {
110129 */
111130 plugin . refresh = ( ) => {
112131 for ( let module in plugin . module ) {
113- if ( plugin . module [ module ] != null && document . querySelector ( plugin . module [ module ] . elements ) ) plugin . module [ module ] . refresh ( ) ;
132+ if ( plugin . module [ module ] != null && document . querySelector ( plugin . settings [ module ] ) ) plugin . module [ module ] . refresh ( ) ;
114133 }
115134 } ;
116135
@@ -119,7 +138,7 @@ const timberCore = (function () {
119138 */
120139 plugin . destroy = ( ) => {
121140 for ( let module in plugin . module ) {
122- if ( plugin . module [ module ] != null && document . querySelector ( plugin . module [ module ] . elements ) ) plugin . module [ module ] . destroy ( ) ;
141+ if ( plugin . module [ module ] != null && document . querySelector ( plugin . settings [ module ] ) ) plugin . module [ module ] . destroy ( ) ;
123142 }
124143 } ;
125144
0 commit comments