X-Git-Url: https://git.mdrn.pl/wolnelektury.git/blobdiff_plain/d9c51b94bfe6b1cda1790d57a9108b83c6e1643b..f7d8acded4a58d423035c5759f6dee9a34396959:/src/wolnelektury/static/js/book_text/pbox.js?ds=sidebyside diff --git a/src/wolnelektury/static/js/book_text/pbox.js b/src/wolnelektury/static/js/book_text/pbox.js new file mode 100644 index 000000000..816938cd1 --- /dev/null +++ b/src/wolnelektury/static/js/book_text/pbox.js @@ -0,0 +1,46 @@ +(function($){$(function(){ + + class PBox { + items = []; + + constructor(element) { + this.$element = element; + } + + addItem(item) { + this.items.unshift(item); + } + + clear() { + $("div", this.$element).remove(); + } + + showButton(item, text, cls) { + let btn = $("
"); + btn.addClass('zakladka-tool'); + btn.addClass('cls'); + btn.text(text); + btn.on('click', item.action); + this.$element.append(btn); + } + + // What's a p? + // We should open at a *marker*. + // And it's the marker that should know its context. + openAt(marker) { + this.marker = marker; + this.clear(); + $.each(this.items, (i, item) => { + item.update(this); + }); + } + + close() { + } + } + + $.pbox = new PBox($('#zakladka-box')); // TODO: rename id + + + +})})(jQuery);