c80_yax 0.1.0.22 → 0.1.0.23

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a0695658ffca19bf340b75e7fbd1512599d08a0c
4
- data.tar.gz: f991a7bb6f7c53125d7dd9b1ba6d68b9dd44253a
3
+ metadata.gz: 4e01e75c062c8b3f52d68ac18851b78f54a0851e
4
+ data.tar.gz: b287e2b15f3bb793e837e0bdea42e0eb1882e4bb
5
5
  SHA512:
6
- metadata.gz: 6af24abd9829d3d98820f4f2cec30aa16f8d265802e2784a1b37c03538c81df793dabe02b63657f545f0d7a295696ae8276fcb2ea11673e658b3a5affbc53dbe
7
- data.tar.gz: 3c14ec8803324d9d59a0619d398ee23a8d2031479ed0edbc3476fda1907f4a452e83bec057c9dcd89b3704e6f835ccfcbfd696f181cd7e126ceb052e600c40d7
6
+ metadata.gz: d5df25892e20e93d59d35ad393fb0468029db94953926595717d13b95405c547532861560baaadb58d17e0df0255e013f73c88e8bccd81d50bd31aecd7f99919
7
+ data.tar.gz: ff6154bbef0c1f947a3bea147111ce25e12ad11a7a4cfb2c0f241b5454a5ecf8d8d5bb0c27c9d64fd2e20e2d3c3594a7029c6d98794c5015aba2f32614e51249
@@ -1,2 +1,3 @@
1
1
  #= require_tree ./c80_yax/frontend
2
- #= require co
2
+ #= require co
3
+ #= require ti
@@ -49,6 +49,12 @@ class C80Yax::Item < ActiveRecord::Base
49
49
  join_table: 'of_items_offers',
50
50
  association_foreign_key: 'item_id'
51
51
 
52
+ has_and_belongs_to_many :offers,
53
+ class_name: 'Ti::Doc',
54
+ foreign_key: 'doc_id',
55
+ join_table: 'ti_docs_items',
56
+ association_foreign_key: 'item_id'
57
+
52
58
  extend FriendlyId
53
59
  friendly_id :slug_candidates, :use => :slugged
54
60
 
@@ -1 +1,2 @@
1
+ #= require_tree ./lib
1
2
  #= require_tree ./co
