Files
edx-platform/lms/static/js/edxnotes/models/note.js
polesye c7153be040 TNL-213: Let Students Add Personal Notes to Course Content.
Co-Authored-By: Jean-Michel Claus <jmc@edx.org>
Co-Authored-By: Brian Talbot <btalbot@edx.org>
Co-Authored-By: Tim Babych <tim@edx.org>
Co-Authored-By: Oleg Marshev <oleg@edx.org>
Co-Authored-By: Chris Rodriguez <crodriguez@edx.org>
2015-01-14 23:34:11 +02:00

60 lines
1.6 KiB
JavaScript

;(function (define) {
'use strict';
define(['backbone', 'underscore.string'], function (Backbone) {
var NoteModel = Backbone.Model.extend({
defaults: {
'id': null,
'created': '',
'updated': '',
'user': '',
'usage_id': '',
'course_id': '',
'text': '',
'quote': '',
'ranges': [],
'unit': {
'display_name': '',
'url': '',
'location': ''
},
'section': {
'display_name': '',
'location': '',
'children': []
},
'chapter': {
'display_name': '',
'location': '',
'index': 0,
'children': []
},
// Flag indicating current state of the note: expanded or collapsed.
'is_expanded': false,
// Flag indicating whether `More` link should be shown.
'show_link': false
},
textSize: 300,
initialize: function () {
if (this.get('quote').length > this.textSize) {
this.set('show_link', true);
}
},
getNoteText: function () {
var message = this.get('quote');
if (!this.get('is_expanded') && this.get('show_link')) {
message = _.str.prune(message, this.textSize);
}
return message;
}
});
return NoteModel;
});
}).call(this, define || RequireJS.define);