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>
This commit is contained in:
59
lms/static/js/edxnotes/models/note.js
Normal file
59
lms/static/js/edxnotes/models/note.js
Normal file
@@ -0,0 +1,59 @@
|
||||
;(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);
|
||||
Reference in New Issue
Block a user