summaryrefslogtreecommitdiff
path: root/StoneIsland/platforms/ios/www/js/lib/view
diff options
context:
space:
mode:
Diffstat (limited to 'StoneIsland/platforms/ios/www/js/lib/view')
-rw-r--r--StoneIsland/platforms/ios/www/js/lib/view/Serializable.js17
1 files changed, 17 insertions, 0 deletions
diff --git a/StoneIsland/platforms/ios/www/js/lib/view/Serializable.js b/StoneIsland/platforms/ios/www/js/lib/view/Serializable.js
index f9abd011..98aa8ce3 100644
--- a/StoneIsland/platforms/ios/www/js/lib/view/Serializable.js
+++ b/StoneIsland/platforms/ios/www/js/lib/view/Serializable.js
@@ -2,7 +2,9 @@ var SerializableView = View.extend({
events: {
"change select": "update_select",
+ "change [type=date]": "update_date",
"focus input": "focus_input",
+ "click .date-wrapper": "focus_date",
"submit form": "save",
},
@@ -21,6 +23,10 @@ var SerializableView = View.extend({
if ($el.attr("type") == "checkbox") {
$el.prop("checked", value)
}
+ if ($el.attr("type") == "date") {
+ $el.val( value )
+ this.update_date({ currentTarget: $el })
+ }
else if ($el.prop("tagName") == "SELECT") {
$el.val( value )
this.update_select({ currentTarget: $el })
@@ -57,12 +63,23 @@ var SerializableView = View.extend({
$(e.currentTarget).removeClass("error_hilite")
},
+ focus_date: function(e){
+ $(e.currentTarget).find("input").focus()
+ },
+
update_select: function(e){
var $target = $(e.currentTarget), value = $target.val()
var label = $target.find("option").filter(function(){ return this.value === value }).html()
$target.parent().addClass("picked")
$target.parent().find("span").html(label)
},
+
+ update_date: function(e){
+ var $target = $(e.currentTarget), value = $target.val()
+ var label = moment(value).format("MM/DD/YYYY")
+ $target.parent().addClass("picked")
+ $target.parent().find("span").html(label)
+ },
validate: function(data, errors){
var data = data || this.serialize()