Renamed the uikit lib folders. Resolved the gh-188 by updateing the note. Resolved gh-92 by implementation of the library manager in the compiler.

This commit is contained in:
2017-12-10 21:17:26 +02:00
parent b60d208d9e
commit f900f65baa
700 changed files with 12837 additions and 14154 deletions

View File

@ -0,0 +1,180 @@
/*! UIkit 2.27.4 | http://www.getuikit.com | (c) 2014 YOOtheme | MIT License */
(function(addon) {
var component;
if (window.UIkit2) {
component = addon(UIkit2);
}
if (typeof define == 'function' && define.amd) {
define('uikit-accordion', ['uikit'], function(){
return component || addon(UIkit2);
});
}
})(function(UI){
"use strict";
UI.component('accordion', {
defaults: {
showfirst : true,
collapse : true,
animate : true,
easing : 'swing',
duration : 300,
toggle : '.uk-accordion-title',
containers : '.uk-accordion-content',
clsactive : 'uk-active'
},
boot: function() {
// init code
UI.ready(function(context) {
setTimeout(function(){
UI.$('[data-uk-accordion]', context).each(function(){
var ele = UI.$(this);
if (!ele.data('accordion')) {
UI.accordion(ele, UI.Utils.options(ele.attr('data-uk-accordion')));
}
});
}, 0);
});
},
init: function() {
var $this = this;
this.element.on('click.uk.accordion', this.options.toggle, function(e) {
e.preventDefault();
$this.toggleItem(UI.$(this).data('wrapper'), $this.options.animate, $this.options.collapse);
});
this.update(true);
UI.domObserve(this.element, function(e) {
if ($this.element.children($this.options.containers).length) {
$this.update();
}
});
},
toggleItem: function(wrapper, animated, collapse) {
var $this = this;
wrapper.data('toggle').toggleClass(this.options.clsactive);
wrapper.data('content').toggleClass(this.options.clsactive);
var active = wrapper.data('toggle').hasClass(this.options.clsactive);
if (collapse) {
this.toggle.not(wrapper.data('toggle')).removeClass(this.options.clsactive);
this.content.not(wrapper.data('content')).removeClass(this.options.clsactive)
.parent().stop().css('overflow', 'hidden').animate({ height: 0 }, {easing: this.options.easing, duration: animated ? this.options.duration : 0}).attr('aria-expanded', 'false');
}
wrapper.stop().css('overflow', 'hidden');
if (animated) {
wrapper.animate({ height: active ? getHeight(wrapper.data('content')) : 0 }, {easing: this.options.easing, duration: this.options.duration, complete: function() {
if (active) {
wrapper.css({'overflow': '', 'height': 'auto'});
UI.Utils.checkDisplay(wrapper.data('content'));
}
$this.trigger('display.uk.check');
}});
} else {
wrapper.height(active ? 'auto' : 0);
if (active) {
wrapper.css({'overflow': ''});
UI.Utils.checkDisplay(wrapper.data('content'));
}
this.trigger('display.uk.check');
}
// Update ARIA
wrapper.attr('aria-expanded', active);
this.element.trigger('toggle.uk.accordion', [active, wrapper.data('toggle'), wrapper.data('content')]);
},
update: function(init) {
var $this = this, $content, $wrapper, $toggle;
this.toggle = this.find(this.options.toggle);
this.content = this.find(this.options.containers);
this.content.each(function(index) {
$content = UI.$(this);
if ($content.parent().data('wrapper')) {
$wrapper = $content.parent();
} else {
$wrapper = UI.$(this).wrap('<div data-wrapper="true" style="overflow:hidden;height:0;position:relative;"></div>').parent();
// Init ARIA
$wrapper.attr('aria-expanded', 'false');
}
$toggle = $this.toggle.eq(index);
$wrapper.data('toggle', $toggle);
$wrapper.data('content', $content);
$toggle.data('wrapper', $wrapper);
$content.data('wrapper', $wrapper);
});
this.element.trigger('update.uk.accordion', [this]);
if (init && this.options.showfirst) {
this.toggleItem(this.toggle.eq(0).data('wrapper'), false, false);
}
}
});
// helper
function getHeight(ele) {
var $ele = UI.$(ele), height = "auto";
if ($ele.is(":visible")) {
height = $ele.outerHeight();
} else {
var tmp = {
position : $ele.css('position'),
visibility : $ele.css('visibility'),
display : $ele.css('display')
};
height = $ele.css({position: 'absolute', visibility: 'hidden', display: 'block'}).outerHeight();
$ele.css(tmp); // reset element
}
return height;
}
return UI.accordion;
});

View File

@ -0,0 +1,2 @@
/*! UIkit 2.27.4 | http://www.getuikit.com | (c) 2014 YOOtheme | MIT License */
!function(t){var i;window.UIkit2&&(i=t(UIkit2)),"function"==typeof define&&define.amd&&define("uikit-accordion",["uikit"],function(){return i||t(UIkit2)})}(function(t){"use strict";function i(i){var e=t.$(i),o="auto";if(e.is(":visible"))o=e.outerHeight();else{var a={position:e.css("position"),visibility:e.css("visibility"),display:e.css("display")};o=e.css({position:"absolute",visibility:"hidden",display:"block"}).outerHeight(),e.css(a)}return o}return t.component("accordion",{defaults:{showfirst:!0,collapse:!0,animate:!0,easing:"swing",duration:300,toggle:".uk-accordion-title",containers:".uk-accordion-content",clsactive:"uk-active"},boot:function(){t.ready(function(i){setTimeout(function(){t.$("[data-uk-accordion]",i).each(function(){var i=t.$(this);i.data("accordion")||t.accordion(i,t.Utils.options(i.attr("data-uk-accordion")))})},0)})},init:function(){var i=this;this.element.on("click.uk.accordion",this.options.toggle,function(e){e.preventDefault(),i.toggleItem(t.$(this).data("wrapper"),i.options.animate,i.options.collapse)}),this.update(!0),t.domObserve(this.element,function(){i.element.children(i.options.containers).length&&i.update()})},toggleItem:function(e,o,a){var n=this;e.data("toggle").toggleClass(this.options.clsactive),e.data("content").toggleClass(this.options.clsactive);var s=e.data("toggle").hasClass(this.options.clsactive);a&&(this.toggle.not(e.data("toggle")).removeClass(this.options.clsactive),this.content.not(e.data("content")).removeClass(this.options.clsactive).parent().stop().css("overflow","hidden").animate({height:0},{easing:this.options.easing,duration:o?this.options.duration:0}).attr("aria-expanded","false")),e.stop().css("overflow","hidden"),o?e.animate({height:s?i(e.data("content")):0},{easing:this.options.easing,duration:this.options.duration,complete:function(){s&&(e.css({overflow:"",height:"auto"}),t.Utils.checkDisplay(e.data("content"))),n.trigger("display.uk.check")}}):(e.height(s?"auto":0),s&&(e.css({overflow:""}),t.Utils.checkDisplay(e.data("content"))),this.trigger("display.uk.check")),e.attr("aria-expanded",s),this.element.trigger("toggle.uk.accordion",[s,e.data("toggle"),e.data("content")])},update:function(i){var e,o,a,n=this;this.toggle=this.find(this.options.toggle),this.content=this.find(this.options.containers),this.content.each(function(i){e=t.$(this),e.parent().data("wrapper")?o=e.parent():(o=t.$(this).wrap('<div data-wrapper="true" style="overflow:hidden;height:0;position:relative;"></div>').parent(),o.attr("aria-expanded","false")),a=n.toggle.eq(i),o.data("toggle",a),o.data("content",e),a.data("wrapper",o),e.data("wrapper",o)}),this.element.trigger("update.uk.accordion",[this]),i&&this.options.showfirst&&this.toggleItem(this.toggle.eq(0).data("wrapper"),!1,!1)}}),t.accordion});

View File

@ -0,0 +1,340 @@
/*! UIkit 2.27.4 | http://www.getuikit.com | (c) 2014 YOOtheme | MIT License */
(function(addon) {
var component;
if (window.UIkit2) {
component = addon(UIkit2);
}
if (typeof define == 'function' && define.amd) {
define('uikit-autocomplete', ['uikit'], function(){
return component || addon(UIkit2);
});
}
})(function(UI){
"use strict";
var active;
UI.component('autocomplete', {
defaults: {
minLength: 3,
param: 'search',
method: 'post',
delay: 300,
loadingClass: 'uk-loading',
flipDropdown: false,
skipClass: 'uk-skip',
hoverClass: 'uk-active',
source: null,
renderer: null,
// template
template: '<ul class="uk-nav uk-nav-autocomplete uk-autocomplete-results">{{~items}}<li data-value="{{$item.value}}"><a>{{$item.value}}</a></li>{{/items}}</ul>'
},
visible : false,
value : null,
selected : null,
boot: function() {
// init code
UI.$html.on('focus.autocomplete.uikit', '[data-uk-autocomplete]', function(e) {
var ele = UI.$(this);
if (!ele.data('autocomplete')) {
UI.autocomplete(ele, UI.Utils.options(ele.attr('data-uk-autocomplete')));
}
});
// register outer click for autocompletes
UI.$html.on('click.autocomplete.uikit', function(e) {
if (active && e.target!=active.input[0]) active.hide();
});
},
init: function() {
var $this = this,
select = false,
trigger = UI.Utils.debounce(function(e) {
if (select) {
return (select = false);
}
$this.handle();
}, this.options.delay);
this.dropdown = this.find('.uk-dropdown');
this.template = this.find('script[type="text/autocomplete"]').html();
this.template = UI.Utils.template(this.template || this.options.template);
this.input = this.find("input:first").attr("autocomplete", "off");
if (!this.dropdown.length) {
this.dropdown = UI.$('<div class="uk-dropdown"></div>').appendTo(this.element);
}
if (this.options.flipDropdown) {
this.dropdown.addClass('uk-dropdown-flip');
}
this.dropdown.attr('aria-expanded', 'false');
this.input.on({
keydown: function(e) {
if (e && e.which && !e.shiftKey && $this.visible) {
switch (e.which) {
case 13: // enter
select = true;
if ($this.selected) {
e.preventDefault();
$this.select();
}
break;
case 38: // up
e.preventDefault();
$this.pick('prev', true);
break;
case 40: // down
e.preventDefault();
$this.pick('next', true);
break;
case 27:
case 9: // esc, tab
$this.hide();
break;
default:
break;
}
}
},
keyup: trigger
});
this.dropdown.on('click', '.uk-autocomplete-results > *', function(){
$this.select();
});
this.dropdown.on('mouseover', '.uk-autocomplete-results > *', function(){
$this.pick(UI.$(this));
});
this.triggercomplete = trigger;
},
handle: function() {
var $this = this, old = this.value;
this.value = this.input.val();
if (this.value.length < this.options.minLength) return this.hide();
if (this.value != old) {
$this.request();
}
return this;
},
pick: function(item, scrollinview) {
var $this = this,
items = UI.$(this.dropdown.find('.uk-autocomplete-results').children(':not(.'+this.options.skipClass+')')),
selected = false;
if (typeof item !== "string" && !item.hasClass(this.options.skipClass)) {
selected = item;
} else if (item == 'next' || item == 'prev') {
if (this.selected) {
var index = items.index(this.selected);
if (item == 'next') {
selected = items.eq(index + 1 < items.length ? index + 1 : 0);
} else {
selected = items.eq(index - 1 < 0 ? items.length - 1 : index - 1);
}
} else {
selected = items[(item == 'next') ? 'first' : 'last']();
}
selected = UI.$(selected);
}
if (selected && selected.length) {
this.selected = selected;
items.removeClass(this.options.hoverClass);
this.selected.addClass(this.options.hoverClass);
// jump to selected if not in view
if (scrollinview) {
var top = selected.position().top,
scrollTop = $this.dropdown.scrollTop(),
dpheight = $this.dropdown.height();
if (top > dpheight || top < 0) {
$this.dropdown.scrollTop(scrollTop + top);
}
}
}
},
select: function() {
if(!this.selected) return;
var data = this.selected.data();
this.trigger('selectitem.uk.autocomplete', [data, this]);
if (data.value) {
this.input.val(data.value).trigger('change');
}
this.hide();
},
show: function() {
if (this.visible) return;
this.visible = true;
this.element.addClass('uk-open');
if (active && active!==this) {
active.hide();
}
active = this;
// Update aria
this.dropdown.attr('aria-expanded', 'true');
return this;
},
hide: function() {
if (!this.visible) return;
this.visible = false;
this.element.removeClass('uk-open');
if (active === this) {
active = false;
}
// Update aria
this.dropdown.attr('aria-expanded', 'false');
return this;
},
request: function() {
var $this = this,
release = function(data) {
if(data) {
$this.render(data);
}
$this.element.removeClass($this.options.loadingClass);
};
this.element.addClass(this.options.loadingClass);
if (this.options.source) {
var source = this.options.source;
switch(typeof(this.options.source)) {
case 'function':
this.options.source.apply(this, [release]);
break;
case 'object':
if(source.length) {
var items = [];
source.forEach(function(item){
if(item.value && item.value.toLowerCase().indexOf($this.value.toLowerCase())!=-1) {
items.push(item);
}
});
release(items);
}
break;
case 'string':
var params ={};
params[this.options.param] = this.value;
UI.$.ajax({
url: this.options.source,
data: params,
type: this.options.method,
dataType: 'json'
}).done(function(json) {
release(json || []);
});
break;
default:
release(null);
}
} else {
this.element.removeClass($this.options.loadingClass);
}
},
render: function(data) {
this.dropdown.empty();
this.selected = false;
if (this.options.renderer) {
this.options.renderer.apply(this, [data]);
} else if(data && data.length) {
this.dropdown.append(this.template({items:data}));
this.show();
this.trigger('show.uk.autocomplete');
}
return this;
}
});
return UI.autocomplete;
});

View File

@ -0,0 +1,2 @@
/*! UIkit 2.27.4 | http://www.getuikit.com | (c) 2014 YOOtheme | MIT License */
!function(t){var e;window.UIkit2&&(e=t(UIkit2)),"function"==typeof define&&define.amd&&define("uikit-autocomplete",["uikit"],function(){return e||t(UIkit2)})}(function(t){"use strict";var e;return t.component("autocomplete",{defaults:{minLength:3,param:"search",method:"post",delay:300,loadingClass:"uk-loading",flipDropdown:!1,skipClass:"uk-skip",hoverClass:"uk-active",source:null,renderer:null,template:'<ul class="uk-nav uk-nav-autocomplete uk-autocomplete-results">{{~items}}<li data-value="{{$item.value}}"><a>{{$item.value}}</a></li>{{/items}}</ul>'},visible:!1,value:null,selected:null,boot:function(){t.$html.on("focus.autocomplete.uikit","[data-uk-autocomplete]",function(){var e=t.$(this);e.data("autocomplete")||t.autocomplete(e,t.Utils.options(e.attr("data-uk-autocomplete")))}),t.$html.on("click.autocomplete.uikit",function(t){e&&t.target!=e.input[0]&&e.hide()})},init:function(){var e=this,i=!1,s=t.Utils.debounce(function(){return i?i=!1:(e.handle(),void 0)},this.options.delay);this.dropdown=this.find(".uk-dropdown"),this.template=this.find('script[type="text/autocomplete"]').html(),this.template=t.Utils.template(this.template||this.options.template),this.input=this.find("input:first").attr("autocomplete","off"),this.dropdown.length||(this.dropdown=t.$('<div class="uk-dropdown"></div>').appendTo(this.element)),this.options.flipDropdown&&this.dropdown.addClass("uk-dropdown-flip"),this.dropdown.attr("aria-expanded","false"),this.input.on({keydown:function(t){if(t&&t.which&&!t.shiftKey&&e.visible)switch(t.which){case 13:i=!0,e.selected&&(t.preventDefault(),e.select());break;case 38:t.preventDefault(),e.pick("prev",!0);break;case 40:t.preventDefault(),e.pick("next",!0);break;case 27:case 9:e.hide()}},keyup:s}),this.dropdown.on("click",".uk-autocomplete-results > *",function(){e.select()}),this.dropdown.on("mouseover",".uk-autocomplete-results > *",function(){e.pick(t.$(this))}),this.triggercomplete=s},handle:function(){var t=this,e=this.value;return this.value=this.input.val(),this.value.length<this.options.minLength?this.hide():(this.value!=e&&t.request(),this)},pick:function(e,i){var s=this,o=t.$(this.dropdown.find(".uk-autocomplete-results").children(":not(."+this.options.skipClass+")")),n=!1;if("string"==typeof e||e.hasClass(this.options.skipClass)){if("next"==e||"prev"==e){if(this.selected){var a=o.index(this.selected);n="next"==e?o.eq(a+1<o.length?a+1:0):o.eq(0>a-1?o.length-1:a-1)}else n=o["next"==e?"first":"last"]();n=t.$(n)}}else n=e;if(n&&n.length&&(this.selected=n,o.removeClass(this.options.hoverClass),this.selected.addClass(this.options.hoverClass),i)){var l=n.position().top,h=s.dropdown.scrollTop(),r=s.dropdown.height();(l>r||0>l)&&s.dropdown.scrollTop(h+l)}},select:function(){if(this.selected){var t=this.selected.data();this.trigger("selectitem.uk.autocomplete",[t,this]),t.value&&this.input.val(t.value).trigger("change"),this.hide()}},show:function(){return this.visible?void 0:(this.visible=!0,this.element.addClass("uk-open"),e&&e!==this&&e.hide(),e=this,this.dropdown.attr("aria-expanded","true"),this)},hide:function(){return this.visible?(this.visible=!1,this.element.removeClass("uk-open"),e===this&&(e=!1),this.dropdown.attr("aria-expanded","false"),this):void 0},request:function(){var e=this,i=function(t){t&&e.render(t),e.element.removeClass(e.options.loadingClass)};if(this.element.addClass(this.options.loadingClass),this.options.source){var s=this.options.source;switch(typeof this.options.source){case"function":this.options.source.apply(this,[i]);break;case"object":if(s.length){var o=[];s.forEach(function(t){t.value&&-1!=t.value.toLowerCase().indexOf(e.value.toLowerCase())&&o.push(t)}),i(o)}break;case"string":var n={};n[this.options.param]=this.value,t.$.ajax({url:this.options.source,data:n,type:this.options.method,dataType:"json"}).done(function(t){i(t||[])});break;default:i(null)}}else this.element.removeClass(e.options.loadingClass)},render:function(t){return this.dropdown.empty(),this.selected=!1,this.options.renderer?this.options.renderer.apply(this,[t]):t&&t.length&&(this.dropdown.append(this.template({items:t})),this.show(),this.trigger("show.uk.autocomplete")),this}}),t.autocomplete});

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,67 @@
/*! UIkit 2.27.4 | http://www.getuikit.com | (c) 2014 YOOtheme | MIT License */
(function(addon) {
var component;
if (window.UIkit2) {
component = addon(UIkit2);
}
if (typeof define == 'function' && define.amd) {
define('uikit-form-password', ['uikit'], function(){
return component || addon(UIkit2);
});
}
})(function(UI){
"use strict";
UI.component('formPassword', {
defaults: {
lblShow: 'Show',
lblHide: 'Hide'
},
boot: function() {
// init code
UI.$html.on('click.formpassword.uikit', '[data-uk-form-password]', function(e) {
var ele = UI.$(this);
if (!ele.data('formPassword')) {
e.preventDefault();
UI.formPassword(ele, UI.Utils.options(ele.attr('data-uk-form-password')));
ele.trigger('click');
}
});
},
init: function() {
var $this = this;
this.on('click', function(e) {
e.preventDefault();
if($this.input.length) {
var type = $this.input.attr('type');
$this.input.attr('type', type=='text' ? 'password':'text');
$this.element.html($this.options[type=='text' ? 'lblShow':'lblHide']);
}
});
this.input = this.element.next('input').length ? this.element.next('input') : this.element.prev('input');
this.element.html(this.options[this.input.is('[type="password"]') ? 'lblShow':'lblHide']);
this.element.data('formPassword', this);
}
});
return UI.formPassword;
});

View File

@ -0,0 +1,2 @@
/*! UIkit 2.27.4 | http://www.getuikit.com | (c) 2014 YOOtheme | MIT License */
!function(t){var i;window.UIkit2&&(i=t(UIkit2)),"function"==typeof define&&define.amd&&define("uikit-form-password",["uikit"],function(){return i||t(UIkit2)})}(function(t){"use strict";return t.component("formPassword",{defaults:{lblShow:"Show",lblHide:"Hide"},boot:function(){t.$html.on("click.formpassword.uikit","[data-uk-form-password]",function(i){var e=t.$(this);e.data("formPassword")||(i.preventDefault(),t.formPassword(e,t.Utils.options(e.attr("data-uk-form-password"))),e.trigger("click"))})},init:function(){var t=this;this.on("click",function(i){if(i.preventDefault(),t.input.length){var e=t.input.attr("type");t.input.attr("type","text"==e?"password":"text"),t.element.html(t.options["text"==e?"lblShow":"lblHide"])}}),this.input=this.element.next("input").length?this.element.next("input"):this.element.prev("input"),this.element.html(this.options[this.input.is('[type="password"]')?"lblShow":"lblHide"]),this.element.data("formPassword",this)}}),t.formPassword});

View File

@ -0,0 +1,85 @@
/*! UIkit 2.27.4 | http://www.getuikit.com | (c) 2014 YOOtheme | MIT License */
(function(addon) {
var component;
if (window.UIkit2) {
component = addon(UIkit2);
}
if (typeof define == 'function' && define.amd) {
define('uikit-form-select', ['uikit'], function(){
return component || addon(UIkit2);
});
}
})(function(UI){
"use strict";
UI.component('formSelect', {
defaults: {
target: '>span:first',
activeClass: 'uk-active'
},
boot: function() {
// init code
UI.ready(function(context) {
UI.$('[data-uk-form-select]', context).each(function(){
var ele = UI.$(this);
if (!ele.data('formSelect')) {
UI.formSelect(ele, UI.Utils.options(ele.attr('data-uk-form-select')));
}
});
});
},
init: function() {
var $this = this;
this.target = this.find(this.options.target);
this.select = this.find('select');
// init + on change event
this.select.on({
change: (function(){
var select = $this.select[0], fn = function(){
try {
if($this.options.target === 'input') {
$this.target.val(select.options[select.selectedIndex].text);
} else {
$this.target.text(select.options[select.selectedIndex].text);
}
} catch(e) {}
$this.element[$this.select.val() ? 'addClass':'removeClass']($this.options.activeClass);
return fn;
};
return fn();
})(),
focus: function(){ $this.target.addClass('uk-focus') },
blur: function(){ $this.target.removeClass('uk-focus') },
mouseenter: function(){ $this.target.addClass('uk-hover') },
mouseleave: function(){ $this.target.removeClass('uk-hover') }
});
this.element.data("formSelect", this);
}
});
return UI.formSelect;
});

View File

@ -0,0 +1,2 @@
/*! UIkit 2.27.4 | http://www.getuikit.com | (c) 2014 YOOtheme | MIT License */
!function(t){var e;window.UIkit2&&(e=t(UIkit2)),"function"==typeof define&&define.amd&&define("uikit-form-select",["uikit"],function(){return e||t(UIkit2)})}(function(t){"use strict";return t.component("formSelect",{defaults:{target:">span:first",activeClass:"uk-active"},boot:function(){t.ready(function(e){t.$("[data-uk-form-select]",e).each(function(){var e=t.$(this);e.data("formSelect")||t.formSelect(e,t.Utils.options(e.attr("data-uk-form-select")))})})},init:function(){var t=this;this.target=this.find(this.options.target),this.select=this.find("select"),this.select.on({change:function(){var e=t.select[0],n=function(){try{"input"===t.options.target?t.target.val(e.options[e.selectedIndex].text):t.target.text(e.options[e.selectedIndex].text)}catch(s){}return t.element[t.select.val()?"addClass":"removeClass"](t.options.activeClass),n};return n()}(),focus:function(){t.target.addClass("uk-focus")},blur:function(){t.target.removeClass("uk-focus")},mouseenter:function(){t.target.addClass("uk-hover")},mouseleave:function(){t.target.removeClass("uk-hover")}}),this.element.data("formSelect",this)}}),t.formSelect});

View File

@ -0,0 +1,168 @@
/*! UIkit 2.27.4 | http://www.getuikit.com | (c) 2014 YOOtheme | MIT License */
(function(addon) {
var component;
if (window.UIkit2) {
component = addon(UIkit2);
}
if (typeof define == 'function' && define.amd) {
define('uikit-grid-parallax', ['uikit'], function(){
return component || addon(UIkit2);
});
}
})(function(UI){
var parallaxes = [], checkParallaxes = function() {
requestAnimationFrame(function(){
for (var i=0; i < parallaxes.length; i++) {
parallaxes[i].process();
}
});
};
UI.component('gridparallax', {
defaults: {
target : false,
smooth : 150,
translate : 150
},
boot: function() {
// listen to scroll and resize
UI.$doc.on('scrolling.uk.document', checkParallaxes);
UI.$win.on('load resize orientationchange', UI.Utils.debounce(function(){
checkParallaxes();
}, 50));
// init code
UI.ready(function(context) {
UI.$('[data-uk-grid-parallax]', context).each(function() {
var parallax = UI.$(this);
if (!parallax.data('gridparallax')) {
UI.gridparallax(parallax, UI.Utils.options(parallax.attr('data-uk-grid-parallax')));
}
});
});
},
init: function() {
var $this = this;
this.initItems().process();
parallaxes.push(this);
UI.$win.on('load resize orientationchange', (function() {
var fn = function() {
var columns = getcolumns($this.element);
$this.element.css('margin-bottom', '');
if (columns > 1) {
$this.element.css('margin-bottom', $this.options.translate + parseInt($this.element.css('margin-bottom')));
}
};
UI.$(function() { fn(); });
return UI.Utils.debounce(fn, 50);
})());
},
initItems: function() {
var smooth = this.options.smooth;
this.items = (this.options.target ? this.element.find(this.options.target) : this.element.children()).each(function(){
UI.$(this).css({
transition: 'transform '+smooth+'ms linear',
transform: ''
});
});
return this;
},
process: function() {
var percent = percentageInViewport(this.element),
columns = getcolumns(this.element),
items = this.items,
mods = [(columns-1)];
if (columns == 1 || !percent) {
items.css('transform', '');
return;
}
while(mods.length < columns) {
if (!(mods[mods.length-1] - 2)) break;
mods.push(mods[mods.length-1] - 2);
}
var translate = this.options.translate, percenttranslate = percent * translate;
items.each(function(idx, ele, translate){
translate = mods.indexOf((idx+1) % columns) != -1 ? percenttranslate : percenttranslate / 8;
UI.$(this).css('transform', 'translate3d(0,'+(translate)+'px, 0)');
});
}
});
function getcolumns(element) {
var children = element.children(),
first = children.filter(':visible:first'),
top = first[0].offsetTop + first.outerHeight();
for (var column=0;column<children.length;column++) {
if (children[column].offsetTop >= top) break;
}
return column || 1;
}
function percentageInViewport(element) {
var top = element.offset().top,
height = element.outerHeight(),
scrolltop = UI.$win.scrollTop(),
wh = window.innerHeight,
distance, percentage, percent;
if (top > (scrolltop + wh)) {
percent = 0;
} else if ((top + height) < scrolltop) {
percent = 1;
} else {
if ((top + height) < wh) {
percent = (scrolltop < wh ? scrolltop : scrolltop - wh) / (top+height);
} else {
distance = (scrolltop + wh) - top;
percentage = Math.round(distance / ((wh + height) / 100));
percent = percentage/100;
}
if (top < wh) {
percent = percent * scrolltop / ((top + height) - wh);
}
}
return percent > 1 ? 1:percent;
}
});

View File

