c80_yax 0.1.0.15 → 0.1.0.16

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 34dc65fa5a2cfeff8fdb2fab6c8302f2b686e221
4
- data.tar.gz: 406a5f17ca523dd7d13b635d48cf46183753b4b6
3
+ metadata.gz: ff7af30b89808c3567f9d20865720520850b376f
4
+ data.tar.gz: 4cd0728270edb831f2e443b14a1d5089ac574af5
5
5
  SHA512:
6
- metadata.gz: bd626611875a14290e58c0ea059c5a939dc0733e44e212cf4436a8a26b87b443b76ad5d1d50971ff78fab59343a52511430e85e69adff1958eff9b13312d858a
7
- data.tar.gz: 14095acd0a89d7a8e6a9b9d38350c86ed4ef12fa64c049b6d65f3036605932cf030c9229515fdf0368e84823c3e4b006c2b8c78e6d81e1434b860889c3bba525
6
+ metadata.gz: 8d928f4bd23c9fb7b93a94e6955df20573d46d4397f1187424dce84ef58d431f57d47ef832d08bcc177f47008d57618639831ef1e9ddaf931ee5321202d82451
7
+ data.tar.gz: cf4d847d51e6face4c3c839d704a5731019699e81c2bc0bca6631bb6763d480e711188c6d415ae926f25ecb60cdc10e293b1238357a62a03ab5ce0c9ecc9beb8
Binary file
Binary file
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+
3
+ var _activate_more_items = function() {
4
+ $('.more_items_list').each(function() {
5
+ new MoreItemsList(this);
6
+ });
7
+ };
8
+
9
+ $(document).ready(function() {
10
+ // alert(MoreItemsList);
11
+ _activate_more_items();
12
+ });
@@ -0,0 +1,109 @@
1
+ "use strict";
2
+
3
+ /*
4
+ * <div class="container-fluid hits_widget more_items_list" data-type='hit|offer'>
5
+ * <div class="container">
6
+ * <h2 class="yield_h2">Хиты продаж</h2>
7
+ * <div class="ajax_div">
8
+ * <%= orima_render_items_hits %>
9
+ * <div class="will_paginate">
10
+ ...
11
+ <span class="next_page disabled">&gt;</span>
12
+ <a class="next_page" href="/?page=2">&gt;</span>
13
+ </div>
14
+ * </div>
15
+ * </div>
16
+ * </div>
17
+ * */
18
+
19
+ var MoreItemsList = function (wrapper) {
20
+
21
+ var _$wrapper;
22
+ var _$next_btn;
23
+
24
+ var loading = (function () {
25
+
26
+ var _$lo;
27
+
28
+ var _fInit = function () {
29
+ _$lo = $('<div id="lo"></div>');
30
+ };
31
+
32
+ var fShow = function ($clickedButton) {
33
+ // console.log('fShow');
34
+
35
+ _$lo.appendTo($('body'));
36
+
37
+ var top = $clickedButton.offset().top;
38
+ var left = $clickedButton.offset().left;
39
+ top = top + $clickedButton.height()/2 - _$lo.height()/2;
40
+
41
+ _$lo.css("top",top+"px");
42
+ _$lo.css("left",left+"px");
43
+ };
44
+
45
+ var fHide = function () {
46
+ _$lo.addClass('invis');
47
+ setTimeout(function () {
48
+ _$lo.remove();
49
+ _$lo.removeClass('invis');
50
+ }, 1000);
51
+ };
52
+
53
+ _fInit();
54
+
55
+ return {
56
+ show:fShow,
57
+ hide:fHide
58
+ }
59
+
60
+ })();
61
+
62
+ // клик по кнопке "больше товаров"
63
+ var _fOnClickNext = function(e) {
64
+ e.preventDefault();
65
+ var $t = $(e.target);
66
+ var t = _$wrapper.data('type');
67
+ var p = $t.attr('href').split('page=')[1];
68
+ console.log('<_fOnClickNext> type: ' + t + '; page: ' + p);
69
+
70
+ loading.show($t);
71
+
72
+ $.ajax({
73
+ url: "/fetch_items",
74
+ data: {
75
+ type: t,
76
+ page: p,
77
+ ajax_items_div: "." + _$wrapper.attr('class').split(' ').join('.') + " .ajax_div"
78
+ },
79
+ dataType: "script",
80
+ type: 'GET'
81
+ }).done(function() {
82
+ loading.hide();
83
+ });
84
+ };
85
+
86
+ // начинаем слушать клики по кнопке "больше товаров"
87
+ var _fSetNextPageBehaviour = function() {
88
+
89
+ // находим в нем next кнопку will paginate
90
+ _$next_btn = _$wrapper.find('a.next_page');
91
+ console.log('<_fSetNextPageBehaviour> ');
92
+
93
+ if (_$next_btn.data('processed')) {
94
+
95
+ } else {
96
+ _$next_btn.data('processed', 1);
97
+ _$next_btn.on('click', _fOnClickNext);
98
+ }
99
+ }
100
+
101
+ var _fInit = function(wrapper) {
102
+ _$wrapper = $(wrapper);
103
+
104
+ _fSetNextPageBehaviour();
105
+
106
+ };
107
+
108
+ _fInit(wrapper);
109
+ }
@@ -0,0 +1 @@
1
+ #= require_tree ./c80_yax/frontend
@@ -0,0 +1,48 @@
1
+ .more_items_list {
2
+ .will_paginate {
3
+ text-align: center;
4
+ z-index: 33;
5
+ position: relative;
6
+
7
+ > div.pagination {
8
+ margin: 0 0 30px 0;
9
+
10
+ a {
11
+ display: none;
12
+
13
+ &.next_page {
14
+ display: inline-block;
15
+ position: relative;
16
+ width: 292px;
17
+ height: 111px;
18
+ color: transparent;
19
+
20
+ &:after {
21
+ content: ' ';
22
+ display: block;
23
+ position: absolute;
24
+ top: 0;
25
+ left: 0;
26
+ width: 292px;
27
+ height: 111px;
28
+ background: transparent image_url('next_btn.png') no-repeat 0 0;
29
+ }
30
+ }
31
+
32
+ }
33
+
34
+ .previous_page {
35
+ display: none;
36
+ }
37
+
38
+ span.next_page {
39
+ display: none;
40
+ }
41
+
42
+ em.current {
43
+ display: none;
44
+ }
45
+ }
46
+
47
+ }
48
+ }
@@ -0,0 +1,18 @@
1
+ #lo {
2
+ position: absolute;
3
+ background: transparent url(image_path('c80_yax/lo.gif')) no-repeat 50% 50%;
4
+ z-index: 120;
5
+ transition: visibility 1s, opacity 0.5s linear;
6
+
7
+ &.invis {
8
+ visibility: hidden;
9
+ opacity: 0;
10
+ }
11
+
12
+ width: 292px;
13
+ height: 111px;
14
+ background-size: 10%;
15
+ //noinspection CssOptimizeSimilarProperties
16
+ //background-color: rgba(0,0,0,0.1);
17
+
18
+ }
@@ -0,0 +1,63 @@
1
+ module C80Yax
2
+ class AjaxController < ::ApplicationController
3
+
4
+ def fetch_items
5
+
6
+ @params = _make_params # params: {type:'hit', ajax_items: '.div_hot_items .ajax_items', page: 1, per_page: 4}
7
+
8
+ case @params[:type]
9
+ when 'hit'
10
+ @itms = Item.where(is_hit: true)
11
+ .includes(item_props: {prop_name: [:uom, :related]})
12
+ .includes(:iphotos)
13
+ .includes(:strsubcat)
14
+ .paginate(page: @params[:page], per_page: @params[:per_page])
15
+ when 'offer'
16
+ @itms = Item.joins(:offers)
17
+ .includes(item_props: {prop_name: [:uom, :related]})
18
+ .includes(:iphotos)
19
+ .includes(:strsubcat)
20
+ .paginate(page: @params[:page], per_page: @params[:per_page])
21
+ end
22
+
23
+ @items = ItemDecorator.decorate_collection(@itms)
24
+
25
+ end
26
+
27
+ private
28
+
29
+ def _make_params
30
+
31
+ result = {}
32
+ result[:page] = 1
33
+ result[:per_page] = 4
34
+ result[:type] = 'hit'
35
+ result[:ajax_items_div] = ''
36
+
37
+ # result[:sorting_type] = -1 # TODO:: убрать хардкод: здесь должно быть обращение к таблице SortingTypes и поиск в ней "сортировки по умолчанию"
38
+ # result[:strsubcat_id] = nil
39
+
40
+ if params[:page].present?;
41
+ result[:page] = params[:page];
42
+ end
43
+ if params[:per_page].present?;
44
+ result[:per_page] = params[:per_page];
45
+ end
46
+ if params[:type].present?;
47
+ result[:type] = params[:type];
48
+ end
49
+ if params[:ajax_items_div].present?;
50
+ result[:ajax_items_div] = params[:ajax_items_div];
51
+ end
52
+ # if params[:sorting_type].present?; result[:sorting_type] = params[:sorting_type]; end
53
+ # if params[:strsubcat_id].present?
54
+ # result[:strsubcat_id] = params[:strsubcat_id]
55
+ # end
56
+
57
+ Rails.logger.debug "[TRACE] <stroy_mat_params_helper.smph_make_params> Обрабатываем параметры: @params = #{result}"
58
+ result
59
+
60
+ end
61
+
62
+ end
63
+ end
@@ -47,7 +47,7 @@ module C80Yax
47
47
  }
