Rearrange js files
authorSteve Sutton <steve@gaslightmedia.com>
Thu, 20 Nov 2014 20:06:57 +0000 (15:06 -0500)
committerSteve Sutton <steve@gaslightmedia.com>
Thu, 20 Nov 2014 20:06:57 +0000 (15:06 -0500)
To allow working with jquery from wordpress

footer.php
functions.php
header.php
js/dollarsign.js [new file with mode: 0644]
js/pageSetup.js [new file with mode: 0644]

index 207caab..85de942 100644 (file)
     </footer>
  </div><!--/inner-wrap-->
  </div><!--/off-canvas-->
-    <script src="<?php bloginfo('template_url'); ?>/js/foundation.min.js"></script>
-    <script>
-    $(document).foundation();
-    $(document).ready(function(){
-        $('ul.children').each(function(){
-            $(this).before('<a class="toggle" href="#"></a>');
-        });
-        $('a.toggle').click('click', function(){
-            console.log('clicked me!');
-            $(this).toggleClass('open');
-            $(this).siblings('ul').toggleClass('open');
-        });
-    });
-    </script>
     <?php wp_footer();?>
  </body>
 </html>
\ No newline at end of file
index 4473221..630e460 100755 (executable)
@@ -56,6 +56,32 @@ set_post_thumbnail_size(120, 100, true);
  */
 function preston_feather_scripts()
 {
+    wp_enqueue_script(
+        'modernizr',
+        get_template_directory_uri() . '/js/vendor/modernizr.js'
+    );
+    wp_enqueue_script(
+        'jquery',
+        get_template_directory_uri() . '/js/vendor/jquery.js'
+    );
+    wp_enqueue_script(
+        'dollarsign',
+        get_template_directory_uri() . '/js/dollarsign.js'
+    );
+    wp_enqueue_script(
+        'foundation',
+        get_template_directory_uri() . '/js/foundation.min.js',
+        'jquery',
+        '1.0',
+        true
+    );
+    wp_enqueue_script(
+        'pageSetup',
+        get_template_directory_uri() . '/js/pageSetup.js',
+        'foundation',
+        '1.0',
+        true
+    );
     if(is_front_page()) {
         wp_enqueue_script(
             'cycle_script',
@@ -63,7 +89,7 @@ function preston_feather_scripts()
             'jquery',
             '1.0',
             true
-         );
+        );
         wp_enqueue_script(
             'glm_google_map_code',
             'http://maps.google.com/maps/api/js?sensor=false',
index ad35a6f..5783624 100644 (file)
@@ -5,8 +5,6 @@
      <title><?php wp_title(); ?></title>
      <link rel="stylesheet" href="<?php bloginfo('template_url'); ?>/css/foundation.min.css">
      <link rel="stylesheet" href="<?php bloginfo('template_url'); ?>/css/styles.css">
-     <script src="<?php bloginfo('template_url'); ?>/js/vendor/modernizr.js"></script>
-     <script src="<?php bloginfo('template_url'); ?>/js/vendor/jquery.js"></script>
      <?php wp_head();?>
  </head>
  <body>
diff --git a/js/dollarsign.js b/js/dollarsign.js
new file mode 100644 (file)
index 0000000..34d34e5
--- /dev/null
@@ -0,0 +1,8 @@
+/* 
+ * To avoid conflicts, Wordpress tends to prefer jQuery being used over $.
+ * As long as this file is included, no such conflicts should arise. Ensure it
+ * is called before other .js files using $.
+ */
+
+
+var $=jQuery.noConflict();
diff --git a/js/pageSetup.js b/js/pageSetup.js
new file mode 100644 (file)
index 0000000..6d21e36
--- /dev/null
@@ -0,0 +1,11 @@
+$(document).foundation();
+$(document).ready(function () {
+    $('ul.children').each(function () {
+        $(this).before('<a class="toggle" href="#"></a>');
+    });
+    $('a.toggle').click('click', function () {
+        console.log('clicked me!');
+        $(this).toggleClass('open');
+        $(this).siblings('ul').toggleClass('open');
+    });
+});
\ No newline at end of file