@ -0,0 +1,2 @@
/*! UIkit 2.27.4 | http://www.getuikit.com | (c) 2014 YOOtheme | MIT License */
!function(t){var n;window.UIkit2&&(n=t(UIkit2)),"function"==typeof define&&define.amd&&define("uikit-grid-parallax",["uikit"],function(){return n||t(UIkit2)})}(function(t){function n(t){for(var n=t.children(),i=n.filter(":visible:first"),e=i[0].offsetTop+i.outerHeight(),o=0;o<n.length&&!(n[o].offsetTop>=e);o++);return o||1}function i(n){var i,e,o,r=n.offset().top,s=n.outerHeight(),a=t.$win.scrollTop(),l=window.innerHeight;return r>a+l?o=0:a>r+s?o=1:(l>r+s?o=(l>a?a:a-l)/(r+s):(i=a+l-r,e=Math.round(i/((l+s)/100)),o=e/100),l>r&&(o=o*a/(r+s-l))),o>1?1:o}var e=[],o=function(){requestAnimationFrame(function(){for(var t=0;t<e.length;t++)e[t].process()})};t.component("gridparallax",{defaults:{target:!1,smooth:150,translate:150},boot:function(){t.$doc.on("scrolling.uk.document",o),t.$win.on("load resize orientationchange",t.Utils.debounce(function(){o()},50)),t.ready(function(n){t.$("[data-uk-grid-parallax]",n).each(function(){var n=t.$(this);n.data("gridparallax")||t.gridparallax(n,t.Utils.options(n.attr("data-uk-grid-parallax")))})})},init:function(){var i=this;this.initItems().process(),e.push(this),t.$win.on("load resize orientationchange",function(){var e=function(){var t=n(i.element);i.element.css("margin-bottom",""),t>1&&i.element.css("margin-bottom",i.options.translate+parseInt(i.element.css("margin-bottom")))};return t.$(function(){e()}),t.Utils.debounce(e,50)}())},initItems:function(){var n=this.options.smooth;return this.items=(this.options.target?this.element.find(this.options.target):this.element.children()).each(function(){t.$(this).css({transition:"transform "+n+"ms linear",transform:""})}),this},process:function(){var e=i(this.element),o=n(this.element),r=this.items,s=[o-1];if(1==o||!e)return r.css("transform",""),void 0;for(;s.length<o&&s[s.length-1]-2;)s.push(s[s.length-1]-2);var a=this.options.translate,l=e*a;r.each(function(n,i,e){e=-1!=s.indexOf((n+1)%o)?l:l/8,t.$(this).css("transform","translate3d(0,"+e+"px, 0)")})}})});

View File

@ -0,0 +1,540 @@
/*! UIkit 2.27.4 | http://www.getuikit.com | (c) 2014 YOOtheme | MIT License */
(function(addon) {
var component;
if (window.UIkit2) {
component = addon(UIkit2);
}
if (typeof define == 'function' && define.amd) {
define('uikit-grid', ['uikit'], function(){
return component || addon(UIkit2);
});
}
})(function(UI){
"use strict";
UI.component('grid', {
defaults: {
colwidth : 'auto',
animation : true,
duration : 300,
gutter : 0,
controls : false,
filter : false,
origin : UI.langdirection
},
boot: function() {
// init code
UI.ready(function(context) {
UI.$('[data-uk-grid]', context).each(function(){
var ele = UI.$(this);
if(!ele.data('grid')) {
UI.grid(ele, UI.Utils.options(ele.attr('data-uk-grid')));
}
});
});
},
init: function() {
var $this = this, gutter = String(this.options.gutter).trim().split(' ');
this.gutterv = parseInt(gutter[0], 10);
this.gutterh = parseInt((gutter[1] || gutter[0]), 10);
// make sure parent element has the right position property
this.element.css({'position': 'relative'});
this.controls = null;
this.origin = this.options.origin;
if (this.options.controls) {
this.controls = UI.$(this.options.controls);
// filter
this.controls.on('click', '[data-uk-filter]', function(e){
e.preventDefault();
$this.filter(UI.$(this).attr('data-uk-filter'));
});
// sort
this.controls.on('click', '[data-uk-sort]', function(e){
e.preventDefault();
var cmd = UI.$(this).attr('data-uk-sort').split(':');
$this.sort(cmd[0], cmd[1]);
});
}
UI.$win.on('load resize orientationchange', UI.Utils.debounce(function(){
if ($this.currentfilter) {
$this.filter($this.currentfilter);
} else {
this.update();
}
}.bind(this), 100));
this.on('display.uk.check', function(){
if ($this.element.is(':visible')) $this.update();
});
UI.domObserve(this.element, function(e) {
$this.update();
});
if (this.options.filter !== false) {
this.filter(this.options.filter);
} else {
this.update();
}
},
_prepareElements: function() {
var children = this.element.children(':not([data-grid-prepared])'), css;
// exit if no already prepared elements found
if (!children.length) {
return;
}
css = {
position : 'absolute',
boxSizing : 'border-box',
width : this.options.colwidth == 'auto' ? '' : this.options.colwidth
};
if (this.options.gutter) {
css['padding-'+this.origin] = this.gutterh;
css['padding-bottom'] = this.gutterv;
this.element.css('margin-'+this.origin, this.gutterh * -1);
}
children.attr('data-grid-prepared', 'true').css(css);
},
update: function(elements) {
var $this = this;
this._prepareElements();
elements = elements || this.element.children(':visible');
var children = elements,
maxwidth = this.element.width() + (2*this.gutterh) + 2,
left = 0,
top = 0,
positions = [],
item, width, height, pos, posi, i, z, max, size;
this.trigger('beforeupdate.uk.grid', [children]);
children.each(function(index){
size = getElementSize(this);
item = UI.$(this);
width = size.outerWidth;
height = size.outerHeight;
left = 0;
top = 0;
for (i=0,max=positions.length;i<max;i++) {
pos = positions[i];
if (left <= pos.aX) { left = pos.aX; }
if (maxwidth < (left + width)) { left = 0; }
if (top <= pos.aY) { top = pos.aY; }
}
posi = {
ele : item,
top : top,
width : width,
height : height,
aY : (top + height),
aX : (left + width)
};
posi[$this.origin] = left;
positions.push(posi);
});
var posPrev, maxHeight = 0, positionto;
// fix top
for (i=0,max=positions.length;i<max;i++) {
pos = positions[i];
top = 0;
for (z=0;z<i;z++) {
posPrev = positions[z];
// (posPrev.left + 1) fixex 1px bug when using % based widths
if (pos[this.origin] < posPrev.aX && (posPrev[this.origin] +1) < pos.aX) {
top = posPrev.aY;
}
}
pos.top = top;
pos.aY = top + pos.height;
maxHeight = Math.max(maxHeight, pos.aY);
}
maxHeight = maxHeight - this.gutterv;
if (this.options.animation) {
this.element.stop().animate({'height': maxHeight}, 100);
positions.forEach(function(pos){
positionto = {"top": pos.top, opacity: 1};
positionto[$this.origin] = pos[$this.origin];
pos.ele.stop().animate(positionto, this.options.duration);
}.bind(this));
} else {
this.element.css('height', maxHeight);
positions.forEach(function(pos){
positionto = {"top": pos.top, opacity: 1};
positionto[$this.origin] = pos[$this.origin];
pos.ele.css(positionto);
}.bind(this));
}
// make sure to trigger possible scrollpies etc.
setTimeout(function() {
UI.$doc.trigger('scrolling.uk.document');
}, 2 * this.options.duration * (this.options.animation ? 1:0));
this.trigger('afterupdate.uk.grid', [children]);
},
filter: function(filter) {
this.currentfilter = filter;
filter = filter || [];
if (typeof(filter) === 'number') {
filter = filter.toString();
}
if (typeof(filter) === 'string') {
filter = filter.split(/,/).map(function(item){ return item.trim(); });
}
var $this = this, children = this.element.children(), elements = {"visible": [], "hidden": []}, visible, hidden;
children.each(function(index){
var ele = UI.$(this), f = ele.attr('data-uk-filter'), infilter = filter.length ? false : true;
if (f) {
f = f.split(/,/).map(function(item){ return item.trim(); });
filter.forEach(function(item){
if (f.indexOf(item) > -1) infilter = true;
});
}
elements[infilter ? "visible":"hidden"].push(ele);
});
// convert to jQuery collections
elements.hidden = UI.$(elements.hidden).map(function () {return this[0];});
elements.visible = UI.$(elements.visible).map(function () {return this[0];});
elements.hidden.attr('aria-hidden', 'true').filter(':visible').fadeOut(this.options.duration);
elements.visible.attr('aria-hidden', 'false').filter(':hidden').css('opacity', 0).show();
$this.update(elements.visible);
if (this.controls && this.controls.length) {
this.controls.find('[data-uk-filter]').removeClass('uk-active').filter('[data-uk-filter="'+filter+'"]').addClass('uk-active');
}
},
sort: function(by, order){
order = order || 1;
// covert from string (asc|desc) to number
if (typeof(order) === 'string') {
order = order.toLowerCase() == 'desc' ? -1 : 1;
}
var elements = this.element.children();
elements.sort(function(a, b){
a = UI.$(a);
b = UI.$(b);
return (b.data(by) || '') < (a.data(by) || '') ? order : (order*-1);
}).appendTo(this.element);
this.update(elements.filter(':visible'));
if (this.controls && this.controls.length) {
this.controls.find('[data-uk-sort]').removeClass('uk-active').filter('[data-uk-sort="'+by+':'+(order == -1 ? 'desc':'asc')+'"]').addClass('uk-active');
}
}
});
/*!
* getSize v1.2.2
* measure size of elements
* MIT license
* https://github.com/desandro/get-size
*/
function _getSize() {
var prefixes = 'Webkit Moz ms Ms O'.split(' ');
var docElemStyle = document.documentElement.style;
function getStyleProperty( propName ) {
if ( !propName ) {
return;
}
// test standard property first
if ( typeof docElemStyle[ propName ] === 'string' ) {
return propName;
}
// capitalize
propName = propName.charAt(0).toUpperCase() + propName.slice(1);
// test vendor specific properties
var prefixed;
for ( var i=0, len = prefixes.length; i < len; i++ ) {
prefixed = prefixes[i] + propName;
if ( typeof docElemStyle[ prefixed ] === 'string' ) {
return prefixed;
}
}
}
// -------------------------- helpers -------------------------- //
// get a number from a string, not a percentage
function getStyleSize( value ) {
var num = parseFloat( value );
// not a percent like '100%', and a number
var isValid = value.indexOf('%') === -1 && !isNaN( num );
return isValid && num;
}
function noop() {}
var logError = typeof console === 'undefined' ? noop : function( message ) {
console.error( message );
};
// -------------------------- measurements -------------------------- //
var measurements = [
'paddingLeft',
'paddingRight',
'paddingTop',
'paddingBottom',
'marginLeft',
'marginRight',
'marginTop',
'marginBottom',
'borderLeftWidth',
'borderRightWidth',
'borderTopWidth',
'borderBottomWidth'
];
function getZeroSize() {
var size = {
width: 0,
height: 0,
innerWidth: 0,
innerHeight: 0,
outerWidth: 0,
outerHeight: 0
};
for ( var i=0, len = measurements.length; i < len; i++ ) {
var measurement = measurements[i];
size[ measurement ] = 0;
}
return size;
}
// -------------------------- setup -------------------------- //
var isSetup = false;
var getStyle, boxSizingProp, isBoxSizeOuter;
/**
* setup vars and functions
* do it on initial getSize(), rather than on script load
* For Firefox bug https://bugzilla.mozilla.org/show_bug.cgi?id=548397
*/
function setup() {
// setup once
if ( isSetup ) {
return;
}
isSetup = true;
var getComputedStyle = window.getComputedStyle;
getStyle = ( function() {
var getStyleFn = getComputedStyle ?
function( elem ) {
return getComputedStyle( elem, null );
} :
function( elem ) {
return elem.currentStyle;
};
return function getStyle( elem ) {
var style = getStyleFn( elem );
if ( !style ) {
logError( 'Style returned ' + style +
'. Are you running this code in a hidden iframe on Firefox? ' +
'See http://bit.ly/getsizebug1' );
}
return style;
};
})();
// -------------------------- box sizing -------------------------- //
boxSizingProp = getStyleProperty('boxSizing');
/**
* WebKit measures the outer-width on style.width on border-box elems
* IE & Firefox measures the inner-width
*/
if ( boxSizingProp ) {
var div = document.createElement('div');
div.style.width = '200px';
div.style.padding = '1px 2px 3px 4px';
div.style.borderStyle = 'solid';
div.style.borderWidth = '1px 2px 3px 4px';
div.style[ boxSizingProp ] = 'border-box';
var body = document.body || document.documentElement;
body.appendChild( div );
var style = getStyle( div );
isBoxSizeOuter = getStyleSize( style.width ) === 200;
body.removeChild( div );
}
}
// -------------------------- getSize -------------------------- //
function getSize( elem ) {
setup();
// use querySeletor if elem is string
if ( typeof elem === 'string' ) {
elem = document.querySelector( elem );
}
// do not proceed on non-objects
if ( !elem || typeof elem !== 'object' || !elem.nodeType ) {
return;
}
var style = getStyle( elem );
// if hidden, everything is 0
if ( style.display === 'none' ) {
return getZeroSize();
}
var size = {};
size.width = elem.offsetWidth;
size.height = elem.offsetHeight;
var isBorderBox = size.isBorderBox = !!( boxSizingProp &&
style[ boxSizingProp ] && style[ boxSizingProp ] === 'border-box' );
// get all measurements
for ( var i=0, len = measurements.length; i < len; i++ ) {
var measurement = measurements[i];
var value = style[ measurement ];
var num = parseFloat( value );
// any 'auto', 'medium' value will be 0
size[ measurement ] = !isNaN( num ) ? num : 0;
}
var paddingWidth = size.paddingLeft + size.paddingRight;
var paddingHeight = size.paddingTop + size.paddingBottom;
var marginWidth = size.marginLeft + size.marginRight;
var marginHeight = size.marginTop + size.marginBottom;
var borderWidth = size.borderLeftWidth + size.borderRightWidth;
var borderHeight = size.borderTopWidth + size.borderBottomWidth;
var isBorderBoxSizeOuter = isBorderBox && isBoxSizeOuter;
// overwrite width and height if we can get it from style
var styleWidth = getStyleSize( style.width );
if ( styleWidth !== false ) {
size.width = styleWidth +
// add padding and border unless it's already including it
( isBorderBoxSizeOuter ? 0 : paddingWidth + borderWidth );
}
var styleHeight = getStyleSize( style.height );
if ( styleHeight !== false ) {
size.height = styleHeight +
// add padding and border unless it's already including it
( isBorderBoxSizeOuter ? 0 : paddingHeight + borderHeight );
}
size.innerWidth = size.width - ( paddingWidth + borderWidth );
size.innerHeight = size.height - ( paddingHeight + borderHeight );
size.outerWidth = size.width + marginWidth;
size.outerHeight = size.height + marginHeight;
return size;
}
return getSize;
}
function getElementSize(ele) {
return _getSize()(ele);
}
});

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,679 @@
/*! UIkit 2.27.4 | http://www.getuikit.com | (c) 2014 YOOtheme | MIT License */
(function(addon) {
var component;
if (window.UIkit2) {
component = addon(UIkit2);
}
if (typeof define == 'function' && define.amd) {
define('uikit-htmleditor', ['uikit'], function(){
return component || addon(UIkit2);
});
}
})(function(UI) {
"use strict";
var editors = [];
UI.component('htmleditor', {
defaults: {
iframe : false,
mode : 'split',
markdown : false,
autocomplete : true,
enablescripts: false,
height : 500,
maxsplitsize : 1000,
codemirror : { mode: 'htmlmixed', lineWrapping: true, dragDrop: false, autoCloseTags: true, matchTags: true, autoCloseBrackets: true, matchBrackets: true, indentUnit: 4, indentWithTabs: false, tabSize: 4, hintOptions: {completionSingle:false} },
toolbar : [ 'bold', 'italic', 'strike', 'link', 'image', 'blockquote', 'listUl', 'listOl' ],
lblPreview : 'Preview',
lblCodeview : 'HTML',
lblMarkedview: 'Markdown'
},
boot: function() {
// init code
UI.ready(function(context) {
UI.$('textarea[data-uk-htmleditor]', context).each(function() {
var editor = UI.$(this);
if (!editor.data('htmleditor')) {
UI.htmleditor(editor, UI.Utils.options(editor.attr('data-uk-htmleditor')));
}
});
});
},
init: function() {
var $this = this, tpl = UI.components.htmleditor.template;
this.CodeMirror = this.options.CodeMirror || CodeMirror;
this.buttons = {};
tpl = tpl.replace(/\{:lblPreview}/g, this.options.lblPreview);
tpl = tpl.replace(/\{:lblCodeview}/g, this.options.lblCodeview);
this.htmleditor = UI.$(tpl);
this.content = this.htmleditor.find('.uk-htmleditor-content');
this.toolbar = this.htmleditor.find('.uk-htmleditor-toolbar');
this.preview = this.htmleditor.find('.uk-htmleditor-preview').children().eq(0);
this.code = this.htmleditor.find('.uk-htmleditor-code');
this.element.before(this.htmleditor).appendTo(this.code);
this.editor = this.CodeMirror.fromTextArea(this.element[0], this.options.codemirror);
this.editor.htmleditor = this;
this.editor.on('change', UI.Utils.debounce(function() { $this.render(); }, 150));
this.editor.on('change', function() {
$this.editor.save();
$this.element.trigger('input');
});
this.code.find('.CodeMirror').css('height', this.options.height);
// iframe mode?
if (this.options.iframe) {
this.iframe = UI.$('<iframe class="uk-htmleditor-iframe" frameborder="0" scrolling="auto" height="100" width="100%"></iframe>');
this.preview.append(this.iframe);
// must open and close document object to start using it!
this.iframe[0].contentWindow.document.open();
this.iframe[0].contentWindow.document.close();
this.preview.container = UI.$(this.iframe[0].contentWindow.document).find('body');
// append custom stylesheet
if (typeof(this.options.iframe) === 'string') {
this.preview.container.parent().append('<link rel="stylesheet" href="'+this.options.iframe+'">');
}
} else {
this.preview.container = this.preview;
}
UI.$win.on('resize load', UI.Utils.debounce(function() { $this.fit(); }, 200));
var previewContainer = this.iframe ? this.preview.container:$this.preview.parent(),
codeContent = this.code.find('.CodeMirror-sizer'),
codeScroll = this.code.find('.CodeMirror-scroll').on('scroll', UI.Utils.debounce(function() {
if ($this.htmleditor.attr('data-mode') == 'tab') return;
// calc position
var codeHeight = codeContent.height() - codeScroll.height(),
previewHeight = previewContainer[0].scrollHeight - ($this.iframe ? $this.iframe.height() : previewContainer.height()),
ratio = previewHeight / codeHeight,
previewPosition = codeScroll.scrollTop() * ratio;
// apply new scroll
previewContainer.scrollTop(previewPosition);
}, 10));
this.htmleditor.on('click', '.uk-htmleditor-button-code, .uk-htmleditor-button-preview', function(e) {
e.preventDefault();
if ($this.htmleditor.attr('data-mode') == 'tab') {
$this.htmleditor.find('.uk-htmleditor-button-code, .uk-htmleditor-button-preview').removeClass('uk-active').filter(this).addClass('uk-active');
$this.activetab = UI.$(this).hasClass('uk-htmleditor-button-code') ? 'code' : 'preview';
$this.htmleditor.attr('data-active-tab', $this.activetab);
$this.editor.refresh();
}
});
// toolbar actions
this.htmleditor.on('click', 'a[data-htmleditor-button]', function() {
if (!$this.code.is(':visible')) return;
$this.trigger('action.' + UI.$(this).data('htmleditor-button'), [$this.editor]);
});
this.preview.parent().css('height', this.code.height());
// autocomplete
if (this.options.autocomplete && this.CodeMirror.showHint && this.CodeMirror.hint && this.CodeMirror.hint.html) {
this.editor.on('inputRead', UI.Utils.debounce(function() {
var doc = $this.editor.getDoc(), POS = doc.getCursor(), mode = $this.CodeMirror.innerMode($this.editor.getMode(), $this.editor.getTokenAt(POS).state).mode.name;
if (mode == 'xml') { //html depends on xml
var cur = $this.editor.getCursor(), token = $this.editor.getTokenAt(cur);
if (token.string.charAt(0) == '<' || token.type == 'attribute') {
$this.CodeMirror.showHint($this.editor, $this.CodeMirror.hint.html, { completeSingle: false });
}
}
}, 100));
}
this.debouncedRedraw = UI.Utils.debounce(function () { $this.redraw(); }, 5);
this.on('init.uk.component', function() {
$this.debouncedRedraw();
});
this.element.attr('data-uk-check-display', 1).on('display.uk.check', function(e) {
if (this.htmleditor.is(":visible")) this.fit();
}.bind(this));
editors.push(this);
},
addButton: function(name, button) {
this.buttons[name] = button;
},
addButtons: function(buttons) {
UI.$.extend(this.buttons, buttons);
},
replaceInPreview: function(regexp, callback) {
var editor = this.editor, results = [], value = editor.getValue(), offset = -1, index = 0;
this.currentvalue = this.currentvalue.replace(regexp, function() {
offset = value.indexOf(arguments[0], ++offset);
var match = {
matches: arguments,
from : translateOffset(offset),
to : translateOffset(offset + arguments[0].length),
replace: function(value) {
editor.replaceRange(value, match.from, match.to);
},
inRange: function(cursor) {
if (cursor.line === match.from.line && cursor.line === match.to.line) {
return cursor.ch >= match.from.ch && cursor.ch < match.to.ch;
}
return (cursor.line === match.from.line && cursor.ch >= match.from.ch) ||
(cursor.line > match.from.line && cursor.line < match.to.line) ||
(cursor.line === match.to.line && cursor.ch < match.to.ch);
}
};
var result = typeof(callback) === 'string' ? callback : callback(match, index);
if (!result && result !== '') {
return arguments[0];
}
index++;
results.push(match);
return result;
});
function translateOffset(offset) {
var result = editor.getValue().substring(0, offset).split('\n');
return { line: result.length - 1, ch: result[result.length - 1].length }
}
return results;
},
_buildtoolbar: function() {
if (!(this.options.toolbar && this.options.toolbar.length)) return;
var $this = this, bar = [];
this.toolbar.empty();
this.options.toolbar.forEach(function(button) {
if (!$this.buttons[button]) return;
var title = $this.buttons[button].title ? $this.buttons[button].title : button;
bar.push('<li><a data-htmleditor-button="'+button+'" title="'+title+'" data-uk-tooltip>'+$this.buttons[button].label+'</a></li>');
});
this.toolbar.html(bar.join('\n'));
},
fit: function() {
var mode = this.options.mode;
if (mode == 'split' && this.htmleditor.width() < this.options.maxsplitsize) {
mode = 'tab';
}
if (mode == 'tab') {
if (!this.activetab) {
this.activetab = 'code';
this.htmleditor.attr('data-active-tab', this.activetab);
}
this.htmleditor.find('.uk-htmleditor-button-code, .uk-htmleditor-button-preview').removeClass('uk-active')
.filter(this.activetab == 'code' ? '.uk-htmleditor-button-code' : '.uk-htmleditor-button-preview')
.addClass('uk-active');
}
this.editor.refresh();
this.preview.parent().css('height', this.code.height());
this.htmleditor.attr('data-mode', mode);
},
redraw: function() {
this._buildtoolbar();
this.render();
this.fit();
},
getMode: function() {
return this.editor.getOption('mode');
},
getCursorMode: function() {
var param = { mode: 'html'};
this.trigger('cursorMode', [param]);
return param.mode;
},
render: function() {
this.currentvalue = this.editor.getValue();
if (!this.options.enablescripts) {
this.currentvalue = this.currentvalue.replace(/<(script|style)\b[^<]*(?:(?!<\/(script|style)>)<[^<]*)*<\/(script|style)>/img, '');
}
// empty code
if (!this.currentvalue) {
this.element.val('');
this.preview.container.html('');
return;
}
this.trigger('render', [this]);
this.trigger('renderLate', [this]);
this.preview.container.html(this.currentvalue);
},
addShortcut: function(name, callback) {
var map = {};
if (!UI.$.isArray(name)) {
name = [name];
}
name.forEach(function(key) {
map[key] = callback;
});
this.editor.addKeyMap(map);
return map;
},
addShortcutAction: function(action, shortcuts) {
var editor = this;
this.addShortcut(shortcuts, function() {
editor.element.trigger('action.' + action, [editor.editor]);
});
},
replaceSelection: function(replace) {
var text = this.editor.getSelection();
if (!text.length) {
var cur = this.editor.getCursor(),
curLine = this.editor.getLine(cur.line),
start = cur.ch,
end = start;
while (end < curLine.length && /[\w$]+/.test(curLine.charAt(end))) ++end;
while (start && /[\w$]+/.test(curLine.charAt(start - 1))) --start;
var curWord = start != end && curLine.slice(start, end);
if (curWord) {
this.editor.setSelection({ line: cur.line, ch: start}, { line: cur.line, ch: end });
text = curWord;
}
}
var html = replace.replace('$1', text);
this.editor.replaceSelection(html, 'end');
this.editor.focus();
},
replaceLine: function(replace) {
var pos = this.editor.getDoc().getCursor(),
text = this.editor.getLine(pos.line),
html = replace.replace('$1', text);
this.editor.replaceRange(html , { line: pos.line, ch: 0 }, { line: pos.line, ch: text.length });
this.editor.setCursor({ line: pos.line, ch: html.length });
this.editor.focus();
},
save: function() {
this.editor.save();
}
});
UI.components.htmleditor.template = [
'<div class="uk-htmleditor uk-clearfix" data-mode="split">',
'<div class="uk-htmleditor-navbar">',
'<ul class="uk-htmleditor-navbar-nav uk-htmleditor-toolbar"></ul>',
'<div class="uk-htmleditor-navbar-flip">',
'<ul class="uk-htmleditor-navbar-nav">',
'<li class="uk-htmleditor-button-code"><a>{:lblCodeview}</a></li>',
'<li class="uk-htmleditor-button-preview"><a>{:lblPreview}</a></li>',
'<li><a data-htmleditor-button="fullscreen"><i class="uk-icon-expand"></i></a></li>',
'</ul>',
'</div>',
'</div>',
'<div class="uk-htmleditor-content">',
'<div class="uk-htmleditor-code"></div>',
'<div class="uk-htmleditor-preview"><div></div></div>',
'</div>',
'</div>'
].join('');
UI.plugin('htmleditor', 'base', {
init: function(editor) {
editor.addButtons({
fullscreen: {
title : 'Fullscreen',
label : '<i class="uk-icon-expand"></i>'
},
bold : {
title : 'Bold',
label : '<i class="uk-icon-bold"></i>'
},
italic : {
title : 'Italic',
label : '<i class="uk-icon-italic"></i>'
},
strike : {
title : 'Strikethrough',
label : '<i class="uk-icon-strikethrough"></i>'
},
blockquote : {
title : 'Blockquote',
label : '<i class="uk-icon-quote-right"></i>'
},
link : {
title : 'Link',
label : '<i class="uk-icon-link"></i>'
},
image : {
title : 'Image',
label : '<i class="uk-icon-picture-o"></i>'
},
listUl : {
title : 'Unordered List',
label : '<i class="uk-icon-list-ul"></i>'
},
listOl : {
title : 'Ordered List',
label : '<i class="uk-icon-list-ol"></i>'
}
});
addAction('bold', '<strong>$1</strong>');
addAction('italic', '<em>$1</em>');
addAction('strike', '<del>$1</del>');
addAction('blockquote', '<blockquote><p>$1</p></blockquote>', 'replaceLine');
addAction('link', '<a href="http://">$1</a>');
addAction('image', '<img src="http://" alt="$1">');
var listfn = function(tag) {
if (editor.getCursorMode() == 'html') {
tag = tag || 'ul';
var cm = editor.editor,
doc = cm.getDoc(),
pos = doc.getCursor(true),
posend = doc.getCursor(false),
im = CodeMirror.innerMode(cm.getMode(), cm.getTokenAt(cm.getCursor()).state),
inList = im && im.state && im.state.context && ['ul','ol'].indexOf(im.state.context.tagName) != -1;
for (var i=pos.line; i<(posend.line+1);i++) {
cm.replaceRange('<li>'+cm.getLine(i)+'</li>', { line: i, ch: 0 }, { line: i, ch: cm.getLine(i).length });
}
if (!inList) {
cm.replaceRange('<'+tag+'>'+"\n"+cm.getLine(pos.line), { line: pos.line, ch: 0 }, { line: pos.line, ch: cm.getLine(pos.line).length });
cm.replaceRange(cm.getLine((posend.line+1))+"\n"+'</'+tag+'>', { line: (posend.line+1), ch: 0 }, { line: (posend.line+1), ch: cm.getLine((posend.line+1)).length });
cm.setCursor({ line: posend.line+1, ch: cm.getLine(posend.line+1).length });
} else {
cm.setCursor({ line: posend.line, ch: cm.getLine(posend.line).length });
}
cm.focus();
}
};
editor.on('action.listUl', function() {
listfn('ul');
});
editor.on('action.listOl', function() {
listfn('ol');
});
editor.htmleditor.on('click', 'a[data-htmleditor-button="fullscreen"]', function() {
editor.htmleditor.toggleClass('uk-htmleditor-fullscreen');
var wrap = editor.editor.getWrapperElement();
if (editor.htmleditor.hasClass('uk-htmleditor-fullscreen')) {
var fixedParent = false, parents = editor.htmleditor.parents().each(function(){
if (UI.$(this).css('position')=='fixed' && !UI.$(this).is('html')) {
fixedParent = UI.$(this);
}
});
editor.htmleditor.data('fixedParents', false);
if (fixedParent) {
var transformed = [];
fixedParent = fixedParent.parent().find(parents).each(function(){
if (UI.$(this).css('transform') != 'none') {
transformed.push(UI.$(this).data('transform-reset', {
'transform': this.style.transform,
'-webkit-transform': this.style.webkitTransform,
'-webkit-transition':this.style.webkitTransition,
'transition':this.style.transition
}).css({
'transform': 'none',
'-webkit-transform': 'none',
'-webkit-transition':'none',
'transition':'none'
}));
}
});
editor.htmleditor.data('fixedParents', transformed);
}
editor.editor.state.fullScreenRestore = {scrollTop: window.pageYOffset, scrollLeft: window.pageXOffset, width: wrap.style.width, height: wrap.style.height};
wrap.style.width = '';
wrap.style.height = editor.content.height()+'px';
document.documentElement.style.overflow = 'hidden';
} else {
document.documentElement.style.overflow = '';
var info = editor.editor.state.fullScreenRestore;
wrap.style.width = info.width; wrap.style.height = info.height;
window.scrollTo(info.scrollLeft, info.scrollTop);
if (editor.htmleditor.data('fixedParents')) {
editor.htmleditor.data('fixedParents').forEach(function(parent){
parent.css(parent.data('transform-reset'));
});
}
}
setTimeout(function() {
editor.fit();
UI.$win.trigger('resize');
}, 50);
});
editor.addShortcut(['Ctrl-S', 'Cmd-S'], function() { editor.element.trigger('htmleditor-save', [editor]); });
editor.addShortcutAction('bold', ['Ctrl-B', 'Cmd-B']);
function addAction(name, replace, mode) {
editor.on('action.'+name, function() {
if (editor.getCursorMode() == 'html') {
editor[mode == 'replaceLine' ? 'replaceLine' : 'replaceSelection'](replace);
}
});
}
}
});
UI.plugin('htmleditor', 'markdown', {
init: function(editor) {
var parser = editor.options.mdparser || window.marked || null;
if (!parser) return;
if (editor.options.markdown) {
enableMarkdown();
}
addAction('bold', '**$1**');
addAction('italic', '*$1*');
addAction('strike', '~~$1~~');
addAction('blockquote', '> $1', 'replaceLine');
addAction('link', '[$1](http://)');
addAction('image', '![$1](http://)');
editor.on('action.listUl', function() {
if (editor.getCursorMode() == 'markdown') {
var cm = editor.editor,
pos = cm.getDoc().getCursor(true),
posend = cm.getDoc().getCursor(false);
for (var i=pos.line; i<(posend.line+1);i++) {
cm.replaceRange('* '+cm.getLine(i), { line: i, ch: 0 }, { line: i, ch: cm.getLine(i).length });
}
cm.setCursor({ line: posend.line, ch: cm.getLine(posend.line).length });
cm.focus();
}
});
editor.on('action.listOl', function() {
if (editor.getCursorMode() == 'markdown') {
var cm = editor.editor,
pos = cm.getDoc().getCursor(true),
posend = cm.getDoc().getCursor(false),
prefix = 1;
if (pos.line > 0) {
var prevline = cm.getLine(pos.line-1), matches;
if(matches = prevline.match(/^(\d+)\./)) {
prefix = Number(matches[1])+1;
}
}
for (var i=pos.line; i<(posend.line+1);i++) {
cm.replaceRange(prefix+'. '+cm.getLine(i), { line: i, ch: 0 }, { line: i, ch: cm.getLine(i).length });
prefix++;
}
cm.setCursor({ line: posend.line, ch: cm.getLine(posend.line).length });
cm.focus();
}
});
editor.on('renderLate', function() {
if (editor.editor.options.mode == 'gfm') {
editor.currentvalue = parser(editor.currentvalue);
}
});
editor.on('cursorMode', function(e, param) {
if (editor.editor.options.mode == 'gfm') {
var pos = editor.editor.getDoc().getCursor();
if (!editor.editor.getTokenAt(pos).state.base.htmlState) {
param.mode = 'markdown';
}
}
});
UI.$.extend(editor, {
enableMarkdown: function() {
enableMarkdown();
this.render();
},
disableMarkdown: function() {
this.editor.setOption('mode', 'htmlmixed');
this.htmleditor.find('.uk-htmleditor-button-code a').html(this.options.lblCodeview);
this.render();
}
});
// switch markdown mode on event
editor.on({
enableMarkdown : function() { editor.enableMarkdown(); },
disableMarkdown : function() { editor.disableMarkdown(); }
});
function enableMarkdown() {
editor.editor.setOption('mode', 'gfm');
editor.htmleditor.find('.uk-htmleditor-button-code a').html(editor.options.lblMarkedview);
}
function addAction(name, replace, mode) {
editor.on('action.'+name, function() {
if (editor.getCursorMode() == 'markdown') {
editor[mode == 'replaceLine' ? 'replaceLine' : 'replaceSelection'](replace);
}
});
}
}
});
return UI.htmleditor;
});

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1 @@
<html><body bgcolor="#FFFFFF"></body></html>

