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
@@ -1,30 +1,50 @@
|
|
1
1
|
"use strict";
|
2
2
|
|
3
|
-
var CartTable = function ($table){
|
3
|
+
var CartTable = function ($table, on_changd){
|
4
4
|
|
5
|
+
var _this = this;
|
5
6
|
var _rows;
|
6
7
|
var _$table;
|
7
8
|
var _$tbody;
|
8
9
|
var _support;
|
10
|
+
var __on_changed;
|
9
11
|
|
10
12
|
//<editor-fold desc="// Инициализация">
|
11
13
|
var _fInitBehaviour = function (){
|
12
14
|
};
|
13
|
-
var _fInit = function ($table){
|
15
|
+
var _fInit = function ($table, on_changed){
|
14
16
|
_$table = $table;
|
15
17
|
_$tbody = _$table.find('tbody');
|
16
18
|
_support = new RowMaker();
|
17
19
|
_rows = [];
|
20
|
+
__on_changed = on_changed;
|
18
21
|
_fInitBehaviour();
|
19
22
|
};
|
20
|
-
_fInit($table);
|
23
|
+
_fInit($table, on_changd);
|
21
24
|
//</editor-fold>
|
22
25
|
|
26
|
+
var _on_click_delete_row = function(e) {
|
27
|
+
var $t = $(e.target);
|
28
|
+
var id = $t.data('id');
|
29
|
+
var color = $t.data('color');
|
30
|
+
|
31
|
+
if (coo.cart_remove_row(id, color)) {
|
32
|
+
_this.remove_row(id, color);
|
33
|
+
__on_changed(id, color, {});
|
34
|
+
}
|
35
|
+
};
|
36
|
+
|
23
37
|
this.add_row = function(row_hash) {
|
24
38
|
_rows.push(row_hash);
|
25
39
|
var $row = $(_support.make_row_htmlstr(row_hash));
|
26
40
|
_$tbody.append($row);
|
27
|
-
|
41
|
+
$row.find('.del_action').on('click', _on_click_delete_row);
|
42
|
+
_activate_q_picker(function(value_after_change) {
|
43
|
+
console.log('<value_after_change> ' + value_after_change);
|
44
|
+
var new_price = value_after_change * $row.data('price_per_item');
|
45
|
+
$row.find('td.price').text(new_price);
|
46
|
+
__on_changed($row.data('id'), $row.data('color'), {price: new_price, q:value_after_change });
|
47
|
+
});
|
28
48
|
};
|
29
49
|
|
30
50
|
this.clear = function() {
|
@@ -35,15 +55,19 @@ var CartTable = function ($table){
|
|
35
55
|
_rows = [];
|
36
56
|
};
|
37
57
|
|
38
|
-
this.remove_row = function(id) {
|
39
|
-
var i, n = _rows.length;
|
58
|
+
this.remove_row = function(id, color) {
|
59
|
+
var i, n = _rows.length - 1;
|
40
60
|
for (i = n; i>=0; i--) {
|
41
|
-
if (_rows[i]['id']
|
42
|
-
|
43
|
-
|
44
|
-
|
61
|
+
if (_rows[i]['id'] !== id) continue;
|
62
|
+
if (_rows[i]['color'] !== color) continue;
|
63
|
+
_rows.splice(i, 1);
|
64
|
+
break;
|
45
65
|
}
|
46
|
-
$('.tr_'+id).
|
66
|
+
$('.tr_'+id).each(function() {
|
67
|
+
var $t = $(this);
|
68
|
+
if ($t.data('color') !== color) return;
|
69
|
+
$t.remove();
|
70
|
+
});
|
47
71
|
};
|
48
72
|
|
49
73
|
};
|
@@ -0,0 +1,53 @@
|
|
1
|
+
|
2
|
+
// =[ interface ]=====================================================================================================================
|
3
|
+
|
4
|
+
var $cart_form_container;
|
5
|
+
var markInvalidateInProgress = false;
|
6
|
+
var markWasPasted = false;
|
7
|
+
var fCartFormInvalidate;
|
8
|
+
var fCartFormOnScroll;
|
9
|
+
|
10
|
+
// =[ implementation ]=====================================================================================================================
|
11
|
+
|
12
|
+
$(function () {
|
13
|
+
|
14
|
+
$cart_form_container = $("div#cart_form_container");
|
15
|
+
|
16
|
+
if ($cart_form_container.length === 1) {
|
17
|
+
|
18
|
+
fCartFormInvalidate = function () {
|
19
|
+
if (!markInvalidateInProgress) {
|
20
|
+
markInvalidateInProgress = true;
|
21
|
+
|
22
|
+
if (!markWasPasted) {
|
23
|
+
|
24
|
+
$('<div id="loading"></div>').appendTo($cart_form_container);
|
25
|
+
|
26
|
+
$.ajax({
|
27
|
+
url: '/give_me_cart_order_form',
|
28
|
+
type: 'GET',
|
29
|
+
dataType: 'script'
|
30
|
+
}).done(function (data, result) {
|
31
|
+
if (result === "success") {
|
32
|
+
markWasPasted = true;
|
33
|
+
}
|
34
|
+
});
|
35
|
+
}
|
36
|
+
}
|
37
|
+
};
|
38
|
+
|
39
|
+
fCartFormOnScroll = function(event) {
|
40
|
+
var closeToBottom = jQuery(window).scrollTop() >= 0;
|
41
|
+
if (closeToBottom) {
|
42
|
+
fCartFormInvalidate();
|
43
|
+
}
|
44
|
+
};
|
45
|
+
|
46
|
+
// start
|
47
|
+
$(document).bind('scroll', fCartFormOnScroll);
|
48
|
+
setTimeout(function () {
|
49
|
+
fCartFormOnScroll();
|
50
|
+
},300);
|
51
|
+
|
52
|
+
}
|
53
|
+
});
|
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
var RowMaker = function() {
|
4
4
|
|
5
|
-
var _ROW = '<tr class="tr_{{ id }}">' +
|
5
|
+
var _ROW = '<tr class="tr_{{ id }}" data-price_per_item="{{ price_per_item }}" data-id="{{ id }}" data-color="{{ color }}">' +
|
6
6
|
'<td class="image">' +
|
7
7
|
'<a class="lazy-image-wrapper" href=" {{ item_url }}" target="_blank" title="{{ title }}">' +
|
8
8
|
'<img data-original="{{ image_url }}" alt="{{ title }}">' +
|
@@ -22,7 +22,7 @@ var RowMaker = function() {
|
|
22
22
|
'</div>' +
|
23
23
|
'</td>' +
|
24
24
|
'<td class="price">{{ price }}</td>' +
|
25
|
-
'<td class="actions"><a title="Удалить" class="del_action" data-id="{{ id }}">Удалить</a></td>' +
|
25
|
+
'<td class="actions"><a title="Удалить" class="del_action" data-id="{{ id }}" data-color="{{ color }}">Удалить</a></td>' +
|
26
26
|
'</tr>';
|
27
27
|
|
28
28
|
this.make_row_htmlstr = function(obj) {
|
@@ -0,0 +1,43 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
var RowPrinter = function() {
|
4
|
+
|
5
|
+
var _ROW = '<tr>' +
|
6
|
+
'<td style="width:290px;">' +
|
7
|
+
'<a href=" {{ item_url }}" title="{{ title }}">' +
|
8
|
+
'{{ title }}' +
|
9
|
+
'</a>' +
|
10
|
+
'</td>' +
|
11
|
+
'<td style="width:130px;">' +
|
12
|
+
'Цвет: {{ color_title }}' +
|
13
|
+
'</td>' +
|
14
|
+
'<td style="width:150px;">' +
|
15
|
+
'Кол-во: {{ q }}' +
|
16
|
+
'</td>' +
|
17
|
+
'<td style="width:190px;">Цена: {{ price }}</td>' +
|
18
|
+
'</tr>';
|
19
|
+
|
20
|
+
var _BOTTOM_ROW = '<tr>' +
|
21
|
+
'<td colspan="2">Итого: {{ order_price }}</td>' +
|
22
|
+
'<td colspan="2">Доставка: {{ deliver }}</td>' +
|
23
|
+
'</tr>';
|
24
|
+
|
25
|
+
var _print = function(obj, pattern) {
|
26
|
+
var res = pattern;
|
27
|
+
var al;
|
28
|
+
for ( var key in obj ){
|
29
|
+
al = "{{ " + key + " }}";
|
30
|
+
res = res.split(al).join(obj[key]);
|
31
|
+
}
|
32
|
+
return res;
|
33
|
+
};
|
34
|
+
|
35
|
+
this.print_row = function(obj) {
|
36
|
+
return _print(obj, _ROW);
|
37
|
+
};
|
38
|
+
|
39
|
+
this.print_bottom_row = function(obj) {
|
40
|
+
return _print(obj, _BOTTOM_ROW);
|
41
|
+
};
|
42
|
+
|
43
|
+
};
|
@@ -0,0 +1,19 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
var $ss;
|
4
|
+
|
5
|
+
var _activate_goto_card = function() {
|
6
|
+
$ss.each(function() {
|
7
|
+
var ins = new ButtonGotoCart(this);
|
8
|
+
ButtonGotoCart.instances.push(ins);
|
9
|
+
});
|
10
|
+
ButtonGotoCart.refresh_count();
|
11
|
+
};
|
12
|
+
|
13
|
+
$(document).ready(function() {
|
14
|
+
$ss = $('.b_make_order a');
|
15
|
+
if ($ss.length !== 0) {
|
16
|
+
// alert(ButtonAddToCart);
|
17
|
+
_activate_goto_card();
|
18
|
+
}
|
19
|
+
});
|
@@ -0,0 +1,40 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
var ButtonGotoCart = function(selector) {
|
4
|
+
|
5
|
+
var _$btn;
|
6
|
+
var _$counter;
|
7
|
+
|
8
|
+
//<editor-fold desc="// инициализация">
|
9
|
+
var _fInitBehaviour = function (){
|
10
|
+
if (_$btn.length <= 0) return;
|
11
|
+
};
|
12
|
+
var _fInit = function (selector){
|
13
|
+
_$btn = $(selector);
|
14
|
+
_$counter = $('<div class="counter"></div>');
|
15
|
+
_$counter.appendTo(_$btn);
|
16
|
+
_fInitBehaviour();
|
17
|
+
};
|
18
|
+
_fInit(selector);
|
19
|
+
//</editor-fold>
|
20
|
+
|
21
|
+
this.set_count = function(new_val) {
|
22
|
+
console.log('<ButtonGotoCart#set_count>');
|
23
|
+
_$counter.text(new_val);
|
24
|
+
}
|
25
|
+
|
26
|
+
};
|
27
|
+
|
28
|
+
ButtonGotoCart.instances = [];
|
29
|
+
ButtonGotoCart.refresh_count = function() {
|
30
|
+
console.log('<ButtonGotoCart.refresh_count>');
|
31
|
+
var cart = coo.cart_get();
|
32
|
+
var new_val = 0;
|
33
|
+
for (var i = 0; i < cart.length; i++) {
|
34
|
+
new_val += Number(cart[i]['q']);
|
35
|
+
}
|
36
|
+
for (var i = 0; i < ButtonGotoCart.instances.length; i++) {
|
37
|
+
var ins = ButtonGotoCart.instances[i];
|
38
|
+
ins.set_count(new_val);
|
39
|
+
}
|
40
|
+
}
|
@@ -0,0 +1,142 @@
|
|
1
|
+
div.card_row {
|
2
|
+
@include clearfix;
|
3
|
+
margin-bottom: 30px;
|
4
|
+
> div {
|
5
|
+
float: left;
|
6
|
+
width: 50%;
|
7
|
+
&#policy {
|
8
|
+
padding-left: 20px;
|
9
|
+
}
|
10
|
+
}
|
11
|
+
}
|
12
|
+
|
13
|
+
#cart_form_container {
|
14
|
+
margin: 0;
|
15
|
+
background-color: transparent;
|
16
|
+
min-height: 300px;
|
17
|
+
position: relative;
|
18
|
+
* { &:focus { outline: none !important; } }
|
19
|
+
|
20
|
+
#loading {
|
21
|
+
position: absolute;
|
22
|
+
top: 0;
|
23
|
+
left: 0;
|
24
|
+
bottom: 0;
|
25
|
+
right: 0;
|
26
|
+
text-align: center;
|
27
|
+
font-size: 20px;
|
28
|
+
background: rgba(255, 255, 255, 1) url(data:image/gif;base64,R0lGODlhIwAjAPUAAP///zLIMuL24tn02fH68czwzPL78vr9+tLy0tz13Of458/xz/f899fz1+z57N/138Xvxer46pfil7LqsjvKO33bfZ3knZPhk4rfijLIMoDcgGPVY7jruKrnqm3XbVXRVbzsvL3svaXmpXDYcHfad6jnqEjNSAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH/C05FVFNDQVBFMi4wAwEAAAAh/hpDcmVhdGVkIHdpdGggYW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gxgDWAcGBIdDxpysGAXEBwIQIQV0RAKLCxAIIDANST5ZFDIopBDizb9UihYk6GekwwaFGDNmwCBkAERkEKwUOXBRo0YPuj4uaPBA2ZEDBSSU1GgCxBADAxCsfOBgWsGXVULwdajwgcKHCqagOGhwKWgeoOEOFEzCwGPIZQjUPMCTAN4XBuMiioJAB+aib18cpOo3AAJaBXgiQlXiIK6iXMsUIRhibdHUkRAPqVUk2O41JQ8VuYWziCKCVHONJC6A19eieWYXRR75uMCDLJr2xjtWAK2Sdl4BENDU9ObmL3YWiQb3xNpi2k9W5/mLu4iCAS57C0cSBAA7AAAAAAAAAAAA) 50% 50% no-repeat;
|
29
|
+
z-index: 9999;
|
30
|
+
line-height: 3;
|
31
|
+
transition: visibility 1s, opacity 0.5s linear;
|
32
|
+
|
33
|
+
&.invis {
|
34
|
+
visibility: hidden;
|
35
|
+
opacity: 0;
|
36
|
+
}
|
37
|
+
|
38
|
+
}
|
39
|
+
|
40
|
+
div#cart_order_form { /* NOTE:: получается, на странице может быть только одна такая форма */
|
41
|
+
|
42
|
+
.modal-dialog {
|
43
|
+
width: auto;
|
44
|
+
margin: 0;
|
45
|
+
|
46
|
+
.modal-content {
|
47
|
+
box-shadow: none;
|
48
|
+
border: none;
|
49
|
+
/*background-color: transparent;*/
|
50
|
+
|
51
|
+
div.modal-header {
|
52
|
+
border-bottom: none !important;
|
53
|
+
}
|
54
|
+
|
55
|
+
div.modal-body {
|
56
|
+
padding: 0;
|
57
|
+
|
58
|
+
div.form-group {
|
59
|
+
margin-bottom: 25px;
|
60
|
+
|
61
|
+
&.hiddn {
|
62
|
+
width: 0;
|
63
|
+
height: 0;
|
64
|
+
position: absolute;
|
65
|
+
overflow: hidden;
|
66
|
+
}
|
67
|
+
|
68
|
+
label {
|
69
|
+
|
70
|
+
}
|
71
|
+
|
72
|
+
.input_wrapper {
|
73
|
+
|
74
|
+
position: relative;
|
75
|
+
|
76
|
+
&:after {
|
77
|
+
content: "";
|
78
|
+
background: transparent url(image_path('stripe.png')) repeat 0 0; /*NOTE:: можно переопределить в custom классах */
|
79
|
+
opacity: 0.1;
|
80
|
+
top: 0;
|
81
|
+
left: 0;
|
82
|
+
bottom: 0;
|
83
|
+
right: 0;
|
84
|
+
position: absolute;
|
85
|
+
z-index: 0;
|
86
|
+
}
|
87
|
+
|
88
|
+
.form-control {
|
89
|
+
position: relative;
|
90
|
+
z-index: 1;
|
91
|
+
|
92
|
+
&:focus {
|
93
|
+
text-shadow: none !important;
|
94
|
+
border: #2d2d2d 1px solid;
|
95
|
+
box-shadow: none !important;
|
96
|
+
-webkit-box-shadow: none !important;
|
97
|
+
}
|
98
|
+
|
99
|
+
}
|
100
|
+
|
101
|
+
}
|
102
|
+
|
103
|
+
textarea {
|
104
|
+
|
105
|
+
}
|
106
|
+
|
107
|
+
.help-block {
|
108
|
+
padding-left: 0 !important;
|
109
|
+
position: absolute;
|
110
|
+
text-align: right;
|
111
|
+
padding-right: 0;
|
112
|
+
color: #ff0000;
|
113
|
+
}
|
114
|
+
|
115
|
+
&.has-error {
|
116
|
+
|
117
|
+
.help-block {
|
118
|
+
/*color: #ff7f7c;*/
|
119
|
+
}
|
120
|
+
|
121
|
+
}
|
122
|
+
|
123
|
+
}
|
124
|
+
|
125
|
+
div.actions {
|
126
|
+
margin-top: 15px;
|
127
|
+
|
128
|
+
input.btn {
|
129
|
+
@include color_button(#FFFFFF, $red);
|
130
|
+
}
|
131
|
+
|
132
|
+
}
|
133
|
+
|
134
|
+
}
|
135
|
+
|
136
|
+
}
|
137
|
+
|
138
|
+
}
|
139
|
+
}
|
140
|
+
|
141
|
+
}
|
142
|
+
|
@@ -0,0 +1,27 @@
|
|
1
|
+
module Co
|
2
|
+
class CartController < ::ApplicationController
|
3
|
+
|
4
|
+
def give_me_cart_order_form
|
5
|
+
end
|
6
|
+
|
7
|
+
def message_cart_order
|
8
|
+
puts '<CartController.message_cart_order>'
|
9
|
+
m = OrderMessage.new(mess_params)
|
10
|
+
respond_to do |format|
|
11
|
+
if m.save
|
12
|
+
|
13
|
+
format.js
|
14
|
+
OrderMessageMailer.send_mess(m, 'Заказ').deliver
|
15
|
+
else
|
16
|
+
puts "<CartController.message_cart_order> errors: #{m.errors}"
|
17
|
+
format.js { render json: m.errors, status: :unprocessable_entity }
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
def mess_params
|
23
|
+
params.require(:mess).permit(:name, :phone, :comment, :city)
|
24
|
+
end
|
25
|
+
|
26
|
+
end
|
27
|
+
end
|
@@ -1,7 +1,29 @@
|
|
1
1
|
module Co
|
2
2
|
module CartPageHelper
|
3
|
-
|
4
|
-
|
3
|
+
|
4
|
+
def c80_yax_render_cart(page_content = '')
|
5
|
+
render partial: 'co/cart_page',
|
6
|
+
locals: {
|
7
|
+
page_content: page_content
|
8
|
+
}
|
5
9
|
end
|
10
|
+
|
11
|
+
def render_cart_order_form
|
12
|
+
|
13
|
+
render :partial => 'co/cart/shared/cart_order_form',
|
14
|
+
:locals => {
|
15
|
+
:mess => OrderMessage.new
|
16
|
+
}
|
17
|
+
|
18
|
+
end
|
19
|
+
|
20
|
+
def render_ok_message
|
21
|
+
render :partial => 'co/cart/shared/ok_message',
|
22
|
+
:locals => {
|
23
|
+
ok_text: 'Мы свяжемся с Вами в ближайшее время.',
|
24
|
+
wtitle: 'Ваше сообщение отправлено'
|
25
|
+
}
|
26
|
+
end
|
27
|
+
|
6
28
|
end
|
7
29
|
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
module Co
|
2
|
+
class OrderMessageMailer < ActionMailer::Base
|
3
|
+
|
4
|
+
default from: Proc.new { SiteProp.first.mail_from },
|
5
|
+
to: Proc.new { SiteProp.first.mail_to }
|
6
|
+
|
7
|
+
def send_mess(message, subject)
|
8
|
+
@message = format_message(message)
|
9
|
+
|
10
|
+
puts '<MessageOrderMailer.send_mess> Отправляем сообщение.'
|
11
|
+
mail(subject: subject) do |format|
|
12
|
+
format.html { render 'mail_mess'}
|
13
|
+
end
|
14
|
+
|
15
|
+
#puts "#{SiteProps.first.mail_to}"
|
16
|
+
end
|
17
|
+
|
18
|
+
private
|
19
|
+
|
20
|
+
def format_message(message)
|
21
|
+
result = "<br> • Имя: #{message.name}"
|
22
|
+
result += "<br> • Телефон: #{message.phone}"
|
23
|
+
result += "<br> • Адрес: #{message.city}"
|
24
|
+
result += "<br> • Детали заказа:<br><br> #{message.comment}"
|
25
|
+
result
|
26
|
+
end
|
27
|
+
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
module Co
|
2
|
+
class OrderMessageValidator < ActiveModel::Validator
|
3
|
+
def validate(record)
|
4
|
+
unless record.errors.present?
|
5
|
+
puts "<OrderMessageValidator.validate> record = #{record}"
|
6
|
+
|
7
|
+
unless record.name.present?
|
8
|
+
record.errors[:name] = 'Укажите, пожалуйста, Ваше имя'
|
9
|
+
end
|
10
|
+
|
11
|
+
if record.phone.present?
|
12
|
+
if record.phone[/^((8|\+7)[\- ]?)?(\(?\d{3}\)?[\- ]?)?[\d\- ]{7,10}$/].present?
|
13
|
+
t2 = 'Пожалуйста, укажите корректный номер телефона'
|
14
|
+
record.errors[:phone] = t2
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
end
|
19
|
+
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -32,10 +32,8 @@
|
|
32
32
|
<%= link_to 'Очистить корзину', '#', class: 'clear_btn' %>
|
33
33
|
</div>
|
34
34
|
</div>
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
:a_rel => 'nofollow'
|
40
|
-
}) %>
|
35
|
+
<div class="card_row">
|
36
|
+
<div id="cart_form_container"></div>
|
37
|
+
<div id="policy"><%= page_content %></div>
|
38
|
+
</div>
|
41
39
|
</div>
|
@@ -0,0 +1,18 @@
|
|
1
|
+
var $cc = $("#cart_form_container");
|
2
|
+
var html_str = "<%= j render_cart_order_form %>";
|
3
|
+
|
4
|
+
setTimeout(function () {
|
5
|
+
$('#loading').addClass('invis');
|
6
|
+
setTimeout(function () {
|
7
|
+
$cc.html(html_str);
|
8
|
+
|
9
|
+
// перед показом можно переопределить надпись на кнопке
|
10
|
+
/*if ($cc.data('button-label') != undefined) {
|
11
|
+
$cc.find('[type=submit]').attr('value', $cc.data('button-label'));
|
12
|
+
}*/
|
13
|
+
|
14
|
+
aCartPage.print_table_to_comment();
|
15
|
+
|
16
|
+
},500);
|
17
|
+
},1000);
|
18
|
+
|
@@ -0,0 +1,83 @@
|
|
1
|
+
<%= render_ok_message %>
|
2
|
+
<div id="cart_order_form" tabindex="-1" role="dialog" aria-labelledby="feedbackForm" aria-hidden="true">
|
3
|
+
<div class="modal-dialog">
|
4
|
+
<div class="modal-content">
|
5
|
+
<div class="modal-header">
|
6
|
+
<h4 class="modal-title medium" id="myModalLabel"> </h4>
|
7
|
+
</div>
|
8
|
+
<div class="modal-body regular">
|
9
|
+
|
10
|
+
<%= form_for :mess,
|
11
|
+
:url => '/message_cart_order',
|
12
|
+
:remote => true,
|
13
|
+
html: {
|
14
|
+
multipart: true,
|
15
|
+
:role => :form,
|
16
|
+
:id => 'form_message',
|
17
|
+
:data => {
|
18
|
+
:model => 'mess'
|
19
|
+
}
|
20
|
+
} do |f| %>
|
21
|
+
|
22
|
+
<div class="form-group clearfix">
|
23
|
+
<%= f.label :name, 'Фамилия Имя Отчество', class: 'control-label must' %>
|
24
|
+
<div class="input_wrapper"><%= f.text_field :name, class: 'form-control' %></div>
|
25
|
+
<span class="help-block col-md-12"></span>
|
26
|
+
</div>
|
27
|
+
|
28
|
+
<div class="form-group clearfix">
|
29
|
+
<%= f.label :phone, 'Контактный телефон', class: 'control-label must' %>
|
30
|
+
<div class="input_wrapper"><%= f.text_field :phone, class: 'form-control' %></div>
|
31
|
+
<span class="help-block col-md-12"></span>
|
32
|
+
</div>
|
33
|
+
|
34
|
+
<div class="form-group clearfix">
|
35
|
+
<%= f.label :date, 'Желаемая дата получения товара', class: 'control-label' %>
|
36
|
+
<div class="input_wrapper"><%= f.text_field :date, class: 'form-control' %></div>
|
37
|
+
<span class="help-block col-md-12"></span>
|
38
|
+
</div>
|
39
|
+
|
40
|
+
<div class="form-group clearfix">
|
41
|
+
<%= f.label :city, 'Адрес', class: 'control-label' %>
|
42
|
+
<div class="input_wrapper"><%= f.text_field :city, class: 'form-control' %></div>
|
43
|
+
<span class="help-block col-md-12"></span>
|
44
|
+
</div>
|
45
|
+
|
46
|
+
<div class="form-group clearfix hiddn" style="margin-bottom: 0;">
|
47
|
+
<%= f.label :comment, 'Сообщение', class: 'control-label' %>
|
48
|
+
<div class="input_wrapper"><%= f.text_area :comment, class: 'form-control', :rows => '1' %></div>
|
49
|
+
<span class="help-block col-md-12"></span>
|
50
|
+
</div>
|
51
|
+
|
52
|
+
<div class="actions clearfix">
|
53
|
+
<%= f.label ' ', class: 'control-label' %>
|
54
|
+
<%= f.submit 'Отправить',
|
55
|
+
class: 'btn btn-primary',
|
56
|
+
data: {
|
57
|
+
disable_with: 'Отправляется...'
|
58
|
+
}
|
59
|
+
%>
|
60
|
+
</div>
|
61
|
+
|
62
|
+
<% end %>
|
63
|
+
|
64
|
+
</div>
|
65
|
+
|
66
|
+
</div>
|
67
|
+
</div>
|
68
|
+
</div>
|
69
|
+
|
70
|
+
<%# настраиваем форму %>
|
71
|
+
<script>
|
72
|
+
$(document).ready(function () {
|
73
|
+
|
74
|
+
var $form = $("form#form_message");
|
75
|
+
|
76
|
+
$form.bind("ajax:error", function (event, data, status, xhr) {
|
77
|
+
$form.render_form_errors($.parseJSON(data.responseText));
|
78
|
+
});
|
79
|
+
|
80
|
+
$form.modal_success();
|
81
|
+
|
82
|
+
});
|
83
|
+
</script>
|
@@ -0,0 +1,16 @@
|
|
1
|
+
<div class="modal fade" id="modal_ok" tabindex="1" role="dialog" aria-labelledby="modalOk" aria-hidden="true">
|
2
|
+
<div class="modal-dialog">
|
3
|
+
<div class="modal-content">
|
4
|
+
<div class="modal-header">
|
5
|
+
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
|
6
|
+
<h4 class="modal-title" id="myModalLabel"><%= wtitle %></h4>
|
7
|
+
</div>
|
8
|
+
<div class="modal-body">
|
9
|
+
<p><%= ok_text %></p>
|
10
|
+
</div>
|
11
|
+
<div class="modal-footer">
|
12
|
+
<button type="button" class="btn btn-primary" data-dismiss="modal">Закрыть</button>
|
13
|
+
</div>
|
14
|
+
</div>
|
15
|
+
</div>
|
16
|
+
</div>
|
@@ -0,0 +1 @@
|
|
1
|
+
<%= @message.html_safe %>
|