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

Commit

Permalink
Added delete note functionality.
Browse files Browse the repository at this point in the history
and cleaned up some code!
  • Loading branch information
octalmage committed Aug 23, 2014
1 parent 97602f4 commit ed4f715
Show file tree
Hide file tree
Showing 52 changed files with 2,752 additions and 1,091 deletions.
75 changes: 66 additions & 9 deletions app.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ var store;
var notes=new Array(), note="";
var current=0;
var defaultnote=["#Welcome to Marknote\n**Clean, easy, markdown notes.**\nDouble click to get started!"];
var newnotetemplate="# New note";


//Custom Renderer
Expand Down Expand Up @@ -68,6 +69,21 @@ $(document).on("click", "#newNote", function()
newNote();
})

$(document).on("mousemove", function(e)
{
if (!displayShowing())
{
return;
}
if (e.pageX>(window.innerWidth-200) && e.pageY < 50)
{
$("#actions").show();
}
else
{
$("#actions").hide();
}
});

$(document).on("ready",function()
{
Expand Down Expand Up @@ -99,23 +115,29 @@ store.exists("notes", function (s)

}
});



updateList();
note=notes[current];
markdown=marked(note, { renderer: renderer });

$("#display").html(markdown);


$("paper-icon-button[icon='close']").on("click", function()
{
deleteNote(current);
});

$("#note").on("dblclick", function()
{
if ($("#edit").css("display")=="none")
if (displayShowing())
{
//Unselect text from doubleclick.
window.getSelection().removeAllRanges()
//$("#noteedit").val(note);
editor.setValue(note);
$("#display").css("display","none");
$("#edit").css("display", "block");

switchDisplay("edit");
//Put cursor at end of textarea.
setTimeout(function()
{
Expand All @@ -134,19 +156,37 @@ store.exists("notes", function (s)
note=editor.getValue();
markdown=marked(note);
$("#display").html(markdown);
$("#edit").css("display", "none");
$("#display").css("display","block");
switchDisplay("display");
notes[current]=note;
//Move note to the top!
notes.splice(0, 0, notes.splice(current, 1)[0]);
current=0;
store.save({key:'notes', notes:notes});
saveNotes();
updateList()

}
})
});

function switchDisplay(mode)
{
if (mode=="edit")
{
$("#display").css("display","none");
$("#edit").css("display", "block");
}
else if (mode=="display")
{
$("#edit").css("display", "none");
$("#display").css("display","block");
}
}

function saveNotes()
{
return store.save({key:'notes', notes:notes});
}

function updateList()
{
$("#list").html("");
Expand All @@ -155,7 +195,24 @@ function updateList()
addNote(notes[i].split("\n")[0], i);
}
}

function deleteNote(id)
{
notes.splice(current, 1);

if (current>(notes.length-1))
{
current-=1;
}
saveNotes();
updateList();
loadNote(current);
}

function displayShowing()
{
return $("#edit").css("display")=="none";
}

function addNote(note, id)
{
Expand All @@ -173,7 +230,7 @@ function loadNote(id)
}
function newNote()
{
notes.push("# New note");
notes.push(newnotetemplate);
updateList();
loadNote(notes.length-1);
}
8 changes: 4 additions & 4 deletions components/core-component-page/.bower.json
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@
"polymer": "Polymer/polymer#>=0.3.0 <1.0.0"
},
"homepage": "https://github.com/Polymer/core-component-page",
"version": "0.3.3",
"_release": "0.3.3",
"version": "0.3.5",
"_release": "0.3.5",
"_resolution": {
"type": "version",
"tag": "0.3.3",
"commit": "31ff29fa197310d0d9e7e043c0dab8d0f9a511cf"
"tag": "0.3.5",
"commit": "87617aa1282994eecf5f1f57ef149155ed96f7f1"
},
"_source": "git://github.com/Polymer/core-component-page.git",
"_target": ">=0.3.0 <1.0.0",
Expand Down
2 changes: 1 addition & 1 deletion components/core-component-page/README.md
100755 → 100644
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
core-component-page
===================

