o: ActiveSupport::Cache::Entry :@compressedF:@expires_in0:@created_atf1371157313.289657: @value"{I" class:EFI"ProcessedAsset;FI"logical_path;FI"lentil/thisorthat.js;FI" pathname;FI"P/Users/jmcasden/Code/lentil/app/assets/javascripts/lentil/thisorthat.js.erb;FI"content_type;FI"application/javascript;FI" mtime;FI"2013-05-10T14:53:56-04:00;FI" length;Fi×I" digest;F"%a4a8cd4c143dec4e3d58ff72b4b6ae4eI" source;FI"×// Place all the behaviors and hooks related to the matching controller here. // All this logic will automatically be available in application.js. (function() { var BATTLE_SPINNER, ERROR_TEXT; ERROR_TEXT = '
' + '
' + '

Error.

' + '

Sorry, there was a problem loading images. Please reload the page.

'; // Set AJAX timeout $.rails.ajax = function(options) { if (!options.timeout) { options.timeout = 20000; } return $.ajax(options); }; $(document).ready(function() { $('.battle-inner:eq(0)').imagesLoaded(function($images, $proper, $broken) { if ($broken.length > 0) { $('.battle-wrapper:eq(0)').replaceWith(ERROR_TEXT); } }); }); $(document).on('ajax:beforeSend', function (evt, xhr, settings) { var img, opts, submitButton, target; // Disable Buttons submitButton = $(this).find('button[name="vote"]'); submitButton.attr('disabled', 'disabled'); // Show Spinner $('#spinner-overlay').show(); opts = { lines: 13, // The number of lines to draw length: 7, // The length of each line width: 4, // The line thickness radius: 10, // The radius of the inner circle corners: 1, // Corner roundness (0..1) rotate: 0, // The rotation offset color: '#fff', // #rgb or #rrggbb speed: 1, // Rounds per second trail: 60, // Afterglow percentage shadow: false, // Whether to render a shadow hwaccel: false, // Whether to use hardware acceleration className: 'spinner', // The CSS class to assign to the spinner zIndex: 2e9, // The z-index (defaults to 2000000000) top: 'auto', // Top position relative to parent in px left: 'auto' // Left position relative to parent in px }; target = document.getElementById('spinner-overlay'); BATTLE_SPINNER = new Spinner(opts).spin(target); }).on('ajax:success', function (evt, data, status, xhr) { // Insert new images into hidden div $('.battle-inner:eq(1)').replaceWith(data); // Once images are loaded, execute callback $('.battle-inner:eq(1)').imagesLoaded(function($images, $proper, $broken) { var wrap; if ($broken.length > 0) { // Insert error text into DOM $('.battle-wrapper:eq(0)').replaceWith(ERROR_TEXT); $('.battle-wrapper:eq(0)').show(); // Hide Spinner $('#spinner-overlay').hide(); BATTLE_SPINNER.stop(); } else { // Remove old images $('.battle-wrapper:eq(0)').remove(); // Div with new images moves up in DOM, display $('.battle-wrapper:eq(0)').show(); // Hide Spinner $('#spinner-overlay').hide(); BATTLE_SPINNER.stop(); // Insert placeholder div for next set of images wrap = ''; $(wrap).insertAfter('.battle-wrapper:eq(0)'); } }); }).on('ajax:error', function (evt, xhr, status) { var error, errors, ajaxError; // Hide Spinner $('#spinner-overlay').hide(); BATTLE_SPINNER.stop(); if (status === 'timeout') { errors = {Message: "Request timed out. Please reload the page and try again."}; } else { try { // Populate ajaxError with the comment errors errors = $.parseJSON(xhr.responseText); } catch (err) { // If the responseText is not valid JSON, populate errors with a generic error message. errors = {Message: "Please reload the page and try again."}; } } // Build an unordered list from the list of errors ajaxError = '
' + '
' + '

Error

"; $('.battle-wrapper:eq(0)').replaceWith(ajaxError); }); })(); ;FI"dependency_digest;F"%d5c60837b399b54db19eae24398c21d3I"required_paths;F[I"b/Users/jmcasden/Code/lentil/vendor/assets/javascripts/imagesloaded/jquery.imagesloaded.min.js;FI"G/Users/jmcasden/Code/lentil/vendor/assets/javascripts/spin/spin.js;FI"P/Users/jmcasden/Code/lentil/app/assets/javascripts/lentil/thisorthat.js.erb;FI"dependency_paths;F[{I" path;FI"P/Users/jmcasden/Code/lentil/app/assets/javascripts/lentil/thisorthat.js.erb;FI" mtime;FI"2013-05-10T14:53:56-04:00;FI" digest;F"%590403aa11a477ee773615d1c76d79e0{I" path;FI"b/Users/jmcasden/Code/lentil/vendor/assets/javascripts/imagesloaded/jquery.imagesloaded.min.js;FI" mtime;FI"2013-05-10T14:53:56-04:00;FI" digest;F"%9be5145b1e21b3c6833fb212d767f258{I" path;FI"G/Users/jmcasden/Code/lentil/vendor/assets/javascripts/spin/spin.js;FI" mtime;FI"2013-05-10T14:53:57-04:00;FI" digest;F"%d99f7980e4e5b30af5a0ad464ee616b4I" _version;F"%ffd318ca8b794f42f5029101c2cf5d91