}
});
-
function MarkdownEditor() {
this.mobileFirst = FLUIDBOOK_DATA.settings.mobileNavigationType === 'mobilefirst';
this.single = ['mobilefirst', 'portrait'].indexOf(FLUIDBOOK_DATA.settings.mobileNavigationType) >= 0 || FLUIDBOOK_DATA.settings.pages <= 1;
this.rasterizePages = this.splitPages(FLUIDBOOK_DATA.settings.rasterizePages);
this.vectorPages = this.splitPages(FLUIDBOOK_DATA.settings.vectorPages);
this.noCache = '?t=' + (new Date(FLUIDBOOK_DATA.composition_updated_at)).getTime();
- this.currentPage = Math.max(0,parseInt(window.location.hash.substring(1))) || 0;
+ this.currentPage = Math.max(1,parseInt(window.location.hash.substring(1))) || 1;
this.editor = null;
this.init()
}
MarkdownEditor.prototype = {
init: function() {
+ const $this = this
this.markdown();
- this.loadPage(2)
+ this.loadPage()
+
+ $(window).on('hashchange', function () {
+ /*if ($this.maskHashEvent) {
+ return;
+ }*/
+ $this.currentPage = Math.max(1,parseInt(window.location.hash.substring(1))) || 1
+ $this.loadPage();
+ });
+
+ $(window).on('mousemove', function (e) {
+ let x = e.pageX;
+ let w = $(this).innerWidth()
+ let ratio= Math.min(33.33, x / w * 100)
+
+ if($(".handle").hasClass("dragging")) {
+ requestAnimationFrame(function() {
+ $("#markdown-preview").width(ratio+'%')
+ })
+ }
+ })
+
+ $(document).on('mousedown', '.handle', function (e) {
+ $(this).addClass("dragging")
+ })
+
+ $(document).on('mouseup', function (e) {
+ $(".handle").removeClass("dragging")
+ })
},
loadPage: function() {
- this.loadPageHtml(this.currentPage, 'left');
if (!this.single) {
- this.loadPageHtml(this.currentPage + 1, 'right');
+ this.loadPageHtml(this.currentPage);
}
this.setContentMarkdown()
},
- loadPageHtml: function(p,side) {
- const container = document.querySelector("#markdown-page-"+side)
+ loadPageHtml: function(p) {
+ const container = document.querySelector("#markdown-page")
var imageFormat = FLUIDBOOK_DATA.settings.imageFormat ?? 'jpg';
var c = '<div class="contents">';
},
setContentMarkdown: function() {
- if(this.currentPage === 0) this.currentPage = 1
const $this = this
$.ajax({
url: '/fluidbook-publication/' + FLUIDBOOK_DATA.id +'/markdown',
});
this.editor.getMarkdown();
+ },
+
+ moveHandle: function () {
+ var $this = this;
+ $(".linkeditor-sidebar .handle.dragging")
}
/*isSpecialPage: function (page) {
@section('content')
<div class="markdown-editor">
+ <div class="markdown-preview-nav"></div>
<div id="markdown-preview" class="markdown-container">
<div class="markdown-wrapper">
- <div draggable="false" class="markdown-page" id="markdown-page-left"></div>
- <div draggable="false" class="markdown-page" id="markdown-page-right"></div>
+ <div draggable="false" class="markdown-page" id="markdown-page"></div>
</div>
</div>
- <div id="editor" class="markdown-editor-container"></div>
+ <div class="markdown-editor-container">
+ <div id="editor"></div>
+ <div class="handle"></div>
+ </div>
</div>
@endsection