Permalink
Browse files

Support confirmation_required button in simple input interface.

  • Loading branch information...
1 parent b855a78 commit 67dc944d0235287c4b1d3bf1806d67028b41d8b2 @kaznum committed Feb 9, 2012
@@ -1,3 +1,6 @@
+//= require toggle_confirmation_required
+//= require_self
+
global = this
global.itemNameObserver = (url) ->
$("#do_add_item #item_name").delayedObserver ->
@@ -1,3 +1,4 @@
//= require application
//= require ejs
//= require view
+//= require toggle_confirmation_required
@@ -0,0 +1,14 @@
+global = this
+global.toggleConfirmationRequired = (isRequired, item_id = null) ->
+ if item_id
+ label_selector = "#confirmation_required_label_" + item_id
+ field_selector = "#confirmation_required_" + item_id
+ else
+ label_selector = "#confirmation_required_label"
+ field_selector = "#confirmation_required"
+ if isRequired
+ $(label_selector).text("").attr "class", "item_confirmation_required"
+ $(field_selector).attr "value", "true"
+ else
+ $(label_selector).text("").attr "class", "item_confirmation_not_required"
+ $(field_selector).attr "value", "false"
@@ -68,3 +68,13 @@ body
#candidates
text-align: left
font-size: 0.8em
+
+.item_confirmation_required
+ color: orange
+ text-decoration: none
+ cursor: pointer
+
+.item_confirmation_not_required
+ color: silver
+ text-decoration: none
+ cursor: pointer
@@ -14,4 +14,7 @@
observerAddItemOnlyInput('#{@data[:authenticity_token]}');
bindSubmitInNewSimple();
$("#action_date").datepicker();
+ $("#confirmation_required_label").bind("click", function() {
+ toggleConfirmationRequired($("#confirmation_required").attr("value") != "true");
+ });
});
@@ -18,7 +18,7 @@
</div>
<div class="reset"></div>
<div class="vl">
- <input id="amount" name="amount" placeholder="金額" style="text-align: right;" type="text" />円 <input id="confirmation_required" name="confirmation_required" type="checkbox" value="true" />
+ <input id="amount" name="amount" placeholder="金額" style="text-align: right;" type="text" />円 <input id="confirmation_required" name="confirmation_required" type="hidden" value="false" /><span id="confirmation_required_label" class="item_confirmation_not_required">☆</span>
</div>
<div class="reset"></div>
<input id="only_add" name="only_add" type="hidden" value="true" />

0 comments on commit 67dc944

Please sign in to comment.