1/** 2 * @copyright D Loja Virtual 3 * @link http://www.dlojavirtual.com 4 * @package app.FrontEnd.Js 5 * @since v 1.0 6 * @author Bruno Lehnen Simões 7**/ 8 9CurrencyBehavior = (function(){ 10 var currencies = { 11 'CatalogoCarrinho' : ['valor_frete','valor_total', 'valor_minimo','valor_total_produtos','total_presente','total_carrinho', 'total_carrinho_produtos', 'total_produto', 'desconto', 'desconto_avista', 'adicional'], 12 'CatalogoProduto': ['valor_inicio', 'valor_fim'], 13 'CatalogoCarrinhoProduto' : ['valor_total','valor_unitario'], 14 'Payment': ['valor_parcela', 'parcela_minima', 'valor_avista', 'taxa_juros', 'taxa_desconto'], 15 'Shipping': ['Valor'] 16 }; 17 18 function toCurrency(field){ 19 20 if(typeof field !== 'undefined'){ 21 field = (field !== null) ? field.toString() : '0'; 22 return accounting.formatMoney(field); 23 } 24 25 return false; 26 }; 27 28 function formatMatches(data, name){ 29 if(typeof data !== 'undefined'){ 30 $.each(currencies[name], function(fieldIndex, field){ 31 data[field] = toCurrency(data[field]); 32 }); 33 } 34 }; 35 36 function formatShipping(data){ 37 $.each(data, function(index, value){ 38 if(value !== null){ 39 if(typeof value.Valor !== 'undefined'){ 40 formatMatches(value, 'Shipping'); 41 }else{ 42 $.each(value, function(index, val){ 43 formatMatches(val, 'Shipping'); 44 }); 45 } 46 } 47 }); 48 } 49 50 function formatCart(data){ 51 if(data.CatalogoCarrinho){ 52 formatMatches(data.CatalogoCarrinho, 'CatalogoCarrinho'); 53 } 54 55 if(data.CatalogoCarrinhoProduto){ 56 var prodLen = data.CatalogoCarrinhoProduto.length; 57 58 if($.isArray(data.CatalogoCarrinhoProduto)){ 59 for(var i = 0; i < prodLen; i++){ 60 formatMatches(data.CatalogoCarrinhoProduto[i].CatalogoCarrinhoProduto, 'CatalogoCarrinhoProduto'); 61 } 62 } 63 else{ 64 formatMatches(data.CatalogoCarrinhoProduto, 'CatalogoCarrinhoProduto'); 65 } 66 } 67 }; 68 69 function formatProduct(data){ 70 var main = data.CatalogoProduto; 71 72 if(main){ 73 $.each(main, function(index, prod){ 74 formatMatches(data.CatalogoProduto[index].CatalogoProduto, 'CatalogoProduto'); 75 }); 76 } 77 }; 78 79 80 function formatPayment(data){ 81 var rec = function(index, value){ 82 if(value && !$.isArray(value)){ 83 formatMatches(value, 'Payment'); 84 85 $.each(value, function(fieldName, val){ 86 if($.isArray(val)){ 87 var valLen = val.length; 88 89 for(var i = 0; i < valLen; i++){ 90 formatMatches(value[fieldName][i], 'Payment'); 91 } 92 93 } 94 }); 95 96 97 }else if($.isArray(value)){ 98 $.each(value, function(index, val){ 99 rec(index, val); 100 value[index] = val; 101 }); 102 } 103 }; 104 105 $.each(data, function(index, value){ rec(index, value); }); 106 }; 107 108 return { 109 formatCart: formatCart, 110 formatPayment: formatPayment, 111 formatProduct: formatProduct, 112 formatShipping: formatShipping 113 } 114 115})();
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.