View File

@ -0,0 +1,588 @@
/*! UIkit 2.27.4 | http://www.getuikit.com | (c) 2014 YOOtheme | MIT License */
(function(addon) {
var component;
if (window.UIkit2) {
component = addon(UIkit2);
}
if (typeof define == 'function' && define.amd) { // AMD
define('uikit-lightbox', ['uikit'], function(){
return component || addon(UIkit2);
});
}
})(function(UI){
"use strict";
var modal, cache = {};
UI.component('lightbox', {
defaults: {
allowfullscreen : true,
duration : 400,
group : false,
keyboard : true
},
index : 0,
items : false,
boot: function() {
UI.$html.on('click', '[data-uk-lightbox]', function(e){
e.preventDefault();
var link = UI.$(this);
if (!link.data('lightbox')) {
UI.lightbox(link, UI.Utils.options(link.attr('data-uk-lightbox')));
}
link.data('lightbox').show(link);
});
// keyboard navigation
UI.$doc.on('keyup', function(e) {
if (modal && modal.is(':visible') && modal.lightbox.options.keyboard) {
e.preventDefault();
switch(e.keyCode) {
case 37:
modal.lightbox.previous();
break;
case 39:
modal.lightbox.next();
break;
}
}
});
},
init: function() {
var siblings = [];
this.index = 0;
this.siblings = [];
if (this.element && this.element.length) {
var domSiblings = this.options.group ? UI.$('[data-uk-lightbox*="'+this.options.group+'"]') : this.element;
domSiblings.each(function() {
var ele = UI.$(this);
siblings.push({
source : ele.attr('href'),
title : ele.attr('data-title') || ele.attr('title'),
type : ele.attr("data-lightbox-type") || 'auto',
link : ele
});
});
this.index = domSiblings.index(this.element);
this.siblings = siblings;
} else if (this.options.group && this.options.group.length) {
this.siblings = this.options.group;
}
this.trigger('lightbox-init', [this]);
},
show: function(index) {
this.modal = getModal(this);
// stop previous animation
this.modal.dialog.stop();
this.modal.content.stop();
var $this = this, promise = UI.$.Deferred(), data, item;
index = index || 0;
// index is a jQuery object or DOM element
if (typeof(index) == 'object') {
this.siblings.forEach(function(s, idx){
if (index[0] === s.link[0]) {
index = idx;
}
});
}
// fix index if needed
if ( index < 0 ) {
index = this.siblings.length - index;
} else if (!this.siblings[index]) {
index = 0;
}
item = this.siblings[index];
data = {
lightbox : $this,
source : item.source,
type : item.type,
index : index,
promise : promise,
title : item.title,
item : item,
meta : {
content : '',
width : null,
height : null
}
};
this.index = index;
this.modal.content.empty();
if (!this.modal.is(':visible')) {
this.modal.content.css({width:'', height:''}).empty();
this.modal.modal.show();
}
this.modal.loader.removeClass('uk-hidden');
promise.promise().done(function() {
$this.data = data;
$this.fitSize(data);
}).fail(function(){
data.meta.content = '<div class="uk-position-cover uk-flex uk-flex-middle uk-flex-center"><strong>Loading resource failed!</strong></div>';
data.meta.width = 400;
data.meta.height = 300;
$this.data = data;
$this.fitSize(data);
});
$this.trigger('showitem.uk.lightbox', [data]);
},
fitSize: function() {
var $this = this,
data = this.data,
pad = this.modal.dialog.outerWidth() - this.modal.dialog.width(),
dpadTop = parseInt(this.modal.dialog.css('margin-top'), 10),
dpadBot = parseInt(this.modal.dialog.css('margin-bottom'), 10),
dpad = dpadTop + dpadBot,
content = data.meta.content,
duration = $this.options.duration;
if (this.siblings.length > 1) {
content = [
content,
'<a href="#" class="uk-slidenav uk-slidenav-contrast uk-slidenav-previous uk-hidden-touch" data-lightbox-previous></a>',
'<a href="#" class="uk-slidenav uk-slidenav-contrast uk-slidenav-next uk-hidden-touch" data-lightbox-next></a>'
].join('');
}
// calculate width
var tmp = UI.$('<div>&nbsp;</div>').css({
opacity : 0,
position : 'absolute',
top : 0,
left : 0,
width : '100%',
maxWidth : $this.modal.dialog.css('max-width'),
padding : $this.modal.dialog.css('padding'),
margin : $this.modal.dialog.css('margin')
}), maxwidth, maxheight, w = data.meta.width, h = data.meta.height;
tmp.appendTo('body').width();
maxwidth = tmp.width();
maxheight = window.innerHeight - dpad;
tmp.remove();
this.modal.dialog.find('.uk-modal-caption').remove();
if (data.title) {
this.modal.dialog.append('<div class="uk-modal-caption">'+data.title+'</div>');
maxheight -= this.modal.dialog.find('.uk-modal-caption').outerHeight();
}
if (maxwidth < data.meta.width) {
h = Math.floor( h * (maxwidth / w) );
w = maxwidth;
}
if (maxheight < h) {
h = Math.floor(maxheight);
w = Math.ceil(data.meta.width * (maxheight/data.meta.height));
}
this.modal.content.css('opacity', 0).width(w).html(content);
if (data.type == 'iframe') {
this.modal.content.find('iframe:first').height(h);
}
var dh = h + pad,
t = Math.floor(window.innerHeight/2 - dh/2) - dpad;
if (t < 0) { t = 0; }
this.modal.closer.addClass('uk-hidden');
if ($this.modal.data('mwidth') == w && $this.modal.data('mheight') == h) {
duration = 0;
}
this.modal.dialog.animate({width: w + pad, height: h + pad, top: t }, duration, 'swing', function() {
$this.modal.loader.addClass('uk-hidden');
$this.modal.content.css({width:''}).animate({opacity: 1}, function() {
$this.modal.closer.removeClass('uk-hidden');
});
$this.modal.data({mwidth: w, mheight: h});
});
},
next: function() {
this.show(this.siblings[(this.index+1)] ? (this.index+1) : 0);
},
previous: function() {
this.show(this.siblings[(this.index-1)] ? (this.index-1) : this.siblings.length-1);
}
});
// Plugins
UI.plugin('lightbox', 'image', {
init: function(lightbox) {
lightbox.on('showitem.uk.lightbox', function(e, data){
if (data.type == 'image' || data.source && data.source.match(/\.(jpg|jpeg|png|gif|svg)$/i)) {
var resolve = function(source, width, height) {
data.meta = {
content : '<img class="uk-responsive-width" width="'+width+'" height="'+height+'" src ="'+source+'">',
width : width,
height : height
};
data.type = 'image';
data.promise.resolve();
};
if (!cache[data.source]) {
var img = new Image();
img.onerror = function(){
data.promise.reject('Loading image failed');
};
img.onload = function(){
cache[data.source] = {width: img.width, height: img.height};
resolve(data.source, cache[data.source].width, cache[data.source].height);
};
img.src = data.source;
} else {
resolve(data.source, cache[data.source].width, cache[data.source].height);
}
}
});
}
});
UI.plugin('lightbox', 'youtube', {
init: function(lightbox) {
var youtubeRegExp = /(\/\/.*?youtube\.[a-z]+)\/watch\?v=([^&]+)&?(.*)/,
youtubeRegExpShort = /youtu\.be\/(.*)/;
lightbox.on('showitem.uk.lightbox', function(e, data){
var id, matches, resolve = function(id, width, height) {
data.meta = {
content: '<iframe src="//www.youtube.com/embed/'+id+'" width="'+width+'" height="'+height+'" style="max-width:100%;"'+(modal.lightbox.options.allowfullscreen?' allowfullscreen':'')+'></iframe>',
width: width,
height: height
};
data.type = 'iframe';
data.promise.resolve();
};
if (matches = data.source.match(youtubeRegExp)) {
id = matches[2];
}
if (matches = data.source.match(youtubeRegExpShort)) {
id = matches[1];
}
if (id) {
if(!cache[id]) {
var img = new Image(), lowres = false;
img.onerror = function(){
cache[id] = {width:640, height:320};
resolve(id, cache[id].width, cache[id].height);
};
img.onload = function(){
//youtube default 404 thumb, fall back to lowres
if (img.width == 120 && img.height == 90) {
if (!lowres) {
lowres = true;
img.src = '//img.youtube.com/vi/' + id + '/0.jpg';
} else {
cache[id] = {width: 640, height: 320};
resolve(id, cache[id].width, cache[id].height);
}
} else {
cache[id] = {width: img.width, height: img.height};
resolve(id, img.width, img.height);
}
};
img.src = '//img.youtube.com/vi/'+id+'/maxresdefault.jpg';
} else {
resolve(id, cache[id].width, cache[id].height);
}
e.stopImmediatePropagation();
}
});
}
});
UI.plugin('lightbox', 'vimeo', {
init: function(lightbox) {
var regex = /(\/\/.*?)vimeo\.[a-z]+\/([0-9]+).*?/, matches;
lightbox.on('showitem.uk.lightbox', function(e, data){
var id, resolve = function(id, width, height) {
data.meta = {
content: '<iframe src="//player.vimeo.com/video/'+id+'" width="'+width+'" height="'+height+'" style="width:100%;box-sizing:border-box;"'+(modal.lightbox.options.allowfullscreen?' allowfullscreen':'')+'></iframe>',
width: width,
height: height
};
data.type = 'iframe';
data.promise.resolve();
};
if (matches = data.source.match(regex)) {
id = matches[2];
if(!cache[id]) {
UI.$.ajax({
type : 'GET',
url : '//vimeo.com/api/oembed.json?url=' + encodeURI(data.source),
jsonp : 'callback',
dataType : 'jsonp',
success : function(data) {
cache[id] = {width:data.width, height:data.height};
resolve(id, cache[id].width, cache[id].height);
}
});
} else {
resolve(id, cache[id].width, cache[id].height);
}
e.stopImmediatePropagation();
}
});
}
});
UI.plugin('lightbox', 'video', {
init: function(lightbox) {
lightbox.on('showitem.uk.lightbox', function(e, data){
var resolve = function(source, width, height) {
data.meta = {
content: '<video class="uk-responsive-width" src="'+source+'" width="'+width+'" height="'+height+'" controls></video>',
width: width,
height: height
};
data.type = 'video';
data.promise.resolve();
};
if (data.type == 'video' || data.source.match(/\.(mp4|webm|ogv)$/i)) {
if (!cache[data.source]) {
var vid = UI.$('<video style="position:fixed;visibility:hidden;top:-10000px;"></video>').attr('src', data.source).appendTo('body');
var idle = setInterval(function() {
if (vid[0].videoWidth) {
clearInterval(idle);
cache[data.source] = {width: vid[0].videoWidth, height: vid[0].videoHeight};
resolve(data.source, cache[data.source].width, cache[data.source].height);
vid.remove();
}
}, 20);
} else {
resolve(data.source, cache[data.source].width, cache[data.source].height);
}
}
});
}
});
UI.plugin('lightbox', 'iframe', {
init: function (lightbox) {
lightbox.on('showitem.uk.lightbox', function (e, data) {
var resolve = function (source, width, height) {
data.meta = {
content: '<iframe class="uk-responsive-width" src="' + source + '" width="' + width + '" height="' + height + '"'+(modal.lightbox.options.allowfullscreen?' allowfullscreen':'')+'></iframe>',
width: width,
height: height
};
data.type = 'iframe';
data.promise.resolve();
};
if (data.type === 'iframe' || data.source.match(/\.(html|php)$/)) {
resolve(data.source, (lightbox.options.width || 800), (lightbox.options.height || 600));
}
});
}
});
function getModal(lightbox) {
if (modal) {
modal.lightbox = lightbox;
return modal;
}
// init lightbox container
modal = UI.$([
'<div class="uk-modal">',
'<div class="uk-modal-dialog uk-modal-dialog-lightbox uk-slidenav-position" style="margin-left:auto;margin-right:auto;width:200px;height:200px;top:'+Math.abs(window.innerHeight/2 - 200)+'px;">',
'<a href="#" class="uk-modal-close uk-close uk-close-alt"></a>',
'<div class="uk-lightbox-content"></div>',
'<div class="uk-modal-spinner uk-hidden"></div>',
'</div>',
'</div>'
].join('')).appendTo('body');
modal.dialog = modal.find('.uk-modal-dialog:first');
modal.content = modal.find('.uk-lightbox-content:first');
modal.loader = modal.find('.uk-modal-spinner:first');
modal.closer = modal.find('.uk-close.uk-close-alt');
modal.modal = UI.modal(modal, {modal:false});
// next / previous
modal.on('swipeRight swipeLeft', function(e) {
modal.lightbox[e.type=='swipeLeft' ? 'next':'previous']();
}).on('click', '[data-lightbox-previous], [data-lightbox-next]', function(e){
e.preventDefault();
modal.lightbox[UI.$(this).is('[data-lightbox-next]') ? 'next':'previous']();
});
// destroy content on modal hide
modal.on('hide.uk.modal', function(e) {
modal.content.html('');
});
var resizeCache = {w: window.innerWidth, h:window.innerHeight};
UI.$win.on('load resize orientationchange', UI.Utils.debounce(function(e){
if (resizeCache.w !== window.innerWidth && modal.is(':visible') && !UI.Utils.isFullscreen()) {
modal.lightbox.fitSize();
}
resizeCache = {w: window.innerWidth, h:window.innerHeight};
}, 100));
modal.lightbox = lightbox;
return modal;
}
UI.lightbox.create = function(items, options) {
if (!items) return;
var group = [], o;
items.forEach(function(item) {
group.push(UI.$.extend({
source : '',
title : '',
type : 'auto',
link : false
}, (typeof(item) == 'string' ? {'source': item} : item)));
});
o = UI.lightbox(UI.$.extend({}, options, {'group':group}));
return o;
};
return UI.lightbox;
});

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,653 @@
/*! UIkit 2.27.4 | http://www.getuikit.com | (c) 2014 YOOtheme | MIT License */
/*
* Based on Nestable jQuery Plugin - Copyright (c) 2012 David Bushell - http://dbushell.com/
*/
(function(addon) {
var component;
if (window.UIkit2) {
component = addon(UIkit2);
}
if (typeof define == 'function' && define.amd) {
define('uikit-nestable', ['uikit'], function(){
return component || addon(UIkit2);
});
}
})(function(UI) {
"use strict";
var hasTouch = 'ontouchstart' in window,
html = UI.$html,
touchedlists = [],
$win = UI.$win,
draggingElement;
var eStart = hasTouch ? 'touchstart' : 'mousedown',
eMove = hasTouch ? 'touchmove' : 'mousemove',
eEnd = hasTouch ? 'touchend' : 'mouseup',
eCancel = hasTouch ? 'touchcancel' : 'mouseup';
UI.component('nestable', {
defaults: {
listBaseClass : 'uk-nestable',
listClass : 'uk-nestable-list',
listItemClass : 'uk-nestable-item',
dragClass : 'uk-nestable-dragged',
movingClass : 'uk-nestable-moving',
noChildrenClass : 'uk-nestable-nochildren',
emptyClass : 'uk-nestable-empty',
handleClass : '',
collapsedClass : 'uk-collapsed',
placeholderClass: 'uk-nestable-placeholder',
noDragClass : 'uk-nestable-nodrag',
group : false,
maxDepth : 10,
threshold : 20,
idlethreshold : 10,
},
boot: function() {
// adjust document scrolling
UI.$html.on('mousemove touchmove', function(e) {
if (draggingElement) {
var top = draggingElement.offset().top;
if (top < UI.$win.scrollTop()) {
UI.$win.scrollTop(UI.$win.scrollTop() - Math.ceil(draggingElement.height()/2));
} else if ( (top + draggingElement.height()) > (window.innerHeight + UI.$win.scrollTop()) ) {
UI.$win.scrollTop(UI.$win.scrollTop() + Math.ceil(draggingElement.height()/2));
}
}
});
// init code
UI.ready(function(context) {
UI.$("[data-uk-nestable]", context).each(function(){
var ele = UI.$(this);
if (!ele.data("nestable")) {
UI.nestable(ele, UI.Utils.options(ele.attr("data-uk-nestable")));
}
});
});
},
init: function() {
var $this = this;
Object.keys(this.options).forEach(function(key){
if(String(key).indexOf('Class')!=-1) {
$this.options['_'+key] = '.' + $this.options[key];
}
});
this.find(this.options._listItemClass).find(">ul").addClass(this.options.listClass);
this.checkEmptyList();
this.reset();
this.element.data('nestable-group', this.options.group || UI.Utils.uid('nestable-group'));
this.find(this.options._listItemClass).each(function() {
$this.setParent(UI.$(this));
});
this.on('click', '[data-nestable-action]', function(e) {
if ($this.dragEl || (!hasTouch && e.button !== 0)) {
return;
}
e.preventDefault();
var target = UI.$(e.currentTarget),
action = target.data('nestableAction'),
item = target.closest($this.options._listItemClass);
if (action === 'collapse') {
$this.collapseItem(item);
}
if (action === 'expand') {
$this.expandItem(item);
}
if (action === 'toggle') {
$this.toggleItem(item);
}
});
var onStartEvent = function(e) {
var handle = UI.$(e.target),
link = handle.is('a[href]') ? handle:handle.parents('a[href]');
if (e.target === $this.element[0]) {
return;
}
if (handle.is($this.options._noDragClass) || handle.closest($this.options._noDragClass).length) {
return;
}
if (handle.is('[data-nestable-action]') || handle.closest('[data-nestable-action]').length) {
return;
}
if ($this.options.handleClass && !handle.hasClass($this.options.handleClass)) {
if ($this.options.handleClass) {
handle = handle.closest($this.options._handleClass);
}
}
if (!handle.length || $this.dragEl || (!hasTouch && e.button !== 0) || (hasTouch && e.touches.length !== 1)) {
return;
}
if (e.originalEvent && e.originalEvent.touches) {
e = evt.originalEvent.touches[0];
}
$this.delayMove = function(evt) {
link = false;
evt.preventDefault();
$this.dragStart(e);
$this.trigger('start.uk.nestable', [$this]);
$this.delayMove = false;
};
$this.delayMove.x = parseInt(e.pageX, 10);
$this.delayMove.y = parseInt(e.pageY, 10);
$this.delayMove.threshold = $this.options.idlethreshold;
if (link.length && eEnd == 'touchend') {
$this.one(eEnd, function(){
if (link && link.attr('href').trim()) {
location.href = link.attr('href');
}
});
}
e.preventDefault();
};
var onMoveEvent = function(e) {
if (e.originalEvent && e.originalEvent.touches) {
e = e.originalEvent.touches[0];
}
if ($this.delayMove && (Math.abs(e.pageX - $this.delayMove.x) > $this.delayMove.threshold || Math.abs(e.pageY - $this.delayMove.y) > $this.delayMove.threshold)) {
if (!window.getSelection().toString()) {
$this.delayMove(e);
} else {
$this.delayMove = false;
}
}
if ($this.dragEl) {
e.preventDefault();
$this.dragMove(e);
$this.trigger('move.uk.nestable', [$this]);
}
};
var onEndEvent = function(e) {
if ($this.dragEl) {
e.preventDefault();
$this.dragStop(hasTouch ? e.touches[0] : e);
}
draggingElement = false;
$this.delayMove = false;
};
if (hasTouch) {
this.element[0].addEventListener(eStart, onStartEvent, false);
window.addEventListener(eMove, onMoveEvent, false);
window.addEventListener(eEnd, onEndEvent, false);
window.addEventListener(eCancel, onEndEvent, false);
} else {
this.on(eStart, onStartEvent);
$win.on(eMove, onMoveEvent);
$win.on(eEnd, onEndEvent);
}
},
serialize: function() {
var data,
depth = 0,
list = this,
step = function(level, depth) {
var array = [ ], items = level.children(list.options._listItemClass);
items.each(function() {
var li = UI.$(this),
item = {}, attribute,
sub = li.children(list.options._listClass);
for (var i = 0, attr, val; i < li[0].attributes.length; i++) {
attribute = li[0].attributes[i];
if (attribute.name.indexOf('data-') === 0) {
attr = attribute.name.substr(5);
val = UI.Utils.str2json(attribute.value);
item[attr] = (val || attribute.value=='false' || attribute.value=='0') ? val:attribute.value;
}
}
if (sub.length) {
item.children = step(sub, depth + 1);
}
array.push(item);
});
return array;
};
data = step(list.element, depth);
return data;
},
list: function(options) {
var data = [],
list = this,
depth = 0,
step = function(level, depth, parent) {
var items = level.children(options._listItemClass);
items.each(function(index) {
var li = UI.$(this),
item = UI.$.extend({parent_id: (parent ? parent : null), depth: depth, order: index}, li.data()),
sub = li.children(options._listClass);
data.push(item);
if (sub.length) {
step(sub, depth + 1, li.data(options.idProperty || 'id'));
}
});
};
options = UI.$.extend({}, list.options, options);
step(list.element, depth);
return data;
},
reset: function() {
this.mouse = {
offsetX : 0,
offsetY : 0,
startX : 0,
startY : 0,
lastX : 0,
lastY : 0,
nowX : 0,
nowY : 0,
distX : 0,
distY : 0,
dirAx : 0,
dirX : 0,
dirY : 0,
lastDirX : 0,
lastDirY : 0,
distAxX : 0,
distAxY : 0
};
this.moving = false;
this.dragEl = null;
this.dragRootEl = null;
this.dragDepth = 0;
this.hasNewRoot = false;
this.pointEl = null;
for (var i=0; i<touchedlists.length; i++) {
this.checkEmptyList(touchedlists[i]);
}
touchedlists = [];
},
toggleItem: function(li) {
this[li.hasClass(this.options.collapsedClass) ? 'expandItem':'collapseItem'](li);
},
expandItem: function(li) {
li.removeClass(this.options.collapsedClass);
},
collapseItem: function(li) {
var lists = li.children(this.options._listClass);
if (lists.length) {
li.addClass(this.options.collapsedClass);
}
},
expandAll: function() {
var list = this;
this.find(list.options._listItemClass).each(function() {
list.expandItem(UI.$(this));
});
},
collapseAll: function() {
var list = this;
this.find(list.options._listItemClass).each(function() {
list.collapseItem(UI.$(this));
});
},
setParent: function(li) {
if (li.children(this.options._listClass).length) {
li.addClass('uk-parent');
}
},
unsetParent: function(li) {
li.removeClass('uk-parent '+this.options.collapsedClass);
li.children(this.options._listClass).remove();
},
dragStart: function(e) {
var mouse = this.mouse,
target = UI.$(e.target),
dragItem = target.closest(this.options._listItemClass),
offset = dragItem.offset();
this.placeEl = dragItem;
mouse.offsetX = e.pageX - offset.left;
mouse.offsetY = e.pageY - offset.top;
mouse.startX = mouse.lastX = offset.left;
mouse.startY = mouse.lastY = offset.top;
this.dragRootEl = this.element;
this.dragEl = UI.$('<ul></ul>').addClass(this.options.listClass + ' ' + this.options.dragClass).append(dragItem.clone());
this.dragEl.css('width', dragItem.width());
this.placeEl.addClass(this.options.placeholderClass);
draggingElement = this.dragEl;
this.tmpDragOnSiblings = [dragItem[0].previousSibling, dragItem[0].nextSibling];
UI.$body.append(this.dragEl);
this.dragEl.css({
left : offset.left,
top : offset.top
});
// total depth of dragging item
var i, depth, items = this.dragEl.find(this.options._listItemClass);
for (i = 0; i < items.length; i++) {
depth = UI.$(items[i]).parents(this.options._listClass+','+this.options._listBaseClass).length;
if (depth > this.dragDepth) {
this.dragDepth = depth;
}
}
html.addClass(this.options.movingClass);
},
dragStop: function(e) {
var el = UI.$(this.placeEl),
root = this.placeEl.parents(this.options._listBaseClass+':first');
this.placeEl.removeClass(this.options.placeholderClass);
this.dragEl.remove();
if (this.element[0] !== root[0]) {
root.trigger('change.uk.nestable',[root.data('nestable'), el, 'added']);
this.element.trigger('change.uk.nestable', [this, el, 'removed']);
} else {
this.element.trigger('change.uk.nestable',[this, el, "moved"]);
}
this.trigger('stop.uk.nestable', [this, el]);
this.reset();
html.removeClass(this.options.movingClass);
},
dragMove: function(e) {
var list, parent, prev, next, depth,
opt = this.options,
mouse = this.mouse,
maxDepth = this.dragRootEl ? this.dragRootEl.data('nestable').options.maxDepth : opt.maxDepth;
this.dragEl.css({
left : e.pageX - mouse.offsetX,
top : e.pageY - mouse.offsetY
});
// mouse position last events
mouse.lastX = mouse.nowX;
mouse.lastY = mouse.nowY;
// mouse position this events
mouse.nowX = e.pageX;
mouse.nowY = e.pageY;
// distance mouse moved between events
mouse.distX = mouse.nowX - mouse.lastX;
mouse.distY = mouse.nowY - mouse.lastY;
// direction mouse was moving
mouse.lastDirX = mouse.dirX;
mouse.lastDirY = mouse.dirY;
// direction mouse is now moving (on both axis)
mouse.dirX = mouse.distX === 0 ? 0 : mouse.distX > 0 ? 1 : -1;
mouse.dirY = mouse.distY === 0 ? 0 : mouse.distY > 0 ? 1 : -1;
// axis mouse is now moving on
var newAx = Math.abs(mouse.distX) > Math.abs(mouse.distY) ? 1 : 0;
// do nothing on first move
if (!mouse.moving) {
mouse.dirAx = newAx;
mouse.moving = true;
return;
}
// calc distance moved on this axis (and direction)
if (mouse.dirAx !== newAx) {
mouse.distAxX = 0;
mouse.distAxY = 0;
} else {
mouse.distAxX += Math.abs(mouse.distX);
if (mouse.dirX !== 0 && mouse.dirX !== mouse.lastDirX) {
mouse.distAxX = 0;
}
mouse.distAxY += Math.abs(mouse.distY);
if (mouse.dirY !== 0 && mouse.dirY !== mouse.lastDirY) {
mouse.distAxY = 0;
}
}
mouse.dirAx = newAx;
/**
* move horizontal
*/
if (mouse.dirAx && mouse.distAxX >= opt.threshold) {
// reset move distance on x-axis for new phase
mouse.distAxX = 0;
prev = this.placeEl.prev('li');
// increase horizontal level if previous sibling exists, is not collapsed, and does not have a 'no children' class
if (mouse.distX > 0 && prev.length && !prev.hasClass(opt.collapsedClass) && !prev.hasClass(opt.noChildrenClass)) {
// cannot increase level when item above is collapsed
list = prev.find(opt._listClass).last();
// check if depth limit has reached
depth = this.placeEl.parents(opt._listClass+','+opt._listBaseClass).length;
if (depth + this.dragDepth <= maxDepth) {
// create new sub-level if one doesn't exist
if (!list.length) {
list = UI.$('<ul/>').addClass(opt.listClass);
list.append(this.placeEl);
prev.append(list);
this.setParent(prev);
} else {
// else append to next level up
list = prev.children(opt._listClass).last();
list.append(this.placeEl);
}
}
}
// decrease horizontal level
if (mouse.distX < 0) {
// we cannot decrease the level if an item precedes the current one
next = this.placeEl.next(opt._listItemClass);
if (!next.length) {
// get parent ul of the list item
var parentUl = this.placeEl.closest([opt._listBaseClass, opt._listClass].join(','));
// try to get the li surrounding the ul
var surroundingLi = parentUl.closest(opt._listItemClass);
// if the ul is inside of a li (meaning it is nested)
if (surroundingLi.length) {
// we can decrease the horizontal level
surroundingLi.after(this.placeEl);
// if the previous parent ul is now empty
if (!parentUl.children().length) {
this.unsetParent(surroundingLi);
}
}
}
}
}
var isEmpty = false;
// find list item under cursor
var pointX = e.pageX - (window.pageXOffset || document.scrollLeft || 0),
pointY = e.pageY - (window.pageYOffset || document.documentElement.scrollTop);
this.pointEl = UI.$(document.elementFromPoint(pointX, pointY));
if (opt.handleClass && this.pointEl.hasClass(opt.handleClass)) {
this.pointEl = this.pointEl.closest(opt._listItemClass);
} else {
var nestableitem = this.pointEl.closest(opt._listItemClass);
if (nestableitem.length) {
this.pointEl = nestableitem;
}
}
if (this.placeEl.find(this.pointEl).length) {
return;
}
if (this.pointEl.data('nestable') && !this.pointEl.children().length) {
isEmpty = true;
this.checkEmptyList(this.pointEl);
} else if (!this.pointEl.length || !this.pointEl.hasClass(opt.listItemClass)) {
return;
}
// find parent list of item under cursor
var pointElRoot = this.element,
tmpRoot = this.pointEl.closest(this.options._listBaseClass),
isNewRoot = pointElRoot[0] != tmpRoot[0];
/**
* move vertical
*/
if (!mouse.dirAx || isNewRoot || isEmpty) {
// check if groups match if dragging over new root
if (isNewRoot && opt.group !== tmpRoot.data('nestable-group')) {
return;
} else {
touchedlists.push(pointElRoot);
}
// check depth limit
depth = this.dragDepth - 1 + this.pointEl.parents(opt._listClass+','+opt._listBaseClass).length;
if (depth > maxDepth) {
return;
}
var before = e.pageY < (this.pointEl.offset().top + this.pointEl.height() / 2);
parent = this.placeEl.parent();
if (isEmpty) {
this.pointEl.append(this.placeEl);
} else if (before) {
this.pointEl.before(this.placeEl);
} else {
this.pointEl.after(this.placeEl);
}
if (!parent.children().length) {
if (!parent.data('nestable')) this.unsetParent(parent.parent());
}
this.checkEmptyList(this.dragRootEl);
this.checkEmptyList(pointElRoot);
// parent root list has changed
if (isNewRoot) {
this.dragRootEl = tmpRoot;
this.hasNewRoot = this.element[0] !== this.dragRootEl[0];
}
}
},
checkEmptyList: function(list) {
list = list ? UI.$(list) : this.element;
if (this.options.emptyClass) {
list[!list.children().length ? 'addClass':'removeClass'](this.options.emptyClass);
}
}
});
return UI.nestable;
});

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,189 @@
/*! UIkit 2.27.4 | http://www.getuikit.com | (c) 2014 YOOtheme | MIT License */
(function(addon) {
var component;
if (window.UIkit2) {
component = addon(UIkit2);
}
if (typeof define == 'function' && define.amd) {
define('uikit-notify', ['uikit'], function(){
return component || addon(UIkit2);
});
}
})(function(UI){
"use strict";
var containers = {},
messages = {},
notify = function(options){
if (UI.$.type(options) == 'string') {
options = { message: options };
}
if (arguments[1]) {
options = UI.$.extend(options, UI.$.type(arguments[1]) == 'string' ? {status:arguments[1]} : arguments[1]);
}
return (new Message(options)).show();
},
closeAll = function(group, instantly){
var id;
if (group) {
for(id in messages) { if(group===messages[id].group) messages[id].close(instantly); }
} else {
for(id in messages) { messages[id].close(instantly); }
}
};
var Message = function(options){
this.options = UI.$.extend({}, Message.defaults, options);
this.uuid = UI.Utils.uid('notifymsg');
this.element = UI.$([
'<div class="uk-notify-message">',
'<a class="uk-close"></a>',
'<div></div>',
'</div>'
].join('')).data("notifyMessage", this);
this.content(this.options.message);
// status
if (this.options.status) {
this.element.addClass('uk-notify-message-'+this.options.status);
this.currentstatus = this.options.status;
}
this.group = this.options.group;
messages[this.uuid] = this;
if(!containers[this.options.pos]) {
containers[this.options.pos] = UI.$('<div class="uk-notify uk-notify-'+this.options.pos+'"></div>').appendTo('body').on("click", ".uk-notify-message", function(){
var message = UI.$(this).data('notifyMessage');
message.element.trigger('manualclose.uk.notify', [message]);
message.close();
});
}
};
UI.$.extend(Message.prototype, {
uuid: false,
element: false,
timout: false,
currentstatus: "",
group: false,
show: function() {
if (this.element.is(':visible')) return;
var $this = this;
containers[this.options.pos].show().prepend(this.element);
var marginbottom = parseInt(this.element.css('margin-bottom'), 10);
this.element.css({opacity:0, marginTop: -1*this.element.outerHeight(), marginBottom:0}).animate({opacity:1, marginTop:0, marginBottom:marginbottom}, function(){
if ($this.options.timeout) {
var closefn = function(){ $this.close(); };
$this.timeout = setTimeout(closefn, $this.options.timeout);
$this.element.hover(
function() { clearTimeout($this.timeout); },
function() { $this.timeout = setTimeout(closefn, $this.options.timeout); }
);
}
});
return this;
},
close: function(instantly) {
var $this = this,
finalize = function(){
$this.element.remove();
if (!containers[$this.options.pos].children().length) {
containers[$this.options.pos].hide();
}
$this.options.onClose.apply($this, []);
$this.element.trigger('close.uk.notify', [$this]);
delete messages[$this.uuid];
};
if (this.timeout) clearTimeout(this.timeout);
if (instantly) {
finalize();
} else {
this.element.animate({opacity:0, marginTop: -1* this.element.outerHeight(), marginBottom:0}, function(){
finalize();
});
}
},
content: function(html){
var container = this.element.find(">div");
if(!html) {
return container.html();
}
container.html(html);
return this;
},
status: function(status) {
if (!status) {
return this.currentstatus;
}
this.element.removeClass('uk-notify-message-'+this.currentstatus).addClass('uk-notify-message-'+status);
this.currentstatus = status;
return this;
}
});
Message.defaults = {
message: "",
status: "",
timeout: 5000,
group: null,
pos: 'top-center',
onClose: function() {}
};
UI.notify = notify;
UI.notify.message = Message;
UI.notify.closeAll = closeAll;
return notify;
});

