o: ActiveSupport::Cache::Entry :@compressedF:@expires_in0:@created_atf1383740409.4025311: @value"Y{I" class:EFI"BundledAsset;FI"logical_path;FI"/iugu-ux/components/usecode/iugu-ui-view.js;TI" pathname;FI"q/Users/alezonez/Projetos/iugu-ux/vendor/assets/javascripts/iugu-ux/components/usecode/iugu-ui-view.js.coffee;TI"content_type;FI"application/javascript;FI" mtime;FI"2013-11-05T14:20:37-02:00;FI" length;FiMI" digest;F"%668ce0da0b0e43f8f975419d408ee222I" source;FI"M(function() { var _ref, __hasProp = {}.hasOwnProperty, __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }; IuguUI.View = (function(_super) { __extends(View, _super); function View() { _ref = View.__super__.constructor.apply(this, arguments); return _ref; } View.prototype.layout = "iugu-ui-view"; View.prototype.secondaryView = false; View.prototype.initialize = function() { View.__super__.initialize.apply(this, arguments); window.Events.on("fillSlots", this.fillSlots); window.Events.on("resetSlots", this.resetSlots); this.defaultLayout = this.layout; if (this.options.secondaryView) { this.secondaryView = this.options.secondaryView; } this.firstRender = true; if (this.model) { Backbone.Validation.bind(this, { forceUpdate: true, valid: function(view, attr, selector, cid) { return view.valid(view, attr, selector, cid); }, invalid: function(view, attr, error, selector, cid) { return view.invalid(view, attr, error, selector, cid); } }); this.model.on('error', this.addErrors, this); } return this; }; View.prototype.redirectBack = function() { return history.back(); }; View.prototype.fillSlots = function(context) { return _.each(_.keys(context), function(key) { var renderContext; renderContext = context[key]; if (renderContext.el) { context[key].$el.detach(); return this.$(key).empty().append(context[key].el); } else { return this.$(key).empty().append(context[key]); } }); }; View.prototype.resetSlots = function(slots) { return _.each(slots, function(slot) { return this.$(slot).empty(); }); }; View.prototype.enableLoader = function() { debug("ENABLED LOADER"); this.viewLoader = $('
'); return $(this.el).append(this.viewLoader); }; View.prototype.disableLoader = function() { debug("DISABLED LOADER"); if (this.viewLoader) { return this.viewLoader.remove(); } }; View.prototype.load = function() { debug("ON LOAD"); this.disableLoader(); return this.render(); }; View.prototype.valid = function(view, attr, selector, cid) { var control, group, list, new_attr, sel; sel = '[' + selector + '~="' + attr + '"]'; if (cid) { sel = sel + '[cid="' + cid + '"]'; } control = view.$(sel); group = view.$(".form-group"); list = group.find(".error-list"); if (view.model.preValidate(attr, control.val())) { return; } new_attr = attr.replace('.', '-'); this.$(".error-" + new_attr).remove(); control.parents('.iugu-ui-form-wrapper').removeClass("input-with-errors"); if (list.find(".error").length === 0) { return list.parent().remove(); } }; View.prototype.invalid = function(view, attr, error, selector, cid) { var control, group, list, model_name, new_attr, parent_model, right_attr, sel; sel = '[' + selector + '~="' + attr + '"]'; if (cid) { sel = sel + '[cid="' + cid + '"]'; } control = view.$(sel); group = view.$(".form-group"); list = group.find(".error-list"); control.parents('.iugu-ui-form-wrapper').addClass("input-with-errors"); if (list.length === 0) { group.prepend("

" + (_t('phrases.error_title')) + "

"); list = group.find(".error-list"); } new_attr = attr.replace('.', '-'); list.find(".error-" + new_attr).remove(); parent_model = ""; if (cid != null) { parent_model = "error-" + attr.split('.')[0]; } model_name = this.model.identifier; right_attr = attr.split('.'); right_attr = right_attr[right_attr.length - 1]; if (model_name == null) { right_attr = attr; } if (_.isArray(error)) { return _.each(error, function(err) { return list.append("
  • " + (_t(model_name + '_fields.' + right_attr)) + " " + err + "
  • "); }); } else { return list.append("
  • " + error + "
  • "); } }; View.prototype.addErrors = function(model, errors) { var errors_json, invalid, view; invalid = this.invalid; view = this; errors_json = JSON.parse(errors.responseText); return _.each(errors_json.errors, function(val, key) { return invalid(view, key, val, "name"); }); }; View.prototype.doEmptyCollectionLogic = function() { if ((this.collection != null) && this.collection.length === 0) { this.layout = this.emptyCollection.layout || 'iugu-ui-view-empty'; return this.extendContextWithEmptyCollection(); } else { if (this.defaultLayout != null) { return this.layout = this.defaultLayout; } } }; View.prototype.extendContextWithEmptyCollection = function() { var ctx; ctx = this.context(); return this.context = function() { return _.extend(ctx, { emptyCollection: this.emptyCollection }); }; }; View.prototype.render = function() { var bindToRivets; if ((this.emptyCollection != null) && this.firstRender) { this.doEmptyCollectionLogic(); } this.firstRender = false; View.__super__.render.apply(this, arguments); if (this.options.secondaryView != null) { this.secondaryView = this.options.secondaryView; } if (app.activeView !== this && this.secondaryView === false) { if (app.activeView) { app.activeView.close(); } app.activeView = this; } if ((window.app.rootWindow != null) && window.app.rootWindow.setTitle) { window.app.rootWindow.setTitle(this.title); } bindToRivets = {}; if (this.model) { bindToRivets['model'] = this.model; } if (this.collection) { bindToRivets['collection'] = this.collection; } if (this.model || this.collection) { rivets.bind(this.$el, bindToRivets); } IuguUI.Combobox.load(this.$el); IuguUI.Button.load(this.$el); IuguUI.Checkbox.load(this.$el); IuguUI.Radio.load(this.$el); IuguUI.Money.load(this.$el); return this; }; View.prototype.unload = function() { debug('Called IuguUI.View:unload'); if (this.model) { Backbone.Validation.unbind(this); this.model.off(null, null, this); } if (this.collection) { this.collection.off(null, null, this); } return View.__super__.unload.apply(this, arguments); }; return View; })(IuguUI.Base); this.IuguUI.View = IuguUI.View; }).call(this); ;FI"required_assets_digest;F"%ae7be5524901afd64ca5d3ce9411ef85I" _version;F"%6776f581a4329e299531e1d52aa59832