diff --git a/assets/images/thumbsdown.png b/assets/images/thumbsdown.png new file mode 100644 index 0000000..3468a8c Binary files /dev/null and b/assets/images/thumbsdown.png differ diff --git a/assets/images/thumbsup.png b/assets/images/thumbsup.png new file mode 100644 index 0000000..3248833 Binary files /dev/null and b/assets/images/thumbsup.png differ diff --git a/libs/jquery-loader.js b/assets/jquery-loader.js similarity index 100% rename from libs/jquery-loader.js rename to assets/jquery-loader.js diff --git a/libs/jquery/jquery-1.7.2.js b/assets/jquery/jquery-1.7.2.js similarity index 100% rename from libs/jquery/jquery-1.7.2.js rename to assets/jquery/jquery-1.7.2.js diff --git a/libs/jquery/jquery.js b/assets/jquery/jquery.js similarity index 100% rename from libs/jquery/jquery.js rename to assets/jquery/jquery.js diff --git a/libs/lawnchair/lawnchair.js b/assets/lawnchair/lawnchair.js similarity index 100% rename from libs/lawnchair/lawnchair.js rename to assets/lawnchair/lawnchair.js diff --git a/libs/qunit/qunit.css b/assets/qunit/qunit.css similarity index 100% rename from libs/qunit/qunit.css rename to assets/qunit/qunit.css diff --git a/libs/qunit/qunit.js b/assets/qunit/qunit.js similarity index 100% rename from libs/qunit/qunit.js rename to assets/qunit/qunit.js diff --git a/libs/require.js b/assets/require.js similarity index 100% rename from libs/require.js rename to assets/require.js diff --git a/grunt.coffee b/grunt.coffee index e56c91c..f6a41a8 100644 --- a/grunt.coffee +++ b/grunt.coffee @@ -81,7 +81,7 @@ module.exports = (grunt) -> appDir: "dist" baseUrl: "." paths: - jquery: "../libs/jquery/jquery-1.7.2" + jquery: "../assets/jquery/jquery-1.7.2" pragmas: doExclude: true modules: [ name: "priority" ] @@ -91,9 +91,10 @@ module.exports = (grunt) -> install: src: [ - "libs/jquery/jquery-1.7.2.js" - "libs/require.js" - "libs/lawnchair/lawnchair.js" + "assets/jquery/jquery-1.7.2.js" + "assets/require.js" + "assets/lawnchair/lawnchair.js" + "assets/images/*.png" ] dest: "dist" diff --git a/grunt.js b/grunt.js index b11bec7..f27ac1d 100644 --- a/grunt.js +++ b/grunt.js @@ -96,7 +96,7 @@ module.exports = function(grunt) { appDir: "dist", baseUrl: ".", paths: { - jquery: "../libs/jquery/jquery-1.7.2" + jquery: "../assets/jquery/jquery-1.7.2" }, pragmas: { doExclude: true @@ -111,7 +111,7 @@ module.exports = function(grunt) { findNestedDependencies: true }, install: { - src: ["libs/jquery/jquery-1.7.2.js", "libs/require.js", "libs/lawnchair/lawnchair.js"], + src: ["assets/jquery/jquery-1.7.2.js", "assets/require.js", "assets/lawnchair/lawnchair.js", "assets/images/*.png"], dest: "dist" }, mocha: { diff --git a/src/edit_priority_template.haml b/src/edit_priority_template.haml deleted file mode 100644 index 5c42a3f..0000000 --- a/src/edit_priority_template.haml +++ /dev/null @@ -1,3 +0,0 @@ -.edit-priority - .input.edit-priority-field(type="text" value="<%= p.name %>" data-for="<%= p.pos %>") - .button.delete-priority-field(data-for="<%= p.pos %>") diff --git a/src/edit_priority_tmpl.haml b/src/edit_priority_tmpl.haml new file mode 100644 index 0000000..90df047 --- /dev/null +++ b/src/edit_priority_tmpl.haml @@ -0,0 +1,3 @@ +.edit-priority + %input.edit-priority-field(type="text" value="<%= p.name %>" data-pos="<%= p.pos %>" data-ty="<%= type %>") + %button.delete-priority-field(data-for="<%= p.pos %>") diff --git a/src/index.haml b/src/index.haml index 2e8f5fb..c0b6498 100644 --- a/src/index.haml +++ b/src/index.haml @@ -16,10 +16,10 @@ .flow .row-fluid #leftbrain.span6 - %h1#prioritize(data-for="0") Today I Will Pay Attention To: + %h1#prioritize(data-pos="N" data-ty="priority") Today I Will Pay Attention To: #priorities #rightbrain.span6 - %h1#ignorize(data-for="0") Today I Will Ignore: + %h1#ignorize(data-pos="N" data-ty="ignore") Today I Will Ignore: #ignorities #message(style="display:none") diff --git a/src/priority.coffee b/src/priority.coffee index d4763c0..5922747 100644 --- a/src/priority.coffee +++ b/src/priority.coffee @@ -2,7 +2,7 @@ require.config paths: 'jquery': 'jquery-1.7.2' -require ['jquery', 'priority_tmpl', 'lawnchair'], ($, priority_template) -> +require ['jquery', 'priority_tmpl', 'edit_priority_tmpl', 'lawnchair'], ($, priority_template, edit_priority_template) -> class Prioritize @@ -12,45 +12,68 @@ require ['jquery', 'priority_tmpl', 'lawnchair'], ($, priority_template) -> @render() $('body').on 'click', @render - $('#prioritize').on 'click', (ev) => @editPriority(ev, 'priority') - $('#ignorize').on 'click', (ev) => @editPriority(ev, 'ignore') + $('#prioritize').on 'click', @editPriority + $('#ignorize').on 'click', @editPriority - editPriority: (ev, ty = 'parent') => - - - newPriority: (ty, ev) => + editPriority: (ev) => ev.stopPropagation() - return if $('.edit-priority').length > 0 - target = if ty == 'priority' then $('#priorities') else $('#ignorities') - target.append(edit_priorities_template({fur: ty})) - input = $('input.edit-priority-field', target) - maybeNewPrioritySave = (ev) => + # Only allow one edit-priority at a time! + return if $('.edit-priority').length > 0 + + tg = $(ev.currentTarget) + ty = tg.data('ty') + pos = tg.data('pos') + + # If the position is 'N', we're adding a new list item to + # the bottom of a list to be populated. + + if pos == 'N' + @priorities.push({name: '', cat: ty}) + pos = @priorities.length - 1 + (if ty == 'priority' then $('#priorities') else $('#ignorities')) + .append('
') + + # Replace the list item's contents with the editor's + # content. + li = $('#pos-' + pos) + li.html edit_priority_template + p: + name: @priorities[pos].name + pos: pos + type: ty + + input = $('input.edit-priority-field', li) + + maybePrioritySave = (ev) => prioritySave = => - @priorities.push({cat: ty, name: input.val()}) + @priorities[pos] = {cat: ty, name: input.val()} @save() code = if ev.keyCode then ev.keyCode else ev.which return prioritySave() if code == 13 return @cleanAndRender() if code == 27 - input.on 'keyup', maybeNewPrioritySave - $('.delete-priority-field', target).on 'click', @render + deletePriority = (ev) => + ev.stopPropagation() + @priorities[pos].name = "" + @save() + + input.on 'keyup', maybePrioritySave + $('.delete-priority-field', li).on 'click', deletePriority input.focus() save: -> + @clean() @repo.save {key: 'priorities', 'priorities': @priorities}, () => @render() clean: -> - @priorities = ({name: p.name, cat: p.cat} for p in @priorities when c.name.trim() != "") - - cleanAndRender: -> - @clean() - @render() + @priorities = ({name: p.name, cat: p.cat} for p in @priorities when p.name.trim() != "") save: -> + @clean() @repo.save {key: 'priorities', 'priorities': @priorities}, => @render() @@ -62,8 +85,9 @@ require ['jquery', 'priority_tmpl', 'lawnchair'], ($, priority_template) -> r.push({name: @priorities[i].name, cat: @priorities[i].cat, pos: i}) r - $('#priorities').html(priority_template({priorities: priority_enumerate('priority')})) - $('#ignorities').html(priority_template({priorities: priority_enumerate('ignore')})) + $('#priorities').html(priority_template({priorities: priority_enumerate('priority'), type: 'priority'})) + $('#ignorities').html(priority_template({priorities: priority_enumerate('ignore'), type: 'ignore'})) + $('.priorityc').bind 'click', @editPriority $ -> prioritize = new Lawnchair {name: 'Prioritize'}, -> diff --git a/src/priority_tmpl.haml b/src/priority_tmpl.haml index c7ed603..ed90423 100644 --- a/src/priority_tmpl.haml +++ b/src/priority_tmpl.haml @@ -1,5 +1,5 @@ %ul.priorities <% var i,l,p; for(i=0,l=priorities.length;i