Positioning the modal editor in the position of the original note

This commit is contained in:
Matias De lellis
2016-05-21 16:44:19 -03:00
parent cdc2d1c7eb
commit bee3d91690
3 changed files with 53 additions and 57 deletions

View File

@@ -153,10 +153,10 @@ View.prototype = {
$('.notes-grid').isotope({ filter: '*'});
},
editNote: function (id) {
var modal = $('#modal-note-editable');
var modaltitle = $('#modal-note-editable #title-editable');
var modalcontent = $('#modal-note-editable #content-editable');
var modalnote = $("#modal-note-editable .quicknote");
var modal = $('#modal-note-div');
var modaltitle = $('#modal-note-div #title-editable');
var modalcontent = $('#modal-note-div #content-editable');
var modalnote = $("#modal-note-div .quicknote");
var note = $('.notes-grid [data-id=' + id + ']').parent();
@@ -174,15 +174,24 @@ View.prototype = {
modalcontent.html(content);
modalnote.css("background-color", color);
/* Positioning the modal to the original size */
$(".modal-content").css({
"position" : "absolute",
"left" : note.offset().left,
"top" : note.offset().top,
"width" : note.width(),
"min-height": note.height(),
"height:" : "auto"
});
modal.removeClass("hide-modal-note");
modal.addClass("show-modal-note");
modalcontent.focus();
},
cancelEdit: function () {
var modal = $('#modal-note-editable');
var modaltitle = $('#modal-note-editable #title-editable');
var modalcontent = $('#modal-note-editable #content-editable');
var modalnote = $("#modal-note-editable .quicknote");
var modal = $('#modal-note-div');
var modaltitle = $('#modal-note-div #title-editable');
var modalcontent = $('#modal-note-dive #content-editable');
var modalnote = $("#modal-note-div .quicknote");
this._notes.unsetActive();
this.showAll();
@@ -213,10 +222,10 @@ View.prototype = {
});
// Handle click event to open note.
var modal = $('#modal-note-editable');
var modaltitle = $('#modal-note-editable #title-editable');
var modalcontent = $('#modal-note-editable #content-editable');
var modalnote = $("#modal-note-editable .quicknote");
var modal = $('#modal-note-div');
var modaltitle = $('#modal-note-div #title-editable');
var modalcontent = $('#modal-note-div #content-editable');
var modalnote = $("#modal-note-div .quicknote");
// Show delete icon on hover.
$(".quicknote").hover(function() {
@@ -235,6 +244,11 @@ View.prototype = {
self.editNote(id);
});
// Cancel when click outside the modal.
$(".modal-note-background").click(function () {
self.cancelEdit();
});
// Cancel with escape key
$(document).keyup(function(event) {
if (event.keyCode == 27) {
@@ -341,16 +355,13 @@ View.prototype = {
});
});
// load a note
// show a note
$('#app-navigation .note > a').click(function () {
var id = parseInt($(this).parent().data('id'), 10);
$('.notes-grid').isotope({ filter: function() {
var itemId = parseInt($(this).children().data('id'), 10);
return id == itemId;
} });
self.editNote(id);
// self._notes.load(id);
});
// Handle colors.