2015-01-20 01:53:18 -05:00
|
|
|
var FFZ = window.FrankerFaceZ;
|
|
|
|
|
|
|
|
|
|
|
|
// --------------------
|
|
|
|
// Initialization
|
|
|
|
// --------------------
|
|
|
|
|
|
|
|
FFZ.prototype.setup_chatview = function() {
|
|
|
|
this.log("Hooking the Ember Chat view.");
|
|
|
|
|
|
|
|
var Chat = App.__container__.resolve('view:chat');
|
|
|
|
this._modify_cview(Chat);
|
|
|
|
|
|
|
|
// For some reason, this doesn't work unless we create an instance of the
|
|
|
|
// chat view and then destroy it immediately.
|
|
|
|
Chat.create().destroy();
|
|
|
|
|
|
|
|
// Modify all existing Chat views.
|
|
|
|
for(var key in Ember.View.views) {
|
|
|
|
if ( ! Ember.View.views.hasOwnProperty(key) )
|
|
|
|
continue;
|
|
|
|
|
|
|
|
var view = Ember.View.views[key];
|
|
|
|
if ( !(view instanceof Chat) )
|
|
|
|
continue;
|
|
|
|
|
|
|
|
this.log("Adding UI link manually to Chat view.", view);
|
2015-02-10 01:34:23 -05:00
|
|
|
try {
|
|
|
|
view.$('.textarea-contain').append(this.build_ui_link(view));
|
|
|
|
} catch(err) {
|
|
|
|
this.error("setup: build_ui_link: " + err);
|
|
|
|
}
|
2015-01-20 01:53:18 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// --------------------
|
|
|
|
// Modify Chat View
|
|
|
|
// --------------------
|
|
|
|
|
|
|
|
FFZ.prototype._modify_cview = function(view) {
|
|
|
|
var f = this;
|
|
|
|
|
|
|
|
view.reopen({
|
|
|
|
didInsertElement: function() {
|
|
|
|
this._super();
|
2015-02-10 01:34:23 -05:00
|
|
|
try {
|
|
|
|
this.$() && this.$('.textarea-contain').append(f.build_ui_link(this));
|
|
|
|
} catch(err) {
|
|
|
|
f.error("didInsertElement: build_ui_link: " + err);
|
|
|
|
}
|
2015-01-20 01:53:18 -05:00
|
|
|
},
|
|
|
|
|
|
|
|
willClearRender: function() {
|
|
|
|
this._super();
|
2015-02-10 01:34:23 -05:00
|
|
|
try {
|
|
|
|
this.$(".ffz-ui-toggle").remove();
|
|
|
|
} catch(err) {
|
|
|
|
f.error("willClearRender: remove ui link: " + err);
|
|
|
|
}
|
2015-01-20 01:53:18 -05:00
|
|
|
},
|
|
|
|
|
|
|
|
ffzUpdateLink: Ember.observer('controller.currentRoom', function() {
|
2015-02-10 01:34:23 -05:00
|
|
|
try {
|
|
|
|
f.update_ui_link();
|
|
|
|
} catch(err) {
|
|
|
|
f.error("ffzUpdateLink: update_ui_link: " + err);
|
|
|
|
}
|
2015-01-20 01:53:18 -05:00
|
|
|
})
|
|
|
|
});
|
2015-01-12 17:58:07 -05:00
|
|
|
}
|