Signin  Pricing  Examples  Support

Libraries > application.js

application.js - Search Live Website Code
It's like doing CTRL+F on millions of websites' source code



NerdyData is a search engine for source code. Search the source code of 200 million websites.


JAVASCRIPT FILE http://songspub.com/javascripts/app/application.js

Function Explorer












Libraries on songspub.com


application.js

home.js

handlebars.js

jquery-1.7.2.min.js

jquery.columnizer.min.js

jquery.imagesloaded.min.js

jquery.mousewheel.min.js

jquery.smoothdivscroll-1.2.min.js

jquery.truncate.min.js

jquery-ui-1.8.18.min.js

modernizr.min.js

soundmanager2.min.js

homepage.js



Explore More


md_stylechanger.js

adHelper.js

breakpointSettingsLoader.js

js_VtafjXmRvoUgAzqzYTA3Wrjkx9wcWhjP0G4ZnnqRamA.js

application.js
				
window.log = function f() { log.history = log.history || []; log.history.push(arguments); if (this.console) { var args = arguments, newarr; args.callee = args.callee.caller; newarr = [].slice.call(args); if (typeof console.log === 'object') log.apply.call(console.log, console, newarr); else console.log.apply(console, newarr); } };

(function (a) { function b() { } for (var c = "assert,count,debug,dir,dirxml,error,exception,group,groupCollapsed,groupEnd,info,log,markTimeline,profile,profileEnd,time,timeEnd,trace,warn".split(","), d; !!(d = c.pop()); ) { a[d] = a[d] || b; } })
(function () { try { console.log(); return window.console; } catch (a) { return (window.console = {}); } } ());

window.requestAnimFrame = (function () {
    return window.requestAnimationFrame ||
            window.webkitRequestAnimationFrame ||
            window.mozRequestAnimationFrame ||
            window.oRequestAnimationFrame ||
            window.msRequestAnimationFrame ||
            function (/* function */callback, /* DOMElement */element) {
                window.setTimeout(callback, 1000 / 60);
            };
})();
/**
* Behaves the same as setInterval except uses requestAnimationFrame() where possible for better performance
* @param {function} fn The callback function
* @param {int} delay The delay in milliseconds
*/
window.requestInterval = function (fn, delay) {
    if (!window.requestAnimationFrame &&
        !window.webkitRequestAnimationFrame &&
        !window.mozRequestAnimationFrame &&
        !window.oRequestAnimationFrame &&
        !window.msRequestAnimationFrame)
        return window.setInterval(fn, delay);
    var start = new Date().getTime(),
        handle = new Object();
    function loop() {
        var current = new Date().getTime(),
            delta = current - start;
        if (delta >= delay) {
            fn.call();
            start = new Date().getTime();
        }
        handle.value = requestAnimFrame(loop);
    };
    handle.value = requestAnimFrame(loop);
    return handle;
}

/**
* Behaves the same as clearInterval except uses cancelRequestAnimationFrame() where possible for better performance
* @param {int|object} fn The callback function
*/
window.clearRequestInterval = function (handle) {
    window.cancelAnimationFrame ? window.cancelAnimationFrame(handle.value) :
    window.webkitCancelRequestAnimationFrame ? window.webkitCancelRequestAnimationFrame(handle.value) :
    window.mozCancelRequestAnimationFrame ? window.mozCancelRequestAnimationFrame(handle.value) :
    window.oCancelRequestAnimationFrame ? window.oCancelRequestAnimationFrame(handle.value) :
    window.msCancelRequestAnimationFrame ? msCancelRequestAnimationFrame(handle.value) :
    clearInterval(handle);
};

