From: Geoff Kimball Date: Thu, 11 Feb 2016 22:24:04 +0000 (-0800) Subject: Re-wrap every JavaScript module in an IIFE, but only pass in jQuery, not Foundation X-Git-Tag: v6.2.0-rc.1~8 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4c974baef093fe6c409496a81b52ac789a44a94d;p=thirdparty%2Ffoundation%2Ffoundation-sites.git Re-wrap every JavaScript module in an IIFE, but only pass in jQuery, not Foundation --- diff --git a/js/foundation.abide.js b/js/foundation.abide.js index 78f6b1e18..cc481b481 100644 --- a/js/foundation.abide.js +++ b/js/foundation.abide.js @@ -1,5 +1,7 @@ 'use strict'; +!function($) { + /** * Abide module. * @module foundation.abide @@ -456,3 +458,5 @@ Abide.defaults = { // Window exports Foundation.plugin(Abide, 'Abide'); + +}(jQuery); diff --git a/js/foundation.accordion.js b/js/foundation.accordion.js index 9c2eb5f6a..ae3381608 100644 --- a/js/foundation.accordion.js +++ b/js/foundation.accordion.js @@ -1,5 +1,7 @@ 'use strict'; +!function($) { + /** * Accordion module. * @module foundation.accordion @@ -233,3 +235,5 @@ Accordion.defaults = { // Window exports Foundation.plugin(Accordion, 'Accordion'); + +}(jQuery); diff --git a/js/foundation.accordionMenu.js b/js/foundation.accordionMenu.js index 885824842..8d3bcb087 100644 --- a/js/foundation.accordionMenu.js +++ b/js/foundation.accordionMenu.js @@ -1,5 +1,7 @@ 'use strict'; +!function($) { + /** * AccordionMenu module. * @module foundation.accordionMenu @@ -264,3 +266,5 @@ AccordionMenu.defaults = { // Window exports Foundation.plugin(AccordionMenu, 'AccordionMenu'); + +}(jQuery); diff --git a/js/foundation.core.js b/js/foundation.core.js index a782fa2c7..2513d2bba 100644 --- a/js/foundation.core.js +++ b/js/foundation.core.js @@ -1,4 +1,5 @@ !function($) { + "use strict"; var FOUNDATION_VERSION = '6.1.2'; @@ -219,7 +220,6 @@ var Foundation = { } }; - Foundation.util = { /** * Function for applying a debounce effect to a function call. diff --git a/js/foundation.drilldown.js b/js/foundation.drilldown.js index 6faed1098..88be96084 100644 --- a/js/foundation.drilldown.js +++ b/js/foundation.drilldown.js @@ -1,5 +1,7 @@ 'use strict'; +!function($) { + /** * Drilldown module. * @module foundation.drilldown @@ -331,3 +333,5 @@ Drilldown.defaults = { // Window exports Foundation.plugin(Drilldown, 'Drilldown'); + +}(jQuery); diff --git a/js/foundation.dropdown.js b/js/foundation.dropdown.js index bd9d667da..3f585138f 100644 --- a/js/foundation.dropdown.js +++ b/js/foundation.dropdown.js @@ -1,5 +1,7 @@ 'use strict'; +!function($) { + /** * Dropdown module. * @module foundation.dropdown @@ -398,3 +400,5 @@ Dropdown.defaults = { // Window exports Foundation.plugin(Dropdown, 'Dropdown'); + +}(jQuery); diff --git a/js/foundation.dropdownMenu.js b/js/foundation.dropdownMenu.js index efc3787e6..9138fcc13 100644 --- a/js/foundation.dropdownMenu.js +++ b/js/foundation.dropdownMenu.js @@ -1,5 +1,7 @@ 'use strict'; +!function($) { + /** * DropdownMenu module. * @module foundation.dropdown-menu @@ -395,3 +397,5 @@ DropdownMenu.defaults = { // Window exports Foundation.plugin(DropdownMenu, 'DropdownMenu'); + +}(jQuery); diff --git a/js/foundation.equalizer.js b/js/foundation.equalizer.js index e7130e456..0893c5573 100644 --- a/js/foundation.equalizer.js +++ b/js/foundation.equalizer.js @@ -1,5 +1,7 @@ 'use strict'; +!function($) { + /** * Equalizer module. * @module foundation.equalizer @@ -279,3 +281,5 @@ Equalizer.defaults = { // Window exports Foundation.plugin(Equalizer, 'Equalizer'); + +}(jQuery); diff --git a/js/foundation.interchange.js b/js/foundation.interchange.js index 764540e27..dc7463bed 100644 --- a/js/foundation.interchange.js +++ b/js/foundation.interchange.js @@ -1,5 +1,7 @@ 'use strict'; +!function($) { + /** * Interchange module. * @module foundation.interchange @@ -185,6 +187,6 @@ Interchange.SPECIAL_QUERIES = { }; // Window exports -if (window.Foundation) { - Foundation.plugin(Interchange, 'Interchange'); -} +Foundation.plugin(Interchange, 'Interchange'); + +}(jQuery); diff --git a/js/foundation.magellan.js b/js/foundation.magellan.js index 379141e74..ff95dc066 100644 --- a/js/foundation.magellan.js +++ b/js/foundation.magellan.js @@ -1,5 +1,7 @@ 'use strict'; +!function($) { + /** * Magellan module. * @module foundation.magellan @@ -217,3 +219,5 @@ Magellan.defaults = { // Window exports Foundation.plugin(Magellan, 'Magellan'); + +}(jQuery); diff --git a/js/foundation.offcanvas.js b/js/foundation.offcanvas.js index 6897c5ec0..cca11d20e 100644 --- a/js/foundation.offcanvas.js +++ b/js/foundation.offcanvas.js @@ -1,5 +1,7 @@ 'use strict'; +!function($) { + /** * OffCanvas module. * @module foundation.offcanvas @@ -389,3 +391,5 @@ OffCanvas.defaults = { // Window exports Foundation.plugin(OffCanvas, 'OffCanvas'); + +}(jQuery); diff --git a/js/foundation.orbit.js b/js/foundation.orbit.js index 0b9c120ed..32bcdbf60 100644 --- a/js/foundation.orbit.js +++ b/js/foundation.orbit.js @@ -1,5 +1,7 @@ 'use strict'; +!function($) { + /** * Orbit module. * @module foundation.orbit @@ -439,3 +441,5 @@ Orbit.defaults = { // Window exports Foundation.plugin(Orbit, 'Orbit'); + +}(jQuery); diff --git a/js/foundation.responsiveMenu.js b/js/foundation.responsiveMenu.js index f146b3bb6..559fe1fd7 100644 --- a/js/foundation.responsiveMenu.js +++ b/js/foundation.responsiveMenu.js @@ -1,5 +1,7 @@ 'use strict'; +!function($) { + /** * ResponsiveMenu module. * @module foundation.responsiveMenu @@ -139,3 +141,5 @@ var MenuPlugins = { // Window exports Foundation.plugin(ResponsiveMenu, 'ResponsiveMenu'); + +}(jQuery); diff --git a/js/foundation.responsiveToggle.js b/js/foundation.responsiveToggle.js index 16fbfc271..d39cecfe2 100644 --- a/js/foundation.responsiveToggle.js +++ b/js/foundation.responsiveToggle.js @@ -1,5 +1,7 @@ 'use strict'; +!function($) { + /** * ResponsiveToggle module. * @module foundation.responsiveToggle @@ -106,3 +108,5 @@ ResponsiveToggle.defaults = { // Window exports Foundation.plugin(ResponsiveToggle, 'ResponsiveToggle'); + +}(jQuery); diff --git a/js/foundation.reveal.js b/js/foundation.reveal.js index 4f8d8a474..5806de500 100644 --- a/js/foundation.reveal.js +++ b/js/foundation.reveal.js @@ -1,5 +1,7 @@ 'use strict'; +!function($) { + /** * Reveal module. * @module foundation.reveal @@ -549,3 +551,5 @@ Foundation.plugin(Reveal, 'Reveal'); function iPhoneSniff() { return /iP(ad|hone|od).*OS/.test(window.navigator.userAgent); } + +}(jQuery); diff --git a/js/foundation.slider.js b/js/foundation.slider.js index 343e552c8..62a13b56f 100644 --- a/js/foundation.slider.js +++ b/js/foundation.slider.js @@ -1,5 +1,7 @@ 'use strict'; +!function($) { + /** * Slider module. * @module foundation.slider @@ -530,6 +532,8 @@ function absPosition($handle, dir, clickPos, param) { // Window exports Foundation.plugin(Slider, 'Slider'); +}(jQuery); + //*********this is in case we go to static, absolute positions instead of dynamic positioning******** // this.setSteps(function() { // _this._events(); diff --git a/js/foundation.sticky.js b/js/foundation.sticky.js index 19de99629..4594e9361 100644 --- a/js/foundation.sticky.js +++ b/js/foundation.sticky.js @@ -1,5 +1,7 @@ 'use strict'; +!function($) { + /** * Sticky module. * @module foundation.sticky @@ -441,3 +443,5 @@ function emCalc(em) { // Window exports Foundation.plugin(Sticky, 'Sticky'); + +}(jQuery); diff --git a/js/foundation.tabs.js b/js/foundation.tabs.js index e4172e307..48bebc9bf 100644 --- a/js/foundation.tabs.js +++ b/js/foundation.tabs.js @@ -1,5 +1,7 @@ 'use strict'; +!function($) { + /** * Tabs module. * @module foundation.tabs @@ -319,3 +321,5 @@ function checkClass($elem){ // Window exports Foundation.plugin(Tabs, 'Tabs'); + +}(jQuery); diff --git a/js/foundation.toggler.js b/js/foundation.toggler.js index 8633eff1d..0bd400b23 100644 --- a/js/foundation.toggler.js +++ b/js/foundation.toggler.js @@ -1,5 +1,7 @@ 'use strict'; +!function($) { + /** * Toggler module. * @module foundation.toggler @@ -137,3 +139,5 @@ Toggler.defaults = { // Window exports Foundation.plugin(Toggler, 'Toggler'); + +}(jQuery); diff --git a/js/foundation.tooltip.js b/js/foundation.tooltip.js index 76361c97d..827fcd298 100644 --- a/js/foundation.tooltip.js +++ b/js/foundation.tooltip.js @@ -1,5 +1,7 @@ 'use strict'; +!function($) { + /** * Tooltip module. * @module foundation.tooltip @@ -432,3 +434,5 @@ Tooltip.defaults = { // Window exports Foundation.plugin(Tooltip, 'Tooltip'); + +}(jQuery); diff --git a/js/foundation.util.box.js b/js/foundation.util.box.js index b4a395900..3d0ce87d7 100644 --- a/js/foundation.util.box.js +++ b/js/foundation.util.box.js @@ -1,3 +1,7 @@ +'use strict'; + +!function($) { + Foundation.Box = { ImNotTouchingYou: ImNotTouchingYou, GetDimensions: GetDimensions, @@ -175,3 +179,5 @@ function GetOffsets(element, anchor, position, vOffset, hOffset, isOverflow) { } } } + +}(jQuery); diff --git a/js/foundation.util.keyboard.js b/js/foundation.util.keyboard.js index 301e416ff..75dc16aa2 100644 --- a/js/foundation.util.keyboard.js +++ b/js/foundation.util.keyboard.js @@ -8,6 +8,8 @@ 'use strict'; +!function($) { + const keyCodes = { 9: 'TAB', 13: 'ENTER', @@ -109,3 +111,5 @@ function getKeyCodes(kcs) { } Foundation.Keyboard = Keyboard; + +}(jQuery); diff --git a/js/foundation.util.mediaQuery.js b/js/foundation.util.mediaQuery.js index 5284c1027..6175b13af 100644 --- a/js/foundation.util.mediaQuery.js +++ b/js/foundation.util.mediaQuery.js @@ -1,3 +1,7 @@ +'use strict'; + +!function($) { + // Default set of media queries const defaultQueries = { 'default' : 'only screen', @@ -201,4 +205,6 @@ function parseStyleToObject(str) { return styleObject; } -window.Foundation.MediaQuery = MediaQuery; +Foundation.MediaQuery = MediaQuery; + +}(jQuery); diff --git a/js/foundation.util.motion.js b/js/foundation.util.motion.js index dd141a613..0473a110e 100644 --- a/js/foundation.util.motion.js +++ b/js/foundation.util.motion.js @@ -1,3 +1,7 @@ +'use strict'; + +!function($) { + /** * Motion module. * @module foundation.motion @@ -6,7 +10,7 @@ const initClasses = ['mui-enter', 'mui-leave']; const activeClasses = ['mui-enter-active', 'mui-leave-active']; -export const Motion = { +const Motion = { animateIn: function(element, animation, cb) { animate(true, element, animation, cb); }, @@ -16,7 +20,7 @@ export const Motion = { } } -export function Move(duration, elem, fn){ +function Move(duration, elem, fn){ var anim, prog, start = null; // console.log('called'); @@ -91,3 +95,5 @@ function animate(isIn, element, animation, cb) { Foundation.Move = Move; Foundation.Motion = Motion; + +}(jQuery); diff --git a/js/foundation.util.nest.js b/js/foundation.util.nest.js index 6a29fade5..a2602442d 100644 --- a/js/foundation.util.nest.js +++ b/js/foundation.util.nest.js @@ -1,5 +1,7 @@ 'use strict'; +!function($) { + const Nest = { Feather(menu, type = 'zf') { menu.attr('role', 'menubar'); @@ -70,3 +72,5 @@ const Nest = { } Foundation.Nest = Nest; + +}(jQuery); diff --git a/js/foundation.util.timerAndImageLoader.js b/js/foundation.util.timerAndImageLoader.js index 7ef2f6821..b5facd02f 100644 --- a/js/foundation.util.timerAndImageLoader.js +++ b/js/foundation.util.timerAndImageLoader.js @@ -1,6 +1,8 @@ 'use strict'; -export function Timer(elem, options, cb) { +!function($) { + +function Timer(elem, options, cb) { var _this = this, duration = options.duration,//options is an object for easily adding features later. nameSpace = Object.keys(elem.data())[0] || 'timer', @@ -48,7 +50,7 @@ export function Timer(elem, options, cb) { * @param {Object} images - Image(s) to check if loaded. * @param {Func} callback - Function to execute when image is fully loaded. */ -export function onImagesLoaded(images, callback){ +function onImagesLoaded(images, callback){ var self = this, unloaded = images.length; @@ -80,3 +82,5 @@ export function onImagesLoaded(images, callback){ Foundation.Timer = Timer; Foundation.onImagesLoaded = onImagesLoaded; + +}(jQuery); diff --git a/js/foundation.util.triggers.js b/js/foundation.util.triggers.js index 743790d1c..c904c9946 100644 --- a/js/foundation.util.triggers.js +++ b/js/foundation.util.triggers.js @@ -1,5 +1,7 @@ 'use strict'; +!function($) { + const MutationObserver = (function () { var prefixes = ['WebKit', 'Moz', 'O', 'Ms', '']; for (var i=0; i < prefixes.length; i++) { @@ -199,6 +201,8 @@ Foundation.IHearYou = checkListeners; // Foundation.ISeeYou = scrollListener; // Foundation.IFeelYou = closemeListener; +}(jQuery); + // function domMutationObserver(debounce) { // // !!! This is coming soon and needs more work; not active !!! // // var timer,