48
48
  end
49
49
 
50
- def c80_yax_render_offers_index(thumb_size = 'thumb_md', page=1, per_page = 16)
50
+ def c80_yax_render_offers_index(thumb_size = 'thumb_md', page=1, per_page = 16, without_paginator = true)
51
51
  itms = Item.joins(:offers)
52
52
  .includes(item_props: {prop_name: [:uom, :related]})
53
53
  .includes(:iphotos)
@@ -57,12 +57,13 @@ module C80Yax
57
57
  render partial: 'c80_yax/items/index',
58
58
  locals: {
59
59
  items: items,
60
- without_paginator: true,
60
+ will_paginate_items: itms,
61
+ without_paginator: without_paginator,
61
62
  thumb_size: thumb_size
62
63
  }
63
64
  end
64
65
 
65
- def c80_yax_render_offers_hits(thumb_size = 'thumb_md', page=1, per_page = 16)
66
+ def c80_yax_render_offers_hits(thumb_size = 'thumb_md', page=1, per_page = 16, without_paginator = true)
66
67
  itms = Item.where(is_hit: true)
67
68
  .includes(item_props: {prop_name: [:uom, :related]})
68
69
  .includes(:iphotos)
@@ -72,7 +73,8 @@ module C80Yax
72
73
  render partial: 'c80_yax/items/index',
73
74
  locals: {
74
75
  items: items,
75
- without_paginator: true,
76
+ will_paginate_items: itms,
77
+ without_paginator: without_paginator,
76
78
  thumb_size: thumb_size
77
79
  }
78
80
  end
@@ -0,0 +1,22 @@
1
+ var $cc = $("<%= @params[:ajax_items_div] %>");
2
+
3
+ var html_str = "<%= j render partial: 'c80_yax/items/index',
4
+ locals: {
5
+ items: @items,
6
+ will_paginate_items: @itms,
7
+ without_paginator: false,
8
+ thumb_size: 'thumb_md'
9
+ } %>";
10
+
11
+ var hh = $cc.outerHeight(true) + "px";
12
+ $cc.css('min-height', hh);
13
+ $cc.find('.will_paginate').remove();
14
+ $cc.append($(html_str));
15
+
16
+ <% if @params[:type] == 'hit' %>
17
+ $cc.css('margin-bottom', '165px');
18
+ <% end %>
19
+
20
+ _activate_more_items();
21
+
22
+ fLazyStart();
data/config/routes.rb CHANGED
@@ -1,4 +1,5 @@
1
1
  C80Yax::Engine.routes.draw do
2
2
  match 'admin_data_get_strsubcat_propnames', :to => 'admin_data#get_strsubcat_propnames', :via => :post
