Sha256: 4a4530e36bd0241c78c0858b6fa13e05c11df5d37731bcc370ec34f4ee67b402

Contents?: true

Size: 1.14 KB

Versions: 18

Compression:

Stored size: 1.14 KB

Contents

// Place your application-specific JavaScript functions and classes here
// This file is automatically included by javascript_include_tag :defaults

var shipping_costs = new Hash();

function calculate_order_total(radio){
	$('order_total_cell').update(number_to_currency(order_total_without_shipping + shipping_costs.get(radio.value)));
}

function number_to_currency(number, options) {
	try {
 		var options   = options || {};
		var precision = options["precision"] || 2;
 		var unit      = options["unit"] || "$";
 		var separator = precision > 0 ? options["separator"] || "." : "";
		var delimiter = options["delimiter"] || ",";
   
 		var parts = parseFloat(number).toFixed(precision).split('.');
		return unit + number_with_delimiter(parts[0], delimiter) + separator + parts[1].toString();
	} catch(e) {
		return number
	}
 }

function number_with_delimiter(number, delimiter, separator) {
	try {
		var delimiter = delimiter || ",";
 		var separator = separator || ".";

		var parts = number.toString().split('.');
		parts[0] = parts[0].replace(/(\d)(?=(\d\d\d)+(?!\d))/g, "$1" + delimiter);
		return parts.join(separator);
	} catch(e) {
		return number
	}
}

Version data entries

18 entries across 18 versions & 3 rubygems

Version Path
kdmny-spree-0.0.1 public/javascripts/application.js
spree-enriquez-0.9.4 public/javascripts/application.js
spree-0.9.4 public/javascripts/application.js
spree-0.9.3 public/javascripts/application.js
spree-0.9.2 public/javascripts/application.js
spree-0.9.1 public/javascripts/application.js
spree-0.9.0 public/javascripts/application.js
spree-0.8.4 public/javascripts/application.js
spree-0.8.5 public/javascripts/application.js
spree-0.5.0 public/javascripts/application.js
spree-0.6.0 public/javascripts/application.js
spree-0.5.1 public/javascripts/application.js
spree-0.7.0 public/javascripts/application.js
spree-0.7.1 public/javascripts/application.js
spree-0.8.0 public/javascripts/application.js
spree-0.8.1 public/javascripts/application.js
spree-0.8.2 public/javascripts/application.js
spree-0.8.3 public/javascripts/application.js