/**
 * Main JS file for Casper behaviours
 */

/* globals jQuery, document */
(function ($, undefined) {
    "use strict";

    $(document).ready(function () {

        var $postContent = $(".post-content");
        $postContent.fitVids();

        $(".menu-button, .nav-cover, .nav-close").on("click", function(e){
            e.preventDefault();
            $("body").toggleClass("nav-opened nav-closed");
        });

        $('.js-current-track').spotify({
            width: '100%',
            height: 380,
            username: 'kjbrum',
            api_key: 'da3d6b59d72cbd535ce2405ec13b97be'
        });
    });

    var jsSocialShares = document.querySelectorAll('.js-social-share');
    if(jsSocialShares) {
        [].forEach.call(jsSocialShares, function(anchor) {
            anchor.addEventListener('click', function(e) {

                var url = this.href,
                    width = 500,
                    height = 300,
                    left = (screen.width / 2) - (width / 2),
                    top = (screen.height / 2) - (height / 2);

                if(/^(f|ht)tps?:\/\//i.test(url) || /^mailto/i.test(url)) {
                    e.preventDefault();
                    window.open(
                        url,
                        '',
                        'menubar=no,toolbar=no,resizable=yes,scrollbars=yes,width=' + width + ',height=' + height + ',top=' + top + ',left=' + left
                    );
                }

            });
        });
    }

})(jQuery);

@@ -16,30 +16,8 @@
 file
- for Casper behaviours
 %0A */
@@ -80,17 +80,17 @@
 ) %7B%0A    
-%22
+'
 use stri
@@ -91,17 +91,17 @@
 e strict
-%22
+'
 ;%0A%0A    $
@@ -131,25 +131,24 @@
 on () %7B%0A
-%0A
         
 var $pos
@@ -143,91 +143,11 @@
     
-var $postContent = $(%22.post-content%22);%0A        $postContent.fitVids();%0A%0A        $(%22
+$('
 .men
@@ -182,21 +182,21 @@
 lose
-%22
+'
 ).on(
-%22
+'
 click
-%22
+'
 , fu
@@ -256,14 +256,14 @@
   $(
-%22
+'
 body
-%22
+'
 ).to
@@ -272,17 +272,17 @@
 leClass(
-%22
+'
 nav-open
@@ -298,9 +298,9 @@
 osed
-%22
+'
 );%0A 
@@ -307,24 +307,72 @@
        %7D);%0A%0A
+        if($('.js-current-track').length) %7B%0A    
         $('.
@@ -400,16 +400,20 @@
 otify(%7B%0A
+    
         
@@ -439,24 +439,28 @@
             
+   
+ 
 height: 380,
@@ -460,16 +460,20 @@
 t: 380,%0A
+    
         
@@ -496,16 +496,20 @@
 jbrum',%0A
+    
         
@@ -560,27 +560,170 @@
 be'%0A        
+ 
-%7D);
+   %7D);%0A        %7D%0A%0A        var $postContent = $('.post-content');%0A%0A        if($postContent.length) %7B%0A            $postContent.fitVids();%0A        %7D
 %0A    %7D);%0A%0A  

Add checks for js functionality