3
3
  mount Pack::Engine => '/'
4
+ match 'fetch_items', to: 'ajax#fetch_items', via: :get
4
5
  end
@@ -1,3 +1,3 @@
1
1
  module C80Yax
2
- VERSION = '0.1.0.15'
2
+ VERSION = '0.1.0.16'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: c80_yax
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0.15
4
+ version: 0.1.0.16
5
5
  platform: ruby
6
6
  authors:
7
7
  - C80609A
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-07-18 00:00:00.000000000 Z
11
+ date: 2017-07-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -133,9 +133,13 @@ files:
133
133
  - app/admin/c80_yax/vendors.rb
134
134
  - app/admin/c80_yax/x_c80_yax.rb
135
135
  - app/assets/images/c80_yax/cart_icon_sm.png
136
+ - app/assets/images/c80_yax/lo.gif
137
+ - app/assets/images/next_btn.png
136
138
  - app/assets/javascripts/c80_yax.js.coffee
137
139
  - app/assets/javascripts/c80_yax/backend/items.js
138
140
  - app/assets/javascripts/c80_yax/backend/strsubcats.js
141
+ - app/assets/javascripts/c80_yax/frontend/more_items_list/app.js
142
+ - app/assets/javascripts/c80_yax/frontend/more_items_list/more_items_list.js
139
143
  - app/assets/javascripts/c80_yax/lib_backend/collapsable-groups.js
140
144
  - app/assets/javascripts/c80_yax/lib_backend/custom_columns.js
141
145
  - app/assets/javascripts/c80_yax/lib_backend/init.js
@@ -153,12 +157,15 @@ files:
153
157
  - app/assets/stylesheets/c80_yax/elems/add_to_bucket.scss
154
158
  - app/assets/stylesheets/c80_yax/elems/cats_iconed_list.scss
155
159
  - app/assets/stylesheets/c80_yax/elems/item_images_no_main.scss
160
+ - app/assets/stylesheets/c80_yax/elems/more_items_list.scss
161
+ - app/assets/stylesheets/c80_yax/elems/more_items_list_loading.scss
156
162
  - app/assets/stylesheets/c80_yax/elems/ul_item_index.scss
157
163
  - app/assets/stylesheets/c80_yax/lib/bootstrap_checkboxes.scss
158
164
  - app/assets/stylesheets/c80_yax/lib/loading.scss
159
165
  - app/assets/stylesheets/c80_yax/lib_custom/bootstrap_checkboxes.scss
160
166
  - app/assets/stylesheets/c80_yax_backend.scss
161
167
  - app/controllers/c80_yax/admin_data_controller.rb
168
+ - app/controllers/c80_yax/ajax_controller.rb
162
169
  - app/controllers/c80_yax/app_controller.rb
163
170
  - app/decorators/c80_yax/item_decorator.rb
164
171
  - app/helpers/c80_yax/cats/cat_lists_helper.rb
@@ -198,6 +205,7 @@ files:
198
205
  - app/uploaders/c80_yax/iphoto_uploader.rb
199
206
  - app/views/admin/items/_show.html.erb
200
207
  - app/views/admin/strsubcats/_view.html.erb
208
+ - app/views/c80_yax/ajax/fetch_items.js.erb
201
209
  - app/views/c80_yax/cats/_cats_iconed_list.html.erb
202
210
  - app/views/c80_yax/items/_buy_options.html.erb
203
211
  - app/views/c80_yax/items/_index.html.erb