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.QuestionOption = (function(superClass) { extend(QuestionOption, superClass); function QuestionOption() { return QuestionOption.__super__.constructor.apply(this, arguments); } QuestionOption.prototype.defaults = function() { return { hidesQuestions: new Quby.Collections.Questions, showsQuestions: new Quby.Collections.Questions, hidesQuestionsKeys: [], showsQuestionsKeys: [], startChosen: false }; }; QuestionOption.prototype.initialize = function() { this.on("checkChosen", this.checkChosen, this); return this.on("add", this.addedToCollection, this); }; QuestionOption.prototype.addedToCollection = function() { if (!_.isEmpty(this.get("hidesQuestionsKeys")) || !_.isEmpty(this.get("showsQuestionsKeys"))) { return this.collection.on("initShowsHides", this.initShowsHides, this); } }; QuestionOption.prototype.initShowsHides = function(allQuestions) { var hidesQuestions, hidesQuestionsKeys, showsQuestions, showsQuestionsKeys; showsQuestionsKeys = this.get("showsQuestionsKeys"); showsQuestions = allQuestions.select(function(question) { return _.contains(showsQuestionsKeys, question.get("key")); }); this.get("showsQuestions").add(showsQuestions); hidesQuestionsKeys = this.get("hidesQuestionsKeys"); hidesQuestions = allQuestions.select(function(question) { return _.contains(hidesQuestionsKeys, question.get("key")); }); this.get("hidesQuestions").add(hidesQuestions); if (this.get("startChosen")) { this.hideQuestions(); this.showQuestions(); return this.trigger("setLastClickedOption", this); } }; QuestionOption.prototype.checkChosen = function() { if (this.get("view").chosen()) { this.hideQuestions(); return this.showQuestions(); } else { this.unhideQuestions(); return this.unshowQuestions(); } }; QuestionOption.prototype.hideQuestions = function() { var option; option = this; return this.get("hidesQuestions").each(function(question) { return question.trigger("hide", option); }); }; QuestionOption.prototype.unhideQuestions = function() { var option; option = this; return this.get("hidesQuestions").each(function(question) { return question.trigger("unhide", option); }); }; QuestionOption.prototype.showQuestions = function() { var option; option = this; return this.get("showsQuestions").each(function(question) { return question.trigger("show", option); }); }; QuestionOption.prototype.unshowQuestions = function() { var option; option = this; return this.get("showsQuestions").each(function(question) { return question.trigger("unshow", option); }); }; return QuestionOption; })(Backbone.Model); }).call(this); :ET