o: ActiveSupport::Cache::Entry :@compressedF:@expires_in0:@created_atf1336656481.0605068: @value"7{I" class:EFI"ProcessedAsset;FI"logical_path;F"'ems/controllers/news_controller.jsI" pathname;F"w/private/var/www/html/development/projects/rails/ems/app/assets/javascripts/ems/controllers/news_controller.coffeeI"content_type;FI"application/javascript;FI" mtime;FI"2012-05-10T14:27:36+01:00;FI" length;FiºI" digest;F"%c7a0a678d3029e7b33ddc0fe8523d534I" source;FI"º(function() { var __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; }; Ems.NewsController = (function(_super) { __extends(NewsController, _super); NewsController.name = 'NewsController'; function NewsController() { return NewsController.__super__.constructor.apply(this, arguments); } NewsController.prototype.news = null; NewsController.prototype.channels = null; NewsController.prototype.suggestTags = new Batman.Set; NewsController.prototype.allTags = null; NewsController.prototype.selectedChannels = []; NewsController.prototype.tags = new Batman.Set; NewsController.prototype.index = function(params) { var filters, _this = this; this.set('categorySlug', params.category); filters = { 'category_slug': params.category }; return Ems.News.load({ 'filters': filters }, function(err, news) { if (err) { throw err; } return _this.set('news', Ems.News.get('loaded')); }); }; NewsController.prototype.show = function(params) {}; NewsController.prototype["new"] = function(params) { var _this = this; this.set('news', new Ems.News); return this.set('category', Ems.Category.find(parseInt(params.categoryId), function(err) { if ((err != null ? err.status : void 0) === 404) { _this.redirect('/404'); } if (err) { throw err; } _this.set('channels', new Batman.Set); return _this.observe('category', function(category, oldCategory) { _this.set('news.category', newVal); return _this.set('channels', _this.get('category.channels')); }); })); }; NewsController.prototype.create = function(params) { var _this = this; return this.get('news').save(function(err) { if (err) { if (!(err instanceof Batman.ErrorsSet)) { throw err; } } else { return Ems.flashSuccess("News " + (_this.get('news.name')) + " created successfully!"); } }); }; NewsController.prototype.edit = function(params) { var _this = this; this.set('news', Ems.News.find(parseInt(params.id), function(err) { if ((err != null ? err.status : void 0) === 404) { _this.redirect('/404'); } if (err) { throw err; } })); this.get('news.category').fetch(function(err, category) { if (err) { throw err; } return _this.set('channels', category.get('channels')); }); setTimeout(function() { return _this.set('tags', _this.get('news.tags')); }, 100); return setTimeout(function() { var channel, channels, _i, _len, _ref, _results; channels = _this.get('news.channels'); if (channels) { _ref = channels.toArray(); _results = []; for (_i = 0, _len = _ref.length; _i < _len; _i++) { channel = _ref[_i]; _results.push(_this.get('selectedChannels').push(channel.id)); } return _results; } }, 100); }; NewsController.prototype.update = function() { var _this = this; return this.get('news').save(function(err) { if (err) { if (!(err instanceof Batman.ErrorsSet)) { throw err; } } else { Ems.flashSuccess("News " + (_this.get('news.name')) + " updated successfully!"); return _this.redirect('/articles'); } }); }; NewsController.prototype.toggleChannel = function(node, event) { var c, channel, channels, newChannels, _i, _len; channels = this.get('channels'); newChannels = new Batman.Set; for (_i = 0, _len = node.length; _i < _len; _i++) { c = node[_i]; if (!(c.nodeType === 1 && c.selected === true)) { continue; } channel = channels.indexedByUnique('id').get(parseInt(c.value)); if (channel) { newChannels.add(channel); } } return this.set('news.channels', newChannels); }; NewsController.prototype.suggestTags = function(node, event) { var _this = this; if (node.value.length > 0) { if (!this.get('allTags')) { Ems.Tag.load(function(err, tags) { if (err) { throw err; } return _this.set('allTags', Ems.Tag.get('loaded')); }); } return setTimeout(function() { var suggestTags, tag, tags, _i, _len, _ref; suggestTags = new Batman.Set; tags = _this.get('allTags'); _ref = tags.toArray(); for (_i = 0, _len = _ref.length; _i < _len; _i++) { tag = _ref[_i]; if (tag.get('title').indexOf(node.value) >= 0) { suggestTags.add(tag); } } return _this.set('suggestTags', suggestTags); }, 100); } }; NewsController.prototype.addTag = function(node, value) { var tag; tag = this.get('allTags').indexedByUnique('id').get(parseInt(node.id)); return this.get('news.tags').add(tag); }; NewsController.prototype.removeTag = function(node, value) { var tag; tag = this.get('news.tags').indexedByUnique('id').get(parseInt(node.id)); return this.get('news.tags').remove(tag); }; return NewsController; })(Batman.Controller); }).call(this); ;TI"dependency_digest;F"%40ad85883ae12db9814f7f5a48237008I"required_paths;F["w/private/var/www/html/development/projects/rails/ems/app/assets/javascripts/ems/controllers/news_controller.coffeeI"dependency_paths;F[{I" path;F"w/private/var/www/html/development/projects/rails/ems/app/assets/javascripts/ems/controllers/news_controller.coffeeI" mtime;FI"2012-05-10T14:27:36+01:00;FI" digest;F"%b0bf4056c28f3f4b956ac3e92af51802I" _version;F"%9f3b95dd7ea3030dc35985c0a8020862