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,92 @@
|
|
1
|
+
/*! UIkit 2.27.1 | http://www.getuikit.com | (c) 2014 YOOtheme | MIT License */
|
2
|
+
(function(addon) {
|
3
|
+
|
4
|
+
var component;
|
5
|
+
|
6
|
+
if (window.UIkit) {
|
7
|
+
component = addon(UIkit);
|
8
|
+
}
|
9
|
+
|
10
|
+
if (typeof define == "function" && define.amd) {
|
11
|
+
define("uikit-search", ["uikit"], function(){
|
12
|
+
return component || addon(UIkit);
|
13
|
+
});
|
14
|
+
}
|
15
|
+
|
16
|
+
})(function(UI){
|
17
|
+
|
18
|
+
"use strict";
|
19
|
+
|
20
|
+
UI.component('search', {
|
21
|
+
defaults: {
|
22
|
+
msgResultsHeader : 'Search Results',
|
23
|
+
msgMoreResults : 'More Results',
|
24
|
+
msgNoResults : 'No results found',
|
25
|
+
template : '<ul class="uk-nav uk-nav-search uk-autocomplete-results">\
|
26
|
+
{{#msgResultsHeader}}<li class="uk-nav-header uk-skip">{{msgResultsHeader}}</li>{{/msgResultsHeader}}\
|
27
|
+
{{#items && items.length}}\
|
28
|
+
{{~items}}\
|
29
|
+
<li data-url="{{!$item.url}}">\
|
30
|
+
<a href="{{!$item.url}}">\
|
31
|
+
{{{$item.title}}}\
|
32
|
+
{{#$item.text}}<div>{{{$item.text}}}</div>{{/$item.text}}\
|
33
|
+
</a>\
|
34
|
+
</li>\
|
35
|
+
{{/items}}\
|
36
|
+
{{#msgMoreResults}}\
|
37
|
+
<li class="uk-nav-divider uk-skip"></li>\
|
38
|
+
<li class="uk-search-moreresults" data-moreresults="true"><a href="#" onclick="jQuery(this).closest(\'form\').submit();">{{msgMoreResults}}</a></li>\
|
39
|
+
{{/msgMoreResults}}\
|
40
|
+
{{/end}}\
|
41
|
+
{{^items.length}}\
|
42
|
+
{{#msgNoResults}}<li class="uk-skip"><a>{{msgNoResults}}</a></li>{{/msgNoResults}}\
|
43
|
+
{{/end}}\
|
44
|
+
</ul>',
|
45
|
+
|
46
|
+
renderer: function(data) {
|
47
|
+
|
48
|
+
var opts = this.options;
|
49
|
+
|
50
|
+
this.dropdown.append(this.template({"items":data.results || [], "msgResultsHeader":opts.msgResultsHeader, "msgMoreResults": opts.msgMoreResults, "msgNoResults": opts.msgNoResults}));
|
51
|
+
this.show();
|
52
|
+
}
|
53
|
+
},
|
54
|
+
|
55
|
+
boot: function() {
|
56
|
+
|
57
|
+
// init code
|
58
|
+
UI.$html.on("focus.search.uikit", "[data-uk-search]", function(e) {
|
59
|
+
var ele =UI.$(this);
|
60
|
+
|
61
|
+
if (!ele.data("search")) {
|
62
|
+
UI.search(ele, UI.Utils.options(ele.attr("data-uk-search")));
|
63
|
+
}
|
64
|
+
});
|
65
|
+
},
|
66
|
+
|
67
|
+
init: function() {
|
68
|
+
var $this = this;
|
69
|
+
|
70
|
+
this.autocomplete = UI.autocomplete(this.element, this.options);
|
71
|
+
|
72
|
+
this.autocomplete.dropdown.addClass('uk-dropdown-search');
|
73
|
+
|
74
|
+
this.autocomplete.input.on("keyup", function(){
|
75
|
+
$this.element[$this.autocomplete.input.val() ? "addClass":"removeClass"]("uk-active");
|
76
|
+
}).closest("form").on("reset", function(){
|
77
|
+
$this.value="";
|
78
|
+
$this.element.removeClass("uk-active");
|
79
|
+
});
|
80
|
+
|
81
|
+
this.on('selectitem.uk.autocomplete', function(e, data) {
|
82
|
+
if (data.url) {
|
83
|
+
location.href = data.url;
|
84
|
+
} else if(data.moreresults) {
|
85
|
+
$this.autocomplete.input.closest('form').submit();
|
86
|
+
}
|
87
|
+
});
|
88
|
+
|
89
|
+
this.element.data("search", this);
|
90
|
+
}
|
91
|
+
});
|
92
|
+
});
|
@@ -0,0 +1,552 @@
|
|
1
|
+
/*! UIkit 2.27.1 | http://www.getuikit.com | (c) 2014 YOOtheme | MIT License */
|
2
|
+
(function(addon) {
|
3
|
+
|
4
|
+
var component;
|
5
|
+
|
6
|
+
if (window.UIkit) {
|
7
|
+
component = addon(UIkit);
|
8
|
+
}
|
9
|
+
|
10
|
+
if (typeof define == "function" && define.amd) {
|
11
|
+
define("uikit-slider", ["uikit"], function(){
|
12
|
+
return component || addon(UIkit);
|
13
|
+
});
|
14
|
+
}
|
15
|
+
|
16
|
+
})(function(UI){
|
17
|
+
|
18
|
+
"use strict";
|
19
|
+
|
20
|
+
var dragging, delayIdle, anchor, dragged, store = {};
|
21
|
+
|
22
|
+
UI.component('slider', {
|
23
|
+
|
24
|
+
defaults: {
|
25
|
+
center : false,
|
26
|
+
threshold : 10,
|
27
|
+
infinite : true,
|
28
|
+
autoplay : false,
|
29
|
+
autoplayInterval : 7000,
|
30
|
+
pauseOnHover : true,
|
31
|
+
activecls : 'uk-active'
|
32
|
+
},
|
33
|
+
|
34
|
+
boot: function() {
|
35
|
+
|
36
|
+
// init code
|
37
|
+
UI.ready(function(context) {
|
38
|
+
|
39
|
+
setTimeout(function(){
|
40
|
+
|
41
|
+
UI.$('[data-uk-slider]', context).each(function(){
|
42
|
+
|
43
|
+
var ele = UI.$(this);
|
44
|
+
|
45
|
+
if (!ele.data('slider')) {
|
46
|
+
UI.slider(ele, UI.Utils.options(ele.attr('data-uk-slider')));
|
47
|
+
}
|
48
|
+
});
|
49
|
+
|
50
|
+
}, 0);
|
51
|
+
});
|
52
|
+
},
|
53
|
+
|
54
|
+
init: function() {
|
55
|
+
|
56
|
+
var $this = this;
|
57
|
+
|
58
|
+
this.container = this.element.find('.uk-slider');
|
59
|
+
this.focus = 0;
|
60
|
+
|
61
|
+
UI.$win.on('resize load', UI.Utils.debounce(function() {
|
62
|
+
$this.update(true);
|
63
|
+
}, 100));
|
64
|
+
|
65
|
+
this.on('click.uk.slider', '[data-uk-slider-item]', function(e) {
|
66
|
+
|
67
|
+
e.preventDefault();
|
68
|
+
|
69
|
+
var item = UI.$(this).attr('data-uk-slider-item');
|
70
|
+
|
71
|
+
if ($this.focus == item) return;
|
72
|
+
|
73
|
+
// stop autoplay
|
74
|
+
$this.stop();
|
75
|
+
|
76
|
+
switch(item) {
|
77
|
+
case 'next':
|
78
|
+
case 'previous':
|
79
|
+
$this[item=='next' ? 'next':'previous']();
|
80
|
+
break;
|
81
|
+
default:
|
82
|
+
$this.updateFocus(parseInt(item, 10));
|
83
|
+
}
|
84
|
+
});
|
85
|
+
|
86
|
+
this.container.on({
|
87
|
+
|
88
|
+
'touchstart mousedown': function(evt) {
|
89
|
+
|
90
|
+
if (evt.originalEvent && evt.originalEvent.touches) {
|
91
|
+
evt = evt.originalEvent.touches[0];
|
92
|
+
}
|
93
|
+
|
94
|
+
// ignore right click button
|
95
|
+
if (evt.button && evt.button==2 || !$this.active) {
|
96
|
+
return;
|
97
|
+
}
|
98
|
+
|
99
|
+
// stop autoplay
|
100
|
+
$this.stop();
|
101
|
+
|
102
|
+
anchor = UI.$(evt.target).is('a') ? UI.$(evt.target) : UI.$(evt.target).parents('a:first');
|
103
|
+
dragged = false;
|
104
|
+
|
105
|
+
if (anchor.length) {
|
106
|
+
|
107
|
+
anchor.one('click', function(e){
|
108
|
+
if (dragged) e.preventDefault();
|
109
|
+
});
|
110
|
+
}
|
111
|
+
|
112
|
+
delayIdle = function(e) {
|
113
|
+
|
114
|
+
dragged = true;
|
115
|
+
dragging = $this;
|
116
|
+
store = {
|
117
|
+
touchx : parseInt(e.pageX, 10),
|
118
|
+
dir : 1,
|
119
|
+
focus : $this.focus,
|
120
|
+
base : $this.options.center ? 'center':'area'
|
121
|
+
};
|
122
|
+
|
123
|
+
if (e.originalEvent && e.originalEvent.touches) {
|
124
|
+
e = e.originalEvent.touches[0];
|
125
|
+
}
|
126
|
+
|
127
|
+
dragging.element.data({
|
128
|
+
'pointer-start': {x: parseInt(e.pageX, 10), y: parseInt(e.pageY, 10)},
|
129
|
+
'pointer-pos-start': $this.pos
|
130
|
+
});
|
131
|
+
|
132
|
+
$this.container.addClass('uk-drag');
|
133
|
+
|
134
|
+
delayIdle = false;
|
135
|
+
};
|
136
|
+
|
137
|
+
delayIdle.x = parseInt(evt.pageX, 10);
|
138
|
+
delayIdle.threshold = $this.options.threshold;
|
139
|
+
|
140
|
+
},
|
141
|
+
|
142
|
+
mouseenter: function() { if ($this.options.pauseOnHover) $this.hovering = true; },
|
143
|
+
mouseleave: function() { $this.hovering = false; }
|
144
|
+
});
|
145
|
+
|
146
|
+
this.update(true);
|
147
|
+
|
148
|
+
this.on('display.uk.check', function(){
|
149
|
+
if ($this.element.is(":visible")) {
|
150
|
+
$this.update(true);
|
151
|
+
}
|
152
|
+
});
|
153
|
+
|
154
|
+
// prevent dragging links + images
|
155
|
+
this.element.find('a,img').attr('draggable', 'false');
|
156
|
+
|
157
|
+
// Set autoplay
|
158
|
+
if (this.options.autoplay) {
|
159
|
+
this.start();
|
160
|
+
}
|
161
|
+
|
162
|
+
UI.domObserve(this.element, function(e) {
|
163
|
+
if ($this.element.children(':not([data-slide])').length) {
|
164
|
+
$this.update(true);
|
165
|
+
}
|
166
|
+
});
|
167
|
+
|
168
|
+
},
|
169
|
+
|
170
|
+
update: function(focus) {
|
171
|
+
|
172
|
+
var $this = this, pos = 0, maxheight = 0, item, width, cwidth, size;
|
173
|
+
|
174
|
+
this.items = this.container.children().filter(':visible');
|
175
|
+
this.vp = this.element[0].getBoundingClientRect().width;
|
176
|
+
|
177
|
+
this.container.css({'min-width': '', 'min-height': ''});
|
178
|
+
|
179
|
+
this.items.each(function(idx){
|
180
|
+
|
181
|
+
item = UI.$(this).attr('data-slide', idx);
|
182
|
+
size = item.css({'left': '', 'width':''})[0].getBoundingClientRect();
|
183
|
+
width = size.width;
|
184
|
+
cwidth = item.width();
|
185
|
+
maxheight = Math.max(maxheight, size.height);
|
186
|
+
|
187
|
+
item.css({'left': pos, 'width':width}).data({'idx':idx, 'left': pos, 'width': width, 'cwidth':cwidth, 'area': (pos+width), 'center':(pos - ($this.vp/2 - cwidth/2))});
|
188
|
+
|
189
|
+
pos += width;
|
190
|
+
});
|
191
|
+
|
192
|
+
this.container.css({'min-width': pos, 'min-height': maxheight});
|
193
|
+
|
194
|
+
if (this.options.infinite && (pos <= (2*this.vp) || this.items.length < 5) && !this.itemsResized) {
|
195
|
+
|
196
|
+
// fill with cloned items
|
197
|
+
this.container.children().each(function(idx){
|
198
|
+
$this.container.append($this.items.eq(idx).clone(true).attr('id', ''));
|
199
|
+
}).each(function(idx){
|
200
|
+
$this.container.append($this.items.eq(idx).clone(true).attr('id', ''));
|
201
|
+
});
|
202
|
+
|
203
|
+
this.itemsResized = true;
|
204
|
+
|
205
|
+
return this.update();
|
206
|
+
}
|
207
|
+
|
208
|
+
this.cw = pos;
|
209
|
+
this.pos = 0;
|
210
|
+
this.active = pos >= this.vp;
|
211
|
+
|
212
|
+
this.container.css({
|
213
|
+
'-ms-transform': '',
|
214
|
+
'-webkit-transform': '',
|
215
|
+
'transform': ''
|
216
|
+
});
|
217
|
+
|
218
|
+
if (focus) this.updateFocus(this.focus);
|
219
|
+
},
|
220
|
+
|
221
|
+
updatePos: function(pos) {
|
222
|
+
this.pos = pos;
|
223
|
+
this.container.css({
|
224
|
+
'-ms-transform': 'translateX('+pos+'px)',
|
225
|
+
'-webkit-transform': 'translateX('+pos+'px)',
|
226
|
+
'transform': 'translateX('+pos+'px)'
|
227
|
+
});
|
228
|
+
},
|
229
|
+
|
230
|
+
updateFocus: function(idx, dir) {
|
231
|
+
|
232
|
+
if (!this.active) {
|
233
|
+
return;
|
234
|
+
}
|
235
|
+
|
236
|
+
dir = dir || (idx > this.focus ? 1:-1);
|
237
|
+
|
238
|
+
var item = this.items.eq(idx), area, i;
|
239
|
+
|
240
|
+
if (this.options.infinite) {
|
241
|
+
this.infinite(idx, dir);
|
242
|
+
}
|
243
|
+
|
244
|
+
if (this.options.center) {
|
245
|
+
|
246
|
+
this.updatePos(item.data('center')*-1);
|
247
|
+
|
248
|
+
this.items.filter('.'+this.options.activecls).removeClass(this.options.activecls);
|
249
|
+
item.addClass(this.options.activecls);
|
250
|
+
|
251
|
+
} else {
|
252
|
+
|
253
|
+
if (this.options.infinite) {
|
254
|
+
|
255
|
+
this.updatePos(item.data('left')*-1);
|
256
|
+
|
257
|
+
} else {
|
258
|
+
|
259
|
+
area = 0;
|
260
|
+
|
261
|
+
for (i=idx;i<this.items.length;i++) {
|
262
|
+
area += this.items.eq(i).data('width');
|
263
|
+
}
|
264
|
+
|
265
|
+
|
266
|
+
if (area > this.vp) {
|
267
|
+
|
268
|
+
this.updatePos(item.data('left')*-1);
|
269
|
+
|
270
|
+
} else {
|
271
|
+
|
272
|
+
if (dir == 1) {
|
273
|
+
|
274
|
+
area = 0;
|
275
|
+
|
276
|
+
for (i=this.items.length-1;i>=0;i--) {
|
277
|
+
|
278
|
+
area += this.items.eq(i).data('width');
|
279
|
+
|
280
|
+
if (area == this.vp) {
|
281
|
+
idx = i;
|
282
|
+
break;
|
283
|
+
}
|
284
|
+
|
285
|
+
if (area > this.vp) {
|
286
|
+
idx = (i < this.items.length-1) ? i+1 : i;
|
287
|
+
break;
|
288
|
+
}
|
289
|
+
}
|
290
|
+
|
291
|
+
if (area > this.vp) {
|
292
|
+
this.updatePos((this.container.width() - this.vp) * -1);
|
293
|
+
} else {
|
294
|
+
this.updatePos(this.items.eq(idx).data('left')*-1);
|
295
|
+
}
|
296
|
+
}
|
297
|
+
}
|
298
|
+
}
|
299
|
+
}
|
300
|
+
|
301
|
+
// mark elements
|
302
|
+
var left = this.items.eq(idx).data('left');
|
303
|
+
|
304
|
+
this.items.removeClass('uk-slide-before uk-slide-after').each(function(i){
|
305
|
+
if (i!==idx) {
|
306
|
+
UI.$(this).addClass(UI.$(this).data('left') < left ? 'uk-slide-before':'uk-slide-after');
|
307
|
+
}
|
308
|
+
});
|
309
|
+
|
310
|
+
this.focus = idx;
|
311
|
+
|
312
|
+
this.trigger('focusitem.uk.slider', [idx,this.items.eq(idx),this]);
|
313
|
+
},
|
314
|
+
|
315
|
+
next: function() {
|
316
|
+
|
317
|
+
var focus = this.items[this.focus + 1] ? (this.focus + 1) : (this.options.infinite ? 0:this.focus);
|
318
|
+
|
319
|
+
this.updateFocus(focus, 1);
|
320
|
+
},
|
321
|
+
|
322
|
+
previous: function() {
|
323
|
+
|
324
|
+
var focus = this.items[this.focus - 1] ? (this.focus - 1) : (this.options.infinite ? (this.items[this.focus - 1] ? this.items-1:this.items.length-1):this.focus);
|
325
|
+
|
326
|
+
this.updateFocus(focus, -1);
|
327
|
+
},
|
328
|
+
|
329
|
+
start: function() {
|
330
|
+
|
331
|
+
this.stop();
|
332
|
+
|
333
|
+
var $this = this;
|
334
|
+
|
335
|
+
this.interval = setInterval(function() {
|
336
|
+
if (!$this.hovering) $this.next();
|
337
|
+
}, this.options.autoplayInterval);
|
338
|
+
|
339
|
+
},
|
340
|
+
|
341
|
+
stop: function() {
|
342
|
+
if (this.interval) clearInterval(this.interval);
|
343
|
+
},
|
344
|
+
|
345
|
+
infinite: function(baseidx, direction) {
|
346
|
+
|
347
|
+
var $this = this, item = this.items.eq(baseidx), i, z = baseidx, move = [], area = 0;
|
348
|
+
|
349
|
+
if (direction == 1) {
|
350
|
+
|
351
|
+
|
352
|
+
for (i=0;i<this.items.length;i++) {
|
353
|
+
|
354
|
+
if (z != baseidx) {
|
355
|
+
area += this.items.eq(z).data('width');
|
356
|
+
move.push(this.items.eq(z));
|
357
|
+
}
|
358
|
+
|
359
|
+
if (area > this.vp) {
|
360
|
+
break;
|
361
|
+
}
|
362
|
+
|
363
|
+
z = z+1 == this.items.length ? 0:z+1;
|
364
|
+
}
|
365
|
+
|
366
|
+
if (move.length) {
|
367
|
+
|
368
|
+
move.forEach(function(itm){
|
369
|
+
|
370
|
+
var left = item.data('area');
|
371
|
+
|
372
|
+
itm.css({'left': left}).data({
|
373
|
+
'left' : left,
|
374
|
+
'area' : (left+itm.data('width')),
|
375
|
+
'center': (left - ($this.vp/2 - itm.data('cwidth')/2))
|
376
|
+
});
|
377
|
+
|
378
|
+
item = itm;
|
379
|
+
});
|
380
|
+
}
|
381
|
+
|
382
|
+
|
383
|
+
} else {
|
384
|
+
|
385
|
+
for (i=this.items.length-1;i >-1 ;i--) {
|
386
|
+
|
387
|
+
area += this.items.eq(z).data('width');
|
388
|
+
|
389
|
+
if (z != baseidx) {
|
390
|
+
move.push(this.items.eq(z));
|
391
|
+
}
|
392
|
+
|
393
|
+
if (area > this.vp) {
|
394
|
+
break;
|
395
|
+
}
|
396
|
+
|
397
|
+
z = z-1 == -1 ? this.items.length-1:z-1;
|
398
|
+
}
|
399
|
+
|
400
|
+
if (move.length) {
|
401
|
+
|
402
|
+
move.forEach(function(itm){
|
403
|
+
|
404
|
+
var left = item.data('left') - itm.data('width');
|
405
|
+
|
406
|
+
itm.css({'left': left}).data({
|
407
|
+
'left' : left,
|
408
|
+
'area' : (left+itm.data('width')),
|
409
|
+
'center': (left - ($this.vp/2 - itm.data('cwidth')/2))
|
410
|
+
});
|
411
|
+
|
412
|
+
item = itm;
|
413
|
+
});
|
414
|
+
}
|
415
|
+
}
|
416
|
+
}
|
417
|
+
});
|
418
|
+
|
419
|
+
// handle dragging
|
420
|
+
UI.$doc.on('mousemove.uk.slider touchmove.uk.slider', function(e) {
|
421
|
+
|
422
|
+
if (e.originalEvent && e.originalEvent.touches) {
|
423
|
+
e = e.originalEvent.touches[0];
|
424
|
+
}
|
425
|
+
|
426
|
+
if (delayIdle && Math.abs(e.pageX - delayIdle.x) > delayIdle.threshold) {
|
427
|
+
|
428
|
+
if (!window.getSelection().toString()) {
|
429
|
+
delayIdle(e);
|
430
|
+
} else {
|
431
|
+
dragging = delayIdle = false;
|
432
|
+
}
|
433
|
+
}
|
434
|
+
|
435
|
+
if (!dragging) {
|
436
|
+
return;
|
437
|
+
}
|
438
|
+
|
439
|
+
var x, xDiff, pos, dir, focus, item, next, diff, i, z, itm;
|
440
|
+
|
441
|
+
if (e.clientX || e.clientY) {
|
442
|
+
x = e.clientX;
|
443
|
+
} else if (e.pageX || e.pageY) {
|
444
|
+
x = e.pageX - document.body.scrollLeft - document.documentElement.scrollLeft;
|
445
|
+
}
|
446
|
+
|
447
|
+
focus = store.focus;
|
448
|
+
xDiff = x - dragging.element.data('pointer-start').x;
|
449
|
+
pos = dragging.element.data('pointer-pos-start') + xDiff;
|
450
|
+
dir = x > dragging.element.data('pointer-start').x ? -1:1;
|
451
|
+
item = dragging.items.eq(store.focus);
|
452
|
+
|
453
|
+
if (dir == 1) {
|
454
|
+
|
455
|
+
diff = item.data('left') + Math.abs(xDiff);
|
456
|
+
|
457
|
+
for (i=0,z=store.focus;i<dragging.items.length;i++) {
|
458
|
+
|
459
|
+
itm = dragging.items.eq(z);
|
460
|
+
|
461
|
+
if (z != store.focus && itm.data('left') < diff && itm.data('area') > diff) {
|
462
|
+
focus = z;
|
463
|
+
break;
|
464
|
+
}
|
465
|
+
|
466
|
+
z = z+1 == dragging.items.length ? 0:z+1;
|
467
|
+
}
|
468
|
+
|
469
|
+
} else {
|
470
|
+
|
471
|
+
diff = item.data('left') - Math.abs(xDiff);
|
472
|
+
|
473
|
+
for (i=0,z=store.focus;i<dragging.items.length;i++) {
|
474
|
+
|
475
|
+
itm = dragging.items.eq(z);
|
476
|
+
|
477
|
+
if (z != store.focus && itm.data('area') <= item.data('left') && itm.data('center') < diff) {
|
478
|
+
focus = z;
|
479
|
+
break;
|
480
|
+
}
|
481
|
+
|
482
|
+
z = z-1 == -1 ? dragging.items.length-1:z-1;
|
483
|
+
}
|
484
|
+
}
|
485
|
+
|
486
|
+
if (dragging.options.infinite && focus!=store._focus) {
|
487
|
+
dragging.infinite(focus, dir);
|
488
|
+
}
|
489
|
+
|
490
|
+
dragging.updatePos(pos);
|
491
|
+
|
492
|
+
store.dir = dir;
|
493
|
+
store._focus = focus;
|
494
|
+
store.touchx = parseInt(e.pageX, 10);
|
495
|
+
store.diff = diff;
|
496
|
+
});
|
497
|
+
|
498
|
+
UI.$doc.on('mouseup.uk.slider touchend.uk.slider', function(e) {
|
499
|
+
|
500
|
+
if (dragging) {
|
501
|
+
|
502
|
+
dragging.container.removeClass('uk-drag');
|
503
|
+
|
504
|
+
// TODO is this needed?
|
505
|
+
dragging.items.eq(store.focus);
|
506
|
+
|
507
|
+
var itm, focus = false, i, z;
|
508
|
+
|
509
|
+
if (store.dir == 1) {
|
510
|
+
|
511
|
+
for (i=0,z=store.focus;i<dragging.items.length;i++) {
|
512
|
+
|
513
|
+
itm = dragging.items.eq(z);
|
514
|
+
|
515
|
+
if (z != store.focus && itm.data('left') > store.diff) {
|
516
|
+
focus = z;
|
517
|
+
break;
|
518
|
+
}
|
519
|
+
|
520
|
+
z = z+1 == dragging.items.length ? 0:z+1;
|
521
|
+
}
|
522
|
+
if (!dragging.options.infinite && !focus) {
|
523
|
+
focus = dragging.items.length;
|
524
|
+
}
|
525
|
+
|
526
|
+
} else {
|
527
|
+
|
528
|
+
for (i=0,z=store.focus;i<dragging.items.length;i++) {
|
529
|
+
|
530
|
+
itm = dragging.items.eq(z);
|
531
|
+
|
532
|
+
if (z != store.focus && itm.data('left') < store.diff) {
|
533
|
+
focus = z;
|
534
|
+
break;
|
535
|
+
}
|
536
|
+
|
537
|
+
z = z-1 == -1 ? dragging.items.length-1:z-1;
|
538
|
+
}
|
539
|
+
if (!dragging.options.infinite && !focus) {
|
540
|
+
focus = 0
|
541
|
+
}
|
542
|
+
}
|
543
|
+
|
544
|
+
dragging.updateFocus(focus!==false ? focus:store._focus);
|
545
|
+
|
546
|
+
}
|
547
|
+
|
548
|
+
dragging = delayIdle = false;
|
549
|
+
});
|
550
|
+
|
551
|
+
return UI.slider;
|
552
|
+
});
|