This repository has been archived by the owner on Jul 15, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
script.js
81 lines (71 loc) · 1.92 KB
/
script.js
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
var paperkit = new Materializer();
window.addEventListener('load', function(){
paperkit.init();
// Ading event listeners to offers
[].forEach.call(document.querySelectorAll('.offer'), function(offer){
offer.addEventListener('click', function(e){
var el = e.currentTarget;
showBeer(el);
});
});
});
function goTo(el){
var id = el.getAttribute('data-page');
var page = document.getElementById(id);
page.scrollIntoView();
document.body.scrollIntoView();
paperkit.sidemenu.close();
}
function searchBeer(el){
var paper = document.getElementById('search-paper');
showBeer(paper);
}
function showBeer(el){
var beer = 1;
if (el.hasAttribute('data-beer')) {
beer = el.getAttribute('data-beer');
};
paperkit.fab.hide();
var page = 'cerve'+beer+'.html';
console.log(page);
transition.morph(el,false,function(beer){
paperkit.ajaxInsert(page,beer,function(response,parent){
paperkit.initElement(parent);
var cerve = document.getElementById('transition-cerve');
cerve.style.opacity = 0;
setTimeout(function(){
cerve.style.display = 'none';
},500)
});
});
}
function hideBeer(){
paperkit.fab.show();
transition.morphBack();
}
function sendOrder(amount, beer, callback){
num_beers = amount;
beer_price = beer;
total_amount = num_beers * beer_price;
orderJson = {
'total_amount' : total_amount,
'goods' : 'beer'
}
//$.post("/pagar",{suggest:orderJson},function(result){
// alert(result.status);
callback();
//});
}
function payBeer(){
var q = document.getElementById('quantity').value;
sendOrder(q, 2, function(){
paperkit.fab.querySelector('md-icon').setAttribute('md-image','icon:done');
paperkit.fab.setAttribute('md-color','green');
paperkit.fab.show();
setTimeout(function(){
paperkit.fab.querySelector('md-icon').setAttribute('md-image','icon:search');
paperkit.fab.setAttribute('md-color','brown');
hideBeer();
},1000);
});
}