o: ActiveSupport::Cache::Entry :@compressedF:@expires_in0:@created_atf1392321407.872778: @value"{I" class:EFI"BundledAsset;FI"logical_path;FI"1iugu-ux/components/usecode/iugu-ui-button.js;TI" pathname;FI"s/Users/nkr/Projetos/Iugu/iugu-ux/vendor/assets/javascripts/iugu-ux/components/usecode/iugu-ui-button.js.coffee;TI"content_type;FI"application/javascript;FI" mtime;FI"2014-01-30T15:30:10-02:00;FI" length;FiòI" digest;F"%c048a6ee832f61c0a74d7ad2946e420cI" source;FI"ò(function() { IuguUI.Button = (function() { Button.prototype.defaults = { none: false, hideInput: true }; Button.prototype.el = void 0; Button.load = function(context) { var elements, selector; selector = "[data-type='iux.form.button']"; if (context) { elements = context.find(selector); } else { elements = $(selector); } if (elements.length === 0) { return; } return elements.each(function() { if ($(this).data("iux.initialized") === true) { return; } new IuguUI.Button({ el: this, context: context }); return $(this).data("iux.initialized", true); }); }; function Button(options) { this.initialize(options); } Button.prototype.initialize = function(options) { var input_selector; _.bindAll(this); this.options = _.extend({}, this.defaults, options); if (!this.options.el) { return null; } this.el = $(this.options.el); if (this.el.data("mode") === "toggle") { this.toggle_button = true; } if (this.options.onClick) { this.onClick = this.options.onClick; } if (this.el.data("input")) { input_selector = "#" + this.el.data("input"); } if (this.options.context && input_selector) { this.input_element = $(this.options.context.find(input_selector)); if (this.input_element.size() === 0) { this.input_element = this.options.context; } this.input_element = $(this.input_element[0]); } else if (input_selector) { this.input_element = $(input_selector); } if (this.getInput() && this.el.data("value") && this.el.data("value").toString() === this.getInput().val().toString()) { if (!this.el.hasClass("selected")) { this.el.addClass("selected"); } } if (this.getInput() && this.getInput().is(":checkbox") && this.getInput().is(":checked")) { this.el.addClass("selected"); } if (this.getInput() && this.getInput().is(":radio") && this.getInput().is(":checked")) { this.el.addClass("selected"); } if (this.getInput() && this.getInput().is(":radio") || this.getInput().is(":checkbox")) { this.getInput().bind("change", this.inputChangedCallback); } this.el.bind("click", this.click); if (this.options.hideInput && this.input_element) { return this.input_element.hide(); } }; Button.prototype.getInput = function() { if (this.input_element) { return $(this.input_element); } return false; }; Button.prototype.linkedElements = function() { return $('[data-group="' + this.el.data("group") + '"]'); }; Button.prototype.hasLinkedElements = function() { var elms; elms = this.linkedElements(); if (!(elms && elms.size() > 1)) { return false; } return true; }; Button.prototype.inputChangedCallback = function() { if (this.hasLinkedElements()) { this.linkedElements().removeClass("selected"); } if (this.getInput() && this.getInput().is(":checkbox") && this.getInput().is(":checked")) { this.el.addClass("selected"); } if (this.getInput() && this.getInput().is(":radio") && this.getInput().is(":checked")) { return this.el.addClass("selected"); } }; Button.prototype.configureInputElementValue = function(value) { if (!this.getInput()) { return; } if (this.getInput().is(":checkbox")) { this.getInput().attr("checked", this.el.hasClass("selected")); } else if (this.getInput().is(":radio")) { this.getInput().attr("checked", this.el.hasClass("selected")); } else { if (this.getInput()) { this.getInput().val(value); } } if (this.getInput()) { return this.getInput().trigger("change"); } }; Button.prototype.toggleable = function() { if (!this.toggle_button) { return false; } if (this.hasLinkedElements()) { return false; } return true; }; Button.prototype.click = function() { var value; if (this.el.data("value")) { value = this.el.data("value"); } if (this.toggleable()) { this.el.toggleClass("selected"); } if (this.toggleable() && this.el.hasClass("selected") === false) { value = null; } if (this.hasLinkedElements()) { this.linkedElements().removeClass("selected"); this.el.addClass("selected"); } if (value !== null) { if (this.onClick) { this.onClick(value); } return this.configureInputElementValue(value); } else { return this.configureInputElementValue(value); } }; return Button; })(); this.IuguUI.Button = IuguUI.Button; $(function() { return IuguUI.Button.load(); }); }).call(this); ;FI"required_assets_digest;F"%a3f1e208c2edd8a3850559be271aefc9I" _version;F"%9f3b95dd7ea3030dc35985c0a8020862