uikit-on-rails 1.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +18 -0
- data/README.md +37 -0
- data/Rakefile +1 -0
- data/lib/uikit-on-rails.rb +1 -0
- data/lib/uikit/sass/rails.rb +2 -0
- data/lib/uikit/sass/rails/engine.rb +12 -0
- data/lib/uikit/sass/rails/version.rb +7 -0
- data/uikit-on-rails.gemspec +23 -0
- data/vendor/assets/fonts/fontawesome-webfont.eot +0 -0
- data/vendor/assets/fonts/fontawesome-webfont.otf +0 -0
- data/vendor/assets/fonts/fontawesome-webfont.svg +565 -0
- data/vendor/assets/fonts/fontawesome-webfont.ttf +0 -0
- data/vendor/assets/fonts/fontawesome-webfont.woff +0 -0
- data/vendor/assets/fonts/fontawesome-webfont.woff2 +0 -0
- data/vendor/assets/javascripts/uikit.js +19 -0
- data/vendor/assets/javascripts/uikit/components/accordion.js +180 -0
- data/vendor/assets/javascripts/uikit/components/autocomplete.js +340 -0
- data/vendor/assets/javascripts/uikit/components/datepicker.js +3167 -0
- data/vendor/assets/javascripts/uikit/components/form-password.js +67 -0
- data/vendor/assets/javascripts/uikit/components/form-select.js +85 -0
- data/vendor/assets/javascripts/uikit/components/grid-parallax.js +168 -0
- data/vendor/assets/javascripts/uikit/components/grid.js +540 -0
- data/vendor/assets/javascripts/uikit/components/htmleditor.js +679 -0
- data/vendor/assets/javascripts/uikit/components/lightbox.js +591 -0
- data/vendor/assets/javascripts/uikit/components/nestable.js +653 -0
- data/vendor/assets/javascripts/uikit/components/notify.js +189 -0
- data/vendor/assets/javascripts/uikit/components/pagination.js +147 -0
- data/vendor/assets/javascripts/uikit/components/parallax.js +462 -0
- data/vendor/assets/javascripts/uikit/components/search.js +92 -0
- data/vendor/assets/javascripts/uikit/components/slider.js +552 -0
- data/vendor/assets/javascripts/uikit/components/slideset.js +523 -0
- data/vendor/assets/javascripts/uikit/components/slideshow-fx.js +383 -0
- data/vendor/assets/javascripts/uikit/components/slideshow.js +596 -0
- data/vendor/assets/javascripts/uikit/components/sortable.js +688 -0
- data/vendor/assets/javascripts/uikit/components/sticky.js +364 -0
- data/vendor/assets/javascripts/uikit/components/timepicker.js +192 -0
- data/vendor/assets/javascripts/uikit/components/tooltip.js +234 -0
- data/vendor/assets/javascripts/uikit/components/upload.js +262 -0
- data/vendor/assets/javascripts/uikit/core/alert.js +66 -0
- data/vendor/assets/javascripts/uikit/core/button.js +156 -0
- data/vendor/assets/javascripts/uikit/core/core.js +820 -0
- data/vendor/assets/javascripts/uikit/core/cover.js +95 -0
- data/vendor/assets/javascripts/uikit/core/dropdown.js +529 -0
- data/vendor/assets/javascripts/uikit/core/grid.js +117 -0
- data/vendor/assets/javascripts/uikit/core/modal.js +389 -0
- data/vendor/assets/javascripts/uikit/core/nav.js +152 -0
- data/vendor/assets/javascripts/uikit/core/offcanvas.js +197 -0
- data/vendor/assets/javascripts/uikit/core/scrollspy.js +209 -0
- data/vendor/assets/javascripts/uikit/core/smooth-scroll.js +62 -0
- data/vendor/assets/javascripts/uikit/core/switcher.js +309 -0
- data/vendor/assets/javascripts/uikit/core/tab.js +167 -0
- data/vendor/assets/javascripts/uikit/core/toggle.js +124 -0
- data/vendor/assets/javascripts/uikit/core/touch.js +175 -0
- data/vendor/assets/javascripts/uikit/core/utility.js +338 -0
- data/vendor/assets/javascripts/uikit/uikit.js +3905 -0
- data/vendor/assets/stylesheets/extra/font-awesome.scss +14 -0
- data/vendor/assets/stylesheets/uikit.scss +7 -0
- data/vendor/assets/stylesheets/uikit/components/accordion.scss +94 -0
- data/vendor/assets/stylesheets/uikit/components/autocomplete.scss +107 -0
- data/vendor/assets/stylesheets/uikit/components/datepicker.scss +197 -0
- data/vendor/assets/stylesheets/uikit/components/dotnav.scss +212 -0
- data/vendor/assets/stylesheets/uikit/components/form-advanced.scss +128 -0
- data/vendor/assets/stylesheets/uikit/components/form-file.scss +63 -0
- data/vendor/assets/stylesheets/uikit/components/form-password.scss +74 -0
- data/vendor/assets/stylesheets/uikit/components/form-select.scss +66 -0
- data/vendor/assets/stylesheets/uikit/components/htmleditor.scss +269 -0
- data/vendor/assets/stylesheets/uikit/components/nestable.scss +231 -0
- data/vendor/assets/stylesheets/uikit/components/notify.scss +190 -0
- data/vendor/assets/stylesheets/uikit/components/placeholder.scss +66 -0
- data/vendor/assets/stylesheets/uikit/components/progress.scss +173 -0
- data/vendor/assets/stylesheets/uikit/components/search.scss +309 -0
- data/vendor/assets/stylesheets/uikit/components/slidenav.scss +183 -0
- data/vendor/assets/stylesheets/uikit/components/slider.scss +139 -0
- data/vendor/assets/stylesheets/uikit/components/slideshow.scss +208 -0
- data/vendor/assets/stylesheets/uikit/components/sortable.scss +124 -0
- data/vendor/assets/stylesheets/uikit/components/sticky.scss +57 -0
- data/vendor/assets/stylesheets/uikit/components/tooltip.scss +177 -0
- data/vendor/assets/stylesheets/uikit/components/upload.scss +34 -0
- data/vendor/assets/stylesheets/uikit/core/alert.scss +141 -0
- data/vendor/assets/stylesheets/uikit/core/animation.scss +599 -0
- data/vendor/assets/stylesheets/uikit/core/article.scss +139 -0
- data/vendor/assets/stylesheets/uikit/core/badge.scss +110 -0
- data/vendor/assets/stylesheets/uikit/core/base.scss +563 -0
- data/vendor/assets/stylesheets/uikit/core/block.scss +155 -0
- data/vendor/assets/stylesheets/uikit/core/breadcrumb.scss +86 -0
- data/vendor/assets/stylesheets/uikit/core/button.scss +406 -0
- data/vendor/assets/stylesheets/uikit/core/close.scss +132 -0
- data/vendor/assets/stylesheets/uikit/core/column.scss +209 -0
- data/vendor/assets/stylesheets/uikit/core/comment.scss +172 -0
- data/vendor/assets/stylesheets/uikit/core/contrast.scss +493 -0
- data/vendor/assets/stylesheets/uikit/core/cover.scss +70 -0
- data/vendor/assets/stylesheets/uikit/core/description-list.scss +71 -0
- data/vendor/assets/stylesheets/uikit/core/dropdown.scss +280 -0
- data/vendor/assets/stylesheets/uikit/core/flex.scss +320 -0
- data/vendor/assets/stylesheets/uikit/core/form.scss +629 -0
- data/vendor/assets/stylesheets/uikit/core/grid.scss +731 -0
- data/vendor/assets/stylesheets/uikit/core/icon.scss +930 -0
- data/vendor/assets/stylesheets/uikit/core/list.scss +102 -0
- data/vendor/assets/stylesheets/uikit/core/modal.scss +343 -0
- data/vendor/assets/stylesheets/uikit/core/nav.scss +468 -0
- data/vendor/assets/stylesheets/uikit/core/navbar.scss +325 -0
- data/vendor/assets/stylesheets/uikit/core/offcanvas.scss +203 -0
- data/vendor/assets/stylesheets/uikit/core/overlay.scss +534 -0
- data/vendor/assets/stylesheets/uikit/core/pagination.scss +197 -0
- data/vendor/assets/stylesheets/uikit/core/panel.scss +332 -0
- data/vendor/assets/stylesheets/uikit/core/print.scss +61 -0
- data/vendor/assets/stylesheets/uikit/core/subnav.scss +213 -0
- data/vendor/assets/stylesheets/uikit/core/switcher.scss +38 -0
- data/vendor/assets/stylesheets/uikit/core/tab.scss +368 -0
- data/vendor/assets/stylesheets/uikit/core/table.scss +147 -0
- data/vendor/assets/stylesheets/uikit/core/text.scss +136 -0
- data/vendor/assets/stylesheets/uikit/core/thumbnail.scss +122 -0
- data/vendor/assets/stylesheets/uikit/core/thumbnav.scss +122 -0
- data/vendor/assets/stylesheets/uikit/core/utility.scss +610 -0
- data/vendor/assets/stylesheets/uikit/core/variables.scss +23 -0
- data/vendor/assets/stylesheets/uikit/uikit-mixins.scss +327 -0
- data/vendor/assets/stylesheets/uikit/uikit-variables.scss +819 -0
- data/vendor/assets/stylesheets/uikit/uikit.scss +52 -0
- metadata +177 -0
@@ -0,0 +1,62 @@
|
|
1
|
+
/*! UIkit 2.27.1 | http://www.getuikit.com | (c) 2014 YOOtheme | MIT License */
|
2
|
+
(function(UI) {
|
3
|
+
|
4
|
+
"use strict";
|
5
|
+
|
6
|
+
UI.component('smoothScroll', {
|
7
|
+
|
8
|
+
boot: function() {
|
9
|
+
|
10
|
+
// init code
|
11
|
+
UI.$html.on("click.smooth-scroll.uikit", "[data-uk-smooth-scroll]", function(e) {
|
12
|
+
var ele = UI.$(this);
|
13
|
+
|
14
|
+
if (!ele.data("smoothScroll")) {
|
15
|
+
var obj = UI.smoothScroll(ele, UI.Utils.options(ele.attr("data-uk-smooth-scroll")));
|
16
|
+
ele.trigger("click");
|
17
|
+
}
|
18
|
+
|
19
|
+
return false;
|
20
|
+
});
|
21
|
+
},
|
22
|
+
|
23
|
+
init: function() {
|
24
|
+
|
25
|
+
var $this = this;
|
26
|
+
|
27
|
+
this.on("click", function(e) {
|
28
|
+
e.preventDefault();
|
29
|
+
scrollToElement(UI.$(this.hash).length ? UI.$(this.hash) : UI.$("body"), $this.options);
|
30
|
+
});
|
31
|
+
}
|
32
|
+
});
|
33
|
+
|
34
|
+
function scrollToElement(ele, options) {
|
35
|
+
|
36
|
+
options = UI.$.extend({
|
37
|
+
duration: 1000,
|
38
|
+
transition: 'easeOutExpo',
|
39
|
+
offset: 0,
|
40
|
+
complete: function(){}
|
41
|
+
}, options);
|
42
|
+
|
43
|
+
// get / set parameters
|
44
|
+
var target = ele.offset().top - options.offset,
|
45
|
+
docheight = UI.$doc.height(),
|
46
|
+
winheight = window.innerHeight;
|
47
|
+
|
48
|
+
if ((target + winheight) > docheight) {
|
49
|
+
target = docheight - winheight;
|
50
|
+
}
|
51
|
+
|
52
|
+
// animate to target, fire callback when done
|
53
|
+
UI.$("html,body").stop().animate({scrollTop: target}, options.duration, options.transition).promise().done(options.complete);
|
54
|
+
}
|
55
|
+
|
56
|
+
UI.Utils.scrollToElement = scrollToElement;
|
57
|
+
|
58
|
+
if (!UI.$.easing.easeOutExpo) {
|
59
|
+
UI.$.easing.easeOutExpo = function(x, t, b, c, d) { return (t == d) ? b + c : c * (-Math.pow(2, -10 * t / d) + 1) + b; };
|
60
|
+
}
|
61
|
+
|
62
|
+
})(UIkit);
|
@@ -0,0 +1,309 @@
|
|
1
|
+
/*! UIkit 2.27.1 | http://www.getuikit.com | (c) 2014 YOOtheme | MIT License */
|
2
|
+
(function(UI) {
|
3
|
+
|
4
|
+
"use strict";
|
5
|
+
|
6
|
+
var Animations;
|
7
|
+
|
8
|
+
UI.component('switcher', {
|
9
|
+
|
10
|
+
defaults: {
|
11
|
+
connect : false,
|
12
|
+
toggle : ">*",
|
13
|
+
active : 0,
|
14
|
+
animation : false,
|
15
|
+
duration : 200,
|
16
|
+
swiping : true
|
17
|
+
},
|
18
|
+
|
19
|
+
animating: false,
|
20
|
+
|
21
|
+
boot: function() {
|
22
|
+
|
23
|
+
// init code
|
24
|
+
UI.ready(function(context) {
|
25
|
+
|
26
|
+
UI.$("[data-uk-switcher]", context).each(function() {
|
27
|
+
var switcher = UI.$(this);
|
28
|
+
|
29
|
+
if (!switcher.data("switcher")) {
|
30
|
+
var obj = UI.switcher(switcher, UI.Utils.options(switcher.attr("data-uk-switcher")));
|
31
|
+
}
|
32
|
+
});
|
33
|
+
});
|
34
|
+
},
|
35
|
+
|
36
|
+
init: function() {
|
37
|
+
|
38
|
+
var $this = this;
|
39
|
+
|
40
|
+
this.on('click.uk.switcher', this.options.toggle, function(e) {
|
41
|
+
e.preventDefault();
|
42
|
+
$this.show(this);
|
43
|
+
});
|
44
|
+
|
45
|
+
if (!this.options.connect) {
|
46
|
+
return;
|
47
|
+
}
|
48
|
+
|
49
|
+
this.connect = UI.$(this.options.connect);
|
50
|
+
|
51
|
+
if (!this.connect.length) {
|
52
|
+
return;
|
53
|
+
}
|
54
|
+
|
55
|
+
this.connect.on('click.uk.switcher', '[data-uk-switcher-item]', function(e) {
|
56
|
+
|
57
|
+
e.preventDefault();
|
58
|
+
|
59
|
+
var item = UI.$(this).attr('data-uk-switcher-item');
|
60
|
+
|
61
|
+
if ($this.index == item) return;
|
62
|
+
|
63
|
+
switch(item) {
|
64
|
+
case 'next':
|
65
|
+
case 'previous':
|
66
|
+
$this.show($this.index + (item=='next' ? 1:-1));
|
67
|
+
break;
|
68
|
+
default:
|
69
|
+
$this.show(parseInt(item, 10));
|
70
|
+
}
|
71
|
+
});
|
72
|
+
|
73
|
+
if (this.options.swiping) {
|
74
|
+
|
75
|
+
this.connect.on('swipeRight swipeLeft', function(e) {
|
76
|
+
e.preventDefault();
|
77
|
+
if (!window.getSelection().toString()) {
|
78
|
+
$this.show($this.index + (e.type == 'swipeLeft' ? 1 : -1));
|
79
|
+
}
|
80
|
+
});
|
81
|
+
}
|
82
|
+
|
83
|
+
this.update();
|
84
|
+
},
|
85
|
+
|
86
|
+
update: function() {
|
87
|
+
|
88
|
+
this.connect.children().removeClass('uk-active').attr('aria-hidden', 'true');
|
89
|
+
|
90
|
+
var toggles = this.find(this.options.toggle),
|
91
|
+
active = toggles.filter(".uk-active");
|
92
|
+
|
93
|
+
if (active.length) {
|
94
|
+
this.show(active, false);
|
95
|
+
} else {
|
96
|
+
|
97
|
+
if (this.options.active===false) return;
|
98
|
+
|
99
|
+
active = toggles.eq(this.options.active);
|
100
|
+
this.show(active.length ? active : toggles.eq(0), false);
|
101
|
+
}
|
102
|
+
|
103
|
+
// Init ARIA for toggles
|
104
|
+
toggles.not(active).attr('aria-expanded', 'false');
|
105
|
+
active.attr('aria-expanded', 'true');
|
106
|
+
},
|
107
|
+
|
108
|
+
show: function(tab, animate) {
|
109
|
+
|
110
|
+
if (this.animating) {
|
111
|
+
return;
|
112
|
+
}
|
113
|
+
|
114
|
+
if (isNaN(tab)) {
|
115
|
+
tab = UI.$(tab);
|
116
|
+
} else {
|
117
|
+
|
118
|
+
var toggles = this.find(this.options.toggle);
|
119
|
+
|
120
|
+
tab = tab < 0 ? toggles.length-1 : tab;
|
121
|
+
tab = toggles.eq(toggles[tab] ? tab : 0);
|
122
|
+
}
|
123
|
+
|
124
|
+
var $this = this,
|
125
|
+
toggles = this.find(this.options.toggle),
|
126
|
+
active = UI.$(tab),
|
127
|
+
animation = Animations[this.options.animation] || function(current, next) {
|
128
|
+
|
129
|
+
if (!$this.options.animation) {
|
130
|
+
return Animations.none.apply($this);
|
131
|
+
}
|
132
|
+
|
133
|
+
var anim = $this.options.animation.split(',');
|
134
|
+
|
135
|
+
if (anim.length == 1) {
|
136
|
+
anim[1] = anim[0];
|
137
|
+
}
|
138
|
+
|
139
|
+
anim[0] = anim[0].trim();
|
140
|
+
anim[1] = anim[1].trim();
|
141
|
+
|
142
|
+
return coreAnimation.apply($this, [anim, current, next]);
|
143
|
+
};
|
144
|
+
|
145
|
+
if (animate===false || !UI.support.animation) {
|
146
|
+
animation = Animations.none;
|
147
|
+
}
|
148
|
+
|
149
|
+
if (active.hasClass("uk-disabled")) return;
|
150
|
+
|
151
|
+
// Update ARIA for Toggles
|
152
|
+
toggles.attr('aria-expanded', 'false');
|
153
|
+
active.attr('aria-expanded', 'true');
|
154
|
+
|
155
|
+
toggles.filter(".uk-active").removeClass("uk-active");
|
156
|
+
active.addClass("uk-active");
|
157
|
+
|
158
|
+
if (this.options.connect && this.connect.length) {
|
159
|
+
|
160
|
+
this.index = this.find(this.options.toggle).index(active);
|
161
|
+
|
162
|
+
if (this.index == -1 ) {
|
163
|
+
this.index = 0;
|
164
|
+
}
|
165
|
+
|
166
|
+
this.connect.each(function() {
|
167
|
+
|
168
|
+
var container = UI.$(this),
|
169
|
+
children = UI.$(container.children()),
|
170
|
+
current = UI.$(children.filter('.uk-active')),
|
171
|
+
next = UI.$(children.eq($this.index));
|
172
|
+
|
173
|
+
$this.animating = true;
|
174
|
+
|
175
|
+
animation.apply($this, [current, next]).then(function(){
|
176
|
+
|
177
|
+
current.removeClass("uk-active");
|
178
|
+
next.addClass("uk-active");
|
179
|
+
|
180
|
+
// Update ARIA for connect
|
181
|
+
current.attr('aria-hidden', 'true');
|
182
|
+
next.attr('aria-hidden', 'false');
|
183
|
+
|
184
|
+
UI.Utils.checkDisplay(next, true);
|
185
|
+
|
186
|
+
$this.animating = false;
|
187
|
+
|
188
|
+
});
|
189
|
+
});
|
190
|
+
}
|
191
|
+
|
192
|
+
this.trigger("show.uk.switcher", [active]);
|
193
|
+
}
|
194
|
+
});
|
195
|
+
|
196
|
+
Animations = {
|
197
|
+
|
198
|
+
'none': function() {
|
199
|
+
var d = UI.$.Deferred();
|
200
|
+
d.resolve();
|
201
|
+
return d.promise();
|
202
|
+
},
|
203
|
+
|
204
|
+
'fade': function(current, next) {
|
205
|
+
return coreAnimation.apply(this, ['uk-animation-fade', current, next]);
|
206
|
+
},
|
207
|
+
|
208
|
+
'slide-bottom': function(current, next) {
|
209
|
+
return coreAnimation.apply(this, ['uk-animation-slide-bottom', current, next]);
|
210
|
+
},
|
211
|
+
|
212
|
+
'slide-top': function(current, next) {
|
213
|
+
return coreAnimation.apply(this, ['uk-animation-slide-top', current, next]);
|
214
|
+
},
|
215
|
+
|
216
|
+
'slide-vertical': function(current, next, dir) {
|
217
|
+
|
218
|
+
var anim = ['uk-animation-slide-top', 'uk-animation-slide-bottom'];
|
219
|
+
|
220
|
+
if (current && current.index() > next.index()) {
|
221
|
+
anim.reverse();
|
222
|
+
}
|
223
|
+
|
224
|
+
return coreAnimation.apply(this, [anim, current, next]);
|
225
|
+
},
|
226
|
+
|
227
|
+
'slide-left': function(current, next) {
|
228
|
+
return coreAnimation.apply(this, ['uk-animation-slide-left', current, next]);
|
229
|
+
},
|
230
|
+
|
231
|
+
'slide-right': function(current, next) {
|
232
|
+
return coreAnimation.apply(this, ['uk-animation-slide-right', current, next]);
|
233
|
+
},
|
234
|
+
|
235
|
+
'slide-horizontal': function(current, next, dir) {
|
236
|
+
|
237
|
+
var anim = ['uk-animation-slide-right', 'uk-animation-slide-left'];
|
238
|
+
|
239
|
+
if (current && current.index() > next.index()) {
|
240
|
+
anim.reverse();
|
241
|
+
}
|
242
|
+
|
243
|
+
return coreAnimation.apply(this, [anim, current, next]);
|
244
|
+
},
|
245
|
+
|
246
|
+
'scale': function(current, next) {
|
247
|
+
return coreAnimation.apply(this, ['uk-animation-scale-up', current, next]);
|
248
|
+
}
|
249
|
+
};
|
250
|
+
|
251
|
+
UI.switcher.animations = Animations;
|
252
|
+
|
253
|
+
|
254
|
+
// helpers
|
255
|
+
|
256
|
+
function coreAnimation(cls, current, next) {
|
257
|
+
|
258
|
+
var d = UI.$.Deferred(), clsIn = cls, clsOut = cls, release;
|
259
|
+
|
260
|
+
if (next[0]===current[0]) {
|
261
|
+
d.resolve();
|
262
|
+
return d.promise();
|
263
|
+
}
|
264
|
+
|
265
|
+
if (typeof(cls) == 'object') {
|
266
|
+
clsIn = cls[0];
|
267
|
+
clsOut = cls[1] || cls[0];
|
268
|
+
}
|
269
|
+
|
270
|
+
UI.$body.css('overflow-x', 'hidden'); // fix scroll jumping in iOS
|
271
|
+
|
272
|
+
release = function() {
|
273
|
+
|
274
|
+
if (current) current.hide().removeClass('uk-active '+clsOut+' uk-animation-reverse');
|
275
|
+
|
276
|
+
next.addClass(clsIn).one(UI.support.animation.end, function() {
|
277
|
+
|
278
|
+
setTimeout(function () {
|
279
|
+
next.removeClass(''+clsIn+'').css({opacity:'', display:''});
|
280
|
+
}, 0);
|
281
|
+
|
282
|
+
d.resolve();
|
283
|
+
|
284
|
+
UI.$body.css('overflow-x', '');
|
285
|
+
|
286
|
+
if (current) current.css({opacity:'', display:''});
|
287
|
+
|
288
|
+
}.bind(this)).show();
|
289
|
+
};
|
290
|
+
|
291
|
+
next.css('animation-duration', this.options.duration+'ms');
|
292
|
+
|
293
|
+
if (current && current.length) {
|
294
|
+
|
295
|
+
current.css('animation-duration', this.options.duration+'ms');
|
296
|
+
|
297
|
+
current.css('display', 'none').addClass(clsOut+' uk-animation-reverse').one(UI.support.animation.end, function() {
|
298
|
+
release();
|
299
|
+
}.bind(this)).css('display', '');
|
300
|
+
|
301
|
+
} else {
|
302
|
+
next.addClass('uk-active');
|
303
|
+
release();
|
304
|
+
}
|
305
|
+
|
306
|
+
return d.promise();
|
307
|
+
}
|
308
|
+
|
309
|
+
})(UIkit);
|
@@ -0,0 +1,167 @@
|
|
1
|
+
/*! UIkit 2.27.1 | http://www.getuikit.com | (c) 2014 YOOtheme | MIT License */
|
2
|
+
(function(UI) {
|
3
|
+
|
4
|
+
"use strict";
|
5
|
+
|
6
|
+
UI.component('tab', {
|
7
|
+
|
8
|
+
defaults: {
|
9
|
+
target : '>li:not(.uk-tab-responsive, .uk-disabled)',
|
10
|
+
connect : false,
|
11
|
+
active : 0,
|
12
|
+
animation : false,
|
13
|
+
duration : 200,
|
14
|
+
swiping : true
|
15
|
+
},
|
16
|
+
|
17
|
+
boot: function() {
|
18
|
+
|
19
|
+
// init code
|
20
|
+
UI.ready(function(context) {
|
21
|
+
|
22
|
+
UI.$("[data-uk-tab]", context).each(function() {
|
23
|
+
|
24
|
+
var tab = UI.$(this);
|
25
|
+
|
26
|
+
if (!tab.data("tab")) {
|
27
|
+
var obj = UI.tab(tab, UI.Utils.options(tab.attr("data-uk-tab")));
|
28
|
+
}
|
29
|
+
});
|
30
|
+
});
|
31
|
+
},
|
32
|
+
|
33
|
+
init: function() {
|
34
|
+
|
35
|
+
var $this = this;
|
36
|
+
|
37
|
+
this.current = false;
|
38
|
+
|
39
|
+
this.on("click.uk.tab", this.options.target, function(e) {
|
40
|
+
|
41
|
+
e.preventDefault();
|
42
|
+
|
43
|
+
if ($this.switcher && $this.switcher.animating) {
|
44
|
+
return;
|
45
|
+
}
|
46
|
+
|
47
|
+
var current = $this.find($this.options.target).not(this);
|
48
|
+
|
49
|
+
current.removeClass("uk-active").blur();
|
50
|
+
|
51
|
+
$this.trigger("change.uk.tab", [UI.$(this).addClass("uk-active"), $this.current]);
|
52
|
+
|
53
|
+
$this.current = UI.$(this);
|
54
|
+
|
55
|
+
// Update ARIA
|
56
|
+
if (!$this.options.connect) {
|
57
|
+
current.attr('aria-expanded', 'false');
|
58
|
+
UI.$(this).attr('aria-expanded', 'true');
|
59
|
+
}
|
60
|
+
});
|
61
|
+
|
62
|
+
if (this.options.connect) {
|
63
|
+
this.connect = UI.$(this.options.connect);
|
64
|
+
}
|
65
|
+
|
66
|
+
// init responsive tab
|
67
|
+
this.responsivetab = UI.$('<li class="uk-tab-responsive uk-active"><a></a></li>').append('<div class="uk-dropdown uk-dropdown-small"><ul class="uk-nav uk-nav-dropdown"></ul><div>');
|
68
|
+
|
69
|
+
this.responsivetab.dropdown = this.responsivetab.find('.uk-dropdown');
|
70
|
+
this.responsivetab.lst = this.responsivetab.dropdown.find('ul');
|
71
|
+
this.responsivetab.caption = this.responsivetab.find('a:first');
|
72
|
+
|
73
|
+
if (this.element.hasClass("uk-tab-bottom")) this.responsivetab.dropdown.addClass("uk-dropdown-up");
|
74
|
+
|
75
|
+
// handle click
|
76
|
+
this.responsivetab.lst.on('click.uk.tab', 'a', function(e) {
|
77
|
+
|
78
|
+
e.preventDefault();
|
79
|
+
e.stopPropagation();
|
80
|
+
|
81
|
+
var link = UI.$(this);
|
82
|
+
|
83
|
+
$this.element.children('li:not(.uk-tab-responsive)').eq(link.data('index')).trigger('click');
|
84
|
+
});
|
85
|
+
|
86
|
+
this.on('show.uk.switcher change.uk.tab', function(e, tab) {
|
87
|
+
$this.responsivetab.caption.html(tab.text());
|
88
|
+
});
|
89
|
+
|
90
|
+
this.element.append(this.responsivetab);
|
91
|
+
|
92
|
+
// init UIkit components
|
93
|
+
if (this.options.connect) {
|
94
|
+
this.switcher = UI.switcher(this.element, {
|
95
|
+
'toggle' : '>li:not(.uk-tab-responsive)',
|
96
|
+
'connect' : this.options.connect,
|
97
|
+
'active' : this.options.active,
|
98
|
+
'animation' : this.options.animation,
|
99
|
+
'duration' : this.options.duration,
|
100
|
+
'swiping' : this.options.swiping
|
101
|
+
});
|
102
|
+
}
|
103
|
+
|
104
|
+
UI.dropdown(this.responsivetab, {"mode": "click", "preventflip": "y"});
|
105
|
+
|
106
|
+
// init
|
107
|
+
$this.trigger("change.uk.tab", [this.element.find(this.options.target).not('.uk-tab-responsive').filter('.uk-active')]);
|
108
|
+
|
109
|
+
this.check();
|
110
|
+
|
111
|
+
UI.$win.on('resize orientationchange', UI.Utils.debounce(function(){
|
112
|
+
if ($this.element.is(":visible")) $this.check();
|
113
|
+
}, 100));
|
114
|
+
|
115
|
+
this.on('display.uk.check', function(){
|
116
|
+
if ($this.element.is(":visible")) $this.check();
|
117
|
+
});
|
118
|
+
},
|
119
|
+
|
120
|
+
check: function() {
|
121
|
+
|
122
|
+
var children = this.element.children('li:not(.uk-tab-responsive)').removeClass('uk-hidden');
|
123
|
+
|
124
|
+
if (!children.length) {
|
125
|
+
this.responsivetab.addClass('uk-hidden');
|
126
|
+
return;
|
127
|
+
}
|
128
|
+
|
129
|
+
var top = (children.eq(0).offset().top + Math.ceil(children.eq(0).height()/2)),
|
130
|
+
doresponsive = false,
|
131
|
+
item, link, clone;
|
132
|
+
|
133
|
+
this.responsivetab.lst.empty();
|
134
|
+
|
135
|
+
children.each(function(){
|
136
|
+
|
137
|
+
if (UI.$(this).offset().top > top) {
|
138
|
+
doresponsive = true;
|
139
|
+
}
|
140
|
+
});
|
141
|
+
|
142
|
+
if (doresponsive) {
|
143
|
+
|
144
|
+
for (var i = 0; i < children.length; i++) {
|
145
|
+
|
146
|
+
item = UI.$(children.eq(i));
|
147
|
+
link = item.find('a');
|
148
|
+
|
149
|
+
if (item.css('float') != 'none' && !item.attr('uk-dropdown')) {
|
150
|
+
|
151
|
+
if (!item.hasClass('uk-disabled')) {
|
152
|
+
|
153
|
+
clone = item[0].outerHTML.replace('<a ', '<a data-index="'+i+'" ');
|
154
|
+
|
155
|
+
this.responsivetab.lst.append(clone);
|
156
|
+
}
|
157
|
+
|
158
|
+
item.addClass('uk-hidden');
|
159
|
+
}
|
160
|
+
}
|
161
|
+
}
|
162
|
+
|
163
|
+
this.responsivetab[this.responsivetab.lst.children('li').length ? 'removeClass':'addClass']('uk-hidden');
|
164
|
+
}
|
165
|
+
});
|
166
|
+
|
167
|
+
})(UIkit);
|