I"² (function() { var extend = 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; }, hasProp = {}.hasOwnProperty; Quby.Models.Question = (function(superClass) { extend(Question, superClass); function Question() { return Question.__super__.constructor.apply(this, arguments); } Question.prototype.defaults = function() { return { options: new Quby.Collections.QuestionOptions, views: [], lastClickedOption: null, parentQuestion: null, parentOption: null, key: "", viewSelector: "", type: "", defaultInvisible: false, deselectable: false, hiddenByOptions: new Quby.Collections.QuestionOptions, shownByOptions: new Quby.Collections.QuestionOptions }; }; Question.prototype.initialize = function() { var options, questionModel, viewSelector, views; options = this.get("options"); options.on("clicked", this.optionClicked, this); options.on("setLastClickedOption", this.setLastClickedOption, this); this.on("hide", this.hide, this); this.on("unhide", this.unhide, this); this.on("show", this.show, this); this.on("unshow", this.unshow, this); viewSelector = this.get("viewSelector"); views = this.get("views"); questionModel = this; if (_.isEmpty(viewSelector)) { return views.push(new Quby.Views.QuestionView({ model: questionModel })); } else { return $(viewSelector).each(function(index, element) { return views.push(new Quby.Views.QuestionView({ model: questionModel, el: element })); }); } }; Question.prototype.isVisible = function() { return _.every(this.get("views"), function(view) { return view.isVisible(); }); }; Question.prototype.optionClicked = function(optionModel) { var lastClickedOption; lastClickedOption = this.get("lastClickedOption"); if (lastClickedOption !== null && lastClickedOption !== optionModel && this.unchecksLastClicked()) { lastClickedOption.trigger("checkChosen"); } optionModel.trigger("checkChosen"); return this.setLastClickedOption(optionModel); }; Question.prototype.setLastClickedOption = function(optionModel) { return this.set("lastClickedOption", optionModel); }; Question.prototype.unchecksLastClicked = function() { return _.contains(["radio", "select", "scale"], this.get("type")); }; Question.prototype.hide = function(hidingOption) { this.get("hiddenByOptions").add(hidingOption); return this.trigger("decideVisibility"); }; Question.prototype.unhide = function(hidingOption) { this.get("hiddenByOptions").remove(hidingOption); return this.trigger("decideVisibility"); }; Question.prototype.show = function(showingOption) { this.get("shownByOptions").add(showingOption); return this.trigger("decideVisibility"); }; Question.prototype.unshow = function(showingOption) { this.get("shownByOptions").remove(showingOption); return this.trigger("decideVisibility"); }; return Question; })(Backbone.Model); }).call(this); :ET