Skip to content

Instantly share code, notes, and snippets.

@ttepasse
Created November 7, 2012 15:59
Show Gist options
  • Save ttepasse/4032441 to your computer and use it in GitHub Desktop.
Save ttepasse/4032441 to your computer and use it in GitHub Desktop.
define [
"helper/HostApp"
"controller/Timeline"
],
(HostApp, Timeline) ->
class Mentions extends Timeline
constructor: ->
@initialized = yes
@action = "mentions"
@unreadMentions = 0
super
newStatus: (status) ->
super status
if @initalized and @action is "mentions"
@unreadMentions += status.length
HostApp.unreadMentions @unreadMentions
@initialized = yes
getNewData: (addToSearch = {}) ->
unless addToSearch["mentionedEntity"]
addToSearch["mentionedEntity"] = HostApp.stringForKey("entity");
super addToSearch
@ttepasse
Copy link
Author

ttepasse commented Nov 7, 2012

Der erzeugte Code, laut dem Online-Compiler:

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;
    };

define(["helper/HostApp", "controller/Timeline"], function(HostApp, Timeline) {
  var Mentions;
  return Mentions = (function(_super) {

    __extends(Mentions, _super);

    function Mentions() {
      this.initialized = true;
      this.action = "mentions";
      this.unreadMentions = 0;
      Mentions.__super__.constructor.apply(this, arguments);
    }

    Mentions.prototype.newStatus = function(status) {
      Mentions.__super__.newStatus.call(this, status);
      if (this.initalized && this.action === "mentions") {
        this.unreadMentions += status.length;
        HostApp.unreadMentions(this.unreadMentions);
      }
      return this.initialized = true;
    };

    Mentions.prototype.getNewData = function(addToSearch) {
      if (addToSearch == null) {
        addToSearch = {};
      }
      if (!addToSearch["mentionedEntity"]) {
        addToSearch["mentionedEntity"] = HostApp.stringForKey("entity");
      }
      return Mentions.__super__.getNewData.call(this, addToSearch);
    };

    return Mentions;

  })(Timeline);
});

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment