1(function () { 2 var Cookies; 3 4 (function () { 5 var exports = {}; 6 7 /*! Cookies.js - 0.3.1; Copyright (c) 2013, Scott Hamper; http://www.opensource.org/licenses/MIT */ 8 (function(e){"use strict";var a=function(b,d,c){return 1===arguments.length?a.get(b):a.set(b,d,c)};a._document=document;a._navigator=navigator;a.defaults={path:"/"};a.get=function(b){a._cachedDocumentCookie!==a._document.cookie&&a._renewCache();return a._cache[b]};a.set=function(b,d,c){c=a._getExtendedOptions(c);c.expires=a._getExpiresDate(d===e?-1:c.expires);a._document.cookie=a._generateCookieString(b,d,c);return a};a.expire=function(b,d){return a.set(b,e,d)};a._getExtendedOptions=function(b){return{path:b&& 9 b.path||a.defaults.path,domain:b&&b.domain||a.defaults.domain,expires:b&&b.expires||a.defaults.expires,secure:b&&b.secure!==e?b.secure:a.defaults.secure}};a._isValidDate=function(b){return"[object Date]"===Object.prototype.toString.call(b)&&!isNaN(b.getTime())};a._getExpiresDate=function(b,d){d=d||new Date;switch(typeof b){case "number":b=new Date(d.getTime()+1E3*b);break;case "string":b=new Date(b)}if(b&&!a._isValidDate(b))throw Error("`expires` parameter cannot be converted to a valid Date instance"); 10 return b};a._generateCookieString=function(b,a,c){b=encodeURIComponent(b);a=(a+"").replace(/[^!#$&-+\--:<-\[\]-~]/g,encodeURIComponent);c=c||{};b=b+"="+a+(c.path?";path="+c.path:"");b+=c.domain?";domain="+c.domain:"";b+=c.expires?";expires="+c.expires.toUTCString():"";return b+=c.secure?";secure":""};a._getCookieObjectFromString=function(b){var d={};b=b?b.split("; "):[];for(var c=0;c<b.length;c++){var f=a._getKeyValuePairFromCookieString(b[c]);d[f.key]===e&&(d[f.key]=f.value)}return d};a._getKeyValuePairFromCookieString=
11 function(b){var a=b.indexOf("="),a=0>a?b.length:a;return{key:decodeURIComponent(b.substr(0,a)),value:decodeURIComponent(b.substr(a+1))}};a._renewCache=function(){a._cache=a._getCookieObjectFromString(a._document.cookie);a._cachedDocumentCookie=a._document.cookie};a._areEnabled=function(){return a._navigator.cookieEnabled||"1"===a.set("cookies.js",1).get("cookies.js")};a.enabled=a._areEnabled();"function"===typeof define&&define.amd?define(function(){return a}):"undefined"!==typeof exports?("undefined"!== 12 typeof module&&module.exports&&(exports=module.exports=a),exports.Cookies=a):window.Cookies=a})(); 13 14 Cookies = exports.Cookies; 15 }()); 16 17 $('select.options').change(function(){ 18 var $this = $(this), 19 optionId = $this.val(), 20 $selected = $this.find(':selected'), 21 $submit = $this.parents('form').first().find(':submit'), 22 //option_price = $selected.data('price'); 23 optionPrice = null; 24 25 26 $.each(CurrentProduct.options, function (i, option) { 27 if (option.id == optionId && option.has_price) { 28 optionPrice = option.display_price_formatted; 29 } 30 }); 31 32 if (optionPrice !== null) { 33 $this.parent().find('.price').html(optionPrice); 34 } 35 36 if ($selected.data('outofstock') == 1) { 37 $submit.addClass('grey_button').removeClass('green_button').attr('disabled', 'disabled'); 38 } else { 39 $submit.removeClass('grey_button').addClass('green_button').removeAttr('disabled'); 40 } 41 42 /*var option_price = $(this).find(':selected').text(); 43 option_price = option_price.match(/\([^\)]+\)/g); 44 45 if ($.isArray(option_price)) { 46 option_price = option_price.pop(); 47 option_price = option_price.replace('(', ''); 48 option_price = option_price.replace(')', ''); 49 $(this).parent().find('.price').html(option_price); 50 }*/ 51 }).change(); 52 53 54 55 window.Shop = { 56 formatPrice: function (price) { 57 //return Math.round(price) + ' kr'; 58 var currency = Cart.currency; 59 var thousand = '.'; 60 61 if (currency.name === 'Swedish Krona') { 62 thousand = ' '; 63 } 64 65 if (currency.suffix) { 66 return accounting.formatMoney(price, { symbol: currency.symbol_native, decimal: ',', thousand: thousand, format: "%v %s", precision: Cart.decimals }); 67 } 68 return accounting.formatMoney(price, { symbol: currency.symbol_native, decimal: ',', thousand: thousand, format: "%s %v", precision: Cart.decimals }); 69 //return accounting.formatMoney(price, { symbol: "kr", decimal: ',', thousand: '.', format: "%v %s" }); 70 }, 71 taxAdd: function (price) { 72 return price * Cart.tax.rate_float; 73 }, 74 tax: function (price) { 75 return Shop.taxAdd(price) - price; 76 }, 77 texts: { 78 toCheckout: 'Till kassan', 79 loading: 'Laddar...' 80 }, 81 Cart: { 82 checkoutUrl: '/shop/cart' 83 } 84 } 85 86 Handlebars.registerHelper('formatPrice', Shop.formatPrice); 87 Handlebars.registerHelper('taxAdd', Shop.taxAdd); 88 Handlebars.registerHelper('tax', Shop.tax); 89 Handlebars.registerHelper('debug', function () { 90 console.log(arguments); 91 }); 92 93 Handlebars.registerHelper('toLowerCase', function(str) { 94 return str.toLowerCase(); 95 }); 96 97 Handlebars.registerHelper('chain', function () { 98 var helpers = [], value; 99 $.each(arguments, function (i, arg) { 100 if (Handlebars.helpers[arg]) { 101 helpers.push(Handlebars.helpers[arg]); 102 } else { 103 value = arg; 104 $.each(helpers, function (j, helper) { 105 value = helper(value, arguments[i + 1]); 106 }); 107 return false; 108 } 109 }); 110 return value; 111 }); 112 113 Shop.initCart = function ($cart, renderCallback) { 114 $('input.quantity', $cart).on('keyup change', function () { 115 var $input = $(this), 116 $row = $input.parents('[data-id]'), 117 productId = $row.data('id'), 118 optionId = $row.data('option-id'); 119 120 var value = $input.val(); 121 122 if (value !== "0" && value < 1) { 123 return 124 } 125 126 if ($('#payment_button').length > 0) { 127 $('#payment_button button'). 128 attr('disabled', 'disabled') 129 .css({ 130 'background': '#b3b3b3', 131 'cursor': 'not-allowed', 132 'transform': 'scale(1)' 133 }).text(window.Shop.texts.loading); 134 } 135 136 $.post('/shop/cart/set_quantity/' + productId + (optionId ? '/' + optionId : ''), { quantity: value }, function (r) { 137 Cart = r.cart; 138 renderCallback(); 139 140 if ($('#payment_button').length > 0) { 141 $('#payment_button button').removeAttr('disabled').removeAttr('style').text(window.Shop.texts.toCheckout); 142 } 143 }); 144 }); 145 }; 146 147 var words = { 148 incl: 'Varav', 149 shipping: 'Frakt', 150 shipping_cost_discounted: 'Rabatt på frakt', 151 discount: 'Rabatt', 152 payment_provider_cost: 'Fakturaavgift' 153 } 154 //var incl = 'Varav'; 155 //var shipping = 'Frakt'; 156 157 // No retell 158 Shop.cartTemplate = Handlebars.compile([ 159 '<table>', 160 '{{#each items}}', 161 '{{#if this.quantity}}', 162 '<tr data-id="{{this.product.id}}">', 163 '<td>', 164 '<strong>{{this.product.name}}</strong>', 165 '</td>', 166 '<td>', 167 '{{formatPrice this.unit_price}}', 168 '</td>', 169 '<td>', 170 '<input type="number" class="quantity" value="{{this.quantity}}" />', 171 '</td>', 172 '<td class="product_total_price">', 173 '{{formatPrice this.total_price}}', 174 '</td>', 175 '<td>', 176 '<i class="icon-remove"></i>', 177 '</td>', 178 '</tr>', 179 '{{/if}}', 180 181 '{{#each this.options}}', 182 '<tr data-id="{{../this.product.id}}" data-option-id="{{this.option.id}}">', 183 '<td>', 184 '<strong>{{../this.product.name}}, {{this.option.name}}</strong>', 185 '</td>', 186 '<td>', 187 '{{formatPrice this.unit_price}}', 188 '</td>', 189 '<td>', 190 '<input type="number" class="quantity" value="{{this.quantity}}" />', 191 '</td>', 192 '<td class="product_total_price">', 193 '{{formatPrice this.total_price}}', 194 '</td>', 195 '<td>', 196 '<i class="icon-remove"></i>', 197 '</td>', 198 '</tr>', 199 '{{/each}}', 200 '{{/each}}', 201 202 '<tr class="summary">', 203 '<th class="sum_description" colspan="3">', 204 // No retell 205 'Summa<br />', 206 // No retell 207 '{{#if shipping}}' + words.shipping + '<br />{{/if}}', 208 '{{#if discount}}
208<span style="color:red">{{#if shipping_cost_discounted}}' + words.shipping_cost_discounted +'{{else}}{{#if discount.display_text}}' + words.discount + ' {{discount.display_text}}{{else}}' + words.discount +'{{/if}}{{/if}}</span><br />{{/if}}', 209 '{{#if payment_provider_cost}}' + words.payment_provider_cost + '<br/>{{/if}}', 210 // No retell 211 '<strong>Totalt</strong>', 212 // No retell 213 '{{#each taxes}}', 214 '{{#if this.total}}', 215 '<br />' + words.incl + ' {{toLowerCase this.name}} {{this.rate_int}}%', 216 '{{/if}}', 217 '{{/each}}', 218 // No retell 219 // No retell 220 '</th>', 221 '<td class="sum">', 222 '{{formatPrice products_sum}}<br />', 223 '{{#if shipping}}', 224 '{{#if ../display_price_with_vat}}', 225 '{{formatPrice shipping.price_with_vat}}', 226 '{{else}}', 227 '{{formatPrice shipping.price}}', 228 '{{/if}}', 229 '<br />', 230 '{{/if}}', 231 '{{#if discount}}<span style="color:red">-{{formatPrice sum_discount_saved}}</span><br />{{/if}}', 232 '{{#if payment_provider_cost}}{{formatPrice payment_provider_cost}}<br/>{{/if}}', 233 '{{formatPrice total}}<br />', 234 '{{#each taxes}}', 235 '{{#if this.total}}', 236 '{{formatPrice this.total}}', 237 '{{/if}}', 238 '{{/each}}', 239 '</td>', 240 '</tr>', 241 '</table>' 242 ].join('\n')); 243 // No retell 244 245 Handlebars.registerPartial('cart', Shop.cartTemplate); 246 247 // Shop sidebar 248 (function () { 249 var $categories = $('.shop2 nav.categories'), 250 $products = $('.shop2 .products'), 251 resizeTimeout, 252 paddingHeight; 253 254 if ($('li', $categories).length > 0) { 255 256 //$('.products').css('margin-top', '50px'); 257 // Need to manually bind the button, so we can add a callback 258 $('.shop2 section.categories .toggle_button_wrap a').click(function (e) { 259 e.preventDefault(); 260 261 if ($categories.hasClass('open')) { 262 $categories.removeClass('open'); 263 $products.removeClass('expanded_categories'); 264 } else { 265 $categories.addClass('open'); 266 $products.addClass('expanded_categories'); 267 } 268 269 categoriesToggled(); 270 }); 271 272 273 /*if ($categories.hasClass('open')) { 274 $products.addClass('expanded_categories'); 275 }*/ 276 //if ($(window).width() >= 1200 && typeof localStorage != 'undefined') { 277 //if (localStorage.getItem('shop_category_navigation_open')) { 278 /*if (Cookies.get('shop_category_navigation_open')) { 279 $categories.addClass('open'); 280 $products.addClass('expanded_categories'); 281 }*/ 282 //} 283 284 } 285 286 function categoriesToggled() { 287 var isOpen = $categories.hasClass('open'); 288 289 //if (typeof localStorage != 'undefined') { 290 if (isOpen) { 291 //localStorage.setItem('shop_category_navigation_open', '1'); 292 Cookies.set('shop_category_navigation_open', '1'); 293 } else { 294 //localStorage.removeItem('shop_category_navigation_open'); 295 Cookies.expire('shop_category_navigation_open'); 296 } 297 //} 298 } 299 }()); 300 301 // Message field 302 $('#add_message_button').click(function(){ 303 $(this).hide(); 304 $('#message_area').show(); 305 }); 306 307 308 /** 309 * Search 310 */ 311 (function () { 312 var $search = $('#shop_wrapper section.search input'); 313 314 //$search.keyup(function () { 315 // $.post('/shop/search/search.json', { query: $search.val() }, function (r) { 316 // console.log(r); 317 // }); 318 //}); 319 }()); 320 321}());
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.