Files
edx-platform/lms/static/js/views/message.js
muhammad-ammar c9b87aa099 Unit Bookmarks List View
TNL-1958
2015-12-17 22:07:31 +05:00

43 lines
1.3 KiB
JavaScript

;(function (define, undefined) {
'use strict';
define([
'gettext', 'jquery', 'underscore', 'backbone', 'text!templates/fields/message_banner.underscore'
], function (gettext, $, _, Backbone, messageBannerTemplate) {
var MessageBannerView = Backbone.View.extend({
initialize: function (options) {
if (_.isUndefined(options)) {
options = {};
}
this.options = _.defaults(options, {urgency: 'high', type: ''});
},
render: function () {
if (_.isUndefined(this.message) || _.isNull(this.message)) {
this.$el.html('');
} else {
this.$el.html(this.template({
message: this.message,
icon: this.icon
}));
}
return this;
},
showMessage: function (message, icon) {
this.message = message;
this.icon = icon;
this.render();
},
hideMessage: function () {
this.message = null;
this.render();
}
});
return MessageBannerView;
});
}).call(this, define || RequireJS.define);