Skip to content

Commit

Permalink
Merge pull request #34 from bicarbon8/issue-30
Browse files Browse the repository at this point in the history
fixes #30
  • Loading branch information
bicarbon8 committed Jan 10, 2018
2 parents b7be5d6 + 0aaad5a commit 1ec3c0c
Show file tree
Hide file tree
Showing 11 changed files with 51 additions and 35 deletions.
2 changes: 1 addition & 1 deletion dist/doc/TodoTxt.Task.html
Original file line number Diff line number Diff line change
Expand Up @@ -909,7 +909,7 @@ <h2><a href="index.html">Index</a></h2><h3>Classes</h3><ul><li><a href="TodoTxt.
<br clear="both">

<footer>
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.2.2</a> on Fri Oct 23 2015 17:02:31 GMT+0100 (IST)
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.2.2</a> on Wed Jan 10 2018 15:03:40 GMT-0000 (GMT)
</footer>

<script> prettyPrint(); </script>
Expand Down
2 changes: 1 addition & 1 deletion dist/doc/TodoTxt.Utils.html
Original file line number Diff line number Diff line change
Expand Up @@ -670,7 +670,7 @@ <h2><a href="index.html">Index</a></h2><h3>Classes</h3><ul><li><a href="TodoTxt.
<br clear="both">

<footer>
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.2.2</a> on Fri Oct 23 2015 17:02:31 GMT+0100 (IST)
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.2.2</a> on Wed Jan 10 2018 15:03:40 GMT-0000 (GMT)
</footer>

<script> prettyPrint(); </script>
Expand Down
2 changes: 1 addition & 1 deletion dist/doc/TodoTxt.html
Original file line number Diff line number Diff line change
Expand Up @@ -1578,7 +1578,7 @@ <h2><a href="index.html">Index</a></h2><h3>Classes</h3><ul><li><a href="TodoTxt.
<br clear="both">

<footer>
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.2.2</a> on Fri Oct 23 2015 17:02:31 GMT+0100 (IST)
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.2.2</a> on Wed Jan 10 2018 15:03:40 GMT-0000 (GMT)
</footer>

<script> prettyPrint(); </script>
Expand Down
2 changes: 1 addition & 1 deletion dist/doc/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ <h2><a href="index.html">Index</a></h2><h3>Classes</h3><ul><li><a href="TodoTxt.
<br clear="both">

<footer>
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.2.2</a> on Fri Oct 23 2015 17:02:31 GMT+0100 (IST)
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.2.2</a> on Wed Jan 10 2018 15:03:40 GMT-0000 (GMT)
</footer>

<script> prettyPrint(); </script>
Expand Down
2 changes: 1 addition & 1 deletion dist/doc/task.js.html
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,7 @@ <h2><a href="index.html">Index</a></h2><h3>Classes</h3><ul><li><a href="TodoTxt.
<br clear="both">

<footer>
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.2.2</a> on Fri Oct 23 2015 17:02:31 GMT+0100 (IST)
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.2.2</a> on Wed Jan 10 2018 15:03:40 GMT-0000 (GMT)
</footer>

<script> prettyPrint(); </script>
Expand Down
2 changes: 1 addition & 1 deletion dist/doc/todoTxt.js.html
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,7 @@ <h2><a href="index.html">Index</a></h2><h3>Classes</h3><ul><li><a href="TodoTxt.
<br clear="both">

<footer>
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.2.2</a> on Fri Oct 23 2015 17:02:31 GMT+0100 (IST)
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.2.2</a> on Wed Jan 10 2018 15:03:40 GMT-0000 (GMT)
</footer>

<script> prettyPrint(); </script>
Expand Down
2 changes: 1 addition & 1 deletion dist/doc/utils.js.html
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ <h2><a href="index.html">Index</a></h2><h3>Classes</h3><ul><li><a href="TodoTxt.
<br clear="both">

<footer>
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.2.2</a> on Fri Oct 23 2015 17:02:31 GMT+0100 (IST)
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.2.2</a> on Wed Jan 10 2018 15:03:40 GMT-0000 (GMT)
</footer>

<script> prettyPrint(); </script>
Expand Down
34 changes: 21 additions & 13 deletions dist/doc/view.js.html
Original file line number Diff line number Diff line change
Expand Up @@ -200,12 +200,17 @@ <h1 class="page-title">Source: objects/view.js</h1>
}
},

closeModal: function () {
TodoTxt.View.removeModal();
TodoTxt.View.refreshUi();
},

modalEventHandlers: [
{ el: function () { return document; }, ev: "keydown", fn: function (e) { TodoTxt.View.handleAltEnter(e); } },
{ el: function () { return document; }, ev: "keydown", fn: function (e) { TodoTxt.View.handleEsc(e); } },
{ el: function () { return document; }, ev: "keydown", fn: function (e) { TodoTxt.View.handleAltP(e); } },
{ el: function () { return document.querySelector('#modalEditSave-button'); }, ev: "click", fn: function (e) { TodoTxt.View.handleAltEnter(e); } },
{ el: function () { return document.querySelector('#modalEditClose-button'); }, ev: "click", fn: function (e) { TodoTxt.View.handleEsc(e); }, uc: true },
{ el: function () { return document.querySelector('#modalEditClose-button'); }, ev: "click", fn: function (e) { TodoTxt.View.closeModal(); } },
{ el: function () { return document.querySelector('#modalEditDelete-button'); }, ev: "click", fn: function (e) { TodoTxt.View.handleDeleteClick(e); } },
{ el: function () { return document.querySelector('#modalEditPreview-button'); }, ev: "click", fn: function (e) { TodoTxt.View.handleAltP(e); } },
],
Expand Down Expand Up @@ -353,23 +358,26 @@ <h1 class="page-title">Source: objects/view.js</h1>