var APP = (function ($) {
    var app = {}, $el, on = "on",
    // Animation speeds
        slow = 500, normal = 250, fast = 150,

        // Sound Manager
        sm = null, sm_id = 0, sm_obj = "sm_obj", sm_class = {
          'playing': "sm-playing", 'loaded': "sm-loaded"
        };

    function init() {
        // Set up the global ajax
        $.ajaxSetup({ cache: false, error: function errorLog(x, e) { log(x, e); }, type: 'POST' });
        if (!Modernizr.input.placeholder) { placeholder(); }
        yepnope([{ test: Modernizr.csstransitions,
            nope: 'javascripts/app/css3.js'
        }]);

        app.linkTracks($('a[href$=".mp3"],a[type$="mp3"]'));
        app.fixToolTips();
        $('a[href=#]').attr('href', 'javascript:;');
        $('.link-cols').columnize({ columns: 4 });

        var $bios = $('.bio');
        if ($bios.length > 0) {
          $bios.each(function(i, el) { app.bootstrapBio($(el)); });
        }
        $('.scrollable').smoothDivScroll({
          scrollingHotSpotLeftClass: "hotspot-left",
          scrollingHotSpotRightClass: "hotspot-right",
          scrollableAreaClass: "scroll-train",
          scrollWrapperClass: "scroll-train-wrap",
          hotSpotsVisibleTime: 5000
        });

        // Events
        $(document)
          .on("click", '.expand .block-link', function (e) {
            e.preventDefault();
            app.Expander($(this));
            app.loadSocialWidgets();
          })
          .on("click", 'a[href^="http://"],a[href^="https://"]', open)
          .on("click", '.bio .block-link', function(e) {
            e.preventDefault();
            app.bioExpander($(this));
          })
          .on("mouseenter mouseleave", '.tooltip',
            function(e) {
              var $tooltip = $(this),
                  $magic_box = $tooltip.find('.magic-box'),
                  $magic_inner = $magic_box.children('div');

              if (e.type === "mouseenter") {
                $magic_box.show();
                $magic_inner.animate({ left: '100%', opacity: 1 }, normal);
              } else {
                $magic_inner.animate({ left: '75%', opacity: 0 }, normal,
                  function() { $magic_box.hide(); });
              }
          })
          .on("click", 'a[href$=".mp3"],a[type$="mp3"]',
            function(e) {
              e.preventDefault();

              var $elem = $(this);

              if (is_playing($elem)) {
                pause($elem);
              } else {
                play($elem);
              }
            });;


        var $featured_placements = $('.featured-placements');
        $featured_placements.find('li a').click(featuredPlacements);
        if ($featured_placements.length > 0) {
          $featured_placements.each(function(i, el) {
            $(el).find('li a:first').click();
          });
        }
    }
    app.linkTracks = function ($tracks) {
      if (sm === null) {
        sm = soundManager;
      soundManager.debugMode = false;
      soundManager.allowScriptAccess = 'always';
      soundManager.useHighPerformance = true;
      soundManager.url = '/flash/';
      soundManager.preferFlash = false;
      soundManager.stream = true;
      soundManager.flashVersion = 9;
      }
      
      sm.onready(function () {
		 var $tracks = $('a[href$=".mp3"]:not(".' + sm_class.loaded + '"),a[type$="mp3"]:not(".' + sm_class.loaded + '")'),
            $track;

        for (var c = $tracks.length - 1; c >= 0; c--) {
          $track = $tracks.eq(c).addClass(sm_class.loaded);
          sm_id += 1;
          sound_object = sm.createSound({
            id: "sound-manager-obj-" + sm_id,
            url: $track.attr('href')
          });
          $track.data(sm_obj, sound_object);
        }
      });
    }
    app.fixToolTips = function() {
      var $tooltips = $('.tooltip');
      $tooltips.find('img').imagesLoaded(function(i, p, b) {
      $tooltips.each(function (i, el) {
        $el = $(el);
          var $magic_box = $el.find('.magic-box'),
              $box = $magic_box.find('div'),
            mheight = $box.outerHeight() / 2,
            iheight = $el.find('img').outerHeight(true) / 2,
            offset;

        if (mheight > iheight) {
          offset = iheight - mheight;
        } else {
          offset = mheight - iheight;
        }

        $box.css("margin-top", offset + "px");
          $magic_box.hide();
        });
      });
    }

    app.bootstrapBio = function($el) {
      $el.truncated(500, {
        // wrapper: '<div></div>',
        // toggleSpeed: 'fast',
        wrapperClass: 'truncated',
        toggler: '<a class="block-link" href="#">More</a>',
        togglerClass: ''
      });
    }
    app.bioExpander = function($el) {
      var $truncated = $el.parent().find('.truncated'),
          height = $truncated.data('height');

      if (height === undefined) {
        height = $truncated.css({
          visibility: 'hidden', position: 'absolute', display: 'block'
        }).height();
        $truncated.data('height', height);
        $truncated.removeAttr('style');
      }
      $el.css({ position: "relative" }).animate(
        { opacity: 0, height: 0, margin: 0, bottom: '5%', right: '5%',
          padding: 0, width: 0 },
          fast,
          function() {
            $truncated
            .css({ height: 0, opacity: 0 })
            .addClass('on')
            .animate({ height: height, opacity: 1 }, fast, function() {
              $truncated.removeAttr('style');
            });
          });
    }
    app.loadSocialWidgets =	function () {
		// load social buttons - DHH
    	if (typeof twttr != 'undefined') { twttr.widgets.load(); }
    	if (typeof FB != 'undefined') { FB.XFBML.parse(); }
    	if (typeof IN != 'undefined') { IN.parse(document); }
    	if (typeof gapi != 'undefined') { gapi.plus.go(); }
    	if (typeof Tumblr != 'undefined') { Tumblr.activate_share_on_tumblr_buttons(); }
    	$(".songs_tumblr_share").on("click", function () { return false; });
    	window.parsePinBtns();
	}
    app.Expander = function ($el) {
      // e.preventDefault();
      var $par = $el.parents('.expand'),
      $block = $par.find('div'),
      height = $block.data('height');

      if ($par.hasClass(on)) {
        $block.animate({ height: 0 }, fast, function () {
          $par.removeClass(on);
          $block.attr('style', '');
        });
      } else {
        if (height === undefined) {
          height = $block.css({
            visibility: 'hidden', position: 'absolute', display: 'block'
          }).height();
          $block.data('height', height);
          $block.removeAttr('style');
        }
        $block.css({ height: 0, opacity: 0 });
        $par.addClass(on);
        $block.animate({ height: height }, fast, function () {
          $block.animate({ opacity: 1 }, fast, function () {
            $block.removeAttr('style');
          });
        });
      }
    }
    function is_paused($elem) { return $elem.data(sm_obj).paused; }
    function is_playing($elem) { return $elem.hasClass(sm_class.playing); }
    function play($elem) {
      var obj = $elem.data(sm_obj),
          $playing = $('.' + sm_class.playing);

      if ($playing.length > 0) {
        for (var c = $playing.length - 1; c >= 0; c--) {
          pause($playing.eq(c));
        }
      }

      obj.play();
      $elem
        .addClass(sm_class.playing)
        .parent()
          .addClass(on);
    }
    function pause($elem) {
      $elem.data(sm_obj).pause();
      $elem
        .removeClass(sm_class.playing)
        .parent()
          .removeClass(on);
    }
    function featuredPlacements(e) {
      e.preventDefault();
      $el = $(this);
      var preview_height = 255,
      preview_width = 459,
      $mod_container = $el.parents('.mod-container'),
      $preview_container = $mod_container.find('.featured-preview'),
      $description_container = $mod_container.find('.featured-description'),
      $li = $el.parent('li'),
      $featured_content = $li.find('.featured-content'),
      $preview_content = $featured_content.find('div').clone(),
      $description_content = $featured_content.find('h3,p').clone(),
      $iframe = $preview_content.find('iframe');

      $mod_container.find('.on').removeClass('on');
      $li.addClass('on');

      if ($iframe.length > 0) {
        $iframe.attr({ height: preview_height, width: preview_width });
      }

      $preview_container.animate({ opacity: 0 }, {
        duration: normal,
        queue: false,
        complete: function() {
          $preview_container
          .html('')
          .append($preview_content)
          .animate({ opacity: 1 }, { duration: slow, queue: false });
        }
      });

      $description_container.animate({ opacity: 0 }, {
        duration: normal,
        queue: false,
        complete: function() {
          $description_container
          .html('')
          .append($description_content)
          .animate({ opacity: 1 }, { duration: slow, queue: false });
        }
      });
    }
    function open(e) {
      e.preventDefault();
      var href = this.getAttribute("href");
      if (window.location.host !== href.split('/')[2]) {
        window.open(href);
      } else {
        window.location = href;
      }
    }
    function placeholder() {
      var attr = 'placeholder';
      $('input[' + attr + '!=""]').each(function (idx, el) {
        $el = $(el);
        var d = $el.attr(attr);
        if (d === undefined) { return; }
        $el.focus(function onFocus() {
          if (this.value === d) { this.value = ''; }
        }).blur(function onBlur() {
          if ($.trim(this.value) === '') { this.value = d; }
        });
        $el.blur();
      });
    }
    // Call the init function on load
    $(init);
    return app;
} (jQuery));


A B C D E F G H I J K L M N O P Q R S T U V W X Y Z