See the [component page](http://polymer.github.io/core-component-page) for more information.
See the [component page](http://polymer-project.org/docs/elements/core-elements.html#core-component-page) for more information.

Note: this is the vulcanized version of [`core-component-page-dev`](https://github.com/Polymer/core-component-page-dev) (the source).
Empty file modified components/core-component-page/bowager-logo.png
100755 → 100644
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file modified components/core-component-page/bower.json
100755 → 100644
Empty file.
3,283 changes: 2,305 additions & 978 deletions components/core-component-page/core-component-page.html
100755 → 100644

Large diffs are not rendered by default.

Empty file modified components/core-component-page/demo.html
100755 → 100644
Empty file.
1 change: 0 additions & 1 deletion components/core-component-page/index.html
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
<head>

<script src="../platform/platform.js"></script>
<link rel="import" href="../polymer/polymer.html">
<link rel="import" href="../core-component-page/core-component-page.html">

</head>
Expand Down
8 changes: 4 additions & 4 deletions components/core-meta/.bower.json
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@
"polymer": "Polymer/polymer#>=0.3.0 <1.0.0"
},
"homepage": "https://github.com/Polymer/core-meta",
"version": "0.3.3",
"_release": "0.3.3",
"version": "0.3.5",
"_release": "0.3.5",
"_resolution": {
"type": "version",
"tag": "0.3.3",
"commit": "038b6c9752c923ecd8c114a06eff51d2dcab90ed"
"tag": "0.3.5",
"commit": "4d2a4cf723403a6ee0575e3863be843648db32ec"
},
"_source": "git://github.com/Polymer/core-meta.git",
"_target": ">=0.3.0 <1.0.0",
Expand Down
2 changes: 1 addition & 1 deletion components/core-meta/README.md
100755 → 100644
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
core-meta
=========

See the [component page](http://polymer.github.io/core-meta) for more information.
See the [component page](http://polymer-project.org/docs/elements/core-elements.html#core-meta) for more information.
Empty file modified components/core-meta/bower.json
100755 → 100644
Empty file.
4 changes: 2 additions & 2 deletions components/core-meta/core-meta.html
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@

<link rel="import" href="../polymer/polymer.html">

<polymer-element name="core-meta" attributes="list label type" hidden>
<polymer-element name="core-meta" attributes="label type" hidden>
<script>

(function() {
Expand Down Expand Up @@ -118,7 +118,7 @@
/**
* Returns a list of all meta-data elements with the same type.
*
* @attribute list
* @property list
* @type array
* @default []
*/
Expand Down
Empty file modified components/core-meta/demo.html
100755 → 100644
Empty file.
1 change: 0 additions & 1 deletion components/core-meta/index.html
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
<head>

<script src="../platform/platform.js"></script>
<link rel="import" href="../polymer/polymer.html">
<link rel="import" href="../core-component-page/core-component-page.html">

</head>
Expand Down
10 changes: 5 additions & 5 deletions components/core-overlay/.bower.json
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@
"core-transition": "Polymer/core-transition#>=0.3.0 <1.0.0"
},
"homepage": "https://github.com/Polymer/core-overlay",
"version": "0.3.3",
"_release": "0.3.3",
"version": "0.3.5",
"_release": "0.3.5",
"_resolution": {
"type": "version",
"tag": "0.3.3",
"commit": "f8480dbc18cd574607774425f500b441f6771316"
"tag": "0.3.5",
"commit": "4912afb4418ce4a173b37e09020d6622870054e2"
},
"_source": "git://github.com/Polymer/core-overlay.git",
"_target": "*",
"_target": ">=0.3.0 <1.0.0",
"_originalSource": "Polymer/core-overlay"
}
2 changes: 1 addition & 1 deletion components/core-overlay/README.md
100755 → 100644
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
core-overlay
============

See the [component page](http://polymer.github.io/core-overlay) for more information.
See the [component page](http://polymer-project.org/docs/elements/core-elements.html#core-overlay) for more information.
Empty file modified components/core-overlay/bower.json
100755 → 100644
Empty file.
Empty file modified components/core-overlay/core-key-helper.html
100755 → 100644
Empty file.
Empty file modified components/core-overlay/core-overlay-layer.html
100755 → 100644
Empty file.
48 changes: 31 additions & 17 deletions components/core-overlay/core-overlay.html
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -270,10 +270,10 @@ <h2>Dialog</h2>
if (transition) {
transition.teardown(old);
} else {
old.style.position = null;
old.style.outline = null;
old.style.position = '';
old.style.outline = '';
}
old.style.display = null;
old.style.display = '';
}
},

Expand All @@ -284,7 +284,7 @@ <h2>Dialog</h2>
return;
}
this.target.__overlaySetup = true;
this.target.style.display = null;
this.target.style.display = '';
var transition = this.getTransition();
if (transition) {
transition.setup(this.target);
Expand All @@ -302,14 +302,15 @@ <h2>Dialog</h2>
},

openedChanged: function() {
this.transitioning = true;
this.ensureTargetSetup();
this.prepareRenderOpened();
// continue styling after delay so display state can change
// without aborting transitions
// note: we wait a full frame so that transition changes executed
// during measuring do not cause transition
this.async(function() {
this.target.style.display = null;
this.target.style.display = '';
this.async('renderOpened');
});
this.fire('core-overlay-open', this.opened);
Expand All @@ -335,7 +336,7 @@ <h2>Dialog</h2>
// TODO(sorvell): force SD Polyfill to render
forcePolyfillRender(this.target);
if (!this._shouldPosition) {
this.target.style.position = 'static';
this.target.style.position = 'absolute';
var computed = getComputedStyle(this.target);
var t = (computed.top === 'auto' && computed.bottom === 'auto');
var l = (computed.left === 'auto' && computed.right === 'auto');
Expand Down Expand Up @@ -371,6 +372,7 @@ <h2>Dialog</h2>
if (e && e.target !== this.target) {
return;
}
this.transitioning = false;
if (!this.opened) {
this.resetTargetDimensions();
this.target.style.display = 'none';
Expand Down Expand Up @@ -414,13 +416,13 @@ <h2>Dialog</h2>
prepareMeasure: function(target) {
target.style.transition = target.style.webkitTransition = 'none';
target.style.transform = target.style.webkitTransform = 'none';
target.style.display = null;
target.style.display = '';
},

finishMeasure: function(target) {
target.style.display = 'none';
target.style.transform = target.style.webkitTransform = null;
target.style.transition = target.style.webkitTransition = null;
target.style.transform = target.style.webkitTransform = '';
target.style.transition = target.style.webkitTransition = '';
},

getTransition: function() {
Expand All @@ -437,7 +439,11 @@ <h2>Dialog</h2>
focusNode.focus();
} else {
focusNode.blur();
focusOverlay();
if (currentOverlay() == this) {
console.warn('Current core-overlay is attempting to focus itself as next! (bug)');
} else {
focusOverlay();
}
}
},

Expand Down Expand Up @@ -480,9 +486,9 @@ <h2>Dialog</h2>
},

resetTargetDimensions: function() {
this.target.style.top = this.target.style.left = null;
this.target.style.right = this.target.style.bottom = null;
this.target.style.width = this.target.style.height = null;
this.target.style.top = this.target.style.left = '';
this.target.style.right = this.target.style.bottom = '';
this.target.style.width = this.target.style.height = '';
this._shouldPosition = null;
},

Expand Down Expand Up @@ -556,14 +562,14 @@ <h2>Dialog</h2>
addElementListener: function(node, event, methodName, capture) {
var fn = this._makeBoundListener(methodName);
if (node && fn) {
node.addEventListener(event, fn, capture);
Polymer.addEventListener(node, event, fn, capture);
}
},

removeElementListener: function(node, event, methodName, capture) {
var fn = this._makeBoundListener(methodName);
if (node && fn) {
node.removeEventListener(event, fn, capture);
Polymer.removeEventListener(node, event, fn, capture);
}
},

Expand Down Expand Up @@ -605,7 +611,7 @@ <h2>Dialog</h2>
var i = overlays.indexOf(overlay);
if (i >= 0) {
overlays.splice(i, 1);
setZ(overlay, null);
setZ(overlay, '');
}
}

Expand Down Expand Up @@ -637,7 +643,15 @@ <h2>Dialog</h2>

function focusOverlay() {
var current = currentOverlay();
if (current) {
// We have to be careful to focus the next overlay _after_ any current
// transitions are complete (due to the state being toggled prior to the
// transition). Otherwise, we risk infinite recursion when a transitioning
// (closed) overlay becomes the current overlay.
//
// NOTE: We make the assumption that any overlay that completes a transition
// will call into focusOverlay to kick the process back off. Currently:
// transitionend -> applyFocus -> focusOverlay.
if (current && !current.transitioning) {
current.applyFocus();
}
}
Expand Down
Loading

0 comments on commit ed4f715

Please sign in to comment.