]> git.ipfire.org Git - thirdparty/foundation/foundation-sites.git/commitdiff
Converted F6 Core JS string concatenations to template literals
authorColin Marshall <colin.michael.marshall@gmail.com>
Tue, 26 Jan 2016 04:01:39 +0000 (21:01 -0700)
committerColin Marshall <colin.michael.marshall@gmail.com>
Mon, 1 Feb 2016 22:19:26 +0000 (15:19 -0700)
js/foundation.core.js

index 8154355ec47926f5b6c6eebd27ea8456badfb91c..9dc041b8c17497196db8f704cbc1fdcd7e286d95 100644 (file)
@@ -52,13 +52,13 @@ var Foundation = {
     var pluginName = name ? hyphenate(name) : functionName(plugin.constructor).toLowerCase();
     plugin.uuid = this.GetYoDigits(6, pluginName);
 
-    if(!plugin.$element.attr('data-' + pluginName)){ plugin.$element.attr('data-' + pluginName, plugin.uuid); }
+    if(!plugin.$element.attr(`data-${pluginName}`)){ plugin.$element.attr(`data-${pluginName}`, plugin.uuid); }
     if(!plugin.$element.data('zfPlugin')){ plugin.$element.data('zfPlugin', plugin); }
           /**
            * Fires when the plugin has initialized.
            * @event Plugin#init
            */
-    plugin.$element.trigger('init.zf.' + pluginName);
+    plugin.$element.trigger(`init.zf.${pluginName}`);
 
     this._uuids.push(plugin.uuid);
 
@@ -76,12 +76,12 @@ var Foundation = {
     var pluginName = hyphenate(functionName(plugin.$element.data('zfPlugin').constructor));
 
     this._uuids.splice(this._uuids.indexOf(plugin.uuid), 1);
-    plugin.$element.removeAttr('data-' + pluginName).removeData('zfPlugin')
+    plugin.$element.removeAttr(`data-${pluginName}`).removeData('zfPlugin')
           /**
            * Fires when the plugin has been destroyed.
            * @event Plugin#destroyed
            */
-          .trigger('destroyed.zf.' + pluginName);
+          .trigger(`destroyed.zf.${pluginName}`);
     for(var prop in plugin){
       plugin[prop] = null;//clean up script to prep for garbage collection.
     }
@@ -136,7 +136,7 @@ var Foundation = {
    */
   GetYoDigits: function(length, namespace){
     length = length || 6;
-    return Math.round((Math.pow(36, length + 1) - Math.random() * Math.pow(36, length))).toString(36).slice(1) + (namespace ? '-' + namespace : '');
+    return Math.round((Math.pow(36, length + 1) - Math.random() * Math.pow(36, length))).toString(36).slice(1) + (namespace ? `-${namespace}` : '');
   },
   /**
    * Initialize plugins on any elements within `elem` (and `elem` itself) that aren't already initialized.
@@ -279,7 +279,7 @@ var foundation = function(method) {
       throw new ReferenceError("We're sorry, '" + method + "' is not an available method for " + (plugClass ? functionName(plugClass) : 'this element') + '.');
     }
   }else{//error for invalid argument type
-    throw new TypeError("We're sorry, '" + type + "' is not a valid parameter. You must use a string representing the method you wish to invoke.");
+    throw new TypeError(`We're sorry, ${type} is not a valid parameter. You must use a string representing the method you wish to invoke.`);
   }
   return this;
 };