Files
edx-platform/cms/static/js/models/section.js
David Baumgold b6e3b0ee03 Refactor Backbone Notifications
Models are extraneous for something as temporary as a notifaction -- this change
moves all the configuration into the views, and removes the models entirely.
2013-06-18 10:20:31 -04:00

38 lines
981 B
JavaScript

CMS.Models.Section = Backbone.Model.extend({
defaults: {
"name": ""
},
validate: function(attrs, options) {
if (!attrs.name) {
return gettext("You must specify a name");
}
},
url: "/save_item",
toJSON: function() {
return {
id: this.get("id"),
metadata: {
display_name: this.get("name")
}
};
},
initialize: function() {
this.listenTo(this, "request", this.showNotification);
this.listenTo(this, "sync", this.hideNotification);
},
showNotification: function() {
if(!this.msg) {
this.msg = new CMS.Views.Notification.Saving({
title: gettext("Saving…"),
closeIcon: false,
minShown: 1250
});
}
this.msg.show();
},
hideNotification: function() {
if(!this.msg) { return; }
this.msg.hide();
}
});