c80_yax 0.1.0.18 → 0.1.0.20
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +2 -1
- data/app/assets/images/c80_yax/stripe.png +0 -0
- data/app/assets/javascripts/c80_yax/frontend/item_color_selector/item_color_selector.js +11 -4
- data/app/assets/javascripts/c80_yax/frontend/item_quantity_picker/app.js +11 -3
- data/app/assets/javascripts/c80_yax/frontend/item_quantity_picker/item_quantity_picker.js +27 -2
- data/app/decorators/c80_yax/item_decorator.rb +4 -1
- data/app/views/c80_yax/items/_color_selector.html.erb +2 -2
- data/app/views/c80_yax/items/_index.html.erb +4 -1
- data/config/routes.rb +1 -0
- data/engines/co/README.md +21 -17
- data/engines/co/app/admin/co/order_messages.rb +23 -0
- data/engines/co/app/assets/javascripts/co/_service/cookies_service.js +71 -2
- data/engines/co/app/assets/javascripts/co/add_to_cart/actions/add_row_to_cart.js +2 -2
- data/engines/co/app/assets/javascripts/co/add_to_cart/{xapp.js → app.js} +0 -0
- data/engines/co/app/assets/javascripts/co/add_to_cart/button_add_to_cart.js +1 -0
- data/engines/co/app/assets/javascripts/co/add_to_cart/service/collect_data_for_row.js +5 -1
- data/engines/co/app/assets/javascripts/co/add_to_cart_sm/actions/add_row_to_cart_sm.js +17 -0
- data/engines/co/app/assets/javascripts/co/add_to_cart_sm/app.js +17 -0
- data/engines/co/app/assets/javascripts/co/add_to_cart_sm/button_add_to_cart_sm.js +36 -0
- data/engines/co/app/assets/javascripts/co/add_to_cart_sm/service/collect_data_for_row_sm.js +37 -0
- data/engines/co/app/assets/javascripts/co/cart_page/app.js +2 -1
- data/engines/co/app/assets/javascripts/co/cart_page/cart_page.js +37 -1
- data/engines/co/app/assets/javascripts/co/cart_page/cart_table.js +35 -11
- data/engines/co/app/assets/javascripts/co/cart_page/message-order-form-ajax.js +53 -0
- data/engines/co/app/assets/javascripts/co/cart_page/support/row_maker.js +2 -2
- data/engines/co/app/assets/javascripts/co/cart_page/support/row_printer.js +43 -0
- data/engines/co/app/assets/javascripts/co/goto_cart/app.js +19 -0
- data/engines/co/app/assets/javascripts/co/goto_cart/button_goto_cart.js +40 -0
- data/engines/co/app/assets/stylesheets/co/cart_page/form.scss +142 -0
- data/engines/co/app/controllers/co/cart_controller.rb +27 -0
- data/engines/co/app/helpers/co/cart_page_helper.rb +24 -2
- data/engines/co/app/mailers/co/order_message_mailer.rb +29 -0
- data/engines/co/app/models/co/order_message.rb +5 -0
- data/engines/co/app/models/co/order_message_validator.rb +22 -0
- data/engines/co/app/views/co/_cart_page.html.erb +4 -6
- data/engines/co/app/views/co/cart/give_me_cart_order_form.js.erb +18 -0
- data/engines/co/app/views/co/cart/message_cart_order.js.erb +4 -0
- data/engines/co/app/views/co/cart/shared/_cart_order_form.html.erb +83 -0
- data/engines/co/app/views/co/cart/shared/_ok_message.html.erb +16 -0
- data/engines/co/app/views/co/order_message_mailer/mail_mess.html.erb +1 -0
- data/engines/co/config/routes.rb +4 -0
- data/engines/co/db/migrate/20170723095252_create_co_order_messages.rb +13 -0
- data/engines/co/lib/co/engine.rb +1 -1
- data/engines/of/lib/of/engine.rb +1 -1
- data/lib/c80_yax/version.rb +1 -1
- metadata +25 -4
- data/engines/co/app/assets/javascripts/co/add_to_cart/data_order_row.js +0 -16
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 041fbacb1e43b64b2db9667790ad9d1779569333
|
4
|
+
data.tar.gz: f7995f6e3f18f0aa3e869818c99eae75ced5622c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1668b05f1292d286d96dcc12ebf445bdbc503bb92fcdcbd215e7ec0296f91ba7101d1aadacff6d9dca1aa1258e54f2724716f8090fcafdb72c47623ba16981f9
|
7
|
+
data.tar.gz: 57a9bb1ac7b5053fe9f796ef4a0225c4ee2c69fd8b9473b6aaecd946b06c627e9bbf9f1ae32e8fafb75289e48e9931b5ffb6d24fdca5e09df77677bacd8f7ad4
|
data/Gemfile
CHANGED
Binary file
|
@@ -1,24 +1,29 @@
|
|
1
1
|
"use strict";
|
2
2
|
|
3
|
+
// _color_selector.html.erb
|
4
|
+
|
3
5
|
var ItemColorSelector = function(wrapper) {
|
4
6
|
|
5
7
|
var _$wrapper;
|
6
8
|
var _$lic;
|
7
9
|
var _sel_color;
|
10
|
+
var _sel_color_title;
|
8
11
|
|
9
|
-
var _get_sel_color = function() {
|
10
|
-
return
|
12
|
+
var _get_sel_color = function(mark_return_title) {
|
13
|
+
return (mark_return_title) ? _sel_color_title:_sel_color;
|
11
14
|
};
|
12
15
|
|
13
|
-
var _set_sel_color = function(new_color) {
|
16
|
+
var _set_sel_color = function(new_color, new_color_title) {
|
14
17
|
_sel_color = new_color;
|
18
|
+
_sel_color_title = new_color_title;
|
15
19
|
};
|
16
20
|
|
17
21
|
var _onClickColorBox = function(e) {
|
18
22
|
e.preventDefault();
|
19
23
|
var $t = $(e.target);
|
20
24
|
var t_color = $t.data('color');
|
21
|
-
|
25
|
+
var t_color_title = $t.data('color_title');
|
26
|
+
_set_sel_color(t_color, t_color_title);
|
22
27
|
_$lic.removeClass('active');
|
23
28
|
$t.addClass('active');
|
24
29
|
};
|
@@ -33,6 +38,8 @@ var ItemColorSelector = function(wrapper) {
|
|
33
38
|
|
34
39
|
_$wrapper = $(wrapper);
|
35
40
|
_$lic = _$wrapper.find('li.c');
|
41
|
+
_sel_color = '';
|
42
|
+
_sel_color_title = 'не указан';
|
36
43
|
|
37
44
|
_fInitRadioBehaviour();
|
38
45
|
|
@@ -2,10 +2,18 @@
|
|
2
2
|
|
3
3
|
var ITEM_QUANTITY_PICKERS = {};
|
4
4
|
|
5
|
-
var _activate_q_picker = function() {
|
5
|
+
var _activate_q_picker = function(onChange) {
|
6
6
|
$('.quantity_picker').each(function() {
|
7
|
-
|
8
|
-
|
7
|
+
var $t = $(this);
|
8
|
+
if ($t.data('initalized') == '1') return;
|
9
|
+
$t.data('initalized', '1');
|
10
|
+
var id = $t.data('id');
|
11
|
+
var ip = new ItemQuantityPicker(this);
|
12
|
+
ITEM_QUANTITY_PICKERS[ id ] = ip;
|
13
|
+
|
14
|
+
if (onChange !== undefined) {
|
15
|
+
ip.on_change(onChange);
|
16
|
+
}
|
9
17
|
});
|
10
18
|
};
|
11
19
|
|
@@ -5,9 +5,32 @@ var ItemQuantityPicker = function (wrapper){
|
|
5
5
|
var _$wrapper;
|
6
6
|
var _$less, _$great, _$input;
|
7
7
|
var _cur_val;
|
8
|
+
var __callbacks;
|
9
|
+
|
10
|
+
var _on_change = function(func) {
|
11
|
+
if (__callbacks === null) return;
|
12
|
+
__callbacks.push(func);
|
13
|
+
};
|
14
|
+
|
15
|
+
var _call_on_change = function() {
|
16
|
+
if (__callbacks === null) return;
|
17
|
+
|
18
|
+
for (var i = 0; i < __callbacks.length; i++) {
|
19
|
+
if (__callbacks[i] !== undefined) {
|
20
|
+
__callbacks[i](_get_cur_val());
|
21
|
+
}
|
22
|
+
}
|
23
|
+
};
|
8
24
|
|
9
25
|
var _set_cur_val = function (new_val){
|
10
|
-
|
26
|
+
if (new_val !== _cur_val) {
|
27
|
+
if (new_val === 0) {
|
28
|
+
_cur_val = 1;
|
29
|
+
} else {
|
30
|
+
_cur_val = new_val;
|
31
|
+
_call_on_change();
|
32
|
+
}
|
33
|
+
}
|
11
34
|
};
|
12
35
|
|
13
36
|
var _get_cur_val = function() {
|
@@ -49,6 +72,7 @@ var ItemQuantityPicker = function (wrapper){
|
|
49
72
|
_$great = _$wrapper.find('a.g');
|
50
73
|
_$input = _$wrapper.find('input');
|
51
74
|
_cur_val = _$input.val();
|
75
|
+
__callbacks = [];
|
52
76
|
|
53
77
|
_fInitBehaviour();
|
54
78
|
|
@@ -57,7 +81,8 @@ var ItemQuantityPicker = function (wrapper){
|
|
57
81
|
_fInit(wrapper);
|
58
82
|
|
59
83
|
return {
|
60
|
-
get_cur_val: _get_cur_val
|
84
|
+
get_cur_val: _get_cur_val,
|
85
|
+
on_change: _on_change
|
61
86
|
}
|
62
87
|
|
63
88
|
};
|
@@ -2,8 +2,8 @@
|
|
2
2
|
<li class="caption">Цвет: </li>
|
3
3
|
<% colors.each do |color| %>
|
4
4
|
<% style = "style='background-color: #{color.value}'".html_safe %>
|
5
|
-
<% data = "data-color='#{color.value}'".html_safe %>
|
5
|
+
<% data = "data-color='#{color.value}' data-color_title='#{color.title}'".html_safe %>
|
6
6
|
<% klass = "class='c c_#{color.id}'".html_safe %>
|
7
|
-
<li <%=style%> <%=klass%> <%=data
|
7
|
+
<li title="<%= color.title %>" <%=style%> <%=klass%> <%=data%>></li>
|
8
8
|
<% end %>
|
9
9
|
</ul>
|
@@ -1,6 +1,9 @@
|
|
1
1
|
<ul class="item_index">
|
2
2
|
<% items.each do |item| %>
|
3
|
-
<li class="li_item i_<%= item.id%>"
|
3
|
+
<li class="li_item i_<%= item.id%>"
|
4
|
+
data-item_url="<%= item.my_url %>"
|
5
|
+
data-title="<%= item.title %>"
|
6
|
+
data-image_url="<%= item.fetch_first_photo('thumb_md') %>">
|
4
7
|
<%= item.main_image(thumb_size) %>
|
5
8
|
<%= item.h3_title(thumb_size) %>
|
6
9
|
<%= item.div_prices %>
|
data/config/routes.rb
CHANGED
data/engines/co/README.md
CHANGED
@@ -18,24 +18,29 @@
|
|
18
18
|
* в виджете-кнопке должно обновиться количество
|
19
19
|
|
20
20
|
#### При клике по виджету-кнопке "корзина":
|
21
|
-
* открывается новая страница, содержащая таблицу и форму.
|
22
|
-
* таблица:
|
23
|
-
- картинка-ссылка до товара, новое окно
|
24
|
-
- название
|
25
|
-
- цвет
|
26
|
-
- компонент выбора количества
|
27
|
-
- сумма
|
28
|
-
- кнопка "удалить"
|
29
|
-
|
30
|
-
*
|
31
|
-
|
32
|
-
|
21
|
+
* [X] открывается новая страница, содержащая таблицу и форму.
|
22
|
+
* [X] таблица:
|
23
|
+
- [X] картинка-ссылка до товара, новое окно
|
24
|
+
- [X] название
|
25
|
+
- [X] цвет
|
26
|
+
- [ ] компонент выбора количества
|
27
|
+
- [X] сумма
|
28
|
+
- [X] кнопка "удалить"
|
29
|
+
|
30
|
+
* [ ] строка "итого"
|
31
|
+
- [X] Должна содержать сумму цен всех строк
|
32
|
+
- [ ] должна пересчитываться при удалении строк из заказа
|
33
|
+
- [ ] должна пересчитываться при изменении кол-ва
|
34
|
+
* [X] чекбокс "заказать доставку"
|
35
|
+
* [X] кнопка "очистить корзину"
|
36
|
+
|
37
|
+
* [ ] форма:
|
33
38
|
* ФИО
|
34
39
|
* Мобильный
|
35
40
|
* Дата получения
|
36
41
|
* Населённый пункт
|
37
42
|
|
38
|
-
* когда нажимаем кнопку "отправить", уходит письмо с текстом вида:
|
43
|
+
* [ ] когда нажимаем кнопку "отправить", уходит письмо с текстом вида:
|
39
44
|
|
40
45
|
```
|
41
46
|
Заказ:
|
@@ -51,7 +56,6 @@
|
|
51
56
|
* перед тем, как уходит письмо, создаётся Объект `order` содержащий `rows`
|
52
57
|
- [ ] создать модель Order
|
53
58
|
- [ ] создать модель Row
|
54
|
-
- [ ]
|
55
59
|
|
56
60
|
# Todo Добавить в Корзину
|
57
61
|
|
@@ -71,9 +75,9 @@
|
|
71
75
|
- [X] реализовать js-компонент "опции"
|
72
76
|
- [X] добавить в js-компонент `id` товара (среди множества виджетов необходимо распознать релевантный)
|
73
77
|
- [X] добавить и испытать метод, выдающий текущий `value`
|
74
|
-
- [
|
75
|
-
- [ ] Находить на странице
|
76
|
-
- [ ] реализовать js-компонент '
|
78
|
+
- [X] На основе собранной инфы должен создавать объект `DataOrderRow` и помещать его в cookie.
|
79
|
+
- [ ] Находить на странице виджет "корзина-кнопка" и обновлять там количество `DataOrderRow` в корзине
|
80
|
+
- [ ] реализовать js-компонент 'корзина-кнопка'
|
77
81
|
- [ ] Публичный setter: `set_count`
|
78
82
|
- [X] Должен появиться `bootstrap modal` с кнопками "продолжить покупки", "перейти в корзину"
|
79
83
|
|
@@ -0,0 +1,23 @@
|
|
1
|
+
ActiveAdmin.register Co::OrderMessage, :as => 'OrderMessage' do
|
2
|
+
|
3
|
+
before_filter :skip_sidebar!, :only => :index
|
4
|
+
|
5
|
+
menu :label => 'Заказы',
|
6
|
+
:parent => 'x_c80_yax',
|
7
|
+
:priority => 20
|
8
|
+
|
9
|
+
index do
|
10
|
+
selectable_column
|
11
|
+
id_column
|
12
|
+
column :created_at
|
13
|
+
column :name
|
14
|
+
column :phone
|
15
|
+
column :comment do |msg|
|
16
|
+
msg.comment.html_safe if msg.comment.present?
|
17
|
+
end
|
18
|
+
|
19
|
+
actions
|
20
|
+
end
|
21
|
+
|
22
|
+
|
23
|
+
end
|
@@ -1,5 +1,19 @@
|
|
1
1
|
var CookiesService = function() {
|
2
2
|
|
3
|
+
var Support = function() {
|
4
|
+
this.find_all_by_id = function(array, id) {
|
5
|
+
var res = [];
|
6
|
+
for (var i = 0; i < array.length; i++) {
|
7
|
+
if (array[i]['id'] === id) {
|
8
|
+
res.push(i);
|
9
|
+
}
|
10
|
+
}
|
11
|
+
return res;
|
12
|
+
}
|
13
|
+
};
|
14
|
+
|
15
|
+
var __ = new Support();
|
16
|
+
|
3
17
|
var _create_cookie = function(name, value, days) {
|
4
18
|
var expires = '';
|
5
19
|
|
@@ -32,7 +46,35 @@ var CookiesService = function() {
|
|
32
46
|
this.cart_push = function(row_as_hash) {
|
33
47
|
var cart = _read_cookie('cart3');
|
34
48
|
if (cart === null) cart = [];
|
35
|
-
|
49
|
+
|
50
|
+
// если в корзине уже лежат товары этого id - найдём их все
|
51
|
+
var ids = __.find_all_by_id(cart, row_as_hash['id']);
|
52
|
+
|
53
|
+
if (ids.length !== 0) {
|
54
|
+
// пробежимся по этим товарам
|
55
|
+
var existent_row;
|
56
|
+
for (var i = 0; i < ids.length; i++) {
|
57
|
+
existent_row = cart[ids[i]];
|
58
|
+
// если цвет совпал - это товар того же цвета - мержим его
|
59
|
+
// console.log(existent_row['color']+'----'+row_as_hash['color']);
|
60
|
+
if (existent_row['color'] === row_as_hash['color']) {
|
61
|
+
var old_price = existent_row['price'];
|
62
|
+
var old_quantity = existent_row['q'];
|
63
|
+
var new_row = existent_row;
|
64
|
+
new_row['price'] = Number(old_price) + Number(row_as_hash['price']);
|
65
|
+
new_row['q'] = Number(old_quantity) + Number(row_as_hash['q']);
|
66
|
+
cart[ids[i]] = new_row;
|
67
|
+
break;
|
68
|
+
}
|
69
|
+
// если товар того же айди разного цвета - это разные товары, добавляем новый
|
70
|
+
else {
|
71
|
+
cart.push(row_as_hash);
|
72
|
+
}
|
73
|
+
}
|
74
|
+
} else {
|
75
|
+
cart.push(row_as_hash);
|
76
|
+
}
|
77
|
+
|
36
78
|
_create_cookie('cart3', cart, 256);
|
37
79
|
console.log('<CookiesService.cart_push>');
|
38
80
|
};
|
@@ -43,13 +85,40 @@ var CookiesService = function() {
|
|
43
85
|
}
|
44
86
|
|
45
87
|
this.cart_clean = function() {
|
46
|
-
console.log('<cart_clean>');
|
88
|
+
// console.log('<cart_clean>');
|
47
89
|
var cart = _read_cookie('cart3');
|
48
90
|
if (cart === null) return;
|
49
91
|
cart = [];
|
50
92
|
_create_cookie('cart3', cart, 256);
|
51
93
|
};
|
52
94
|
|
95
|
+
this.cart_update_row = function(row_id, color, obj_with_new_values) {
|
96
|
+
// console.log('<cart_update_row> row_id: ' + row_id + "; color: " + color);
|
97
|
+
var cart = _read_cookie('cart3');
|
98
|
+
for (var i = 0, row; i < cart.length; i++) {
|
99
|
+
row = cart[i];
|
100
|
+
if (row['id'] !== row_id) continue;
|
101
|
+
if (row['color'] !== color) continue;
|
102
|
+
for (var key in obj_with_new_values) {
|
103
|
+
row[key] = obj_with_new_values[key];
|
104
|
+
}
|
105
|
+
cart[i] = row; // нужно ли так делать?
|
106
|
+
}
|
107
|
+
_create_cookie('cart3', cart, 256);
|
108
|
+
}
|
53
109
|
|
110
|
+
this.cart_remove_row = function(row_id, color) {
|
111
|
+
var cart = _read_cookie('cart3');
|
112
|
+
for (var i = 0, row; i < cart.length; i++) {
|
113
|
+
row = cart[i];
|
114
|
+
if (row['id'] !== row_id) continue;
|
115
|
+
if (row['color'] !== color) continue;
|
116
|
+
console.log('<cart_remove_row> id: ' + row_id + ", color: " + color);
|
117
|
+
cart.splice(i,1);
|
118
|
+
_create_cookie('cart3', cart, 256);
|
119
|
+
return true;
|
120
|
+
}
|
121
|
+
return false;
|
122
|
+
}
|
54
123
|
|
55
124
|
};
|
@@ -4,8 +4,8 @@
|
|
4
4
|
var AddRowToCart = function(item_id) {
|
5
5
|
this.call = function() {
|
6
6
|
var row_as_hash = new CollectDataForRow(item_id).call();
|
7
|
-
console.log("<AddRowToCart.call> row_as_hash: " + row_as_hash);
|
8
|
-
console.log(row_as_hash);
|
7
|
+
// console.log("<AddRowToCart.call> row_as_hash: " + row_as_hash);
|
8
|
+
// console.log(row_as_hash);
|
9
9
|
|
10
10
|
coo.cart_push(row_as_hash);
|
11
11
|
|
File without changes
|
@@ -8,9 +8,11 @@ var CollectDataForRow = function(item_id) {
|
|
8
8
|
var $item_show = $('.item_show_'+item_id);
|
9
9
|
|
10
10
|
var q = ITEM_QUANTITY_PICKERS[item_id].get_cur_val();
|
11
|
-
var
|
11
|
+
var price_per_item = Number($item_show.find('.price_props p.cur span.pvalue').text().split(',').join('.'));
|
12
|
+
var price = q * price_per_item;
|
12
13
|
var title = $item_show.data('title');
|
13
14
|
var color = ITEM_COLOR_SELECTOR[item_id].get_cur_val();
|
15
|
+
var color_title = ITEM_COLOR_SELECTOR[item_id].get_cur_val(true);
|
14
16
|
var options = ITEM_OPTIONS[item_id].get_cur_val();
|
15
17
|
|
16
18
|
return {
|
@@ -18,7 +20,9 @@ var CollectDataForRow = function(item_id) {
|
|
18
20
|
title: title,
|
19
21
|
q: q,
|
20
22
|
color: color,
|
23
|
+
color_title: color_title,
|
21
24
|
price: price,
|
25
|
+
price_per_item: price_per_item,
|
22
26
|
image_url: $item_show.data('image_url'),
|
23
27
|
item_url: $item_show.data('item_url'),
|
24
28
|
options: {
|
@@ -0,0 +1,17 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
// добавляет
|
4
|
+
var AddRowToCartSm = function(item_id) {
|
5
|
+
this.call = function() {
|
6
|
+
var row_as_hash = new CollectDataForRowSm(item_id).call();
|
7
|
+
console.log("<AddRowToCartSm.call> row_as_hash: " + row_as_hash);
|
8
|
+
console.log(row_as_hash);
|
9
|
+
|
10
|
+
coo.cart_push(row_as_hash);
|
11
|
+
|
12
|
+
return {
|
13
|
+
result: true,
|
14
|
+
message: '1 товар добавлено в корзину.'
|
15
|
+
}
|
16
|
+
}
|
17
|
+
};
|
@@ -0,0 +1,17 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
var $ss;
|
4
|
+
|
5
|
+
var _activate_cart_button_sm = function() {
|
6
|
+
$ss.each(function() {
|
7
|
+
new ButtonAddToCartSm(this);
|
8
|
+
});
|
9
|
+
};
|
10
|
+
|
11
|
+
$(document).ready(function() {
|
12
|
+
$ss = $('.add_to_bucket_sm');
|
13
|
+
if ($ss.length !== 0) {
|
14
|
+
// alert(ButtonAddToCart);
|
15
|
+
_activate_cart_button_sm();
|
16
|
+
}
|
17
|
+
});
|
@@ -0,0 +1,36 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
var ButtonAddToCartSm = function(selector) {
|
4
|
+
|
5
|
+
var _$btn;
|
6
|
+
var _item_id;
|
7
|
+
|
8
|
+
var _onClickBtn = function(e) {
|
9
|
+
console.log('<_onClickBtn>');
|
10
|
+
e.preventDefault();
|
11
|
+
var c = new AddRowToCartSm(_item_id).call();
|
12
|
+
if (c.result) {
|
13
|
+
// com.showDouble(c.message);
|
14
|
+
com.showDouble('Продолжить покупки?');
|
15
|
+
ButtonGotoCart.refresh_count();
|
16
|
+
}
|
17
|
+
};
|
18
|
+
|
19
|
+
var _fInitBehaviour = function (){
|
20
|
+
if (_$btn.length <= 0) return;
|
21
|
+
_$btn.on('click', _onClickBtn);
|
22
|
+
};
|
23
|
+
|
24
|
+
/**
|
25
|
+
* selector = "add_to_bucket_sm_#{item.id}"
|
26
|
+
* @param selector
|
27
|
+
*/
|
28
|
+
var _fInit = function (selector){
|
29
|
+
_$btn = $(selector);
|
30
|
+
_item_id = _$btn.data('id');
|
31
|
+
_fInitBehaviour();
|
32
|
+
};
|
33
|
+
|
34
|
+
_fInit(selector);
|
35
|
+
|
36
|
+
};
|
@@ -0,0 +1,37 @@
|
|
1
|
+
// собирает данные для строки после
|
2
|
+
// нажатия мелкой кнопки "в корзину"
|
3
|
+
|
4
|
+
var CollectDataForRowSm = function(item_id) {
|
5
|
+
this.call = function() {
|
6
|
+
console.log("<CollectDataForRowSm.call> item_id = " + item_id);
|
7
|
+
|
8
|
+
var $item_show = $('.li_item.i_'+item_id);
|
9
|
+
|
10
|
+
var q = 1;
|
11
|
+
var price_per_item = Number($item_show.find('.price_props p.cur span.pvalue').text().split(',').join('.'));
|
12
|
+
var price = q * price_per_item;
|
13
|
+
var title = $item_show.data('title');
|
14
|
+
var color = '';
|
15
|
+
var color_title = 'не указан';
|
16
|
+
var options = {delivery:false, super_colors:false, metallic:false};
|
17
|
+
|
18
|
+
return {
|
19
|
+
id: item_id,
|
20
|
+
title: title,
|
21
|
+
q: q,
|
22
|
+
color: color,
|
23
|
+
color_title: color_title,
|
24
|
+
price: price,
|
25
|
+
price_per_item: price_per_item,
|
26
|
+
image_url: $item_show.data('image_url'),
|
27
|
+
item_url: $item_show.data('item_url'),
|
28
|
+
options: {
|
29
|
+
mark_delivery: options['delivery'],
|
30
|
+
mark_super_colors: options['super_colors'],
|
31
|
+
mark_metallic: options['metallic']
|
32
|
+
}
|
33
|
+
}
|
34
|
+
|
35
|
+
}
|
36
|
+
|
37
|
+
};
|
@@ -5,12 +5,33 @@ var CartPage = function($cart_page) {
|
|
5
5
|
var _cart_table;
|
6
6
|
var _$clear_btn;
|
7
7
|
var _$result_price_val;
|
8
|
+
var _$delivery_checkbox;
|
9
|
+
var _support;
|
10
|
+
|
8
11
|
var _fill_table = function() {
|
9
12
|
var cart = coo.cart_get();
|
10
13
|
for (var i = 0; i < cart.length; i++) {
|
11
14
|
_cart_table.add_row(cart[i]);
|
12
15
|
}
|
13
16
|
};
|
17
|
+
var _print_table = function() {
|
18
|
+
var res = '';
|
19
|
+
var cart = coo.cart_get();
|
20
|
+
for (var i = 0; i < cart.length; i++) {
|
21
|
+
res += _support.print_row(cart[i]);
|
22
|
+
}
|
23
|
+
res += _support.print_bottom_row({
|
24
|
+
order_price: _$result_price_val.text(),
|
25
|
+
deliver: _$delivery_checkbox[0].checked ? 'да':'нет'
|
26
|
+
});
|
27
|
+
res = "<table border='1' cellpadding='0' cellspacing='0'>" + res + "</table>";
|
28
|
+
return res;
|
29
|
+
};
|
30
|
+
var _print_table_to_comment = function() {
|
31
|
+
var ss = _print_table();
|
32
|
+
console.log(ss);
|
33
|
+
$cc.find('#mess_comment').val(ss);
|
34
|
+
}
|
14
35
|
var _calc_result_price = function() {
|
15
36
|
var cart = coo.cart_get();
|
16
37
|
var result = 0;
|
@@ -23,7 +44,17 @@ var CartPage = function($cart_page) {
|
|
23
44
|
e.preventDefault();
|
24
45
|
_cart_table.clear();
|
25
46
|
coo.cart_clean();
|
47
|
+
_calc_result_price();
|
48
|
+
_print_table_to_comment();
|
49
|
+
ButtonGotoCart.refresh_count();
|
26
50
|
};
|
51
|
+
var _on_row_changed = function(row_id, color, obj_with_new_values) {
|
52
|
+
console.log('<_on_row_changed>');
|
53
|
+
coo.cart_update_row(row_id, color, obj_with_new_values);
|
54
|
+
_calc_result_price();
|
55
|
+
_print_table_to_comment();
|
56
|
+
ButtonGotoCart.refresh_count();
|
57
|
+
}
|
27
58
|
var _fInitBehaviour = function (){
|
28
59
|
_fill_table();
|
29
60
|
_calc_result_price();
|
@@ -32,10 +63,15 @@ var CartPage = function($cart_page) {
|
|
32
63
|
};
|
33
64
|
var _fInit = function($cart_page) {
|
34
65
|
_$cart_page = $cart_page;
|
35
|
-
_cart_table = new CartTable(_$cart_page.find('table.cart_table'));
|
66
|
+
_cart_table = new CartTable(_$cart_page.find('table.cart_table'), _on_row_changed);
|
36
67
|
_$clear_btn = $cart_page.find('.clear_btn');
|
37
68
|
_$result_price_val = $cart_page.find('.bottom_row .result .val');
|
69
|
+
_$delivery_checkbox = $cart_page.find('.bottom_row div.checkbox input');
|
70
|
+
_support = new RowPrinter();
|
38
71
|
_fInitBehaviour();
|
39
72
|
};
|
40
73
|
_fInit($cart_page);
|
74
|
+
return {
|
75
|
+
print_table_to_comment: _print_table_to_comment
|
76
|
+
}
|
41
77
|
};
|