1( function($) { 2 3 var waTheme = { 4 // VARS 5 site_url: "", 6 app_id: "", 7 app_url: "", 8 locale: "", 9 is_touch_enabled: ("ontouchstart" in window), 10 is_frame: isFrame(), 11 12 // 13 apps: {}, 14 15 // DOM 16 layout: {}, 17 18 // FUNCTIONS 19 init: {}, // constructor storage 20 21 addFonts: function(fonts) { 22 var content = []; 23 24 $.each(fonts, function(i, font) { addFont(font); }); 25 26 function addFont(font) { 27 var name = font.name, 28 font_uri = font.uri; 29 30 content.push("@import url('" + font_uri + "');"); 31 } 32 33 render( content.join("\n") ); 34 35 function render(content) { 36 var style = document.createElement("style"); 37 style.rel = "stylesheet"; 38 document.head.appendChild(style); 39 style.textContent = content; 40 } 41 }, 42 43 // ÐеÑÐ¾Ð´Ñ Ð´Ð»Ñ ÑабоÑÑ Ñ Ñеной (ÑоÑмаÑиÑование в валÑÑе за единиÑÑ Ð¸Ð·Ð¼ÐµÑÐµÐ½Ð¸Ñ Ð¸ Ñ.д.) 44 45 currencies: { 46 "default": { 47 code : null, 48 fraction_divider: ".", 49 fraction_size : 2, 50 group_divider : " ", 51 group_size : 3, 52 pattern_html : "<span class=\"price\">%s</span>", 53 pattern_text : "%s", 54 pattern_unit : "%s/%unit", 55 rounding : 0.01 56 } 57 }, 58 59 /** 60 * @param {object} currency_data 61 * @return undefined 62 * */ 63 addCurrency: function(currency_data) { 64 var self = this; 65 66 if (currency_data) { 67 self.currencies[currency_data["code"]] = currency_data; 68 } 69 }, 70 71 /** 72 * @param {string|number} price 73 * @param {object?} options 74 * @return {string} 75 * */ 76 formatPrice: function(price, options) { 77 var self = this, 78 result = price; 79 80 // ÐпÑии 81 options = (typeof options !== "undefined" ? options : {}); 82 options.unit = (typeof options.unit === "string" ? options.unit : null); 83 options.html = (typeof options.html === "boolean" ? options.html : true); 84 options.currency = (typeof options.currency === "string" ? options.currency : "default"); 85 86 // ÐалидаÑÐ¸Ñ Ð²Ð°Ð»ÑÑÑ 87 if (!options.currency || !self.currencies[options.currency]) { 88 console.error("ERROR: Currency is not exist"); 89 return result; 90 } 91 92 var format = self.currencies[options.currency]; 93 94 try { 95 price = parseFloat(price); 96 if (price >= 0) { 97 price = price.toFixed(format.fraction_size); 98 99 var price_floor = Math.floor(price), 100 price_string = getGroupedString("" + price_floor, format.group_size, format.group_divider), 101 fraction_string = getFractionString(price - price_floor); 102 103 result = (options.html ? format.pattern_html : format.pattern_text) 104 .replace("%s", price_string + fraction_string ); 105 106 if (options.unit) { 107 var unit = (options.html ? '<span class="unit">'+options.unit+'</span>' : options.unit); 108 result = format.pattern_unit 109 .replace("%s", result) 110 .replace("%unit", unit); 111 } 112 } 113 } catch(e) { 114 if (console && console.log) { 115 console.log(e.message, price); 116 } 117 } 118 119 if (options.html) { 120 result = '<span class="price-wrapper">'+result+'</span>'; 121 } 122 123 return result; 124 125 function getGroupedString(string, size, divider) { 126 var result = ""; 127 128 if (!(size && string && divider)) { 129 return string; 130 } 131 132 var string_array = string.split("").reverse(); 133 134 var groups = []; 135 var group = []; 136 137 for (var i = 0; i < string_array.length; i++) { 138 var letter = string_array[i], 139 is_first = (i === 0), 140 is_last = (i === string_array.length - 1), 141 delta = (i % size); 142 143 if (delta === 0 && !is_first) { 144 groups.unshift(group); 145 group = []; 146 } 147 148 group.unshift(letter); 149 150 if (is_last) { 151 groups.unshift(group); 152 } 153 } 154 155 for (i = 0; i < groups.length; i++) { 156 var is_last_group = (i === groups.length - 1), 157 _group = groups[i].join(""); 158 159 result += _group + ( is_last_group ? "" : divider ); 160 } 161 162 return result; 163 } 164 165 function getFractionString(number) { 166 var result = ""; 167 168 if (number > 0) { 169 number = number.toFixed(format.fraction_size + 1); 170 number = Math.round(number * Math.pow(10, format.fraction_size))/Math.pow(10, format.fraction_size); 171 var string = number.toFixed(format.fraction_size); 172 result = string.replace("0.", format.fraction_divider); 173 } 174 175 return result; 176 } 177 } 178 }; 179 180 addApp(["site", "shop", "hub", "blog", "photos", "helpdesk"]); 181 182 window.waTheme = (window.waTheme ? $.extend(waTheme, window.waTheme) : waTheme); 183 184 /** 185 * @return {Boolean} 186 * */ 187 function isFrame() { 188 var result = false; 189 190 try { 191 result = (window.self !== window.top); 192 } catch(e) {} 193 194 return result; 195 } 196 197 /** 198 * @param {Array|String} app 199 * */ 200 function addApp(app) { 201 var that = waTheme, 202 type = typeof app; 203 204 switch (type) { 205 case "object": 206 $.each(app, function(index, app_name) { 207 addApp(app_name); 208 }); 209 break; 210 case "string": 211 add(app); 212 break; 213 default: 214 break; 215 } 216 217 /** 218 * @param {String} app_name 219 * */ 220 function add(app_name) { 221 if (!app_name.length) {return false;} 222 223 that.apps[app_name] = {}; 224 that.init[app_name] = {}; 225 } 226 } 227 228})(jQuery);
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.