@@ -0,0 +1,453 @@
1
+ (function (factory) {
2
+ if (typeof define === 'function' && define.amd) {
3
+ // AMD. Register as an anonymous module.
4
+ define(['jquery'], factory);
5
+ } else if (typeof exports === 'object') {
6
+ // Node/CommonJS
7
+ factory(require('jquery'));
8
+ } else {
9
+ // Browser globals
10
+ factory(jQuery);
11
+ }
12
+ }(function ($) {
13
+
14
+ var ua = navigator.userAgent,
15
+ iPhone = /iphone/i.test(ua),
16
+ chrome = /chrome/i.test(ua),
17
+ android = /android/i.test(ua),
18
+ caretTimeoutId;
19
+
20
+ $.mask = {
21
+ //Predefined character definitions
22
+ definitions: {
23
+ '9': "[0-9]",
24
+ 'a': "[A-Za-z]",
25
+ '*': "[A-Za-z0-9]"
26
+ },
27
+ autoclear: true,
28
+ dataName: "rawMaskFn",
29
+ placeholder: '_'
30
+ };
31
+
32
+ $.fn.extend({
33
+ //Helper Function for Caret positioning
34
+ caret: function(begin, end) {
35
+ var range;
36
+
37
+ if (this.length === 0 || this.is(":hidden") || this.get(0) !== document.activeElement) {
38
+ return;
39
+ }
40
+
41
+ if (typeof begin == 'number') {
42
+ end = (typeof end === 'number') ? end : begin;
43
+ return this.each(function() {
44
+ if (this.setSelectionRange) {
45
+ this.setSelectionRange(begin, end);
46
+ } else if (this.createTextRange) {
47
+ range = this.createTextRange();
48
+ range.collapse(true);
49
+ range.moveEnd('character', end);
50
+ range.moveStart('character', begin);
51
+ range.select();
52
+ }
53
+ });
54
+ } else {
55
+ if (this[0].setSelectionRange) {
56
+ begin = this[0].selectionStart;
57
+ end = this[0].selectionEnd;
58
+ } else if (document.selection && document.selection.createRange) {
59
+ range = document.selection.createRange();
60
+ begin = 0 - range.duplicate().moveStart('character', -100000);
61
+ end = begin + range.text.length;
62
+ }
63
+ return { begin: begin, end: end };
64
+ }
65
+ },
66
+ unmask: function() {
67
+ return this.trigger("unmask");
68
+ },
69
+ mask: function(mask, settings) {
70
+ var input,
71
+ defs,
72
+ tests,
73
+ partialPosition,
74
+ firstNonMaskPos,
75
+ lastRequiredNonMaskPos,
76
+ len,
77
+ oldVal;
78
+
79
+ if (!mask && this.length > 0) {
80
+ input = $(this[0]);
81
+ var fn = input.data($.mask.dataName)
82
+ return fn?fn():undefined;
83
+ }
84
+
85
+ settings = $.extend({
86
+ autoclear: $.mask.autoclear,
87
+ placeholder: $.mask.placeholder, // Load default placeholder
88
+ completed: null
89
+ }, settings);
90
+
91
+
92
+ defs = $.mask.definitions;
93
+ tests = [];
94
+ partialPosition = len = mask.length;
95
+ firstNonMaskPos = null;
96
+
97
+ mask = String(mask);
98
+
99
+ $.each(mask.split(""), function(i, c) {
100
+ if (c == '?') {
101
+ len--;
102
+ partialPosition = i;
103
+ } else if (defs[c]) {
104
+ tests.push(new RegExp(defs[c]));
105
+ if (firstNonMaskPos === null) {
106
+ firstNonMaskPos = tests.length - 1;
107
+ }
108
+ if(i < partialPosition){
109
+ lastRequiredNonMaskPos = tests.length - 1;
110
+ }
111
+ } else {
112
+ tests.push(null);
113
+ }
114
+ });
115
+
116
+ return this.trigger("unmask").each(function() {
117
+ var input = $(this),
118
+ buffer = $.map(
119
+ mask.split(""),
120
+ function(c, i) {
121
+ if (c != '?') {
122
+ return defs[c] ? getPlaceholder(i) : c;
123
+ }
124
+ }),
125
+ defaultBuffer = buffer.join(''),
126
+ focusText = input.val();
127
+
128
+ function tryFireCompleted(){
129
+ if (!settings.completed) {
130
+ return;
131
+ }
132
+
133
+ for (var i = firstNonMaskPos; i <= lastRequiredNonMaskPos; i++) {
134
+ if (tests[i] && buffer[i] === getPlaceholder(i)) {
135
+ return;
136
+ }
137
+ }
138
+ settings.completed.call(input);
139
+ }
140
+
141
+ function getPlaceholder(i){
142
+ if(i < settings.placeholder.length)
143
+ return settings.placeholder.charAt(i);
144
+ return settings.placeholder.charAt(0);
145
+ }
146
+
147
+ function seekNext(pos) {
148
+ while (++pos < len && !tests[pos]);
149
+ return pos;
150
+ }
151
+
152
+ function seekPrev(pos) {
153
+ while (--pos >= 0 && !tests[pos]);
154
+ return pos;
155
+ }
156
+
157
+ function shiftL(begin,end) {
158
+ var i,
159
+ j;
160
+
161
+ if (begin<0) {
162
+ return;
163
+ }
164
+
165
+ for (i = begin, j = seekNext(end); i < len; i++) {
166
+ if (tests[i]) {
167
+ if (j < len && tests[i].test(buffer[j])) {
168
+ buffer[i] = buffer[j];
169
+ buffer[j] = getPlaceholder(j);
170
+ } else {
171
+ break;
172
+ }
173
+
174
+ j = seekNext(j);
175
+ }
176
+ }
177
+ writeBuffer();
178
+ input.caret(Math.max(firstNonMaskPos, begin));
179
+ }
180
+
181
+ function shiftR(pos) {
182
+ var i,
183
+ c,
184
+ j,
185
+ t;
186
+
187
+ for (i = pos, c = getPlaceholder(pos); i < len; i++) {
188
+ if (tests[i]) {
189
+ j = seekNext(i);
190
+ t = buffer[i];
191
+ buffer[i] = c;
192
+ if (j < len && tests[j].test(t)) {
193
+ c = t;
194
+ } else {
195
+ break;
196
+ }
197
+ }
198
+ }
199
+ }
200
+
201
+ function androidInputEvent(e) {
202
+ var curVal = input.val();
203
+ var pos = input.caret();
204
+
205
+ var proxy = function () {
206
+ $.proxy($.fn.caret, input, pos.begin, pos.begin)();
207
+ };
208
+
209
+ if (oldVal && oldVal.length && oldVal.length > curVal.length ) {
210
+ // a deletion or backspace happened
211
+ checkVal(true);
212
+ while (pos.begin > 0 && !tests[pos.begin-1])
213
+ pos.begin--;
214
+ if (pos.begin === 0)
215
+ {
216
+ while (pos.begin < firstNonMaskPos && !tests[pos.begin])
217
+ pos.begin++;
218
+ }
219
+ setTimeout(proxy, 0);
220
+ } else {
221
+ var pos2 = checkVal(true);
222
+ var lastEnteredValue = curVal.charAt(pos.begin);
223
+ if (pos.begin < len){
224
+ if(!tests[pos.begin]){
225
+ pos.begin++;
226
+ if(tests[pos.begin].test(lastEnteredValue)){
227
+ pos.begin++;
228
+ }
229
+ }else{
230
+ if(tests[pos.begin].test(lastEnteredValue)){
231
+ pos.begin++;
232
+ }
233
+ }
234
+ }
235
+ setTimeout(proxy, 0);
236
+ }
237
+ tryFireCompleted();
238
+ }
239
+
240
+
241
+ function blurEvent(e) {
242
+ checkVal();
243
+
244
+ if (input.val() != focusText)
245
+ input.change();
246
+ }
247
+
248
+ function keydownEvent(e) {
249
+ if (input.prop("readonly")){
250
+ return;
251
+ }
252
+
253
+ var k = e.which || e.keyCode,
254
+ pos,
255
+ begin,
256
+ end;
257
+ oldVal = input.val();
258
+ //backspace, delete, and escape get special treatment
259
+ if (k === 8 || k === 46 || (iPhone && k === 127)) {
260
+ pos = input.caret();
261
+ begin = pos.begin;
262
+ end = pos.end;
263
+
264
+ if (end - begin === 0) {
265
+ begin=k!==46?seekPrev(begin):(end=seekNext(begin-1));
266
+ end=k===46?seekNext(end):end;
267
+ }
268
+ clearBuffer(begin, end);
269
+ shiftL(begin, end - 1);
270
+
271
+ e.preventDefault();
272
+ } else if( k === 13 ) { // enter
273
+ blurEvent.call(this, e);
274
+ } else if (k === 27) { // escape
275
+ input.val(focusText);
276
+ input.caret(0, checkVal());
277
+ e.preventDefault();
278
+ }
279
+ }
280
+
281
+ function keypressEvent(e) {
282
+ if (input.prop("readonly")){
283
+ return;
284
+ }
285
+
286
+ var k = e.which || e.keyCode,
287
+ pos = input.caret(),
288
+ p,
289
+ c,
290
+ next;
291
+
292
+ if (e.ctrlKey || e.altKey || e.metaKey || k < 32) {//Ignore
293
+ return;
294
+ } else if ( k && k !== 13 ) {
295
+ if (pos.end - pos.begin !== 0){
296
+ clearBuffer(pos.begin, pos.end);
297
+ shiftL(pos.begin, pos.end-1);
298
+ }
299
+
300
+ p = seekNext(pos.begin - 1);
301
+ if (p < len) {
302
+ c = String.fromCharCode(k);
303
+ if (tests[p].test(c)) {
304
+ shiftR(p);
305
+
306
+ buffer[p] = c;
307
+ writeBuffer();
308
+ next = seekNext(p);
309
+
310
+ if(android){
311
+ //Path for CSP Violation on FireFox OS 1.1
312
+ var proxy = function() {
313
+ $.proxy($.fn.caret,input,next)();
314
+ };
315
+
316
+ setTimeout(proxy,0);
317
+ }else{
318
+ input.caret(next);
319
+ }
320
+ if(pos.begin <= lastRequiredNonMaskPos){
321
+ tryFireCompleted();
322
+ }
323
+ }
324
+ }
325
+ e.preventDefault();
326
+ }
327
+ }
328
+
329
+ function clearBuffer(start, end) {
330
+ var i;
331
+ for (i = start; i < end && i < len; i++) {
332
+ if (tests[i]) {
333
+ buffer[i] = getPlaceholder(i);
334
+ }
335
+ }
336
+ }
337
+
338
+ function writeBuffer() { input.val(buffer.join('')); }
339
+
340
+ function checkVal(allow) {
341
+ //try to place characters where they belong
342
+ var test = input.val(),
343
+ lastMatch = -1,
344
+ i,
345
+ c,
346
+ pos;
347
+
348
+ for (i = 0, pos = 0; i < len; i++) {
349
+ if (tests[i]) {
350
+ buffer[i] = getPlaceholder(i);
351
+ while (pos++ < test.length) {
352
+ c = test.charAt(pos - 1);
353
+ if (tests[i].test(c)) {
354
+ buffer[i] = c;
355
+ lastMatch = i;
356
+ break;
357
+ }
358
+ }
359
+ if (pos > test.length) {
360
+ clearBuffer(i + 1, len);
361
+ break;
362
+ }
363
+ } else {
364
+ if (buffer[i] === test.charAt(pos)) {
365
+ pos++;
366
+ }
367
+ if( i < partialPosition){
368
+ lastMatch = i;
369
+ }
370
+ }
371
+ }
372
+ if (allow) {
373
+ writeBuffer();
374
+ } else if (lastMatch + 1 < partialPosition) {
375
+ if (settings.autoclear || buffer.join('') === defaultBuffer) {
376
+ // Invalid value. Remove it and replace it with the
377
+ // mask, which is the default behavior.
378
+ if(input.val()) input.val("");
379
+ clearBuffer(0, len);
380
+ } else {
381
+ // Invalid value, but we opt to show the value to the
382
+ // user and allow them to correct their mistake.
383
+ writeBuffer();
384
+ }
385
+ } else {
386
+ writeBuffer();
387
+ input.val(input.val().substring(0, lastMatch + 1));
388
+ }
389
+ return (partialPosition ? i : firstNonMaskPos);
390
+ }
391
+
392
+ input.data($.mask.dataName,function(){
393
+ return $.map(buffer, function(c, i) {
394
+ return tests[i]&&c!=getPlaceholder(i) ? c : null;
395
+ }).join('');
396
+ });
397
+
398
+
399
+ input
400
+ .one("unmask", function() {
401
+ input
402
+ .off(".mask")
403
+ .removeData($.mask.dataName);
404
+ })
405
+ .on("focus.mask", function() {
406
+ if (input.prop("readonly")){
407
+ return;
408
+ }
409
+
410
+ clearTimeout(caretTimeoutId);
411
+ var pos;
412
+
413
+ focusText = input.val();
414
+
415
+ pos = checkVal();
416
+
417
+ caretTimeoutId = setTimeout(function(){
418
+ if(input.get(0) !== document.activeElement){
419
+ return;
420
+ }
421
+ writeBuffer();
422
+ if (pos == mask.replace("?","").length) {
423
+ input.caret(0, pos);
424
+ } else {
425
+ input.caret(pos);
426
+ }
427
+ }, 10);
428
+ })
429
+ .on("blur.mask", blurEvent)
430
+ .on("keydown.mask", keydownEvent)
431
+ .on("keypress.mask", keypressEvent)
432
+ .on("input.mask paste.mask", function() {
433
+ if (input.prop("readonly")){
434
+ return;
435
+ }
436
+
437
+ setTimeout(function() {
438
+ var pos=checkVal(true);
439
+ input.caret(pos);
440
+ tryFireCompleted();
441
+ }, 0);
442
+ });
443
+ if (chrome && android)
444
+ {
445
+ input
446
+ .off('input.mask')
447
+ .on('input.mask', androidInputEvent);
448
+ }
449
+ checkVal(); //Perform initial check for existing values
450
+ });
451
+ }
452
+ });
453
+ }));
@@ -13,6 +13,8 @@ setTimeout(function () {
13
13
 
14
14
  aCartPage.print_table_to_comment();
15
15
 
16
+ $cc.find('input#mess_phone').mask('+9(999)999-99-99');
17
+
16
18
  },500);
