windhamdavid 10 years ago
parent
commit
126b756c13
6 changed files with 82 additions and 43 deletions
  1. 24 0
      .jshintrc
  2. 1 1
      functions.php
  3. 11 2
      gruntfile.js
  4. 39 0
      js/init.js
  5. 5 39
      js/script.js
  6. 2 1
      package.json

+ 24 - 0
.jshintrc

@@ -0,0 +1,24 @@
+{
+	"boss": true,
+	"curly": true,
+	"eqeqeq": true,
+	"eqnull": true,
+	"es3": true,
+	"expr": true,
+	"immed": true,
+	"noarg": true,
+	"onevar": true,
+	"quotmark": "single",
+	"trailing": true,
+	"undef": true,
+	"unused": true,
+
+	"browser": true,
+
+	"globals": {
+		"_": false,
+		"Backbone": false,
+		"jQuery": false,
+		"wp": false
+	}
+}

+ 1 - 1
functions.php

@@ -24,8 +24,8 @@ function dw_scripts() {
 	wp_enqueue_script('jquery', get_template_directory_uri() . '/js/jquery-2.1.1.min.js', array(), false, true);
 	wp_enqueue_script('boot', get_template_directory_uri() . '/js/bootstrap.min.js', array(), false, true);
 	wp_enqueue_script('jasny', get_template_directory_uri() . '/js/jasny-canvas.js', array(), false, true);
-	wp_enqueue_script( 'small-menu', get_template_directory_uri() . '/js/navigation.js', 'jquery', '', true );
 	wp_enqueue_script( 'script', get_template_directory_uri() . '/js/script.js', 'jquery', '', true );
+	wp_enqueue_script( 'init', get_template_directory_uri() . '/js/init.js', 'jquery', '', true );
 	if ( is_singular() && comments_open() && get_option( 'thread_comments' ) ) {
 		wp_enqueue_script( 'comment-reply', '', '', '', true );
 	}

+ 11 - 2
gruntfile.js

@@ -15,14 +15,23 @@ module.exports = function(grunt) {
 		      'style.min.css': ['css/styles.css', 'css/bootstrap.css', 'css/jasny-bootstrap.css', ]
 		    }
 		  }
+		},
+		concat: {
+			options: {
+				separator: ';',
+			},
+			dist: {
+				src: ['js/bootstrap.min.js', 'js/jasny-canvas.js'],
+				dest: 'js/script.js',
+			},
 		}
-
 	});
 
 	grunt.loadNpmTasks('grunt-contrib-jshint');
 	grunt.loadNpmTasks('grunt-contrib-cssmin');
+	grunt.loadNpmTasks('grunt-contrib-concat');
 
 	grunt.registerTask('test', [ 'cssmin' ]);
-	grunt.registerTask('default', [ 'cssmin' ]);
+	grunt.registerTask('default', [ 'cssmin', 'concat' ]);
 
 };

+ 39 - 0
js/init.js

@@ -0,0 +1,39 @@
+jQuery(document).ready(function($) {
+
+var wide = 768;
+if ($(window).width() > wide) {
+var headerHeight = $('.navbar').height();
+$(window).on('scroll', {
+    previousTop: 0
+},
+function() {
+    var currentTop = $(window).scrollTop();
+    if (currentTop < this.previousTop) {
+        if (currentTop > 0 && $('.navbar').hasClass('fixed')) {
+            $('.navbar').addClass('visible');
+        } else {
+            $('.navbar').removeClass('visible fixed');
+        }
+    } else {
+        $('.navbar').removeClass('visible');
+        if (currentTop > headerHeight && !$('.navbar').hasClass('fixed')) $('.navbar').addClass('fixed');
+    }
+    this.previousTop = currentTop;
+});
+}
+
+var commentsDiv = $('#comments');
+if (commentsDiv.length) {
+  $(commentsDiv).hide();
+  $('.toggle-comments').on('click', function(e) {
+    e.preventDefault();
+    $(commentsDiv).toggle('slow', function() {
+      var anchor = $('.toggle-comments');
+      var anchorText = anchor.text() == 'Hide Comments' ? 'Show Comments' : 'Hide Comments';
+      $(anchor).text(anchorText);
+    });
+  });
+}
+
+
+});

File diff suppressed because it is too large
+ 5 - 39
js/script.js


+ 2 - 1
package.json

@@ -4,6 +4,7 @@
   "devDependencies": {
     "grunt": "~0.4.5",
     "grunt-contrib-jshint": "~0.10.0",
-	"grunt-contrib-cssmin": "~0.10.0"
+	"grunt-contrib-cssmin": "~0.10.0",
+	"grunt-contrib-concat": "~0.5.0"
   }
 }

Some files were not shown because too many files changed in this diff