luda 0.3.0 → 0.3.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -12,22 +12,23 @@
12
12
  // data:
13
13
  // disable:
14
14
  // tabIndex: string # required
15
+ disableTargetProp: function() {
16
+ var ref;
17
+ return ((ref = this.attr) != null ? ref.disable : void 0) || 'disabled';
18
+ },
15
19
  disableCreate: function() {
16
- var dataAttr, ref, rootEl, tabIndex;
17
- rootEl = this.root.els[0];
18
- tabIndex = rootEl.tabIndex;
20
+ var dataAttr, tabIndex;
21
+ tabIndex = this.root.prop('tabIndex');
19
22
  dataAttr = this.data.disable.tabIndex;
20
23
  if (!this.root.hasData(dataAttr)) {
21
24
  this.root.data(dataAttr, tabIndex);
22
25
  }
23
- rootEl.tabIndex = -1;
24
- return rootEl[((ref = this.attr) != null ? ref.disable : void 0) || 'disabled'] = true;
26
+ return this.root.prop('tabIndex', -1).prop(this.disableTargetProp(), true);
25
27
  },
26
28
  disableDestroy: function() {
27
- var ref, rootEl;
28
- rootEl = this.root.els[0];
29
- rootEl.tabIndex = this.root.data(this.data.disable.tabIndex);
30
- return rootEl[((ref = this.attr) != null ? ref.disable : void 0) || 'disabled'] = false;
29
+ var tabIndex;
30
+ tabIndex = this.root.data(this.data.disable.tabIndex);
31
+ return this.root.prop('tabIndex', tabIndex).prop(this.disableTargetProp(), false);
31
32
  }
32
33
  });
33
34
 
@@ -36,6 +36,30 @@
36
36
  // indicators: string # required
37
37
  // prevCtrl: string # optional
38
38
  // nextCtrl: string # optional
39
+ tabableActiveIndex: function() {
40
+ var index, ref, ref1;
41
+ index = ((ref = this.default) != null ? (ref1 = ref.tabable) != null ? ref1.activeIndex : void 0 : void 0) || 0;
42
+ this.tabableTargets.els.some((it, i) => {
43
+ if (!luda(it).hasClass(this.cls.tabable.active)) {
44
+ return false;
45
+ }
46
+ index = i;
47
+ return true;
48
+ });
49
+ return index;
50
+ },
51
+ tabableWrapable: function() {
52
+ var ref, ref1, wrapAttr, wrapable;
53
+ wrapAttr = this.data.tabable.wrap;
54
+ if (!wrapAttr) {
55
+ return false;
56
+ }
57
+ wrapable = this.root.data(wrapAttr);
58
+ if (wrapable === false) {
59
+ return false;
60
+ }
61
+ return (ref = this.default) != null ? (ref1 = ref.tabable) != null ? ref1.wrap : void 0 : void 0;
62
+ },
39
63
  tabableActivate: function(index) {
40
64
  var direction;
41
65
  if (!luda.isNumeric(index)) {
@@ -127,30 +151,6 @@
127
151
  this.tabableSetDirectionCtrlsState();
128
152
  return true;
129
153
  },
130
- tabableActiveIndex: function() {
131
- var index, ref, ref1;
132
- index = ((ref = this.default) != null ? (ref1 = ref.tabable) != null ? ref1.activeIndex : void 0 : void 0) || 0;
133
- this.tabableTargets.els.some((it, i) => {
134
- if (!luda(it).hasClass(this.cls.tabable.active)) {
135
- return false;
136
- }
137
- index = i;
138
- return true;
139
- });
140
- return index;
141
- },
142
- tabableWrapable: function() {
143
- var ref, ref1, wrapAttr, wrapable;
144
- wrapAttr = this.data.tabable.wrap;
145
- if (!wrapAttr) {
146
- return false;
147
- }
148
- wrapable = this.root.data(wrapAttr);
149
- if (wrapable === false) {
150
- return false;
151
- }
152
- return (ref = this.default) != null ? (ref1 = ref.tabable) != null ? ref1.wrap : void 0 : void 0;
153
- },
154
154
  tabableTransitioning: function() {
155
155
  return 'tabableActivating' in this || 'tabableDeactivating' in this;
156
156
  },
@@ -255,7 +255,7 @@
255
255
  wrapAttr && attr.push([wrapAttr, this.tabableSetDirectionControlState]);
256
256
  return {
257
257
  attr: attr,
258
- dom: [[this.selector.tabable.targets, this.tabableLayout], [this.selector.tabable.indicators, this.tabableSetIndicatorsState]]
258
+ node: [[this.selector.tabable.targets, this.tabableLayout], [this.selector.tabable.indicators, this.tabableSetIndicatorsState]]
259
259
  };
260
260
  },
261
261
  tabableListen: function() {
@@ -29,6 +29,38 @@
29
29
  // selector:
30
30
  // toggleable:
31
31
  // target: string # optional
32
+ toggleableActive: function() {
33
+ return this.root.hasClass(this.cls.toggleable.active);
34
+ },
35
+ toggleableTriggerable: function(e) {
36
+ var evtPath, index, ref, ref1, toggleAttr, trigger;
37
+ if (this.toggleableTransitioning()) {
38
+ return;
39
+ }
40
+ if (/key/.test(e.type)) {
41
+ return true;
42
+ }
43
+ if (!this.root.els[0].contains(e.target)) {
44
+ return true;
45
+ }
46
+ trigger = (ref = this.default) != null ? (ref1 = ref.toggleable) != null ? ref1.trigger : void 0 : void 0;
47
+ toggleAttr = this.data.toggleable.trigger;
48
+ if (!toggleAttr) {
49
+ return trigger;
50
+ }
51
+ evtPath = e.eventPath();
52
+ index = evtPath.indexOf(this.root.els[0]) + 1;
53
+ evtPath.slice(0, index).some(function(el) {
54
+ var ins;
55
+ ins = luda(el);
56
+ if (!ins.hasData(toggleAttr)) {
57
+ return;
58
+ }
59
+ trigger = ins.data(toggleAttr) !== false;
60
+ return true;
61
+ });
62
+ return trigger;
63
+ },
32
64
  toggleableActivate: function() {
33
65
  var evt;
34
66
  if (this.toggleableActive()) {
@@ -78,41 +110,9 @@
78
110
  return this.toggleableActivate();
79
111
  }
80
112
  },
81
- toggleableActive: function() {
82
- return this.root.hasClass(this.cls.toggleable.active);
83
- },
84
113
  toggleableTransitioning: function() {
85
114
  return 'toggleableActivating' in this || 'toggleableDeactivating' in this;
86
115
  },
87
- toggleableTriggerable: function(e) {
88
- var evtPath, index, ref, ref1, toggleAttr, trigger;
89
- if (this.toggleableTransitioning()) {
90
- return;
91
- }
92
- if (/key/.test(e.type)) {
93
- return true;
94
- }
95
- if (!this.root.els[0].contains(e.target)) {
96
- return true;
97
- }
98
- trigger = (ref = this.default) != null ? (ref1 = ref.toggleable) != null ? ref1.trigger : void 0 : void 0;
99
- toggleAttr = this.data.toggleable.trigger;
100
- if (!toggleAttr) {
101
- return trigger;
102
- }
103
- evtPath = e.eventPath();
104
- index = evtPath.indexOf(this.root.els[0]) + 1;
105
- evtPath.slice(0, index).some(function(el) {
106
- var ins;
107
- ins = luda(el);
108
- if (!ins.hasData(toggleAttr)) {
109
- return;
110
- }
111
- trigger = ins.data(toggleAttr) !== false;
112
- return true;
113
- });
114
- return trigger;
115
- },
116
116
  toggleableFocusOpener: function(e) {
117
117
  var ins;
118
118
  if (this.toggleableActive()) {
@@ -45,6 +45,15 @@
45
45
  nextCtrl: '.carousel-next'
46
46
  }
47
47
  }
48
+ }).protect({
49
+ interval: function() {
50
+ var duration;
51
+ duration = this.root.data(this.data.interval);
52
+ if (duration === false) {
53
+ return false;
54
+ }
55
+ return Math.abs(parseInt(duration, 10)) || this.default.interval;
56
+ }
48
57
  }).include(luda.mixin('tabable').alias({
49
58
  activate: 'tabableActivate',
50
59
  next: 'tabableNext',
@@ -83,17 +92,26 @@
83
92
  return this.intervaling = setTimeout(handler, this.nextInterval);
84
93
  }
85
94
  }).protect(luda.mixin('tabable').all()).protect({
86
- interval: function() {
87
- var duration;
88
- duration = this.root.data(this.data.interval);
89
- if (duration === false) {
90
- return false;
91
- }
92
- return Math.abs(parseInt(duration, 10)) || this.default.interval;
95
+ togglePath: function(path, action) {
96
+ var targets;
97
+ targets = path.filter((el) => {
98
+ return this.con.contains(el);
99
+ });
100
+ return this.con.create(targets).forEach(function(ins) {
101
+ return ins[action]();
102
+ });
103
+ },
104
+ pauseOnEvt: function(e) {
105
+ return this.togglePath(e.eventPath(), 'pause');
106
+ },
107
+ playOnEvt: function(e) {
108
+ return this.togglePath(e.eventPath(), 'play');
93
109
  },
94
- touchendPlay: function() {
110
+ playOnTouchend: function(e) {
111
+ var path;
112
+ path = e.eventPath();
95
113
  return setTimeout(() => {
96
- return this.play();
114
+ return this.togglePath(path, 'play');
97
115
  });
98
116
  }
99
117
  }).help({
@@ -115,7 +133,7 @@
115
133
  return watches;
116
134
  },
117
135
  listen: function() {
118
- return this.tabableListen().concat([['swipeleft', this.tabableNextOnEvent], ['swiperight', this.tabablePrevOnEvent], ['touchstart mouseover', this.pause], ['mouseout', this.play], ['touchend', this.touchendPlay]]);
136
+ return this.tabableListen().concat([['swipeleft', this.tabableNextOnEvent], ['swiperight', this.tabablePrevOnEvent], ['touchstart mouseover', this.pauseOnEvt], ['mouseout', this.playOnEvt], ['touchend', this.playOnTouchend]]);
119
137
  }
120
138
  });
121
139
 
@@ -108,6 +108,12 @@
108
108
  }
