discourse/app/assets/javascripts/discourse/models/composer_message.js
2014-06-10 11:54:38 -04:00

35 lines
984 B
JavaScript

/**
Represents a pop up message displayed over the composer
@class ComposerMessage
@extends Ember.Object
@namespace Discourse
@module Discourse
**/
Discourse.ComposerMessage = Em.Object.extend({});
Discourse.ComposerMessage.reopenClass({
/**
Look for composer messages given the current composing settings.
@method find
@param {Discourse.Composer} composer The current composer
@returns {Discourse.ComposerMessage} the composer message to display (or null)
**/
find: function(composer) {
var data = { composerAction: composer.get('action') },
topicId = composer.get('topic.id'),
postId = composer.get('post.id');
if (topicId) { data.topic_id = topicId; }
if (postId) { data.post_id = postId; }
return Discourse.ajax('/composer-messages', { data: data }).then(function (messages) {
return messages.map(function (message) {
return Discourse.ComposerMessage.create(message);
});
});
}
});