cartCtrl.js
1.41 KB
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
'use strict';
angular.module('newApp').controller('cartCtrl', function ($scope) {
$scope.$on('$viewContentLoaded', function() {
setTimeout(function() {
cartWizard();
}, 100);
$('.wizard-validation').on('click', '.sf-btn', function() {
setTimeout(function() {
$(window).resize();
$(window).trigger('resize');
}, 0);
});
/* Remove Elements */
$(".shopping-cart-table .icons-office-52").on('click', function() {
$(this).closest('tr').fadeOut(200, function() {
$(this).closest('tr').remove();
var total = 0;
$('.item-total').each(function() {
total += +($(this).text());
});
$('.total p').text(total + '.00');
});
});
/* Update total on quantity change */
$(".shopping-cart-table .quantity").on('change', function() {
var quantity = $(this).val();
var itemPrice = $(this).closest('tr').find('.item-price').text();
var itemTotal = quantity * itemPrice;
$(this).closest('tr').find('.item-total').text(itemTotal + '.00');
var total = 0;
$('.item-total').each(function() {
total += +($(this).text());
});
$('.total p').text(total + '.00');
});
});
});