handleEsc: function (e) {
if (e.keyCode === 27 || e.keyCode === 0) { // Esc
TodoTxt.View.removeModal();
TodoTxt.View.refreshUi();
TodoTxt.View.closeModal();
}
},

handleDeleteClick: function () {
var taskId = document.querySelector("#modalEditTaskId-input").value;
if (confirm(TodoTxt.Resources.get("DELETE_CONFIRM") + "\n\t\"" + TodoTxt.getTask(taskId).toString() + "\"")) {
if (TodoTxt.deleteTask(taskId)) {
TodoTxt.View.refreshUi();
try {
TodoTxt.View.removeModal();
} catch (e) {
// TODO: log this
var task = TodoTxt.getTask(taskId);
if (task)
{
if (confirm(TodoTxt.Resources.get("DELETE_CONFIRM") + "\n\t\"" + task.toString() + "\"")) {
if (TodoTxt.deleteTask(taskId)) {
TodoTxt.View.refreshUi();
try {
TodoTxt.View.removeModal();
} catch (e) {
// TODO: log this
}
} else {
// TODO: display error toast
}
} else {
// TODO: display error toast
}
}
},
Expand Down Expand Up @@ -741,7 +749,7 @@ <h2><a href="index.html">Index</a></h2><h3>Classes</h3><ul><li><a href="TodoTxt.
<br clear="both">

<footer>
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.2.2</a> on Fri Oct 23 2015 17:02:31 GMT+0100 (IST)
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.2.2</a> on Wed Jan 10 2018 15:03:40 GMT-0000 (GMT)
</footer>

<script> prettyPrint(); </script>
Expand Down
4 changes: 2 additions & 2 deletions dist/todoTxt.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/todoTxt.min.js.map

Large diffs are not rendered by default.

32 changes: 20 additions & 12 deletions js/objects/view.js
Original file line number Diff line number Diff line change
Expand Up @@ -173,12 +173,17 @@ TodoTxt.View = {
}
},

closeModal: function () {
TodoTxt.View.removeModal();
TodoTxt.View.refreshUi();
},

modalEventHandlers: [
{ el: function () { return document; }, ev: "keydown", fn: function (e) { TodoTxt.View.handleAltEnter(e); } },
{ el: function () { return document; }, ev: "keydown", fn: function (e) { TodoTxt.View.handleEsc(e); } },
{ el: function () { return document; }, ev: "keydown", fn: function (e) { TodoTxt.View.handleAltP(e); } },
{ el: function () { return document.querySelector('#modalEditSave-button'); }, ev: "click", fn: function (e) { TodoTxt.View.handleAltEnter(e); } },
{ el: function () { return document.querySelector('#modalEditClose-button'); }, ev: "click", fn: function (e) { TodoTxt.View.handleEsc(e); }, uc: true },
{ el: function () { return document.querySelector('#modalEditClose-button'); }, ev: "click", fn: function (e) { TodoTxt.View.closeModal(); } },
{ el: function () { return document.querySelector('#modalEditDelete-button'); }, ev: "click", fn: function (e) { TodoTxt.View.handleDeleteClick(e); } },
{ el: function () { return document.querySelector('#modalEditPreview-button'); }, ev: "click", fn: function (e) { TodoTxt.View.handleAltP(e); } },
],
Expand Down Expand Up @@ -326,23 +331,26 @@ TodoTxt.View = {

handleEsc: function (e) {
if (e.keyCode === 27 || e.keyCode === 0) { // Esc
TodoTxt.View.removeModal();
TodoTxt.View.refreshUi();
TodoTxt.View.closeModal();
}
},

handleDeleteClick: function () {
var taskId = document.querySelector("#modalEditTaskId-input").value;
if (confirm(TodoTxt.Resources.get("DELETE_CONFIRM") + "\n\t\"" + TodoTxt.getTask(taskId).toString() + "\"")) {
if (TodoTxt.deleteTask(taskId)) {
TodoTxt.View.refreshUi();
try {
TodoTxt.View.removeModal();
} catch (e) {
// TODO: log this
var task = TodoTxt.getTask(taskId);
if (task)
{
if (confirm(TodoTxt.Resources.get("DELETE_CONFIRM") + "\n\t\"" + task.toString() + "\"")) {
if (TodoTxt.deleteTask(taskId)) {
TodoTxt.View.refreshUi();
try {
TodoTxt.View.removeModal();
} catch (e) {
// TODO: log this
}
} else {
// TODO: display error toast
}
} else {
// TODO: display error toast
}
}
},
Expand Down

0 comments on commit 1ec3c0c

Please sign in to comment.