/
base.jinja
698 lines (656 loc) · 30 KB
/
base.jinja
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
<!DOCTYPE html>
{% set version = version or '' %}
{% set CDN = CDN or '' %}
{% set LOGO = CDN + url_for('nereid.webshop.send_static_file', filename='images/nereid_cart_logo.png') %}
{% block notification_bar %}
{% if request.nereid_website.show_site_message %}
<div align="center" class="alert alert-warning hidden" id="site-message">
<button type="button" class="close" data-dismiss="alert">×</button>
{{ request.nereid_website.site_message }}
</div>
{% endif %}
{% endblock %}
{% macro render_account_menu() %}
{% if not current_user.is_anonymous() %}
<li><a href="{{ url_for('nereid.website.account') }}">
<i class="fa fa-user"></i> {{ _('Profile') }}
</a></li>
<li><a href="{{ url_for('sale.sale.render_list') }}">
<i class="fa fa-cubes"></i> {{ _('My Orders') }}
</a></li>
<li><a href="{{ url_for('party.address.view_address') }}">
<i class="fa fa-book"></i> {{ _('Address Book') }}
</a></li>
<li><a href="{{ url_for('wishlist.wishlist.render_wishlists') }}">
<i class="fa fa-heart"></i> {{ _('My Wishlist') }}
</a></li>
<li><a href="{{ url_for('party.party.view_payment_profiles') }}">
<i class="fa fa-credit-card"></i> {{ _('My Cards') }}
</a></li>
<li><a href="{{ url_for('nereid.website.logout') }}">
<i class="fa fa-sign-out"></i> {{ _('Logout') }}
</a></li>
{% else %}
<li><a class="register-buttons" href="{{ url_for('nereid.website.login') }}">{{ _('Login / SignUp') }}</a></li>
{% endif %}
{% endmacro %}
{% macro render_breadcrumb_item(title, url) %}
<li itemscope itemtype="http://data-vocabulary.org/Breadcrumb">
<a href="{{ url }}" itemprop="url">
<span itemprop="title">{{ title }}</span>
</a>
</li>
{% endmacro %}
<html lang="{{ request.nereid_language.code }}">
<head>
<title>{% block title %}{% trans %}Nereid Webshop{% endtrans %}{% endblock title %}</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no">
<meta name="description" content="{% block meta_description %}{% endblock %}">
<meta name="csrf-token" content="{{ csrf_token() }}">
<meta http-equiv="X-UA-Compatible" content="IE=9">
<link rel="icon" href="{{ SHOP_FAVICON or url_for('nereid.webshop.send_static_file', filename='images/favicon.ico') }}" type="image/x-icon">
<link rel="shortcut icon" href="{{ SHOP_FAVICON or url_for('nereid.webshop.send_static_file', filename='images/favicon.ico') }}" type="image/x-icon">
{% block link_tags %}
{# This block adds <link> tags to the head section of the template. #}
<link href="{{ CDN }}{{ url_for('nereid.webshop.send_static_file', filename='css/bootstrap.min.css') }}" rel="stylesheet" media="screen">
<link href="{{ CDN }}{{ url_for('nereid.webshop.send_static_file', filename='css/typeaheadjs.css') }}" rel="stylesheet">
<!-- HTML5 shim and Respond.js IE8 support of HTML5 elements and media queries -->
<!--[if lt IE 9]>
<script src="{{ CDN }}{{ url_for('nereid.webshop.send_static_file', filename='js/html5shiv.js') }}"></script>
<script src="{{ CDN }}{{ url_for('nereid.webshop.send_static_file', filename='js/respond.min.js') }}"></script>
<![endif]-->
<link href='https://fonts.googleapis.com/css?family=Open+Sans:300italic,400italic,600italic,700italic,800italic,400,300,600,700,800' rel='stylesheet' type='text/css'>
<link rel="stylesheet" type="text/css" href="{{ CDN }}{{ url_for('nereid.webshop.send_static_file', filename='css/font-awesome.min.css') }}">
<link rel="stylesheet" type="text/css" href="{{ CDN }}{{ url_for('nereid.webshop.send_static_file', filename='css/jquery.pnotify.default.css') }}">
{% endblock link_tags %}
{% block base_stylesheet %}
<link rel="stylesheet" type="text/css" href="{{ CDN }}{{ url_for('nereid.webshop.send_static_file', filename='css/style.css') }}?v={{ version }}">
{% endblock base_stylesheet %}
{% block extra_head %}
{# This block is empty by default and can be used to add extra
contents into the <head> tag of the generated HTML file. This is
the right place to add references to extra CSS files.
Though it is possible to add Javascript files to this section, It
is not recommended.
See why: http://developer.yahoo.com/performance/rules.html#js_bottom
#}
{% endblock extra_head %}
</head>
<body>
{% block header %}
<section class="header-main">
{% block header_row_1 %}
<!-- Top Meta Details -->
<div class="container">
<div class="row">
<div class="col-md-12">
<div class="top-meta hidden-xs">
{% block new_offers %}
<!-- New Offers row -->
<div class="new-offers">
<a href="">
<small class="btn-danger btn-xs"> Offer <i class="fa fa-caret-right"></i> </small>
<span class="text-danger">Additional 30% off </span>on orders above $1199
<span class="pull-right">Use Coupon Code: <small class="text-rounded-border">Shop30</small>
<i class="fa fa-times-circle" title="close"></i>
</span>
</a>
</div>
{% endblock new_offers %}
<div class="row">
{% block locales %}
<div class="col-xs-3">
<!-- Choose Language -->
{% if request.nereid_website.locales %}
{% set current_locale = request.nereid_locale.language %}
<div class="btn-group">
<button type="button" class="btn btn-default dropdown-toggle btn-xs" data-toggle="dropdown">
<img class="flag flag-{{ current_locale.code[3:]|lower }}"> {{ current_locale.rec_name }} <span class="caret"></span>
</button>
<ul class="dropdown-menu" role="menu">
{% for locale in request.nereid_website.locales + (request.nereid_website.default_locale,) %}
{% if locale.id != request.nereid_locale.id %}
<li>
<a href="{{url_for('nereid.website.home', locale=locale.code)}}">
<img class="flag flag-{{ locale.language.code[3:]|lower }}"> {{ locale.language.rec_name }}
</a>
</li>
{% endif %}
{% endfor %}
</ul>
</div>
{% endif %}
</div>
{% endblock locales %}
<div class="col-xs-9 pull-right">
<ul class="list-inline pull-right links">
{% block header_links %}
<li><a href="tel:+91 120 6455161"> <i class="fa fa-phone"></i> +91 120 6455161</a></li>
<li>
{% if not current_user.is_anonymous() %}
<span class="text-muted">Welcome, </span> <span >{{ request.nereid_user.display_name }}</span>
<a href="{{ url_for('nereid.website.logout') }}"><span class="text-danger"><i class="fa fa-sign-out"></i> Log Out</span>
</a>
{% else %}
<a class="register-buttons" href="{{ url_for('nereid.website.login') }}">{{ _('Login / SignUp') }}</a>
{% endif %}
</li>
{% endblock header_links %}
</ul>
</div>
</div>
</div>
</div>
</div>
</div>
{% endblock header_row_1 %}
{% block header_row_2 %}
<div class="container logo-container">
<div class="row">
{% block logo %}
<div class="col-md-3 col-sm-3 col-xs-12">
<div class="main-logo">
<a href="{{ url_for('nereid.website.home') }}">
<img src="{{ LOGO }}">
</a>
</div>
</div>
{% endblock logo %}
{% block header_user %}
{% if not checkout_page %}
<div class="col-md-4 col-md-push-5 my-account">
<ul class="list-inline pull-right">
<li>
<div class="btn-group">
<a type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown">
<i class="fa fa-user"></i> <span class="hidden-xs hidden-sm">{{ _('My Account') }}</span> <span class="caret"></span>
</a>
<ul class="dropdown-menu" role="menu">
{{ render_account_menu() }}
</ul>
</div>
</li>
<li class="my-cart">
<a href="" class="my-cart-show">{{ _('My Cart') }} <span class="quantity">0</span></a>
</li>
</ul>
</div>
{% endif %}
{% endblock header_user %}
{% block search %}
{% if not checkout_page %}
<div class="col-md-5 col-sm-12 col-xs-12 col-md-pull-4 top-search"
itemscope itemtype="http://schema.org/WebSite">
<meta itemprop="url" content="{{ url_for('nereid.website.home', _external=True) }}"/>
<form action="{{ url_for('nereid.website.quick_search') }}" id="search_form"
itemprop="potentialAction" itemscope itemtype="http://schema.org/SearchAction">
<meta itemprop="target" content="{{ url_for('nereid.website.quick_search', _external=True) }}?q={q}"/>
<div class="input-group" id="search-bar">
<input type="text" class="form-control typeahead" data-provide="typeahead" name="q" itemprop="query-input" required>
<span class="input-group-btn">
<button class="btn btn-default" type="submit"><i class="fa fa-search"></i></button>
</span>
</div><!-- /input-group -->
</form>
</div>
{% endif %}
{% endblock search %}
</div>
</div>
{% endblock header_row_2 %}
<!--Main Navigation -->
{% block main_navigation %}
<div class="container sticky">
{% if not checkout_page %}
<div class="row main-navigation">
<div class="col-md-12">
<ul class="list-inline" id="nav-list">
{% from '_helpers.jinja' import render_cms_root_menu %}
{% if request.nereid_website.cms_root_menu %}
{{ render_cms_root_menu(request.nereid_website.cms_root_menu) }}
{% endif %}
{# add any other navigational elements like probably an article list or custom link here #}
</ul>
</div>
</div>
{% endif %}
</div>
{% endblock main_navigation %}
</section>
<div class="container container-breadcrumb hidden-xs">
<ol class="breadcrumb">
{% block breadcrumb %}
{{ render_breadcrumb_item(_('Home'), url_for('nereid.website.home')) }}
{% endblock %}
</ol>
</div>
{% endblock header %}
{% block main %}
{% endblock main %}
{% set bottom_article_categories = ['customer-service', 'about-us', 'contact-us', 'press', 'help'] %}
{% block footer %}
<!--Footer Links blocks Starts-->
<footer>
<div class="container">
<hr>
<!--First Row-->
<div class="row">
<!-- Site Navigation and root links -->
{% for category_name in bottom_article_categories %}
<div class="col-md-2">
{% set category = get_article_category(category_name) %}
<h4>{{ category.title }}</h4>
<ul class="list-unstyled">
{% for article in category.articles %}
<li><a href="{{ url_for('nereid.cms.article.render', uri=article.uri) }}">{{ article.title }}</a></li>
{% endfor %}
</ul>
</div>
{% endfor %}
<!-- Social Links and Subscribe -->
<div class="col-md-{{ 12 - 2 * (bottom_article_categories|length) }} social-block">
<div class="row">
<h4>Social</h4>
<a href="" class="social-links facebook"><i></i></a>
<a href="" class="social-links twitter"><i></i></a>
<a href="" class="social-links googleplus"><i></i></a>
<a href="" class="social-links pinterest"><i></i></a>
<a href="" class="social-links youtube"><i></i></a>
</div>
<div class="row">
<div class="subscribe-block">
<h5>Sign Up for the Newsletter</h5>
<!--Subscribe form-->
<form autocomplete="off">
<div class="input-group">
<input type="text" class="form-control" placeholder="you@mail.com">
<span class="input-group-btn">
<button class="btn btn-danger" type="button"><i class="fa fa-plus"></i></button>
</span>
</div>
</form>
</div>
</div>
</div>
</div>
<hr>
<!-- Second Row -->
<div class="row">
<div class="col-md-8 payment-gateway">
<h4>Payment Gateway</h4>
<ul class="list-inline">
<li>
<img src="{{ CDN }}{{ url_for('nereid.webshop.send_static_file', filename='images/payment-gateway/visa.png') }}">
</li>
<li>
<img src="{{ CDN }}{{ url_for('nereid.webshop.send_static_file', filename='images/payment-gateway/paypal.png') }}">
</li>
<li>
<img src="{{ CDN }}{{ url_for('nereid.webshop.send_static_file', filename='images/payment-gateway/mastercard.png') }}">
</li>
<li>
<img src="{{ CDN }}{{ url_for('nereid.webshop.send_static_file', filename='images/payment-gateway/solo.png') }}">
</li>
<li>
<img src="{{ CDN }}{{ url_for('nereid.webshop.send_static_file', filename='images/payment-gateway/cirrus.png') }}">
</li>
<li>
<img src="{{ CDN }}{{ url_for('nereid.webshop.send_static_file', filename='images/payment-gateway/western-union.png') }}">
</li>
<li>
<img src="{{ CDN }}{{ url_for('nereid.webshop.send_static_file', filename='images/payment-gateway/american-express.png') }}">
</li>
</ul>
</div>
</div>
<hr>
<!-- third row -->
<div class="row copyright-footer">
<ul class="list-inline center">
<li>
© Openlabs /
</li>
<li><a href=""> All Rights Reserved</a> /</li>
<li><a href=""> Privacy Policy</a> /</li>
<li><a href=""> Terms of Use</a> /</li>
<li><a href="{{ url_for('nereid.website.render_sitemap') }}">Sitemap</a></li>
</ul>
</div>
</div>
</footer>
<script type="text/html" id='cart-html-append'>
<a href="{{ url_for('nereid.cart.view_cart') }}" class="my-cart-show">{{ _('My Cart') }} <span class="quantity"><%= parseInt(user_status.cart_size) %></span></a>
<!-- Drop down cart -->
<div class="cart-item">
<!-- If cart is empty -->
<%
if (user_status.cart_size > 0){ %>
<div class="cart-total">
<span class="pull-left"><%= parseInt(user_status.cart_size) %> Item(s)</span><span class="pull-right"><strong>{{ _('Subtotal') }} :</strong> <%= user_status.cart.total_amount %>
</span>
</div>
<%
_.each(user_status.cart.lines, function(line, index) { %>
<div class="product-details">
<div class="row">
<div class="col-xs-3 cart-product-image">
<a href="">
<img src="<%= line.product.image %>">
</a>
</div>
<div class="col-xs-7 cart-product-name">
<a href=""><%= line.product.name %>
</a><br>
<span class="text-muted"><%= line.quantity %> x <%= line.amount %></span>
</div>
<div class="col-xs-2 cart-product-total">
<span data-url="<%= line.remove_url %>" title="{{ _('Remove') }}" class="remove_product" data-ga-event-label="Remove From Cart Hover" data-ga-product-name="<%= line.product.name %>" data-ga-product-category="<%= line.product.category %>" data-ga-product-price="<%= line.amount %>" data-ga-product-id="<%= line.product.id %>" data-ga-product-quantity="<%= line.quantity %>"><i class="fa fa-trash-o"></i></span>
</div>
</div>
</div>
<%
});
%>
<a href="{{ url_for('nereid.cart.view_cart') }}" class="btn btn-danger pull-right" >{{ _('Checkout') }}</a>
<% } else { %>
<div class="empty-cart center">
<i class="fa fa-frown-o fa-3x"></i>
<h3>hey !</h3>
<p>{{ _('Your shopping cart is empty') }}</p>
</div>
<% } %>
</div>
</script>
{% endblock footer %}
<!-- javascript section -->
<!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->
<script src="{{ CDN }}{{ url_for('nereid.webshop.send_static_file', filename='js/jquery.min.js') }}"></script>
<!-- Include all compiled plugins (below), or include individual files as needed -->
<script src="{{ CDN }}{{ url_for('nereid.webshop.send_static_file', filename='js/bootstrap.min.js') }}"></script>
<script src="{{ CDN }}{{ url_for('nereid.webshop.send_static_file', filename='js/jquery.pnotify.min.js') }}"></script>
<script src="{{ CDN }}{{ url_for('nereid.webshop.send_static_file', filename='js/underscore-min.js') }}"></script>
<script src="{{ CDN }}{{ url_for('nereid.webshop.send_static_file', filename='js/jquery.touchSwipe.min.js') }}"></script>
<script src="{{ CDN }}{{ url_for('nereid.webshop.send_static_file', filename='js/imagesloaded.pkgd.min.js') }}"></script>
<script src="{{ CDN }}{{ url_for('nereid.webshop.send_static_file', filename='js/typeahead.bundle.min.js') }}"></script>
{% block script_tags %}
{#
use this block for additional script tags which can be replaced by downstream modules if they dont use
a custom feature like the lightbox provided by webshop. However hard dependencies without which this
template wont work are listed outside this block
#}
<script src="{{ CDN }}{{ url_for('nereid.webshop.send_static_file', filename='js/app.js') }}?v={{ version }}"></script>
<script src="{{ CDN }}{{ url_for('nereid.webshop.send_static_file', filename='js/holder.js') }}?v={{ version }}"></script>
{% endblock script_tags %}
<script type="text/javascript">
var csrftoken = $('meta[name=csrf-token]').attr('content')
$.ajaxSetup({
beforeSend: function(xhr, settings) {
if (!/^(GET|HEAD|OPTIONS|TRACE)$/i.test(settings.type)) {
xhr.setRequestHeader("X-CSRFToken", csrftoken)
}
}
})
</script>
<script type="text/javascript">
$(document).ready(function($){
{# Message flashin #}
$.pnotify.defaults.styling = "bootstrap";
$.pnotify.defaults.history = false;
{% for category, message in get_flashed_messages(with_categories=True) %}
$.pnotify({
title: '{{ category }}',
text: '{{ message }}',
history: false,
type: '{{ category }}',
nonblock: true,
delay:2000,
nonblock_opacity: .4,
animation: 'show'
});
{% endfor %}
});
</script>
<script type="text/javascript">
var userDataCallbacks = $.Callbacks("");
function removeFromCart(url){
$.ajax({
type: "DELETE",
url: url,
})
.success(function(){
location.reload();
});
}
$.post("{{ url_for('nereid.website.user_status') }}", function(data){
var template = $("#cart-html-append").html();
$("li.my-cart").html(_.template(template, {'user_status': data.status}));
userDataCallbacks.fire(data);
$('.remove_product, .remove_from_cart').on('click', function(e){
var delUrl = $(this).data("url");
if(typeof ga == 'undefined'){
removeFromCart(delUrl);
return true;
}
e.preventDefault();
var alreadySubmitted = false;
var form = this;
/* The code below registers a timeout which acts
* as a safety net. The boolean alreadySubmitted is used
* to check whether the form was already submitted or not.
* It is used by the callbacks in setTimeout and GA. It is to
* avoid the specific cases where both callbacks fire, resulting
* in a double form submission.
*/
var t = setTimeout(function() {
if (alreadySubmitted) return;
alreadySubmitted = true;
removeFromCart(delUrl);
}, 500);
ga('ec:addProduct', {
'id': $(this).data('ga-product-id'),
'name': $(this).data('ga-product-name'),
'category': $(this).data('ga-product-category'),
'price': $(this).data('ga-product-price'),
'quantity': $(this).data('ga-product-quantity'),
});
ga('ec:setAction', 'remove');
ga('send', 'event', 'CartAnalytics', 'click', $(this).data('ga-event-label') || '', {
'hitCallback': function() {
if (alreadySubmitted) return;
alreadySubmitted = true;
// Remove anyway
removeFromCart(delUrl);
}});
});
});
</script>
<script type="text/javascript">
$(function () {
if (!sessionStorage.hide_site_message)
{
$("#site-message").removeClass("hidden");
}
$("#site-message .close").on("click", function(){
$("#site-message").addClass("hidden");
sessionStorage.hide_site_message = true;
})
});
</script>
<script>
$(document).ready(function(){
function resize_products () {
var tallest_el_height = 0;
$('.product-list').children()
.height('auto')
.each(function() {
if ($(this).height() > tallest_el_height){
tallest_el_height=$(this).height()
}})
.height(tallest_el_height);
}
// Resize on load
$('.product-list').imagesLoaded(resize_products);
// Adjust height on window resize
$(window).on('resize', resize_products);
});
</script>
{% if GOOGLE_ANALYTICS_PROPERTY_ID %}
<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
ga('create', {
trackingId: '{{ GOOGLE_ANALYTICS_PROPERTY_ID }}',
cookieDomain: 'auto'
{% if not current_user.is_anonymous() %}
,userId: {{ current_user.id }}
{% endif %}
});
ga('require', 'displayfeatures');
ga('require', 'ec');
{% block ga_page_view %}
{# In downstream pages add calls to be made before send here #}
{% endblock ga_page_view %}
// Tracking product clicks.
$(function (){
$('a[href][ga-product-link]').on("click", function(e){
if(typeof ga == 'undefined'){
return true;
}
e.preventDefault();
e.stopPropagation();
var url = $(this).attr('href');
// register safety net timeout:
var t = setTimeout(function() {
document.location.href = url
}, 500);
ga('ec:addProduct', {
'id': $(this).data('ga-product-id'),
'name': $(this).data('ga-product-name'),
'category': $(this).data('ga-product-category')
});
ga('ec:setAction', 'click', {list: $(this).data('ga-product-list')});
ga('send', 'event', 'Product', 'click', $(this).data('ga-event-label') || '', {
'hitCallback': function() {
clearTimeout(t);
// redirect anyway:
document.location.href = url;
}});
});
});
//Tracking product add-to-cart.
$(function() {
$('.add-to-cart').submit(function(e){
if(typeof ga == 'undefined'){
return true;
}
e.preventDefault();
var alreadySubmitted = false;
var form = this;
/* The code below registers a timeout which acts
* as a safety net. The boolean alreadySubmitted is used
* to check whether the form was already submitted or not.
* It is used by the callbacks in setTimeout and GA. It is to
* avoid the specific cases where both callbacks fire, resulting
* in a double form submission.
*/
var t = setTimeout(function() {
if (alreadySubmitted) return;
alreadySubmitted = true;
form.submit();
}, 500);
ga('ec:addProduct', {
'id': $(this).children("input[name='product']").attr('value'),
'name': $(this).data('ga-product-name'),
'category': $(this).data('ga-product-category'),
'price': $(this).data('ga-product-price'),
'quantity': $(this).children("input[name='quantity']").attr('value'),
});
ga('ec:setAction', 'add');
ga('send', 'event', 'CartAnalytics', 'click', $(this).data('ga-event-label') || '', {
'hitCallback': function() {
if (alreadySubmitted) return;
alreadySubmitted = true;
// Submit anyway
form.submit();
}});
});
});
ga('send', 'pageview');
</script>
{% endif %}
<script type="text/javascript">
$(document).ready(function(){
var products = new Bloodhound({
datumTokenizer: function (datum) {
return Bloodhound.tokenizers.whitespace(datum.value);
},
queryTokenizer: Bloodhound.tokenizers.whitespace,
remote: {
url: "{{ url_for('nereid.website.search_auto_complete') }}?q=%QUERY",
filter: function (products) {
return products.results;
}
}
});
products.initialize();
$('#search-bar .typeahead').typeahead({
hint: true,
minLength: 5,
highlight: true
},
{
name: 'products',
displayKey: 'display_name',
source: products.ttAdapter(),
templates: {
suggestion: _.template("<a href=<%=url%>><%= display_name %></a>")
}
});
});
</script>
{% block scripts %}
{% endblock scripts %}
{% if OLARK_SITE_ID %}
<!-- begin olark code -->
<script data-cfasync="false" type='text/javascript'>/*<![CDATA[*/window.olark||(function(c){var f=window,d=document,l=f.location.protocol=="https:"?"https:":"http:",z=c.name,r="load";var nt=function(){
f[z]=function(){
(a.s=a.s||[]).push(arguments)};var a=f[z]._={
},q=c.methods.length;while(q--){(function(n){f[z][n]=function(){
f[z]("call",n,arguments)}})(c.methods[q])}a.l=c.loader;a.i=nt;a.p={
0:+new Date};a.P=function(u){
a.p[u]=new Date-a.p[0]};function s(){
a.P(r);f[z](r)}f.addEventListener?f.addEventListener(r,s,false):f.attachEvent("on"+r,s);var ld=function(){function p(hd){
hd="head";return["<",hd,"></",hd,"><",i,' onl' + 'oad="var d=',g,";d.getElementsByTagName('head')[0].",j,"(d.",h,"('script')).",k,"='",l,"//",a.l,"'",'"',"></",i,">"].join("")}var i="body",m=d[i];if(!m){
return setTimeout(ld,100)}a.P(1);var j="appendChild",h="createElement",k="src",n=d[h]("div"),v=n[j](d[h](z)),b=d[h]("iframe"),g="document",e="domain",o;n.style.display="none";m.insertBefore(n,m.firstChild).id=z;b.frameBorder="0";b.id=z+"-loader";if(/MSIE[ ]+6/.test(navigator.userAgent)){
b.src="javascript:false"}b.allowTransparency="true";v[j](b);try{
b.contentWindow[g].open()}catch(w){
c[e]=d[e];o="javascript:var d="+g+".open();d.domain='"+d.domain+"';";b[k]=o+"void(0);"}try{
var t=b.contentWindow[g];t.write(p());t.close()}catch(x){
b[k]=o+'d.write("'+p().replace(/"/g,String.fromCharCode(92)+'"')+'");d.close();'}a.P(2)};ld()};nt()})({
loader: "static.olark.com/jsclient/loader0.js",name:"olark",methods:["configure","extend","declare","identify"]});
/* custom configuration goes here (www.olark.com/documentation) */
olark.identify('{{ OLARK_SITE_ID }}');/*]]>*/</script><noscript><a href="https://www.olark.com/site/2036-772-10-9217/contact" title="Contact us" target="_blank">Questions? Feedback?</a> powered by <a href="http://www.olark.com?welcome" title="Olark live chat software">Olark live chat software</a></noscript>
<!-- end olark code -->
<!-- Additional olark stuff -->
<script type="text/javascript">
function updateOlark(userData) {
var details = [];
if (userData.status.name) {
details.push(userData.status.name);
} else {
details.push('Guest User');
}
if (userData.status.cart_total_amount) {
details.push('Cart Total:' + userData.status.cart_total_amount);
details.push('Cart Size: ' + userData.status.cart_size);
}
olark('api.chat.updateVisitorNickname', {snippet: details});
};
userDataCallbacks.add(updateOlark);
</script>
<!-- END: Additional Olark Stuff -->
{% endif %}
</body>
</html>