View File

@ -0,0 +1,2 @@
/*! UIkit 2.27.4 | http://www.getuikit.com | (c) 2014 YOOtheme | MIT License */
!function(t){var e;window.UIkit2&&(e=t(UIkit2)),"function"==typeof define&&define.amd&&define("uikit-notify",["uikit"],function(){return e||t(UIkit2)})}(function(t){"use strict";var e={},i={},s=function(e){return"string"==t.$.type(e)&&(e={message:e}),arguments[1]&&(e=t.$.extend(e,"string"==t.$.type(arguments[1])?{status:arguments[1]}:arguments[1])),new n(e).show()},o=function(t,e){var s;if(t)for(s in i)t===i[s].group&&i[s].close(e);else for(s in i)i[s].close(e)},n=function(s){this.options=t.$.extend({},n.defaults,s),this.uuid=t.Utils.uid("notifymsg"),this.element=t.$(['<div class="uk-notify-message">','<a class="uk-close"></a>',"<div></div>","</div>"].join("")).data("notifyMessage",this),this.content(this.options.message),this.options.status&&(this.element.addClass("uk-notify-message-"+this.options.status),this.currentstatus=this.options.status),this.group=this.options.group,i[this.uuid]=this,e[this.options.pos]||(e[this.options.pos]=t.$('<div class="uk-notify uk-notify-'+this.options.pos+'"></div>').appendTo("body").on("click",".uk-notify-message",function(){var e=t.$(this).data("notifyMessage");e.element.trigger("manualclose.uk.notify",[e]),e.close()}))};return t.$.extend(n.prototype,{uuid:!1,element:!1,timout:!1,currentstatus:"",group:!1,show:function(){if(!this.element.is(":visible")){var t=this;e[this.options.pos].show().prepend(this.element);var i=parseInt(this.element.css("margin-bottom"),10);return this.element.css({opacity:0,marginTop:-1*this.element.outerHeight(),marginBottom:0}).animate({opacity:1,marginTop:0,marginBottom:i},function(){if(t.options.timeout){var e=function(){t.close()};t.timeout=setTimeout(e,t.options.timeout),t.element.hover(function(){clearTimeout(t.timeout)},function(){t.timeout=setTimeout(e,t.options.timeout)})}}),this}},close:function(t){var s=this,o=function(){s.element.remove(),e[s.options.pos].children().length||e[s.options.pos].hide(),s.options.onClose.apply(s,[]),s.element.trigger("close.uk.notify",[s]),delete i[s.uuid]};this.timeout&&clearTimeout(this.timeout),t?o():this.element.animate({opacity:0,marginTop:-1*this.element.outerHeight(),marginBottom:0},function(){o()})},content:function(t){var e=this.element.find(">div");return t?(e.html(t),this):e.html()},status:function(t){return t?(this.element.removeClass("uk-notify-message-"+this.currentstatus).addClass("uk-notify-message-"+t),this.currentstatus=t,this):this.currentstatus}}),n.defaults={message:"",status:"",timeout:5e3,group:null,pos:"top-center",onClose:function(){}},t.notify=s,t.notify.message=n,t.notify.closeAll=o,s});

View File

@ -0,0 +1,147 @@
/*! UIkit 2.27.4 | http://www.getuikit.com | (c) 2014 YOOtheme | MIT License */
/*
* Based on simplePagination - Copyright (c) 2012 Flavius Matis - http://flaviusmatis.github.com/simplePagination.js/ (MIT)
*/
(function(addon) {
var component;
if (window.UIkit2) {
component = addon(UIkit2);
}
if (typeof define == 'function' && define.amd) {
define('uikit-pagination', ['uikit'], function(){
return component || addon(UIkit2);
});
}
})(function(UI){
"use strict";
UI.component('pagination', {
defaults: {
items : 1,
itemsOnPage : 1,
pages : 0,
displayedPages : 7,
edges : 1,
currentPage : 0,
lblPrev : false,
lblNext : false,
onSelectPage : function() {}
},
boot: function() {
// init code
UI.ready(function(context) {
UI.$('[data-uk-pagination]', context).each(function(){
var ele = UI.$(this);
if (!ele.data('pagination')) {
UI.pagination(ele, UI.Utils.options(ele.attr('data-uk-pagination')));
}
});
});
},
init: function() {
var $this = this;
this.pages = this.options.pages ? this.options.pages : Math.ceil(this.options.items / this.options.itemsOnPage) ? Math.ceil(this.options.items / this.options.itemsOnPage) : 1;
this.currentPage = this.options.currentPage;
this.halfDisplayed = this.options.displayedPages / 2;
this.on('click', 'a[data-page]', function(e){
e.preventDefault();
$this.selectPage(UI.$(this).data('page'));
});
this._render();
},
_getInterval: function() {
return {
start: Math.ceil(this.currentPage > this.halfDisplayed ? Math.max(Math.min(this.currentPage - this.halfDisplayed, (this.pages - this.options.displayedPages)), 0) : 0),
end : Math.ceil(this.currentPage > this.halfDisplayed ? Math.min(this.currentPage + this.halfDisplayed, this.pages) : Math.min(this.options.displayedPages, this.pages))
};
},
render: function(pages) {
this.pages = pages ? pages : this.pages;
this._render();
},
selectPage: function(pageIndex, pages) {
this.currentPage = pageIndex;
this.render(pages);
this.options.onSelectPage.apply(this, [pageIndex]);
this.trigger('select.uk.pagination', [pageIndex, this]);
},
_render: function() {
var o = this.options, interval = this._getInterval(), i;
this.element.empty();
// Generate Prev link
if (o.lblPrev) this._append(this.currentPage - 1, {text: o.lblPrev});
// Generate start edges
if (interval.start > 0 && o.edges > 0) {
var end = Math.min(o.edges, interval.start);
for (i = 0; i < end; i++) this._append(i);
if (o.edges < interval.start && (interval.start - o.edges != 1)) {
this.element.append('<li><span>...</span></li>');
} else if (interval.start - o.edges == 1) {
this._append(o.edges);
}
}
// Generate interval links
for (i = interval.start; i < interval.end; i++) this._append(i);
// Generate end edges
if (interval.end < this.pages && o.edges > 0) {
if (this.pages - o.edges > interval.end && (this.pages - o.edges - interval.end != 1)) {
this.element.append('<li><span>...</span></li>');
} else if (this.pages - o.edges - interval.end == 1) {
this._append(interval.end++);
}
var begin = Math.max(this.pages - o.edges, interval.end);
for (i = begin; i < this.pages; i++) this._append(i);
}
// Generate Next link (unless option is set for at front)
if (o.lblNext) this._append(this.currentPage + 1, {text: o.lblNext});
},
_append: function(pageIndex, opts) {
var item, options;
pageIndex = pageIndex < 0 ? 0 : (pageIndex < this.pages ? pageIndex : this.pages - 1);
options = UI.$.extend({ text: pageIndex + 1 }, opts);
item = (pageIndex == this.currentPage) ? '<li class="uk-active"><span>' + (options.text) + '</span></li>' : '<li><a href="#page-'+(pageIndex+1)+'" data-page="'+pageIndex+'">'+options.text+'</a></li>';
this.element.append(item);
}
});
return UI.pagination;
});

View File

@ -0,0 +1,2 @@
/*! UIkit 2.27.4 | http://www.getuikit.com | (c) 2014 YOOtheme | MIT License */
!function(t){var e;window.UIkit2&&(e=t(UIkit2)),"function"==typeof define&&define.amd&&define("uikit-pagination",["uikit"],function(){return e||t(UIkit2)})}(function(t){"use strict";return t.component("pagination",{defaults:{items:1,itemsOnPage:1,pages:0,displayedPages:7,edges:1,currentPage:0,lblPrev:!1,lblNext:!1,onSelectPage:function(){}},boot:function(){t.ready(function(e){t.$("[data-uk-pagination]",e).each(function(){var e=t.$(this);e.data("pagination")||t.pagination(e,t.Utils.options(e.attr("data-uk-pagination")))})})},init:function(){var e=this;this.pages=this.options.pages?this.options.pages:Math.ceil(this.options.items/this.options.itemsOnPage)?Math.ceil(this.options.items/this.options.itemsOnPage):1,this.currentPage=this.options.currentPage,this.halfDisplayed=this.options.displayedPages/2,this.on("click","a[data-page]",function(i){i.preventDefault(),e.selectPage(t.$(this).data("page"))}),this._render()},_getInterval:function(){return{start:Math.ceil(this.currentPage>this.halfDisplayed?Math.max(Math.min(this.currentPage-this.halfDisplayed,this.pages-this.options.displayedPages),0):0),end:Math.ceil(this.currentPage>this.halfDisplayed?Math.min(this.currentPage+this.halfDisplayed,this.pages):Math.min(this.options.displayedPages,this.pages))}},render:function(t){this.pages=t?t:this.pages,this._render()},selectPage:function(t,e){this.currentPage=t,this.render(e),this.options.onSelectPage.apply(this,[t]),this.trigger("select.uk.pagination",[t,this])},_render:function(){var t,e=this.options,i=this._getInterval();if(this.element.empty(),e.lblPrev&&this._append(this.currentPage-1,{text:e.lblPrev}),i.start>0&&e.edges>0){var s=Math.min(e.edges,i.start);for(t=0;s>t;t++)this._append(t);e.edges<i.start&&i.start-e.edges!=1?this.element.append("<li><span>...</span></li>"):i.start-e.edges==1&&this._append(e.edges)}for(t=i.start;t<i.end;t++)this._append(t);if(i.end<this.pages&&e.edges>0){this.pages-e.edges>i.end&&this.pages-e.edges-i.end!=1?this.element.append("<li><span>...</span></li>"):this.pages-e.edges-i.end==1&&this._append(i.end++);var a=Math.max(this.pages-e.edges,i.end);for(t=a;t<this.pages;t++)this._append(t)}e.lblNext&&this._append(this.currentPage+1,{text:e.lblNext})},_append:function(e,i){var s,a;e=0>e?0:e<this.pages?e:this.pages-1,a=t.$.extend({text:e+1},i),s=e==this.currentPage?'<li class="uk-active"><span>'+a.text+"</span></li>":'<li><a href="#page-'+(e+1)+'" data-page="'+e+'">'+a.text+"</a></li>",this.element.append(s)}}),t.pagination});

View File

@ -0,0 +1,462 @@
/*! UIkit 2.27.4 | http://www.getuikit.com | (c) 2014 YOOtheme | MIT License */
(function(addon) {
var component;
if (window.UIkit2) {
component = addon(UIkit2);
}
if (typeof define == 'function' && define.amd) {
define('uikit-parallax', ['uikit'], function(){
return component || addon(UIkit2);
});
}
})(function(UI){
"use strict";
var parallaxes = [],
supports3d = false,
scrolltop = 0,
wh = window.innerHeight,
checkParallaxes = function() {
scrolltop = UI.$win.scrollTop();
window.requestAnimationFrame(function(){
for (var i=0; i < parallaxes.length; i++) {
parallaxes[i].process();
}
});
};
UI.component('parallax', {
defaults: {
velocity : 0.5,
target : false,
viewport : false,
media : false
},
boot: function() {
supports3d = (function(){
var el = document.createElement('div'),
has3d,
transforms = {
'WebkitTransform':'-webkit-transform',
'MSTransform':'-ms-transform',
'MozTransform':'-moz-transform',
'Transform':'transform'
};
// Add it to the body to get the computed style.
document.body.insertBefore(el, null);
for (var t in transforms) {
if (el.style[t] !== undefined) {
el.style[t] = 'translate3d(1px,1px,1px)';
has3d = window.getComputedStyle(el).getPropertyValue(transforms[t]);
}
}
document.body.removeChild(el);
return (has3d !== undefined && has3d.length > 0 && has3d !== "none");
})();
// listen to scroll and resize
UI.$doc.on('scrolling.uk.document', checkParallaxes);
UI.$win.on('load resize orientationchange', UI.Utils.debounce(function(){
wh = window.innerHeight;
checkParallaxes();
}, 50));
// init code
UI.ready(function(context) {
UI.$('[data-uk-parallax]', context).each(function() {
var parallax = UI.$(this);
if (!parallax.data('parallax')) {
UI.parallax(parallax, UI.Utils.options(parallax.attr('data-uk-parallax')));
}
});
});
},
init: function() {
this.base = this.options.target ? UI.$(this.options.target) : this.element;
this.props = {};
this.velocity = (this.options.velocity || 1);
var reserved = ['target','velocity','viewport','plugins','media'];
Object.keys(this.options).forEach(function(prop){
if (reserved.indexOf(prop) !== -1) {
return;
}
var start, end, dir, diff, startend = String(this.options[prop]).split(',');
if (prop.match(/color/i)) {
start = startend[1] ? startend[0] : this._getStartValue(prop),
end = startend[1] ? startend[1] : startend[0];
if (!start) {
start = 'rgba(255,255,255,0)';
}
} else {
start = parseFloat(startend[1] ? startend[0] : this._getStartValue(prop)),
end = parseFloat(startend[1] ? startend[1] : startend[0]);
diff = (start < end ? (end-start):(start-end));
dir = (start < end ? 1:-1);
}
this.props[prop] = { start: start, end: end, dir: dir, diff: diff };
}.bind(this));
parallaxes.push(this);
},
process: function() {
if (this.options.media) {
switch(typeof(this.options.media)) {
case 'number':
if (window.innerWidth < this.options.media) {
return false;
}
break;
case 'string':
if (window.matchMedia && !window.matchMedia(this.options.media).matches) {
return false;
}
break;
}
}
var percent = this.percentageInViewport();
if (this.options.viewport !== false) {
percent = (this.options.viewport === 0) ? 1 : percent / this.options.viewport;
}
this.update(percent);
},
percentageInViewport: function() {
var top = this.base.offset().top,
height = this.base.outerHeight(),
distance, percentage, percent;
if (top > (scrolltop + wh)) {
percent = 0;
} else if ((top + height) < scrolltop) {
percent = 1;
} else {
if ((top + height) < wh) {
percent = (scrolltop < wh ? scrolltop : scrolltop - wh) / (top+height);
} else {
distance = (scrolltop + wh) - top;
percentage = Math.round(distance / ((wh + height) / 100));
percent = percentage/100;
}
}
return percent;
},
update: function(percent) {
var $this = this,
css = {transform:'', filter:''},
compercent = percent * (1 - (this.velocity - (this.velocity * percent))),
opts, val;
if (compercent < 0) compercent = 0;
if (compercent > 1) compercent = 1;
if (this._percent !== undefined && this._percent == compercent) {
return;
}
Object.keys(this.props).forEach(function(prop) {
opts = this.props[prop];
if (percent === 0) {
val = opts.start;
} else if(percent === 1) {
val = opts.end;
} else if(opts.diff !== undefined) {
val = opts.start + (opts.diff * compercent * opts.dir);
}
if ((prop == 'bg' || prop == 'bgp') && !this._bgcover) {
this._bgcover = initBgImageParallax(this, prop, opts);
}
switch(prop) {
// transforms
case 'x':
css.transform += supports3d ? ' translate3d('+val+'px, 0, 0)':' translateX('+val+'px)';
break;
case 'xp':
css.transform += supports3d ? ' translate3d('+val+'%, 0, 0)':' translateX('+val+'%)';
break;
case 'y':
css.transform += supports3d ? ' translate3d(0, '+val+'px, 0)':' translateY('+val+'px)';
break;
case 'yp':
css.transform += supports3d ? ' translate3d(0, '+val+'%, 0)':' translateY('+val+'%)';
break;
case 'rotate':
css.transform += ' rotate('+val+'deg)';
break;
case 'scale':
css.transform += ' scale('+val+')';
break;
// bg image
case 'bg':
// don't move if image height is too small
// if ($this.element.data('bgsize') && ($this.element.data('bgsize').h + val - window.innerHeight) < 0) {
// break;
// }
css['background-position'] = '50% '+val+'px';
break;
case 'bgp':
css['background-position'] = '50% '+val+'%';
break;
// color
case 'color':
case 'background-color':
case 'border-color':
css[prop] = calcColor(opts.start, opts.end, compercent);
break;
// CSS Filter
case 'blur':
css.filter += ' blur('+val+'px)';
break;
case 'hue':
css.filter += ' hue-rotate('+val+'deg)';
break;
case 'grayscale':
css.filter += ' grayscale('+val+'%)';
break;
case 'invert':
css.filter += ' invert('+val+'%)';
break;
case 'fopacity':
css.filter += ' opacity('+val+'%)';
break;
case 'saturate':
css.filter += ' saturate('+val+'%)';
break;
case 'sepia':
css.filter += ' sepia('+val+'%)';
break;
default:
css[prop] = val;
break;
}
}.bind(this));
if (css.filter) {
css['-webkit-filter'] = css.filter;
}
this.element.css(css);
this._percent = compercent;
},
_getStartValue: function(prop) {
var value = 0;
switch(prop) {
case 'scale':
value = 1;
break;
default:
value = this.element.css(prop);
}
return (value || 0);
}
});
// helper
function initBgImageParallax(obj, prop, opts) {
var img = new Image(), url, element, size, check, ratio, width, height;
element = obj.element.css({backgroundSize: 'cover', backgroundRepeat: 'no-repeat'});
url = element.css('background-image').replace(/^url\(/g, '').replace(/\)$/g, '').replace(/("|')/g, '');
check = function() {
var w = element.innerWidth(), h = element.innerHeight(), extra = (prop=='bg') ? opts.diff : (opts.diff/100) * h;
h += extra;
w += Math.ceil(extra * ratio);
if (w-extra < size.w && h < size.h) {
return obj.element.css({backgroundSize: 'auto'});
}
// if element height < parent height (gap underneath)
if ((w / ratio) < h) {
width = Math.ceil(h * ratio);
height = h;
if (h > window.innerHeight) {
width = width * 1.2;
height = height * 1.2;
}
// element width < parent width (gap to right)
} else {
width = w;
height = Math.ceil(w / ratio);
}
element.css({backgroundSize: (width+'px '+height+'px')}).data('bgsize', {w:width,h:height});
};
img.onerror = function(){
// image url doesn't exist
};
img.onload = function(){
size = {w:img.width, h:img.height};
ratio = img.width / img.height;
UI.$win.on('load resize orientationchange', UI.Utils.debounce(function(){
check();
}, 50));
check();
};
img.src = url;
return true;
}
// Some named colors to work with, added by Bradley Ayers
// From Interface by Stefan Petre
// http://interface.eyecon.ro/
var colors = {
'black': [0,0,0,1],
'blue': [0,0,255,1],
'brown': [165,42,42,1],
'cyan': [0,255,255,1],
'fuchsia': [255,0,255,1],
'gold': [255,215,0,1],
'green': [0,128,0,1],
'indigo': [75,0,130,1],
'khaki': [240,230,140,1],
'lime': [0,255,0,1],
'magenta': [255,0,255,1],
'maroon': [128,0,0,1],
'navy': [0,0,128,1],
'olive': [128,128,0,1],
'orange': [255,165,0,1],
'pink': [255,192,203,1],
'purple': [128,0,128,1],
'violet': [128,0,128,1],
'red': [255,0,0,1],
'silver': [192,192,192,1],
'white': [255,255,255,1],
'yellow': [255,255,0,1],
'transparent': [255,255,255,0]
};
function calcColor(start, end, pos) {
start = parseColor(start);
end = parseColor(end);
pos = pos || 0;
return calculateColor(start, end, pos);
}
/**!
* @preserve Color animation 1.6.0
* http://www.bitstorm.org/jquery/color-animation/
* Copyright 2011, 2013 Edwin Martin <edwin@bitstorm.org>
* Released under the MIT and GPL licenses.
*/
// Calculate an in-between color. Returns "#aabbcc"-like string.
function calculateColor(begin, end, pos) {
var color = 'rgba('
+ parseInt((begin[0] + pos * (end[0] - begin[0])), 10) + ','
+ parseInt((begin[1] + pos * (end[1] - begin[1])), 10) + ','
+ parseInt((begin[2] + pos * (end[2] - begin[2])), 10) + ','
+ (begin && end ? parseFloat(begin[3] + pos * (end[3] - begin[3])) : 1);
color += ')';
return color;
}
// Parse an CSS-syntax color. Outputs an array [r, g, b]
function parseColor(color) {
var match, quadruplet;
// Match #aabbcc
if (match = /#([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})/.exec(color)) {
quadruplet = [parseInt(match[1], 16), parseInt(match[2], 16), parseInt(match[3], 16), 1];
// Match #abc
} else if (match = /#([0-9a-fA-F])([0-9a-fA-F])([0-9a-fA-F])/.exec(color)) {
quadruplet = [parseInt(match[1], 16) * 17, parseInt(match[2], 16) * 17, parseInt(match[3], 16) * 17, 1];
// Match rgb(n, n, n)
} else if (match = /rgb\(\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*\)/.exec(color)) {
quadruplet = [parseInt(match[1]), parseInt(match[2]), parseInt(match[3]), 1];
} else if (match = /rgba\(\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*,\s*([0-9\.]*)\s*\)/.exec(color)) {
quadruplet = [parseInt(match[1], 10), parseInt(match[2], 10), parseInt(match[3], 10),parseFloat(match[4])];
// No browser returns rgb(n%, n%, n%), so little reason to support this format.
} else {
quadruplet = colors[color] || [255,255,255,0];
}
return quadruplet;
}
return UI.parallax;
});

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,92 @@
/*! UIkit 2.27.4 | http://www.getuikit.com | (c) 2014 YOOtheme | MIT License */
(function(addon) {
var component;
if (window.UIkit2) {
component = addon(UIkit2);
}
if (typeof define == 'function' && define.amd) {
define('uikit-search', ['uikit'], function(){
return component || addon(UIkit2);
});
}
})(function(UI){
"use strict";
UI.component('search', {
defaults: {
msgResultsHeader : 'Search Results',
msgMoreResults : 'More Results',
msgNoResults : 'No results found',
template : '<ul class="uk-nav uk-nav-search uk-autocomplete-results">\
{{#msgResultsHeader}}<li class="uk-nav-header uk-skip">{{msgResultsHeader}}</li>{{/msgResultsHeader}}\
{{#items && items.length}}\
{{~items}}\
<li data-url="{{!$item.url}}">\
<a href="{{!$item.url}}">\
{{{$item.title}}}\
{{#$item.text}}<div>{{{$item.text}}}</div>{{/$item.text}}\
</a>\
</li>\
{{/items}}\
{{#msgMoreResults}}\
<li class="uk-nav-divider uk-skip"></li>\
<li class="uk-search-moreresults" data-moreresults="true"><a href="#" onclick="jQuery(this).closest(\'form\').submit();">{{msgMoreResults}}</a></li>\
{{/msgMoreResults}}\
{{/end}}\
{{^items.length}}\
{{#msgNoResults}}<li class="uk-skip"><a>{{msgNoResults}}</a></li>{{/msgNoResults}}\
{{/end}}\
</ul>',
renderer: function(data) {
var opts = this.options;
this.dropdown.append(this.template({items:data.results || [], msgResultsHeader:opts.msgResultsHeader, msgMoreResults: opts.msgMoreResults, msgNoResults: opts.msgNoResults}));
this.show();
}
},
boot: function() {
// init code
UI.$html.on('focus.search.uikit', '[data-uk-search]', function(e) {
var ele =UI.$(this);
if (!ele.data('search')) {
UI.search(ele, UI.Utils.options(ele.attr('data-uk-search')));
}
});
},
init: function() {
var $this = this;
this.autocomplete = UI.autocomplete(this.element, this.options);
this.autocomplete.dropdown.addClass('uk-dropdown-search');
this.autocomplete.input.on("keyup", function(){
$this.element[$this.autocomplete.input.val() ? 'addClass':'removeClass']('uk-active');
}).closest("form").on("reset", function(){
$this.value = '';
$this.element.removeClass('uk-active');
});
this.on('selectitem.uk.autocomplete', function(e, data) {
if (data.url) {
location.href = data.url;
} else if(data.moreresults) {
$this.autocomplete.input.closest('form').submit();
}
});
this.element.data('search', this);
}
});
});

View File

@ -0,0 +1,2 @@
/*! UIkit 2.27.4 | http://www.getuikit.com | (c) 2014 YOOtheme | MIT License */
!function(e){var s;window.UIkit2&&(s=e(UIkit2)),"function"==typeof define&&define.amd&&define("uikit-search",["uikit"],function(){return s||e(UIkit2)})}(function(e){"use strict";e.component("search",{defaults:{msgResultsHeader:"Search Results",msgMoreResults:"More Results",msgNoResults:"No results found",template:'<ul class="uk-nav uk-nav-search uk-autocomplete-results"> {{#msgResultsHeader}}<li class="uk-nav-header uk-skip">{{msgResultsHeader}}</li>{{/msgResultsHeader}} {{#items && items.length}} {{~items}} <li data-url="{{!$item.url}}"> <a href="{{!$item.url}}"> {{{$item.title}}} {{#$item.text}}<div>{{{$item.text}}}</div>{{/$item.text}} </a> </li> {{/items}} {{#msgMoreResults}} <li class="uk-nav-divider uk-skip"></li> <li class="uk-search-moreresults" data-moreresults="true"><a href="#" onclick="jQuery(this).closest(\'form\').submit();">{{msgMoreResults}}</a></li> {{/msgMoreResults}} {{/end}} {{^items.length}} {{#msgNoResults}}<li class="uk-skip"><a>{{msgNoResults}}</a></li>{{/msgNoResults}} {{/end}} </ul>',renderer:function(e){var s=this.options;this.dropdown.append(this.template({items:e.results||[],msgResultsHeader:s.msgResultsHeader,msgMoreResults:s.msgMoreResults,msgNoResults:s.msgNoResults})),this.show()}},boot:function(){e.$html.on("focus.search.uikit","[data-uk-search]",function(){var s=e.$(this);s.data("search")||e.search(s,e.Utils.options(s.attr("data-uk-search")))})},init:function(){var s=this;this.autocomplete=e.autocomplete(this.element,this.options),this.autocomplete.dropdown.addClass("uk-dropdown-search"),this.autocomplete.input.on("keyup",function(){s.element[s.autocomplete.input.val()?"addClass":"removeClass"]("uk-active")}).closest("form").on("reset",function(){s.value="",s.element.removeClass("uk-active")}),this.on("selectitem.uk.autocomplete",function(e,t){t.url?location.href=t.url:t.moreresults&&s.autocomplete.input.closest("form").submit()}),this.element.data("search",this)}})});

View File

@ -0,0 +1,552 @@
/*! UIkit 2.27.4 | http://www.getuikit.com | (c) 2014 YOOtheme | MIT License */
(function(addon) {
var component;
if (window.UIkit2) {
component = addon(UIkit2);
}
if (typeof define == 'function' && define.amd) {
define('uikit-slider', ['uikit'], function(){
return component || addon(UIkit2);
});
}
})(function(UI){
"use strict";
var dragging, delayIdle, anchor, dragged, store = {};
UI.component('slider', {
defaults: {
center : false,
threshold : 10,
infinite : true,
autoplay : false,
autoplayInterval : 7000,
pauseOnHover : true,
activecls : 'uk-active'
},
boot: function() {
// init code
UI.ready(function(context) {
setTimeout(function(){
UI.$('[data-uk-slider]', context).each(function(){
var ele = UI.$(this);
if (!ele.data('slider')) {
UI.slider(ele, UI.Utils.options(ele.attr('data-uk-slider')));
}
});
}, 0);
});
},
init: function() {
var $this = this;
this.container = this.element.find('.uk-slider');
this.focus = 0;
UI.$win.on('resize load', UI.Utils.debounce(function() {
$this.update(true);
}, 100));
this.on('click.uk.slider', '[data-uk-slider-item]', function(e) {
e.preventDefault();
var item = UI.$(this).attr('data-uk-slider-item');
if ($this.focus == item) return;
// stop autoplay
$this.stop();
switch(item) {
case 'next':
case 'previous':
$this[item=='next' ? 'next':'previous']();
break;
default:
$this.updateFocus(parseInt(item, 10));
}
});
this.container.on({
'touchstart mousedown': function(evt) {
if (evt.originalEvent && evt.originalEvent.touches) {
evt = evt.originalEvent.touches[0];
}
// ignore right click button
if (evt.button && evt.button==2 || !$this.active) {
return;
}
// stop autoplay
$this.stop();
anchor = UI.$(evt.target).is('a') ? UI.$(evt.target) : UI.$(evt.target).parents('a:first');
dragged = false;
if (anchor.length) {
anchor.one('click', function(e){
if (dragged) e.preventDefault();
});
}
delayIdle = function(e) {
dragged = true;
dragging = $this;
store = {
touchx : parseInt(e.pageX, 10),
dir : 1,
focus : $this.focus,
base : $this.options.center ? 'center':'area'
};
if (e.originalEvent && e.originalEvent.touches) {
e = e.originalEvent.touches[0];
}
dragging.element.data({
'pointer-start': {x: parseInt(e.pageX, 10), y: parseInt(e.pageY, 10)},
'pointer-pos-start': $this.pos
});
$this.container.addClass('uk-drag');
delayIdle = false;
};
delayIdle.x = parseInt(evt.pageX, 10);
delayIdle.threshold = $this.options.threshold;
},
mouseenter: function() { if ($this.options.pauseOnHover) $this.hovering = true; },
mouseleave: function() { $this.hovering = false; }
});
this.update(true);
this.on('display.uk.check', function(){
if ($this.element.is(":visible")) {
$this.update(true);
}
});
// prevent dragging links + images
this.element.find('a,img').attr('draggable', 'false');
// Set autoplay
if (this.options.autoplay) {
this.start();
}
UI.domObserve(this.element, function(e) {
if ($this.element.children(':not([data-slider-slide])').length) {
$this.update(true);
}
});
},
update: function(focus) {
var $this = this, pos = 0, maxheight = 0, item, width, cwidth, size;
this.items = this.container.children().filter(':visible');
this.vp = this.element[0].getBoundingClientRect().width;
this.container.css({'min-width': '', 'min-height': ''});
this.items.each(function(idx){
item = UI.$(this).attr('data-slider-slide', idx);
size = item.css({'left': '', 'width':''})[0].getBoundingClientRect();
width = size.width;
cwidth = item.width();
maxheight = Math.max(maxheight, size.height);
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))});
pos += width;
});
this.container.css({'min-width': pos, 'min-height': maxheight});
if (this.options.infinite && (pos <= (2*this.vp) || this.items.length < 5) && !this.itemsResized) {
// fill with cloned items
this.container.children().each(function(idx){
$this.container.append($this.items.eq(idx).clone(true).attr('id', ''));
}).each(function(idx){
$this.container.append($this.items.eq(idx).clone(true).attr('id', ''));
});
this.itemsResized = true;
return this.update();
}
this.cw = pos;
this.pos = 0;
this.active = pos >= this.vp;
this.container.css({
'-ms-transform': '',
'-webkit-transform': '',
'transform': ''
});
if (focus) this.updateFocus(this.focus);
},
updatePos: function(pos) {
this.pos = pos;
this.container.css({
'-ms-transform': 'translateX('+pos+'px)',
'-webkit-transform': 'translateX('+pos+'px)',
'transform': 'translateX('+pos+'px)'
});
},
updateFocus: function(idx, dir) {
if (!this.active) {
return;
}
dir = dir || (idx > this.focus ? 1:-1);
var item = this.items.eq(idx), area, i;
if (this.options.infinite) {
this.infinite(idx, dir);
}
if (this.options.center) {
this.updatePos(item.data('center')*-1);
this.items.filter('.'+this.options.activecls).removeClass(this.options.activecls);
item.addClass(this.options.activecls);
} else {
if (this.options.infinite) {
this.updatePos(item.data('left')*-1);
} else {
area = 0;
for (i=idx;i<this.items.length;i++) {
area += this.items.eq(i).data('width');
}
if (area > this.vp) {
this.updatePos(item.data('left')*-1);
} else {
if (dir == 1) {
area = 0;
for (i=this.items.length-1;i>=0;i--) {
area += this.items.eq(i).data('width');
if (area == this.vp) {
idx = i;
break;
}
if (area > this.vp) {
idx = (i < this.items.length-1) ? i+1 : i;
break;
}
}
if (area > this.vp) {
this.updatePos((this.container.width() - this.vp) * -1);
} else {
this.updatePos(this.items.eq(idx).data('left')*-1);
}
}
}
}
}
// mark elements
var left = this.items.eq(idx).data('left');
this.items.removeClass('uk-slide-before uk-slide-after').each(function(i){
if (i!==idx) {
UI.$(this).addClass(UI.$(this).data('left') < left ? 'uk-slide-before':'uk-slide-after');
}
});
this.focus = idx;
this.trigger('focusitem.uk.slider', [idx,this.items.eq(idx),this]);
},
next: function() {
var focus = this.items[this.focus + 1] ? (this.focus + 1) : (this.options.infinite ? 0:this.focus);
this.updateFocus(focus, 1);
},
previous: function() {
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);
this.updateFocus(focus, -1);
},
start: function() {
this.stop();
var $this = this;
this.interval = setInterval(function() {
if (!$this.hovering) $this.next();
}, this.options.autoplayInterval);
},
stop: function() {
if (this.interval) clearInterval(this.interval);
},
infinite: function(baseidx, direction) {
var $this = this, item = this.items.eq(baseidx), i, z = baseidx, move = [], area = 0;
if (direction == 1) {
for (i=0;i<this.items.length;i++) {
if (z != baseidx) {
area += this.items.eq(z).data('width');
move.push(this.items.eq(z));
}
if (area > this.vp) {
break;
}
z = z+1 == this.items.length ? 0:z+1;
}
if (move.length) {
move.forEach(function(itm){
var left = item.data('area');
itm.css({'left': left}).data({
left : left,
area : (left+itm.data('width')),
center: (left - ($this.vp/2 - itm.data('cwidth')/2))
});
item = itm;
});
}
} else {
for (i=this.items.length-1;i >-1 ;i--) {
area += this.items.eq(z).data('width');
if (z != baseidx) {
move.push(this.items.eq(z));
}
if (area > this.vp) {
break;
}
z = z-1 == -1 ? this.items.length-1:z-1;
}
if (move.length) {
move.forEach(function(itm){
var left = item.data('left') - itm.data('width');
itm.css({'left': left}).data({
left : left,
area : (left+itm.data('width')),
center: (left - ($this.vp/2 - itm.data('cwidth')/2))
});
item = itm;
});
}
}
}
});
// handle dragging
UI.$doc.on('mousemove.uk.slider touchmove.uk.slider', function(e) {
if (e.originalEvent && e.originalEvent.touches) {
e = e.originalEvent.touches[0];
}
if (delayIdle && Math.abs(e.pageX - delayIdle.x) > delayIdle.threshold) {
if (!window.getSelection().toString()) {
delayIdle(e);
} else {
dragging = delayIdle = false;
}
}
if (!dragging) {
return;
}
var x, xDiff, pos, dir, focus, item, next, diff, i, z, itm;
if (e.clientX || e.clientY) {
x = e.clientX;
} else if (e.pageX || e.pageY) {
x = e.pageX - document.body.scrollLeft - document.documentElement.scrollLeft;
}
focus = store.focus;
xDiff = x - dragging.element.data('pointer-start').x;
pos = dragging.element.data('pointer-pos-start') + xDiff;
dir = x > dragging.element.data('pointer-start').x ? -1:1;
item = dragging.items.eq(store.focus);
if (dir == 1) {
diff = item.data('left') + Math.abs(xDiff);
for (i=0,z=store.focus;i<dragging.items.length;i++) {
itm = dragging.items.eq(z);
if (z != store.focus && itm.data('left') < diff && itm.data('area') > diff) {
focus = z;
break;
}
z = z+1 == dragging.items.length ? 0:z+1;
}
} else {
diff = item.data('left') - Math.abs(xDiff);
for (i=0,z=store.focus;i<dragging.items.length;i++) {
itm = dragging.items.eq(z);
if (z != store.focus && itm.data('area') <= item.data('left') && itm.data('center') < diff) {
focus = z;
break;
}
z = z-1 == -1 ? dragging.items.length-1:z-1;
}
}
if (dragging.options.infinite && focus!=store._focus) {
dragging.infinite(focus, dir);
}
dragging.updatePos(pos);
store.dir = dir;
store._focus = focus;
store.touchx = parseInt(e.pageX, 10);
store.diff = diff;
});
UI.$doc.on('mouseup.uk.slider touchend.uk.slider', function(e) {
if (dragging) {
dragging.container.removeClass('uk-drag');
// TODO is this needed?
dragging.items.eq(store.focus);
var itm, focus = false, i, z;
if (store.dir == 1) {
for (i=0,z=store.focus;i<dragging.items.length;i++) {
itm = dragging.items.eq(z);
if (z != store.focus && itm.data('left') > store.diff) {
focus = z;
break;
}
z = z+1 == dragging.items.length ? 0:z+1;
}
if (!dragging.options.infinite && !focus) {
focus = dragging.items.length;
}
} else {
for (i=0,z=store.focus;i<dragging.items.length;i++) {
itm = dragging.items.eq(z);
if (z != store.focus && itm.data('left') < store.diff) {
focus = z;
break;
}
z = z-1 == -1 ? dragging.items.length-1:z-1;
}
if (!dragging.options.infinite && !focus) {
focus = 0
}
}
dragging.updateFocus(focus!==false ? focus:store._focus);
}
dragging = delayIdle = false;
});
return UI.slider;
});

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,523 @@
/*! UIkit 2.27.4 | http://www.getuikit.com | (c) 2014 YOOtheme | MIT License */
(function(addon) {
var component;
if (window.UIkit2) {
component = addon(UIkit2);
}
if (typeof define == 'function' && define.amd) {
define('uikit-slideset', ['uikit'], function(){
return component || addon(UIkit2);
});
}
})(function(UI){
"use strict";
var Animations;
UI.component('slideset', {
defaults: {
default : 1,
animation : 'fade',
duration : 200,
filter : '',
delay : false,
controls : false,
autoplay : false,
autoplayInterval : 7000,
pauseOnHover : true
},
sets: [],
boot: function() {
// auto init
UI.ready(function(context) {
UI.$('[data-uk-slideset]', context).each(function(){
var ele = UI.$(this);
if(!ele.data('slideset')) {
UI.slideset(ele, UI.Utils.options(ele.attr('data-uk-slideset')));
}
});
});
},
init: function() {
var $this = this;
this.activeSet = false;
this.list = this.element.find('.uk-slideset');
this.nav = this.element.find('.uk-slideset-nav');
this.controls = this.options.controls ? UI.$(this.options.controls) : this.element;
UI.$win.on('resize load', UI.Utils.debounce(function() {
$this.update();
}, 100));
$this.list.addClass('uk-grid-width-1-'+$this.options.default);
['xlarge', 'large', 'medium', 'small'].forEach(function(bp) {
if (!$this.options[bp]) {
return;
}
$this.list.addClass('uk-grid-width-'+bp+'-1-'+$this.options[bp]);
});
this.on('click.uk.slideset', '[data-uk-slideset-item]', function(e) {
e.preventDefault();
if ($this.animating) {
return;
}
var set = UI.$(this).attr('data-uk-slideset-item');
if ($this.activeSet === set) return;
switch(set) {
case 'next':
case 'previous':
$this[set=='next' ? 'next':'previous']();
break;
default:
$this.show(parseInt(set, 10));
}
});
this.controls.on('click.uk.slideset', '[data-uk-filter]', function(e) {
var ele = UI.$(this);
if (ele.parent().hasClass('uk-slideset')) {
return;
}
e.preventDefault();
if ($this.animating || $this.currentFilter == ele.attr('data-uk-filter')) {
return;
}
$this.updateFilter(ele.attr('data-uk-filter'));
$this._hide().then(function(){
$this.update(true, true);
});
});
this.on('swipeRight swipeLeft', function(e) {
$this[e.type=='swipeLeft' ? 'next' : 'previous']();
});
this.updateFilter(this.options.filter);
this.update();
this.element.on({
mouseenter: function() { if ($this.options.pauseOnHover) $this.hovering = true; },
mouseleave: function() { $this.hovering = false; }
});
// Set autoplay
if (this.options.autoplay) {
this.start();
}
UI.domObserve(this.list, function(e) {
if ($this.list.children(':visible:not(.uk-active)').length) {
$this.update(false,true);
}
});
},
update: function(animate, force) {
var visible = this.visible, i;
this.visible = this.getVisibleOnCurrenBreakpoint();
if (visible == this.visible && !force) {
return;
}
this.children = this.list.children().hide();
this.items = this.getItems();
this.sets = array_chunk(this.items, this.visible);
for (i=0;i<this.sets.length;i++) {
this.sets[i].css({'display': 'none'});
}
// update nav
if (this.nav.length && this.nav.empty()) {
for (i=0;i<this.sets.length;i++) {
this.nav.append('<li data-uk-slideset-item="'+i+'"><a></a></li>');
}
this.nav[this.nav.children().length==1 ? 'addClass':'removeClass']('uk-invisible');
}
this.activeSet = false;
this.show(0, !animate);
},
updateFilter: function(currentfilter) {
var $this = this, filter;
this.currentFilter = currentfilter;
this.controls.find('[data-uk-filter]').each(function(){
filter = UI.$(this);
if (!filter.parent().hasClass('uk-slideset')) {
if (filter.attr('data-uk-filter') == $this.currentFilter) {
filter.addClass('uk-active');
} else {
filter.removeClass('uk-active');
}
}
});
},
getVisibleOnCurrenBreakpoint: function() {
var breakpoint = null,
tmp = UI.$('<div style="position:absolute;height:1px;top:-1000px;width:100px"><div></div></div>').appendTo('body'),
testdiv = tmp.children().eq(0),
breakpoints = this.options;
['xlarge', 'large', 'medium', 'small'].forEach(function(bp) {
if (!breakpoints[bp] || breakpoint) {
return;
}
tmp.attr('class', 'uk-grid-width-'+bp+'-1-2').width();
if (testdiv.width() == 50) {
breakpoint = bp;
}
});
tmp.remove();
return this.options[breakpoint] || this.options['default'];
},
getItems: function() {
var items = [], filter;
if (this.currentFilter) {
filter = this.currentFilter || [];
if (typeof(filter) === 'string') {
filter = filter.split(/,/).map(function(item){ return item.trim(); });
}
this.children.each(function(index){
var ele = UI.$(this), f = ele.attr('data-uk-filter'), infilter = filter.length ? false : true;
if (f) {
f = f.split(/,/).map(function(item){ return item.trim(); });
filter.forEach(function(item){
if (f.indexOf(item) > -1) infilter = true;
});
}
if(infilter) items.push(ele[0]);
});
items = UI.$(items);
} else {
items = this.list.children();
}
return items;
},
show: function(setIndex, noanimate, dir) {
var $this = this;
if (this.activeSet === setIndex || this.animating) {
return;
}
dir = dir || (setIndex < this.activeSet ? -1:1);
var current = this.sets[this.activeSet] || [],
next = this.sets[setIndex],
animation = this._getAnimation();
if (noanimate || !UI.support.animation) {
animation = Animations.none;
}
this.animating = true;
if (this.nav.length) {
this.nav.children().removeClass('uk-active').eq(setIndex).addClass('uk-active');
}
animation.apply($this, [current, next, dir]).then(function(){
UI.Utils.checkDisplay(next, true);
$this.children.hide().removeClass('uk-active');
next.addClass('uk-active').css({'display': '', 'opacity':''});
$this.animating = false;
$this.activeSet = setIndex;
UI.Utils.checkDisplay(next, true);
$this.trigger('show.uk.slideset', [next]);
});
},
_getAnimation: function() {
var animation = Animations[this.options.animation] || Animations.none;
if (!UI.support.animation) {
animation = Animations.none;
}
return animation;
},
_hide: function() {
var $this = this,
current = this.sets[this.activeSet] || [],
animation = this._getAnimation();
this.animating = true;
return animation.apply($this, [current, [], 1]).then(function(){
$this.animating = false;
});
},
next: function() {
this.show(this.sets[this.activeSet + 1] ? (this.activeSet + 1) : 0, false, 1);
},
previous: function() {
this.show(this.sets[this.activeSet - 1] ? (this.activeSet - 1) : (this.sets.length - 1), false, -1);
},
start: function() {
this.stop();
var $this = this;
this.interval = setInterval(function() {
if (!$this.hovering && !$this.animating) $this.next();
}, this.options.autoplayInterval);
},
stop: function() {
if (this.interval) clearInterval(this.interval);
}
});
Animations = {
'none': function() {
var d = UI.$.Deferred();
d.resolve();
return d.promise();
},
'fade': function(current, next) {
return coreAnimation.apply(this, ['uk-animation-fade', current, next]);
},
'slide-bottom': function(current, next) {
return coreAnimation.apply(this, ['uk-animation-slide-bottom', current, next]);
},
'slide-top': function(current, next) {
return coreAnimation.apply(this, ['uk-animation-slide-top', current, next]);
},
'slide-vertical': function(current, next, dir) {
var anim = ['uk-animation-slide-top', 'uk-animation-slide-bottom'];
if (dir == -1) {
anim.reverse();
}
return coreAnimation.apply(this, [anim, current, next]);
},
'slide-horizontal': function(current, next, dir) {
var anim = ['uk-animation-slide-right', 'uk-animation-slide-left'];
if (dir == -1) {
anim.reverse();
}
return coreAnimation.apply(this, [anim, current, next, dir]);
},
'scale': function(current, next) {
return coreAnimation.apply(this, ['uk-animation-scale-up', current, next]);
}
};
UI.slideset.animations = Animations;
// helpers
function coreAnimation(cls, current, next, dir) {
var d = UI.$.Deferred(),
delay = (this.options.delay === false) ? Math.floor(this.options.duration/2) : this.options.delay,
$this = this, clsIn, clsOut, release, i;
dir = dir || 1;
this.element.css('min-height', this.element.height());
if (next[0]===current[0]) {
d.resolve();
return d.promise();
}
if (typeof(cls) == 'object') {
clsIn = cls[0];
clsOut = cls[1] || cls[0];
} else {
clsIn = cls;
clsOut = clsIn;
}
UI.$body.css('overflow-x', 'hidden'); // prevent horizontal scrollbar on animation
release = function() {
if (current && current.length) {
current.hide().removeClass(clsOut+' uk-animation-reverse').css({'opacity':'', 'animation-delay': '', 'animation':''});
}
if (!next.length) {
d.resolve();
return;
}
for (i=0;i<next.length;i++) {
next.eq(dir == 1 ? i:(next.length - i)-1).css('animation-delay', (i*delay)+'ms');
}
var finish = function() {
next.removeClass(''+clsIn+'').css({opacity:'', display:'', 'animation-delay':'', 'animation':''});
d.resolve();
UI.$body.css('overflow-x', '');
$this.element.css('min-height', '');
finish = false;
};
next.addClass(clsIn)[dir==1 ? 'last':'first']().one(UI.support.animation.end, function(){
if(finish) finish();
}).end().css('display', '');
// make sure everything resolves really
setTimeout(function() {
if(finish) finish();
}, next.length * delay * 2);
};
if (next.length) {
next.css('animation-duration', this.options.duration+'ms');
}
if (current && current.length) {
current.css('animation-duration', this.options.duration+'ms')[dir==1 ? 'last':'first']().one(UI.support.animation.end, function() {
release();
});
for (i=0;i<current.length;i++) {
(function (index, ele){
setTimeout(function(){
ele.css('display', 'none').css('display', '').css('opacity', 0).on(UI.support.animation.end, function(){
ele.removeClass(clsOut);
}).addClass(clsOut+' uk-animation-reverse');
}.bind(this), i * delay);
})(i, current.eq(dir == 1 ? i:(current.length - i)-1));
}
} else {
release();
}
return d.promise();
}
function array_chunk(input, size) {
var x, i = 0, c = -1, l = input.length || 0, n = [];
if (size < 1) return null;
while (i < l) {
x = i % size;
if(x) {
n[c][x] = input[i];
} else {
n[++c] = [input[i]];
}
i++;
}
i = 0;
l = n.length;
while (i < l) {
n[i] = jQuery(n[i]);
i++;
}
return n;
}
});

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,382 @@
/*! UIkit 2.27.4 | http://www.getuikit.com | (c) 2014 YOOtheme | MIT License */
(function(addon) {
var component;
if (window.UIkit2) {
component = addon(UIkit2);
}
if (typeof define == 'function' && define.amd) {
define('uikit-slideshow-fx', ['uikit'], function() {
return component || addon(UIkit2);
});
}
})(function(UI) {
"use strict";
var Animations = UI.slideshow.animations;
UI.$.extend(UI.slideshow.animations, {
slice: function(current, next, dir, fromfx) {
if (!current.data('cover')) {
return Animations.fade.apply(this, arguments);
}
var d = UI.$.Deferred();
var sliceWidth = Math.ceil(this.element.width() / this.options.slices),
bgimage = next.data('cover').css('background-image'),
ghost = UI.$('<li class="uk-slideshow-ghost"></li>').css({
top : 0,
left : 0,
width : this.container.width(),
height : this.container.height(),
opacity: 1,
zIndex : 15
}),
ghostWidth = ghost.width(),
ghostHeight = ghost.height(),
pos = fromfx == 'slice-up' ? ghostHeight:'0',
bar;
for (var i = 0; i < this.options.slices; i++) {
if (fromfx == 'slice-up-down') {
pos = ((i % 2) + 2) % 2==0 ? '0':ghostHeight;
}
var width = (i == this.options.slices-1) ? sliceWidth : sliceWidth,
clipto = ('rect(0px, '+(width*(i+1))+'px, '+ghostHeight+'px, '+(sliceWidth*i)+'px)'),
clipfrom;
//slice-down - default
clipfrom = ('rect(0px, '+(width*(i+1))+'px, 0px, '+(sliceWidth*i)+'px)');
if (fromfx == 'slice-up' || (fromfx == 'slice-up-down' && ((i % 2) + 2) % 2==0 )) {
clipfrom = ('rect('+ghostHeight+'px, '+(width*(i+1))+'px, '+ghostHeight+'px, '+(sliceWidth*i)+'px)');
}
bar = UI.$('<div class="uk-cover-background"></div>').css({
'position' : 'absolute',
'top' : 0,
'left' : 0,
'width' : ghostWidth,
'height' : ghostHeight,
'background-image' : bgimage,
'clip' : clipfrom,
'opacity' : 0,
'transition' : 'all '+this.options.duration+'ms ease-in-out '+(i*60)+'ms',
'-webkit-transition' : 'all '+this.options.duration+'ms ease-in-out '+(i*60)+'ms'
}).data('clip', clipto);
ghost.append(bar);
}
this.container.append(ghost);
ghost.children().last().on(UI.support.transition.end, function() {
setTimeout(function() {
ghost.remove();
d.resolve();
}, 0);
});
ghost.width();
ghost.children().each(function() {
bar = UI.$(this);
bar.css({ clip: bar.data('clip'), opacity: 1 });
});
return d.promise();
},
'slice-up': function(current, next, dir) {
return Animations.slice.apply(this, [current, next, dir, 'slice-up']);
},
'slice-down': function(current, next, dir) {
return Animations.slice.apply(this, [current, next, dir, 'slice-down']);
},
'slice-up-down': function(current, next, dir) {
return Animations.slice.apply(this, [current, next, dir, 'slice-up-down']);
},
fold: function(current, next, dir) {
if (!next.data('cover')) {
return Animations.fade.apply(this, arguments);
}
var d = UI.$.Deferred();
var sliceWidth = Math.ceil(this.element.width() / this.options.slices),
bgimage = next.data('cover').css('background-image'),
ghost = UI.$('<li class="uk-slideshow-ghost"></li>').css({
width : next.width(),
height : next.height(),
opacity: 1,
zIndex : 15
}),
ghostWidth = next.width(),
ghostHeight = next.height(),
bar;
for (var i = 0; i < this.options.slices; i++) {
bar = UI.$('<div class="uk-cover-background"></div>').css({
'position' : 'absolute',
'top' : 0,
'left' : 0,
'width' : ghostWidth,
'height' : ghostHeight,
'background-image' : bgimage,
'transform-origin' : (sliceWidth*i)+'px 0 0',
'clip' : ('rect(0px, '+(sliceWidth*(i+1))+'px, '+ghostHeight+'px, '+(sliceWidth*i)+'px)'),
'opacity' : 0,
'transform' : 'scaleX(0.000001)',
'transition' : 'all '+this.options.duration+'ms ease-in-out '+(100+i*60)+'ms',
'-webkit-transition' : 'all '+this.options.duration+'ms ease-in-out '+(100+i*60)+'ms'
});
ghost.prepend(bar);
}
this.container.append(ghost);
ghost.width();
ghost.children().first().on(UI.support.transition.end, function() {
setTimeout(function() {
ghost.remove();
d.resolve();
}, 0);
}).end().css({
transform: 'scaleX(1)',
opacity: 1
});
return d.promise();
},
puzzle: function(current, next, dir) {
if (!next.data('cover')) {
return Animations.fade.apply(this, arguments);
}
var d = UI.$.Deferred(), $this = this;
var boxCols = Math.round(this.options.slices/2),
boxWidth = Math.round(next.width()/boxCols),
boxRows = Math.round(next.height()/boxWidth),
boxHeight = Math.round(next.height()/boxRows)+1,
bgimage = next.data('cover').css('background-image'),
ghost = UI.$('<li class="uk-slideshow-ghost"></li>').css({
width : this.container.width(),
height : this.container.height(),
opacity : 1,
zIndex : 15
}),
ghostWidth = this.container.width(),
ghostHeight = this.container.height(),
box, rect, width;
for (var rows = 0; rows < boxRows; rows++) {
for (var cols = 0; cols < boxCols; cols++) {
width = (cols == boxCols-1) ? (boxWidth + 2) : boxWidth;
rect = [
(boxHeight * rows) +'px', // top
(width * (cols+1)) +'px', // right
(boxHeight * (rows + 1)) +'px', // bottom
(boxWidth * cols) +'px' // left
];
box = UI.$('<div class="uk-cover-background"></div>').css({
'position' : 'absolute',
'top' : 0,
'left' : 0,
'opacity' : 0,
'width' : ghostWidth,
'height' : ghostHeight,
'background-image' : bgimage,
'clip' : ('rect('+rect.join(',')+')'),
'-webkit-transform' : 'translateZ(0)', // fixes webkit opacity flickering bug
'transform' : 'translateZ(0)' // fixes moz opacity flickering bug
});
ghost.append(box);
}
}
this.container.append(ghost);
var boxes = shuffle(ghost.children());
boxes.each(function(i) {
UI.$(this).css({
'transition': 'all '+$this.options.duration+'ms ease-in-out '+(50+i*25)+'ms',
'-webkit-transition': 'all '+$this.options.duration+'ms ease-in-out '+(50+i*25)+'ms'
});
}).last().on(UI.support.transition.end, function() {
setTimeout(function() {
ghost.remove();
d.resolve();
}, 0);
});
ghost.width();
boxes.css({opacity: 1});
return d.promise();
},
boxes: function(current, next, dir, fromfx) {
if (!next.data('cover')) {
return Animations.fade.apply(this, arguments);
}
var d = UI.$.Deferred();
var boxCols = Math.round(this.options.slices/2),
boxWidth = Math.round(next.width()/boxCols),
boxRows = Math.round(next.height()/boxWidth),
boxHeight = Math.round(next.height()/boxRows)+1,
bgimage = next.data('cover').css('background-image'),
ghost = UI.$('<li class="uk-slideshow-ghost"></li>').css({
width : next.width(),
height : next.height(),
opacity : 1,
zIndex : 15
}),
ghostWidth = next.width(),
ghostHeight = next.height(),
box, rect, width, cols;
for (var rows = 0; rows < boxRows; rows++) {
for (cols = 0; cols < boxCols; cols++) {
width = (cols == boxCols-1) ? (boxWidth + 2) : boxWidth;
rect = [
(boxHeight * rows) +'px', // top
(width * (cols+1)) +'px', // right
(boxHeight * (rows + 1)) +'px', // bottom
(boxWidth * cols) +'px' // left
];
box = UI.$('<div class="uk-cover-background"></div>').css({
'position' : 'absolute',
'top' : 0,
'left' : 0,
'opacity' : 1,
'width' : ghostWidth,
'height' : ghostHeight,
'background-image' : bgimage,
'transform-origin' : rect[3]+' '+rect[0]+' 0',
'clip' : ('rect('+rect.join(',')+')'),
'-webkit-transform' : 'scale(0.0000000000000001)',
'transform' : 'scale(0.0000000000000001)'
});
ghost.append(box);
}
}
this.container.append(ghost);
var rowIndex = 0, colIndex = 0, timeBuff = 0, box2Darr = [[]], boxes = ghost.children(), prevCol;
if (fromfx == 'boxes-reverse') {
boxes = [].reverse.apply(boxes);
}
boxes.each(function() {
box2Darr[rowIndex][colIndex] = UI.$(this);
colIndex++;
if(colIndex == boxCols) {
rowIndex++;
colIndex = 0;
box2Darr[rowIndex] = [];
}
});
for (cols = 0, prevCol = 0; cols < (boxCols * boxRows); cols++) {
prevCol = cols;
for (var row = 0; row < boxRows; row++) {
if (prevCol >= 0 && prevCol < boxCols) {
box2Darr[row][prevCol].css({
'transition': 'all '+this.options.duration+'ms linear '+(50+timeBuff)+'ms',
'-webkit-transition': 'all '+this.options.duration+'ms linear '+(50+timeBuff)+'ms'
});
}
prevCol--;
}
timeBuff += 100;
}
boxes.last().on(UI.support.transition.end, function() {
setTimeout(function() {
ghost.remove();
d.resolve();
}, 0);
});
ghost.width();
boxes.css({
'-webkit-transform': 'scale(1)',
'transform': 'scale(1)'
});
return d.promise();
},
'boxes-reverse': function(current, next, dir) {
return Animations.boxes.apply(this, [current, next, dir, 'boxes-reverse']);
},
'random-fx': function(){
var animations = ['slice-up', 'fold', 'puzzle', 'slice-down', 'boxes', 'slice-up-down', 'boxes-reverse'];
this.fxIndex = (this.fxIndex === undefined ? -1 : this.fxIndex) + 1;
if (!animations[this.fxIndex]) this.fxIndex = 0;
return Animations[animations[this.fxIndex]].apply(this, arguments);
}
});
// helper functions
// Shuffle an array
var shuffle = function(arr) {
for (var j, x, i = arr.length; i; j = parseInt(Math.random() * i), x = arr[--i], arr[i] = arr[j], arr[j] = x) {}
return arr;
};
return UI.slideshow.animations;
});

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,596 @@
/*! UIkit 2.27.4 | http://www.getuikit.com | (c) 2014 YOOtheme | MIT License */
(function(addon) {
var component;
if (window.UIkit2) {
component = addon(UIkit2);
}
if (typeof define == 'function' && define.amd) {
define('uikit-slideshow', ['uikit'], function() {
return component || addon(UIkit2);
});
}
})(function(UI) {
"use strict";
var Animations, playerId = 0;
UI.component('slideshow', {
defaults: {
animation : 'fade',
duration : 500,
height : 'auto',
start : 0,
autoplay : false,
autoplayInterval : 7000,
videoautoplay : true,
videomute : true,
slices : 15,
pauseOnHover : true,
kenburns : false,
kenburnsanimations : [
'uk-animation-middle-left',
'uk-animation-top-right',
'uk-animation-bottom-left',
'uk-animation-top-center',
'', // middle-center
'uk-animation-bottom-right'
]
},
current : false,
interval : null,
hovering : false,
boot: function() {
// init code
UI.ready(function(context) {
UI.$('[data-uk-slideshow]', context).each(function() {
var slideshow = UI.$(this);
if (!slideshow.data('slideshow')) {
UI.slideshow(slideshow, UI.Utils.options(slideshow.attr('data-uk-slideshow')));
}
});
});
},
init: function() {
var $this = this;
this.container = this.element.hasClass('uk-slideshow') ? this.element : UI.$(this.find('.uk-slideshow:first'));
this.current = this.options.start;
this.animating = false;
this.fixFullscreen = navigator.userAgent.match(/(iPad|iPhone|iPod)/g) && this.container.hasClass('uk-slideshow-fullscreen'); // viewport unit fix for height:100vh - should be fixed in iOS 8
if (this.options.kenburns) {
this.kbanimduration = this.options.kenburns === true ? '15s': this.options.kenburns;
if (!String(this.kbanimduration).match(/(ms|s)$/)) {
this.kbanimduration += 'ms';
}
if (typeof(this.options.kenburnsanimations) == 'string') {
this.options.kenburnsanimations = this.options.kenburnsanimations.split(',');
}
}
this.update();
this.on('click.uk.slideshow', '[data-uk-slideshow-item]', function(e) {
e.preventDefault();
var slide = UI.$(this).attr('data-uk-slideshow-item');
if ($this.current == slide) return;
switch(slide) {
case 'next':
case 'previous':
$this[slide=='next' ? 'next':'previous']();
break;
default:
$this.show(parseInt(slide, 10));
}
$this.stop();
});
UI.$win.on("resize load", UI.Utils.debounce(function() {
$this.resize();
if ($this.fixFullscreen) {
$this.container.css('height', window.innerHeight);
$this.slides.css('height', window.innerHeight);
}
}, 100));
// chrome image load fix
setTimeout(function(){
$this.resize();
}, 80);
// Set autoplay
if (this.options.autoplay) {
this.start();
}
if (this.options.videoautoplay && this.slides.eq(this.current).data('media')) {
this.playmedia(this.slides.eq(this.current).data('media'));
}
if (this.options.kenburns) {
this.applyKenBurns(this.slides.eq(this.current));
}
this.container.on({
mouseenter: function() { if ($this.options.pauseOnHover) $this.hovering = true; },
mouseleave: function() { $this.hovering = false; }
});
this.on('swipeRight swipeLeft', function(e) {
$this[e.type=='swipeLeft' ? 'next' : 'previous']();
});
this.on('display.uk.check', function(){
if ($this.element.is(':visible')) {
$this.resize();
if ($this.fixFullscreen) {
$this.container.css('height', window.innerHeight);
$this.slides.css('height', window.innerHeight);
}
}
});
UI.domObserve(this.element, function(e) {
if ($this.container.children(':not([data-slideshow-slide])').not('.uk-slideshow-ghost').length) {
$this.update(true);
}
});
},
update: function(resize) {
var $this = this, canvas, processed = 0;
this.slides = this.container.children();
this.slidesCount = this.slides.length;
if (!this.slides.eq(this.current).length) {
this.current = 0;
}
this.slides.each(function(index) {
var slide = UI.$(this);
if (slide.data('processed')) {
return;
}
var media = slide.children('img,video,iframe').eq(0), type = 'html';
slide.data('media', media);
slide.data('sizer', media);
if (media.length) {
var placeholder;
type = media[0].nodeName.toLowerCase();
switch(media[0].nodeName) {
case 'IMG':
var cover = UI.$('<div class="uk-cover-background uk-position-cover"></div>').css({'background-image':'url('+ media.attr('src') + ')'});
if (media.attr('width') && media.attr('height')) {
placeholder = UI.$('<canvas></canvas>').attr({width:media.attr('width'), height:media.attr('height')});
media.replaceWith(placeholder);
media = placeholder;
placeholder = undefined;
}
media.css({width: '100%',height: 'auto', opacity:0});
slide.prepend(cover).data('cover', cover);
break;
case 'IFRAME':
var src = media[0].src, iframeId = 'sw-'+(++playerId);
media
.attr('src', '').on('load', function(){
if (index !== $this.current || (index == $this.current && !$this.options.videoautoplay)) {
$this.pausemedia(media);
}
if ($this.options.videomute) {
$this.mutemedia(media);
var inv = setInterval((function(ic) {
return function() {
$this.mutemedia(media);
if (++ic >= 4) clearInterval(inv);
}
})(0), 250);
}
})
.data('slideshow', $this) // add self-reference for the vimeo-ready listener
.attr('data-player-id', iframeId) // add frameId for the vimeo-ready listener
.attr('src', [src, (src.indexOf('?') > -1 ? '&':'?'), 'enablejsapi=1&api=1&player_id='+iframeId].join(''))
.addClass('uk-position-absolute');
// disable pointer events
if(!UI.support.touch) media.css('pointer-events', 'none');
placeholder = true;
if (UI.cover) {
UI.cover(media);
media.attr('data-uk-cover', '{}');
}
break;
case 'VIDEO':
media.addClass('uk-cover-object uk-position-absolute');
placeholder = true;
if ($this.options.videomute) $this.mutemedia(media);
}
if (placeholder) {
canvas = UI.$('<canvas></canvas>').attr({'width': media[0].width, 'height': media[0].height});
var img = UI.$('<img style="width:100%;height:auto;">').attr('src', canvas[0].toDataURL());
slide.prepend(img);
slide.data('sizer', img);
}
} else {
slide.data('sizer', slide);
}
if ($this.hasKenBurns(slide)) {
slide.data('cover').css({
'-webkit-animation-duration': $this.kbanimduration,
'animation-duration': $this.kbanimduration
});
}
slide.data('processed', ++processed);
slide.attr('data-slideshow-slide', type);
});
if (processed) {
this.triggers = this.find('[data-uk-slideshow-item]');
// Set start slide
this.slides.attr('aria-hidden', 'true').removeClass('uk-active').eq(this.current).addClass('uk-active').attr('aria-hidden', 'false');
this.triggers.filter('[data-uk-slideshow-item="'+this.current+'"]').addClass('uk-active');
}
if (resize && processed) {
this.resize();
}
},
resize: function() {
if (this.container.hasClass('uk-slideshow-fullscreen')) return;
var height = this.options.height;
if (this.options.height === 'auto') {
height = 0;
this.slides.css('height', '').each(function() {
height = Math.max(height, UI.$(this).height());
});
}
this.container.css('height', height);
this.slides.css('height', height);
},
show: function(index, direction) {
if (this.animating || this.current == index) return;
this.animating = true;
var $this = this,
current = this.slides.eq(this.current),
next = this.slides.eq(index),
dir = direction ? direction : this.current < index ? 1 : -1,
currentmedia = current.data('media'),
animation = Animations[this.options.animation] ? this.options.animation : 'fade',
nextmedia = next.data('media'),
finalize = function() {
if (!$this.animating) return;
if (currentmedia && currentmedia.is('video,iframe')) {
$this.pausemedia(currentmedia);
}
if (nextmedia && nextmedia.is('video,iframe')) {
$this.playmedia(nextmedia);
}
next.addClass('uk-active').attr('aria-hidden', 'false');
current.removeClass('uk-active').attr('aria-hidden', 'true');
$this.animating = false;
$this.current = index;
UI.Utils.checkDisplay(next, '[class*="uk-animation-"]:not(.uk-cover-background.uk-position-cover)');
$this.trigger('show.uk.slideshow', [next, current, $this]);
};
$this.applyKenBurns(next);
// animation fallback
if (!UI.support.animation) {
animation = 'none';
}
current = UI.$(current);
next = UI.$(next);
$this.trigger('beforeshow.uk.slideshow', [next, current, $this]);
Animations[animation].apply(this, [current, next, dir]).then(finalize);
$this.triggers.removeClass('uk-active');
$this.triggers.filter('[data-uk-slideshow-item="'+index+'"]').addClass('uk-active');
},
applyKenBurns: function(slide) {
if (!this.hasKenBurns(slide)) {
return;
}
var animations = this.options.kenburnsanimations,
index = this.kbindex || 0;
slide.data('cover').attr('class', 'uk-cover-background uk-position-cover').width();
slide.data('cover').addClass(['uk-animation-scale', 'uk-animation-reverse', animations[index].trim()].join(' '));
this.kbindex = animations[index + 1] ? (index+1):0;
},
hasKenBurns: function(slide) {
return (this.options.kenburns && slide.data('cover'));
},
next: function() {
this.show(this.slides[this.current + 1] ? (this.current + 1) : 0, 1);
},
previous: function() {
this.show(this.slides[this.current - 1] ? (this.current - 1) : (this.slides.length - 1), -1);
},
start: function() {
this.stop();
var $this = this;
this.interval = setInterval(function() {
if (!$this.hovering) $this.next();
}, this.options.autoplayInterval);
},
stop: function() {
if (this.interval) clearInterval(this.interval);
},
playmedia: function(media) {
if (!(media && media[0])) return;
switch(media[0].nodeName) {
case 'VIDEO':
if (!this.options.videomute) {
media[0].muted = false;
}
media[0].play();
break;
case 'IFRAME':
if (!this.options.videomute) {
media[0].contentWindow.postMessage('{ "event": "command", "func": "unmute", "method":"setVolume", "value":1}', '*');
}
media[0].contentWindow.postMessage('{ "event": "command", "func": "playVideo", "method":"play"}', '*');
break;
}
},
pausemedia: function(media) {
switch(media[0].nodeName) {
case 'VIDEO':
media[0].pause();
break;
case 'IFRAME':
media[0].contentWindow.postMessage('{ "event": "command", "func": "pauseVideo", "method":"pause"}', '*');
break;
}
},
mutemedia: function(media) {
switch(media[0].nodeName) {
case 'VIDEO':
media[0].muted = true;
break;
case 'IFRAME':
media[0].contentWindow.postMessage('{ "event": "command", "func": "mute", "method":"setVolume", "value":0}', '*');
break;
}
}
});
Animations = {
'none': function() {
var d = UI.$.Deferred();
d.resolve();
return d.promise();
},
'scroll': function(current, next, dir) {
var d = UI.$.Deferred();
current.css('animation-duration', this.options.duration+'ms');
next.css('animation-duration', this.options.duration+'ms');
next.css('opacity', 1).one(UI.support.animation.end, function() {
current.css('opacity', 0).removeClass(dir == -1 ? 'uk-slideshow-scroll-backward-out' : 'uk-slideshow-scroll-forward-out');
next.removeClass(dir == -1 ? 'uk-slideshow-scroll-backward-in' : 'uk-slideshow-scroll-forward-in');
d.resolve();
}.bind(this));
current.addClass(dir == -1 ? 'uk-slideshow-scroll-backward-out' : 'uk-slideshow-scroll-forward-out');
next.addClass(dir == -1 ? 'uk-slideshow-scroll-backward-in' : 'uk-slideshow-scroll-forward-in');
next.width(); // force redraw
return d.promise();
},
'swipe': function(current, next, dir) {
var d = UI.$.Deferred();
current.css('animation-duration', this.options.duration+'ms');
next.css('animation-duration', this.options.duration+'ms');
next.css('opacity', 1).one(UI.support.animation.end, function() {
current.css('opacity', 0).removeClass(dir === -1 ? 'uk-slideshow-swipe-backward-out' : 'uk-slideshow-swipe-forward-out');
next.removeClass(dir === -1 ? 'uk-slideshow-swipe-backward-in' : 'uk-slideshow-swipe-forward-in');
d.resolve();
}.bind(this));
current.addClass(dir == -1 ? 'uk-slideshow-swipe-backward-out' : 'uk-slideshow-swipe-forward-out');
next.addClass(dir == -1 ? 'uk-slideshow-swipe-backward-in' : 'uk-slideshow-swipe-forward-in');
next.width(); // force redraw
return d.promise();
},
'scale': function(current, next, dir) {
var d = UI.$.Deferred();
current.css('animation-duration', this.options.duration+'ms');
next.css('animation-duration', this.options.duration+'ms');
next.css('opacity', 1);
current.one(UI.support.animation.end, function() {
current.css('opacity', 0).removeClass('uk-slideshow-scale-out');
d.resolve();
}.bind(this));
current.addClass('uk-slideshow-scale-out');
current.width(); // force redraw
return d.promise();
},
'fade': function(current, next, dir) {
var d = UI.$.Deferred();
current.css('animation-duration', this.options.duration+'ms');
next.css('animation-duration', this.options.duration+'ms');
next.css('opacity', 1);
// for plain text content slides - looks smoother
if (!(next.data('cover') || next.data('placeholder'))) {
next.css('opacity', 1).one(UI.support.animation.end, function() {
next.removeClass('uk-slideshow-fade-in');
}).addClass('uk-slideshow-fade-in');
}
current.one(UI.support.animation.end, function() {
current.css('opacity', 0).removeClass('uk-slideshow-fade-out');
d.resolve();
}.bind(this));
current.addClass('uk-slideshow-fade-out');
current.width(); // force redraw
return d.promise();
}
};
UI.slideshow.animations = Animations;
// Listen for messages from the vimeo player
window.addEventListener('message', function onMessageReceived(e) {
var data = e.data, iframe;
if (typeof(data) == 'string') {
try {
data = JSON.parse(data);
} catch(err) {
data = {};
}
}
if (e.origin && e.origin.indexOf('vimeo') > -1 && data.event == 'ready' && data.player_id) {
iframe = UI.$('[data-player-id="'+ data.player_id+'"]');
if (iframe.length) {
iframe.data('slideshow').mutemedia(iframe);
}
}
}, false);
});

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,688 @@
/*! UIkit 2.27.4 | http://www.getuikit.com | (c) 2014 YOOtheme | MIT License */
/*
* Based on nativesortable - Copyright (c) Brian Grinstead - https://github.com/bgrins/nativesortable
*/
(function(addon) {
var component;
if (window.UIkit2) {
component = addon(UIkit2);
}
if (typeof define == 'function' && define.amd) {
define('uikit-sortable', ['uikit'], function(){
return component || addon(UIkit2);
});
}
})(function(UI){
"use strict";
var supportsTouch = ('ontouchstart' in window || 'MSGesture' in window) || (window.DocumentTouch && document instanceof DocumentTouch),
draggingPlaceholder, currentlyDraggingElement, currentlyDraggingTarget, dragging, moving, clickedlink, delayIdle, touchedlists, moved, overElement, startEvent;
var POINTER_DOWN = supportsTouch ? ('MSGesture' in window ? 'pointerdown':'touchstart') : 'mousedown',
POINTER_MOVE = supportsTouch ? ('MSGesture' in window ? 'pointermove':'touchmove') : 'mousemove',
POINTER_UP = supportsTouch ? ('MSGesture' in window ? 'pointerup':'touchend') : 'mouseup';
function closestSortable(ele) {
ele = UI.$(ele);
do {
if (ele.data('sortable')) {
return ele;
}
ele = UI.$(ele).parent();
} while(ele.length);
return ele;
}
UI.component('sortable', {
defaults: {
animation : 150,
threshold : 10,
childClass : 'uk-sortable-item',
placeholderClass : 'uk-sortable-placeholder',
overClass : 'uk-sortable-over',
draggingClass : 'uk-sortable-dragged',
dragMovingClass : 'uk-sortable-moving',
baseClass : 'uk-sortable',
noDragClass : 'uk-sortable-nodrag',
emptyClass : 'uk-sortable-empty',
dragCustomClass : '',
handleClass : false,
group : false,
stop : function() {},
start : function() {},
change : function() {}
},
boot: function() {
// auto init
UI.ready(function(context) {
UI.$('[data-uk-sortable]', context).each(function(){
var ele = UI.$(this);
if(!ele.data('sortable')) {
UI.sortable(ele, UI.Utils.options(ele.attr('data-uk-sortable')));
}
});
});
UI.$html.on(POINTER_MOVE, function(e) {
if (delayIdle) {
var src = e.originalEvent.targetTouches ? e.originalEvent.targetTouches[0] : e;
if (Math.abs(src.pageX - delayIdle.pos.x) > delayIdle.threshold || Math.abs(src.pageY - delayIdle.pos.y) > delayIdle.threshold) {
delayIdle.apply(src);
}
}
if (draggingPlaceholder) {
if (!moving) {
moving = true;
draggingPlaceholder.show();
draggingPlaceholder.$current.addClass(draggingPlaceholder.$sortable.options.placeholderClass);
draggingPlaceholder.$sortable.element.children().addClass(draggingPlaceholder.$sortable.options.childClass);
UI.$html.addClass(draggingPlaceholder.$sortable.options.dragMovingClass);
}
var offset = draggingPlaceholder.data('mouse-offset'),
ev = e.originalEvent.touches && e.originalEvent.touches[0] || e.originalEvent,
left = parseInt(ev.pageX, 10) + offset.left,
top = parseInt(ev.pageY, 10) + offset.top;
draggingPlaceholder.css({left: left, top: top });
// adjust document scrolling
if (top + (draggingPlaceholder.height()/3) > document.body.offsetHeight) {
return;
}
if (top < UI.$win.scrollTop()) {
UI.$win.scrollTop(UI.$win.scrollTop() - Math.ceil(draggingPlaceholder.height()/3));
} else if ( (top + (draggingPlaceholder.height()/3)) > (window.innerHeight + UI.$win.scrollTop()) ) {
UI.$win.scrollTop(UI.$win.scrollTop() + Math.ceil(draggingPlaceholder.height()/3));
}
}
});
UI.$html.on(POINTER_UP, function(e) {
delayIdle = clickedlink = false;
// dragging?
if (!currentlyDraggingElement || !draggingPlaceholder) {
// completely reset dragging attempt. will cause weird delay behavior elsewise
currentlyDraggingElement = draggingPlaceholder = null;
return;
}
// inside or outside of sortable?
var sortable = closestSortable(currentlyDraggingElement),
component = draggingPlaceholder.$sortable,
ev = { type: e.type };
if (sortable[0]) {
component.dragDrop(ev, component.element);
}
component.dragEnd(ev, component.element);
});
},
init: function() {
var $this = this,
element = this.element[0];
touchedlists = [];
this.checkEmptyList();
this.element.data('sortable-group', this.options.group ? this.options.group : UI.Utils.uid('sortable-group'));
var handleDragStart = delegate(function(e) {
if (e.data && e.data.sortable) {
return;
}
var $target = UI.$(e.target),
$link = $target.is('a[href]') ? $target:$target.parents('a[href]');
if ($target.is(':input')) {
return;
}
if ($this.options.handleClass) {
var handle = $target.hasClass($this.options.handleClass) ? $target : $target.closest('.'+$this.options.handleClass, $this.element);
if (!handle.length) return;
}
e.preventDefault();
if ($link.length) {
$link.one('click', function(e){
e.preventDefault();
}).one(POINTER_UP, function(){
if (!moved) {
$link.trigger('click');
if (supportsTouch && $link.attr('href').trim()) {
location.href = $link.attr('href');
}
}
});
}
e.data = e.data || {};
e.data.sortable = element;
return $this.dragStart(e, this);
});
var handleDragEnter = delegate(UI.Utils.debounce(function(e) {
return $this.dragEnter(e, this);
}), 40);
var handleDragLeave = delegate(function(e) {
// Prevent dragenter on a child from allowing a dragleave on the container
var previousCounter = $this.dragenterData(this);
$this.dragenterData(this, previousCounter - 1);
// This is a fix for child elements firing dragenter before the parent fires dragleave
if (!$this.dragenterData(this)) {
UI.$(this).removeClass($this.options.overClass);
$this.dragenterData(this, false);
}
});
var handleTouchMove = delegate(function(e) {
if (!currentlyDraggingElement ||
currentlyDraggingElement === this ||
currentlyDraggingTarget === this) {
return true;
}
$this.element.children().removeClass($this.options.overClass);
currentlyDraggingTarget = this;
$this.moveElementNextTo(currentlyDraggingElement, this);
return prevent(e);
});
// Bind/unbind standard mouse/touch events as a polyfill.
function addDragHandlers() {
if (supportsTouch && startEvent.touches && startEvent.touches.length) {
element.addEventListener(POINTER_MOVE, handleTouchMove, false);
} else {
element.addEventListener('mouseover', handleDragEnter, false);
element.addEventListener('mouseout', handleDragLeave, false);
}
// document.addEventListener("selectstart", prevent, false);
}
function removeDragHandlers() {
if (supportsTouch && startEvent.touches && startEvent.touches.length) {
element.removeEventListener(POINTER_MOVE, handleTouchMove, false);
} else {
element.removeEventListener('mouseover', handleDragEnter, false);
element.removeEventListener('mouseout', handleDragLeave, false);
}
// document.removeEventListener("selectstart", prevent, false);
}
this.addDragHandlers = addDragHandlers;
this.removeDragHandlers = removeDragHandlers;
function handleDragMove(e) {
if (!currentlyDraggingElement) {
return;
}
$this.dragMove(e, $this);
}
function delegate(fn) {
return function(e) {
var touch, target, context;
startEvent = e;
if (e) {
touch = e.touches && e.touches[0] || e;
target = touch.target || e.target;
// Fix event.target for a touch event
if (supportsTouch && document.elementFromPoint) {
target = document.elementFromPoint(touch.pageX - document.body.scrollLeft, touch.pageY - document.body.scrollTop);
}
overElement = UI.$(target);
}
if (UI.$(target).hasClass('.'+$this.options.childClass)) {
fn.apply(target, [e]);
} else if (target !== element) {
// If a child is initiating the event or ending it, then use the container as context for the callback.
context = moveUpToChildNode(element, target);
if (context) {
fn.apply(context, [e]);
}
}
};
}
window.addEventListener(POINTER_MOVE, handleDragMove, false);
element.addEventListener(POINTER_DOWN, handleDragStart, false);
},
dragStart: function(e, elem) {
moved = false;
moving = false;
dragging = false;
var $this = this,
target = UI.$(e.target);
if (!supportsTouch && e.button==2) {
return;
}
if (target.is('.'+$this.options.noDragClass) || target.closest('.'+$this.options.noDragClass).length) {
return;
}
// prevent dragging if taget is a form field
if (target.is(':input')) {
return;
}
currentlyDraggingElement = elem;
// init drag placeholder
if (draggingPlaceholder) {
draggingPlaceholder.remove();
}
var $current = UI.$(currentlyDraggingElement), offset = $current.offset(), ev = e.touches && e.touches[0] || e;
delayIdle = {
pos : { x:ev.pageX, y:ev.pageY },
threshold : $this.options.handleClass ? 1 : $this.options.threshold,
apply : function(evt) {
draggingPlaceholder = UI.$('<div class="'+([$this.options.draggingClass, $this.options.dragCustomClass].join(' '))+'"></div>').css({
display : 'none',
top : offset.top,
left : offset.left,
width : $current.width(),
height : $current.height(),
padding : $current.css('padding')
}).data({
'mouse-offset': {
left : offset.left - parseInt(ev.pageX, 10),
top : offset.top - parseInt(ev.pageY, 10)
},
origin : $this.element,
index : $current.index()
}).append($current.html()).appendTo('body');
draggingPlaceholder.$current = $current;
draggingPlaceholder.$sortable = $this;
$current.data({
'start-list': $current.parent(),
'start-index': $current.index(),
'sortable-group': $this.options.group
});
$this.addDragHandlers();
$this.options.start(this, currentlyDraggingElement);
$this.trigger('start.uk.sortable', [$this, currentlyDraggingElement, draggingPlaceholder]);
moved = true;
delayIdle = false;
}
};
},
dragMove: function(e, elem) {
overElement = UI.$(document.elementFromPoint(e.pageX - (document.body.scrollLeft || document.scrollLeft || 0), e.pageY - (document.body.scrollTop || document.documentElement.scrollTop || 0)));
var overRoot = overElement.closest('.'+this.options.baseClass),
groupOver = overRoot.data('sortable-group'),
$current = UI.$(currentlyDraggingElement),
currentRoot = $current.parent(),
groupCurrent = $current.data('sortable-group'),
overChild;
if (overRoot[0] !== currentRoot[0] && groupCurrent !== undefined && groupOver === groupCurrent) {
overRoot.data('sortable').addDragHandlers();
touchedlists.push(overRoot);
overRoot.children().addClass(this.options.childClass);
// swap root
if (overRoot.children().length > 0) {
overChild = overElement.closest('.'+this.options.childClass);
if (overChild.length) {
overChild.before($current);
} else {
overRoot.append($current);
}
} else { // empty list
overElement.append($current);
}
UI.$doc.trigger('mouseover');
}
this.checkEmptyList();
this.checkEmptyList(currentRoot);
},
dragEnter: function(e, elem) {
if (!currentlyDraggingElement || currentlyDraggingElement === elem) {
return true;
}
var previousCounter = this.dragenterData(elem);
this.dragenterData(elem, previousCounter + 1);
// Prevent dragenter on a child from allowing a dragleave on the container
if (previousCounter === 0) {
var currentlist = UI.$(elem).parent(),
startlist = UI.$(currentlyDraggingElement).data('start-list');
if (currentlist[0] !== startlist[0]) {
var groupOver = currentlist.data('sortable-group'),
groupCurrent = UI.$(currentlyDraggingElement).data('sortable-group');
if ((groupOver || groupCurrent) && (groupOver != groupCurrent)) {
return false;
}
}
UI.$(elem).addClass(this.options.overClass);
this.moveElementNextTo(currentlyDraggingElement, elem);
}
return false;
},
dragEnd: function(e, elem) {
var $this = this;
// avoid triggering event twice
if (currentlyDraggingElement) {
// TODO: trigger on right element?
this.options.stop(elem);
this.trigger('stop.uk.sortable', [this]);
}
currentlyDraggingElement = null;
currentlyDraggingTarget = null;
touchedlists.push(this.element);
touchedlists.forEach(function(el, i) {
UI.$(el).children().each(function() {
if (this.nodeType === 1) {
UI.$(this).removeClass($this.options.overClass)
.removeClass($this.options.placeholderClass)
.removeClass($this.options.childClass);
$this.dragenterData(this, false);
}
});
});
touchedlists = [];
UI.$html.removeClass(this.options.dragMovingClass);
this.removeDragHandlers();
if (draggingPlaceholder) {
draggingPlaceholder.remove();
draggingPlaceholder = null;
}
},
dragDrop: function(e, elem) {
if (e.type === 'drop') {
if (e.stopPropagation) {
e.stopPropagation();
}
if (e.preventDefault) {
e.preventDefault();
}
}
this.triggerChangeEvents();
},
triggerChangeEvents: function() {
// trigger events once
if (!currentlyDraggingElement) return;
var $current = UI.$(currentlyDraggingElement),
oldRoot = draggingPlaceholder.data('origin'),
newRoot = $current.closest('.'+this.options.baseClass),
triggers = [],
el = UI.$(currentlyDraggingElement);
// events depending on move inside lists or across lists
if (oldRoot[0] === newRoot[0] && draggingPlaceholder.data('index') != $current.index() ) {
triggers.push({sortable: this, mode: 'moved'});
} else if (oldRoot[0] != newRoot[0]) {
triggers.push({sortable: UI.$(newRoot).data('sortable'), mode: 'added'}, {sortable: UI.$(oldRoot).data('sortable'), mode: 'removed'});
}
triggers.forEach(function (trigger, i) {
if (trigger.sortable) {
trigger.sortable.element.trigger('change.uk.sortable', [trigger.sortable, el, trigger.mode]);
}
});
},
dragenterData: function(element, val) {
element = UI.$(element);
if (arguments.length == 1) {
return parseInt(element.data('child-dragenter'), 10) || 0;
} else if (!val) {
element.removeData('child-dragenter');
} else {
element.data('child-dragenter', Math.max(0, val));
}
},
moveElementNextTo: function(element, elementToMoveNextTo) {
dragging = true;
var $this = this,
list = UI.$(element).parent().css('min-height', ''),
next = isBelow(element, elementToMoveNextTo) ? elementToMoveNextTo : elementToMoveNextTo.nextSibling,
children = list.children(),
count = children.length;
if (!$this.options.animation) {
elementToMoveNextTo.parentNode.insertBefore(element, next);
UI.Utils.checkDisplay($this.element.parent());
return;
}
list.css('min-height', list.height());
children.stop().each(function(){
var ele = UI.$(this),
offset = ele.position();
offset.width = ele.width();
ele.data('offset-before', offset);
});
elementToMoveNextTo.parentNode.insertBefore(element, next);
UI.Utils.checkDisplay($this.element.parent());
children = list.children().each(function() {
var ele = UI.$(this);
ele.data('offset-after', ele.position());
}).each(function() {
var ele = UI.$(this),
before = ele.data('offset-before');
ele.css({position:'absolute', top:before.top, left:before.left, minWidth:before.width });
});
children.each(function(){
var ele = UI.$(this),
before = ele.data('offset-before'),
offset = ele.data('offset-after');
ele.css('pointer-events', 'none').width();
setTimeout(function(){
ele.animate({'top':offset.top, 'left':offset.left}, $this.options.animation, function() {
ele.css({position:'',top:'', left:'', minWidth: '', 'pointer-events':''}).removeClass($this.options.overClass).removeData('child-dragenter');
count--;
if (!count) {
list.css('min-height', '');
UI.Utils.checkDisplay($this.element.parent());
}
});
}, 0);
});
},
serialize: function() {
var data = [], item, attribute;
this.element.children().each(function(j, child) {
item = {};
for (var i = 0, attr, val; i < child.attributes.length; i++) {
attribute = child.attributes[i];
if (attribute.name.indexOf('data-') === 0) {
attr = attribute.name.substr(5);
val = UI.Utils.str2json(attribute.value);
item[attr] = (val || attribute.value=='false' || attribute.value=='0') ? val:attribute.value;
}
}
data.push(item);
});
return data;
},
checkEmptyList: function(list) {
list = list ? UI.$(list) : this.element;
if (this.options.emptyClass) {
list[!list.children().length ? 'addClass':'removeClass'](this.options.emptyClass);
}
}
});
// helpers
function isBelow(el1, el2) {
var parent = el1.parentNode;
if (el2.parentNode != parent) {
return false;
}
var cur = el1.previousSibling;
while (cur && cur.nodeType !== 9) {
if (cur === el2) {
return true;
}
cur = cur.previousSibling;
}
return false;
}
function moveUpToChildNode(parent, child) {
var cur = child;
if (cur == parent) { return null; }
while (cur) {
if (cur.parentNode === parent) {
return cur;
}
cur = cur.parentNode;
if ( !cur || !cur.ownerDocument || cur.nodeType === 11 ) {
break;
}
}
return null;
}
function prevent(e) {
if (e.stopPropagation) {
e.stopPropagation();
}
if (e.preventDefault) {
e.preventDefault();
}
e.returnValue = false;
}
return UI.sortable;
});

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,364 @@
/*! UIkit 2.27.4 | http://www.getuikit.com | (c) 2014 YOOtheme | MIT License */
(function(addon) {
var component;
if (window.UIkit2) {
component = addon(UIkit2);
}
if (typeof define == 'function' && define.amd) {
define('uikit-sticky', ['uikit'], function(){
return component || addon(UIkit2);
});
}
})(function(UI){
"use strict";
var $win = UI.$win,
$doc = UI.$doc,
sticked = [],
direction = 1;
UI.component('sticky', {
defaults: {
top : 0,
bottom : 0,
animation : '',
clsinit : 'uk-sticky-init',
clsactive : 'uk-active',
clsinactive : '',
getWidthFrom : '',
showup : false,
boundary : false,
media : false,
target : false,
disabled : false
},
boot: function() {
// should be more efficient than using $win.scroll(checkscrollposition):
UI.$doc.on('scrolling.uk.document', function(e, data) {
if (!data || !data.dir) return;
direction = data.dir.y;
checkscrollposition();
});
UI.$win.on('resize orientationchange', UI.Utils.debounce(function() {
if (!sticked.length) return;
for (var i = 0; i < sticked.length; i++) {
sticked[i].reset(true);
sticked[i].self.computeWrapper();
}
checkscrollposition();
}, 100));
// init code
UI.ready(function(context) {
setTimeout(function(){
UI.$('[data-uk-sticky]', context).each(function(){
var $ele = UI.$(this);
if (!$ele.data('sticky')) {
UI.sticky($ele, UI.Utils.options($ele.attr('data-uk-sticky')));
}
});
checkscrollposition();
}, 0);
});
},
init: function() {
var boundary = this.options.boundary, boundtoparent;
this.wrapper = this.element.wrap('<div class="uk-sticky-placeholder"></div>').parent();
this.computeWrapper();
this.wrapper.css({
'margin-top' : this.element.css('margin-top'),
'margin-bottom' : this.element.css('margin-bottom'),
'margin-left' : this.element.css('margin-left'),
'margin-right' : this.element.css('margin-right')
})
this.element.css('margin', 0);
if (boundary) {
if (boundary === true || boundary[0] === '!') {
boundary = boundary === true ? this.wrapper.parent() : this.wrapper.closest(boundary.substr(1));
boundtoparent = true;
} else if (typeof boundary === "string") {
boundary = UI.$(boundary);
}
}
this.sticky = {
self : this,
options : this.options,
element : this.element,
currentTop : null,
wrapper : this.wrapper,
init : false,
getWidthFrom : UI.$(this.options.getWidthFrom || this.wrapper),
boundary : boundary,
boundtoparent : boundtoparent,
top : 0,
calcTop : function() {
var top = this.options.top;
// dynamic top parameter
if (this.options.top && typeof(this.options.top) == 'string') {
// e.g. 50vh
if (this.options.top.match(/^(-|)(\d+)vh$/)) {
top = window.innerHeight * parseInt(this.options.top, 10)/100;
// e.g. #elementId, or .class-1,class-2,.class-3 (first found is used)
} else {
var topElement = UI.$(this.options.top).first();
if (topElement.length && topElement.is(':visible')) {
top = -1 * ((topElement.offset().top + topElement.outerHeight()) - this.wrapper.offset().top);
}
}
}
this.top = top;
},
reset: function(force) {
this.calcTop();
var finalize = function() {
this.element.css({position:'', top:'', width:'', left:'', margin:'0'});
this.element.removeClass([this.options.animation, 'uk-animation-reverse', this.options.clsactive].join(' '));
this.element.addClass(this.options.clsinactive);
this.element.trigger('inactive.uk.sticky');
this.currentTop = null;
this.animate = false;
}.bind(this);
if (!force && this.options.animation && UI.support.animation && !UI.Utils.isInView(this.wrapper)) {
this.animate = true;
this.element.removeClass(this.options.animation).one(UI.support.animation.end, function(){
finalize();
}).width(); // force redraw
this.element.addClass(this.options.animation+' '+'uk-animation-reverse');
} else {
finalize();
}
},
check: function() {
if (this.options.disabled) {
return false;
}
if (this.options.media) {
switch(typeof(this.options.media)) {
case 'number':
if (window.innerWidth < this.options.media) {
return false;
}
break;
case 'string':
if (window.matchMedia && !window.matchMedia(this.options.media).matches) {
return false;
}
break;
}
}
var scrollTop = $win.scrollTop(),
documentHeight = $doc.height(),
dwh = documentHeight - window.innerHeight,
extra = (scrollTop > dwh) ? dwh - scrollTop : 0,
elementTop = this.wrapper.offset().top,
etse = elementTop - this.top - extra,
active = (scrollTop >= etse);
if (active && this.options.showup) {
// set inactiv if scrolling down
if (direction == 1) {
active = false;
}
// set inactive when wrapper is still in view
if (direction == -1 && !this.element.hasClass(this.options.clsactive) && UI.Utils.isInView(this.wrapper)) {
active = false;
}
}
return active;
}
};
this.sticky.calcTop();
sticked.push(this.sticky);
},
update: function() {
checkscrollposition(this.sticky);
},
enable: function() {
this.options.disabled = false;
this.update();
},
disable: function(force) {
this.options.disabled = true;
this.sticky.reset(force);
},
computeWrapper: function() {
this.wrapper.css({
'height' : ['absolute','fixed'].indexOf(this.element.css('position')) == -1 ? this.element.outerHeight() : '',
'float' : this.element.css('float') != 'none' ? this.element.css('float') : ''
});
if (this.element.css('position') == 'fixed') {
this.element.css({
width: this.sticky.getWidthFrom.length ? this.sticky.getWidthFrom.width() : this.element.width()
});
}
}
});
function checkscrollposition(direction) {
var stickies = arguments.length ? arguments : sticked;
if (!stickies.length || $win.scrollTop() < 0) return;
var scrollTop = $win.scrollTop(),
documentHeight = $doc.height(),
windowHeight = $win.height(),
dwh = documentHeight - windowHeight,
extra = (scrollTop > dwh) ? dwh - scrollTop : 0,
newTop, containerBottom, stickyHeight, sticky;
for (var i = 0; i < stickies.length; i++) {
sticky = stickies[i];
if (!sticky.element.is(':visible') || sticky.animate) {
continue;
}
if (!sticky.check()) {
if (sticky.currentTop !== null) {
sticky.reset();
}
} else {
if (sticky.top < 0) {
newTop = 0;
} else {
stickyHeight = sticky.element.outerHeight();
newTop = documentHeight - stickyHeight - sticky.top - sticky.options.bottom - scrollTop - extra;
newTop = newTop < 0 ? newTop + sticky.top : sticky.top;
}
if (sticky.boundary && sticky.boundary.length) {
var bTop = sticky.boundary.offset().top;
if (sticky.boundtoparent) {
containerBottom = documentHeight - (bTop + sticky.boundary.outerHeight()) + parseInt(sticky.boundary.css('padding-bottom'));
} else {
containerBottom = documentHeight - bTop;
}
newTop = (scrollTop + stickyHeight) > (documentHeight - containerBottom - (sticky.top < 0 ? 0 : sticky.top)) ? (documentHeight - containerBottom) - (scrollTop + stickyHeight) : newTop;
}
if (sticky.currentTop != newTop) {
sticky.element.css({
position : 'fixed',
top : newTop,
width : sticky.getWidthFrom.length ? sticky.getWidthFrom.width() : sticky.element.width()
});
if (!sticky.init) {
sticky.element.addClass(sticky.options.clsinit);
if (location.hash && scrollTop > 0 && sticky.options.target) {
var $target = UI.$(location.hash);
if ($target.length) {
setTimeout((function($target, sticky){
return function() {
sticky.element.width(); // force redraw
var offset = $target.offset(),
maxoffset = offset.top + $target.outerHeight(),
stickyOffset = sticky.element.offset(),
stickyHeight = sticky.element.outerHeight(),
stickyMaxOffset = stickyOffset.top + stickyHeight;
if (stickyOffset.top < maxoffset && offset.top < stickyMaxOffset) {
scrollTop = offset.top - stickyHeight - sticky.options.target;
window.scrollTo(0, scrollTop);
}
};
})($target, sticky), 0);
}
}
}
sticky.element.addClass(sticky.options.clsactive).removeClass(sticky.options.clsinactive);
sticky.element.trigger('active.uk.sticky');
sticky.element.css('margin', '');
if (sticky.options.animation && sticky.init && !UI.Utils.isInView(sticky.wrapper)) {
sticky.element.addClass(sticky.options.animation);
}
sticky.currentTop = newTop;
}
}
sticky.init = true;
}
}
return UI.sticky;
});

