o: ActiveSupport::Cache::Entry :@compressedF:@expires_in0:@created_atf1416672640.342701: @value"‘{I" class:ETI"ProcessedAsset;FI"logical_path;TI"locomotive/toggle.js;FI" pathname;TI"€/Users/didier/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/locomotive_cms-2.5.5/vendor/assets/javascripts/locomotive/toggle.js;FI"content_type;TI"application/javascript;TI" mtime;TI"2014-11-22T16:47:37+01:00;TI" length;TiÍI" digest;TI"%ddb7ab9d4930e28fb8ffad89ff2bec4c;FI" source;TI"Í/** * * Copyright (c) 2009 Tony Dewan (http://www.tonydewan.com/) * Licensed under the MIT License: * http://www.opensource.org/licenses/mit-license.php * * Project home: * http://www.tonydewan.com/code/checkToggle/ * */ (function($) { /** * Version 1.0 * Replaces checkboxes with a toggle switch. * usage: $("input[type='checkbox']").checkToggle(settings); * * @name checkToggle * @type jquery * @param Hash settings Settings * @param String settings[on_label] Text used for the left-side (on) label. Defaults to "On" * @param String settings[off_label] Text used for the right-side (off) label. Defaults to "Off" * @param String settings[on_bg_color] Hex background color for On state * @param String settings[off_bg_color] Hex background color for Off state * @param String settings[skin_dir] Document relative (or absolute) path to the skin directory * @param Bool settings[bypass_skin] Flags whether to bypass the inclusion of the skin.css file. Used if you've included the skin styles somewhere else already. */ $.fn.checkToggle = function(action, settings) { if (typeof(action) == 'object' || typeof(action) == 'undefined') { settings = action || {}; action = 'initialize'; } settings = $.extend({ toggle_width: 28, on_label : 'Yes', on_label_color : '#333333', on_bg_color : '#8FE38D', off_label : 'No', off_label_color : '#cccccc', off_bg_color: '#F8837C', skin_dir : "skin/", bypass_skin : false, on_callback : function(el) {}, off_callback : function(el) {} }, settings); // FIXME (Didier Lafforgue) it works but it doesn't scale if we handle another locale if (typeof window.locale != 'undefined' && window.locale == 'fr') { settings.on_label = 'Oui'; settings.off_label = 'Non'; } function showUncheckedState(element) { element.parent().prev().css("color",settings.off_label_color).removeClass('on'); element.parent().next().css("color",settings.on_label_color).addClass('on'); element.parent().css("background-color", settings.off_bg_color).removeClass('on'); element.parent().parent().prev().removeAttr("checked").trigger('change'); element.removeClass("left").addClass("right"); } function showCheckedState(element) { element.parent().prev().css("color",settings.on_label_color).addClass('on'); element.parent().next().css("color",settings.off_label_color).removeClass('on'); element.parent().css("background-color", settings.on_bg_color).addClass('on'); element.parent().parent().prev().attr("checked", "checked").trigger('change'); element.removeClass("right").addClass("left"); } function toggle(element){ var checked = $(element).parent().parent().prev().is(':checked'); // if it's set to on if(checked){ $(element).animate({marginLeft: '0px'}, 100, // callback function function(){ showUncheckedState($(element)); if (typeof $.fn.publish != 'undefined') $.publish('toggle.' + $(element).parent().parent().prev().attr('id') + '.unchecked', []); settings.off_callback(); }); } else { $(element).animate({marginLeft: settings.toggle_width + 'px'}, 100, // callback function function(){ showCheckedState($(element)); if (typeof $.fn.publish != 'undefined') $.publish('toggle.' + $(element).parent().parent().prev().attr('id') + '.checked', []); settings.on_callback(); }); } }; return this.each(function () { if (action == 'initialize') {// initialize the UI element if ($(this).hasClass('simple')) return; // hide the checkbox $(this).css('display','none'); // insert the new toggle markup if($(this).attr("checked") == "checked" || $(this).attr("checked") == true){ $(this).after('
'+settings.on_label+'<\/span>
<\/span><\/div>'+settings.off_label+'<\/span><\/div>'); }else{ $(this).after('
'+settings.on_label+'<\/span>
<\/span><\/div>'+settings.off_label+'<\/span><\/div>'); } // Bind the switchHandle click events to the internal toggle function $(this).next().find('div.switchArea').bind("click", function () { toggle($(this).find('.switchHandle')); }) } else if (action == 'sync') { element = $(this).next().find('.switchHandle'); if ($(this).is(':checked')) showCheckedState(element); else showUncheckedState(element); } else { console.log('unknown action for the checkToggle plugin') } }); }; })(jQuery); ;TI"dependency_digest;TI"%7cc20798606351052c904a88ccbf380d;FI"required_paths;T[I"€/Users/didier/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/locomotive_cms-2.5.5/vendor/assets/javascripts/locomotive/toggle.js;FI"dependency_paths;T[{I" path;TI"€/Users/didier/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/locomotive_cms-2.5.5/vendor/assets/javascripts/locomotive/toggle.js;FI" mtime;TI"2014-11-22T16:47:37+01:00;TI" digest;TI"%a2fc36d8f1df37a165b5c163c4842a2e;FI" _version;TI"%ffd318ca8b794f42f5029101c2cf5d91;F