109
109
  });
110
110
  },
111
+ create: function() {
112
+ return this.toggleableCreate();
113
+ },
114
+ destroy: function() {
115
+ return this.toggleableDestroy();
116
+ },
111
117
  listen: function() {
112
118
  var self;
113
119
  self = this;
@@ -16,12 +16,15 @@
16
16
  data: {
17
17
  label: 'fm-dropdown-label'
18
18
  },
19
+ evt: {
20
+ changed: 'luda:fmDropdown:changed'
21
+ },
19
22
  splitor: ' '
20
23
  }).protect({
21
- disableSimulator: function() {
24
+ initSimulator: function() {
22
25
  return this.simulator.data('auto', false).attr('readonly', '');
23
26
  },
24
- updateValue: function() {
27
+ updateSimulatorValue: function() {
25
28
  var values;
26
29
  values = [];
27
30
  this.options.els.forEach((input, index) => {
@@ -29,13 +32,31 @@
29
32
  if (!input.checked) {
30
33
  return;
31
34
  }
32
- label = luda(this.labels.els[index]);
35
+ label = this.labels.eq(index);
33
36
  value = label.data(this.data.label) || label.text();
34
37
  if (value && !values.includes(value)) {
35
38
  return values.push(value);
36
39
  }
37
40
  });
38
- return this.simulator.attr('value', values.join(this.splitor));
41
+ return this.simulator.val(values.join(this.splitor));
42
+ },
43
+ updateValue: function() {
44
+ var checked, oldVal;
45
+ this.updateSimulatorValue();
46
+ oldVal = this.selectedVal;
47
+ checked = this.options.els.filter(function(input) {
48
+ return input.checked;
49
+ });
50
+ this.selectedVal = checked.map(function(input) {
51
+ return luda(input).val();
52
+ });
53
+ if (!oldVal || luda.arrayEqual(this.selectedVal, oldVal)) {
54
+ return;
55
+ }
56
+ return this.root.trigger(this.evt.changed, {
57
+ value: this.selectedVal,
58
+ selected: checked
59
+ });
39
60
  },
40
61
  triggerClick: function() {
41
62
  return this.simulator.trigger('click');
@@ -49,13 +70,13 @@
49
70
  };
50
71
  },
51
72
  create: function() {
52
- this.disableSimulator();
73
+ this.initSimulator();
53
74
  return this.updateValue();
54
75
  },
55
76
  watch: function() {
56
77
  return {
57
- dom: [[this.selector.options, this.updateValue]],
58
- attr: [['checked', this.selector.options, this.updateValue]]
78
+ node: [[this.selector.options, this.updateValue]],
79
+ attr: [['checked', this.selector.options, this.updateValue], ['type', this.selector.options, this.updateValue]]
59
80
  };
60
81
  },
61
82
  listen: function() {
@@ -1,7 +1,7 @@
1
1
  // sass-lint:disable no-empty-rulesets
2
2
  +install(banner)
3
3
  /*!
4
- * Luda 0.3.0 | Theme default | https://oatw.github.io/luda
4
+ * Luda 0.3.1 | Theme default | https://oatw.github.io/luda
5
5
  * Copyright 2019 Oatw | https://oatw.blog
6
6
  * MIT license | http://opensource.org/licenses/MIT
7
7
  */
@@ -14,6 +14,7 @@
14
14
 
15
15
  .nav-logo img,
16
16
  .nav-logo svg
17
+ display: block
17
18
  height: $navigation-logo-image-height-rem
18
19
  object-fit: contain
19
20
  fill: $color-light
@@ -1,3 +1,3 @@
1
1
  module Luda
2
- VERSION = '0.3.0'
2
+ VERSION = '0.3.1'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: luda
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - oatw
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-11-19 00:00:00.000000000 Z
11
+ date: 2019-12-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: sass