View File

@ -0,0 +1,2 @@
/*! UIkit 2.27.4 | http://www.getuikit.com | (c) 2014 YOOtheme | MIT License */
!function(t){var i;window.UIkit2&&(i=t(UIkit2)),"function"==typeof define&&define.amd&&define("uikit-sticky",["uikit"],function(){return i||t(UIkit2)})}(function(t){"use strict";function i(){var i=arguments.length?arguments:n;if(i.length&&!(e.scrollTop()<0))for(var o,a,r,h,p=e.scrollTop(),c=s.height(),l=e.height(),m=c-l,d=p>m?m-p:0,u=0;u<i.length;u++)if(h=i[u],h.element.is(":visible")&&!h.animate){if(h.check()){if(h.top<0?o=0:(r=h.element.outerHeight(),o=c-r-h.top-h.options.bottom-p-d,o=0>o?o+h.top:h.top),h.boundary&&h.boundary.length){var f=h.boundary.offset().top;a=h.boundtoparent?c-(f+h.boundary.outerHeight())+parseInt(h.boundary.css("padding-bottom")):c-f,o=p+r>c-a-(h.top<0?0:h.top)?c-a-(p+r):o}if(h.currentTop!=o){if(h.element.css({position:"fixed",top:o,width:h.getWidthFrom.length?h.getWidthFrom.width():h.element.width()}),!h.init&&(h.element.addClass(h.options.clsinit),location.hash&&p>0&&h.options.target)){var g=t.$(location.hash);g.length&&setTimeout(function(t,i){return function(){i.element.width();var e=t.offset(),s=e.top+t.outerHeight(),n=i.element.offset(),o=i.element.outerHeight(),a=n.top+o;n.top<s&&e.top<a&&(p=e.top-o-i.options.target,window.scrollTo(0,p))}}(g,h),0)}h.element.addClass(h.options.clsactive).removeClass(h.options.clsinactive),h.element.trigger("active.uk.sticky"),h.element.css("margin",""),h.options.animation&&h.init&&!t.Utils.isInView(h.wrapper)&&h.element.addClass(h.options.animation),h.currentTop=o}}else null!==h.currentTop&&h.reset();h.init=!0}}var e=t.$win,s=t.$doc,n=[],o=1;return t.component("sticky",{defaults:{top:0,bottom:0,animation:"",clsinit:"uk-sticky-init",clsactive:"uk-active",clsinactive:"",getWidthFrom:"",showup:!1,boundary:!1,media:!1,target:!1,disabled:!1},boot:function(){t.$doc.on("scrolling.uk.document",function(t,e){e&&e.dir&&(o=e.dir.y,i())}),t.$win.on("resize orientationchange",t.Utils.debounce(function(){if(n.length){for(var t=0;t<n.length;t++)n[t].reset(!0),n[t].self.computeWrapper();i()}},100)),t.ready(function(e){setTimeout(function(){t.$("[data-uk-sticky]",e).each(function(){var i=t.$(this);i.data("sticky")||t.sticky(i,t.Utils.options(i.attr("data-uk-sticky")))}),i()},0)})},init:function(){var i,a=this.options.boundary;this.wrapper=this.element.wrap('<div class="uk-sticky-placeholder"></div>').parent(),this.computeWrapper(),this.wrapper.css({"margin-top":this.element.css("margin-top"),"margin-bottom":this.element.css("margin-bottom"),"margin-left":this.element.css("margin-left"),"margin-right":this.element.css("margin-right")}),this.element.css("margin",0),a&&(a===!0||"!"===a[0]?(a=a===!0?this.wrapper.parent():this.wrapper.closest(a.substr(1)),i=!0):"string"==typeof a&&(a=t.$(a))),this.sticky={self:this,options:this.options,element:this.element,currentTop:null,wrapper:this.wrapper,init:!1,getWidthFrom:t.$(this.options.getWidthFrom||this.wrapper),boundary:a,boundtoparent:i,top:0,calcTop:function(){var i=this.options.top;if(this.options.top&&"string"==typeof this.options.top)if(this.options.top.match(/^(-|)(\d+)vh$/))i=window.innerHeight*parseInt(this.options.top,10)/100;else{var e=t.$(this.options.top).first();e.length&&e.is(":visible")&&(i=-1*(e.offset().top+e.outerHeight()-this.wrapper.offset().top))}this.top=i},reset:function(i){this.calcTop();var e=function(){this.element.css({position:"",top:"",width:"",left:"",margin:"0"}),this.element.removeClass([this.options.animation,"uk-animation-reverse",this.options.clsactive].join(" ")),this.element.addClass(this.options.clsinactive),this.element.trigger("inactive.uk.sticky"),this.currentTop=null,this.animate=!1}.bind(this);!i&&this.options.animation&&t.support.animation&&!t.Utils.isInView(this.wrapper)?(this.animate=!0,this.element.removeClass(this.options.animation).one(t.support.animation.end,function(){e()}).width(),this.element.addClass(this.options.animation+" uk-animation-reverse")):e()},check:function(){if(this.options.disabled)return!1;if(this.options.media)switch(typeof this.options.media){case"number":if(window.innerWidth<this.options.media)return!1;break;case"string":if(window.matchMedia&&!window.matchMedia(this.options.media).matches)return!1}var i=e.scrollTop(),n=s.height(),a=n-window.innerHeight,r=i>a?a-i:0,h=this.wrapper.offset().top,p=h-this.top-r,c=i>=p;return c&&this.options.showup&&(1==o&&(c=!1),-1==o&&!this.element.hasClass(this.options.clsactive)&&t.Utils.isInView(this.wrapper)&&(c=!1)),c}},this.sticky.calcTop(),n.push(this.sticky)},update:function(){i(this.sticky)},enable:function(){this.options.disabled=!1,this.update()},disable:function(t){this.options.disabled=!0,this.sticky.reset(t)},computeWrapper:function(){this.wrapper.css({height:-1==["absolute","fixed"].indexOf(this.element.css("position"))?this.element.outerHeight():"","float":"none"!=this.element.css("float")?this.element.css("float"):""}),"fixed"==this.element.css("position")&&this.element.css({width:this.sticky.getWidthFrom.length?this.sticky.getWidthFrom.width():this.element.width()})}}),t.sticky});

View File

@ -0,0 +1,192 @@
/*! UIkit 2.27.4 | http://www.getuikit.com | (c) 2014 YOOtheme | MIT License */
(function(addon) {
var component;
if (window.UIkit2) {
component = addon(UIkit2);
}
if (typeof define == 'function' && define.amd) {
define('uikit-timepicker', ['uikit'], function(){
return component || addon(UIkit2);
});
}
})(function(UI){
"use strict";
UI.component('timepicker', {
defaults: {
format : '24h',
delay : 0,
start : 0,
end : 24
},
boot: function() {
// init code
UI.$html.on('focus.timepicker.uikit', '[data-uk-timepicker]', function(e) {
var ele = UI.$(this);
if (!ele.data('timepicker')) {
var obj = UI.timepicker(ele, UI.Utils.options(ele.attr('data-uk-timepicker')));
setTimeout(function(){
obj.autocomplete.input.focus();
}, 40);
}
});
},
init: function() {
var $this = this, times = getTimeRange(this.options.start, this.options.end), container;
this.options.minLength = 0;
this.options.template = '<ul class="uk-nav uk-nav-autocomplete uk-autocomplete-results">{{~items}}<li data-value="{{$item.value}}"><a>{{$item.value}}</a></li>{{/items}}</ul>';
this.options.source = function(release) {
release(times[$this.options.format] || times['12h']);
};
if (this.element.is('input')) {
this.element.wrap('<div class="uk-autocomplete"></div>');
container = this.element.parent();
} else {
container = this.element.addClass('uk-autocomplete');
}
this.autocomplete = UI.autocomplete(container, this.options);
this.autocomplete.dropdown.addClass('uk-dropdown-small uk-dropdown-scrollable');
this.autocomplete.on('show.uk.autocomplete', function() {
var selected = $this.autocomplete.dropdown.find('[data-value="'+$this.autocomplete.input.val()+'"]');
setTimeout(function(){
$this.autocomplete.pick(selected, true);
}, 10);
});
this.autocomplete.input.on('focus', function(){
$this.autocomplete.value = Math.random();
$this.autocomplete.triggercomplete();
}).on('blur', UI.Utils.debounce(function() {
$this.checkTime();
}, 100));
this.element.data("timepicker", this);
},
checkTime: function() {
var arr, timeArray, meridian = 'AM', hour, minute, time = this.autocomplete.input.val();
if (this.options.format == '12h') {
arr = time.split(' ');
timeArray = arr[0].split(':');
meridian = arr[1];
} else {
timeArray = time.split(':');
}
hour = parseInt(timeArray[0], 10);
minute = parseInt(timeArray[1], 10);
if (isNaN(hour)) hour = 0;
if (isNaN(minute)) minute = 0;
if (this.options.format == '12h') {
if (hour > 12) {
hour = 12;
} else if (hour < 0) {
hour = 12;
}
if (meridian === 'am' || meridian === 'a') {
meridian = 'AM';
} else if (meridian === 'pm' || meridian === 'p') {
meridian = 'PM';
}
if (meridian !== 'AM' && meridian !== 'PM') {
meridian = 'AM';
}
} else {
if (hour >= 24) {
hour = 23;
} else if (hour < 0) {
hour = 0;
}
}
if (minute < 0) {
minute = 0;
} else if (minute >= 60) {
minute = 0;
}
this.autocomplete.input.val(this.formatTime(hour, minute, meridian)).trigger('change');
},
formatTime: function(hour, minute, meridian) {
hour = hour < 10 ? '0' + hour : hour;
minute = minute < 10 ? '0' + minute : minute;
return hour + ':' + minute + (this.options.format == '12h' ? ' ' + meridian : '');
}
});
// helper
function getTimeRange(start, end) {
start = start || 0;
end = end || 24;
var times = {'12h':[], '24h':[]}, i, h;
for (i = start, h=''; i<end; i++) {
h = ''+i;
if (i<10) h = '0'+h;
times['24h'].push({value: (h+':00')});
times['24h'].push({value: (h+':30')});
if (i === 0) {
h = 12;
times['12h'].push({value: (h+':00 AM')});
times['12h'].push({value: (h+':30 AM')});
}
if (i > 0 && i<13 && i!==12) {
times['12h'].push({value: (h+':00 AM')});
times['12h'].push({value: (h+':30 AM')});
}
if (i >= 12) {
h = h-12;
if (h === 0) h = 12;
if (h < 10) h = '0'+String(h);
times['12h'].push({value: (h+':00 PM')});
times['12h'].push({value: (h+':30 PM')});
}
}
return times;
}
});

