//= require jquery
//= require jquery_ujs
//= require jquery-ui/sortable
//= require modernizr
// require foundation FOUNDATION 5 JAVASCRIPT IMPLEMENTATIONS AND EMBER ARE NOT COMPATIBLE, FOUNDATION IS TOO SIMPLISTIC AT THE MOMENT AND DESTROYS DOM EVENTS
//= require js-routes
//= require translations
//= require qwaiter
//= require ./qsupplier
//= require handlebars
//= require faye
//= require ./base
//= require qtip
//= require pickdate
//= require_directory .
//= require_self
//= require moment
var Qstorage = localStorage;

$.extend($translations.en, <%= I18n.t('supplier', locale: :en).to_json %>);
$.extend($translations.nl, <%= I18n.t('supplier', locale: :nl).to_json %>);

String.prototype.capitalize = function() {
    return this.charAt(0).toUpperCase() + this.slice(1);
}

var path_mapping = {
  user_root: '/user',
  join_occupied_table: '/user/join_occupied_table',
  list_products_for_table: '/user/list_products_for_table',
  list_products: '/user/list_products'
}
function redirect_to(mapping, variables){
  variables || (variables = {});
  var vars = []
  for(var name in variables){
    vars.push(name + '=' +variables[name])
  }
  window.location = path_mapping[mapping] + '?' + vars.join('&')
}
function currency(num) {
  return Qwaiter.currency(num);
}

Handlebars.registerHelper('t', function(tlocation) {
  return t(tlocation)
})
Handlebars.registerHelper('currency', function(price) {
  if(price.fn){
    price = price.fn(this);
  }
  if(typeof(price) == 'function'){
    price = price.call(this)
  }
  return new Handlebars.SafeString(currency(price))
})
