]> _ Git - fluidbook-html5.git/commitdiff
wip #3962 @0:20
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Mon, 26 Oct 2020 17:23:37 +0000 (18:23 +0100)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Mon, 26 Oct 2020 17:23:37 +0000 (18:23 +0100)
js/libs/fluidbook/fluidbook.cache.js
js/libs/fluidbook/fluidbook.notes.js
style/notes.less

index 93e97eaef6c8a32498cdff401015b228957b7fb7..c2c472c1085e68cd9f3976507840da2e25f20a41 100644 (file)
@@ -73,6 +73,16 @@ FluidbookCache.prototype = {
             this._cache[key] = value;
         }
     },
+    unset: function (key) {
+        if (this._support) {
+            if (key.indexOf(this._prefix) !== 0) {
+                key = this._prefix + key;
+            }
+            localStorage.removeItem(key);
+        } else {
+            delete this._cache[key];
+        }
+    },
     find: function (search) {
         var $this = this;
         var res = {};
index 9c0cfbb043f03b6ad53b588eae8743c3f7cfdd07..3a869a9a99567640e4518056499178e29ad8f5ad 100644 (file)
@@ -21,6 +21,11 @@ FluidbookNotes.prototype = {
             $this.addNote();
             return false;
         });
+        $(document).on('click', '.note .remove', function () {
+            $this.removeNote($(this).closest('.note'));
+            return false;
+        });
+
         $(document).on('change keyup resize', '.note textarea', function () {
             $this.updateNote($(this).closest('.note').attr('id'));
         });
@@ -49,11 +54,17 @@ FluidbookNotes.prototype = {
     addNote: function () {
 
         var name = 'note_' + Math.round(Math.random() * 10000000);
-        $("#notesHolder").append('<div class="note" id="' + name + '" style="left:' + (0.5 * this.fluidbook.resize.fluidbookrect.width) + 'px;top:' + (0.5 * this.fluidbook.resize.fluidbookrect.height) + 'px;"><a href="#" class="remove"></a><textarea placeholder="' + __('your text') + '" name="' + name + '"></textarea></div>');
+        $("#notesHolder").append('<div class="note" id="' + name + '" style="left:' + (0.5 * this.fluidbook.resize.fluidbookrect.width) + 'px;top:' + (0.5 * this.fluidbook.resize.fluidbookrect.height) + 'px;"><a href="#" class="remove">' + getSpriteIcon('interface-close') + '</a><textarea placeholder="' + __('your text') + '" name="' + name + '"></textarea></div>');
         this.initNotes();
         this.createNote(name);
     },
 
+    removeNote: function (n) {
+        var id = $(n).attr('id');
+        $("#" + id).remove();
+        this._unsetNote(id);
+    },
+
     clearNotes: function () {
         $("#notesHolder .note").each(function () {
             interact('#' + $(this).attr('id')).unset();
@@ -86,7 +97,7 @@ FluidbookNotes.prototype = {
                     v.x++;
                 }
             }
-            $('#notesHolder').append('<div class="note" id="' + k + '" style="left:' + (v.x * w) + 'px;top:' + (v.y * $this.fluidbook.resize.fluidbookrect.height) + 'px;"><a href="#" class="remove"></a><textarea style="width:' + v.w + 'px;px;height:' + v.h + 'px;" placeholder="' + __('your text') + '" name="' + k + '">' + v.c + '</textarea></div>')
+            $('#notesHolder').append('<div class="note" id="' + k + '" style="left:' + (v.x * w) + 'px;top:' + (v.y * $this.fluidbook.resize.fluidbookrect.height) + 'px;"><a href="#" class="remove">' + getSpriteIcon('interface-close') + '</a><textarea style="width:' + v.w + 'px;px;height:' + v.h + 'px;" placeholder="' + __('your text') + '" name="' + k + '">' + v.c + '</textarea></div>')
         });
         this.initNotes();
     },
@@ -121,7 +132,6 @@ FluidbookNotes.prototype = {
                 }
             },
             onmove: function (event) {
-                console.log('//0');
                 $this.moveNote(event);
             },
             onend: function () {
@@ -140,7 +150,6 @@ FluidbookNotes.prototype = {
     },
     moveNote: function (event) {
         var target = event.target;
-        console.log(target, event.dx);
         this.setNotePosition(target, $(target).data('x') + event.dx, $(target).data('y') + event.dy);
     },
     getNotes: function (pageNr) {
@@ -197,5 +206,8 @@ FluidbookNotes.prototype = {
     _getNote: function (id) {
         return this.fluidbook.cache.get(id, this._defaultNote());
     },
+    _unsetNote: function (id) {
+        this.fluidbook.cache.unset(id);
+    }
 
 }
\ No newline at end of file
index c2b0e5a9b48ef108391d1ef6d7ff1008e677f1f0..f13b6dd4ce89fdbf2508381a76c3f48f4e9a5968 100644 (file)
     cursor: move;
     box-shadow: 0 0 3px 0 rgba(0, 0, 0, 0.25);
 
+    .remove {
+      position: absolute;
+      top: 5px;
+      right: 5px;
+      width: 14px;
+      height: 14px;
+      color:#b5b46c;
+    }
+
     textarea {
       font-family: @font;
       border: 0;
@@ -36,7 +45,7 @@
       max-height: 400px;
       min-width: 100px;
       min-height: 100px;
-      padding:0 15px 15px 0;
+      padding: 0 15px 15px 0;
     }
   }
 }
\ No newline at end of file