17
19
  },1000);
18
20
 
@@ -1,4 +1,4 @@
1
- ActiveAdmin.register Ti::Doc, :as => 'Docs' do
1
+ ActiveAdmin.register Ti::Doc, :as => 'Doc' do
2
2
 
3
3
  before_filter :skip_sidebar!, :only => :index
4
4
 
@@ -9,6 +9,7 @@ ActiveAdmin.register Ti::Doc, :as => 'Docs' do
9
9
  permit_params :title,
10
10
  :full,
11
11
  :category_ids => [],
12
+ :item_ids => [],
12
13
  :dphotos_attributes => [:id,:image,:_destroy]
13
14
 
14
15
  index do
@@ -60,6 +61,19 @@ ActiveAdmin.register Ti::Doc, :as => 'Docs' do
60
61
  end
61
62
  end
62
63
 
64
+ f.input :items,
65
+ :as => :select,
66
+ :input_html => {
67
+ :title => '',
68
+ :class => 'selectpicker',
69
+ :data => {
70
+ :size => 10,
71
+ :width => '700px'
72
+ },
73
+ :multiple => true
74
+ },
75
+ :include_blank => true
76
+
63
77
  f.input :full, :as => :ckeditor,
64
78
  :input_html => {:style => 'height:500px', rows: 20}
