Add weekday selection and client side date formatting

This commit is contained in:
2013-02-19 09:32:24 +01:00
parent 43073e10f8
commit c5f6813765
17 changed files with 89 additions and 12 deletions
+1 -11
View File
@@ -1,14 +1,3 @@
// This is a manifest file that'll be compiled into application.js, which will include all the files
// listed below.
//
// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
// or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path.
//
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
// the compiled file.
//
// WARNING: THE FIRST BLANK LINE MARKS THE END OF WHAT'S TO BE PROCESSED, ANY BLANK LINE SHOULD
// GO AFTER THE REQUIRES BELOW.
//= require jquery
//= require jquery_ujs
//= require jquery-ui
@@ -32,6 +21,7 @@
//= require qwaiter
//= require_directory .
//= require_self
//= require moment
var Qstorage = localStorage;
String.prototype.capitalize = function() {
return this.charAt(0).toUpperCase() + this.slice(1);
@@ -1,5 +1,16 @@
$( ->
$('.week-day-select').each( (i)->
select = $(this)
container = select.siblings('.btn-group')
toggle = $('<button type="button" class="btn"></button>')
toggle.attr('data-t', 'product_category.week_days.abbreviation.'+select.data('day'))
toggle.addClass('active') if select.val() == '1'
container.append(toggle)
toggle.click( -> select.val(Math.abs(select.val() - 1)))
)
# GOOGLE LOCATION PICKER
$("input.location_picker").each( (i)->
return if typeof(google) == 'undefined'
location_input = $(this)
map_div = $('<div>').addClass("location_picker_map")
@@ -13,6 +13,7 @@ var $translations = {
}
}
$transformation_mappings = {
downcase: 'toLowerCase',
upcase: 'toUpperCase'
@@ -62,4 +63,8 @@ function setTranslations(selector){
}else{
$('[data-t]').each(function(){$(this).text(t($(this).data('t'),$(this).data('tAttributes')))})
}
moment.lang($locale);
$('[data-time]').each(function(){
$(this).text(moment($(this).data('time')).format($(this).data('timeFormat') || 'dd D HH:MM'))
})
}