Skip to content
This repository was archived by the owner on Mar 16, 2023. It is now read-only.

Commit 429f7d0

Browse files
committed
Starting pageflip for #13.
1 parent 109d1b2 commit 429f7d0

3 files changed

Lines changed: 50 additions & 28 deletions

File tree

app.js

Lines changed: 45 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -274,35 +274,25 @@ $(document).on("ready",function()
274274

275275
if (displayShowing())
276276
{
277-
//Unselect text from doubleclick.
278-
window.getSelection().removeAllRanges()
279-
editor.setValue(note);
280-
switchDisplay("edit");
281-
//Put cursor at end of textarea.
282-
setTimeout(function()
283-
{
284-
editor.clearSelection();
285-
},1)
286-
277+
edit();
287278
}
288279
else
289280
{
290-
//unselect text from doubleclick.
291-
window.getSelection().removeAllRanges()
292-
note=editor.getValue();
293-
notes[current]=note;
294-
buildCache(current);
295-
$("#display").html(noteCache[current]);
296-
switchDisplay("display");
297-
//Move note (and cache) to the top!
298-
notes.splice(0, 0, notes.splice(current, 1)[0]);
299-
noteCache.splice(0, 0, noteCache.splice(current, 1)[0]);
300-
current=0;
301-
saveNotes();
302-
updateList();
303-
281+
display();
304282
}
305283
})
284+
285+
$("#pageflip").on("mousedown", function()
286+
{
287+
if (displayShowing())
288+
{
289+
edit();
290+
}
291+
else
292+
{
293+
display();
294+
}
295+
});
306296
});
307297

308298
//Very cusom Renderer.
@@ -312,6 +302,37 @@ function render(markdown)
312302
return html;
313303
}
314304

305+
function edit()
306+
{
307+
//Unselect text from doubleclick.
308+
window.getSelection().removeAllRanges()
309+
editor.setValue(note);
310+
switchDisplay("edit");
311+
//Put cursor at end of textarea.
312+
setTimeout(function()
313+
{
314+
editor.clearSelection();
315+
editor.focus();
316+
},1)
317+
}
318+
319+
function display()
320+
{
321+
//unselect text from doubleclick.
322+
window.getSelection().removeAllRanges()
323+
note=editor.getValue();
324+
notes[current]=note;
325+
buildCache(current);
326+
$("#display").html(noteCache[current]);
327+
switchDisplay("display");
328+
//Move note (and cache) to the top!
329+
notes.splice(0, 0, notes.splice(current, 1)[0]);
330+
noteCache.splice(0, 0, noteCache.splice(current, 1)[0]);
331+
current=0;
332+
saveNotes();
333+
updateList();
334+
}
335+
315336
function switchDisplay(mode)
316337
{
317338
if (mode=="edit")

index.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,9 +70,9 @@
7070
<paper-icon-button icon="content-copy"></paper-icon-button><paper-icon-button icon="close"></paper-icon-button>
7171
</div>
7272

73-
<!--<div id="pageflip">
73+
<div id="pageflip">
7474

75-
</div>-->
75+
</div>
7676

7777
<div id="find">
7878
<input class="mousetrap" type="text" id="findtext">

style.css

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,9 +82,10 @@
8282
position: fixed;
8383
bottom:0px;
8484
right:0px;
85-
width:50px;
86-
height:50px;
85+
width:25px;
86+
height:25px;
8787
background-color: #c0c0c0;
88+
z-index: 10;
8889
}
8990

9091

0 commit comments

Comments
 (0)