View File

@ -0,0 +1,2 @@
/*! UIkit 2.27.4 | http://www.getuikit.com | (c) 2014 YOOtheme | MIT License */
!function(t){var e;window.UIkit2&&(e=t(UIkit2)),"function"==typeof define&&define.amd&&define("uikit-timepicker",["uikit"],function(){return e||t(UIkit2)})}(function(t){"use strict";function e(t,e){t=t||0,e=e||24;var i,o,a={"12h":[],"24h":[]};for(i=t,o="";e>i;i++)o=""+i,10>i&&(o="0"+o),a["24h"].push({value:o+":00"}),a["24h"].push({value:o+":30"}),0===i&&(o=12,a["12h"].push({value:o+":00 AM"}),a["12h"].push({value:o+":30 AM"})),i>0&&13>i&&12!==i&&(a["12h"].push({value:o+":00 AM"}),a["12h"].push({value:o+":30 AM"})),i>=12&&(o-=12,0===o&&(o=12),10>o&&(o="0"+String(o)),a["12h"].push({value:o+":00 PM"}),a["12h"].push({value:o+":30 PM"}));return a}t.component("timepicker",{defaults:{format:"24h",delay:0,start:0,end:24},boot:function(){t.$html.on("focus.timepicker.uikit","[data-uk-timepicker]",function(){var e=t.$(this);if(!e.data("timepicker")){var i=t.timepicker(e,t.Utils.options(e.attr("data-uk-timepicker")));setTimeout(function(){i.autocomplete.input.focus()},40)}})},init:function(){var i,o=this,a=e(this.options.start,this.options.end);this.options.minLength=0,this.options.template='<ul class="uk-nav uk-nav-autocomplete uk-autocomplete-results">{{~items}}<li data-value="{{$item.value}}"><a>{{$item.value}}</a></li>{{/items}}</ul>',this.options.source=function(t){t(a[o.options.format]||a["12h"])},this.element.is("input")?(this.element.wrap('<div class="uk-autocomplete"></div>'),i=this.element.parent()):i=this.element.addClass("uk-autocomplete"),this.autocomplete=t.autocomplete(i,this.options),this.autocomplete.dropdown.addClass("uk-dropdown-small uk-dropdown-scrollable"),this.autocomplete.on("show.uk.autocomplete",function(){var t=o.autocomplete.dropdown.find('[data-value="'+o.autocomplete.input.val()+'"]');setTimeout(function(){o.autocomplete.pick(t,!0)},10)}),this.autocomplete.input.on("focus",function(){o.autocomplete.value=Math.random(),o.autocomplete.triggercomplete()}).on("blur",t.Utils.debounce(function(){o.checkTime()},100)),this.element.data("timepicker",this)},checkTime:function(){var t,e,i,o,a="AM",u=this.autocomplete.input.val();"12h"==this.options.format?(t=u.split(" "),e=t[0].split(":"),a=t[1]):e=u.split(":"),i=parseInt(e[0],10),o=parseInt(e[1],10),isNaN(i)&&(i=0),isNaN(o)&&(o=0),"12h"==this.options.format?(i>12?i=12:0>i&&(i=12),"am"===a||"a"===a?a="AM":("pm"===a||"p"===a)&&(a="PM"),"AM"!==a&&"PM"!==a&&(a="AM")):i>=24?i=23:0>i&&(i=0),0>o?o=0:o>=60&&(o=0),this.autocomplete.input.val(this.formatTime(i,o,a)).trigger("change")},formatTime:function(t,e,i){return t=10>t?"0"+t:t,e=10>e?"0"+e:e,t+":"+e+("12h"==this.options.format?" "+i:"")}})});

View File

@ -0,0 +1,235 @@
/*! UIkit 2.27.4 | http://www.getuikit.com | (c) 2014 YOOtheme | MIT License */
(function(addon) {
var component;
if (window.UIkit2) {
component = addon(UIkit2);
}
if (typeof define == 'function' && define.amd) {
define('uikit-tooltip', ['uikit'], function(){
return component || addon(UIkit2);
});
}
})(function(UI){
"use strict";
var $tooltip, // tooltip container
tooltipdelay, checkIdle;
UI.component('tooltip', {
defaults: {
offset: 5,
pos: 'top',
animation: false,
delay: 0, // in miliseconds
cls: '',
activeClass: 'uk-active',
src: function(ele) {
var title = ele.attr('title');
if (title !== undefined) {
ele.data('cached-title', title).removeAttr('title');
}
return ele.data("cached-title");
}
},
tip: '',
boot: function() {
// init code
UI.$html.on('mouseenter.tooltip.uikit focus.tooltip.uikit', '[data-uk-tooltip]', function(e) {
var ele = UI.$(this);
if (!ele.data('tooltip')) {
UI.tooltip(ele, UI.Utils.options(ele.attr('data-uk-tooltip')));
ele.trigger('mouseenter');
}
});
},
init: function() {
var $this = this;
if (!$tooltip) {
$tooltip = UI.$('<div class="uk-tooltip"></div>').appendTo("body");
}
this.on({
focus : function(e) { $this.show(); },
blur : function(e) { $this.hide(); },
mouseenter : function(e) { $this.show(); },
mouseleave : function(e) { $this.hide(); }
});
},
show: function() {
this.tip = typeof(this.options.src) === 'function' ? this.options.src(this.element) : this.options.src;
if (tooltipdelay) clearTimeout(tooltipdelay);
if (checkIdle) clearInterval(checkIdle);
if (typeof(this.tip) === 'string' ? !this.tip.length:true) return;
$tooltip.stop().css({top: -2000, visibility: 'hidden'}).removeClass(this.options.activeClass).show();
$tooltip.html('<div class="uk-tooltip-inner">' + this.tip + '</div>');
var $this = this,
pos = UI.$.extend({}, this.element.offset(), {width: this.element[0].offsetWidth, height: this.element[0].offsetHeight}),
width = $tooltip[0].offsetWidth,
height = $tooltip[0].offsetHeight,
offset = typeof(this.options.offset) === "function" ? this.options.offset.call(this.element) : this.options.offset,
position = typeof(this.options.pos) === "function" ? this.options.pos.call(this.element) : this.options.pos,
tmppos = position.split("-"),
tcss = {
display : 'none',
visibility : 'visible',
top : (pos.top + pos.height + height),
left : pos.left
};
// prevent strange position
// when tooltip is in offcanvas etc.
if (UI.$html.css('position')=='fixed' || UI.$body.css('position')=='fixed'){
var bodyoffset = UI.$('body').offset(),
htmloffset = UI.$('html').offset(),
docoffset = {top: (htmloffset.top + bodyoffset.top), left: (htmloffset.left + bodyoffset.left)};
pos.left -= docoffset.left;
pos.top -= docoffset.top;
}
if ((tmppos[0] == 'left' || tmppos[0] == 'right') && UI.langdirection == 'right') {
tmppos[0] = tmppos[0] == 'left' ? 'right' : 'left';
}
var variants = {
bottom : {top: pos.top + pos.height + offset, left: pos.left + pos.width / 2 - width / 2},
top : {top: pos.top - height - offset, left: pos.left + pos.width / 2 - width / 2},
left : {top: pos.top + pos.height / 2 - height / 2, left: pos.left - width - offset},
right : {top: pos.top + pos.height / 2 - height / 2, left: pos.left + pos.width + offset}
};
UI.$.extend(tcss, variants[tmppos[0]]);
if (tmppos.length == 2) tcss.left = (tmppos[1] == 'left') ? (pos.left) : ((pos.left + pos.width) - width);
var boundary = this.checkBoundary(tcss.left, tcss.top, width, height);
if(boundary) {
switch(boundary) {
case 'x':
if (tmppos.length == 2) {
position = tmppos[0]+"-"+(tcss.left < 0 ? 'left': 'right');
} else {
position = tcss.left < 0 ? 'right': 'left';
}
break;
case 'y':
if (tmppos.length == 2) {
position = (tcss.top < 0 ? 'bottom': 'top')+'-'+tmppos[1];
} else {
position = (tcss.top < 0 ? 'bottom': 'top');
}
break;
case 'xy':
if (tmppos.length == 2) {
position = (tcss.top < 0 ? 'bottom': 'top')+'-'+(tcss.left < 0 ? 'left': 'right');
} else {
position = tcss.left < 0 ? 'right': 'left';
}
break;
}
tmppos = position.split('-');
UI.$.extend(tcss, variants[tmppos[0]]);
if (tmppos.length == 2) tcss.left = (tmppos[1] == 'left') ? (pos.left) : ((pos.left + pos.width) - width);
}
tcss.left -= UI.$body.position().left;
tooltipdelay = setTimeout(function(){
$tooltip.css(tcss).attr('class', ['uk-tooltip', 'uk-tooltip-'+position, $this.options.cls].join(' '));
if ($this.options.animation) {
$tooltip.css({opacity: 0, display: 'block'}).addClass($this.options.activeClass).animate({opacity: 1}, parseInt($this.options.animation, 10) || 400);
} else {
$tooltip.show().addClass($this.options.activeClass);
}
tooltipdelay = false;
// close tooltip if element was removed or hidden
checkIdle = setInterval(function(){
if(!$this.element.is(':visible')) $this.hide();
}, 150);
}, parseInt(this.options.delay, 10) || 0);
},
hide: function() {
if (this.element.is('input') && this.element[0]===document.activeElement) return;
if (tooltipdelay) clearTimeout(tooltipdelay);
if (checkIdle) clearInterval(checkIdle);
$tooltip.stop();
if (this.options.animation) {
var $this = this;
$tooltip.fadeOut(parseInt(this.options.animation, 10) || 400, function(){
$tooltip.removeClass($this.options.activeClass)
});
} else {
$tooltip.hide().removeClass(this.options.activeClass);
}
},
content: function() {
return this.tip;
},
checkBoundary: function(left, top, width, height) {
var axis = "";
if(left < 0 || ((left - UI.$win.scrollLeft())+width) > window.innerWidth) {
axis += "x";
}
if(top < 0 || ((top - UI.$win.scrollTop())+height) > window.innerHeight) {
axis += "y";
}
return axis;
}
});
return UI.tooltip;
});

View File

@ -0,0 +1,2 @@
/*! UIkit 2.27.4 | http://www.getuikit.com | (c) 2014 YOOtheme | MIT License */
!function(t){var i;window.UIkit2&&(i=t(UIkit2)),"function"==typeof define&&define.amd&&define("uikit-tooltip",["uikit"],function(){return i||t(UIkit2)})}(function(t){"use strict";var i,o,e;return t.component("tooltip",{defaults:{offset:5,pos:"top",animation:!1,delay:0,cls:"",activeClass:"uk-active",src:function(t){var i=t.attr("title");return void 0!==i&&t.data("cached-title",i).removeAttr("title"),t.data("cached-title")}},tip:"",boot:function(){t.$html.on("mouseenter.tooltip.uikit focus.tooltip.uikit","[data-uk-tooltip]",function(){var i=t.$(this);i.data("tooltip")||(t.tooltip(i,t.Utils.options(i.attr("data-uk-tooltip"))),i.trigger("mouseenter"))})},init:function(){var o=this;i||(i=t.$('<div class="uk-tooltip"></div>').appendTo("body")),this.on({focus:function(){o.show()},blur:function(){o.hide()},mouseenter:function(){o.show()},mouseleave:function(){o.hide()}})},show:function(){if(this.tip="function"==typeof this.options.src?this.options.src(this.element):this.options.src,o&&clearTimeout(o),e&&clearInterval(e),"string"==typeof this.tip?this.tip.length:0){i.stop().css({top:-2e3,visibility:"hidden"}).removeClass(this.options.activeClass).show(),i.html('<div class="uk-tooltip-inner">'+this.tip+"</div>");var s=this,n=t.$.extend({},this.element.offset(),{width:this.element[0].offsetWidth,height:this.element[0].offsetHeight}),l=i[0].offsetWidth,f=i[0].offsetHeight,a="function"==typeof this.options.offset?this.options.offset.call(this.element):this.options.offset,p="function"==typeof this.options.pos?this.options.pos.call(this.element):this.options.pos,h=p.split("-"),c={display:"none",visibility:"visible",top:n.top+n.height+f,left:n.left};if("fixed"==t.$html.css("position")||"fixed"==t.$body.css("position")){var r=t.$("body").offset(),d=t.$("html").offset(),u={top:d.top+r.top,left:d.left+r.left};n.left-=u.left,n.top-=u.top}"left"!=h[0]&&"right"!=h[0]||"right"!=t.langdirection||(h[0]="left"==h[0]?"right":"left");var m={bottom:{top:n.top+n.height+a,left:n.left+n.width/2-l/2},top:{top:n.top-f-a,left:n.left+n.width/2-l/2},left:{top:n.top+n.height/2-f/2,left:n.left-l-a},right:{top:n.top+n.height/2-f/2,left:n.left+n.width+a}};t.$.extend(c,m[h[0]]),2==h.length&&(c.left="left"==h[1]?n.left:n.left+n.width-l);var v=this.checkBoundary(c.left,c.top,l,f);if(v){switch(v){case"x":p=2==h.length?h[0]+"-"+(c.left<0?"left":"right"):c.left<0?"right":"left";break;case"y":p=2==h.length?(c.top<0?"bottom":"top")+"-"+h[1]:c.top<0?"bottom":"top";break;case"xy":p=2==h.length?(c.top<0?"bottom":"top")+"-"+(c.left<0?"left":"right"):c.left<0?"right":"left"}h=p.split("-"),t.$.extend(c,m[h[0]]),2==h.length&&(c.left="left"==h[1]?n.left:n.left+n.width-l)}c.left-=t.$body.position().left,o=setTimeout(function(){i.css(c).attr("class",["uk-tooltip","uk-tooltip-"+p,s.options.cls].join(" ")),s.options.animation?i.css({opacity:0,display:"block"}).addClass(s.options.activeClass).animate({opacity:1},parseInt(s.options.animation,10)||400):i.show().addClass(s.options.activeClass),o=!1,e=setInterval(function(){s.element.is(":visible")||s.hide()},150)},parseInt(this.options.delay,10)||0)}},hide:function(){if(!this.element.is("input")||this.element[0]!==document.activeElement)if(o&&clearTimeout(o),e&&clearInterval(e),i.stop(),this.options.animation){var t=this;i.fadeOut(parseInt(this.options.animation,10)||400,function(){i.removeClass(t.options.activeClass)})}else i.hide().removeClass(this.options.activeClass)},content:function(){return this.tip},checkBoundary:function(i,o,e,s){var n="";return(0>i||i-t.$win.scrollLeft()+e>window.innerWidth)&&(n+="x"),(0>o||o-t.$win.scrollTop()+s>window.innerHeight)&&(n+="y"),n}}),t.tooltip});

View File

@ -0,0 +1,262 @@
/*! UIkit 2.27.4 | http://www.getuikit.com | (c) 2014 YOOtheme | MIT License */
(function(addon) {
var component;
if (window.UIkit2) {
component = addon(UIkit2);
}
if (typeof define == 'function' && define.amd) {
define('uikit-upload', ['uikit'], function(){
return component || addon(UIkit2);
});
}
})(function(UI){
"use strict";
UI.component('uploadSelect', {
init: function() {
var $this = this;
this.on('change', function() {
xhrupload($this.element[0].files, $this.options);
var twin = $this.element.clone(true).data('uploadSelect', $this);
$this.element.replaceWith(twin);
$this.element = twin;
});
}
});
UI.component('uploadDrop', {
defaults: {
'dragoverClass': 'uk-dragover'
},
init: function() {
var $this = this, hasdragCls = false;
this.on('drop', function(e){
if (e.originalEvent.dataTransfer && e.originalEvent.dataTransfer.files) {
e.stopPropagation();
e.preventDefault();
$this.element.removeClass($this.options.dragoverClass);
$this.element.trigger('dropped.uk.upload', [e.originalEvent.dataTransfer.files]);
xhrupload(e.originalEvent.dataTransfer.files, $this.options);
}
}).on('dragenter', function(e){
e.stopPropagation();
e.preventDefault();
}).on('dragover', function(e){
e.stopPropagation();
e.preventDefault();
if (!hasdragCls) {
$this.element.addClass($this.options.dragoverClass);
hasdragCls = true;
}
}).on('dragleave', function(e){
e.stopPropagation();
e.preventDefault();
$this.element.removeClass($this.options.dragoverClass);
hasdragCls = false;
});
}
});
UI.support.ajaxupload = (function() {
function supportFileAPI() {
var fi = document.createElement('INPUT'); fi.type = 'file'; return 'files' in fi;
}
function supportAjaxUploadProgressEvents() {
var xhr = new XMLHttpRequest(); return !! (xhr && ('upload' in xhr) && ('onprogress' in xhr.upload));
}
function supportFormData() {
return !! window.FormData;
}
return supportFileAPI() && supportAjaxUploadProgressEvents() && supportFormData();
})();
function xhrupload(files, settings) {
if (!UI.support.ajaxupload){
return this;
}
settings = UI.$.extend({}, xhrupload.defaults, settings);
if (!files.length){
return;
}
if (settings.allow !== '*.*') {
for(var i=0,file;file=files[i];i++) {
if(!matchName(settings.allow, file.name)) {
if(typeof(settings.notallowed) == 'string') {
alert(settings.notallowed);
} else {
settings.notallowed(file, settings);
}
return;
}
}
}
var complete = settings.complete;
if (settings.single){
var count = files.length,
uploaded = 0,
allow = true;
settings.beforeAll(files);
settings.complete = function(response, xhr){
uploaded = uploaded + 1;
complete(response, xhr);
if (settings.filelimit && uploaded >= settings.filelimit){
allow = false;
}
if (allow && uploaded<count){
upload([files[uploaded]], settings);
} else {
settings.allcomplete(response, xhr);
}
};
upload([files[0]], settings);
} else {
settings.complete = function(response, xhr){
complete(response, xhr);
settings.allcomplete(response, xhr);
};
upload(files, settings);
}
function upload(files, settings){
// upload all at once
var formData = new FormData(), xhr = new XMLHttpRequest();
if (settings.before(settings, files)===false) return;
for (var i = 0, f; f = files[i]; i++) { formData.append(settings.param, f); }
for (var p in settings.params) { formData.append(p, settings.params[p]); }
// Add any event handlers here...
xhr.upload.addEventListener('progress', function(e){
var percent = (e.loaded / e.total)*100;
settings.progress(percent, e);
}, false);
xhr.addEventListener('loadstart', function(e){ settings.loadstart(e); }, false);
xhr.addEventListener('load', function(e){ settings.load(e); }, false);
xhr.addEventListener('loadend', function(e){ settings.loadend(e); }, false);
xhr.addEventListener('error', function(e){ settings.error(e); }, false);
xhr.addEventListener('abort', function(e){ settings.abort(e); }, false);
xhr.open(settings.method, settings.action, true);
if (settings.type=='json') {
xhr.setRequestHeader('Accept', 'application/json');
}
for (var h in settings.headers) {
xhr.setRequestHeader(h, settings.headers[h]);
}
xhr.onreadystatechange = function() {
settings.readystatechange(xhr);
if (xhr.readyState==4){
var response = xhr.responseText;
if (settings.type=='json') {
try {
response = UI.$.parseJSON(response);
} catch(e) {
response = false;
}
}
settings.complete(response, xhr);
}
};
settings.beforeSend(xhr);
xhr.send(formData);
}
}
xhrupload.defaults = {
action: '',
single: true,
method: 'POST',
param : 'files[]',
params: {},
allow : '*.*',
type : 'text',
filelimit: false,
headers: {},
// events
before : function(o){},
beforeSend : function(xhr){},
beforeAll : function(){},
loadstart : function(){},
load : function(){},
loadend : function(){},
error : function(){},
abort : function(){},
progress : function(){},
complete : function(){},
allcomplete : function(){},
readystatechange: function(){},
notallowed : function(file, settings){ alert('Only the following file types are allowed: '+settings.allow); }
};
function matchName(pattern, path) {
var parsedPattern = '^' + pattern.replace(/\//g, '\\/').
replace(/\*\*/g, '(\\/[^\\/]+)*').
replace(/\*/g, '[^\\/]+').
replace(/((?!\\))\?/g, '$1.') + '$';
parsedPattern = '^' + parsedPattern + '$';
return (path.match(new RegExp(parsedPattern, 'i')) !== null);
}
UI.Utils.xhrupload = xhrupload;
return xhrupload;
});

View File

@ -0,0 +1,2 @@
/*! UIkit 2.27.4 | http://www.getuikit.com | (c) 2014 YOOtheme | MIT License */
!function(e){var t;window.UIkit2&&(t=e(UIkit2)),"function"==typeof define&&define.amd&&define("uikit-upload",["uikit"],function(){return t||e(UIkit2)})}(function(e){"use strict";function t(o,a){function r(t,n){var o=new FormData,a=new XMLHttpRequest;if(n.before(n,t)!==!1){for(var r,i=0;r=t[i];i++)o.append(n.param,r);for(var l in n.params)o.append(l,n.params[l]);a.upload.addEventListener("progress",function(e){var t=e.loaded/e.total*100;n.progress(t,e)},!1),a.addEventListener("loadstart",function(e){n.loadstart(e)},!1),a.addEventListener("load",function(e){n.load(e)},!1),a.addEventListener("loadend",function(e){n.loadend(e)},!1),a.addEventListener("error",function(e){n.error(e)},!1),a.addEventListener("abort",function(e){n.abort(e)},!1),a.open(n.method,n.action,!0),"json"==n.type&&a.setRequestHeader("Accept","application/json");for(var s in n.headers)a.setRequestHeader(s,n.headers[s]);a.onreadystatechange=function(){if(n.readystatechange(a),4==a.readyState){var t=a.responseText;if("json"==n.type)try{t=e.$.parseJSON(t)}catch(o){t=!1}n.complete(t,a)}},n.beforeSend(a),a.send(o)}}if(!e.support.ajaxupload)return this;if(a=e.$.extend({},t.defaults,a),o.length){if("*.*"!==a.allow)for(var i,l=0;i=o[l];l++)if(!n(a.allow,i.name))return"string"==typeof a.notallowed?alert(a.notallowed):a.notallowed(i,a),void 0;var s=a.complete;if(a.single){var d=o.length,f=0,p=!0;a.beforeAll(o),a.complete=function(e,t){f+=1,s(e,t),a.filelimit&&f>=a.filelimit&&(p=!1),p&&d>f?r([o[f]],a):a.allcomplete(e,t)},r([o[0]],a)}else a.complete=function(e,t){s(e,t),a.allcomplete(e,t)},r(o,a)}}function n(e,t){var n="^"+e.replace(/\//g,"\\/").replace(/\*\*/g,"(\\/[^\\/]+)*").replace(/\*/g,"[^\\/]+").replace(/((?!\\))\?/g,"$1.")+"$";return n="^"+n+"$",null!==t.match(new RegExp(n,"i"))}return e.component("uploadSelect",{init:function(){var e=this;this.on("change",function(){t(e.element[0].files,e.options);var n=e.element.clone(!0).data("uploadSelect",e);e.element.replaceWith(n),e.element=n})}}),e.component("uploadDrop",{defaults:{dragoverClass:"uk-dragover"},init:function(){var e=this,n=!1;this.on("drop",function(n){n.originalEvent.dataTransfer&&n.originalEvent.dataTransfer.files&&(n.stopPropagation(),n.preventDefault(),e.element.removeClass(e.options.dragoverClass),e.element.trigger("dropped.uk.upload",[n.originalEvent.dataTransfer.files]),t(n.originalEvent.dataTransfer.files,e.options))}).on("dragenter",function(e){e.stopPropagation(),e.preventDefault()}).on("dragover",function(t){t.stopPropagation(),t.preventDefault(),n||(e.element.addClass(e.options.dragoverClass),n=!0)}).on("dragleave",function(t){t.stopPropagation(),t.preventDefault(),e.element.removeClass(e.options.dragoverClass),n=!1})}}),e.support.ajaxupload=function(){function e(){var e=document.createElement("INPUT");return e.type="file","files"in e}function t(){var e=new XMLHttpRequest;return!!(e&&"upload"in e&&"onprogress"in e.upload)}function n(){return!!window.FormData}return e()&&t()&&n()}(),t.defaults={action:"",single:!0,method:"POST",param:"files[]",params:{},allow:"*.*",type:"text",filelimit:!1,headers:{},before:function(){},beforeSend:function(){},beforeAll:function(){},loadstart:function(){},load:function(){},loadend:function(){},error:function(){},abort:function(){},progress:function(){},complete:function(){},allcomplete:function(){},readystatechange:function(){},notallowed:function(e,t){alert("Only the following file types are allowed: "+t.allow)}},e.Utils.xhrupload=t,t});