(function() { var bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; }, 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; if (ELA.Views == null) { ELA.Views = {}; } ELA.Views.Overview = (function(superClass) { extend(Overview, superClass); function Overview() { this.adjustDimensions = bind(this.adjustDimensions, this); this.calculateTileSize = bind(this.calculateTileSize, this); this.showHelp = bind(this.showHelp, this); this.deactivate = bind(this.deactivate, this); this.activate = bind(this.activate, this); return Overview.__super__.constructor.apply(this, arguments); } Overview.prototype.id = 'overview'; Overview.prototype.tagName = 'section'; Overview.prototype.className = 'active'; Overview.prototype.template = JST['overview/app']; Overview.prototype.events = { 'tap header .help.icon': 'showHelp' }; Overview.prototype.hammerjs = true; Overview.prototype.keep = true; Overview.prototype.initialize = function() { var apps; $(window).resize(this.adjustDimensions); apps = _.chain(ELA.settings.apps).sortBy(function(app) { return app.name; }).map(function(app) { var group, groups, j, len, results; groups = ELA.settings[app].groups; if ((groups != null) && groups.length > 0) { results = []; for (j = 0, len = groups.length; j < len; j++) { group = groups[j]; results.push({ name: app, group: group }); } return results; } else { return { name: app }; } }).flatten().value(); return this.collection = new Backbone.Collection(apps); }; Overview.prototype.setActive = function(val) { return this.$el.toggleClass('active', val); }; Overview.prototype.activate = function() { return this.$el.toggleClass('active', true); }; Overview.prototype.deactivate = function() { return this.$el.toggleClass('active', false); }; Overview.prototype.showHelp = function() { return ELA.router.navigate('about', { trigger: true }); }; Overview.prototype.calculateTileSize = function() { var columns, tileSize, width; width = this.$el.width() - 2 * 14; tileSize = 200; columns = Math.ceil(width / tileSize); return Math.floor(Math.min(width / columns, tileSize)); }; Overview.prototype.adjustDimensions = function() { var size; size = this.calculateTileSize(); return this.$('.tile').each(function(i, elem) { return $(elem).css({ height: size + "px", width: size + "px" }); }); }; Overview.prototype.render = function() { this.$el.html(this.template()); if (/Android.*Chrome/.test(navigator.userAgent)) { this.$('#chrome-android-flag-hint').css({ display: 'block' }); } this.list = new Backbone.Poised.List({ filterAttributes: [], collection: this.collection, itemClass: ELA.Views.OverviewTile, group: { by: 'group', sorting: ELA.settings.appGroups, collapsible: true }, localePrefix: 'overview' }); this.$('article ul').replaceWith(this.list.render().el); delay(this.adjustDimensions); return this; }; return Overview; })(Backbone.Poised.View); }).call(this);