65
79
 
@@ -0,0 +1,22 @@
1
+ var activate_collapsed_ti = function () {
2
+ $(document).ready(function () {
3
+ $('.tech_info_list h3').bind('click', function (e) {
4
+
5
+ // на тот случай, если внутрь легенды положена ссылка "например" и кликнули по этой ссылке
6
+ if ($(e.target).attr('href') !== undefined) return;
7
+
8
+ var $li_parent = $(this).parent();
9
+ var $ul_docs = $li_parent.find('ul.docs');
10
+
11
+ if ($ul_docs.css('display') === 'none') {
12
+ $ul_docs.css('display', 'block');
13
+ $li_parent.addClass('shown');
14
+ } else {
15
+ $ul_docs.css('display', 'none');
16
+ $li_parent.removeClass('shown');
17
+ }
18
+
19
+ });
20
+ });
21
+ };
22
+ activate_collapsed_ti();
@@ -1 +1 @@
1
- # require_tree ./ti
1
+ #= require_tree ./ti
@@ -0,0 +1,50 @@
1
+ %collapsed {
2
+ ul.docs_of_cats {
3
+ margin: 0 0 40px 0 !important;
4
+
5
+ > li {
6
+
7
+ h3 {
8
+ cursor: pointer;
9
+ padding-left: 29px !important;
10
+
11
+ position: relative;
12
+ &:after {
13
+ position: absolute;
14
+ top: 17px;
15
+ left: 10px;
16
+ color: rgba(255,255,255,0.9) !important;
17
+ text-transform: uppercase;
18
+ font-size: 12px;
19
+ font-family: FontAwesome;
20
+ font-style: normal;
21
+ font-weight: normal;
22
+ content: '\f138';
23
+ }
24
+
25
+ }
26
+
27
+ ul.docs {
28
+ display: none;
29
+ }
30
+
31
+ &.shown {
32
+ h3 {
33
+ &:after {
34
+ content: '\f13a';
35
+ }
36
+ }
37
+ }
38
+
39
+ &:hover {
40
+ h3 {
41
+ &:after {
42
+ color: rgba(255,255,255,0.99) !important;
43
+ }
44
+ }
45
+ }
46
+
47
+ }
48
+
49
+ }
50
+ }
@@ -2,6 +2,7 @@ ul.tech_info_list {
2
2
  margin: 0;
3
3
  padding: 0;
4
4
  list-style: none;
5
+ @extend %collapsed;
5
6
 
6
7
  h2 {
7
8
  text-transform: uppercase;
@@ -10,6 +10,12 @@ module Ti
10
10
  },
11
11
  :allow_destroy => true
12
12
  has_and_belongs_to_many :categories
13
+ has_and_belongs_to_many :items,
14
+ class_name: 'C80Yax::Item',
15
+ foreign_key: 'item_id',
16
+ join_table: 'ti_docs_items',
17
+ association_foreign_key: 'doc_id'
18
+
13
19
  validates_with DocValidator
14
20
  default_scope {order(:created_at => :desc)}
15
21
 
@@ -0,0 +1,17 @@
1
+ class CreateTiJoinTableDocsItems < ActiveRecord::Migration
2
+ def self.up
3
+ create_table :ti_docs_items, id: false do |t|
4
+ t.integer :doc_id
5
+ t.integer :item_id
6
+ end
7
+
8
+ add_index(:ti_docs_items, [:doc_id, :item_id], :unique => true)
9
+ add_index(:ti_docs_items, [:item_id, :doc_id], :unique => true)
10
+ end
11
+
12
+ def self.down
13
+ remove_index(:ti_docs_items, [:item_id, :doc_id])
14
+ remove_index(:ti_docs_items, [:doc_id, :item_id])
15
+ drop_table :ti_docs_items
16
+ end
17
+ end
@@ -1,3 +1,3 @@
1
1
  module C80Yax
2
- VERSION = '0.1.0.22'
2
+ VERSION = '0.1.0.23'
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.22
4
+ version: 0.1.0.23
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-26 00:00:00.000000000 Z
11
+ date: 2017-07-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -281,6 +281,7 @@ files:
281
281
  - engines/co/app/assets/javascripts/co/cart_page/support/row_printer.js
282
282
  - engines/co/app/assets/javascripts/co/goto_cart/app.js
283
283
  - engines/co/app/assets/javascripts/co/goto_cart/button_goto_cart.js
284
+ - engines/co/app/assets/javascripts/lib/masked_input/jquery.maskedinput.js
284
285
  - engines/co/app/assets/stylesheets/co.scss
285
286
  - engines/co/app/assets/stylesheets/co/cart_page/_cart_button.scss
286
287
  - engines/co/app/assets/stylesheets/co/cart_page/bottom_row.scss
@@ -349,7 +350,9 @@ files:
349
350
  - engines/ti/app/admin/ti/docs.rb
350
351
  - engines/ti/app/admin/ti/x_ti.rb
351
352
  - engines/ti/app/assets/javascripts/ti.coffee
353
+ - engines/ti/app/assets/javascripts/ti/tech_info_list_collapsed.js
352
354
  - engines/ti/app/assets/stylesheets/ti.scss
355
+ - engines/ti/app/assets/stylesheets/ti/_collapsed.scss
353
356
  - engines/ti/app/assets/stylesheets/ti/tech_info_list.scss
354
357
  - engines/ti/app/controllers/ti/application_controller.rb
355
358
  - engines/ti/app/helpers/ti/application_helper.rb
@@ -376,6 +379,7 @@ files:
376
379
  - engines/ti/db/migrate/20170706083939_create_ti_join_table_categories_docs.rb
377
380
  - engines/ti/db/migrate/20170718035050_add_ti_listed_to_categories.rb
378
381
  - engines/ti/db/migrate/20170718052828_add_ti_per_widget_to_props.rb
382
+ - engines/ti/db/migrate/20170728044343_create_ti_join_table_docs_items.rb
379
383
  - engines/ti/db/seeds/ti_02_fill_test_data.rb
380
384
  - engines/ti/lib/ti.rb
381
385
  - engines/ti/lib/ti/engine.rb