use i18n-js
This commit is contained in:
parent
a9dff7f1df
commit
64a597c689
10 changed files with 33 additions and 24 deletions
|
|
@ -9,6 +9,8 @@
|
|||
//= require bootstrap-datepicker/locales/bootstrap-datepicker.nl
|
||||
//= require jquery.observe_field
|
||||
//= require rails.validations
|
||||
//= require i18n
|
||||
//= require i18n/translations
|
||||
//= require_self
|
||||
//= require ordering
|
||||
//= require stupidtable
|
||||
|
|
|
|||
|
|
@ -7,9 +7,6 @@
|
|||
|
||||
var modified = false // indicates if anything has been clicked on this page
|
||||
var groupBalance = 0; // available group money
|
||||
var currencySeparator = "."; // default decimal separator
|
||||
var currencyPrecision = 2; // default digits behind comma
|
||||
var currencyUnit = "€"; // default currency
|
||||
var minimumBalance = 0; // minimum group balance for the order to be succesful
|
||||
var toleranceIsCostly = true; // default tolerance behaviour
|
||||
var isStockit = false; // Wheter the order is from stock oder normal supplier
|
||||
|
|
@ -23,12 +20,6 @@ var toleranceOthers = new Array();
|
|||
var itemsAllocated = new Array(); // how many items the group has been allocated and should definitely get
|
||||
var quantityAvailable = new Array(); // stock_order. how many items are currently in stock
|
||||
|
||||
function setCurrencyFormat(separator, precision, unit) {
|
||||
currencySeparator = separator;
|
||||
currencyPrecision = precision;
|
||||
currencyUnit = unit;
|
||||
}
|
||||
|
||||
function setToleranceBehaviour(value) {
|
||||
toleranceIsCostly = value;
|
||||
}
|
||||
|
|
@ -124,7 +115,7 @@ function update(item, quantity, tolerance) {
|
|||
} else {
|
||||
itemTotal[item] = price[item] * (Number(quantity));
|
||||
}
|
||||
$('#price_' + item + '_display').html(asMoney(itemTotal[item]));
|
||||
$('#price_' + item + '_display').html(I18n.l("currency", itemTotal[item]));
|
||||
|
||||
// update missing units
|
||||
var missing_units = unit[item] - (((quantityOthers[item] + Number(quantity)) % unit[item]) + Number(tolerance) + toleranceOthers[item])
|
||||
|
|
@ -137,10 +128,6 @@ function update(item, quantity, tolerance) {
|
|||
updateBalance();
|
||||
}
|
||||
|
||||
function asMoney(amount) {
|
||||
return String(amount.toFixed(currencyPrecision)).replace(/\./, currencySeparator) + ' ' + currencyUnit;
|
||||
}
|
||||
|
||||
function calcUnits(unitSize, quantity, tolerance) {
|
||||
var units = Math.floor(quantity / unitSize)
|
||||
var remainder = quantity % unitSize
|
||||
|
|
@ -158,10 +145,10 @@ function updateBalance() {
|
|||
for (i in itemTotal) {
|
||||
total += itemTotal[i];
|
||||
}
|
||||
$('#total_price').html(asMoney(total));
|
||||
$('#total_price').html(I18n.l("currency", total));
|
||||
var balance = groupBalance - total;
|
||||
$('#new_balance').html(asMoney(balance));
|
||||
$('#total_balance').val(asMoney(balance));
|
||||
$('#new_balance').html(I18n.l("currency", balance));
|
||||
$('#total_balance').val(I18n.l("currency", balance));
|
||||
// determine bgcolor and submit button state according to balance
|
||||
var bgcolor = '';
|
||||
if (balance < minimumBalance) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue