It works, but I'm not happy with the bootstrap hackery. Must fix.

This commit is contained in:
Elf M. Sternberg 2012-07-15 15:50:35 -07:00
parent f4090dd0d2
commit 738ea5cc8d
17 changed files with 130 additions and 35 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.5 KiB

BIN
assets/images/thumbsup.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.3 KiB

View File

@ -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"

View File

@ -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: {

View File

@ -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 %>")

View File

@ -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 %>")

View File

@ -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")

View File

@ -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('<li class="priority" id="pos-' + pos + '"></li>')
# 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'}, ->

View File

@ -1,5 +1,5 @@
%ul.priorities
<% var i,l,p; for(i=0,l=priorities.length;i<l;++i) { p=priorities[i]; %>
%li.task
.taskc <%= p.name %>
%li.priority(id="pos-<%= p.pos %>")
.priorityc(data-ty="<%= type %>" data-pos="<%= p.pos %>") <%= p.name %>
<% } %>

View File

@ -96,6 +96,76 @@ body {
@fluidGridColumnWidth: 6.382978723%;
@fluidGridGutterWidth: 2.127659574%;
@baseFontSize: 13px;
@baseLineHeight: 18px;
@inputBackground: #fff;
@inputBorder: #ccc;
@inputBorderRadius: 3px;
@inputDisabledBackground: #eee;
.transition(@transition) {
-webkit-transition: @transition;
-moz-transition: @transition;
-ms-transition: @transition;
-o-transition: @transition;
transition: @transition;
}
// Border Radius
.border-radius(@radius) {
-webkit-border-radius: @radius;
-moz-border-radius: @radius;
border-radius: @radius;
}
// Drop shadows
.box-shadow(@shadow) {
-webkit-box-shadow: @shadow;
-moz-box-shadow: @shadow;
box-shadow: @shadow;
}
// Inputs, Textareas, Selects
input,
textarea,
select,
.uneditable-input {
display: inline-block;
width: 210px;
height: @baseLineHeight;
padding: 4px;
margin-bottom: 9px;
font-size: @baseFontSize;
line-height: @baseLineHeight;
color: #555;
background-color: @inputBackground;
border: 1px solid @inputBorder;
.border-radius(@inputBorderRadius);
}
// Help out input buttons
input[type="button"],
input[type="reset"],
input[type="submit"] {
width: auto;
height: auto;
}
input,
textarea {
.box-shadow(inset 0 1px 1px rgba(0,0,0,.075));
@transition: border linear .2s, box-shadow linear .2s;
.transition(@transition);
}
input:focus,
textarea:focus {
border-color: rgba(82,168,236,.8);
outline: 0;
outline: thin dotted \9; /* IE6-9 */
.box-shadow(~"inset 0 1px 1px rgba(0,0,0,.075), 0 0 8px rgba(82,168,236,.6)");
}
#grid {
.core (@gridColumnWidth, @gridGutterWidth) {