mirror of
https://github.com/rr-/szurubooru.git
synced 2025-07-17 08:26:24 +00:00
Added post notes presenter
This commit is contained in:
54
public_html/js/Presenters/PostNotesPresenter.js
Normal file
54
public_html/js/Presenters/PostNotesPresenter.js
Normal file
@ -0,0 +1,54 @@
|
||||
var App = App || {};
|
||||
App.Presenters = App.Presenters || {};
|
||||
|
||||
App.Presenters.PostNotesPresenter = function(
|
||||
util,
|
||||
promise) {
|
||||
|
||||
var post;
|
||||
var notes;
|
||||
var templates = {};
|
||||
var $target;
|
||||
|
||||
function init(params, loaded) {
|
||||
$target = params.$target;
|
||||
post = params.post;
|
||||
notes = params.notes || [];
|
||||
|
||||
promise.wait(util.promiseTemplate('post-notes'))
|
||||
.then(function(postNotesTemplate) {
|
||||
templates.postNotes = postNotesTemplate;
|
||||
render();
|
||||
loaded();
|
||||
}).fail(function() {
|
||||
console.log(arguments);
|
||||
loaded();
|
||||
});
|
||||
}
|
||||
|
||||
function addNewNote() {
|
||||
notes.push({left: 50, top: 50, width: 50, height: 50, text: '…'});
|
||||
}
|
||||
|
||||
function addNewNoteAndRender() {
|
||||
addNewNote();
|
||||
render();
|
||||
}
|
||||
|
||||
function render() {
|
||||
$target.html(templates.postNotes({post: post, notes: notes}));
|
||||
}
|
||||
|
||||
return {
|
||||
init: init,
|
||||
render: render,
|
||||
addNewNote: addNewNoteAndRender,
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
App.DI.register('postNotesPresenter', [
|
||||
'util',
|
||||
'promise'],
|
||||
App.Presenters.PostNotesPresenter);
|
||||
|
Reference in New Issue
Block a user