From c94fb32c7a3c28b18a27460aa2447eeec1fac1de Mon Sep 17 00:00:00 2001 From: Pascal Szewczyk Date: Mon, 18 Jul 2016 23:23:54 +0200 Subject: uikit added --- js/components/accordion.js | 174 ++ js/components/accordion.min.js | 2 + js/components/autocomplete.js | 334 ++++ js/components/autocomplete.min.js | 2 + js/components/datepicker.js | 3166 ++++++++++++++++++++++++++++++ js/components/datepicker.min.js | 3 + js/components/form-password.js | 67 + js/components/form-password.min.js | 2 + js/components/form-select.js | 77 + js/components/form-select.min.js | 2 + js/components/grid-parallax.js | 168 ++ js/components/grid-parallax.min.js | 2 + js/components/grid.js | 527 +++++ js/components/grid.min.js | 2 + js/components/htmleditor.js | 679 +++++++ js/components/htmleditor.min.js | 2 + js/components/lightbox.js | 591 ++++++ js/components/lightbox.min.js | 2 + js/components/nestable.js | 653 ++++++ js/components/nestable.min.js | 2 + js/components/notify.js | 189 ++ js/components/notify.min.js | 2 + js/components/pagination.js | 147 ++ js/components/pagination.min.js | 2 + js/components/parallax.js | 462 +++++ js/components/parallax.min.js | 2 + js/components/search.js | 92 + js/components/search.min.js | 2 + js/components/slider.js | 540 +++++ js/components/slider.min.js | 2 + js/components/slideset.js | 514 +++++ js/components/slideset.min.js | 2 + js/components/slideshow-fx.js | 383 ++++ js/components/slideshow-fx.min.js | 2 + js/components/slideshow.js | 560 ++++++ js/components/slideshow.min.js | 2 + js/components/sortable.js | 688 +++++++ js/components/sortable.min.js | 2 + js/components/sticky.js | 364 ++++ js/components/sticky.min.js | 2 + js/components/timepicker.js | 192 ++ js/components/timepicker.min.js | 2 + js/components/tooltip.js | 234 +++ js/components/tooltip.min.js | 2 + js/components/upload.js | 257 +++ js/components/upload.min.js | 2 + js/core/alert.js | 66 + js/core/alert.min.js | 2 + js/core/button.js | 157 ++ js/core/button.min.js | 2 + js/core/core.js | 786 ++++++++ js/core/core.min.js | 2 + js/core/cover.js | 95 + js/core/cover.min.js | 2 + js/core/dropdown.js | 525 +++++ js/core/dropdown.min.js | 2 + js/core/grid.js | 117 ++ js/core/grid.min.js | 2 + js/core/modal.js | 393 ++++ js/core/modal.min.js | 2 + js/core/nav.js | 136 ++ js/core/nav.min.js | 2 + js/core/offcanvas.js | 180 ++ js/core/offcanvas.min.js | 2 + js/core/scrollspy.js | 209 ++ js/core/scrollspy.min.js | 2 + js/core/smooth-scroll.js | 62 + js/core/smooth-scroll.min.js | 2 + js/core/switcher.js | 307 +++ js/core/switcher.min.js | 2 + js/core/tab.js | 167 ++ js/core/tab.min.js | 2 + js/core/toggle.js | 120 ++ js/core/toggle.min.js | 2 + js/core/touch.js | 175 ++ js/core/touch.min.js | 2 + js/core/utility.js | 319 +++ js/core/utility.min.js | 2 + js/uikit.js | 3814 ++++++++++++++++++++++++++++++++++++ js/uikit.min.js | 3 + 80 files changed, 18768 insertions(+) create mode 100755 js/components/accordion.js create mode 100755 js/components/accordion.min.js create mode 100755 js/components/autocomplete.js create mode 100755 js/components/autocomplete.min.js create mode 100755 js/components/datepicker.js create mode 100755 js/components/datepicker.min.js create mode 100755 js/components/form-password.js create mode 100755 js/components/form-password.min.js create mode 100755 js/components/form-select.js create mode 100755 js/components/form-select.min.js create mode 100755 js/components/grid-parallax.js create mode 100755 js/components/grid-parallax.min.js create mode 100755 js/components/grid.js create mode 100755 js/components/grid.min.js create mode 100755 js/components/htmleditor.js create mode 100755 js/components/htmleditor.min.js create mode 100755 js/components/lightbox.js create mode 100755 js/components/lightbox.min.js create mode 100755 js/components/nestable.js create mode 100755 js/components/nestable.min.js create mode 100755 js/components/notify.js create mode 100755 js/components/notify.min.js create mode 100755 js/components/pagination.js create mode 100755 js/components/pagination.min.js create mode 100755 js/components/parallax.js create mode 100755 js/components/parallax.min.js create mode 100755 js/components/search.js create mode 100755 js/components/search.min.js create mode 100755 js/components/slider.js create mode 100755 js/components/slider.min.js create mode 100755 js/components/slideset.js create mode 100755 js/components/slideset.min.js create mode 100755 js/components/slideshow-fx.js create mode 100755 js/components/slideshow-fx.min.js create mode 100755 js/components/slideshow.js create mode 100755 js/components/slideshow.min.js create mode 100755 js/components/sortable.js create mode 100755 js/components/sortable.min.js create mode 100755 js/components/sticky.js create mode 100755 js/components/sticky.min.js create mode 100755 js/components/timepicker.js create mode 100755 js/components/timepicker.min.js create mode 100755 js/components/tooltip.js create mode 100755 js/components/tooltip.min.js create mode 100755 js/components/upload.js create mode 100755 js/components/upload.min.js create mode 100755 js/core/alert.js create mode 100755 js/core/alert.min.js create mode 100755 js/core/button.js create mode 100755 js/core/button.min.js create mode 100755 js/core/core.js create mode 100755 js/core/core.min.js create mode 100755 js/core/cover.js create mode 100755 js/core/cover.min.js create mode 100755 js/core/dropdown.js create mode 100755 js/core/dropdown.min.js create mode 100755 js/core/grid.js create mode 100755 js/core/grid.min.js create mode 100755 js/core/modal.js create mode 100755 js/core/modal.min.js create mode 100755 js/core/nav.js create mode 100755 js/core/nav.min.js create mode 100755 js/core/offcanvas.js create mode 100755 js/core/offcanvas.min.js create mode 100755 js/core/scrollspy.js create mode 100755 js/core/scrollspy.min.js create mode 100755 js/core/smooth-scroll.js create mode 100755 js/core/smooth-scroll.min.js create mode 100755 js/core/switcher.js create mode 100755 js/core/switcher.min.js create mode 100755 js/core/tab.js create mode 100755 js/core/tab.min.js create mode 100755 js/core/toggle.js create mode 100755 js/core/toggle.min.js create mode 100755 js/core/touch.js create mode 100755 js/core/touch.min.js create mode 100755 js/core/utility.js create mode 100755 js/core/utility.min.js create mode 100755 js/uikit.js create mode 100755 js/uikit.min.js (limited to 'js') diff --git a/js/components/accordion.js b/js/components/accordion.js new file mode 100755 index 0000000..2401780 --- /dev/null +++ b/js/components/accordion.js @@ -0,0 +1,174 @@ +/*! UIkit 2.26.4 | http://www.getuikit.com | (c) 2014 YOOtheme | MIT License */ +(function(addon) { + var component; + + if (window.UIkit) { + component = addon(UIkit); + } + + if (typeof define == "function" && define.amd) { + define("uikit-accordion", ["uikit"], function(){ + return component || addon(UIkit); + }); + } +})(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(); + + if (this.options.showfirst) { + this.toggleItem(this.toggle.eq(0).data('wrapper'), false, false); + } + }, + + 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() { + + 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('
').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]); + } + + }); + + // 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; +}); diff --git a/js/components/accordion.min.js b/js/components/accordion.min.js new file mode 100755 index 0000000..ca3e452 --- /dev/null +++ b/js/components/accordion.min.js @@ -0,0 +1,2 @@ +/*! UIkit 2.26.4 | http://www.getuikit.com | (c) 2014 YOOtheme | MIT License */ +!function(t){var i;window.UIkit&&(i=t(UIkit)),"function"==typeof define&&define.amd&&define("uikit-accordion",["uikit"],function(){return i||t(UIkit)})}(function(t){"use strict";function i(i){var o=t.$(i),e="auto";if(o.is(":visible"))e=o.outerHeight();else{var a={position:o.css("position"),visibility:o.css("visibility"),display:o.css("display")};e=o.css({position:"absolute",visibility:"hidden",display:"block"}).outerHeight(),o.css(a)}return e}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(o){o.preventDefault(),i.toggleItem(t.$(this).data("wrapper"),i.options.animate,i.options.collapse)}),this.update(),this.options.showfirst&&this.toggleItem(this.toggle.eq(0).data("wrapper"),!1,!1)},toggleItem:function(o,e,a){var n=this;o.data("toggle").toggleClass(this.options.clsactive),o.data("content").toggleClass(this.options.clsactive);var s=o.data("toggle").hasClass(this.options.clsactive);a&&(this.toggle.not(o.data("toggle")).removeClass(this.options.clsactive),this.content.not(o.data("content")).removeClass(this.options.clsactive).parent().stop().css("overflow","hidden").animate({height:0},{easing:this.options.easing,duration:e?this.options.duration:0}).attr("aria-expanded","false")),o.stop().css("overflow","hidden"),e?o.animate({height:s?i(o.data("content")):0},{easing:this.options.easing,duration:this.options.duration,complete:function(){s&&(o.css({overflow:"",height:"auto"}),t.Utils.checkDisplay(o.data("content"))),n.trigger("display.uk.check")}}):(o.height(s?"auto":0),s&&(o.css({overflow:""}),t.Utils.checkDisplay(o.data("content"))),this.trigger("display.uk.check")),o.attr("aria-expanded",s),this.element.trigger("toggle.uk.accordion",[s,o.data("toggle"),o.data("content")])},update:function(){var i,o,e,a=this;this.toggle=this.find(this.options.toggle),this.content=this.find(this.options.containers),this.content.each(function(n){i=t.$(this),i.parent().data("wrapper")?o=i.parent():(o=t.$(this).wrap('
').parent(),o.attr("aria-expanded","false")),e=a.toggle.eq(n),o.data("toggle",e),o.data("content",i),e.data("wrapper",o),i.data("wrapper",o)}),this.element.trigger("update.uk.accordion",[this])}}),t.accordion}); \ No newline at end of file diff --git a/js/components/autocomplete.js b/js/components/autocomplete.js new file mode 100755 index 0000000..58a405d --- /dev/null +++ b/js/components/autocomplete.js @@ -0,0 +1,334 @@ +/*! UIkit 2.26.4 | http://www.getuikit.com | (c) 2014 YOOtheme | MIT License */ +(function(addon) { + + var component; + + if (window.UIkit) { + component = addon(UIkit); + } + + if (typeof define == "function" && define.amd) { + define("uikit-autocomplete", ["uikit"], function(){ + return component || addon(UIkit); + }); + } + +})(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: '' + }, + + 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.$('
').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) { + + 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; +}); diff --git a/js/components/autocomplete.min.js b/js/components/autocomplete.min.js new file mode 100755 index 0000000..10eed9a --- /dev/null +++ b/js/components/autocomplete.min.js @@ -0,0 +1,2 @@ +/*! UIkit 2.26.4 | http://www.getuikit.com | (c) 2014 YOOtheme | MIT License */ +!function(t){var e;window.UIkit&&(e=t(UIkit)),"function"==typeof define&&define.amd&&define("uikit-autocomplete",["uikit"],function(){return e||t(UIkit)})}(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:''},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.$('
').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)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.lengtha-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}); \ No newline at end of file diff --git a/js/components/datepicker.js b/js/components/datepicker.js new file mode 100755 index 0000000..31890b4 --- /dev/null +++ b/js/components/datepicker.js @@ -0,0 +1,3166 @@ +/*! UIkit 2.26.4 | http://www.getuikit.com | (c) 2014 YOOtheme | MIT License */ +(function(addon) { + + var component; + + if (window.UIkit) { + component = addon(UIkit); + } + + if (typeof define == "function" && define.amd) { + define("uikit-datepicker", ["uikit"], function(){ + return component || addon(UIkit); + }); + } + +})(function(UI){ + + "use strict"; + + // Datepicker + + var active = false, dropdown, moment; + + UI.component('datepicker', { + + defaults: { + mobile: false, + weekstart: 1, + i18n: { + months : ['January','February','March','April','May','June','July','August','September','October','November','December'], + weekdays : ['Sun','Mon','Tue','Wed','Thu','Fri','Sat'] + }, + format: "YYYY-MM-DD", + offsettop: 5, + maxDate: false, + minDate: false, + pos: 'auto', + template: function(data, opts) { + + var content = '', i; + + content += '
'; + content += ''; + content += ''; + + if (UI.formSelect) { + + var currentyear = (new Date()).getFullYear(), options = [], months, years, minYear, maxYear; + + for (i=0;i'+opts.i18n.months[i]+''); + } else { + options.push(''); + } + } + + months = ''+ opts.i18n.months[data.month] + ''; + + // -- + + options = []; + + minYear = data.minDate ? data.minDate.year() : currentyear - 50; + maxYear = data.maxDate ? data.maxDate.year() : currentyear + 20; + + for (i=minYear;i<=maxYear;i++) { + if (i == data.year) { + options.push(''); + } else { + options.push(''); + } + } + + years = ''+ data.year + ''; + + content += '
'+ months + ' ' + years +'
'; + + } else { + content += '
'+ opts.i18n.months[data.month] +' '+ data.year+'
'; + } + + content += '
'; + + content += ''; + content += ''; + for(i = 0; i < data.weekdays.length; i++) { + if (data.weekdays[i]) { + content += ''; + } + } + content += ''; + + content += ''; + for(i = 0; i < data.days.length; i++) { + if (data.days[i] && data.days[i].length){ + content += ''; + for(var d = 0; d < data.days[i].length; d++) { + if (data.days[i][d]) { + var day = data.days[i][d], + cls = []; + + if(!day.inmonth) cls.push("uk-datepicker-table-muted"); + if(day.selected) cls.push("uk-active"); + if(day.disabled) cls.push('uk-datepicker-date-disabled uk-datepicker-table-muted'); + + content += ''; + } + } + content += ''; + } + } + content += ''; + + content += '
'+data.weekdays[i]+'
'+day.day.format("D")+'
'; + + return content; + } + }, + + boot: function() { + + UI.$win.on("resize orientationchange", function() { + + if (active) { + active.hide(); + } + }); + + // init code + UI.$html.on("focus.datepicker.uikit", "[data-uk-datepicker]", function(e) { + + var ele = UI.$(this); + + if (!ele.data("datepicker")) { + e.preventDefault(); + UI.datepicker(ele, UI.Utils.options(ele.attr("data-uk-datepicker"))); + ele.trigger("focus"); + } + }); + + UI.$html.on("click focus", '*', function(e) { + + var target = UI.$(e.target); + + if (active && target[0] != dropdown[0] && !target.data("datepicker") && !target.parents(".uk-datepicker:first").length) { + active.hide(); + } + }); + }, + + init: function() { + + // use native datepicker on touch devices + if (UI.support.touch && this.element.attr('type')=='date' && !this.options.mobile) { + return; + } + + var $this = this; + + this.current = this.element.val() ? moment(this.element.val(), this.options.format) : moment(); + + this.on("click focus", function(){ + if (active!==$this) $this.pick(this.value ? this.value:($this.options.minDate ? $this.options.minDate :'')); + }).on("change", function(){ + + if ($this.element.val() && !moment($this.element.val(), $this.options.format).isValid()) { + $this.element.val(moment().format($this.options.format)); + } + }); + + // init dropdown + if (!dropdown) { + + dropdown = UI.$('
'); + + dropdown.on("click", ".uk-datepicker-next, .uk-datepicker-previous, [data-date]", function(e){ + + e.stopPropagation(); + e.preventDefault(); + + var ele = UI.$(this); + + if (ele.hasClass('uk-datepicker-date-disabled')) return false; + + if (ele.is('[data-date]')) { + active.current = moment(ele.data("date")); + active.element.val(active.current.isValid() ? active.current.format(active.options.format) : null).trigger("change"); + active.hide(); + } else { + active.add((ele.hasClass("uk-datepicker-next") ? 1:-1), "months"); + } + }); + + dropdown.on('change', '.update-picker-month, .update-picker-year', function(){ + + var select = UI.$(this); + active[select.is('.update-picker-year') ? 'setYear':'setMonth'](Number(select.val())); + }); + + dropdown.appendTo("body"); + } + }, + + pick: function(initdate) { + + var offset = this.element.offset(), + css = {"left": offset.left, "right":""}; + + this.current = isNaN(initdate) ? moment(initdate, this.options.format):moment(); + this.initdate = this.current.format("YYYY-MM-DD"); + + this.update(); + + if (UI.langdirection == 'right') { + css.right = window.innerWidth - (css.left + this.element.outerWidth()); + css.left = ""; + } + + var posTop = (offset.top - this.element.outerHeight() + this.element.height()) - this.options.offsettop - dropdown.outerHeight(), + posBottom = offset.top + this.element.outerHeight() + this.options.offsettop; + + css.top = posBottom; + + if (this.options.pos == 'top') { + css.top = posTop; + } else if(this.options.pos == 'auto' && (window.innerHeight - posBottom - dropdown.outerHeight() < 0 && posTop >= 0) ) { + css.top = posTop; + } + + dropdown.css(css).show(); + this.trigger('show.uk.datepicker'); + + active = this; + }, + + add: function(unit, value) { + this.current.add(unit, value); + this.update(); + }, + + setMonth: function(month) { + this.current.month(month); + this.update(); + }, + + setYear: function(year) { + this.current.year(year); + this.update(); + }, + + update: function() { + + var data = this.getRows(this.current.year(), this.current.month()), + tpl = this.options.template(data, this.options); + + dropdown.html(tpl); + + this.trigger('update.uk.datepicker'); + }, + + getRows: function(year, month) { + + var opts = this.options, + now = moment().format('YYYY-MM-DD'), + days = [31, (year % 4 === 0 && year % 100 !== 0 || year % 400 === 0) ? 29 : 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31][month], + before = new Date(year, month, 1, 12).getDay(), + data = {"month":month, "year":year,"weekdays":[],"days":[], "maxDate": false, "minDate": false}, + row = []; + + if (opts.maxDate!==false){ + data.maxDate = isNaN(opts.maxDate) ? moment(opts.maxDate, opts.format) : moment().add(opts.maxDate, 'days'); + } + + if (opts.minDate!==false){ + data.minDate = isNaN(opts.minDate) ? moment(opts.minDate, opts.format) : moment().add(opts.minDate-1, 'days'); + } + + data.weekdays = (function(){ + + for (var i=0, arr=[]; i < 7; i++) { + + var day = i + (opts.weekstart || 0); + + while (day >= 7) { + day -= 7; + } + + arr.push(opts.i18n.weekdays[day]); + } + + return arr; + })(); + + if (opts.weekstart && opts.weekstart > 0) { + before -= opts.weekstart; + if (before < 0) { + before += 7; + } + } + + var cells = days + before, after = cells; + + while(after > 7) { after -= 7; } + + cells += 7 - after; + + var day, isDisabled, isSelected, isToday, isInMonth; + + for (var i = 0, r = 0; i < cells; i++) { + + day = new Date(year, month, 1 + (i - before), 12); + isDisabled = (data.minDate && data.minDate > day) || (data.maxDate && day > data.maxDate); + isInMonth = !(i < before || i >= (days + before)); + + day = moment(day); + + isSelected = this.initdate == day.format("YYYY-MM-DD"); + isToday = now == day.format("YYYY-MM-DD"); + + row.push({"selected": isSelected, "today": isToday, "disabled": isDisabled, "day":day, "inmonth":isInMonth}); + + if (++r === 7) { + data.days.push(row); + row = []; + r = 0; + } + } + + return data; + }, + + hide: function() { + + if (active && active === this) { + dropdown.hide(); + active = false; + + this.trigger('hide.uk.datepicker'); + } + } + }); + + //! moment.js + //! version : 2.8.3 + //! authors : Tim Wood, Iskren Chernev, Moment.js contributors + //! license : MIT + //! momentjs.com + + moment = (function (undefined) { + /************************************ + Constants + ************************************/ + var moment, + VERSION = '2.8.3', + // the global-scope this is NOT the global object in Node.js + globalScope = typeof global !== 'undefined' ? global : this, + oldGlobalMoment, + round = Math.round, + hasOwnProperty = Object.prototype.hasOwnProperty, + i, + + YEAR = 0, + MONTH = 1, + DATE = 2, + HOUR = 3, + MINUTE = 4, + SECOND = 5, + MILLISECOND = 6, + + // internal storage for locale config files + locales = {}, + + // extra moment internal properties (plugins register props here) + momentProperties = [], + + // check for nodeJS + hasModule = (typeof module !== 'undefined' && module.exports), + + // ASP.NET json date format regex + aspNetJsonRegex = /^\/?Date\((\-?\d+)/i, + aspNetTimeSpanJsonRegex = /(\-)?(?:(\d*)\.)?(\d+)\:(\d+)(?:\:(\d+)\.?(\d{3})?)?/, + + // from http://docs.closure-library.googlecode.com/git/closure_goog_date_date.js.source.html + // somewhat more in line with 4.4.3.2 2004 spec, but allows decimal anywhere + isoDurationRegex = /^(-)?P(?:(?:([0-9,.]*)Y)?(?:([0-9,.]*)M)?(?:([0-9,.]*)D)?(?:T(?:([0-9,.]*)H)?(?:([0-9,.]*)M)?(?:([0-9,.]*)S)?)?|([0-9,.]*)W)$/, + + // format tokens + formattingTokens = /(\[[^\[]*\])|(\\)?(Mo|MM?M?M?|Do|DDDo|DD?D?D?|ddd?d?|do?|w[o|w]?|W[o|W]?|Q|YYYYYY|YYYYY|YYYY|YY|gg(ggg?)?|GG(GGG?)?|e|E|a|A|hh?|HH?|mm?|ss?|S{1,4}|X|zz?|ZZ?|.)/g, + localFormattingTokens = /(\[[^\[]*\])|(\\)?(LT|LL?L?L?|l{1,4})/g, + + // parsing token regexes + parseTokenOneOrTwoDigits = /\d\d?/, // 0 - 99 + parseTokenOneToThreeDigits = /\d{1,3}/, // 0 - 999 + parseTokenOneToFourDigits = /\d{1,4}/, // 0 - 9999 + parseTokenOneToSixDigits = /[+\-]?\d{1,6}/, // -999,999 - 999,999 + parseTokenDigits = /\d+/, // nonzero number of digits + parseTokenWord = /[0-9]*['a-z\u00A0-\u05FF\u0700-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]+|[\u0600-\u06FF\/]+(\s*?[\u0600-\u06FF]+){1,2}/i, // any word (or two) characters or numbers including two/three word month in arabic. + parseTokenTimezone = /Z|[\+\-]\d\d:?\d\d/gi, // +00:00 -00:00 +0000 -0000 or Z + parseTokenT = /T/i, // T (ISO separator) + parseTokenTimestampMs = /[\+\-]?\d+(\.\d{1,3})?/, // 123456789 123456789.123 + parseTokenOrdinal = /\d{1,2}/, + + //strict parsing regexes + parseTokenOneDigit = /\d/, // 0 - 9 + parseTokenTwoDigits = /\d\d/, // 00 - 99 + parseTokenThreeDigits = /\d{3}/, // 000 - 999 + parseTokenFourDigits = /\d{4}/, // 0000 - 9999 + parseTokenSixDigits = /[+-]?\d{6}/, // -999,999 - 999,999 + parseTokenSignedNumber = /[+-]?\d+/, // -inf - inf + + // iso 8601 regex + // 0000-00-00 0000-W00 or 0000-W00-0 + T + 00 or 00:00 or 00:00:00 or 00:00:00.000 + +00:00 or +0000 or +00) + isoRegex = /^\s*(?:[+-]\d{6}|\d{4})-(?:(\d\d-\d\d)|(W\d\d$)|(W\d\d-\d)|(\d\d\d))((T| )(\d\d(:\d\d(:\d\d(\.\d+)?)?)?)?([\+\-]\d\d(?::?\d\d)?|\s*Z)?)?$/, + + isoFormat = 'YYYY-MM-DDTHH:mm:ssZ', + + isoDates = [ + ['YYYYYY-MM-DD', /[+-]\d{6}-\d{2}-\d{2}/], + ['YYYY-MM-DD', /\d{4}-\d{2}-\d{2}/], + ['GGGG-[W]WW-E', /\d{4}-W\d{2}-\d/], + ['GGGG-[W]WW', /\d{4}-W\d{2}/], + ['YYYY-DDD', /\d{4}-\d{3}/] + ], + + // iso time formats and regexes + isoTimes = [ + ['HH:mm:ss.SSSS', /(T| )\d\d:\d\d:\d\d\.\d+/], + ['HH:mm:ss', /(T| )\d\d:\d\d:\d\d/], + ['HH:mm', /(T| )\d\d:\d\d/], + ['HH', /(T| )\d\d/] + ], + + // timezone chunker '+10:00' > ['10', '00'] or '-1530' > ['-15', '30'] + parseTimezoneChunker = /([\+\-]|\d\d)/gi, + + // getter and setter names + proxyGettersAndSetters = 'Date|Hours|Minutes|Seconds|Milliseconds'.split('|'), + unitMillisecondFactors = { + 'Milliseconds' : 1, + 'Seconds' : 1e3, + 'Minutes' : 6e4, + 'Hours' : 36e5, + 'Days' : 864e5, + 'Months' : 2592e6, + 'Years' : 31536e6 + }, + + unitAliases = { + ms : 'millisecond', + s : 'second', + m : 'minute', + h : 'hour', + d : 'day', + D : 'date', + w : 'week', + W : 'isoWeek', + M : 'month', + Q : 'quarter', + y : 'year', + DDD : 'dayOfYear', + e : 'weekday', + E : 'isoWeekday', + gg: 'weekYear', + GG: 'isoWeekYear' + }, + + camelFunctions = { + dayofyear : 'dayOfYear', + isoweekday : 'isoWeekday', + isoweek : 'isoWeek', + weekyear : 'weekYear', + isoweekyear : 'isoWeekYear' + }, + + // format function strings + formatFunctions = {}, + + // default relative time thresholds + relativeTimeThresholds = { + s: 45, // seconds to minute + m: 45, // minutes to hour + h: 22, // hours to day + d: 26, // days to month + M: 11 // months to year + }, + + // tokens to ordinalize and pad + ordinalizeTokens = 'DDD w W M D d'.split(' '), + paddedTokens = 'M D H h m s w W'.split(' '), + + formatTokenFunctions = { + M : function () { + return this.month() + 1; + }, + MMM : function (format) { + return this.localeData().monthsShort(this, format); + }, + MMMM : function (format) { + return this.localeData().months(this, format); + }, + D : function () { + return this.date(); + }, + DDD : function () { + return this.dayOfYear(); + }, + d : function () { + return this.day(); + }, + dd : function (format) { + return this.localeData().weekdaysMin(this, format); + }, + ddd : function (format) { + return this.localeData().weekdaysShort(this, format); + }, + dddd : function (format) { + return this.localeData().weekdays(this, format); + }, + w : function () { + return this.week(); + }, + W : function () { + return this.isoWeek(); + }, + YY : function () { + return leftZeroFill(this.year() % 100, 2); + }, + YYYY : function () { + return leftZeroFill(this.year(), 4); + }, + YYYYY : function () { + return leftZeroFill(this.year(), 5); + }, + YYYYYY : function () { + var y = this.year(), sign = y >= 0 ? '+' : '-'; + return sign + leftZeroFill(Math.abs(y), 6); + }, + gg : function () { + return leftZeroFill(this.weekYear() % 100, 2); + }, + gggg : function () { + return leftZeroFill(this.weekYear(), 4); + }, + ggggg : function () { + return leftZeroFill(this.weekYear(), 5); + }, + GG : function () { + return leftZeroFill(this.isoWeekYear() % 100, 2); + }, + GGGG : function () { + return leftZeroFill(this.isoWeekYear(), 4); + }, + GGGGG : function () { + return leftZeroFill(this.isoWeekYear(), 5); + }, + e : function () { + return this.weekday(); + }, + E : function () { + return this.isoWeekday(); + }, + a : function () { + return this.localeData().meridiem(this.hours(), this.minutes(), true); + }, + A : function () { + return this.localeData().meridiem(this.hours(), this.minutes(), false); + }, + H : function () { + return this.hours(); + }, + h : function () { + return this.hours() % 12 || 12; + }, + m : function () { + return this.minutes(); + }, + s : function () { + return this.seconds(); + }, + S : function () { + return toInt(this.milliseconds() / 100); + }, + SS : function () { + return leftZeroFill(toInt(this.milliseconds() / 10), 2); + }, + SSS : function () { + return leftZeroFill(this.milliseconds(), 3); + }, + SSSS : function () { + return leftZeroFill(this.milliseconds(), 3); + }, + Z : function () { + var a = -this.zone(), + b = '+'; + if (a < 0) { + a = -a; + b = '-'; + } + return b + leftZeroFill(toInt(a / 60), 2) + ':' + leftZeroFill(toInt(a) % 60, 2); + }, + ZZ : function () { + var a = -this.zone(), + b = '+'; + if (a < 0) { + a = -a; + b = '-'; + } + return b + leftZeroFill(toInt(a / 60), 2) + leftZeroFill(toInt(a) % 60, 2); + }, + z : function () { + return this.zoneAbbr(); + }, + zz : function () { + return this.zoneName(); + }, + X : function () { + return this.unix(); + }, + Q : function () { + return this.quarter(); + } + }, + + deprecations = {}, + + lists = ['months', 'monthsShort', 'weekdays', 'weekdaysShort', 'weekdaysMin']; + + // Pick the first defined of two or three arguments. dfl comes from + // default. + function dfl(a, b, c) { + switch (arguments.length) { + case 2: return a != null ? a : b; + case 3: return a != null ? a : b != null ? b : c; + default: throw new Error('Implement me'); + } + } + + function hasOwnProp(a, b) { + return hasOwnProperty.call(a, b); + } + + function defaultParsingFlags() { + // We need to deep clone this object, and es5 standard is not very + // helpful. + return { + empty : false, + unusedTokens : [], + unusedInput : [], + overflow : -2, + charsLeftOver : 0, + nullInput : false, + invalidMonth : null, + invalidFormat : false, + userInvalidated : false, + iso: false + }; + } + + function printMsg(msg) { + if (moment.suppressDeprecationWarnings === false && + typeof console !== 'undefined' && console.warn) { + console.warn('Deprecation warning: ' + msg); + } + } + + function deprecate(msg, fn) { + var firstTime = true; + return extend(function () { + if (firstTime) { + printMsg(msg); + firstTime = false; + } + return fn.apply(this, arguments); + }, fn); + } + + function deprecateSimple(name, msg) { + if (!deprecations[name]) { + printMsg(msg); + deprecations[name] = true; + } + } + + function padToken(func, count) { + return function (a) { + return leftZeroFill(func.call(this, a), count); + }; + } + function ordinalizeToken(func, period) { + return function (a) { + return this.localeData().ordinal(func.call(this, a), period); + }; + } + + while (ordinalizeTokens.length) { + i = ordinalizeTokens.pop(); + formatTokenFunctions[i + 'o'] = ordinalizeToken(formatTokenFunctions[i], i); + } + while (paddedTokens.length) { + i = paddedTokens.pop(); + formatTokenFunctions[i + i] = padToken(formatTokenFunctions[i], 2); + } + formatTokenFunctions.DDDD = padToken(formatTokenFunctions.DDD, 3); + + + /************************************ + Constructors + ************************************/ + + function Locale() { + } + + // Moment prototype object + function Moment(config, skipOverflow) { + if (skipOverflow !== false) { + checkOverflow(config); + } + copyConfig(this, config); + this._d = new Date(+config._d); + } + + // Duration Constructor + function Duration(duration) { + var normalizedInput = normalizeObjectUnits(duration), + years = normalizedInput.year || 0, + quarters = normalizedInput.quarter || 0, + months = normalizedInput.month || 0, + weeks = normalizedInput.week || 0, + days = normalizedInput.day || 0, + hours = normalizedInput.hour || 0, + minutes = normalizedInput.minute || 0, + seconds = normalizedInput.second || 0, + milliseconds = normalizedInput.millisecond || 0; + + // representation for dateAddRemove + this._milliseconds = +milliseconds + + seconds * 1e3 + // 1000 + minutes * 6e4 + // 1000 * 60 + hours * 36e5; // 1000 * 60 * 60 + // Because of dateAddRemove treats 24 hours as different from a + // day when working around DST, we need to store them separately + this._days = +days + + weeks * 7; + // It is impossible translate months into days without knowing + // which months you are are talking about, so we have to store + // it separately. + this._months = +months + + quarters * 3 + + years * 12; + + this._data = {}; + + this._locale = moment.localeData(); + + this._bubble(); + } + + /************************************ + Helpers + ************************************/ + + + function extend(a, b) { + for (var i in b) { + if (hasOwnProp(b, i)) { + a[i] = b[i]; + } + } + + if (hasOwnProp(b, 'toString')) { + a.toString = b.toString; + } + + if (hasOwnProp(b, 'valueOf')) { + a.valueOf = b.valueOf; + } + + return a; + } + + function copyConfig(to, from) { + var i, prop, val; + + if (typeof from._isAMomentObject !== 'undefined') { + to._isAMomentObject = from._isAMomentObject; + } + if (typeof from._i !== 'undefined') { + to._i = from._i; + } + if (typeof from._f !== 'undefined') { + to._f = from._f; + } + if (typeof from._l !== 'undefined') { + to._l = from._l; + } + if (typeof from._strict !== 'undefined') { + to._strict = from._strict; + } + if (typeof from._tzm !== 'undefined') { + to._tzm = from._tzm; + } + if (typeof from._isUTC !== 'undefined') { + to._isUTC = from._isUTC; + } + if (typeof from._offset !== 'undefined') { + to._offset = from._offset; + } + if (typeof from._pf !== 'undefined') { + to._pf = from._pf; + } + if (typeof from._locale !== 'undefined') { + to._locale = from._locale; + } + + if (momentProperties.length > 0) { + for (i in momentProperties) { + prop = momentProperties[i]; + val = from[prop]; + if (typeof val !== 'undefined') { + to[prop] = val; + } + } + } + + return to; + } + + function absRound(number) { + if (number < 0) { + return Math.ceil(number); + } else { + return Math.floor(number); + } + } + + // left zero fill a number + // see http://jsperf.com/left-zero-filling for performance comparison + function leftZeroFill(number, targetLength, forceSign) { + var output = '' + Math.abs(number), + sign = number >= 0; + + while (output.length < targetLength) { + output = '0' + output; + } + return (sign ? (forceSign ? '+' : '') : '-') + output; + } + + function positiveMomentsDifference(base, other) { + var res = {milliseconds: 0, months: 0}; + + res.months = other.month() - base.month() + + (other.year() - base.year()) * 12; + if (base.clone().add(res.months, 'M').isAfter(other)) { + --res.months; + } + + res.milliseconds = +other - +(base.clone().add(res.months, 'M')); + + return res; + } + + function momentsDifference(base, other) { + var res; + other = makeAs(other, base); + if (base.isBefore(other)) { + res = positiveMomentsDifference(base, other); + } else { + res = positiveMomentsDifference(other, base); + res.milliseconds = -res.milliseconds; + res.months = -res.months; + } + + return res; + } + + // TODO: remove 'name' arg after deprecation is removed + function createAdder(direction, name) { + return function (val, period) { + var dur, tmp; + //invert the arguments, but complain about it + if (period !== null && !isNaN(+period)) { + deprecateSimple(name, 'moment().' + name + '(period, number) is deprecated. Please use moment().' + name + '(number, period).'); + tmp = val; val = period; period = tmp; + } + + val = typeof val === 'string' ? +val : val; + dur = moment.duration(val, period); + addOrSubtractDurationFromMoment(this, dur, direction); + return this; + }; + } + + function addOrSubtractDurationFromMoment(mom, duration, isAdding, updateOffset) { + var milliseconds = duration._milliseconds, + days = duration._days, + months = duration._months; + updateOffset = updateOffset == null ? true : updateOffset; + + if (milliseconds) { + mom._d.setTime(+mom._d + milliseconds * isAdding); + } + if (days) { + rawSetter(mom, 'Date', rawGetter(mom, 'Date') + days * isAdding); + } + if (months) { + rawMonthSetter(mom, rawGetter(mom, 'Month') + months * isAdding); + } + if (updateOffset) { + moment.updateOffset(mom, days || months); + } + } + + // check if is an array + function isArray(input) { + return Object.prototype.toString.call(input) === '[object Array]'; + } + + function isDate(input) { + return Object.prototype.toString.call(input) === '[object Date]' || + input instanceof Date; + } + + // compare two arrays, return the number of differences + function compareArrays(array1, array2, dontConvert) { + var len = Math.min(array1.length, array2.length), + lengthDiff = Math.abs(array1.length - array2.length), + diffs = 0, + i; + for (i = 0; i < len; i++) { + if ((dontConvert && array1[i] !== array2[i]) || + (!dontConvert && toInt(array1[i]) !== toInt(array2[i]))) { + diffs++; + } + } + return diffs + lengthDiff; + } + + function normalizeUnits(units) { + if (units) { + var lowered = units.toLowerCase().replace(/(.)s$/, '$1'); + units = unitAliases[units] || camelFunctions[lowered] || lowered; + } + return units; + } + + function normalizeObjectUnits(inputObject) { + var normalizedInput = {}, + normalizedProp, + prop; + + for (prop in inputObject) { + if (hasOwnProp(inputObject, prop)) { + normalizedProp = normalizeUnits(prop); + if (normalizedProp) { + normalizedInput[normalizedProp] = inputObject[prop]; + } + } + } + + return normalizedInput; + } + + function makeList(field) { + var count, setter; + + if (field.indexOf('week') === 0) { + count = 7; + setter = 'day'; + } + else if (field.indexOf('month') === 0) { + count = 12; + setter = 'month'; + } + else { + return; + } + + moment[field] = function (format, index) { + var i, getter, + method = moment._locale[field], + results = []; + + if (typeof format === 'number') { + index = format; + format = undefined; + } + + getter = function (i) { + var m = moment().utc().set(setter, i); + return method.call(moment._locale, m, format || ''); + }; + + if (index != null) { + return getter(index); + } + else { + for (i = 0; i < count; i++) { + results.push(getter(i)); + } + return results; + } + }; + } + + function toInt(argumentForCoercion) { + var coercedNumber = +argumentForCoercion, + value = 0; + + if (coercedNumber !== 0 && isFinite(coercedNumber)) { + if (coercedNumber >= 0) { + value = Math.floor(coercedNumber); + } else { + value = Math.ceil(coercedNumber); + } + } + + return value; + } + + function daysInMonth(year, month) { + return new Date(Date.UTC(year, month + 1, 0)).getUTCDate(); + } + + function weeksInYear(year, dow, doy) { + return weekOfYear(moment([year, 11, 31 + dow - doy]), dow, doy).week; + } + + function daysInYear(year) { + return isLeapYear(year) ? 366 : 365; + } + + function isLeapYear(year) { + return (year % 4 === 0 && year % 100 !== 0) || year % 400 === 0; + } + + function checkOverflow(m) { + var overflow; + if (m._a && m._pf.overflow === -2) { + overflow = + m._a[MONTH] < 0 || m._a[MONTH] > 11 ? MONTH : + m._a[DATE] < 1 || m._a[DATE] > daysInMonth(m._a[YEAR], m._a[MONTH]) ? DATE : + m._a[HOUR] < 0 || m._a[HOUR] > 23 ? HOUR : + m._a[MINUTE] < 0 || m._a[MINUTE] > 59 ? MINUTE : + m._a[SECOND] < 0 || m._a[SECOND] > 59 ? SECOND : + m._a[MILLISECOND] < 0 || m._a[MILLISECOND] > 999 ? MILLISECOND : + -1; + + if (m._pf._overflowDayOfYear && (overflow < YEAR || overflow > DATE)) { + overflow = DATE; + } + + m._pf.overflow = overflow; + } + } + + function isValid(m) { + if (m._isValid == null) { + m._isValid = !isNaN(m._d.getTime()) && + m._pf.overflow < 0 && + !m._pf.empty && + !m._pf.invalidMonth && + !m._pf.nullInput && + !m._pf.invalidFormat && + !m._pf.userInvalidated; + + if (m._strict) { + m._isValid = m._isValid && + m._pf.charsLeftOver === 0 && + m._pf.unusedTokens.length === 0; + } + } + return m._isValid; + } + + function normalizeLocale(key) { + return key ? key.toLowerCase().replace('_', '-') : key; + } + + // pick the locale from the array + // try ['en-au', 'en-gb'] as 'en-au', 'en-gb', 'en', as in move through the list trying each + // substring from most specific to least, but move to the next array item if it's a more specific variant than the current root + function chooseLocale(names) { + var i = 0, j, next, locale, split; + + while (i < names.length) { + split = normalizeLocale(names[i]).split('-'); + j = split.length; + next = normalizeLocale(names[i + 1]); + next = next ? next.split('-') : null; + while (j > 0) { + locale = loadLocale(split.slice(0, j).join('-')); + if (locale) { + return locale; + } + if (next && next.length >= j && compareArrays(split, next, true) >= j - 1) { + //the next array item is better than a shallower substring of this one + break; + } + j--; + } + i++; + } + return null; + } + + function loadLocale(name) { + var oldLocale = null; + if (!locales[name] && hasModule) { + try { + oldLocale = moment.locale(); + require('./locale/' + name); + // because defineLocale currently also sets the global locale, we want to undo that for lazy loaded locales + moment.locale(oldLocale); + } catch (e) { } + } + return locales[name]; + } + + // Return a moment from input, that is local/utc/zone equivalent to model. + function makeAs(input, model) { + return model._isUTC ? moment(input).zone(model._offset || 0) : + moment(input).local(); + } + + /************************************ + Locale + ************************************/ + + + extend(Locale.prototype, { + + set : function (config) { + var prop, i; + for (i in config) { + prop = config[i]; + if (typeof prop === 'function') { + this[i] = prop; + } else { + this['_' + i] = prop; + } + } + }, + + _months : 'January_February_March_April_May_June_July_August_September_October_November_December'.split('_'), + months : function (m) { + return this._months[m.month()]; + }, + + _monthsShort : 'Jan_Feb_Mar_Apr_May_Jun_Jul_Aug_Sep_Oct_Nov_Dec'.split('_'), + monthsShort : function (m) { + return this._monthsShort[m.month()]; + }, + + monthsParse : function (monthName) { + var i, mom, regex; + + if (!this._monthsParse) { + this._monthsParse = []; + } + + for (i = 0; i < 12; i++) { + // make the regex if we don't have it already + if (!this._monthsParse[i]) { + mom = moment.utc([2000, i]); + regex = '^' + this.months(mom, '') + '|^' + this.monthsShort(mom, ''); + this._monthsParse[i] = new RegExp(regex.replace('.', ''), 'i'); + } + // test the regex + if (this._monthsParse[i].test(monthName)) { + return i; + } + } + }, + + _weekdays : 'Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday'.split('_'), + weekdays : function (m) { + return this._weekdays[m.day()]; + }, + + _weekdaysShort : 'Sun_Mon_Tue_Wed_Thu_Fri_Sat'.split('_'), + weekdaysShort : function (m) { + return this._weekdaysShort[m.day()]; + }, + + _weekdaysMin : 'Su_Mo_Tu_We_Th_Fr_Sa'.split('_'), + weekdaysMin : function (m) { + return this._weekdaysMin[m.day()]; + }, + + weekdaysParse : function (weekdayName) { + var i, mom, regex; + + if (!this._weekdaysParse) { + this._weekdaysParse = []; + } + + for (i = 0; i < 7; i++) { + // make the regex if we don't have it already + if (!this._weekdaysParse[i]) { + mom = moment([2000, 1]).day(i); + regex = '^' + this.weekdays(mom, '') + '|^' + this.weekdaysShort(mom, '') + '|^' + this.weekdaysMin(mom, ''); + this._weekdaysParse[i] = new RegExp(regex.replace('.', ''), 'i'); + } + // test the regex + if (this._weekdaysParse[i].test(weekdayName)) { + return i; + } + } + }, + + _longDateFormat : { + LT : 'h:mm A', + L : 'MM/DD/YYYY', + LL : 'MMMM D, YYYY', + LLL : 'MMMM D, YYYY LT', + LLLL : 'dddd, MMMM D, YYYY LT' + }, + longDateFormat : function (key) { + var output = this._longDateFormat[key]; + if (!output && this._longDateFormat[key.toUpperCase()]) { + output = this._longDateFormat[key.toUpperCase()].replace(/MMMM|MM|DD|dddd/g, function (val) { + return val.slice(1); + }); + this._longDateFormat[key] = output; + } + return output; + }, + + isPM : function (input) { + // IE8 Quirks Mode & IE7 Standards Mode do not allow accessing strings like arrays + // Using charAt should be more compatible. + return ((input + '').toLowerCase().charAt(0) === 'p'); + }, + + _meridiemParse : /[ap]\.?m?\.?/i, + meridiem : function (hours, minutes, isLower) { + if (hours > 11) { + return isLower ? 'pm' : 'PM'; + } else { + return isLower ? 'am' : 'AM'; + } + }, + + _calendar : { + sameDay : '[Today at] LT', + nextDay : '[Tomorrow at] LT', + nextWeek : 'dddd [at] LT', + lastDay : '[Yesterday at] LT', + lastWeek : '[Last] dddd [at] LT', + sameElse : 'L' + }, + calendar : function (key, mom) { + var output = this._calendar[key]; + return typeof output === 'function' ? output.apply(mom) : output; + }, + + _relativeTime : { + future : 'in %s', + past : '%s ago', + s : 'a few seconds', + m : 'a minute', + mm : '%d minutes', + h : 'an hour', + hh : '%d hours', + d : 'a day', + dd : '%d days', + M : 'a month', + MM : '%d months', + y : 'a year', + yy : '%d years' + }, + + relativeTime : function (number, withoutSuffix, string, isFuture) { + var output = this._relativeTime[string]; + return (typeof output === 'function') ? + output(number, withoutSuffix, string, isFuture) : + output.replace(/%d/i, number); + }, + + pastFuture : function (diff, output) { + var format = this._relativeTime[diff > 0 ? 'future' : 'past']; + return typeof format === 'function' ? format(output) : format.replace(/%s/i, output); + }, + + ordinal : function (number) { + return this._ordinal.replace('%d', number); + }, + _ordinal : '%d', + + preparse : function (string) { + return string; + }, + + postformat : function (string) { + return string; + }, + + week : function (mom) { + return weekOfYear(mom, this._week.dow, this._week.doy).week; + }, + + _week : { + dow : 0, // Sunday is the first day of the week. + doy : 6 // The week that contains Jan 1st is the first week of the year. + }, + + _invalidDate: 'Invalid date', + invalidDate: function () { + return this._invalidDate; + } + }); + + /************************************ + Formatting + ************************************/ + + + function removeFormattingTokens(input) { + if (input.match(/\[[\s\S]/)) { + return input.replace(/^\[|\]$/g, ''); + } + return input.replace(/\\/g, ''); + } + + function makeFormatFunction(format) { + var array = format.match(formattingTokens), i, length; + + for (i = 0, length = array.length; i < length; i++) { + if (formatTokenFunctions[array[i]]) { + array[i] = formatTokenFunctions[array[i]]; + } else { + array[i] = removeFormattingTokens(array[i]); + } + } + + return function (mom) { + var output = ''; + for (i = 0; i < length; i++) { + output += array[i] instanceof Function ? array[i].call(mom, format) : array[i]; + } + return output; + }; + } + + // format date using native date object + function formatMoment(m, format) { + if (!m.isValid()) { + return m.localeData().invalidDate(); + } + + format = expandFormat(format, m.localeData()); + + if (!formatFunctions[format]) { + formatFunctions[format] = makeFormatFunction(format); + } + + return formatFunctions[format](m); + } + + function expandFormat(format, locale) { + var i = 5; + + function replaceLongDateFormatTokens(input) { + return locale.longDateFormat(input) || input; + } + + localFormattingTokens.lastIndex = 0; + while (i >= 0 && localFormattingTokens.test(format)) { + format = format.replace(localFormattingTokens, replaceLongDateFormatTokens); + localFormattingTokens.lastIndex = 0; + i -= 1; + } + + return format; + } + + + /************************************ + Parsing + ************************************/ + + + // get the regex to find the next token + function getParseRegexForToken(token, config) { + var a, strict = config._strict; + switch (token) { + case 'Q': + return parseTokenOneDigit; + case 'DDDD': + return parseTokenThreeDigits; + case 'YYYY': + case 'GGGG': + case 'gggg': + return strict ? parseTokenFourDigits : parseTokenOneToFourDigits; + case 'Y': + case 'G': + case 'g': + return parseTokenSignedNumber; + case 'YYYYYY': + case 'YYYYY': + case 'GGGGG': + case 'ggggg': + return strict ? parseTokenSixDigits : parseTokenOneToSixDigits; + case 'S': + if (strict) { + return parseTokenOneDigit; + } + /* falls through */ + case 'SS': + if (strict) { + return parseTokenTwoDigits; + } + /* falls through */ + case 'SSS': + if (strict) { + return parseTokenThreeDigits; + } + /* falls through */ + case 'DDD': + return parseTokenOneToThreeDigits; + case 'MMM': + case 'MMMM': + case 'dd': + case 'ddd': + case 'dddd': + return parseTokenWord; + case 'a': + case 'A': + return config._locale._meridiemParse; + case 'X': + return parseTokenTimestampMs; + case 'Z': + case 'ZZ': + return parseTokenTimezone; + case 'T': + return parseTokenT; + case 'SSSS': + return parseTokenDigits; + case 'MM': + case 'DD': + case 'YY': + case 'GG': + case 'gg': + case 'HH': + case 'hh': + case 'mm': + case 'ss': + case 'ww': + case 'WW': + return strict ? parseTokenTwoDigits : parseTokenOneOrTwoDigits; + case 'M': + case 'D': + case 'd': + case 'H': + case 'h': + case 'm': + case 's': + case 'w': + case 'W': + case 'e': + case 'E': + return parseTokenOneOrTwoDigits; + case 'Do': + return parseTokenOrdinal; + default : + a = new RegExp(regexpEscape(unescapeFormat(token.replace('\\', '')), 'i')); + return a; + } + } + + function timezoneMinutesFromString(string) { + string = string || ''; + var possibleTzMatches = (string.match(parseTokenTimezone) || []), + tzChunk = possibleTzMatches[possibleTzMatches.length - 1] || [], + parts = (tzChunk + '').match(parseTimezoneChunker) || ['-', 0, 0], + minutes = +(parts[1] * 60) + toInt(parts[2]); + + return parts[0] === '+' ? -minutes : minutes; + } + + // function to convert string input to date + function addTimeToArrayFromToken(token, input, config) { + var a, datePartArray = config._a; + + switch (token) { + // QUARTER + case 'Q': + if (input != null) { + datePartArray[MONTH] = (toInt(input) - 1) * 3; + } + break; + // MONTH + case 'M' : // fall through to MM + case 'MM' : + if (input != null) { + datePartArray[MONTH] = toInt(input) - 1; + } + break; + case 'MMM' : // fall through to MMMM + case 'MMMM' : + a = config._locale.monthsParse(input); + // if we didn't find a month name, mark the date as invalid. + if (a != null) { + datePartArray[MONTH] = a; + } else { + config._pf.invalidMonth = input; + } + break; + // DAY OF MONTH + case 'D' : // fall through to DD + case 'DD' : + if (input != null) { + datePartArray[DATE] = toInt(input); + } + break; + case 'Do' : + if (input != null) { + datePartArray[DATE] = toInt(parseInt(input, 10)); + } + break; + // DAY OF YEAR + case 'DDD' : // fall through to DDDD + case 'DDDD' : + if (input != null) { + config._dayOfYear = toInt(input); + } + + break; + // YEAR + case 'YY' : + datePartArray[YEAR] = moment.parseTwoDigitYear(input); + break; + case 'YYYY' : + case 'YYYYY' : + case 'YYYYYY' : + datePartArray[YEAR] = toInt(input); + break; + // AM / PM + case 'a' : // fall through to A + case 'A' : + config._isPm = config._locale.isPM(input); + break; + // 24 HOUR + case 'H' : // fall through to hh + case 'HH' : // fall through to hh + case 'h' : // fall through to hh + case 'hh' : + datePartArray[HOUR] = toInt(input); + break; + // MINUTE + case 'm' : // fall through to mm + case 'mm' : + datePartArray[MINUTE] = toInt(input); + break; + // SECOND + case 's' : // fall through to ss + case 'ss' : + datePartArray[SECOND] = toInt(input); + break; + // MILLISECOND + case 'S' : + case 'SS' : + case 'SSS' : + case 'SSSS' : + datePartArray[MILLISECOND] = toInt(('0.' + input) * 1000); + break; + // UNIX TIMESTAMP WITH MS + case 'X': + config._d = new Date(parseFloat(input) * 1000); + break; + // TIMEZONE + case 'Z' : // fall through to ZZ + case 'ZZ' : + config._useUTC = true; + config._tzm = timezoneMinutesFromString(input); + break; + // WEEKDAY - human + case 'dd': + case 'ddd': + case 'dddd': + a = config._locale.weekdaysParse(input); + // if we didn't get a weekday name, mark the date as invalid + if (a != null) { + config._w = config._w || {}; + config._w['d'] = a; + } else { + config._pf.invalidWeekday = input; + } + break; + // WEEK, WEEK DAY - numeric + case 'w': + case 'ww': + case 'W': + case 'WW': + case 'd': + case 'e': + case 'E': + token = token.substr(0, 1); + /* falls through */ + case 'gggg': + case 'GGGG': + case 'GGGGG': + token = token.substr(0, 2); + if (input) { + config._w = config._w || {}; + config._w[token] = toInt(input); + } + break; + case 'gg': + case 'GG': + config._w = config._w || {}; + config._w[token] = moment.parseTwoDigitYear(input); + } + } + + function dayOfYearFromWeekInfo(config) { + var w, weekYear, week, weekday, dow, doy, temp; + + w = config._w; + if (w.GG != null || w.W != null || w.E != null) { + dow = 1; + doy = 4; + + // TODO: We need to take the current isoWeekYear, but that depends on + // how we interpret now (local, utc, fixed offset). So create + // a now version of current config (take local/utc/offset flags, and + // create now). + weekYear = dfl(w.GG, config._a[YEAR], weekOfYear(moment(), 1, 4).year); + week = dfl(w.W, 1); + weekday = dfl(w.E, 1); + } else { + dow = config._locale._week.dow; + doy = config._locale._week.doy; + + weekYear = dfl(w.gg, config._a[YEAR], weekOfYear(moment(), dow, doy).year); + week = dfl(w.w, 1); + + if (w.d != null) { + // weekday -- low day numbers are considered next week + weekday = w.d; + if (weekday < dow) { + ++week; + } + } else if (w.e != null) { + // local weekday -- counting starts from begining of week + weekday = w.e + dow; + } else { + // default to begining of week + weekday = dow; + } + } + temp = dayOfYearFromWeeks(weekYear, week, weekday, doy, dow); + + config._a[YEAR] = temp.year; + config._dayOfYear = temp.dayOfYear; + } + + // convert an array to a date. + // the array should mirror the parameters below + // note: all values past the year are optional and will default to the lowest possible value. + // [year, month, day , hour, minute, second, millisecond] + function dateFromConfig(config) { + var i, date, input = [], currentDate, yearToUse; + + if (config._d) { + return; + } + + currentDate = currentDateArray(config); + + //compute day of the year from weeks and weekdays + if (config._w && config._a[DATE] == null && config._a[MONTH] == null) { + dayOfYearFromWeekInfo(config); + } + + //if the day of the year is set, figure out what it is + if (config._dayOfYear) { + yearToUse = dfl(config._a[YEAR], currentDate[YEAR]); + + if (config._dayOfYear > daysInYear(yearToUse)) { + config._pf._overflowDayOfYear = true; + } + + date = makeUTCDate(yearToUse, 0, config._dayOfYear); + config._a[MONTH] = date.getUTCMonth(); + config._a[DATE] = date.getUTCDate(); + } + + // Default to current date. + // * if no year, month, day of month are given, default to today + // * if day of month is given, default month and year + // * if month is given, default only year + // * if year is given, don't default anything + for (i = 0; i < 3 && config._a[i] == null; ++i) { + config._a[i] = input[i] = currentDate[i]; + } + + // Zero out whatever was not defaulted, including time + for (; i < 7; i++) { + config._a[i] = input[i] = (config._a[i] == null) ? (i === 2 ? 1 : 0) : config._a[i]; + } + + config._d = (config._useUTC ? makeUTCDate : makeDate).apply(null, input); + // Apply timezone offset from input. The actual zone can be changed + // with parseZone. + if (config._tzm != null) { + config._d.setUTCMinutes(config._d.getUTCMinutes() + config._tzm); + } + } + + function dateFromObject(config) { + var normalizedInput; + + if (config._d) { + return; + } + + normalizedInput = normalizeObjectUnits(config._i); + config._a = [ + normalizedInput.year, + normalizedInput.month, + normalizedInput.day, + normalizedInput.hour, + normalizedInput.minute, + normalizedInput.second, + normalizedInput.millisecond + ]; + + dateFromConfig(config); + } + + function currentDateArray(config) { + var now = new Date(); + if (config._useUTC) { + return [ + now.getUTCFullYear(), + now.getUTCMonth(), + now.getUTCDate() + ]; + } else { + return [now.getFullYear(), now.getMonth(), now.getDate()]; + } + } + + // date from string and format string + function makeDateFromStringAndFormat(config) { + if (config._f === moment.ISO_8601) { + parseISO(config); + return; + } + + config._a = []; + config._pf.empty = true; + + // This array is used to make a Date, either with `new Date` or `Date.UTC` + var string = '' + config._i, + i, parsedInput, tokens, token, skipped, + stringLength = string.length, + totalParsedInputLength = 0; + + tokens = expandFormat(config._f, config._locale).match(formattingTokens) || []; + + for (i = 0; i < tokens.length; i++) { + token = tokens[i]; + parsedInput = (string.match(getParseRegexForToken(token, config)) || [])[0]; + if (parsedInput) { + skipped = string.substr(0, string.indexOf(parsedInput)); + if (skipped.length > 0) { + config._pf.unusedInput.push(skipped); + } + string = string.slice(string.indexOf(parsedInput) + parsedInput.length); + totalParsedInputLength += parsedInput.length; + } + // don't parse if it's not a known token + if (formatTokenFunctions[token]) { + if (parsedInput) { + config._pf.empty = false; + } + else { + config._pf.unusedTokens.push(token); + } + addTimeToArrayFromToken(token, parsedInput, config); + } + else if (config._strict && !parsedInput) { + config._pf.unusedTokens.push(token); + } + } + + // add remaining unparsed input length to the string + config._pf.charsLeftOver = stringLength - totalParsedInputLength; + if (string.length > 0) { + config._pf.unusedInput.push(string); + } + + // handle am pm + if (config._isPm && config._a[HOUR] < 12) { + config._a[HOUR] += 12; + } + // if is 12 am, change hours to 0 + if (config._isPm === false && config._a[HOUR] === 12) { + config._a[HOUR] = 0; + } + + dateFromConfig(config); + checkOverflow(config); + } + + function unescapeFormat(s) { + return s.replace(/\\(\[)|\\(\])|\[([^\]\[]*)\]|\\(.)/g, function (matched, p1, p2, p3, p4) { + return p1 || p2 || p3 || p4; + }); + } + + // Code from http://stackoverflow.com/questions/3561493/is-there-a-regexp-escape-function-in-javascript + function regexpEscape(s) { + return s.replace(/[-\/\\^$*+?.()|[\]{}]/g, '\\$&'); + } + + // date from string and array of format strings + function makeDateFromStringAndArray(config) { + var tempConfig, + bestMoment, + + scoreToBeat, + i, + currentScore; + + if (config._f.length === 0) { + config._pf.invalidFormat = true; + config._d = new Date(NaN); + return; + } + + for (i = 0; i < config._f.length; i++) { + currentScore = 0; + tempConfig = copyConfig({}, config); + if (config._useUTC != null) { + tempConfig._useUTC = config._useUTC; + } + tempConfig._pf = defaultParsingFlags(); + tempConfig._f = config._f[i]; + makeDateFromStringAndFormat(tempConfig); + + if (!isValid(tempConfig)) { + continue; + } + + // if there is any input that was not parsed add a penalty for that format + currentScore += tempConfig._pf.charsLeftOver; + + //or tokens + currentScore += tempConfig._pf.unusedTokens.length * 10; + + tempConfig._pf.score = currentScore; + + if (scoreToBeat == null || currentScore < scoreToBeat) { + scoreToBeat = currentScore; + bestMoment = tempConfig; + } + } + + extend(config, bestMoment || tempConfig); + } + + // date from iso format + function parseISO(config) { + var i, l, + string = config._i, + match = isoRegex.exec(string); + + if (match) { + config._pf.iso = true; + for (i = 0, l = isoDates.length; i < l; i++) { + if (isoDates[i][1].exec(string)) { + // match[5] should be 'T' or undefined + config._f = isoDates[i][0] + (match[6] || ' '); + break; + } + } + for (i = 0, l = isoTimes.length; i < l; i++) { + if (isoTimes[i][1].exec(string)) { + config._f += isoTimes[i][0]; + break; + } + } + if (string.match(parseTokenTimezone)) { + config._f += 'Z'; + } + makeDateFromStringAndFormat(config); + } else { + config._isValid = false; + } + } + + // date from iso format or fallback + function makeDateFromString(config) { + parseISO(config); + if (config._isValid === false) { + delete config._isValid; + moment.createFromInputFallback(config); + } + } + + function map(arr, fn) { + var res = [], i; + for (i = 0; i < arr.length; ++i) { + res.push(fn(arr[i], i)); + } + return res; + } + + function makeDateFromInput(config) { + var input = config._i, matched; + if (input === undefined) { + config._d = new Date(); + } else if (isDate(input)) { + config._d = new Date(+input); + } else if ((matched = aspNetJsonRegex.exec(input)) !== null) { + config._d = new Date(+matched[1]); + } else if (typeof input === 'string') { + makeDateFromString(config); + } else if (isArray(input)) { + config._a = map(input.slice(0), function (obj) { + return parseInt(obj, 10); + }); + dateFromConfig(config); + } else if (typeof(input) === 'object') { + dateFromObject(config); + } else if (typeof(input) === 'number') { + // from milliseconds + config._d = new Date(input); + } else { + moment.createFromInputFallback(config); + } + } + + function makeDate(y, m, d, h, M, s, ms) { + //can't just apply() to create a date: + //http://stackoverflow.com/questions/181348/instantiating-a-javascript-object-by-calling-prototype-constructor-apply + var date = new Date(y, m, d, h, M, s, ms); + + //the date constructor doesn't accept years < 1970 + if (y < 1970) { + date.setFullYear(y); + } + return date; + } + + function makeUTCDate(y) { + var date = new Date(Date.UTC.apply(null, arguments)); + if (y < 1970) { + date.setUTCFullYear(y); + } + return date; + } + + function parseWeekday(input, locale) { + if (typeof input === 'string') { + if (!isNaN(input)) { + input = parseInt(input, 10); + } + else { + input = locale.weekdaysParse(input); + if (typeof input !== 'number') { + return null; + } + } + } + return input; + } + + /************************************ + Relative Time + ************************************/ + + + // helper function for moment.fn.from, moment.fn.fromNow, and moment.duration.fn.humanize + function substituteTimeAgo(string, number, withoutSuffix, isFuture, locale) { + return locale.relativeTime(number || 1, !!withoutSuffix, string, isFuture); + } + + function relativeTime(posNegDuration, withoutSuffix, locale) { + var duration = moment.duration(posNegDuration).abs(), + seconds = round(duration.as('s')), + minutes = round(duration.as('m')), + hours = round(duration.as('h')), + days = round(duration.as('d')), + months = round(duration.as('M')), + years = round(duration.as('y')), + + args = seconds < relativeTimeThresholds.s && ['s', seconds] || + minutes === 1 && ['m'] || + minutes < relativeTimeThresholds.m && ['mm', minutes] || + hours === 1 && ['h'] || + hours < relativeTimeThresholds.h && ['hh', hours] || + days === 1 && ['d'] || + days < relativeTimeThresholds.d && ['dd', days] || + months === 1 && ['M'] || + months < relativeTimeThresholds.M && ['MM', months] || + years === 1 && ['y'] || ['yy', years]; + + args[2] = withoutSuffix; + args[3] = +posNegDuration > 0; + args[4] = locale; + return substituteTimeAgo.apply({}, args); + } + + + /************************************ + Week of Year + ************************************/ + + + // firstDayOfWeek 0 = sun, 6 = sat + // the day of the week that starts the week + // (usually sunday or monday) + // firstDayOfWeekOfYear 0 = sun, 6 = sat + // the first week is the week that contains the first + // of this day of the week + // (eg. ISO weeks use thursday (4)) + function weekOfYear(mom, firstDayOfWeek, firstDayOfWeekOfYear) { + var end = firstDayOfWeekOfYear - firstDayOfWeek, + daysToDayOfWeek = firstDayOfWeekOfYear - mom.day(), + adjustedMoment; + + + if (daysToDayOfWeek > end) { + daysToDayOfWeek -= 7; + } + + if (daysToDayOfWeek < end - 7) { + daysToDayOfWeek += 7; + } + + adjustedMoment = moment(mom).add(daysToDayOfWeek, 'd'); + return { + week: Math.ceil(adjustedMoment.dayOfYear() / 7), + year: adjustedMoment.year() + }; + } + + //http://en.wikipedia.org/wiki/ISO_week_date#Calculating_a_date_given_the_year.2C_week_number_and_weekday + function dayOfYearFromWeeks(year, week, weekday, firstDayOfWeekOfYear, firstDayOfWeek) { + var d = makeUTCDate(year, 0, 1).getUTCDay(), daysToAdd, dayOfYear; + + d = d === 0 ? 7 : d; + weekday = weekday != null ? weekday : firstDayOfWeek; + daysToAdd = firstDayOfWeek - d + (d > firstDayOfWeekOfYear ? 7 : 0) - (d < firstDayOfWeek ? 7 : 0); + dayOfYear = 7 * (week - 1) + (weekday - firstDayOfWeek) + daysToAdd + 1; + + return { + year: dayOfYear > 0 ? year : year - 1, + dayOfYear: dayOfYear > 0 ? dayOfYear : daysInYear(year - 1) + dayOfYear + }; + } + + /************************************ + Top Level Functions + ************************************/ + + function makeMoment(config) { + var input = config._i, + format = config._f; + + config._locale = config._locale || moment.localeData(config._l); + + if (input === null || (format === undefined && input === '')) { + return moment.invalid({nullInput: true}); + } + + if (typeof input === 'string') { + config._i = input = config._locale.preparse(input); + } + + if (moment.isMoment(input)) { + return new Moment(input, true); + } else if (format) { + if (isArray(format)) { + makeDateFromStringAndArray(config); + } else { + makeDateFromStringAndFormat(config); + } + } else { + makeDateFromInput(config); + } + + return new Moment(config); + } + + moment = function (input, format, locale, strict) { + var c; + + if (typeof(locale) === 'boolean') { + strict = locale; + locale = undefined; + } + // object construction must be done this way. + // https://github.com/moment/moment/issues/1423 + c = {}; + c._isAMomentObject = true; + c._i = input; + c._f = format; + c._l = locale; + c._strict = strict; + c._isUTC = false; + c._pf = defaultParsingFlags(); + + return makeMoment(c); + }; + + moment.suppressDeprecationWarnings = false; + + moment.createFromInputFallback = deprecate( + 'moment construction falls back to js Date. This is ' + + 'discouraged and will be removed in upcoming major ' + + 'release. Please refer to ' + + 'https://github.com/moment/moment/issues/1407 for more info.', + function (config) { + config._d = new Date(config._i); + } + ); + + // Pick a moment m from moments so that m[fn](other) is true for all + // other. This relies on the function fn to be transitive. + // + // moments should either be an array of moment objects or an array, whose + // first element is an array of moment objects. + function pickBy(fn, moments) { + var res, i; + if (moments.length === 1 && isArray(moments[0])) { + moments = moments[0]; + } + if (!moments.length) { + return moment(); + } + res = moments[0]; + for (i = 1; i < moments.length; ++i) { + if (moments[i][fn](res)) { + res = moments[i]; + } + } + return res; + } + + moment.min = function () { + var args = [].slice.call(arguments, 0); + + return pickBy('isBefore', args); + }; + + moment.max = function () { + var args = [].slice.call(arguments, 0); + + return pickBy('isAfter', args); + }; + + // creating with utc + moment.utc = function (input, format, locale, strict) { + var c; + + if (typeof(locale) === 'boolean') { + strict = locale; + locale = undefined; + } + // object construction must be done this way. + // https://github.com/moment/moment/issues/1423 + c = {}; + c._isAMomentObject = true; + c._useUTC = true; + c._isUTC = true; + c._l = locale; + c._i = input; + c._f = format; + c._strict = strict; + c._pf = defaultParsingFlags(); + + return makeMoment(c).utc(); + }; + + // creating with unix timestamp (in seconds) + moment.unix = function (input) { + return moment(input * 1000); + }; + + // duration + moment.duration = function (input, key) { + var duration = input, + // matching against regexp is expensive, do it on demand + match = null, + sign, + ret, + parseIso, + diffRes; + + if (moment.isDuration(input)) { + duration = { + ms: input._milliseconds, + d: input._days, + M: input._months + }; + } else if (typeof input === 'number') { + duration = {}; + if (key) { + duration[key] = input; + } else { + duration.milliseconds = input; + } + } else if (!!(match = aspNetTimeSpanJsonRegex.exec(input))) { + sign = (match[1] === '-') ? -1 : 1; + duration = { + y: 0, + d: toInt(match[DATE]) * sign, + h: toInt(match[HOUR]) * sign, + m: toInt(match[MINUTE]) * sign, + s: toInt(match[SECOND]) * sign, + ms: toInt(match[MILLISECOND]) * sign + }; + } else if (!!(match = isoDurationRegex.exec(input))) { + sign = (match[1] === '-') ? -1 : 1; + parseIso = function (inp) { + // We'd normally use ~~inp for this, but unfortunately it also + // converts floats to ints. + // inp may be undefined, so careful calling replace on it. + var res = inp && parseFloat(inp.replace(',', '.')); + // apply sign while we're at it + return (isNaN(res) ? 0 : res) * sign; + }; + duration = { + y: parseIso(match[2]), + M: parseIso(match[3]), + d: parseIso(match[4]), + h: parseIso(match[5]), + m: parseIso(match[6]), + s: parseIso(match[7]), + w: parseIso(match[8]) + }; + } else if (typeof duration === 'object' && + ('from' in duration || 'to' in duration)) { + diffRes = momentsDifference(moment(duration.from), moment(duration.to)); + + duration = {}; + duration.ms = diffRes.milliseconds; + duration.M = diffRes.months; + } + + ret = new Duration(duration); + + if (moment.isDuration(input) && hasOwnProp(input, '_locale')) { + ret._locale = input._locale; + } + + return ret; + }; + + // version number + moment.version = VERSION; + + // default format + moment.defaultFormat = isoFormat; + + // constant that refers to the ISO standard + moment.ISO_8601 = function () {}; + + // Plugins that add properties should also add the key here (null value), + // so we can properly clone ourselves. + moment.momentProperties = momentProperties; + + // This function will be called whenever a moment is mutated. + // It is intended to keep the offset in sync with the timezone. + moment.updateOffset = function () {}; + + // This function allows you to set a threshold for relative time strings + moment.relativeTimeThreshold = function (threshold, limit) { + if (relativeTimeThresholds[threshold] === undefined) { + return false; + } + if (limit === undefined) { + return relativeTimeThresholds[threshold]; + } + relativeTimeThresholds[threshold] = limit; + return true; + }; + + moment.lang = deprecate( + 'moment.lang is deprecated. Use moment.locale instead.', + function (key, value) { + return moment.locale(key, value); + } + ); + + // This function will load locale and then set the global locale. If + // no arguments are passed in, it will simply return the current global + // locale key. + moment.locale = function (key, values) { + var data; + if (key) { + if (typeof(values) !== 'undefined') { + data = moment.defineLocale(key, values); + } + else { + data = moment.localeData(key); + } + + if (data) { + moment.duration._locale = moment._locale = data; + } + } + + return moment._locale._abbr; + }; + + moment.defineLocale = function (name, values) { + if (values !== null) { + values.abbr = name; + if (!locales[name]) { + locales[name] = new Locale(); + } + locales[name].set(values); + + // backwards compat for now: also set the locale + moment.locale(name); + + return locales[name]; + } else { + // useful for testing + delete locales[name]; + return null; + } + }; + + moment.langData = deprecate( + 'moment.langData is deprecated. Use moment.localeData instead.', + function (key) { + return moment.localeData(key); + } + ); + + // returns locale data + moment.localeData = function (key) { + var locale; + + if (key && key._locale && key._locale._abbr) { + key = key._locale._abbr; + } + + if (!key) { + return moment._locale; + } + + if (!isArray(key)) { + //short-circuit everything else + locale = loadLocale(key); + if (locale) { + return locale; + } + key = [key]; + } + + return chooseLocale(key); + }; + + // compare moment object + moment.isMoment = function (obj) { + return obj instanceof Moment || + (obj != null && hasOwnProp(obj, '_isAMomentObject')); + }; + + // for typechecking Duration objects + moment.isDuration = function (obj) { + return obj instanceof Duration; + }; + + for (i = lists.length - 1; i >= 0; --i) { + makeList(lists[i]); + } + + moment.normalizeUnits = function (units) { + return normalizeUnits(units); + }; + + moment.invalid = function (flags) { + var m = moment.utc(NaN); + if (flags != null) { + extend(m._pf, flags); + } + else { + m._pf.userInvalidated = true; + } + + return m; + }; + + moment.parseZone = function () { + return moment.apply(null, arguments).parseZone(); + }; + + moment.parseTwoDigitYear = function (input) { + return toInt(input) + (toInt(input) > 68 ? 1900 : 2000); + }; + + /************************************ + Moment Prototype + ************************************/ + + + extend(moment.fn = Moment.prototype, { + + clone : function () { + return moment(this); + }, + + valueOf : function () { + return +this._d + ((this._offset || 0) * 60000); + }, + + unix : function () { + return Math.floor(+this / 1000); + }, + + toString : function () { + return this.clone().locale('en').format('ddd MMM DD YYYY HH:mm:ss [GMT]ZZ'); + }, + + toDate : function () { + return this._offset ? new Date(+this) : this._d; + }, + + toISOString : function () { + var m = moment(this).utc(); + if (0 < m.year() && m.year() <= 9999) { + return formatMoment(m, 'YYYY-MM-DD[T]HH:mm:ss.SSS[Z]'); + } else { + return formatMoment(m, 'YYYYYY-MM-DD[T]HH:mm:ss.SSS[Z]'); + } + }, + + toArray : function () { + var m = this; + return [ + m.year(), + m.month(), + m.date(), + m.hours(), + m.minutes(), + m.seconds(), + m.milliseconds() + ]; + }, + + isValid : function () { + return isValid(this); + }, + + isDSTShifted : function () { + if (this._a) { + return this.isValid() && compareArrays(this._a, (this._isUTC ? moment.utc(this._a) : moment(this._a)).toArray()) > 0; + } + + return false; + }, + + parsingFlags : function () { + return extend({}, this._pf); + }, + + invalidAt: function () { + return this._pf.overflow; + }, + + utc : function (keepLocalTime) { + return this.zone(0, keepLocalTime); + }, + + local : function (keepLocalTime) { + if (this._isUTC) { + this.zone(0, keepLocalTime); + this._isUTC = false; + + if (keepLocalTime) { + this.add(this._dateTzOffset(), 'm'); + } + } + return this; + }, + + format : function (inputString) { + var output = formatMoment(this, inputString || moment.defaultFormat); + return this.localeData().postformat(output); + }, + + add : createAdder(1, 'add'), + + subtract : createAdder(-1, 'subtract'), + + diff : function (input, units, asFloat) { + var that = makeAs(input, this), + zoneDiff = (this.zone() - that.zone()) * 6e4, + diff, output, daysAdjust; + + units = normalizeUnits(units); + + if (units === 'year' || units === 'month') { + // average number of days in the months in the given dates + diff = (this.daysInMonth() + that.daysInMonth()) * 432e5; // 24 * 60 * 60 * 1000 / 2 + // difference in months + output = ((this.year() - that.year()) * 12) + (this.month() - that.month()); + // adjust by taking difference in days, average number of days + // and dst in the given months. + daysAdjust = (this - moment(this).startOf('month')) - + (that - moment(that).startOf('month')); + // same as above but with zones, to negate all dst + daysAdjust -= ((this.zone() - moment(this).startOf('month').zone()) - + (that.zone() - moment(that).startOf('month').zone())) * 6e4; + output += daysAdjust / diff; + if (units === 'year') { + output = output / 12; + } + } else { + diff = (this - that); + output = units === 'second' ? diff / 1e3 : // 1000 + units === 'minute' ? diff / 6e4 : // 1000 * 60 + units === 'hour' ? diff / 36e5 : // 1000 * 60 * 60 + units === 'day' ? (diff - zoneDiff) / 864e5 : // 1000 * 60 * 60 * 24, negate dst + units === 'week' ? (diff - zoneDiff) / 6048e5 : // 1000 * 60 * 60 * 24 * 7, negate dst + diff; + } + return asFloat ? output : absRound(output); + }, + + from : function (time, withoutSuffix) { + return moment.duration({to: this, from: time}).locale(this.locale()).humanize(!withoutSuffix); + }, + + fromNow : function (withoutSuffix) { + return this.from(moment(), withoutSuffix); + }, + + calendar : function (time) { + // We want to compare the start of today, vs this. + // Getting start-of-today depends on whether we're zone'd or not. + var now = time || moment(), + sod = makeAs(now, this).startOf('day'), + diff = this.diff(sod, 'days', true), + format = diff < -6 ? 'sameElse' : + diff < -1 ? 'lastWeek' : + diff < 0 ? 'lastDay' : + diff < 1 ? 'sameDay' : + diff < 2 ? 'nextDay' : + diff < 7 ? 'nextWeek' : 'sameElse'; + return this.format(this.localeData().calendar(format, this)); + }, + + isLeapYear : function () { + return isLeapYear(this.year()); + }, + + isDST : function () { + return (this.zone() < this.clone().month(0).zone() || + this.zone() < this.clone().month(5).zone()); + }, + + day : function (input) { + var day = this._isUTC ? this._d.getUTCDay() : this._d.getDay(); + if (input != null) { + input = parseWeekday(input, this.localeData()); + return this.add(input - day, 'd'); + } else { + return day; + } + }, + + month : makeAccessor('Month', true), + + startOf : function (units) { + units = normalizeUnits(units); + // the following switch intentionally omits break keywords + // to utilize falling through the cases. + switch (units) { + case 'year': + this.month(0); + /* falls through */ + case 'quarter': + case 'month': + this.date(1); + /* falls through */ + case 'week': + case 'isoWeek': + case 'day': + this.hours(0); + /* falls through */ + case 'hour': + this.minutes(0); + /* falls through */ + case 'minute': + this.seconds(0); + /* falls through */ + case 'second': + this.milliseconds(0); + /* falls through */ + } + + // weeks are a special case + if (units === 'week') { + this.weekday(0); + } else if (units === 'isoWeek') { + this.isoWeekday(1); + } + + // quarters are also special + if (units === 'quarter') { + this.month(Math.floor(this.month() / 3) * 3); + } + + return this; + }, + + endOf: function (units) { + units = normalizeUnits(units); + return this.startOf(units).add(1, (units === 'isoWeek' ? 'week' : units)).subtract(1, 'ms'); + }, + + isAfter: function (input, units) { + units = normalizeUnits(typeof units !== 'undefined' ? units : 'millisecond'); + if (units === 'millisecond') { + input = moment.isMoment(input) ? input : moment(input); + return +this > +input; + } else { + return +this.clone().startOf(units) > +moment(input).startOf(units); + } + }, + + isBefore: function (input, units) { + units = normalizeUnits(typeof units !== 'undefined' ? units : 'millisecond'); + if (units === 'millisecond') { + input = moment.isMoment(input) ? input : moment(input); + return +this < +input; + } else { + return +this.clone().startOf(units) < +moment(input).startOf(units); + } + }, + + isSame: function (input, units) { + units = normalizeUnits(units || 'millisecond'); + if (units === 'millisecond') { + input = moment.isMoment(input) ? input : moment(input); + return +this === +input; + } else { + return +this.clone().startOf(units) === +makeAs(input, this).startOf(units); + } + }, + + min: deprecate( + 'moment().min is deprecated, use moment.min instead. https://github.com/moment/moment/issues/1548', + function (other) { + other = moment.apply(null, arguments); + return other < this ? this : other; + } + ), + + max: deprecate( + 'moment().max is deprecated, use moment.max instead. https://github.com/moment/moment/issues/1548', + function (other) { + other = moment.apply(null, arguments); + return other > this ? this : other; + } + ), + + // keepLocalTime = true means only change the timezone, without + // affecting the local hour. So 5:31:26 +0300 --[zone(2, true)]--> + // 5:31:26 +0200 It is possible that 5:31:26 doesn't exist int zone + // +0200, so we adjust the time as needed, to be valid. + // + // Keeping the time actually adds/subtracts (one hour) + // from the actual represented time. That is why we call updateOffset + // a second time. In case it wants us to change the offset again + // _changeInProgress == true case, then we have to adjust, because + // there is no such time in the given timezone. + zone : function (input, keepLocalTime) { + var offset = this._offset || 0, + localAdjust; + if (input != null) { + if (typeof input === 'string') { + input = timezoneMinutesFromString(input); + } + if (Math.abs(input) < 16) { + input = input * 60; + } + if (!this._isUTC && keepLocalTime) { + localAdjust = this._dateTzOffset(); + } + this._offset = input; + this._isUTC = true; + if (localAdjust != null) { + this.subtract(localAdjust, 'm'); + } + if (offset !== input) { + if (!keepLocalTime || this._changeInProgress) { + addOrSubtractDurationFromMoment(this, + moment.duration(offset - input, 'm'), 1, false); + } else if (!this._changeInProgress) { + this._changeInProgress = true; + moment.updateOffset(this, true); + this._changeInProgress = null; + } + } + } else { + return this._isUTC ? offset : this._dateTzOffset(); + } + return this; + }, + + zoneAbbr : function () { + return this._isUTC ? 'UTC' : ''; + }, + + zoneName : function () { + return this._isUTC ? 'Coordinated Universal Time' : ''; + }, + + parseZone : function () { + if (this._tzm) { + this.zone(this._tzm); + } else if (typeof this._i === 'string') { + this.zone(this._i); + } + return this; + }, + + hasAlignedHourOffset : function (input) { + if (!input) { + input = 0; + } + else { + input = moment(input).zone(); + } + + return (this.zone() - input) % 60 === 0; + }, + + daysInMonth : function () { + return daysInMonth(this.year(), this.month()); + }, + + dayOfYear : function (input) { + var dayOfYear = round((moment(this).startOf('day') - moment(this).startOf('year')) / 864e5) + 1; + return input == null ? dayOfYear : this.add((input - dayOfYear), 'd'); + }, + + quarter : function (input) { + return input == null ? Math.ceil((this.month() + 1) / 3) : this.month((input - 1) * 3 + this.month() % 3); + }, + + weekYear : function (input) { + var year = weekOfYear(this, this.localeData()._week.dow, this.localeData()._week.doy).year; + return input == null ? year : this.add((input - year), 'y'); + }, + + isoWeekYear : function (input) { + var year = weekOfYear(this, 1, 4).year; + return input == null ? year : this.add((input - year), 'y'); + }, + + week : function (input) { + var week = this.localeData().week(this); + return input == null ? week : this.add((input - week) * 7, 'd'); + }, + + isoWeek : function (input) { + var week = weekOfYear(this, 1, 4).week; + return input == null ? week : this.add((input - week) * 7, 'd'); + }, + + weekday : function (input) { + var weekday = (this.day() + 7 - this.localeData()._week.dow) % 7; + return input == null ? weekday : this.add(input - weekday, 'd'); + }, + + isoWeekday : function (input) { + // behaves the same as moment#day except + // as a getter, returns 7 instead of 0 (1-7 range instead of 0-6) + // as a setter, sunday should belong to the previous week. + return input == null ? this.day() || 7 : this.day(this.day() % 7 ? input : input - 7); + }, + + isoWeeksInYear : function () { + return weeksInYear(this.year(), 1, 4); + }, + + weeksInYear : function () { + var weekInfo = this.localeData()._week; + return weeksInYear(this.year(), weekInfo.dow, weekInfo.doy); + }, + + get : function (units) { + units = normalizeUnits(units); + return this[units](); + }, + + set : function (units, value) { + units = normalizeUnits(units); + if (typeof this[units] === 'function') { + this[units](value); + } + return this; + }, + + // If passed a locale key, it will set the locale for this + // instance. Otherwise, it will return the locale configuration + // variables for this instance. + locale : function (key) { + var newLocaleData; + + if (key === undefined) { + return this._locale._abbr; + } else { + newLocaleData = moment.localeData(key); + if (newLocaleData != null) { + this._locale = newLocaleData; + } + return this; + } + }, + + lang : deprecate( + 'moment().lang() is deprecated. Use moment().localeData() instead.', + function (key) { + if (key === undefined) { + return this.localeData(); + } else { + return this.locale(key); + } + } + ), + + localeData : function () { + return this._locale; + }, + + _dateTzOffset : function () { + // On Firefox.24 Date#getTimezoneOffset returns a floating point. + // https://github.com/moment/moment/pull/1871 + return Math.round(this._d.getTimezoneOffset() / 15) * 15; + } + }); + + function rawMonthSetter(mom, value) { + var dayOfMonth; + + // TODO: Move this out of here! + if (typeof value === 'string') { + value = mom.localeData().monthsParse(value); + // TODO: Another silent failure? + if (typeof value !== 'number') { + return mom; + } + } + + dayOfMonth = Math.min(mom.date(), + daysInMonth(mom.year(), value)); + mom._d['set' + (mom._isUTC ? 'UTC' : '') + 'Month'](value, dayOfMonth); + return mom; + } + + function rawGetter(mom, unit) { + return mom._d['get' + (mom._isUTC ? 'UTC' : '') + unit](); + } + + function rawSetter(mom, unit, value) { + if (unit === 'Month') { + return rawMonthSetter(mom, value); + } else { + return mom._d['set' + (mom._isUTC ? 'UTC' : '') + unit](value); + } + } + + function makeAccessor(unit, keepTime) { + return function (value) { + if (value != null) { + rawSetter(this, unit, value); + moment.updateOffset(this, keepTime); + return this; + } else { + return rawGetter(this, unit); + } + }; + } + + moment.fn.millisecond = moment.fn.milliseconds = makeAccessor('Milliseconds', false); + moment.fn.second = moment.fn.seconds = makeAccessor('Seconds', false); + moment.fn.minute = moment.fn.minutes = makeAccessor('Minutes', false); + // Setting the hour should keep the time, because the user explicitly + // specified which hour he wants. So trying to maintain the same hour (in + // a new timezone) makes sense. Adding/subtracting hours does not follow + // this rule. + moment.fn.hour = moment.fn.hours = makeAccessor('Hours', true); + // moment.fn.month is defined separately + moment.fn.date = makeAccessor('Date', true); + moment.fn.dates = deprecate('dates accessor is deprecated. Use date instead.', makeAccessor('Date', true)); + moment.fn.year = makeAccessor('FullYear', true); + moment.fn.years = deprecate('years accessor is deprecated. Use year instead.', makeAccessor('FullYear', true)); + + // add plural methods + moment.fn.days = moment.fn.day; + moment.fn.months = moment.fn.month; + moment.fn.weeks = moment.fn.week; + moment.fn.isoWeeks = moment.fn.isoWeek; + moment.fn.quarters = moment.fn.quarter; + + // add aliased format methods + moment.fn.toJSON = moment.fn.toISOString; + + /************************************ + Duration Prototype + ************************************/ + + + function daysToYears (days) { + // 400 years have 146097 days (taking into account leap year rules) + return days * 400 / 146097; + } + + function yearsToDays (years) { + // years * 365 + absRound(years / 4) - + // absRound(years / 100) + absRound(years / 400); + return years * 146097 / 400; + } + + extend(moment.duration.fn = Duration.prototype, { + + _bubble : function () { + var milliseconds = this._milliseconds, + days = this._days, + months = this._months, + data = this._data, + seconds, minutes, hours, years = 0; + + // The following code bubbles up values, see the tests for + // examples of what that means. + data.milliseconds = milliseconds % 1000; + + seconds = absRound(milliseconds / 1000); + data.seconds = seconds % 60; + + minutes = absRound(seconds / 60); + data.minutes = minutes % 60; + + hours = absRound(minutes / 60); + data.hours = hours % 24; + + days += absRound(hours / 24); + + // Accurately convert days to years, assume start from year 0. + years = absRound(daysToYears(days)); + days -= absRound(yearsToDays(years)); + + // 30 days to a month + // TODO (iskren): Use anchor date (like 1st Jan) to compute this. + months += absRound(days / 30); + days %= 30; + + // 12 months -> 1 year + years += absRound(months / 12); + months %= 12; + + data.days = days; + data.months = months; + data.years = years; + }, + + abs : function () { + this._milliseconds = Math.abs(this._milliseconds); + this._days = Math.abs(this._days); + this._months = Math.abs(this._months); + + this._data.milliseconds = Math.abs(this._data.milliseconds); + this._data.seconds = Math.abs(this._data.seconds); + this._data.minutes = Math.abs(this._data.minutes); + this._data.hours = Math.abs(this._data.hours); + this._data.months = Math.abs(this._data.months); + this._data.years = Math.abs(this._data.years); + + return this; + }, + + weeks : function () { + return absRound(this.days() / 7); + }, + + valueOf : function () { + return this._milliseconds + + this._days * 864e5 + + (this._months % 12) * 2592e6 + + toInt(this._months / 12) * 31536e6; + }, + + humanize : function (withSuffix) { + var output = relativeTime(this, !withSuffix, this.localeData()); + + if (withSuffix) { + output = this.localeData().pastFuture(+this, output); + } + + return this.localeData().postformat(output); + }, + + add : function (input, val) { + // supports only 2.0-style add(1, 's') or add(moment) + var dur = moment.duration(input, val); + + this._milliseconds += dur._milliseconds; + this._days += dur._days; + this._months += dur._months; + + this._bubble(); + + return this; + }, + + subtract : function (input, val) { + var dur = moment.duration(input, val); + + this._milliseconds -= dur._milliseconds; + this._days -= dur._days; + this._months -= dur._months; + + this._bubble(); + + return this; + }, + + get : function (units) { + units = normalizeUnits(units); + return this[units.toLowerCase() + 's'](); + }, + + as : function (units) { + var days, months; + units = normalizeUnits(units); + + if (units === 'month' || units === 'year') { + days = this._days + this._milliseconds / 864e5; + months = this._months + daysToYears(days) * 12; + return units === 'month' ? months : months / 12; + } else { + // handle milliseconds separately because of floating point math errors (issue #1867) + days = this._days + yearsToDays(this._months / 12); + switch (units) { + case 'week': return days / 7 + this._milliseconds / 6048e5; + case 'day': return days + this._milliseconds / 864e5; + case 'hour': return days * 24 + this._milliseconds / 36e5; + case 'minute': return days * 24 * 60 + this._milliseconds / 6e4; + case 'second': return days * 24 * 60 * 60 + this._milliseconds / 1000; + // Math.floor prevents floating point math errors here + case 'millisecond': return Math.floor(days * 24 * 60 * 60 * 1000) + this._milliseconds; + default: throw new Error('Unknown unit ' + units); + } + } + }, + + lang : moment.fn.lang, + locale : moment.fn.locale, + + toIsoString : deprecate( + 'toIsoString() is deprecated. Please use toISOString() instead ' + + '(notice the capitals)', + function () { + return this.toISOString(); + } + ), + + toISOString : function () { + // inspired by https://github.com/dordille/moment-isoduration/blob/master/moment.isoduration.js + var years = Math.abs(this.years()), + months = Math.abs(this.months()), + days = Math.abs(this.days()), + hours = Math.abs(this.hours()), + minutes = Math.abs(this.minutes()), + seconds = Math.abs(this.seconds() + this.milliseconds() / 1000); + + if (!this.asSeconds()) { + // this is the same as C#'s (Noda) and python (isodate)... + // but not other JS (goog.date) + return 'P0D'; + } + + return (this.asSeconds() < 0 ? '-' : '') + + 'P' + + (years ? years + 'Y' : '') + + (months ? months + 'M' : '') + + (days ? days + 'D' : '') + + ((hours || minutes || seconds) ? 'T' : '') + + (hours ? hours + 'H' : '') + + (minutes ? minutes + 'M' : '') + + (seconds ? seconds + 'S' : ''); + }, + + localeData : function () { + return this._locale; + } + }); + + moment.duration.fn.toString = moment.duration.fn.toISOString; + + function makeDurationGetter(name) { + moment.duration.fn[name] = function () { + return this._data[name]; + }; + } + + for (i in unitMillisecondFactors) { + if (hasOwnProp(unitMillisecondFactors, i)) { + makeDurationGetter(i.toLowerCase()); + } + } + + moment.duration.fn.asMilliseconds = function () { + return this.as('ms'); + }; + moment.duration.fn.asSeconds = function () { + return this.as('s'); + }; + moment.duration.fn.asMinutes = function () { + return this.as('m'); + }; + moment.duration.fn.asHours = function () { + return this.as('h'); + }; + moment.duration.fn.asDays = function () { + return this.as('d'); + }; + moment.duration.fn.asWeeks = function () { + return this.as('weeks'); + }; + moment.duration.fn.asMonths = function () { + return this.as('M'); + }; + moment.duration.fn.asYears = function () { + return this.as('y'); + }; + + /************************************ + Default Locale + ************************************/ + + + // Set default locale, other locale will inherit from English. + moment.locale('en', { + ordinal : function (number) { + var b = number % 10, + output = (toInt(number % 100 / 10) === 1) ? 'th' : + (b === 1) ? 'st' : + (b === 2) ? 'nd' : + (b === 3) ? 'rd' : 'th'; + return number + output; + } + }); + + return moment; + + }).call(this); + + UI.Utils.moment = moment; + + return UI.datepicker; +}); diff --git a/js/components/datepicker.min.js b/js/components/datepicker.min.js new file mode 100755 index 0000000..f8dfe47 --- /dev/null +++ b/js/components/datepicker.min.js @@ -0,0 +1,3 @@ +/*! UIkit 2.26.4 | http://www.getuikit.com | (c) 2014 YOOtheme | MIT License */ +!function(t){var e;window.UIkit&&(e=t(UIkit)),"function"==typeof define&&define.amd&&define("uikit-datepicker",["uikit"],function(){return e||t(UIkit)})}(function(t){"use strict";var e,n,a=!1;return t.component("datepicker",{defaults:{mobile:!1,weekstart:1,i18n:{months:["January","February","March","April","May","June","July","August","September","October","November","December"],weekdays:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"]},format:"YYYY-MM-DD",offsettop:5,maxDate:!1,minDate:!1,pos:"auto",template:function(e,n){var a,s="";if(s+='
',s+='',s+='',t.formSelect){var i,r,o,u,c=(new Date).getFullYear(),d=[];for(a=0;a'+n.i18n.months[a]+""):d.push('");for(i=''+n.i18n.months[e.month]+'",d=[],o=e.minDate?e.minDate.year():c-50,u=e.maxDate?e.maxDate.year():c+20,a=o;u>=a;a++)a==e.year?d.push('"):d.push('");r=''+e.year+'",s+='
'+i+" "+r+"
"}else s+='
'+n.i18n.months[e.month]+" "+e.year+"
";for(s+="
",s+='',s+="",a=0;a"+e.weekdays[a]+"");for(s+="",s+="",a=0;a";for(var l=0;l'+h.day.format("D")+""}s+=""}return s+="",s+="
"}},boot:function(){t.$win.on("resize orientationchange",function(){a&&a.hide()}),t.$html.on("focus.datepicker.uikit","[data-uk-datepicker]",function(e){var n=t.$(this);n.data("datepicker")||(e.preventDefault(),t.datepicker(n,t.Utils.options(n.attr("data-uk-datepicker"))),n.trigger("focus"))}),t.$html.on("click focus","*",function(n){var s=t.$(n.target);!a||s[0]==e[0]||s.data("datepicker")||s.parents(".uk-datepicker:first").length||a.hide()})},init:function(){if(!t.support.touch||"date"!=this.element.attr("type")||this.options.mobile){var s=this;this.current=this.element.val()?n(this.element.val(),this.options.format):n(),this.on("click focus",function(){a!==s&&s.pick(this.value?this.value:s.options.minDate?s.options.minDate:"")}).on("change",function(){s.element.val()&&!n(s.element.val(),s.options.format).isValid()&&s.element.val(n().format(s.options.format))}),e||(e=t.$('
'),e.on("click",".uk-datepicker-next, .uk-datepicker-previous, [data-date]",function(e){e.stopPropagation(),e.preventDefault();var s=t.$(this);return s.hasClass("uk-datepicker-date-disabled")?!1:(s.is("[data-date]")?(a.current=n(s.data("date")),a.element.val(a.current.isValid()?a.current.format(a.options.format):null).trigger("change"),a.hide()):a.add(s.hasClass("uk-datepicker-next")?1:-1,"months"),void 0)}),e.on("change",".update-picker-month, .update-picker-year",function(){var e=t.$(this);a[e.is(".update-picker-year")?"setYear":"setMonth"](Number(e.val()))}),e.appendTo("body"))}},pick:function(s){var i=this.element.offset(),r={left:i.left,right:""};this.current=isNaN(s)?n(s,this.options.format):n(),this.initdate=this.current.format("YYYY-MM-DD"),this.update(),"right"==t.langdirection&&(r.right=window.innerWidth-(r.left+this.element.outerWidth()),r.left="");var o=i.top-this.element.outerHeight()+this.element.height()-this.options.offsettop-e.outerHeight(),u=i.top+this.element.outerHeight()+this.options.offsettop;r.top=u,"top"==this.options.pos?r.top=o:"auto"==this.options.pos&&window.innerHeight-u-e.outerHeight()<0&&o>=0&&(r.top=o),e.css(r).show(),this.trigger("show.uk.datepicker"),a=this},add:function(t,e){this.current.add(t,e),this.update()},setMonth:function(t){this.current.month(t),this.update()},setYear:function(t){this.current.year(t),this.update()},update:function(){var t=this.getRows(this.current.year(),this.current.month()),n=this.options.template(t,this.options);e.html(n),this.trigger("update.uk.datepicker")},getRows:function(t,e){var a=this.options,s=n().format("YYYY-MM-DD"),i=[31,t%4===0&&t%100!==0||t%400===0?29:28,31,30,31,30,31,31,30,31,30,31][e],r=new Date(t,e,1,12).getDay(),o={month:e,year:t,weekdays:[],days:[],maxDate:!1,minDate:!1},u=[];a.maxDate!==!1&&(o.maxDate=isNaN(a.maxDate)?n(a.maxDate,a.format):n().add(a.maxDate,"days")),a.minDate!==!1&&(o.minDate=isNaN(a.minDate)?n(a.minDate,a.format):n().add(a.minDate-1,"days")),o.weekdays=function(){for(var t=0,e=[];7>t;t++){for(var n=t+(a.weekstart||0);n>=7;)n-=7;e.push(a.i18n.weekdays[n])}return e}(),a.weekstart&&a.weekstart>0&&(r-=a.weekstart,0>r&&(r+=7));for(var c=i+r,d=c;d>7;)d-=7;c+=7-d;for(var l,h,f,m,_,p=0,y=0;c>p;p++)l=new Date(t,e,1+(p-r),12),h=o.minDate&&o.minDate>l||o.maxDate&&l>o.maxDate,_=!(r>p||p>=i+r),l=n(l),f=this.initdate==l.format("YYYY-MM-DD"),m=s==l.format("YYYY-MM-DD"),u.push({selected:f,today:m,disabled:h,day:l,inmonth:_}),7===++y&&(o.days.push(u),u=[],y=0);return o},hide:function(){a&&a===this&&(e.hide(),a=!1,this.trigger("hide.uk.datepicker"))}}),n=function(t){function e(t,e,n){switch(arguments.length){case 2:return null!=t?t:e;case 3:return null!=t?t:null!=e?e:n;default:throw new Error("Implement me")}}function n(t,e){return Ye.call(t,e)}function a(){return{empty:!1,unusedTokens:[],unusedInput:[],overflow:-2,charsLeftOver:0,nullInput:!1,invalidMonth:null,invalidFormat:!1,userInvalidated:!1,iso:!1}}function s(t){De.suppressDeprecationWarnings===!1&&"undefined"!=typeof console&&console.warn&&console.warn("Deprecation warning: "+t)}function i(t,e){var n=!0;return h(function(){return n&&(s(t),n=!1),e.apply(this,arguments)},e)}function r(t,e){mn[t]||(s(e),mn[t]=!0)}function o(t,e){return function(n){return _(t.call(this,n),e)}}function u(t,e){return function(n){return this.localeData().ordinal(t.call(this,n),e)}}function c(){}function d(t,e){e!==!1&&F(t),f(this,t),this._d=new Date(+t._d)}function l(t){var e=v(t),n=e.year||0,a=e.quarter||0,s=e.month||0,i=e.week||0,r=e.day||0,o=e.hour||0,u=e.minute||0,c=e.second||0,d=e.millisecond||0;this._milliseconds=+d+1e3*c+6e4*u+36e5*o,this._days=+r+7*i,this._months=+s+3*a+12*n,this._data={},this._locale=De.localeData(),this._bubble()}function h(t,e){for(var a in e)n(e,a)&&(t[a]=e[a]);return n(e,"toString")&&(t.toString=e.toString),n(e,"valueOf")&&(t.valueOf=e.valueOf),t}function f(t,e){var n,a,s;if("undefined"!=typeof e._isAMomentObject&&(t._isAMomentObject=e._isAMomentObject),"undefined"!=typeof e._i&&(t._i=e._i),"undefined"!=typeof e._f&&(t._f=e._f),"undefined"!=typeof e._l&&(t._l=e._l),"undefined"!=typeof e._strict&&(t._strict=e._strict),"undefined"!=typeof e._tzm&&(t._tzm=e._tzm),"undefined"!=typeof e._isUTC&&(t._isUTC=e._isUTC),"undefined"!=typeof e._offset&&(t._offset=e._offset),"undefined"!=typeof e._pf&&(t._pf=e._pf),"undefined"!=typeof e._locale&&(t._locale=e._locale),Fe.length>0)for(n in Fe)a=Fe[n],s=e[a],"undefined"!=typeof s&&(t[a]=s);return t}function m(t){return 0>t?Math.ceil(t):Math.floor(t)}function _(t,e,n){for(var a=""+Math.abs(t),s=t>=0;a.lengtha;a++)(n&&t[a]!==e[a]||!n&&S(t[a])!==S(e[a]))&&r++;return r+i}function w(t){if(t){var e=t.toLowerCase().replace(/(.)s$/,"$1");t=on[t]||un[e]||e}return t}function v(t){var e,a,s={};for(a in t)n(t,a)&&(e=w(a),e&&(s[e]=t[a]));return s}function b(e){var n,a;if(0===e.indexOf("week"))n=7,a="day";else{if(0!==e.indexOf("month"))return;n=12,a="month"}De[e]=function(s,i){var r,o,u=De._locale[e],c=[];if("number"==typeof s&&(i=s,s=t),o=function(t){var e=De().utc().set(a,t);return u.call(De._locale,e,s||"")},null!=i)return o(i);for(r=0;n>r;r++)c.push(o(r));return c}}function S(t){var e=+t,n=0;return 0!==e&&isFinite(e)&&(n=e>=0?Math.floor(e):Math.ceil(e)),n}function T(t,e){return new Date(Date.UTC(t,e+1,0)).getUTCDate()}function O(t,e,n){return oe(De([t,11,31+e-n]),e,n).week}function W(t){return U(t)?366:365}function U(t){return t%4===0&&t%100!==0||t%400===0}function F(t){var e;t._a&&-2===t._pf.overflow&&(e=t._a[ve]<0||t._a[ve]>11?ve:t._a[be]<1||t._a[be]>T(t._a[we],t._a[ve])?be:t._a[Se]<0||t._a[Se]>23?Se:t._a[Te]<0||t._a[Te]>59?Te:t._a[Oe]<0||t._a[Oe]>59?Oe:t._a[We]<0||t._a[We]>999?We:-1,t._pf._overflowDayOfYear&&(we>e||e>be)&&(e=be),t._pf.overflow=e)}function G(t){return null==t._isValid&&(t._isValid=!isNaN(t._d.getTime())&&t._pf.overflow<0&&!t._pf.empty&&!t._pf.invalidMonth&&!t._pf.nullInput&&!t._pf.invalidFormat&&!t._pf.userInvalidated,t._strict&&(t._isValid=t._isValid&&0===t._pf.charsLeftOver&&0===t._pf.unusedTokens.length)),t._isValid}function C(t){return t?t.toLowerCase().replace("_","-"):t}function z(t){for(var e,n,a,s,i=0;i0;){if(a=x(s.slice(0,e).join("-")))return a;if(n&&n.length>=e&&Y(s,n,!0)>=e-1)break;e--}i++}return null}function x(t){var e=null;if(!Ue[t]&&Ge)try{e=De.locale(),require("./locale/"+t),De.locale(e)}catch(n){}return Ue[t]}function I(t,e){return e._isUTC?De(t).zone(e._offset||0):De(t).local()}function H(t){return t.match(/\[[\s\S]/)?t.replace(/^\[|\]$/g,""):t.replace(/\\/g,"")}function L(t){var e,n,a=t.match(Ie);for(e=0,n=a.length;n>e;e++)a[e]=fn[a[e]]?fn[a[e]]:H(a[e]);return function(s){var i="";for(e=0;n>e;e++)i+=a[e]instanceof Function?a[e].call(s,t):a[e];return i}}function P(t,e){return t.isValid()?(e=A(e,t.localeData()),cn[e]||(cn[e]=L(e)),cn[e](t)):t.localeData().invalidDate()}function A(t,e){function n(t){return e.longDateFormat(t)||t}var a=5;for(He.lastIndex=0;a>=0&&He.test(t);)t=t.replace(He,n),He.lastIndex=0,a-=1;return t}function N(t,e){var n,a=e._strict;switch(t){case"Q":return qe;case"DDDD":return Re;case"YYYY":case"GGGG":case"gggg":return a?Xe:Ae;case"Y":case"G":case"g":return Ke;case"YYYYYY":case"YYYYY":case"GGGGG":case"ggggg":return a?Be:Ne;case"S":if(a)return qe;case"SS":if(a)return Qe;case"SSS":if(a)return Re;case"DDD":return Pe;case"MMM":case"MMMM":case"dd":case"ddd":case"dddd":return je;case"a":case"A":return e._locale._meridiemParse;case"X":return Ve;case"Z":case"ZZ":return Ee;case"T":return $e;case"SSSS":return Ze;case"MM":case"DD":case"YY":case"GG":case"gg":case"HH":case"hh":case"mm":case"ss":case"ww":case"WW":return a?Qe:Le;case"M":case"D":case"d":case"H":case"h":case"m":case"s":case"w":case"W":case"e":case"E":return Le;case"Do":return Je;default:return n=new RegExp(R(Q(t.replace("\\","")),"i"))}}function Z(t){t=t||"";var e=t.match(Ee)||[],n=e[e.length-1]||[],a=(n+"").match(sn)||["-",0,0],s=+(60*a[1])+S(a[2]);return"+"===a[0]?-s:s}function j(t,e,n){var a,s=n._a;switch(t){case"Q":null!=e&&(s[ve]=3*(S(e)-1));break;case"M":case"MM":null!=e&&(s[ve]=S(e)-1);break;case"MMM":case"MMMM":a=n._locale.monthsParse(e),null!=a?s[ve]=a:n._pf.invalidMonth=e;break;case"D":case"DD":null!=e&&(s[be]=S(e));break;case"Do":null!=e&&(s[be]=S(parseInt(e,10)));break;case"DDD":case"DDDD":null!=e&&(n._dayOfYear=S(e));break;case"YY":s[we]=De.parseTwoDigitYear(e);break;case"YYYY":case"YYYYY":case"YYYYYY":s[we]=S(e);break;case"a":case"A":n._isPm=n._locale.isPM(e);break;case"H":case"HH":case"h":case"hh":s[Se]=S(e);break;case"m":case"mm":s[Te]=S(e);break;case"s":case"ss":s[Oe]=S(e);break;case"S":case"SS":case"SSS":case"SSSS":s[We]=S(1e3*("0."+e));break;case"X":n._d=new Date(1e3*parseFloat(e));break;case"Z":case"ZZ":n._useUTC=!0,n._tzm=Z(e);break;case"dd":case"ddd":case"dddd":a=n._locale.weekdaysParse(e),null!=a?(n._w=n._w||{},n._w.d=a):n._pf.invalidWeekday=e;break;case"w":case"ww":case"W":case"WW":case"d":case"e":case"E":t=t.substr(0,1);case"gggg":case"GGGG":case"GGGGG":t=t.substr(0,2),e&&(n._w=n._w||{},n._w[t]=S(e));break;case"gg":case"GG":n._w=n._w||{},n._w[t]=De.parseTwoDigitYear(e)}}function E(t){var n,a,s,i,r,o,u;n=t._w,null!=n.GG||null!=n.W||null!=n.E?(r=1,o=4,a=e(n.GG,t._a[we],oe(De(),1,4).year),s=e(n.W,1),i=e(n.E,1)):(r=t._locale._week.dow,o=t._locale._week.doy,a=e(n.gg,t._a[we],oe(De(),r,o).year),s=e(n.w,1),null!=n.d?(i=n.d,r>i&&++s):i=null!=n.e?n.e+r:r),u=ue(a,s,i,o,r),t._a[we]=u.year,t._dayOfYear=u.dayOfYear}function $(t){var n,a,s,i,r=[];if(!t._d){for(s=J(t),t._w&&null==t._a[be]&&null==t._a[ve]&&E(t),t._dayOfYear&&(i=e(t._a[we],s[we]),t._dayOfYear>W(i)&&(t._pf._overflowDayOfYear=!0),a=ae(i,0,t._dayOfYear),t._a[ve]=a.getUTCMonth(),t._a[be]=a.getUTCDate()),n=0;3>n&&null==t._a[n];++n)t._a[n]=r[n]=s[n];for(;7>n;n++)t._a[n]=r[n]=null==t._a[n]?2===n?1:0:t._a[n];t._d=(t._useUTC?ae:ne).apply(null,r),null!=t._tzm&&t._d.setUTCMinutes(t._d.getUTCMinutes()+t._tzm)}}function V(t){var e;t._d||(e=v(t._i),t._a=[e.year,e.month,e.day,e.hour,e.minute,e.second,e.millisecond],$(t))}function J(t){var e=new Date;return t._useUTC?[e.getUTCFullYear(),e.getUTCMonth(),e.getUTCDate()]:[e.getFullYear(),e.getMonth(),e.getDate()]}function q(t){if(t._f===De.ISO_8601)return B(t),void 0;t._a=[],t._pf.empty=!0;var e,n,a,s,i,r=""+t._i,o=r.length,u=0;for(a=A(t._f,t._locale).match(Ie)||[],e=0;e0&&t._pf.unusedInput.push(i),r=r.slice(r.indexOf(n)+n.length),u+=n.length),fn[s]?(n?t._pf.empty=!1:t._pf.unusedTokens.push(s),j(s,n,t)):t._strict&&!n&&t._pf.unusedTokens.push(s);t._pf.charsLeftOver=o-u,r.length>0&&t._pf.unusedInput.push(r),t._isPm&&t._a[Se]<12&&(t._a[Se]+=12),t._isPm===!1&&12===t._a[Se]&&(t._a[Se]=0),$(t),F(t)}function Q(t){return t.replace(/\\(\[)|\\(\])|\[([^\]\[]*)\]|\\(.)/g,function(t,e,n,a,s){return e||n||a||s})}function R(t){return t.replace(/[-\/\\^$*+?.()|[\]{}]/g,"\\$&")}function X(t){var e,n,s,i,r;if(0===t._f.length)return t._pf.invalidFormat=!0,t._d=new Date(0/0),void 0;for(i=0;ir)&&(s=r,n=e));h(t,n||e)}function B(t){var e,n,a=t._i,s=tn.exec(a);if(s){for(t._pf.iso=!0,e=0,n=nn.length;n>e;e++)if(nn[e][1].exec(a)){t._f=nn[e][0]+(s[6]||" ");break}for(e=0,n=an.length;n>e;e++)if(an[e][1].exec(a)){t._f+=an[e][0];break}a.match(Ee)&&(t._f+="Z"),q(t)}else t._isValid=!1}function K(t){B(t),t._isValid===!1&&(delete t._isValid,De.createFromInputFallback(t))}function te(t,e){var n,a=[];for(n=0;nt&&o.setFullYear(t),o}function ae(t){var e=new Date(Date.UTC.apply(null,arguments));return 1970>t&&e.setUTCFullYear(t),e}function se(t,e){if("string"==typeof t)if(isNaN(t)){if(t=e.weekdaysParse(t),"number"!=typeof t)return null}else t=parseInt(t,10);return t}function ie(t,e,n,a,s){return s.relativeTime(e||1,!!n,t,a)}function re(t,e,n){var a=De.duration(t).abs(),s=Me(a.as("s")),i=Me(a.as("m")),r=Me(a.as("h")),o=Me(a.as("d")),u=Me(a.as("M")),c=Me(a.as("y")),d=s0,d[4]=n,ie.apply({},d)}function oe(t,e,n){var a,s=n-e,i=n-t.day();return i>s&&(i-=7),s-7>i&&(i+=7),a=De(t).add(i,"d"),{week:Math.ceil(a.dayOfYear()/7),year:a.year()}}function ue(t,e,n,a,s){var i,r,o=ae(t,0,1).getUTCDay();return o=0===o?7:o,n=null!=n?n:s,i=s-o+(o>a?7:0)-(s>o?7:0),r=7*(e-1)+(n-s)+i+1,{year:r>0?t:t-1,dayOfYear:r>0?r:W(t-1)+r}}function ce(e){var n=e._i,a=e._f;return e._locale=e._locale||De.localeData(e._l),null===n||a===t&&""===n?De.invalid({nullInput:!0}):("string"==typeof n&&(e._i=n=e._locale.preparse(n)),De.isMoment(n)?new d(n,!0):(a?k(a)?X(e):q(e):ee(e),new d(e)))}function de(t,e){var n,a;if(1===e.length&&k(e[0])&&(e=e[0]),!e.length)return De();for(n=e[0],a=1;a=0?"+":"-";return e+_(Math.abs(t),6)},gg:function(){return _(this.weekYear()%100,2)},gggg:function(){return _(this.weekYear(),4)},ggggg:function(){return _(this.weekYear(),5)},GG:function(){return _(this.isoWeekYear()%100,2)},GGGG:function(){return _(this.isoWeekYear(),4)},GGGGG:function(){return _(this.isoWeekYear(),5)},e:function(){return this.weekday()},E:function(){return this.isoWeekday()},a:function(){return this.localeData().meridiem(this.hours(),this.minutes(),!0)},A:function(){return this.localeData().meridiem(this.hours(),this.minutes(),!1)},H:function(){return this.hours()},h:function(){return this.hours()%12||12},m:function(){return this.minutes()},s:function(){return this.seconds()},S:function(){return S(this.milliseconds()/100)},SS:function(){return _(S(this.milliseconds()/10),2)},SSS:function(){return _(this.milliseconds(),3)},SSSS:function(){return _(this.milliseconds(),3)},Z:function(){var t=-this.zone(),e="+";return 0>t&&(t=-t,e="-"),e+_(S(t/60),2)+":"+_(S(t)%60,2)},ZZ:function(){var t=-this.zone(),e="+";return 0>t&&(t=-t,e="-"),e+_(S(t/60),2)+_(S(t)%60,2)},z:function(){return this.zoneAbbr()},zz:function(){return this.zoneName()},X:function(){return this.unix()},Q:function(){return this.quarter()}},mn={},_n=["months","monthsShort","weekdays","weekdaysShort","weekdaysMin"];ln.length;)ge=ln.pop(),fn[ge+"o"]=u(fn[ge],ge);for(;hn.length;)ge=hn.pop(),fn[ge+ge]=o(fn[ge],2);fn.DDDD=o(fn.DDD,3),h(c.prototype,{set:function(t){var e,n;for(n in t)e=t[n],"function"==typeof e?this[n]=e:this["_"+n]=e},_months:"January_February_March_April_May_June_July_August_September_October_November_December".split("_"),months:function(t){return this._months[t.month()]},_monthsShort:"Jan_Feb_Mar_Apr_May_Jun_Jul_Aug_Sep_Oct_Nov_Dec".split("_"),monthsShort:function(t){return this._monthsShort[t.month()]},monthsParse:function(t){var e,n,a;for(this._monthsParse||(this._monthsParse=[]),e=0;12>e;e++)if(this._monthsParse[e]||(n=De.utc([2e3,e]),a="^"+this.months(n,"")+"|^"+this.monthsShort(n,""),this._monthsParse[e]=new RegExp(a.replace(".",""),"i")),this._monthsParse[e].test(t))return e},_weekdays:"Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"),weekdays:function(t){return this._weekdays[t.day()]},_weekdaysShort:"Sun_Mon_Tue_Wed_Thu_Fri_Sat".split("_"),weekdaysShort:function(t){return this._weekdaysShort[t.day()]},_weekdaysMin:"Su_Mo_Tu_We_Th_Fr_Sa".split("_"),weekdaysMin:function(t){return this._weekdaysMin[t.day()]},weekdaysParse:function(t){var e,n,a;for(this._weekdaysParse||(this._weekdaysParse=[]),e=0;7>e;e++)if(this._weekdaysParse[e]||(n=De([2e3,1]).day(e),a="^"+this.weekdays(n,"")+"|^"+this.weekdaysShort(n,"")+"|^"+this.weekdaysMin(n,""),this._weekdaysParse[e]=new RegExp(a.replace(".",""),"i")),this._weekdaysParse[e].test(t))return e},_longDateFormat:{LT:"h:mm A",L:"MM/DD/YYYY",LL:"MMMM D, YYYY",LLL:"MMMM D, YYYY LT",LLLL:"dddd, MMMM D, YYYY LT"},longDateFormat:function(t){var e=this._longDateFormat[t];return!e&&this._longDateFormat[t.toUpperCase()]&&(e=this._longDateFormat[t.toUpperCase()].replace(/MMMM|MM|DD|dddd/g,function(t){return t.slice(1)}),this._longDateFormat[t]=e),e},isPM:function(t){return"p"===(t+"").toLowerCase().charAt(0)},_meridiemParse:/[ap]\.?m?\.?/i,meridiem:function(t,e,n){return t>11?n?"pm":"PM":n?"am":"AM"},_calendar:{sameDay:"[Today at] LT",nextDay:"[Tomorrow at] LT",nextWeek:"dddd [at] LT",lastDay:"[Yesterday at] LT",lastWeek:"[Last] dddd [at] LT",sameElse:"L"},calendar:function(t,e){var n=this._calendar[t];return"function"==typeof n?n.apply(e):n},_relativeTime:{future:"in %s",past:"%s ago",s:"a few seconds",m:"a minute",mm:"%d minutes",h:"an hour",hh:"%d hours",d:"a day",dd:"%d days",M:"a month",MM:"%d months",y:"a year",yy:"%d years"},relativeTime:function(t,e,n,a){var s=this._relativeTime[n];return"function"==typeof s?s(t,e,n,a):s.replace(/%d/i,t)},pastFuture:function(t,e){var n=this._relativeTime[t>0?"future":"past"];return"function"==typeof n?n(e):n.replace(/%s/i,e)},ordinal:function(t){return this._ordinal.replace("%d",t)},_ordinal:"%d",preparse:function(t){return t},postformat:function(t){return t},week:function(t){return oe(t,this._week.dow,this._week.doy).week},_week:{dow:0,doy:6},_invalidDate:"Invalid date",invalidDate:function(){return this._invalidDate}}),De=function(e,n,s,i){var r;return"boolean"==typeof s&&(i=s,s=t),r={},r._isAMomentObject=!0,r._i=e,r._f=n,r._l=s,r._strict=i,r._isUTC=!1,r._pf=a(),ce(r)},De.suppressDeprecationWarnings=!1,De.createFromInputFallback=i("moment construction falls back to js Date. This is discouraged and will be removed in upcoming major release. Please refer to https://github.com/moment/moment/issues/1407 for more info.",function(t){t._d=new Date(t._i)}),De.min=function(){var t=[].slice.call(arguments,0);return de("isBefore",t)},De.max=function(){var t=[].slice.call(arguments,0);return de("isAfter",t)},De.utc=function(e,n,s,i){var r;return"boolean"==typeof s&&(i=s,s=t),r={},r._isAMomentObject=!0,r._useUTC=!0,r._isUTC=!0,r._l=s,r._i=e,r._f=n,r._strict=i,r._pf=a(),ce(r).utc()},De.unix=function(t){return De(1e3*t)},De.duration=function(t,e){var a,s,i,r,o=t,u=null;return De.isDuration(t)?o={ms:t._milliseconds,d:t._days,M:t._months}:"number"==typeof t?(o={},e?o[e]=t:o.milliseconds=t):(u=ze.exec(t))?(a="-"===u[1]?-1:1,o={y:0,d:S(u[be])*a,h:S(u[Se])*a,m:S(u[Te])*a,s:S(u[Oe])*a,ms:S(u[We])*a}):(u=xe.exec(t))?(a="-"===u[1]?-1:1,i=function(t){var e=t&&parseFloat(t.replace(",","."));return(isNaN(e)?0:e)*a},o={y:i(u[2]),M:i(u[3]),d:i(u[4]),h:i(u[5]),m:i(u[6]),s:i(u[7]),w:i(u[8])}):"object"==typeof o&&("from"in o||"to"in o)&&(r=y(De(o.from),De(o.to)),o={},o.ms=r.milliseconds,o.M=r.months),s=new l(o),De.isDuration(t)&&n(t,"_locale")&&(s._locale=t._locale),s},De.version=ke,De.defaultFormat=en,De.ISO_8601=function(){},De.momentProperties=Fe,De.updateOffset=function(){},De.relativeTimeThreshold=function(e,n){return dn[e]===t?!1:n===t?dn[e]:(dn[e]=n,!0)},De.lang=i("moment.lang is deprecated. Use moment.locale instead.",function(t,e){return De.locale(t,e)}),De.locale=function(t,e){var n;return t&&(n="undefined"!=typeof e?De.defineLocale(t,e):De.localeData(t),n&&(De.duration._locale=De._locale=n)),De._locale._abbr},De.defineLocale=function(t,e){return null!==e?(e.abbr=t,Ue[t]||(Ue[t]=new c),Ue[t].set(e),De.locale(t),Ue[t]):(delete Ue[t],null)},De.langData=i("moment.langData is deprecated. Use moment.localeData instead.",function(t){return De.localeData(t)}),De.localeData=function(t){var e;if(t&&t._locale&&t._locale._abbr&&(t=t._locale._abbr),!t)return De._locale;if(!k(t)){if(e=x(t))return e;t=[t]}return z(t)},De.isMoment=function(t){return t instanceof d||null!=t&&n(t,"_isAMomentObject")},De.isDuration=function(t){return t instanceof l};for(ge=_n.length-1;ge>=0;--ge)b(_n[ge]);De.normalizeUnits=function(t){return w(t)},De.invalid=function(t){var e=De.utc(0/0);return null!=t?h(e._pf,t):e._pf.userInvalidated=!0,e},De.parseZone=function(){return De.apply(null,arguments).parseZone()},De.parseTwoDigitYear=function(t){return S(t)+(S(t)>68?1900:2e3)},h(De.fn=d.prototype,{clone:function(){return De(this)},valueOf:function(){return+this._d+6e4*(this._offset||0)},unix:function(){return Math.floor(+this/1e3)},toString:function(){return this.clone().locale("en").format("ddd MMM DD YYYY HH:mm:ss [GMT]ZZ")},toDate:function(){return this._offset?new Date(+this):this._d},toISOString:function(){var t=De(this).utc();return 00:!1},parsingFlags:function(){return h({},this._pf)},invalidAt:function(){return this._pf.overflow},utc:function(t){return this.zone(0,t)},local:function(t){return this._isUTC&&(this.zone(0,t),this._isUTC=!1,t&&this.add(this._dateTzOffset(),"m")),this},format:function(t){var e=P(this,t||De.defaultFormat);return this.localeData().postformat(e)},add:D(1,"add"),subtract:D(-1,"subtract"),diff:function(t,e,n){var a,s,i,r=I(t,this),o=6e4*(this.zone()-r.zone());return e=w(e),"year"===e||"month"===e?(a=432e5*(this.daysInMonth()+r.daysInMonth()),s=12*(this.year()-r.year())+(this.month()-r.month()),i=this-De(this).startOf("month")-(r-De(r).startOf("month")),i-=6e4*(this.zone()-De(this).startOf("month").zone()-(r.zone()-De(r).startOf("month").zone())),s+=i/a,"year"===e&&(s/=12)):(a=this-r,s="second"===e?a/1e3:"minute"===e?a/6e4:"hour"===e?a/36e5:"day"===e?(a-o)/864e5:"week"===e?(a-o)/6048e5:a),n?s:m(s)},from:function(t,e){return De.duration({to:this,from:t}).locale(this.locale()).humanize(!e)},fromNow:function(t){return this.from(De(),t)},calendar:function(t){var e=t||De(),n=I(e,this).startOf("day"),a=this.diff(n,"days",!0),s=-6>a?"sameElse":-1>a?"lastWeek":0>a?"lastDay":1>a?"sameDay":2>a?"nextDay":7>a?"nextWeek":"sameElse";return this.format(this.localeData().calendar(s,this))},isLeapYear:function(){return U(this.year())},isDST:function(){return this.zone()+t):+this.clone().startOf(e)>+De(t).startOf(e)},isBefore:function(t,e){return e=w("undefined"!=typeof e?e:"millisecond"),"millisecond"===e?(t=De.isMoment(t)?t:De(t),+t>+this):+this.clone().startOf(e)<+De(t).startOf(e)},isSame:function(t,e){return e=w(e||"millisecond"),"millisecond"===e?(t=De.isMoment(t)?t:De(t),+this===+t):+this.clone().startOf(e)===+I(t,this).startOf(e)},min:i("moment().min is deprecated, use moment.min instead. https://github.com/moment/moment/issues/1548",function(t){return t=De.apply(null,arguments),this>t?this:t}),max:i("moment().max is deprecated, use moment.max instead. https://github.com/moment/moment/issues/1548",function(t){return t=De.apply(null,arguments),t>this?this:t}),zone:function(t,e){var n,a=this._offset||0;return null==t?this._isUTC?a:this._dateTzOffset():("string"==typeof t&&(t=Z(t)),Math.abs(t)<16&&(t=60*t),!this._isUTC&&e&&(n=this._dateTzOffset()),this._offset=t,this._isUTC=!0,null!=n&&this.subtract(n,"m"),a!==t&&(!e||this._changeInProgress?g(this,De.duration(a-t,"m"),1,!1):this._changeInProgress||(this._changeInProgress=!0,De.updateOffset(this,!0),this._changeInProgress=null)),this)},zoneAbbr:function(){return this._isUTC?"UTC":""},zoneName:function(){return this._isUTC?"Coordinated Universal Time":""},parseZone:function(){return this._tzm?this.zone(this._tzm):"string"==typeof this._i&&this.zone(this._i),this +},hasAlignedHourOffset:function(t){return t=t?De(t).zone():0,(this.zone()-t)%60===0},daysInMonth:function(){return T(this.year(),this.month())},dayOfYear:function(t){var e=Me((De(this).startOf("day")-De(this).startOf("year"))/864e5)+1;return null==t?e:this.add(t-e,"d")},quarter:function(t){return null==t?Math.ceil((this.month()+1)/3):this.month(3*(t-1)+this.month()%3)},weekYear:function(t){var e=oe(this,this.localeData()._week.dow,this.localeData()._week.doy).year;return null==t?e:this.add(t-e,"y")},isoWeekYear:function(t){var e=oe(this,1,4).year;return null==t?e:this.add(t-e,"y")},week:function(t){var e=this.localeData().week(this);return null==t?e:this.add(7*(t-e),"d")},isoWeek:function(t){var e=oe(this,1,4).week;return null==t?e:this.add(7*(t-e),"d")},weekday:function(t){var e=(this.day()+7-this.localeData()._week.dow)%7;return null==t?e:this.add(t-e,"d")},isoWeekday:function(t){return null==t?this.day()||7:this.day(this.day()%7?t:t-7)},isoWeeksInYear:function(){return O(this.year(),1,4)},weeksInYear:function(){var t=this.localeData()._week;return O(this.year(),t.dow,t.doy)},get:function(t){return t=w(t),this[t]()},set:function(t,e){return t=w(t),"function"==typeof this[t]&&this[t](e),this},locale:function(e){var n;return e===t?this._locale._abbr:(n=De.localeData(e),null!=n&&(this._locale=n),this)},lang:i("moment().lang() is deprecated. Use moment().localeData() instead.",function(e){return e===t?this.localeData():this.locale(e)}),localeData:function(){return this._locale},_dateTzOffset:function(){return 15*Math.round(this._d.getTimezoneOffset()/15)}}),De.fn.millisecond=De.fn.milliseconds=me("Milliseconds",!1),De.fn.second=De.fn.seconds=me("Seconds",!1),De.fn.minute=De.fn.minutes=me("Minutes",!1),De.fn.hour=De.fn.hours=me("Hours",!0),De.fn.date=me("Date",!0),De.fn.dates=i("dates accessor is deprecated. Use date instead.",me("Date",!0)),De.fn.year=me("FullYear",!0),De.fn.years=i("years accessor is deprecated. Use year instead.",me("FullYear",!0)),De.fn.days=De.fn.day,De.fn.months=De.fn.month,De.fn.weeks=De.fn.week,De.fn.isoWeeks=De.fn.isoWeek,De.fn.quarters=De.fn.quarter,De.fn.toJSON=De.fn.toISOString,h(De.duration.fn=l.prototype,{_bubble:function(){var t,e,n,a=this._milliseconds,s=this._days,i=this._months,r=this._data,o=0;r.milliseconds=a%1e3,t=m(a/1e3),r.seconds=t%60,e=m(t/60),r.minutes=e%60,n=m(e/60),r.hours=n%24,s+=m(n/24),o=m(_e(s)),s-=m(pe(o)),i+=m(s/30),s%=30,o+=m(i/12),i%=12,r.days=s,r.months=i,r.years=o},abs:function(){return this._milliseconds=Math.abs(this._milliseconds),this._days=Math.abs(this._days),this._months=Math.abs(this._months),this._data.milliseconds=Math.abs(this._data.milliseconds),this._data.seconds=Math.abs(this._data.seconds),this._data.minutes=Math.abs(this._data.minutes),this._data.hours=Math.abs(this._data.hours),this._data.months=Math.abs(this._data.months),this._data.years=Math.abs(this._data.years),this},weeks:function(){return m(this.days()/7)},valueOf:function(){return this._milliseconds+864e5*this._days+this._months%12*2592e6+31536e6*S(this._months/12)},humanize:function(t){var e=re(this,!t,this.localeData());return t&&(e=this.localeData().pastFuture(+this,e)),this.localeData().postformat(e)},add:function(t,e){var n=De.duration(t,e);return this._milliseconds+=n._milliseconds,this._days+=n._days,this._months+=n._months,this._bubble(),this},subtract:function(t,e){var n=De.duration(t,e);return this._milliseconds-=n._milliseconds,this._days-=n._days,this._months-=n._months,this._bubble(),this},get:function(t){return t=w(t),this[t.toLowerCase()+"s"]()},as:function(t){var e,n;if(t=w(t),"month"===t||"year"===t)return e=this._days+this._milliseconds/864e5,n=this._months+12*_e(e),"month"===t?n:n/12;switch(e=this._days+pe(this._months/12),t){case"week":return e/7+this._milliseconds/6048e5;case"day":return e+this._milliseconds/864e5;case"hour":return 24*e+this._milliseconds/36e5;case"minute":return 24*e*60+this._milliseconds/6e4;case"second":return 24*e*60*60+this._milliseconds/1e3;case"millisecond":return Math.floor(24*e*60*60*1e3)+this._milliseconds;default:throw new Error("Unknown unit "+t)}},lang:De.fn.lang,locale:De.fn.locale,toIsoString:i("toIsoString() is deprecated. Please use toISOString() instead (notice the capitals)",function(){return this.toISOString()}),toISOString:function(){var t=Math.abs(this.years()),e=Math.abs(this.months()),n=Math.abs(this.days()),a=Math.abs(this.hours()),s=Math.abs(this.minutes()),i=Math.abs(this.seconds()+this.milliseconds()/1e3);return this.asSeconds()?(this.asSeconds()<0?"-":"")+"P"+(t?t+"Y":"")+(e?e+"M":"")+(n?n+"D":"")+(a||s||i?"T":"")+(a?a+"H":"")+(s?s+"M":"")+(i?i+"S":""):"P0D"},localeData:function(){return this._locale}}),De.duration.fn.toString=De.duration.fn.toISOString;for(ge in rn)n(rn,ge)&&ye(ge.toLowerCase());return De.duration.fn.asMilliseconds=function(){return this.as("ms")},De.duration.fn.asSeconds=function(){return this.as("s")},De.duration.fn.asMinutes=function(){return this.as("m")},De.duration.fn.asHours=function(){return this.as("h")},De.duration.fn.asDays=function(){return this.as("d")},De.duration.fn.asWeeks=function(){return this.as("weeks")},De.duration.fn.asMonths=function(){return this.as("M")},De.duration.fn.asYears=function(){return this.as("y")},De.locale("en",{ordinal:function(t){var e=t%10,n=1===S(t%100/10)?"th":1===e?"st":2===e?"nd":3===e?"rd":"th";return t+n}}),De}.call(this),t.Utils.moment=n,t.datepicker}); \ No newline at end of file diff --git a/js/components/form-password.js b/js/components/form-password.js new file mode 100755 index 0000000..b0b0e60 --- /dev/null +++ b/js/components/form-password.js @@ -0,0 +1,67 @@ +/*! UIkit 2.26.4 | http://www.getuikit.com | (c) 2014 YOOtheme | MIT License */ +(function(addon) { + + var component; + + if (window.UIkit) { + component = addon(UIkit); + } + + if (typeof define == "function" && define.amd) { + define("uikit-form-password", ["uikit"], function(){ + return component || addon(UIkit); + }); + } + +})(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; +}); diff --git a/js/components/form-password.min.js b/js/components/form-password.min.js new file mode 100755 index 0000000..b358994 --- /dev/null +++ b/js/components/form-password.min.js @@ -0,0 +1,2 @@ +/*! UIkit 2.26.4 | http://www.getuikit.com | (c) 2014 YOOtheme | MIT License */ +!function(t){var i;window.UIkit&&(i=t(UIkit)),"function"==typeof define&&define.amd&&define("uikit-form-password",["uikit"],function(){return i||t(UIkit)})}(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}); \ No newline at end of file diff --git a/js/components/form-select.js b/js/components/form-select.js new file mode 100755 index 0000000..8f081fb --- /dev/null +++ b/js/components/form-select.js @@ -0,0 +1,77 @@ +/*! UIkit 2.26.4 | http://www.getuikit.com | (c) 2014 YOOtheme | MIT License */ +(function(addon) { + + var component; + + if (window.UIkit) { + component = addon(UIkit); + } + + if (typeof define == "function" && define.amd) { + define("uikit-form-select", ["uikit"], function(){ + return component || addon(UIkit); + }); + } + +})(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(); + })()); + + this.element.data("formSelect", this); + } + }); + + return UI.formSelect; +}); diff --git a/js/components/form-select.min.js b/js/components/form-select.min.js new file mode 100755 index 0000000..ee92f53 --- /dev/null +++ b/js/components/form-select.min.js @@ -0,0 +1,2 @@ +/*! UIkit 2.26.4 | http://www.getuikit.com | (c) 2014 YOOtheme | MIT License */ +!function(t){var e;window.UIkit&&(e=t(UIkit)),"function"==typeof define&&define.amd&&define("uikit-form-select",["uikit"],function(){return e||t(UIkit)})}(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],i=function(){try{"input"===t.options.target?t.target.val(e.options[e.selectedIndex].text):t.target.text(e.options[e.selectedIndex].text)}catch(n){}return t.element[t.select.val()?"addClass":"removeClass"](t.options.activeClass),i};return i()}()),this.element.data("formSelect",this)}}),t.formSelect}); \ No newline at end of file diff --git a/js/components/grid-parallax.js b/js/components/grid-parallax.js new file mode 100755 index 0000000..45b7a9e --- /dev/null +++ b/js/components/grid-parallax.js @@ -0,0 +1,168 @@ +/*! UIkit 2.26.4 | http://www.getuikit.com | (c) 2014 YOOtheme | MIT License */ +(function(addon) { + + var component; + + if (window.UIkit) { + component = addon(UIkit); + } + + if (typeof define == "function" && define.amd) { + define("uikit-grid-parallax", ["uikit"], function(){ + return component || addon(UIkit); + }); + } + +})(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= top) break; + } + + return column || 1; + } + + function percentageInViewport(element) { + + var top = element.offset().top, + height = element.outerHeight(), + scrolltop = UIkit.$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; + } +}); \ No newline at end of file diff --git a/js/components/grid-parallax.min.js b/js/components/grid-parallax.min.js new file mode 100755 index 0000000..fddc517 --- /dev/null +++ b/js/components/grid-parallax.min.js @@ -0,0 +1,2 @@ +/*! UIkit 2.26.4 | http://www.getuikit.com | (c) 2014 YOOtheme | MIT License */ +!function(t){var n;window.UIkit&&(n=t(UIkit)),"function"==typeof define&&define.amd&&define("uikit-grid-parallax",["uikit"],function(){return n||t(UIkit)})}(function(t){function n(t){for(var n=t.children(),i=n.filter(":visible:first"),e=i[0].offsetTop+i.outerHeight(),o=0;o=e);o++);return o||1}function i(t){var n,i,e,o=t.offset().top,r=t.outerHeight(),s=UIkit.$win.scrollTop(),a=window.innerHeight;return o>s+a?e=0:s>o+r?e=1:(a>o+r?e=(a>s?s:s-a)/(o+r):(n=s+a-o,i=Math.round(n/((a+r)/100)),e=i/100),a>o&&(e=e*s/(o+r-a))),e>1?1:e}var e=[],o=function(){requestAnimationFrame(function(){for(var t=0;t1&&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 -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.updateLayout(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.updateLayout(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); + } +}); diff --git a/js/components/grid.min.js b/js/components/grid.min.js new file mode 100755 index 0000000..3eeedfe --- /dev/null +++ b/js/components/grid.min.js @@ -0,0 +1,2 @@ +/*! UIkit 2.26.4 | http://www.getuikit.com | (c) 2014 YOOtheme | MIT License */ +!function(t){var i;window.UIkit&&(i=t(UIkit)),"function"==typeof define&&define.amd&&define("uikit-grid",["uikit"],function(){return i||t(UIkit)})}(function(t){"use strict";function i(){function t(t){if(t){if("string"==typeof u[t])return t;t=t.charAt(0).toUpperCase()+t.slice(1);for(var i,e=0,n=h.length;n>e;e++)if(i=h[e]+t,"string"==typeof u[i])return i}}function i(t){var i=parseFloat(t),e=-1===t.indexOf("%")&&!isNaN(i);return e&&i}function e(){}function n(){for(var t={width:0,height:0,innerWidth:0,innerHeight:0,outerWidth:0,outerHeight:0},i=0,e=f.length;e>i;i++){var n=f[i];t[n]=0}return t}function r(){if(!c){c=!0;var e=window.getComputedStyle;if(a=function(){var t=e?function(t){return e(t,null)}:function(t){return t.currentStyle};return function(i){var e=t(i);return e||l("Style returned "+e+". Are you running this code in a hidden iframe on Firefox? See http://bit.ly/getsizebug1"),e}}(),s=t("boxSizing")){var n=document.createElement("div");n.style.width="200px",n.style.padding="1px 2px 3px 4px",n.style.borderStyle="solid",n.style.borderWidth="1px 2px 3px 4px",n.style[s]="border-box";var r=document.body||document.documentElement;r.appendChild(n);var o=a(n);d=200===i(o.width),r.removeChild(n)}}}function o(t){if(r(),"string"==typeof t&&(t=document.querySelector(t)),t&&"object"==typeof t&&t.nodeType){var e=a(t);if("none"===e.display)return n();var o={};o.width=t.offsetWidth,o.height=t.offsetHeight;for(var h=o.isBorderBox=!(!s||!e[s]||"border-box"!==e[s]),u=0,l=f.length;l>u;u++){var c=f[u],p=e[c],g=parseFloat(p);o[c]=isNaN(g)?0:g}var m=o.paddingLeft+o.paddingRight,v=o.paddingTop+o.paddingBottom,b=o.marginLeft+o.marginRight,y=o.marginTop+o.marginBottom,k=o.borderLeftWidth+o.borderRightWidth,w=o.borderTopWidth+o.borderBottomWidth,x=h&&d,W=i(e.width);W!==!1&&(o.width=W+(x?0:m+k));var L=i(e.height);return L!==!1&&(o.height=L+(x?0:v+w)),o.innerWidth=o.width-(m+k),o.innerHeight=o.height-(v+w),o.outerWidth=o.width+b,o.outerHeight=o.height+y,o}}var a,s,d,h="Webkit Moz ms Ms O".split(" "),u=document.documentElement.style,l="undefined"==typeof console?e:function(t){console.error(t)},f=["paddingLeft","paddingRight","paddingTop","paddingBottom","marginLeft","marginRight","marginTop","marginBottom","borderLeftWidth","borderRightWidth","borderTopWidth","borderBottomWidth"],c=!1;return o}function e(t){return i()(t)}t.component("grid",{defaults:{colwidth:"auto",animation:!0,duration:300,gutter:0,controls:!1,filter:!1},boot:function(){t.ready(function(i){t.$("[data-uk-grid]",i).each(function(){var i=t.$(this);i.data("grid")||t.grid(i,t.Utils.options(i.attr("data-uk-grid")))})})},init:function(){var i=this,e=String(this.options.gutter).trim().split(" ");this.gutterv=parseInt(e[0],10),this.gutterh=parseInt(e[1]||e[0],10),this.element.css({position:"relative"}),this.controls=null,this.options.controls&&(this.controls=t.$(this.options.controls),this.controls.on("click","[data-uk-filter]",function(e){e.preventDefault(),i.filter(t.$(this).attr("data-uk-filter"))}),this.controls.on("click","[data-uk-sort]",function(e){e.preventDefault();var n=t.$(this).attr("data-uk-sort").split(":");i.sort(n[0],n[1])})),t.$win.on("load resize orientationchange",t.Utils.debounce(function(){i.currentfilter?i.filter(i.currentfilter):this.updateLayout()}.bind(this),100)),this.on("display.uk.check",function(){i.element.is(":visible")&&i.updateLayout()}),t.domObserve(this.element,function(){i.updateLayout()}),this.options.filter!==!1?this.filter(this.options.filter):this.updateLayout()},_prepareElements:function(){var t,i=this.element.children(":not([data-grid-prepared])");i.length&&(t={position:"absolute","box-sizing":"border-box",width:"auto"==this.options.colwidth?"":this.options.colwidth},this.options.gutter&&(t["padding-left"]=this.gutterh,t["padding-bottom"]=this.gutterv,this.element.css("margin-left",-1*this.gutterh)),i.attr("data-grid-prepared","true").css(t))},updateLayout:function(i){this._prepareElements(),i=i||this.element.children(":visible");var n,r,o,a,s,d,h,u,l=i,f=this.element.width()+2*this.gutterh+2,c=0,p=0,g=[];this.trigger("beforeupdate.uk.grid",[l]),l.each(function(){for(u=e(this),n=t.$(this),r=u.outerWidth,o=u.outerHeight,c=0,p=0,s=0,h=g.length;h>s;s++)a=g[s],c<=a.aX&&(c=a.aX),c+r>f&&(c=0),p<=a.aY&&(p=a.aY);g.push({ele:n,top:p,left:c,width:r,height:o,aY:p+o,aX:c+r})});var m,v=0;for(s=0,h=g.length;h>s;s++){for(a=g[s],p=0,d=0;s>d;d++)m=g[d],a.left-1&&(o=!0)})),r[o?"visible":"hidden"].push(e)}),r.hidden=t.$(r.hidden).map(function(){return this[0]}),r.visible=t.$(r.visible).map(function(){return this[0]}),r.hidden.attr("aria-hidden","true").filter(":visible").fadeOut(this.options.duration),r.visible.attr("aria-hidden","false").filter(":hidden").css("opacity",0).show(),e.updateLayout(r.visible),this.controls&&this.controls.length&&this.controls.find("[data-uk-filter]").removeClass("uk-active").filter('[data-uk-filter="'+i+'"]').addClass("uk-active")},sort:function(i,e){e=e||1,"string"==typeof e&&(e="desc"==e.toLowerCase()?-1:1);var n=this.element.children();n.sort(function(n,r){return n=t.$(n),r=t.$(r),(r.data(i)||"")<(n.data(i)||"")?e:-1*e}).appendTo(this.element),this.updateLayout(n.filter(":visible")),this.controls&&this.controls.length&&this.controls.find("[data-uk-sort]").removeClass("uk-active").filter('[data-uk-sort="'+i+":"+(-1==e?"desc":"asc")+'"]').addClass("uk-active")}})}); \ No newline at end of file diff --git a/js/components/htmleditor.js b/js/components/htmleditor.js new file mode 100755 index 0000000..68b5b52 --- /dev/null +++ b/js/components/htmleditor.js @@ -0,0 +1,679 @@ +/*! UIkit 2.26.4 | http://www.getuikit.com | (c) 2014 YOOtheme | MIT License */ +(function(addon) { + + var component; + + if (window.UIkit) { + component = addon(UIkit); + } + + if (typeof define == "function" && define.amd) { + define("uikit-htmleditor", ["uikit"], function(){ + return component || addon(UIkit); + }); + } + +})(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.$(''); + 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(''); + } + + } 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('
  • '+$this.buttons[button].label+'
  • '); + }); + + 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 = [ + '
    ', + '
    ', + '
      ', + '
      ', + '', + '
      ', + '
      ', + '
      ', + '
      ', + '
      ', + '
      ', + '
      ' + ].join(''); + + + UI.plugin('htmleditor', 'base', { + + init: function(editor) { + + editor.addButtons({ + + fullscreen: { + title : 'Fullscreen', + label : '' + }, + bold : { + title : 'Bold', + label : '' + }, + italic : { + title : 'Italic', + label : '' + }, + strike : { + title : 'Strikethrough', + label : '' + }, + blockquote : { + title : 'Blockquote', + label : '' + }, + link : { + title : 'Link', + label : '' + }, + image : { + title : 'Image', + label : '' + }, + listUl : { + title : 'Unordered List', + label : '' + }, + listOl : { + title : 'Ordered List', + label : '' + } + + }); + + addAction('bold', '$1'); + addAction('italic', '$1'); + addAction('strike', '$1'); + addAction('blockquote', '

      $1

      ', 'replaceLine'); + addAction('link', '$1'); + addAction('image', '$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('
    • '+cm.getLine(i)+'
    • ', { 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"+'', { 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; +}); diff --git a/js/components/htmleditor.min.js b/js/components/htmleditor.min.js new file mode 100755 index 0000000..a62f47e --- /dev/null +++ b/js/components/htmleditor.min.js @@ -0,0 +1,2 @@ +/*! UIkit 2.26.4 | http://www.getuikit.com | (c) 2014 YOOtheme | MIT License */ +!function(t){var e;window.UIkit&&(e=t(UIkit)),"function"==typeof define&&define.amd&&define("uikit-htmleditor",["uikit"],function(){return e||t(UIkit)})}(function(t){"use strict";var e=[];return t.component("htmleditor",{defaults:{iframe:!1,mode:"split",markdown:!1,autocomplete:!0,enablescripts:!1,height:500,maxsplitsize:1e3,codemirror:{mode:"htmlmixed",lineWrapping:!0,dragDrop:!1,autoCloseTags:!0,matchTags:!0,autoCloseBrackets:!0,matchBrackets:!0,indentUnit:4,indentWithTabs:!1,tabSize:4,hintOptions:{completionSingle:!1}},toolbar:["bold","italic","strike","link","image","blockquote","listUl","listOl"],lblPreview:"Preview",lblCodeview:"HTML",lblMarkedview:"Markdown"},boot:function(){t.ready(function(e){t.$("textarea[data-uk-htmleditor]",e).each(function(){var e=t.$(this);e.data("htmleditor")||t.htmleditor(e,t.Utils.options(e.attr("data-uk-htmleditor")))})})},init:function(){var i=this,o=t.components.htmleditor.template;this.CodeMirror=this.options.CodeMirror||CodeMirror,this.buttons={},o=o.replace(/\{:lblPreview}/g,this.options.lblPreview),o=o.replace(/\{:lblCodeview}/g,this.options.lblCodeview),this.htmleditor=t.$(o),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",t.Utils.debounce(function(){i.render()},150)),this.editor.on("change",function(){i.editor.save(),i.element.trigger("input")}),this.code.find(".CodeMirror").css("height",this.options.height),this.options.iframe?(this.iframe=t.$(''),this.preview.append(this.iframe),this.iframe[0].contentWindow.document.open(),this.iframe[0].contentWindow.document.close(),this.preview.container=t.$(this.iframe[0].contentWindow.document).find("body"),"string"==typeof this.options.iframe&&this.preview.container.parent().append('')):this.preview.container=this.preview,t.$win.on("resize load",t.Utils.debounce(function(){i.fit()},200));var n=this.iframe?this.preview.container:i.preview.parent(),r=this.code.find(".CodeMirror-sizer"),l=this.code.find(".CodeMirror-scroll").on("scroll",t.Utils.debounce(function(){if("tab"!=i.htmleditor.attr("data-mode")){var t=r.height()-l.height(),e=n[0].scrollHeight-(i.iframe?i.iframe.height():n.height()),o=e/t,s=l.scrollTop()*o;n.scrollTop(s)}},10));this.htmleditor.on("click",".uk-htmleditor-button-code, .uk-htmleditor-button-preview",function(e){e.preventDefault(),"tab"==i.htmleditor.attr("data-mode")&&(i.htmleditor.find(".uk-htmleditor-button-code, .uk-htmleditor-button-preview").removeClass("uk-active").filter(this).addClass("uk-active"),i.activetab=t.$(this).hasClass("uk-htmleditor-button-code")?"code":"preview",i.htmleditor.attr("data-active-tab",i.activetab),i.editor.refresh())}),this.htmleditor.on("click","a[data-htmleditor-button]",function(){i.code.is(":visible")&&i.trigger("action."+t.$(this).data("htmleditor-button"),[i.editor])}),this.preview.parent().css("height",this.code.height()),this.options.autocomplete&&this.CodeMirror.showHint&&this.CodeMirror.hint&&this.CodeMirror.hint.html&&this.editor.on("inputRead",t.Utils.debounce(function(){var t=i.editor.getDoc(),e=t.getCursor(),o=i.CodeMirror.innerMode(i.editor.getMode(),i.editor.getTokenAt(e).state).mode.name;if("xml"==o){var n=i.editor.getCursor(),r=i.editor.getTokenAt(n);("<"==r.string.charAt(0)||"attribute"==r.type)&&i.CodeMirror.showHint(i.editor,i.CodeMirror.hint.html,{completeSingle:!1})}},100)),this.debouncedRedraw=t.Utils.debounce(function(){i.redraw()},5),this.on("init.uk.component",function(){i.debouncedRedraw()}),this.element.attr("data-uk-check-display",1).on("display.uk.check",function(){this.htmleditor.is(":visible")&&this.fit()}.bind(this)),e.push(this)},addButton:function(t,e){this.buttons[t]=e},addButtons:function(e){t.$.extend(this.buttons,e)},replaceInPreview:function(t,e){function i(t){var e=o.getValue().substring(0,t).split("\n");return{line:e.length-1,ch:e[e.length-1].length}}var o=this.editor,n=[],r=o.getValue(),l=-1,s=0;return this.currentvalue=this.currentvalue.replace(t,function(){l=r.indexOf(arguments[0],++l);var t={matches:arguments,from:i(l),to:i(l+arguments[0].length),replace:function(e){o.replaceRange(e,t.from,t.to)},inRange:function(e){return e.line===t.from.line&&e.line===t.to.line?e.ch>=t.from.ch&&e.ch=t.from.ch||e.line>t.from.line&&e.line'+t.buttons[i].label+"")}}),this.toolbar.html(e.join("\n"))}},fit:function(){var t=this.options.mode;"split"==t&&this.htmleditor.width())<[^<]*)*<\/(script|style)>/gim,"")),this.currentvalue?(this.trigger("render",[this]),this.trigger("renderLate",[this]),this.preview.container.html(this.currentvalue),void 0):(this.element.val(""),this.preview.container.html(""),void 0)},addShortcut:function(e,i){var o={};return t.$.isArray(e)||(e=[e]),e.forEach(function(t){o[t]=i}),this.editor.addKeyMap(o),o},addShortcutAction:function(t,e){var i=this;this.addShortcut(e,function(){i.element.trigger("action."+t,[i.editor])})},replaceSelection:function(t){var e=this.editor.getSelection();if(!e.length){for(var i=this.editor.getCursor(),o=this.editor.getLine(i.line),n=i.ch,r=n;r','
      ','
        ','
        ','","
        ","
        ",'
        ','
        ','
        ',"
        ",""].join(""),t.plugin("htmleditor","base",{init:function(e){function i(t,i,o){e.on("action."+t,function(){"html"==e.getCursorMode()&&e["replaceLine"==o?"replaceLine":"replaceSelection"](i)})}e.addButtons({fullscreen:{title:"Fullscreen",label:''},bold:{title:"Bold",label:''},italic:{title:"Italic",label:''},strike:{title:"Strikethrough",label:''},blockquote:{title:"Blockquote",label:''},link:{title:"Link",label:''},image:{title:"Image",label:''},listUl:{title:"Unordered List",label:''},listOl:{title:"Ordered List",label:''}}),i("bold","$1"),i("italic","$1"),i("strike","$1"),i("blockquote","

        $1

        ","replaceLine"),i("link",'$1'),i("image",'$1');var o=function(t){if("html"==e.getCursorMode()){t=t||"ul";for(var i=e.editor,o=i.getDoc(),n=o.getCursor(!0),r=o.getCursor(!1),l=CodeMirror.innerMode(i.getMode(),i.getTokenAt(i.getCursor()).state),s=l&&l.state&&l.state.context&&-1!=["ul","ol"].indexOf(l.state.context.tagName),a=n.line;a"+i.getLine(a)+"",{line:a,ch:0},{line:a,ch:i.getLine(a).length});s?i.setCursor({line:r.line,ch:i.getLine(r.line).length}):(i.replaceRange("<"+t+">\n"+i.getLine(n.line),{line:n.line,ch:0},{line:n.line,ch:i.getLine(n.line).length}),i.replaceRange(i.getLine(r.line+1)+"\n",{line:r.line+1,ch:0},{line:r.line+1,ch:i.getLine(r.line+1).length}),i.setCursor({line:r.line+1,ch:i.getLine(r.line+1).length})),i.focus()}};e.on("action.listUl",function(){o("ul")}),e.on("action.listOl",function(){o("ol")}),e.htmleditor.on("click",'a[data-htmleditor-button="fullscreen"]',function(){e.htmleditor.toggleClass("uk-htmleditor-fullscreen");var i=e.editor.getWrapperElement();if(e.htmleditor.hasClass("uk-htmleditor-fullscreen")){var o=!1,n=e.htmleditor.parents().each(function(){"fixed"!=t.$(this).css("position")||t.$(this).is("html")||(o=t.$(this))});if(e.htmleditor.data("fixedParents",!1),o){var r=[];o=o.parent().find(n).each(function(){"none"!=t.$(this).css("transform")&&r.push(t.$(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"}))}),e.htmleditor.data("fixedParents",r)}e.editor.state.fullScreenRestore={scrollTop:window.pageYOffset,scrollLeft:window.pageXOffset,width:i.style.width,height:i.style.height},i.style.width="",i.style.height=e.content.height()+"px",document.documentElement.style.overflow="hidden"}else{document.documentElement.style.overflow="";var l=e.editor.state.fullScreenRestore;i.style.width=l.width,i.style.height=l.height,window.scrollTo(l.scrollLeft,l.scrollTop),e.htmleditor.data("fixedParents")&&e.htmleditor.data("fixedParents").forEach(function(t){t.css(t.data("transform-reset"))})}setTimeout(function(){e.fit(),t.$win.trigger("resize")},50)}),e.addShortcut(["Ctrl-S","Cmd-S"],function(){e.element.trigger("htmleditor-save",[e])}),e.addShortcutAction("bold",["Ctrl-B","Cmd-B"])}}),t.plugin("htmleditor","markdown",{init:function(e){function i(){e.editor.setOption("mode","gfm"),e.htmleditor.find(".uk-htmleditor-button-code a").html(e.options.lblMarkedview)}function o(t,i,o){e.on("action."+t,function(){"markdown"==e.getCursorMode()&&e["replaceLine"==o?"replaceLine":"replaceSelection"](i)})}var n=e.options.mdparser||window.marked||null;n&&(e.options.markdown&&i(),o("bold","**$1**"),o("italic","*$1*"),o("strike","~~$1~~"),o("blockquote","> $1","replaceLine"),o("link","[$1](http://)"),o("image","![$1](http://)"),e.on("action.listUl",function(){if("markdown"==e.getCursorMode()){for(var t=e.editor,i=t.getDoc().getCursor(!0),o=t.getDoc().getCursor(!1),n=i.line;n0){var r,l=t.getLine(i.line-1);(r=l.match(/^(\d+)\./))&&(n=Number(r[1])+1)}for(var s=i.line;s 1) { + + content = [ + content, + '', + '' + ].join(''); + } + + // calculate width + var tmp = UI.$('
         
        ').css({ + 'opacity' : 0, + 'position' : 'absolute', + 'top' : 0, + 'left' : 0, + 'width' : '100%', + 'max-width' : $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('
        '+data.title+'
        '); + 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" : '', + "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': '', + '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': '', + '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 : 'http://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': '', + '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.$('').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); + } + } + }); + } + }); + + + UIkit.plugin("lightbox", "iframe", { + + init: function (lightbox) { + + lightbox.on("showitem.uk.lightbox", function (e, data) { + + var resolve = function (source, width, height) { + + data.meta = { + 'content': '', + '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.$([ + '
        ', + '
        ', + '', + '
        ', + '
        ', + '
        ', + '
        ' + ].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; +}); diff --git a/js/components/lightbox.min.js b/js/components/lightbox.min.js new file mode 100755 index 0000000..5075244 --- /dev/null +++ b/js/components/lightbox.min.js @@ -0,0 +1,2 @@ +/*! UIkit 2.26.4 | http://www.getuikit.com | (c) 2014 YOOtheme | MIT License */ +!function(i){var t;window.UIkit&&(t=i(UIkit)),"function"==typeof define&&define.amd&&define("uikit-lightbox",["uikit"],function(){return t||i(UIkit)})}(function(i){"use strict";function t(t){if(e)return e.lightbox=t,e;e=i.$(['
        ','
        ','','
        ','
        ',"
        ","
        "].join("")).appendTo("body"),e.dialog=e.find(".uk-modal-dialog:first"),e.content=e.find(".uk-lightbox-content:first"),e.loader=e.find(".uk-modal-spinner:first"),e.closer=e.find(".uk-close.uk-close-alt"),e.modal=i.modal(e,{modal:!1}),e.on("swipeRight swipeLeft",function(i){e.lightbox["swipeLeft"==i.type?"next":"previous"]()}).on("click","[data-lightbox-previous], [data-lightbox-next]",function(t){t.preventDefault(),e.lightbox[i.$(this).is("[data-lightbox-next]")?"next":"previous"]()}),e.on("hide.uk.modal",function(){e.content.html("")});var o={w:window.innerWidth,h:window.innerHeight};return i.$win.on("load resize orientationchange",i.Utils.debounce(function(){o.w!==window.innerWidth&&e.is(":visible")&&!i.Utils.isFullscreen()&&e.lightbox.fitSize(),o={w:window.innerWidth,h:window.innerHeight}},100)),e.lightbox=t,e}var e,o={};return i.component("lightbox",{defaults:{allowfullscreen:!0,duration:400,group:!1,keyboard:!0},index:0,items:!1,boot:function(){i.$html.on("click","[data-uk-lightbox]",function(t){t.preventDefault();var e=i.$(this);e.data("lightbox")||i.lightbox(e,i.Utils.options(e.attr("data-uk-lightbox"))),e.data("lightbox").show(e)}),i.$doc.on("keyup",function(i){if(e&&e.is(":visible")&&e.lightbox.options.keyboard)switch(i.preventDefault(),i.keyCode){case 37:e.lightbox.previous();break;case 39:e.lightbox.next()}})},init:function(){var t=[];if(this.index=0,this.siblings=[],this.element&&this.element.length){var e=this.options.group?i.$(['[data-uk-lightbox*="'+this.options.group+'"]',"[data-uk-lightbox*='"+this.options.group+"']"].join(",")):this.element;e.each(function(){var e=i.$(this);t.push({source:e.attr("href"),title:e.attr("data-title")||e.attr("title"),type:e.attr("data-lightbox-type")||"auto",link:e})}),this.index=e.index(this.element),this.siblings=t}else this.options.group&&this.options.group.length&&(this.siblings=this.options.group);this.trigger("lightbox-init",[this])},show:function(e){this.modal=t(this),this.modal.dialog.stop(),this.modal.content.stop();var o,n,s=this,h=i.$.Deferred();e=e||0,"object"==typeof e&&this.siblings.forEach(function(i,t){e[0]===i.link[0]&&(e=t)}),0>e?e=this.siblings.length-e:this.siblings[e]||(e=0),n=this.siblings[e],o={lightbox:s,source:n.source,type:n.type,index:e,promise:h,title:n.title,item:n,meta:{content:"",width:null,height:null}},this.index=e,this.modal.content.empty(),this.modal.is(":visible")||(this.modal.content.css({width:"",height:""}).empty(),this.modal.modal.show()),this.modal.loader.removeClass("uk-hidden"),h.promise().done(function(){s.data=o,s.fitSize(o)}).fail(function(){o.meta.content='
        Loading resource failed!
        ',o.meta.width=400,o.meta.height=300,s.data=o,s.fitSize(o)}),s.trigger("showitem.uk.lightbox",[o])},fitSize:function(){var t=this,e=this.data,o=this.modal.dialog.outerWidth()-this.modal.dialog.width(),n=parseInt(this.modal.dialog.css("margin-top"),10),s=parseInt(this.modal.dialog.css("margin-bottom"),10),h=n+s,a=e.meta.content,l=t.options.duration;this.siblings.length>1&&(a=[a,'',''].join(""));var d,r,u=i.$("
         
        ").css({opacity:0,position:"absolute",top:0,left:0,width:"100%","max-width":t.modal.dialog.css("max-width"),padding:t.modal.dialog.css("padding"),margin:t.modal.dialog.css("margin")}),c=e.meta.width,g=e.meta.height;u.appendTo("body").width(),d=u.width(),r=window.innerHeight-h,u.remove(),this.modal.dialog.find(".uk-modal-caption").remove(),e.title&&(this.modal.dialog.append('
        '+e.title+"
        "),r-=this.modal.dialog.find(".uk-modal-caption").outerHeight()),dr&&(g=Math.floor(r),c=Math.ceil(e.meta.width*(r/e.meta.height))),this.modal.content.css("opacity",0).width(c).html(a),"iframe"==e.type&&this.modal.content.find("iframe:first").height(g);var m=g+o,p=Math.floor(window.innerHeight/2-m/2)-h;0>p&&(p=0),this.modal.closer.addClass("uk-hidden"),t.modal.data("mwidth")==c&&t.modal.data("mheight")==g&&(l=0),this.modal.dialog.animate({width:c+o,height:g+o,top:p},l,"swing",function(){t.modal.loader.addClass("uk-hidden"),t.modal.content.css({width:""}).animate({opacity:1},function(){t.modal.closer.removeClass("uk-hidden")}),t.modal.data({mwidth:c,mheight:g})})},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)}}),i.plugin("lightbox","image",{init:function(i){i.on("showitem.uk.lightbox",function(i,t){if("image"==t.type||t.source&&t.source.match(/\.(jpg|jpeg|png|gif|svg)$/i)){var e=function(i,e,o){t.meta={content:'',width:e,height:o},t.type="image",t.promise.resolve()};if(o[t.source])e(t.source,o[t.source].width,o[t.source].height);else{var n=new Image;n.onerror=function(){t.promise.reject("Loading image failed")},n.onload=function(){o[t.source]={width:n.width,height:n.height},e(t.source,o[t.source].width,o[t.source].height)},n.src=t.source}}})}}),i.plugin("lightbox","youtube",{init:function(i){var t=/(\/\/.*?youtube\.[a-z]+)\/watch\?v=([^&]+)&?(.*)/,n=/youtu\.be\/(.*)/;i.on("showitem.uk.lightbox",function(i,s){var h,a,l=function(i,t,o){s.meta={content:'",width:t,height:o},s.type="iframe",s.promise.resolve()};if((a=s.source.match(t))&&(h=a[2]),(a=s.source.match(n))&&(h=a[1]),h){if(o[h])l(h,o[h].width,o[h].height);else{var d=new Image,r=!1;d.onerror=function(){o[h]={width:640,height:320},l(h,o[h].width,o[h].height)},d.onload=function(){120==d.width&&90==d.height?r?(o[h]={width:640,height:320},l(h,o[h].width,o[h].height)):(r=!0,d.src="//img.youtube.com/vi/"+h+"/0.jpg"):(o[h]={width:d.width,height:d.height},l(h,d.width,d.height))},d.src="//img.youtube.com/vi/"+h+"/maxresdefault.jpg"}i.stopImmediatePropagation()}})}}),i.plugin("lightbox","vimeo",{init:function(t){var n,s=/(\/\/.*?)vimeo\.[a-z]+\/([0-9]+).*?/;t.on("showitem.uk.lightbox",function(t,h){var a,l=function(i,t,o){h.meta={content:'",width:t,height:o},h.type="iframe",h.promise.resolve()};(n=h.source.match(s))&&(a=n[2],o[a]?l(a,o[a].width,o[a].height):i.$.ajax({type:"GET",url:"http://vimeo.com/api/oembed.json?url="+encodeURI(h.source),jsonp:"callback",dataType:"jsonp",success:function(i){o[a]={width:i.width,height:i.height},l(a,o[a].width,o[a].height)}}),t.stopImmediatePropagation())})}}),i.plugin("lightbox","video",{init:function(t){t.on("showitem.uk.lightbox",function(t,e){var n=function(i,t,o){e.meta={content:'',width:t,height:o},e.type="video",e.promise.resolve()};if("video"==e.type||e.source.match(/\.(mp4|webm|ogv)$/i))if(o[e.source])n(e.source,o[e.source].width,o[e.source].height);else var s=i.$('').attr("src",e.source).appendTo("body"),h=setInterval(function(){s[0].videoWidth&&(clearInterval(h),o[e.source]={width:s[0].videoWidth,height:s[0].videoHeight},n(e.source,o[e.source].width,o[e.source].height),s.remove())},20)})}}),UIkit.plugin("lightbox","iframe",{init:function(i){i.on("showitem.uk.lightbox",function(t,o){var n=function(i,t,n){o.meta={content:'",width:t,height:n},o.type="iframe",o.promise.resolve()};("iframe"===o.type||o.source.match(/\.(html|php)$/))&&n(o.source,i.options.width||800,i.options.height||600)})}}),i.lightbox.create=function(t,e){if(t){var o,n=[];return t.forEach(function(t){n.push(i.$.extend({source:"",title:"",type:"auto",link:!1},"string"==typeof t?{source:t}:t))}),o=i.lightbox(i.$.extend({},e,{group:n}))}},i.lightbox}); \ No newline at end of file diff --git a/js/components/nestable.js b/js/components/nestable.js new file mode 100755 index 0000000..573345d --- /dev/null +++ b/js/components/nestable.js @@ -0,0 +1,653 @@ +/*! UIkit 2.26.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.UIkit) { + component = addon(UIkit); + } + + if (typeof define == "function" && define.amd) { + define("uikit-nestable", ["uikit"], function(){ + return component || addon(UIkit); + }); + } + +})(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').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.$('
          ').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; +}); diff --git a/js/components/nestable.min.js b/js/components/nestable.min.js new file mode 100755 index 0000000..e0d4da2 --- /dev/null +++ b/js/components/nestable.min.js @@ -0,0 +1,2 @@ +/*! UIkit 2.26.4 | http://www.getuikit.com | (c) 2014 YOOtheme | MIT License */ +!function(t){var s;window.UIkit&&(s=t(UIkit)),"function"==typeof define&&define.amd&&define("uikit-nestable",["uikit"],function(){return s||t(UIkit)})}(function(t){"use strict";var s,e="ontouchstart"in window,i=t.$html,l=[],a=t.$win,n=e?"touchstart":"mousedown",o=e?"touchmove":"mousemove",h=e?"touchend":"mouseup",r=e?"touchcancel":"mouseup";return t.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:!1,maxDepth:10,threshold:20,idlethreshold:10},boot:function(){t.$html.on("mousemove touchmove",function(){if(s){var e=s.offset().top;ewindow.innerHeight+t.$win.scrollTop()&&t.$win.scrollTop(t.$win.scrollTop()+Math.ceil(s.height()/2))}}),t.ready(function(s){t.$("[data-uk-nestable]",s).each(function(){var s=t.$(this);s.data("nestable")||t.nestable(s,t.Utils.options(s.attr("data-uk-nestable")))})})},init:function(){var i=this;Object.keys(this.options).forEach(function(t){-1!=String(t).indexOf("Class")&&(i.options["_"+t]="."+i.options[t])}),this.find(this.options._listItemClass).find(">ul").addClass(this.options.listClass),this.checkEmptyList(),this.reset(),this.element.data("nestable-group",this.options.group||t.Utils.uid("nestable-group")),this.find(this.options._listItemClass).each(function(){i.setParent(t.$(this))}),this.on("click","[data-nestable-action]",function(s){if(!i.dragEl&&(e||0===s.button)){s.preventDefault();var l=t.$(s.currentTarget),a=l.data("nestableAction"),n=l.closest(i.options._listItemClass);"collapse"===a&&i.collapseItem(n),"expand"===a&&i.expandItem(n),"toggle"===a&&i.toggleItem(n)}});var l=function(s){var l=t.$(s.target),a=l.is("a[href]")?l:l.parents("a[href]");s.target!==i.element[0]&&(l.is(i.options._noDragClass)||l.closest(i.options._noDragClass).length||l.is("[data-nestable-action]")||l.closest("[data-nestable-action]").length||(i.options.handleClass&&!l.hasClass(i.options.handleClass)&&i.options.handleClass&&(l=l.closest(i.options._handleClass)),!l.length||i.dragEl||!e&&0!==s.button||e&&1!==s.touches.length||(s.originalEvent&&s.originalEvent.touches&&(s=evt.originalEvent.touches[0]),i.delayMove=function(t){a=!1,t.preventDefault(),i.dragStart(s),i.trigger("start.uk.nestable",[i]),i.delayMove=!1},i.delayMove.x=parseInt(s.pageX,10),i.delayMove.y=parseInt(s.pageY,10),i.delayMove.threshold=i.options.idlethreshold,a.length&&"touchend"==h&&i.one(h,function(){a&&a.attr("href").trim()&&(location.href=a.attr("href"))}),s.preventDefault())))},d=function(t){t.originalEvent&&t.originalEvent.touches&&(t=t.originalEvent.touches[0]),i.delayMove&&(Math.abs(t.pageX-i.delayMove.x)>i.delayMove.threshold||Math.abs(t.pageY-i.delayMove.y)>i.delayMove.threshold)&&(window.getSelection().toString()?i.delayMove=!1:i.delayMove(t)),i.dragEl&&(t.preventDefault(),i.dragMove(t),i.trigger("move.uk.nestable",[i]))},p=function(t){i.dragEl&&(t.preventDefault(),i.dragStop(e?t.touches[0]:t)),s=!1,i.delayMove=!1};e?(this.element[0].addEventListener(n,l,!1),window.addEventListener(o,d,!1),window.addEventListener(h,p,!1),window.addEventListener(r,p,!1)):(this.on(n,l),a.on(o,d),a.on(h,p))},serialize:function(){var s,e=0,i=this,l=function(s,e){var a=[],n=s.children(i.options._listItemClass);return n.each(function(){for(var s,n,o,h=t.$(this),r={},d=h.children(i.options._listClass),p=0;p
        ").addClass(this.options.listClass+" "+this.options.dragClass).append(n.clone()),this.dragEl.css("width",n.width()),this.placeEl.addClass(this.options.placeholderClass),s=this.dragEl,this.tmpDragOnSiblings=[n[0].previousSibling,n[0].nextSibling],t.$body.append(this.dragEl),this.dragEl.css({left:o.left,top:o.top});var h,r,d=this.dragEl.find(this.options._listItemClass);for(h=0;hthis.dragDepth&&(this.dragDepth=r);i.addClass(this.options.movingClass)},dragStop:function(){var s=t.$(this.placeEl),e=this.placeEl.parents(this.options._listBaseClass+":first");this.placeEl.removeClass(this.options.placeholderClass),this.dragEl.remove(),this.element[0]!==e[0]?(e.trigger("change.uk.nestable",[e.data("nestable"),s,"added"]),this.element.trigger("change.uk.nestable",[this,s,"removed"])):this.element.trigger("change.uk.nestable",[this,s,"moved"]),this.trigger("stop.uk.nestable",[this,s]),this.reset(),i.removeClass(this.options.movingClass)},dragMove:function(s){var e,i,a,n,o,h=this.options,r=this.mouse,d=this.dragRootEl?this.dragRootEl.data("nestable").options.maxDepth:h.maxDepth;this.dragEl.css({left:s.pageX-r.offsetX,top:s.pageY-r.offsetY}),r.lastX=r.nowX,r.lastY=r.nowY,r.nowX=s.pageX,r.nowY=s.pageY,r.distX=r.nowX-r.lastX,r.distY=r.nowY-r.lastY,r.lastDirX=r.dirX,r.lastDirY=r.dirY,r.dirX=0===r.distX?0:r.distX>0?1:-1,r.dirY=0===r.distY?0:r.distY>0?1:-1;var p=Math.abs(r.distX)>Math.abs(r.distY)?1:0;if(!r.moving)return r.dirAx=p,r.moving=!0,void 0;if(r.dirAx!==p?(r.distAxX=0,r.distAxY=0):(r.distAxX+=Math.abs(r.distX),0!==r.dirX&&r.dirX!==r.lastDirX&&(r.distAxX=0),r.distAxY+=Math.abs(r.distY),0!==r.dirY&&r.dirY!==r.lastDirY&&(r.distAxY=0)),r.dirAx=p,r.dirAx&&r.distAxX>=h.threshold&&(r.distAxX=0,a=this.placeEl.prev("li"),r.distX>0&&a.length&&!a.hasClass(h.collapsedClass)&&!a.hasClass(h.noChildrenClass)&&(e=a.find(h._listClass).last(),o=this.placeEl.parents(h._listClass+","+h._listBaseClass).length,o+this.dragDepth<=d&&(e.length?(e=a.children(h._listClass).last(),e.append(this.placeEl)):(e=t.$("
          ").addClass(h.listClass),e.append(this.placeEl),a.append(e),this.setParent(a)))),r.distX<0&&(n=this.placeEl.next(h._listItemClass),!n.length))){var c=this.placeEl.closest([h._listBaseClass,h._listClass].join(",")),g=c.closest(h._listItemClass);g.length&&(g.after(this.placeEl),c.children().length||this.unsetParent(g))}var u=!1,f=s.pageX-(window.pageXOffset||document.scrollLeft||0),m=s.pageY-(window.pageYOffset||document.documentElement.scrollTop);if(this.pointEl=t.$(document.elementFromPoint(f,m)),h.handleClass&&this.pointEl.hasClass(h.handleClass))this.pointEl=this.pointEl.closest(h._listItemClass);else{var C=this.pointEl.closest(h._listItemClass);C.length&&(this.pointEl=C)}if(!this.placeEl.find(this.pointEl).length){if(this.pointEl.data("nestable")&&!this.pointEl.children().length)u=!0,this.checkEmptyList(this.pointEl);else if(!this.pointEl.length||!this.pointEl.hasClass(h.listItemClass))return;var v=this.element,E=this.pointEl.closest(this.options._listBaseClass),b=v[0]!=E[0];if(!r.dirAx||b||u){if(b&&h.group!==E.data("nestable-group"))return;if(l.push(v),o=this.dragDepth-1+this.pointEl.parents(h._listClass+","+h._listBaseClass).length,o>d)return;var X=s.pageY', + '', + '
          ', + '' + + ].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.$('
          ').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, "margin-top": -1*this.element.outerHeight(), "margin-bottom":0}).animate({"opacity":1, "margin-top": 0, "margin-bottom":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, "margin-top": -1* this.element.outerHeight(), "margin-bottom":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; +}); diff --git a/js/components/notify.min.js b/js/components/notify.min.js new file mode 100755 index 0000000..6c24ebb --- /dev/null +++ b/js/components/notify.min.js @@ -0,0 +1,2 @@ +/*! UIkit 2.26.4 | http://www.getuikit.com | (c) 2014 YOOtheme | MIT License */ +!function(t){var e;window.UIkit&&(e=t(UIkit)),"function"==typeof define&&define.amd&&define("uikit-notify",["uikit"],function(){return e||t(UIkit)})}(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.$(['
          ','',"
          ","
          "].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.$('
          ').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,"margin-top":-1*this.element.outerHeight(),"margin-bottom":0}).animate({opacity:1,"margin-top":0,"margin-bottom":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,"margin-top":-1*this.element.outerHeight(),"margin-bottom":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}); \ No newline at end of file diff --git a/js/components/pagination.js b/js/components/pagination.js new file mode 100755 index 0000000..f5a8478 --- /dev/null +++ b/js/components/pagination.js @@ -0,0 +1,147 @@ +/*! UIkit 2.26.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.UIkit) { + component = addon(UIkit); + } + + if (typeof define == "function" && define.amd) { + define("uikit-pagination", ["uikit"], function(){ + return component || addon(UIkit); + }); + } + +})(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('
        • ...
        • '); + } 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('
        • ...
        • '); + } 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) ? '
        • ' + (options.text) + '
        • ' : '
        • '+options.text+'
        • '; + + this.element.append(item); + } + }); + + return UI.pagination; +}); diff --git a/js/components/pagination.min.js b/js/components/pagination.min.js new file mode 100755 index 0000000..7361066 --- /dev/null +++ b/js/components/pagination.min.js @@ -0,0 +1,2 @@ +/*! UIkit 2.26.4 | http://www.getuikit.com | (c) 2014 YOOtheme | MIT License */ +!function(t){var e;window.UIkit&&(e=t(UIkit)),"function"==typeof define&&define.amd&&define("uikit-pagination",["uikit"],function(){return e||t(UIkit)})}(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-e.edges==1&&this._append(e.edges)}for(t=i.start;t0){this.pages-e.edges>i.end&&this.pages-e.edges-i.end!=1?this.element.append("
        • ...
        • "):this.pages-e.edges-i.end==1&&this._append(i.end++);var a=Math.max(this.pages-e.edges,i.end);for(t=a;te?0:e'+a.text+"":'
        • '+a.text+"
        • ",this.element.append(s)}}),t.pagination}); \ No newline at end of file diff --git a/js/components/parallax.js b/js/components/parallax.js new file mode 100755 index 0000000..e706abb --- /dev/null +++ b/js/components/parallax.js @@ -0,0 +1,462 @@ +/*! UIkit 2.26.4 | http://www.getuikit.com | (c) 2014 YOOtheme | MIT License */ +(function(addon) { + + var component; + + if (window.UIkit) { + component = addon(UIkit); + } + + if (typeof define == "function" && define.amd) { + define("uikit-parallax", ["uikit"], function(){ + return component || addon(UIkit); + }); + } + +})(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({'background-size': 'cover', 'background-repeat': '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({'background-size': '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({'background-size': (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 + * 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; +}); diff --git a/js/components/parallax.min.js b/js/components/parallax.min.js new file mode 100755 index 0000000..aa290a1 --- /dev/null +++ b/js/components/parallax.min.js @@ -0,0 +1,2 @@ +/*! UIkit 2.26.4 | http://www.getuikit.com | (c) 2014 YOOtheme | MIT License */ +!function(e){var t;window.UIkit&&(t=e(UIkit)),"function"==typeof define&&define.amd&&define("uikit-parallax",["uikit"],function(){return t||e(UIkit)})}(function(e){"use strict";function t(t,a,r){var i,n,s,o,c,l,p,f=new Image;return n=t.element.css({"background-size":"cover","background-repeat":"no-repeat"}),i=n.css("background-image").replace(/^url\(/g,"").replace(/\)$/g,"").replace(/("|')/g,""),o=function(){var e=n.innerWidth(),i=n.innerHeight(),o="bg"==a?r.diff:r.diff/100*i;return i+=o,e+=Math.ceil(o*c),e-oe/c?(l=Math.ceil(i*c),p=i,i>window.innerHeight&&(l=1.2*l,p=1.2*p)):(l=e,p=Math.ceil(e/c)),n.css({"background-size":l+"px "+p+"px"}).data("bgsize",{w:l,h:p}),void 0)},f.onerror=function(){},f.onload=function(){s={w:f.width,h:f.height},c=f.width/f.height,e.$win.on("load resize orientationchange",e.Utils.debounce(function(){o()},50)),o()},f.src=i,!0}function a(e,t,a){return e=i(e),t=i(t),a=a||0,r(e,t,a)}function r(e,t,a){var r="rgba("+parseInt(e[0]+a*(t[0]-e[0]),10)+","+parseInt(e[1]+a*(t[1]-e[1]),10)+","+parseInt(e[2]+a*(t[2]-e[2]),10)+","+(e&&t?parseFloat(e[3]+a*(t[3]-e[3])):1);return r+=")"}function i(e){var t,a;return a=(t=/#([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})/.exec(e))?[parseInt(t[1],16),parseInt(t[2],16),parseInt(t[3],16),1]:(t=/#([0-9a-fA-F])([0-9a-fA-F])([0-9a-fA-F])/.exec(e))?[17*parseInt(t[1],16),17*parseInt(t[2],16),17*parseInt(t[3],16),1]:(t=/rgb\(\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*\)/.exec(e))?[parseInt(t[1]),parseInt(t[2]),parseInt(t[3]),1]:(t=/rgba\(\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*,\s*([0-9\.]*)\s*\)/.exec(e))?[parseInt(t[1],10),parseInt(t[2],10),parseInt(t[3],10),parseFloat(t[4])]:p[e]||[255,255,255,0]}var n=[],s=!1,o=0,c=window.innerHeight,l=function(){o=e.$win.scrollTop(),window.requestAnimationFrame(function(){for(var e=0;e0&&"none"!==e}(),e.$doc.on("scrolling.uk.document",l),e.$win.on("load resize orientationchange",e.Utils.debounce(function(){c=window.innerHeight,l()},50)),e.ready(function(t){e.$("[data-uk-parallax]",t).each(function(){var t=e.$(this);t.data("parallax")||e.parallax(t,e.Utils.options(t.attr("data-uk-parallax")))})})},init:function(){this.base=this.options.target?e.$(this.options.target):this.element,this.props={},this.velocity=this.options.velocity||1;var t=["target","velocity","viewport","plugins","media"];Object.keys(this.options).forEach(function(e){if(-1===t.indexOf(e)){var a,r,i,n,s=String(this.options[e]).split(",");e.match(/color/i)?(a=s[1]?s[0]:this._getStartValue(e),r=s[1]?s[1]:s[0],a||(a="rgba(255,255,255,0)")):(a=parseFloat(s[1]?s[0]:this._getStartValue(e)),r=parseFloat(s[1]?s[1]:s[0]),n=r>a?r-a:a-r,i=r>a?1:-1),this.props[e]={start:a,end:r,dir:i,diff:n}}}.bind(this)),n.push(this)},process:function(){if(this.options.media)switch(typeof this.options.media){case"number":if(window.innerWidtho+c?a=0:o>r+i?a=1:c>r+i?a=(c>o?o:o-c)/(r+i):(e=o+c-r,t=Math.round(e/((c+i)/100)),a=t/100),a},update:function(e){var r,i,n={transform:"",filter:""},o=e*(1-(this.velocity-this.velocity*e));0>o&&(o=0),o>1&&(o=1),(void 0===this._percent||this._percent!=o)&&(Object.keys(this.props).forEach(function(c){switch(r=this.props[c],0===e?i=r.start:1===e?i=r.end:void 0!==r.diff&&(i=r.start+r.diff*o*r.dir),"bg"!=c&&"bgp"!=c||this._bgcover||(this._bgcover=t(this,c,r)),c){case"x":n.transform+=s?" translate3d("+i+"px, 0, 0)":" translateX("+i+"px)";break;case"xp":n.transform+=s?" translate3d("+i+"%, 0, 0)":" translateX("+i+"%)";break;case"y":n.transform+=s?" translate3d(0, "+i+"px, 0)":" translateY("+i+"px)";break;case"yp":n.transform+=s?" translate3d(0, "+i+"%, 0)":" translateY("+i+"%)";break;case"rotate":n.transform+=" rotate("+i+"deg)";break;case"scale":n.transform+=" scale("+i+")";break;case"bg":n["background-position"]="50% "+i+"px";break;case"bgp":n["background-position"]="50% "+i+"%";break;case"color":case"background-color":case"border-color":n[c]=a(r.start,r.end,o);break;case"blur":n.filter+=" blur("+i+"px)";break;case"hue":n.filter+=" hue-rotate("+i+"deg)";break;case"grayscale":n.filter+=" grayscale("+i+"%)";break;case"invert":n.filter+=" invert("+i+"%)";break;case"fopacity":n.filter+=" opacity("+i+"%)";break;case"saturate":n.filter+=" saturate("+i+"%)";break;case"sepia":n.filter+=" sepia("+i+"%)";break;default:n[c]=i}}.bind(this)),n.filter&&(n["-webkit-filter"]=n.filter),this.element.css(n),this._percent=o)},_getStartValue:function(e){var t=0;switch(e){case"scale":t=1;break;default:t=this.element.css(e)}return t||0}});var p={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]};return e.parallax}); \ No newline at end of file diff --git a/js/components/search.js b/js/components/search.js new file mode 100755 index 0000000..6f8a46e --- /dev/null +++ b/js/components/search.js @@ -0,0 +1,92 @@ +/*! UIkit 2.26.4 | http://www.getuikit.com | (c) 2014 YOOtheme | MIT License */ +(function(addon) { + + var component; + + if (window.UIkit) { + component = addon(UIkit); + } + + if (typeof define == "function" && define.amd) { + define("uikit-search", ["uikit"], function(){ + return component || addon(UIkit); + }); + } + +})(function(UI){ + + "use strict"; + + UI.component('search', { + defaults: { + msgResultsHeader : 'Search Results', + msgMoreResults : 'More Results', + msgNoResults : 'No results found', + template : '', + + 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); + } + }); +}); diff --git a/js/components/search.min.js b/js/components/search.min.js new file mode 100755 index 0000000..d74b4ac --- /dev/null +++ b/js/components/search.min.js @@ -0,0 +1,2 @@ +/*! UIkit 2.26.4 | http://www.getuikit.com | (c) 2014 YOOtheme | MIT License */ +!function(e){var s;window.UIkit&&(s=e(UIkit)),"function"==typeof define&&define.amd&&define("uikit-search",["uikit"],function(){return s||e(UIkit)})}(function(e){"use strict";e.component("search",{defaults:{msgResultsHeader:"Search Results",msgMoreResults:"More Results",msgNoResults:"No results found",template:'',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)}})}); \ No newline at end of file diff --git a/js/components/slider.js b/js/components/slider.js new file mode 100755 index 0000000..f89b588 --- /dev/null +++ b/js/components/slider.js @@ -0,0 +1,540 @@ +/*! UIkit 2.26.4 | http://www.getuikit.com | (c) 2014 YOOtheme | MIT License */ +(function(addon) { + + var component; + + if (window.UIkit) { + component = addon(UIkit); + } + + if (typeof define == "function" && define.amd) { + define("uikit-slider", ["uikit"], function(){ + return component || addon(UIkit); + }); + } + +})(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.resize(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.resize(true); + + this.on('display.uk.check', function(){ + if ($this.element.is(":visible")) { + $this.resize(true); + } + }); + + // prevent dragging links + images + this.element.find('a,img').attr('draggable', 'false'); + + // Set autoplay + if (this.options.autoplay) { + this.start(); + } + + }, + + resize: 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); + 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.resize(); + } + + 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.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.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 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 store.diff) { + focus = z; + break; + } + + z = z+1 == dragging.items.length ? 0:z+1; + } + + } else { + + for (i=0,z=store.focus;i=this.vp,this.container.css({"-ms-transform":"","-webkit-transform":"",transform:""}),e&&this.updateFocus(this.focus),void 0)},updatePos:function(t){this.pos=t,this.container.css({"-ms-transform":"translateX("+t+"px)","-webkit-transform":"translateX("+t+"px)",transform:"translateX("+t+"px)"})},updateFocus:function(e,i){if(this.active){i=i||(e>this.focus?1:-1);var s,n,a=this.items.eq(e);if(this.options.infinite&&this.infinite(e,i),this.options.center)this.updatePos(-1*a.data("center")),this.items.filter("."+this.options.activecls).removeClass(this.options.activecls),a.addClass(this.options.activecls);else if(this.options.infinite)this.updatePos(-1*a.data("left"));else{for(s=0,n=e;nthis.vp)this.updatePos(-1*a.data("left"));else if(1==i){for(s=0,n=this.items.length-1;n>=0;n--){if(s+=this.items.eq(n).data("width"),s==this.vp){e=n;break}if(s>this.vp){e=nthis.vp?this.updatePos(-1*(this.container.width()-this.vp)):this.updatePos(-1*this.items.eq(e).data("left"))}}var o=this.items.eq(e).data("left");this.items.removeClass("uk-slide-before uk-slide-after").each(function(i){i!==e&&t.$(this).addClass(t.$(this).data("left")this.vp));i++)a=a+1==this.items.length?0:a+1;o.length&&o.forEach(function(t){var e=n.data("area");t.css({left:e}).data({left:e,area:e+t.data("width"),center:e-(s.vp/2-t.data("cwidth")/2)}),n=t})}else{for(i=this.items.length-1;i>-1&&(h+=this.items.eq(a).data("width"),a!=t&&o.push(this.items.eq(a)),!(h>this.vp));i--)a=a-1==-1?this.items.length-1:a-1;o.length&&o.forEach(function(t){var e=n.data("left")-t.data("width");t.css({left:e}).data({left:e,area:e+t.data("width"),center:e-(s.vp/2-t.data("cwidth")/2)}),n=t})}}}),t.$doc.on("mousemove.uk.slider touchmove.uk.slider",function(t){if(t.originalEvent&&t.originalEvent.touches&&(t=t.originalEvent.touches[0]),i&&Math.abs(t.pageX-i.x)>i.threshold&&(window.getSelection().toString()?e=i=!1:i(t)),e){var s,n,o,h,r,c,f,u,d,l;if(t.clientX||t.clientY?s=t.clientX:(t.pageX||t.pageY)&&(s=t.pageX-document.body.scrollLeft-document.documentElement.scrollLeft),r=a.focus,n=s-e.element.data("pointer-start").x,o=e.element.data("pointer-pos-start")+n,h=s>e.element.data("pointer-start").x?-1:1,c=e.items.eq(a.focus),1==h)for(f=c.data("left")+Math.abs(n),u=0,d=a.focus;uf){r=d;break}d=d+1==e.items.length?0:d+1}else for(f=c.data("left")-Math.abs(n),u=0,d=a.focus;ua.diff){o=n;break}n=n+1==e.items.length?0:n+1}else for(s=0,n=a.focus;s'); + } + + 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.$('
          ').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; + } + + 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;ii)return null;for(;a>s;)e=s%i,e?o[n][e]=t[s]:o[++n]=[t[s]],s++;for(s=0,a=o.length;a>s;)o[s]=jQuery(o[s]),s++;return o}var s;t.component("slideset",{defaults:{"default":1,animation:"fade",duration:200,filter:"",delay:!1,controls:!1,autoplay:!1,autoplayInterval:7e3,pauseOnHover:!0},sets:[],boot:function(){t.ready(function(i){t.$("[data-uk-slideset]",i).each(function(){var i=t.$(this);i.data("slideset")||t.slideset(i,t.Utils.options(i.attr("data-uk-slideset")))})})},init:function(){var i=this;this.activeSet=!1,this.list=this.element.find(".uk-slideset"),this.nav=this.element.find(".uk-slideset-nav"),this.controls=this.options.controls?t.$(this.options.controls):this.element,t.$win.on("resize load",t.Utils.debounce(function(){i.updateSets()},100)),i.list.addClass("uk-grid-width-1-"+i.options.default),["xlarge","large","medium","small"].forEach(function(t){i.options[t]&&i.list.addClass("uk-grid-width-"+t+"-1-"+i.options[t])}),this.on("click.uk.slideset","[data-uk-slideset-item]",function(e){if(e.preventDefault(),!i.animating){var s=t.$(this).attr("data-uk-slideset-item");if(i.activeSet!==s)switch(s){case"next":case"previous":i["next"==s?"next":"previous"]();break;default:i.show(parseInt(s,10))}}}),this.controls.on("click.uk.slideset","[data-uk-filter]",function(e){var s=t.$(this);s.parent().hasClass("uk-slideset")||(e.preventDefault(),i.animating||i.currentFilter==s.attr("data-uk-filter")||(i.updateFilter(s.attr("data-uk-filter")),i._hide().then(function(){i.updateSets(!0,!0)})))}),this.on("swipeRight swipeLeft",function(t){i["swipeLeft"==t.type?"next":"previous"]()}),this.updateFilter(this.options.filter),this.updateSets(),this.element.on({mouseenter:function(){i.options.pauseOnHover&&(i.hovering=!0)},mouseleave:function(){i.hovering=!1}}),this.options.autoplay&&this.start()},updateSets:function(t,i){var s,n=this.visible;if(this.visible=this.getVisibleOnCurrenBreakpoint(),n!=this.visible||i){for(this.children=this.list.children().hide(),this.items=this.getItems(),this.sets=e(this.items,this.visible),s=0;s');this.nav[1==this.nav.children().length?"addClass":"removeClass"]("uk-invisible")}this.activeSet=!1,this.show(0,!t)}},updateFilter:function(i){var e,s=this;this.currentFilter=i,this.controls.find("[data-uk-filter]").each(function(){e=t.$(this),e.parent().hasClass("uk-slideset")||(e.attr("data-uk-filter")==s.currentFilter?e.addClass("uk-active"):e.removeClass("uk-active"))})},getVisibleOnCurrenBreakpoint:function(){var i=null,e=t.$('
          ').appendTo("body"),s=e.children().eq(0),n=this.options;return["xlarge","large","medium","small"].forEach(function(t){n[t]&&!i&&(e.attr("class","uk-grid-width-"+t+"-1-2").width(),50==s.width()&&(i=t))}),e.remove(),this.options[i]||this.options["default"]},getItems:function(){var i,e=[];return this.currentFilter?(i=this.currentFilter||[],"string"==typeof i&&(i=i.split(/,/).map(function(t){return t.trim()})),this.children.each(function(){var s=t.$(this),n=s.attr("data-uk-filter"),a=i.length?!1:!0;n&&(n=n.split(/,/).map(function(t){return t.trim()}),i.forEach(function(t){n.indexOf(t)>-1&&(a=!0)})),a&&e.push(s[0])}),e=t.$(e)):e=this.list.children(),e},show:function(i,e,n){var a=this;if(this.activeSet!==i&&!this.animating){n=n||(i').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.$('
          ').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(ghost.remove.bind(ghost), 0); + + d.resolve(); + }); + + ghost.width(); + + ghost.children().each(function() { + var 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.$('
        • ').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.$('
          ').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(ghost.remove.bind(ghost), 0); + + d.resolve(); + }).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.$('
        • ').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.$('
          ').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(ghost.remove.bind(ghost), 0); + + d.resolve(); + }); + + 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.$('
        • ').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.$('
          ').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(ghost.remove.bind(ghost), 0); + + d.resolve(); + }); + + 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; +}); diff --git a/js/components/slideshow-fx.min.js b/js/components/slideshow-fx.min.js new file mode 100755 index 0000000..72340d1 --- /dev/null +++ b/js/components/slideshow-fx.min.js @@ -0,0 +1,2 @@ +/*! UIkit 2.26.4 | http://www.getuikit.com | (c) 2014 YOOtheme | MIT License */ +!function(i){var t;window.UIkit&&(t=i(UIkit)),"function"==typeof define&&define.amd&&define("uikit-slideshow-fx",["uikit"],function(){return t||i(UIkit)})}(function(i){"use strict";var t=i.slideshow.animations;i.$.extend(i.slideshow.animations,{slice:function(e,s,n,o){if(!e.data("cover"))return t.fade.apply(this,arguments);for(var r,a=i.$.Deferred(),c=Math.ceil(this.element.width()/this.options.slices),d=s.data("cover").css("background-image"),h=i.$("
        • ").css({top:0,left:0,width:this.container.width(),height:this.container.height(),opacity:1,zIndex:15}),p=h.width(),l=h.height(),u="slice-up"==o?l:"0",f=0;f').css({position:"absolute",top:0,left:0,width:p,height:l,"background-image":d,clip:m,opacity:0,transition:"all "+this.options.duration+"ms ease-in-out "+60*f+"ms","-webkit-transition":"all "+this.options.duration+"ms ease-in-out "+60*f+"ms"}).data("clip",v),h.append(r)}return this.container.append(h),h.children().last().on(i.support.transition.end,function(){setTimeout(h.remove.bind(h),0),a.resolve()}),h.width(),h.children().each(function(){var t=i.$(this);t.css({clip:t.data("clip"),opacity:1})}),a.promise()},"slice-up":function(i,e,s){return t.slice.apply(this,[i,e,s,"slice-up"])},"slice-down":function(i,e,s){return t.slice.apply(this,[i,e,s,"slice-down"])},"slice-up-down":function(i,e,s){return t.slice.apply(this,[i,e,s,"slice-up-down"])},fold:function(e,s){if(!s.data("cover"))return t.fade.apply(this,arguments);for(var n,o=i.$.Deferred(),r=Math.ceil(this.element.width()/this.options.slices),a=s.data("cover").css("background-image"),c=i.$("
        • ").css({width:s.width(),height:s.height(),opacity:1,zIndex:15}),d=s.width(),h=s.height(),p=0;p').css({position:"absolute",top:0,left:0,width:d,height:h,"background-image":a,"transform-origin":r*p+"px 0 0",clip:"rect(0px, "+r*(p+1)+"px, "+h+"px, "+r*p+"px)",opacity:0,transform:"scaleX(0.000001)",transition:"all "+this.options.duration+"ms ease-in-out "+(100+60*p)+"ms","-webkit-transition":"all "+this.options.duration+"ms ease-in-out "+(100+60*p)+"ms"}),c.prepend(n);return this.container.append(c),c.width(),c.children().first().on(i.support.transition.end,function(){setTimeout(c.remove.bind(c),0),o.resolve()}).end().css({transform:"scaleX(1)",opacity:1}),o.promise()},puzzle:function(s,n){if(!n.data("cover"))return t.fade.apply(this,arguments);for(var o,r,a,c=i.$.Deferred(),d=this,h=Math.round(this.options.slices/2),p=Math.round(n.width()/h),l=Math.round(n.height()/p),u=Math.round(n.height()/l)+1,f=n.data("cover").css("background-image"),m=i.$("
        • ").css({width:this.container.width(),height:this.container.height(),opacity:1,zIndex:15}),x=this.container.width(),v=this.container.height(),g=0;l>g;g++)for(var w=0;h>w;w++)a=w==h-1?p+2:p,r=[u*g+"px",a*(w+1)+"px",u*(g+1)+"px",p*w+"px"],o=i.$('
          ').css({position:"absolute",top:0,left:0,opacity:0,width:x,height:v,"background-image":f,clip:"rect("+r.join(",")+")","-webkit-transform":"translateZ(0)",transform:"translateZ(0)"}),m.append(o);this.container.append(m);var b=e(m.children());return b.each(function(t){i.$(this).css({transition:"all "+d.options.duration+"ms ease-in-out "+(50+25*t)+"ms","-webkit-transition":"all "+d.options.duration+"ms ease-in-out "+(50+25*t)+"ms"})}).last().on(i.support.transition.end,function(){setTimeout(m.remove.bind(m),0),c.resolve()}),m.width(),b.css({opacity:1}),c.promise()},boxes:function(e,s,n,o){if(!s.data("cover"))return t.fade.apply(this,arguments);for(var r,a,c,d,h=i.$.Deferred(),p=Math.round(this.options.slices/2),l=Math.round(s.width()/p),u=Math.round(s.height()/l),f=Math.round(s.height()/u)+1,m=s.data("cover").css("background-image"),x=i.$("
        • ").css({width:s.width(),height:s.height(),opacity:1,zIndex:15}),v=s.width(),g=s.height(),w=0;u>w;w++)for(d=0;p>d;d++)c=d==p-1?l+2:l,a=[f*w+"px",c*(d+1)+"px",f*(w+1)+"px",l*d+"px"],r=i.$('
          ').css({position:"absolute",top:0,left:0,opacity:1,width:v,height:g,"background-image":m,"transform-origin":a[3]+" "+a[0]+" 0",clip:"rect("+a.join(",")+")","-webkit-transform":"scale(0.0000000000000001)",transform:"scale(0.0000000000000001)"}),x.append(r);this.container.append(x);var b,k=0,y=0,$=0,I=[[]],M=x.children();for("boxes-reverse"==o&&(M=[].reverse.apply(M)),M.each(function(){I[k][y]=i.$(this),y++,y==p&&(k++,y=0,I[k]=[])}),d=0,b=0;p*u>d;d++){b=d;for(var z=0;u>z;z++)b>=0&&p>b&&I[z][b].css({transition:"all "+this.options.duration+"ms linear "+(50+$)+"ms","-webkit-transition":"all "+this.options.duration+"ms linear "+(50+$)+"ms"}),b--;$+=100}return M.last().on(i.support.transition.end,function(){setTimeout(x.remove.bind(x),0),h.resolve()}),x.width(),M.css({"-webkit-transform":"scale(1)",transform:"scale(1)"}),h.promise()},"boxes-reverse":function(i,e,s){return t.boxes.apply(this,[i,e,s,"boxes-reverse"])},"random-fx":function(){var i=["slice-up","fold","puzzle","slice-down","boxes","slice-up-down","boxes-reverse"];return this.fxIndex=(void 0===this.fxIndex?-1:this.fxIndex)+1,i[this.fxIndex]||(this.fxIndex=0),t[i[this.fxIndex]].apply(this,arguments)}});var e=function(i){for(var t,e,s=i.length;s;t=parseInt(Math.random()*s),e=i[--s],i[s]=i[t],i[t]=e);return i};return i.slideshow.animations}); \ No newline at end of file diff --git a/js/components/slideshow.js b/js/components/slideshow.js new file mode 100755 index 0000000..88cd4e7 --- /dev/null +++ b/js/components/slideshow.js @@ -0,0 +1,560 @@ +/*! UIkit 2.26.4 | http://www.getuikit.com | (c) 2014 YOOtheme | MIT License */ +(function(addon) { + + var component; + + if (window.UIkit) { + component = addon(UIkit); + } + + if (typeof define == "function" && define.amd) { + define("uikit-slideshow", ["uikit"], function() { + return component || addon(UIkit); + }); + } + +})(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, canvas, kbanimduration; + + this.container = this.element.hasClass('uk-slideshow') ? this.element : UI.$(this.find('.uk-slideshow:first')); + this.slides = this.container.children(); + this.slidesCount = this.slides.length; + this.current = this.options.start; + this.animating = false; + this.triggers = this.find('[data-uk-slideshow-item]'); + 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) { + + kbanimduration = this.options.kenburns === true ? '15s': this.options.kenburns; + + if (!String(kbanimduration).match(/(ms|s)$/)) { + kbanimduration += 'ms'; + } + + if (typeof(this.options.kenburnsanimations) == 'string') { + this.options.kenburnsanimations = this.options.kenburnsanimations.split(','); + } + } + + this.slides.each(function(index) { + + var slide = UI.$(this), + media = slide.children('img,video,iframe').eq(0); + + slide.data('media', media); + slide.data('sizer', media); + + if (media.length) { + + var placeholder; + + switch(media[0].nodeName) { + case 'IMG': + + var cover = UI.$('
          ').css({'background-image':'url('+ media.attr('src') + ')'}); + + if (media.attr('width') && media.attr('height')) { + placeholder = UI.$('').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.$('').attr({'width': media[0].width, 'height': media[0].height}); + var img = UI.$('').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': kbanimduration, + 'animation-duration': kbanimduration + }); + } + }); + + 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(); + }); + + // Set start slide + this.slides.attr('aria-hidden', 'true').eq(this.current).addClass('uk-active').attr('aria-hidden', 'false'); + this.triggers.filter('[data-uk-slideshow-item="'+this.current+'"]').addClass('uk-active'); + + 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); + } + } + }); + }, + + + 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); + +}); diff --git a/js/components/slideshow.min.js b/js/components/slideshow.min.js new file mode 100755 index 0000000..0dc7037 --- /dev/null +++ b/js/components/slideshow.min.js @@ -0,0 +1,2 @@ +/*! UIkit 2.26.4 | http://www.getuikit.com | (c) 2014 YOOtheme | MIT License */ +!function(i){var t;window.UIkit&&(t=i(UIkit)),"function"==typeof define&&define.amd&&define("uikit-slideshow",["uikit"],function(){return t||i(UIkit)})}(function(i){"use strict";var t,s=0;i.component("slideshow",{defaults:{animation:"fade",duration:500,height:"auto",start:0,autoplay:!1,autoplayInterval:7e3,videoautoplay:!0,videomute:!0,slices:15,pauseOnHover:!0,kenburns:!1,kenburnsanimations:["uk-animation-middle-left","uk-animation-top-right","uk-animation-bottom-left","uk-animation-top-center","","uk-animation-bottom-right"]},current:!1,interval:null,hovering:!1,boot:function(){i.ready(function(t){i.$("[data-uk-slideshow]",t).each(function(){var t=i.$(this);t.data("slideshow")||i.slideshow(t,i.Utils.options(t.attr("data-uk-slideshow")))})})},init:function(){var t,e,a=this;this.container=this.element.hasClass("uk-slideshow")?this.element:i.$(this.find(".uk-slideshow:first")),this.slides=this.container.children(),this.slidesCount=this.slides.length,this.current=this.options.start,this.animating=!1,this.triggers=this.find("[data-uk-slideshow-item]"),this.fixFullscreen=navigator.userAgent.match(/(iPad|iPhone|iPod)/g)&&this.container.hasClass("uk-slideshow-fullscreen"),this.options.kenburns&&(e=this.options.kenburns===!0?"15s":this.options.kenburns,String(e).match(/(ms|s)$/)||(e+="ms"),"string"==typeof this.options.kenburnsanimations&&(this.options.kenburnsanimations=this.options.kenburnsanimations.split(","))),this.slides.each(function(n){var o=i.$(this),r=o.children("img,video,iframe").eq(0);if(o.data("media",r),o.data("sizer",r),r.length){var d;switch(r[0].nodeName){case"IMG":var u=i.$('
          ').css({"background-image":"url("+r.attr("src")+")"});r.attr("width")&&r.attr("height")&&(d=i.$("").attr({width:r.attr("width"),height:r.attr("height")}),r.replaceWith(d),r=d,d=void 0),r.css({width:"100%",height:"auto",opacity:0}),o.prepend(u).data("cover",u);break;case"IFRAME":var h=r[0].src,c="sw-"+ ++s;r.attr("src","").on("load",function(){if((n!==a.current||n==a.current&&!a.options.videoautoplay)&&a.pausemedia(r),a.options.videomute){a.mutemedia(r);var i=setInterval(function(t){return function(){a.mutemedia(r),++t>=4&&clearInterval(i)}}(0),250)}}).data("slideshow",a).attr("data-player-id",c).attr("src",[h,h.indexOf("?")>-1?"&":"?","enablejsapi=1&api=1&player_id="+c].join("")).addClass("uk-position-absolute"),i.support.touch||r.css("pointer-events","none"),d=!0,i.cover&&(i.cover(r),r.attr("data-uk-cover","{}"));break;case"VIDEO":r.addClass("uk-cover-object uk-position-absolute"),d=!0,a.options.videomute&&a.mutemedia(r)}if(d){t=i.$("").attr({width:r[0].width,height:r[0].height});var l=i.$('').attr("src",t[0].toDataURL());o.prepend(l),o.data("sizer",l)}}else o.data("sizer",o);a.hasKenBurns(o)&&o.data("cover").css({"-webkit-animation-duration":e,"animation-duration":e})}),this.on("click.uk.slideshow","[data-uk-slideshow-item]",function(t){t.preventDefault();var s=i.$(this).attr("data-uk-slideshow-item");if(a.current!=s){switch(s){case"next":case"previous":a["next"==s?"next":"previous"]();break;default:a.show(parseInt(s,10))}a.stop()}}),this.slides.attr("aria-hidden","true").eq(this.current).addClass("uk-active").attr("aria-hidden","false"),this.triggers.filter('[data-uk-slideshow-item="'+this.current+'"]').addClass("uk-active"),i.$win.on("resize load",i.Utils.debounce(function(){a.resize(),a.fixFullscreen&&(a.container.css("height",window.innerHeight),a.slides.css("height",window.innerHeight))},100)),setTimeout(function(){a.resize()},80),this.options.autoplay&&this.start(),this.options.videoautoplay&&this.slides.eq(this.current).data("media")&&this.playmedia(this.slides.eq(this.current).data("media")),this.options.kenburns&&this.applyKenBurns(this.slides.eq(this.current)),this.container.on({mouseenter:function(){a.options.pauseOnHover&&(a.hovering=!0)},mouseleave:function(){a.hovering=!1}}),this.on("swipeRight swipeLeft",function(i){a["swipeLeft"==i.type?"next":"previous"]()}),this.on("display.uk.check",function(){a.element.is(":visible")&&(a.resize(),a.fixFullscreen&&(a.container.css("height",window.innerHeight),a.slides.css("height",window.innerHeight)))})},resize:function(){if(!this.container.hasClass("uk-slideshow-fullscreen")){var t=this.options.height;"auto"===this.options.height&&(t=0,this.slides.css("height","").each(function(){t=Math.max(t,i.$(this).height())})),this.container.css("height",t),this.slides.css("height",t)}},show:function(s,e){if(!this.animating&&this.current!=s){this.animating=!0;var a=this,n=this.slides.eq(this.current),o=this.slides.eq(s),r=e?e:this.current-1&&"ready"==e.event&&e.player_id&&(s=i.$('[data-player-id="'+e.player_id+'"]'),s.length&&s.data("slideshow").mutemedia(s))},!1)}); \ No newline at end of file diff --git a/js/components/sortable.js b/js/components/sortable.js new file mode 100755 index 0000000..de378d9 --- /dev/null +++ b/js/components/sortable.js @@ -0,0 +1,688 @@ +/*! UIkit 2.26.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.UIkit) { + component = addon(UIkit); + } + + if (typeof define == "function" && define.amd) { + define("uikit-sortable", ["uikit"], function(){ + return component || addon(UIkit); + }); + } + +})(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.$('
          ').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); + } + + UIkit.$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, 'min-width':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':'', 'min-width': '', '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; +}); diff --git a/js/components/sortable.min.js b/js/components/sortable.min.js new file mode 100755 index 0000000..3807ff1 --- /dev/null +++ b/js/components/sortable.min.js @@ -0,0 +1,2 @@ +/*! UIkit 2.26.4 | http://www.getuikit.com | (c) 2014 YOOtheme | MIT License */ +!function(t){var e;window.UIkit&&(e=t(UIkit)),"function"==typeof define&&define.amd&&define("uikit-sortable",["uikit"],function(){return e||t(UIkit)})}(function(t){"use strict";function e(e){e=t.$(e);do{if(e.data("sortable"))return e;e=t.$(e).parent()}while(e.length);return e}function o(t,e){var o=t.parentNode;if(e.parentNode!=o)return!1;for(var n=t.previousSibling;n&&9!==n.nodeType;){if(n===e)return!0;n=n.previousSibling}return!1}function n(t,e){var o=e;if(o==t)return null;for(;o;){if(o.parentNode===t)return o;if(o=o.parentNode,!o||!o.ownerDocument||11===o.nodeType)break}return null}function s(t){t.stopPropagation&&t.stopPropagation(),t.preventDefault&&t.preventDefault(),t.returnValue=!1}var a,r,i,l,d,h,u,p,c,g,f,m="ontouchstart"in window||"MSGesture"in window||window.DocumentTouch&&document instanceof DocumentTouch,v=m?"MSGesture"in window?"pointerdown":"touchstart":"mousedown",b=m?"MSGesture"in window?"pointermove":"touchmove":"mousemove",C=m?"MSGesture"in window?"pointerup":"touchend":"mouseup";return t.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:!1,group:!1,stop:function(){},start:function(){},change:function(){}},boot:function(){t.ready(function(e){t.$("[data-uk-sortable]",e).each(function(){var e=t.$(this);e.data("sortable")||t.sortable(e,t.Utils.options(e.attr("data-uk-sortable")))})}),t.$html.on(b,function(e){if(u){var o=e.originalEvent.targetTouches?e.originalEvent.targetTouches[0]:e;(Math.abs(o.pageX-u.pos.x)>u.threshold||Math.abs(o.pageY-u.pos.y)>u.threshold)&&u.apply(o)}if(a){d||(d=!0,a.show(),a.$current.addClass(a.$sortable.options.placeholderClass),a.$sortable.element.children().addClass(a.$sortable.options.childClass),t.$html.addClass(a.$sortable.options.dragMovingClass));var n=a.data("mouse-offset"),s=e.originalEvent.touches&&e.originalEvent.touches[0]||e.originalEvent,r=parseInt(s.pageX,10)+n.left,i=parseInt(s.pageY,10)+n.top;if(a.css({left:r,top:i}),i+a.height()/3>document.body.offsetHeight)return;iwindow.innerHeight+t.$win.scrollTop()&&t.$win.scrollTop(t.$win.scrollTop()+Math.ceil(a.height()/3))}}),t.$html.on(C,function(t){if(u=h=!1,!r||!a)return r=a=null,void 0;var o=e(r),n=a.$sortable,s={type:t.type};o[0]&&n.dragDrop(s,n.element),n.dragEnd(s,n.element)})},init:function(){function e(){m&&f.touches&&f.touches.length?h.addEventListener(b,y,!1):(h.addEventListener("mouseover",$,!1),h.addEventListener("mouseout",w,!1))}function o(){m&&f.touches&&f.touches.length?h.removeEventListener(b,y,!1):(h.removeEventListener("mouseover",$,!1),h.removeEventListener("mouseout",w,!1))}function a(t){r&&d.dragMove(t,d)}function l(e){return function(o){var s,a,r;f=o,o&&(s=o.touches&&o.touches[0]||o,a=s.target||o.target,m&&document.elementFromPoint&&(a=document.elementFromPoint(s.pageX-document.body.scrollLeft,s.pageY-document.body.scrollTop)),g=t.$(a)),t.$(a).hasClass("."+d.options.childClass)?e.apply(a,[o]):a!==h&&(r=n(h,a),r&&e.apply(r,[o]))}}var d=this,h=this.element[0];p=[],this.checkEmptyList(),this.element.data("sortable-group",this.options.group?this.options.group:t.Utils.uid("sortable-group"));var u=l(function(e){if(!e.data||!e.data.sortable){var o=t.$(e.target),n=o.is("a[href]")?o:o.parents("a[href]");if(!o.is(":input")){if(d.options.handleClass){var s=o.hasClass(d.options.handleClass)?o:o.closest("."+d.options.handleClass,d.element);if(!s.length)return}return e.preventDefault(),n.length&&n.one("click",function(t){t.preventDefault()}).one(C,function(){c||(n.trigger("click"),m&&n.attr("href").trim()&&(location.href=n.attr("href")))}),e.data=e.data||{},e.data.sortable=h,d.dragStart(e,this)}}}),$=l(t.Utils.debounce(function(t){return d.dragEnter(t,this)}),40),w=l(function(){var e=d.dragenterData(this);d.dragenterData(this,e-1),d.dragenterData(this)||(t.$(this).removeClass(d.options.overClass),d.dragenterData(this,!1))}),y=l(function(t){return r&&r!==this&&i!==this?(d.element.children().removeClass(d.options.overClass),i=this,d.moveElementNextTo(r,this),s(t)):!0});this.addDragHandlers=e,this.removeDragHandlers=o,window.addEventListener(b,a,!1),h.addEventListener(v,u,!1)},dragStart:function(e,o){c=!1,d=!1,l=!1;var n=this,s=t.$(e.target);if(!(!m&&2==e.button||s.is("."+n.options.noDragClass)||s.closest("."+n.options.noDragClass).length||s.is(":input"))){r=o,a&&a.remove();var i=t.$(r),h=i.offset(),p=e.touches&&e.touches[0]||e;u={pos:{x:p.pageX,y:p.pageY},threshold:n.options.handleClass?1:n.options.threshold,apply:function(){a=t.$('
          ').css({display:"none",top:h.top,left:h.left,width:i.width(),height:i.height(),padding:i.css("padding")}).data({"mouse-offset":{left:h.left-parseInt(p.pageX,10),top:h.top-parseInt(p.pageY,10)},origin:n.element,index:i.index()}).append(i.html()).appendTo("body"),a.$current=i,a.$sortable=n,i.data({"start-list":i.parent(),"start-index":i.index(),"sortable-group":n.options.group}),n.addDragHandlers(),n.options.start(this,r),n.trigger("start.uk.sortable",[n,r,a]),c=!0,u=!1}}}},dragMove:function(e){g=t.$(document.elementFromPoint(e.pageX-(document.body.scrollLeft||document.scrollLeft||0),e.pageY-(document.body.scrollTop||document.documentElement.scrollTop||0)));var o,n=g.closest("."+this.options.baseClass),s=n.data("sortable-group"),a=t.$(r),i=a.parent(),l=a.data("sortable-group");n[0]!==i[0]&&void 0!==l&&s===l&&(n.data("sortable").addDragHandlers(),p.push(n),n.children().addClass(this.options.childClass),n.children().length>0?(o=g.closest("."+this.options.childClass),o.length?o.before(a):n.append(a)):g.append(a),UIkit.$doc.trigger("mouseover")),this.checkEmptyList(),this.checkEmptyList(i)},dragEnter:function(e,o){if(!r||r===o)return!0;var n=this.dragenterData(o);if(this.dragenterData(o,n+1),0===n){var s=t.$(o).parent(),a=t.$(r).data("start-list");if(s[0]!==a[0]){var i=s.data("sortable-group"),l=t.$(r).data("sortable-group");if((i||l)&&i!=l)return!1}t.$(o).addClass(this.options.overClass),this.moveElementNextTo(r,o)}return!1},dragEnd:function(e,o){var n=this;r&&(this.options.stop(o),this.trigger("stop.uk.sortable",[this])),r=null,i=null,p.push(this.element),p.forEach(function(e){t.$(e).children().each(function(){1===this.nodeType&&(t.$(this).removeClass(n.options.overClass).removeClass(n.options.placeholderClass).removeClass(n.options.childClass),n.dragenterData(this,!1))})}),p=[],t.$html.removeClass(this.options.dragMovingClass),this.removeDragHandlers(),a&&(a.remove(),a=null)},dragDrop:function(t){"drop"===t.type&&(t.stopPropagation&&t.stopPropagation(),t.preventDefault&&t.preventDefault()),this.triggerChangeEvents()},triggerChangeEvents:function(){if(r){var e=t.$(r),o=a.data("origin"),n=e.closest("."+this.options.baseClass),s=[],i=t.$(r);o[0]===n[0]&&a.data("index")!=e.index()?s.push({sortable:this,mode:"moved"}):o[0]!=n[0]&&s.push({sortable:t.$(n).data("sortable"),mode:"added"},{sortable:t.$(o).data("sortable"),mode:"removed"}),s.forEach(function(t){t.sortable&&t.sortable.element.trigger("change.uk.sortable",[t.sortable,i,t.mode])})}},dragenterData:function(e,o){return e=t.$(e),1==arguments.length?parseInt(e.data("child-dragenter"),10)||0:(o?e.data("child-dragenter",Math.max(0,o)):e.removeData("child-dragenter"),void 0)},moveElementNextTo:function(e,n){l=!0;var s=this,a=t.$(e).parent().css("min-height",""),r=o(e,n)?n:n.nextSibling,i=a.children(),d=i.length;return s.options.animation?(a.css("min-height",a.height()),i.stop().each(function(){var e=t.$(this),o=e.position();o.width=e.width(),e.data("offset-before",o)}),n.parentNode.insertBefore(e,r),t.Utils.checkDisplay(s.element.parent()),i=a.children().each(function(){var e=t.$(this);e.data("offset-after",e.position())}).each(function(){var e=t.$(this),o=e.data("offset-before");e.css({position:"absolute",top:o.top,left:o.left,"min-width":o.width})}),i.each(function(){var e=t.$(this),o=(e.data("offset-before"),e.data("offset-after"));e.css("pointer-events","none").width(),setTimeout(function(){e.animate({top:o.top,left:o.left},s.options.animation,function(){e.css({position:"",top:"",left:"","min-width":"","pointer-events":""}).removeClass(s.options.overClass).removeData("child-dragenter"),d--,d||(a.css("min-height",""),t.Utils.checkDisplay(s.element.parent()))})},0)}),void 0):(n.parentNode.insertBefore(e,r),t.Utils.checkDisplay(s.element.parent()),void 0)},serialize:function(){var e,o,n=[];return this.element.children().each(function(s,a){e={};for(var r,i,l=0;l').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; +}); diff --git a/js/components/sticky.min.js b/js/components/sticky.min.js new file mode 100755 index 0000000..0fa4ead --- /dev/null +++ b/js/components/sticky.min.js @@ -0,0 +1,2 @@ +/*! UIkit 2.26.4 | http://www.getuikit.com | (c) 2014 YOOtheme | MIT License */ +!function(t){var i;window.UIkit&&(i=t(UIkit)),"function"==typeof define&&define.amd&&define("uikit-sticky",["uikit"],function(){return i||t(UIkit)})}(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;uo?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').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.innerWidtha?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}); \ No newline at end of file diff --git a/js/components/timepicker.js b/js/components/timepicker.js new file mode 100755 index 0000000..1b7a808 --- /dev/null +++ b/js/components/timepicker.js @@ -0,0 +1,192 @@ +/*! UIkit 2.26.4 | http://www.getuikit.com | (c) 2014 YOOtheme | MIT License */ +(function(addon) { + + var component; + + if (window.UIkit) { + component = addon(UIkit); + } + + if (typeof define == "function" && define.amd) { + define("uikit-timepicker", ["uikit"], function(){ + return component || addon(UIkit); + }); + } + +})(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 = ''; + + this.options.source = function(release) { + release(times[$this.options.format] || times['12h']); + }; + + if (this.element.is('input')) { + this.element.wrap('
          '); + 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 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; + } + +}); diff --git a/js/components/timepicker.min.js b/js/components/timepicker.min.js new file mode 100755 index 0000000..df160db --- /dev/null +++ b/js/components/timepicker.min.js @@ -0,0 +1,2 @@ +/*! UIkit 2.26.4 | http://www.getuikit.com | (c) 2014 YOOtheme | MIT License */ +!function(t){var e;window.UIkit&&(e=t(UIkit)),"function"==typeof define&&define.amd&&define("uikit-timepicker",["uikit"],function(){return e||t(UIkit)})}(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='',this.options.source=function(t){t(a[o.options.format]||a["12h"])},this.element.is("input")?(this.element.wrap('
          '),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:"")}})}); \ No newline at end of file diff --git a/js/components/tooltip.js b/js/components/tooltip.js new file mode 100755 index 0000000..a38d49d --- /dev/null +++ b/js/components/tooltip.js @@ -0,0 +1,234 @@ +/*! UIkit 2.26.4 | http://www.getuikit.com | (c) 2014 YOOtheme | MIT License */ +(function(addon) { + var component; + + if (window.UIkit) { + component = addon(UIkit); + } + + if (typeof define == "function" && define.amd) { + define("uikit-tooltip", ["uikit"], function(){ + return component || addon(UIkit); + }); + } + +})(function(UI){ + + "use strict"; + + var $tooltip, // tooltip container + tooltipdelay, checkdelay; + + 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.$('
          ').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 (checkdelay) clearTimeout(checkdelay); + + if (typeof(this.tip) === 'string' ? !this.tip.length:true) return; + + $tooltip.stop().css({"top": -2000, "visibility": "hidden"}).removeClass(this.options.activeClass).show(); + $tooltip.html('
          ' + this.tip + '
          '); + + 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 + checkdelay = 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 (checkdelay) clearTimeout(checkdelay); + + $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; +}); diff --git a/js/components/tooltip.min.js b/js/components/tooltip.min.js new file mode 100755 index 0000000..130ea2e --- /dev/null +++ b/js/components/tooltip.min.js @@ -0,0 +1,2 @@ +/*! UIkit 2.26.4 | http://www.getuikit.com | (c) 2014 YOOtheme | MIT License */ +!function(t){var i;window.UIkit&&(i=t(UIkit)),"function"==typeof define&&define.amd&&define("uikit-tooltip",["uikit"],function(){return i||t(UIkit)})}(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.$('
          ').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&&clearTimeout(e),"string"==typeof this.tip?this.tip.length:0){i.stop().css({top:-2e3,visibility:"hidden"}).removeClass(this.options.activeClass).show(),i.html('
          '+this.tip+"
          ");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,p="function"==typeof this.options.offset?this.options.offset.call(this.element):this.options.offset,a="function"==typeof this.options.pos?this.options.pos.call(this.element):this.options.pos,h=a.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+p,left:n.left+n.width/2-l/2},top:{top:n.top-f-p,left:n.left+n.width/2-l/2},left:{top:n.top+n.height/2-f/2,left:n.left-l-p},right:{top:n.top+n.height/2-f/2,left:n.left+n.width+p}};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":a=2==h.length?h[0]+"-"+(c.left<0?"left":"right"):c.left<0?"right":"left";break;case"y":a=2==h.length?(c.top<0?"bottom":"top")+"-"+h[1]:c.top<0?"bottom":"top";break;case"xy":a=2==h.length?(c.top<0?"bottom":"top")+"-"+(c.left<0?"left":"right"):c.left<0?"right":"left"}h=a.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-"+a,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&&clearTimeout(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}); \ No newline at end of file diff --git a/js/components/upload.js b/js/components/upload.js new file mode 100755 index 0000000..f80f26e --- /dev/null +++ b/js/components/upload.js @@ -0,0 +1,257 @@ +/*! UIkit 2.26.4 | http://www.getuikit.com | (c) 2014 YOOtheme | MIT License */ +(function(addon) { + + var component; + + if (window.UIkit) { + component = addon(UIkit); + } + + if (typeof define == "function" && define.amd) { + define("uikit-upload", ["uikit"], function(){ + return component || addon(UIkit); + }); + } + +})(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=a.filelimit&&(p=!1),p&&s>d?r([o[d]],a):a.allcomplete(e,t)},r([o[0]],a)}else a.complete=function(e,t){f(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,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}); \ No newline at end of file diff --git a/js/core/alert.js b/js/core/alert.js new file mode 100755 index 0000000..e145d5f --- /dev/null +++ b/js/core/alert.js @@ -0,0 +1,66 @@ +/*! UIkit 2.26.4 | http://www.getuikit.com | (c) 2014 YOOtheme | MIT License */ +(function(UI) { + + "use strict"; + + UI.component('alert', { + + defaults: { + "fade": true, + "duration": 200, + "trigger": ".uk-alert-close" + }, + + boot: function() { + + // init code + UI.$html.on("click.alert.uikit", "[data-uk-alert]", function(e) { + + var ele = UI.$(this); + + if (!ele.data("alert")) { + + var alert = UI.alert(ele, UI.Utils.options(ele.attr("data-uk-alert"))); + + if (UI.$(e.target).is(alert.options.trigger)) { + e.preventDefault(); + alert.close(); + } + } + }); + }, + + init: function() { + + var $this = this; + + this.on("click", this.options.trigger, function(e) { + e.preventDefault(); + $this.close(); + }); + }, + + close: function() { + + var element = this.trigger("close.uk.alert"), + removeElement = function () { + this.trigger("closed.uk.alert").remove(); + }.bind(this); + + if (this.options.fade) { + element.css("overflow", "hidden").css("max-height", element.height()).animate({ + "height" : 0, + "opacity" : 0, + "padding-top" : 0, + "padding-bottom" : 0, + "margin-top" : 0, + "margin-bottom" : 0 + }, this.options.duration, removeElement); + } else { + removeElement(); + } + } + + }); + +})(UIkit); diff --git a/js/core/alert.min.js b/js/core/alert.min.js new file mode 100755 index 0000000..501b85d --- /dev/null +++ b/js/core/alert.min.js @@ -0,0 +1,2 @@ +/*! UIkit 2.26.4 | http://www.getuikit.com | (c) 2014 YOOtheme | MIT License */ +!function(t){"use strict";t.component("alert",{defaults:{fade:!0,duration:200,trigger:".uk-alert-close"},boot:function(){t.$html.on("click.alert.uikit","[data-uk-alert]",function(i){var o=t.$(this);if(!o.data("alert")){var e=t.alert(o,t.Utils.options(o.attr("data-uk-alert")));t.$(i.target).is(e.options.trigger)&&(i.preventDefault(),e.close())}})},init:function(){var t=this;this.on("click",this.options.trigger,function(i){i.preventDefault(),t.close()})},close:function(){var t=this.trigger("close.uk.alert"),i=function(){this.trigger("closed.uk.alert").remove()}.bind(this);this.options.fade?t.css("overflow","hidden").css("max-height",t.height()).animate({height:0,opacity:0,"padding-top":0,"padding-bottom":0,"margin-top":0,"margin-bottom":0},this.options.duration,i):i()}})}(UIkit); \ No newline at end of file diff --git a/js/core/button.js b/js/core/button.js new file mode 100755 index 0000000..9ebe57a --- /dev/null +++ b/js/core/button.js @@ -0,0 +1,157 @@ +/*! UIkit 2.26.4 | http://www.getuikit.com | (c) 2014 YOOtheme | MIT License */ +(function(UI) { + + "use strict"; + + UI.component('buttonRadio', { + + defaults: { + "activeClass": 'uk-active', + "target": ".uk-button" + }, + + boot: function() { + + // init code + UI.$html.on("click.buttonradio.uikit", "[data-uk-button-radio]", function(e) { + + var ele = UI.$(this); + + if (!ele.data("buttonRadio")) { + + var obj = UI.buttonRadio(ele, UI.Utils.options(ele.attr("data-uk-button-radio"))), + target = UI.$(e.target); + + if (target.is(obj.options.target)) { + target.trigger("click"); + } + } + }); + }, + + init: function() { + + var $this = this; + + // Init ARIA + this.find($this.options.target).attr('aria-checked', 'false').filter('.' + $this.options.activeClass).attr('aria-checked', 'true'); + + this.on("click", this.options.target, function(e) { + + var ele = UI.$(this); + + if (ele.is('a[href="#"]')) e.preventDefault(); + + $this.find($this.options.target).not(ele).removeClass($this.options.activeClass).blur(); + ele.addClass($this.options.activeClass); + + // Update ARIA + $this.find($this.options.target).not(ele).attr('aria-checked', 'false'); + ele.attr('aria-checked', 'true'); + + $this.trigger("change.uk.button", [ele]); + }); + + }, + + getSelected: function() { + return this.find('.' + this.options.activeClass); + } + }); + + UI.component('buttonCheckbox', { + + defaults: { + "activeClass": 'uk-active', + "target": ".uk-button" + }, + + boot: function() { + + UI.$html.on("click.buttoncheckbox.uikit", "[data-uk-button-checkbox]", function(e) { + var ele = UI.$(this); + + if (!ele.data("buttonCheckbox")) { + + var obj = UI.buttonCheckbox(ele, UI.Utils.options(ele.attr("data-uk-button-checkbox"))), + target = UI.$(e.target); + + if (target.is(obj.options.target)) { + target.trigger("click"); + } + } + }); + }, + + init: function() { + + var $this = this; + + // Init ARIA + this.find($this.options.target).attr('aria-checked', 'false').filter('.' + $this.options.activeClass).attr('aria-checked', 'true'); + + this.on("click", this.options.target, function(e) { + var ele = UI.$(this); + + if (ele.is('a[href="#"]')) e.preventDefault(); + + ele.toggleClass($this.options.activeClass).blur(); + + // Update ARIA + ele.attr('aria-checked', ele.hasClass($this.options.activeClass)); + + $this.trigger("change.uk.button", [ele]); + }); + + }, + + getSelected: function() { + return this.find('.' + this.options.activeClass); + } + }); + + + UI.component('button', { + + defaults: {}, + + boot: function() { + + UI.$html.on("click.button.uikit", "[data-uk-button]", function(e) { + var ele = UI.$(this); + + if (!ele.data("button")) { + + var obj = UI.button(ele, UI.Utils.options(ele.attr("data-uk-button"))); + ele.trigger("click"); + } + }); + }, + + init: function() { + + var $this = this; + + // Init ARIA + this.element.attr('aria-pressed', this.element.hasClass("uk-active")); + + this.on("click", function(e) { + + if ($this.element.is('a[href="#"]')) e.preventDefault(); + + $this.toggle(); + $this.trigger("change.uk.button", [$this.element.blur().hasClass("uk-active")]); + }); + + }, + + toggle: function() { + this.element.toggleClass("uk-active"); + + // Update ARIA + this.element.attr('aria-pressed', this.element.hasClass("uk-active")); + } + }); + +})(UIkit); + diff --git a/js/core/button.min.js b/js/core/button.min.js new file mode 100755 index 0000000..9458783 --- /dev/null +++ b/js/core/button.min.js @@ -0,0 +1,2 @@ +/*! UIkit 2.26.4 | http://www.getuikit.com | (c) 2014 YOOtheme | MIT License */ +!function(t){"use strict";t.component("buttonRadio",{defaults:{activeClass:"uk-active",target:".uk-button"},boot:function(){t.$html.on("click.buttonradio.uikit","[data-uk-button-radio]",function(i){var a=t.$(this);if(!a.data("buttonRadio")){var e=t.buttonRadio(a,t.Utils.options(a.attr("data-uk-button-radio"))),o=t.$(i.target);o.is(e.options.target)&&o.trigger("click")}})},init:function(){var i=this;this.find(i.options.target).attr("aria-checked","false").filter("."+i.options.activeClass).attr("aria-checked","true"),this.on("click",this.options.target,function(a){var e=t.$(this);e.is('a[href="#"]')&&a.preventDefault(),i.find(i.options.target).not(e).removeClass(i.options.activeClass).blur(),e.addClass(i.options.activeClass),i.find(i.options.target).not(e).attr("aria-checked","false"),e.attr("aria-checked","true"),i.trigger("change.uk.button",[e])})},getSelected:function(){return this.find("."+this.options.activeClass)}}),t.component("buttonCheckbox",{defaults:{activeClass:"uk-active",target:".uk-button"},boot:function(){t.$html.on("click.buttoncheckbox.uikit","[data-uk-button-checkbox]",function(i){var a=t.$(this);if(!a.data("buttonCheckbox")){var e=t.buttonCheckbox(a,t.Utils.options(a.attr("data-uk-button-checkbox"))),o=t.$(i.target);o.is(e.options.target)&&o.trigger("click")}})},init:function(){var i=this;this.find(i.options.target).attr("aria-checked","false").filter("."+i.options.activeClass).attr("aria-checked","true"),this.on("click",this.options.target,function(a){var e=t.$(this);e.is('a[href="#"]')&&a.preventDefault(),e.toggleClass(i.options.activeClass).blur(),e.attr("aria-checked",e.hasClass(i.options.activeClass)),i.trigger("change.uk.button",[e])})},getSelected:function(){return this.find("."+this.options.activeClass)}}),t.component("button",{defaults:{},boot:function(){t.$html.on("click.button.uikit","[data-uk-button]",function(){var i=t.$(this);if(!i.data("button")){{t.button(i,t.Utils.options(i.attr("data-uk-button")))}i.trigger("click")}})},init:function(){var t=this;this.element.attr("aria-pressed",this.element.hasClass("uk-active")),this.on("click",function(i){t.element.is('a[href="#"]')&&i.preventDefault(),t.toggle(),t.trigger("change.uk.button",[t.element.blur().hasClass("uk-active")])})},toggle:function(){this.element.toggleClass("uk-active"),this.element.attr("aria-pressed",this.element.hasClass("uk-active"))}})}(UIkit); \ No newline at end of file diff --git a/js/core/core.js b/js/core/core.js new file mode 100755 index 0000000..85540af --- /dev/null +++ b/js/core/core.js @@ -0,0 +1,786 @@ +/*! UIkit 2.26.4 | http://www.getuikit.com | (c) 2014 YOOtheme | MIT License */ +(function(core) { + + if (typeof define == "function" && define.amd) { // AMD + + define("uikit", function(){ + + var uikit = window.UIkit || core(window, window.jQuery, window.document); + + uikit.load = function(res, req, onload, config) { + + var resources = res.split(','), load = [], i, base = (config.config && config.config.uikit && config.config.uikit.base ? config.config.uikit.base : "").replace(/\/+$/g, ""); + + if (!base) { + throw new Error( "Please define base path to UIkit in the requirejs config." ); + } + + for (i = 0; i < resources.length; i += 1) { + var resource = resources[i].replace(/\./g, '/'); + load.push(base+'/components/'+resource); + } + + req(load, function() { + onload(uikit); + }); + }; + + return uikit; + }); + } + + if (!window.jQuery) { + throw new Error( "UIkit requires jQuery" ); + } + + if (window && window.jQuery) { + core(window, window.jQuery, window.document); + } + + +})(function(global, $, doc) { + + "use strict"; + + var UI = {}, _UI = global.UIkit ? Object.create(global.UIkit) : undefined; + + UI.version = '2.26.4'; + + UI.noConflict = function() { + // restore UIkit version + if (_UI) { + global.UIkit = _UI; + $.UIkit = _UI; + $.fn.uk = _UI.fn; + } + + return UI; + }; + + UI.prefix = function(str) { + return str; + }; + + // cache jQuery + UI.$ = $; + + UI.$doc = UI.$(document); + UI.$win = UI.$(window); + UI.$html = UI.$('html'); + + UI.support = {}; + UI.support.transition = (function() { + + var transitionEnd = (function() { + + var element = doc.body || doc.documentElement, + transEndEventNames = { + WebkitTransition : 'webkitTransitionEnd', + MozTransition : 'transitionend', + OTransition : 'oTransitionEnd otransitionend', + transition : 'transitionend' + }, name; + + for (name in transEndEventNames) { + if (element.style[name] !== undefined) return transEndEventNames[name]; + } + }()); + + return transitionEnd && { end: transitionEnd }; + })(); + + UI.support.animation = (function() { + + var animationEnd = (function() { + + var element = doc.body || doc.documentElement, + animEndEventNames = { + WebkitAnimation : 'webkitAnimationEnd', + MozAnimation : 'animationend', + OAnimation : 'oAnimationEnd oanimationend', + animation : 'animationend' + }, name; + + for (name in animEndEventNames) { + if (element.style[name] !== undefined) return animEndEventNames[name]; + } + }()); + + return animationEnd && { end: animationEnd }; + })(); + + // requestAnimationFrame polyfill + //https://github.com/darius/requestAnimationFrame + (function() { + + Date.now = Date.now || function() { return new Date().getTime(); }; + + var vendors = ['webkit', 'moz']; + for (var i = 0; i < vendors.length && !window.requestAnimationFrame; ++i) { + var vp = vendors[i]; + window.requestAnimationFrame = window[vp+'RequestAnimationFrame']; + window.cancelAnimationFrame = (window[vp+'CancelAnimationFrame'] + || window[vp+'CancelRequestAnimationFrame']); + } + if (/iP(ad|hone|od).*OS 6/.test(window.navigator.userAgent) // iOS6 is buggy + || !window.requestAnimationFrame || !window.cancelAnimationFrame) { + var lastTime = 0; + window.requestAnimationFrame = function(callback) { + var now = Date.now(); + var nextTime = Math.max(lastTime + 16, now); + return setTimeout(function() { callback(lastTime = nextTime); }, + nextTime - now); + }; + window.cancelAnimationFrame = clearTimeout; + } + }()); + + UI.support.touch = ( + ('ontouchstart' in document) || + (global.DocumentTouch && document instanceof global.DocumentTouch) || + (global.navigator.msPointerEnabled && global.navigator.msMaxTouchPoints > 0) || //IE 10 + (global.navigator.pointerEnabled && global.navigator.maxTouchPoints > 0) || //IE >=11 + false + ); + + UI.support.mutationobserver = (global.MutationObserver || global.WebKitMutationObserver || null); + + UI.Utils = {}; + + UI.Utils.isFullscreen = function() { + return document.webkitFullscreenElement || document.mozFullScreenElement || document.msFullscreenElement || document.fullscreenElement || false; + }; + + UI.Utils.str2json = function(str, notevil) { + try { + if (notevil) { + return JSON.parse(str + // wrap keys without quote with valid double quote + .replace(/([\$\w]+)\s*:/g, function(_, $1){return '"'+$1+'":';}) + // replacing single quote wrapped ones to double quote + .replace(/'([^']+)'/g, function(_, $1){return '"'+$1+'"';}) + ); + } else { + return (new Function("", "var json = " + str + "; return JSON.parse(JSON.stringify(json));"))(); + } + } catch(e) { return false; } + }; + + UI.Utils.debounce = function(func, wait, immediate) { + var timeout; + return function() { + var context = this, args = arguments; + var later = function() { + timeout = null; + if (!immediate) func.apply(context, args); + }; + var callNow = immediate && !timeout; + clearTimeout(timeout); + timeout = setTimeout(later, wait); + if (callNow) func.apply(context, args); + }; + }; + + UI.Utils.throttle = function (func, limit) { + var wait = false; + return function () { + if (!wait) { + func.call(); + wait = true; + setTimeout(function () { + wait = false; + }, limit); + } + } + }; + + UI.Utils.removeCssRules = function(selectorRegEx) { + var idx, idxs, stylesheet, _i, _j, _k, _len, _len1, _len2, _ref; + + if(!selectorRegEx) return; + + setTimeout(function(){ + try { + _ref = document.styleSheets; + for (_i = 0, _len = _ref.length; _i < _len; _i++) { + stylesheet = _ref[_i]; + idxs = []; + stylesheet.cssRules = stylesheet.cssRules; + for (idx = _j = 0, _len1 = stylesheet.cssRules.length; _j < _len1; idx = ++_j) { + if (stylesheet.cssRules[idx].type === CSSRule.STYLE_RULE && selectorRegEx.test(stylesheet.cssRules[idx].selectorText)) { + idxs.unshift(idx); + } + } + for (_k = 0, _len2 = idxs.length; _k < _len2; _k++) { + stylesheet.deleteRule(idxs[_k]); + } + } + } catch (_error) {} + }, 0); + }; + + UI.Utils.isInView = function(element, options) { + + var $element = $(element); + + if (!$element.is(':visible')) { + return false; + } + + var window_left = UI.$win.scrollLeft(), window_top = UI.$win.scrollTop(), offset = $element.offset(), left = offset.left, top = offset.top; + + options = $.extend({topoffset:0, leftoffset:0}, options); + + if (top + $element.height() >= window_top && top - options.topoffset <= window_top + UI.$win.height() && + left + $element.width() >= window_left && left - options.leftoffset <= window_left + UI.$win.width()) { + return true; + } else { + return false; + } + }; + + UI.Utils.checkDisplay = function(context, initanimation) { + + var elements = UI.$('[data-uk-margin], [data-uk-grid-match], [data-uk-grid-margin], [data-uk-check-display]', context || document), animated; + + if (context && !elements.length) { + elements = $(context); + } + + elements.trigger('display.uk.check'); + + // fix firefox / IE animations + if (initanimation) { + + if (typeof(initanimation)!='string') { + initanimation = '[class*="uk-animation-"]'; + } + + elements.find(initanimation).each(function(){ + + var ele = UI.$(this), + cls = ele.attr('class'), + anim = cls.match(/uk-animation-(.+)/); + + ele.removeClass(anim[0]).width(); + + ele.addClass(anim[0]); + }); + } + + return elements; + }; + + UI.Utils.options = function(string) { + + if ($.type(string)!='string') return string; + + if (string.indexOf(':') != -1 && string.trim().substr(-1) != '}') { + string = '{'+string+'}'; + } + + var start = (string ? string.indexOf("{") : -1), options = {}; + + if (start != -1) { + try { + options = UI.Utils.str2json(string.substr(start)); + } catch (e) {} + } + + return options; + }; + + UI.Utils.animate = function(element, cls) { + + var d = $.Deferred(); + + element = UI.$(element); + + element.css('display', 'none').addClass(cls).one(UI.support.animation.end, function() { + element.removeClass(cls); + d.resolve(); + }); + + element.css('display', ''); + + return d.promise(); + }; + + UI.Utils.uid = function(prefix) { + return (prefix || 'id') + (new Date().getTime())+"RAND"+(Math.ceil(Math.random() * 100000)); + }; + + UI.Utils.template = function(str, data) { + + var tokens = str.replace(/\n/g, '\\n').replace(/\{\{\{\s*(.+?)\s*\}\}\}/g, "{{!$1}}").split(/(\{\{\s*(.+?)\s*\}\})/g), + i=0, toc, cmd, prop, val, fn, output = [], openblocks = 0; + + while(i < tokens.length) { + + toc = tokens[i]; + + if(toc.match(/\{\{\s*(.+?)\s*\}\}/)) { + i = i + 1; + toc = tokens[i]; + cmd = toc[0]; + prop = toc.substring(toc.match(/^(\^|\#|\!|\~|\:)/) ? 1:0); + + switch(cmd) { + case '~': + output.push("for(var $i=0;$i<"+prop+".length;$i++) { var $item = "+prop+"[$i];"); + openblocks++; + break; + case ':': + output.push("for(var $key in "+prop+") { var $val = "+prop+"[$key];"); + openblocks++; + break; + case '#': + output.push("if("+prop+") {"); + openblocks++; + break; + case '^': + output.push("if(!"+prop+") {"); + openblocks++; + break; + case '/': + output.push("}"); + openblocks--; + break; + case '!': + output.push("__ret.push("+prop+");"); + break; + default: + output.push("__ret.push(escape("+prop+"));"); + break; + } + } else { + output.push("__ret.push('"+toc.replace(/\'/g, "\\'")+"');"); + } + i = i + 1; + } + + fn = new Function('$data', [ + 'var __ret = [];', + 'try {', + 'with($data){', (!openblocks ? output.join('') : '__ret = ["Not all blocks are closed correctly."]'), '};', + '}catch(e){__ret = [e.message];}', + 'return __ret.join("").replace(/\\n\\n/g, "\\n");', + "function escape(html) { return String(html).replace(/&/g, '&').replace(/\"/g, '"').replace(//g, '>');}" + ].join("\n")); + + return data ? fn(data) : fn; + }; + + UI.Utils.events = {}; + UI.Utils.events.click = UI.support.touch ? 'tap' : 'click'; + + global.UIkit = UI; + + // deprecated + + UI.fn = function(command, options) { + + var args = arguments, cmd = command.match(/^([a-z\-]+)(?:\.([a-z]+))?/i), component = cmd[1], method = cmd[2]; + + if (!UI[component]) { + $.error("UIkit component [" + component + "] does not exist."); + return this; + } + + return this.each(function() { + var $this = $(this), data = $this.data(component); + if (!data) $this.data(component, (data = UI[component](this, method ? undefined : options))); + if (method) data[method].apply(data, Array.prototype.slice.call(args, 1)); + }); + }; + + $.UIkit = UI; + $.fn.uk = UI.fn; + + UI.langdirection = UI.$html.attr("dir") == "rtl" ? "right" : "left"; + + UI.components = {}; + + UI.component = function(name, def) { + + var fn = function(element, options) { + + var $this = this; + + this.UIkit = UI; + this.element = element ? UI.$(element) : null; + this.options = $.extend(true, {}, this.defaults, options); + this.plugins = {}; + + if (this.element) { + this.element.data(name, this); + } + + this.init(); + + (this.options.plugins.length ? this.options.plugins : Object.keys(fn.plugins)).forEach(function(plugin) { + + if (fn.plugins[plugin].init) { + fn.plugins[plugin].init($this); + $this.plugins[plugin] = true; + } + + }); + + this.trigger('init.uk.component', [name, this]); + + return this; + }; + + fn.plugins = {}; + + $.extend(true, fn.prototype, { + + defaults : {plugins: []}, + + boot: function(){}, + init: function(){}, + + on: function(a1,a2,a3){ + return UI.$(this.element || this).on(a1,a2,a3); + }, + + one: function(a1,a2,a3){ + return UI.$(this.element || this).one(a1,a2,a3); + }, + + off: function(evt){ + return UI.$(this.element || this).off(evt); + }, + + trigger: function(evt, params) { + return UI.$(this.element || this).trigger(evt, params); + }, + + find: function(selector) { + return UI.$(this.element ? this.element: []).find(selector); + }, + + proxy: function(obj, methods) { + + var $this = this; + + methods.split(' ').forEach(function(method) { + if (!$this[method]) $this[method] = function() { return obj[method].apply(obj, arguments); }; + }); + }, + + mixin: function(obj, methods) { + + var $this = this; + + methods.split(' ').forEach(function(method) { + if (!$this[method]) $this[method] = obj[method].bind($this); + }); + }, + + option: function() { + + if (arguments.length == 1) { + return this.options[arguments[0]] || undefined; + } else if (arguments.length == 2) { + this.options[arguments[0]] = arguments[1]; + } + } + + }, def); + + this.components[name] = fn; + + this[name] = function() { + + var element, options; + + if (arguments.length) { + + switch(arguments.length) { + case 1: + + if (typeof arguments[0] === "string" || arguments[0].nodeType || arguments[0] instanceof jQuery) { + element = $(arguments[0]); + } else { + options = arguments[0]; + } + + break; + case 2: + + element = $(arguments[0]); + options = arguments[1]; + break; + } + } + + if (element && element.data(name)) { + return element.data(name); + } + + return (new UI.components[name](element, options)); + }; + + if (UI.domready) { + UI.component.boot(name); + } + + return fn; + }; + + UI.plugin = function(component, name, def) { + this.components[component].plugins[name] = def; + }; + + UI.component.boot = function(name) { + + if (UI.components[name].prototype && UI.components[name].prototype.boot && !UI.components[name].booted) { + UI.components[name].prototype.boot.apply(UI, []); + UI.components[name].booted = true; + } + }; + + UI.component.bootComponents = function() { + + for (var component in UI.components) { + UI.component.boot(component); + } + }; + + + // DOM mutation save ready helper function + + UI.domObservers = []; + UI.domready = false; + + UI.ready = function(fn) { + + UI.domObservers.push(fn); + + if (UI.domready) { + fn(document); + } + }; + + UI.on = function(a1,a2,a3){ + + if (a1 && a1.indexOf('ready.uk.dom') > -1 && UI.domready) { + a2.apply(UI.$doc); + } + + return UI.$doc.on(a1,a2,a3); + }; + + UI.one = function(a1,a2,a3){ + + if (a1 && a1.indexOf('ready.uk.dom') > -1 && UI.domready) { + a2.apply(UI.$doc); + return UI.$doc; + } + + return UI.$doc.one(a1,a2,a3); + }; + + UI.trigger = function(evt, params) { + return UI.$doc.trigger(evt, params); + }; + + UI.domObserve = function(selector, fn) { + + if(!UI.support.mutationobserver) return; + + fn = fn || function() {}; + + UI.$(selector).each(function() { + + var element = this, + $element = UI.$(element); + + if ($element.data('observer')) { + return; + } + + try { + + var observer = new UI.support.mutationobserver(UI.Utils.debounce(function(mutations) { + fn.apply(element, []); + $element.trigger('changed.uk.dom'); + }, 50), {childList: true, subtree: true}); + + // pass in the target node, as well as the observer options + observer.observe(element, { childList: true, subtree: true }); + + $element.data('observer', observer); + + } catch(e) {} + }); + }; + + UI.init = function(root) { + + root = root || document; + + UI.domObservers.forEach(function(fn){ + fn(root); + }); + }; + + UI.on('domready.uk.dom', function(){ + + UI.init(); + + if (UI.domready) UI.Utils.checkDisplay(); + }); + + document.addEventListener('DOMContentLoaded', function(){ + + var domReady = function() { + + UI.$body = UI.$('body'); + + UI.trigger('beforeready.uk.dom'); + + UI.component.bootComponents(); + + // custom scroll observer + var rafToken = requestAnimationFrame((function(){ + + var memory = {dir: {x:0, y:0}, x: window.pageXOffset, y:window.pageYOffset}; + + var fn = function(){ + // reading this (window.page[X|Y]Offset) causes a full page recalc of the layout in Chrome, + // so we only want to do this once + var wpxo = window.pageXOffset; + var wpyo = window.pageYOffset; + + // Did the scroll position change since the last time we were here? + if (memory.x != wpxo || memory.y != wpyo) { + + // Set the direction of the scroll and store the new position + if (wpxo != memory.x) {memory.dir.x = wpxo > memory.x ? 1:-1; } else { memory.dir.x = 0; } + if (wpyo != memory.y) {memory.dir.y = wpyo > memory.y ? 1:-1; } else { memory.dir.y = 0; } + + memory.x = wpxo; + memory.y = wpyo; + + // Trigger the scroll event, this could probably be sent using memory.clone() but this is + // more explicit and easier to see exactly what is being sent in the event. + UI.$doc.trigger('scrolling.uk.document', [{ + "dir": {"x": memory.dir.x, "y": memory.dir.y}, "x": wpxo, "y": wpyo + }]); + } + + cancelAnimationFrame(rafToken); + rafToken = requestAnimationFrame(fn); + }; + + if (UI.support.touch) { + UI.$html.on('touchmove touchend MSPointerMove MSPointerUp pointermove pointerup', fn); + } + + if (memory.x || memory.y) fn(); + + return fn; + + })()); + + // run component init functions on dom + UI.trigger('domready.uk.dom'); + + if (UI.support.touch) { + + // remove css hover rules for touch devices + // UI.Utils.removeCssRules(/\.uk-(?!navbar).*:hover/); + + // viewport unit fix for uk-height-viewport - should be fixed in iOS 8 + if (navigator.userAgent.match(/(iPad|iPhone|iPod)/g)) { + + UI.$win.on('load orientationchange resize', UI.Utils.debounce((function(){ + + var fn = function() { + $('.uk-height-viewport').css('height', window.innerHeight); + return fn; + }; + + return fn(); + + })(), 100)); + } + } + + UI.trigger('afterready.uk.dom'); + + // mark that domready is left behind + UI.domready = true; + + // auto init js components + if (UI.support.mutationobserver) { + + var initFn = UI.Utils.debounce(function(){ + requestAnimationFrame(function(){ UI.init(document.body);}); + }, 10); + + (new UI.support.mutationobserver(function(mutations) { + + var init = false; + + mutations.every(function(mutation){ + + if (mutation.type != 'childList') return true; + + for (var i = 0, node; i < mutation.addedNodes.length; ++i) { + + node = mutation.addedNodes[i]; + + if (node.outerHTML && node.outerHTML.indexOf('data-uk-') !== -1) { + return (init = true) && false; + } + } + return true; + }); + + if (init) initFn(); + + })).observe(document.body, {childList: true, subtree: true}); + } + }; + + if (document.readyState == 'complete' || document.readyState == 'interactive') { + setTimeout(domReady); + } + + return domReady; + + }()); + + // add touch identifier class + UI.$html.addClass(UI.support.touch ? "uk-touch" : "uk-notouch"); + + // add uk-hover class on tap to support overlays on touch devices + if (UI.support.touch) { + + var hoverset = false, + exclude, + hovercls = 'uk-hover', + selector = '.uk-overlay, .uk-overlay-hover, .uk-overlay-toggle, .uk-animation-hover, .uk-has-hover'; + + UI.$html.on('mouseenter touchstart MSPointerDown pointerdown', selector, function() { + + if (hoverset) $('.'+hovercls).removeClass(hovercls); + + hoverset = $(this).addClass(hovercls); + + }).on('mouseleave touchend MSPointerUp pointerup', function(e) { + + exclude = $(e.target).parents(selector); + + if (hoverset) { + hoverset.not(exclude).removeClass(hovercls); + } + }); + } + + return UI; +}); diff --git a/js/core/core.min.js b/js/core/core.min.js new file mode 100755 index 0000000..07642d0 --- /dev/null +++ b/js/core/core.min.js @@ -0,0 +1,2 @@ +/*! UIkit 2.26.4 | http://www.getuikit.com | (c) 2014 YOOtheme | MIT License */ +!function(t){if("function"==typeof define&&define.amd&&define("uikit",function(){var n=window.UIkit||t(window,window.jQuery,window.document);return n.load=function(t,e,o,i){var r,a=t.split(","),s=[],u=(i.config&&i.config.uikit&&i.config.uikit.base?i.config.uikit.base:"").replace(/\/+$/g,"");if(!u)throw new Error("Please define base path to UIkit in the requirejs config.");for(r=0;r0||t.navigator.pointerEnabled&&t.navigator.maxTouchPoints>0||!1,o.support.mutationobserver=t.MutationObserver||t.WebKitMutationObserver||null,o.Utils={},o.Utils.isFullscreen=function(){return document.webkitFullscreenElement||document.mozFullScreenElement||document.msFullscreenElement||document.fullscreenElement||!1},o.Utils.str2json=function(t,n){try{return n?JSON.parse(t.replace(/([\$\w]+)\s*:/g,function(t,n){return'"'+n+'":'}).replace(/'([^']+)'/g,function(t,n){return'"'+n+'"'})):new Function("","var json = "+t+"; return JSON.parse(JSON.stringify(json));")()}catch(e){return!1}},o.Utils.debounce=function(t,n,e){var o;return function(){var i=this,r=arguments,a=function(){o=null,e||t.apply(i,r)},s=e&&!o;clearTimeout(o),o=setTimeout(a,n),s&&t.apply(i,r)}},o.Utils.throttle=function(t,n){var e=!1;return function(){e||(t.call(),e=!0,setTimeout(function(){e=!1},n))}},o.Utils.removeCssRules=function(t){var n,e,o,i,r,a,s,u,c,d;t&&setTimeout(function(){try{for(d=document.styleSheets,i=0,s=d.length;s>i;i++){for(o=d[i],e=[],o.cssRules=o.cssRules,n=r=0,u=o.cssRules.length;u>r;n=++r)o.cssRules[n].type===CSSRule.STYLE_RULE&&t.test(o.cssRules[n].selectorText)&&e.unshift(n);for(a=0,c=e.length;c>a;a++)o.deleteRule(e[a])}}catch(l){}},0)},o.Utils.isInView=function(t,e){var i=n(t);if(!i.is(":visible"))return!1;var r=o.$win.scrollLeft(),a=o.$win.scrollTop(),s=i.offset(),u=s.left,c=s.top;return e=n.extend({topoffset:0,leftoffset:0},e),c+i.height()>=a&&c-e.topoffset<=a+o.$win.height()&&u+i.width()>=r&&u-e.leftoffset<=r+o.$win.width()?!0:!1},o.Utils.checkDisplay=function(t,e){var i=o.$("[data-uk-margin], [data-uk-grid-match], [data-uk-grid-margin], [data-uk-check-display]",t||document);return t&&!i.length&&(i=n(t)),i.trigger("display.uk.check"),e&&("string"!=typeof e&&(e='[class*="uk-animation-"]'),i.find(e).each(function(){var t=o.$(this),n=t.attr("class"),e=n.match(/uk-animation-(.+)/);t.removeClass(e[0]).width(),t.addClass(e[0])})),i},o.Utils.options=function(t){if("string"!=n.type(t))return t;-1!=t.indexOf(":")&&"}"!=t.trim().substr(-1)&&(t="{"+t+"}");var e=t?t.indexOf("{"):-1,i={};if(-1!=e)try{i=o.Utils.str2json(t.substr(e))}catch(r){}return i},o.Utils.animate=function(t,e){var i=n.Deferred();return t=o.$(t),t.css("display","none").addClass(e).one(o.support.animation.end,function(){t.removeClass(e),i.resolve()}),t.css("display",""),i.promise()},o.Utils.uid=function(t){return(t||"id")+(new Date).getTime()+"RAND"+Math.ceil(1e5*Math.random())},o.Utils.template=function(t,n){for(var e,o,i,r,a=t.replace(/\n/g,"\\n").replace(/\{\{\{\s*(.+?)\s*\}\}\}/g,"{{!$1}}").split(/(\{\{\s*(.+?)\s*\}\})/g),s=0,u=[],c=0;s/g, '>');}"].join("\n")),n?r(n):r},o.Utils.events={},o.Utils.events.click=o.support.touch?"tap":"click",t.UIkit=o,o.fn=function(t,e){var i=arguments,r=t.match(/^([a-z\-]+)(?:\.([a-z]+))?/i),a=r[1],s=r[2];return o[a]?this.each(function(){var t=n(this),r=t.data(a);r||t.data(a,r=o[a](this,s?void 0:e)),s&&r[s].apply(r,Array.prototype.slice.call(i,1))}):(n.error("UIkit component ["+a+"] does not exist."),this)},n.UIkit=o,n.fn.uk=o.fn,o.langdirection="rtl"==o.$html.attr("dir")?"right":"left",o.components={},o.component=function(t,e){var i=function(e,r){var a=this;return this.UIkit=o,this.element=e?o.$(e):null,this.options=n.extend(!0,{},this.defaults,r),this.plugins={},this.element&&this.element.data(t,this),this.init(),(this.options.plugins.length?this.options.plugins:Object.keys(i.plugins)).forEach(function(t){i.plugins[t].init&&(i.plugins[t].init(a),a.plugins[t]=!0)}),this.trigger("init.uk.component",[t,this]),this};return i.plugins={},n.extend(!0,i.prototype,{defaults:{plugins:[]},boot:function(){},init:function(){},on:function(t,n,e){return o.$(this.element||this).on(t,n,e)},one:function(t,n,e){return o.$(this.element||this).one(t,n,e)},off:function(t){return o.$(this.element||this).off(t)},trigger:function(t,n){return o.$(this.element||this).trigger(t,n)},find:function(t){return o.$(this.element?this.element:[]).find(t)},proxy:function(t,n){var e=this;n.split(" ").forEach(function(n){e[n]||(e[n]=function(){return t[n].apply(t,arguments)})})},mixin:function(t,n){var e=this;n.split(" ").forEach(function(n){e[n]||(e[n]=t[n].bind(e))})},option:function(){return 1==arguments.length?this.options[arguments[0]]||void 0:(2==arguments.length&&(this.options[arguments[0]]=arguments[1]),void 0)}},e),this.components[t]=i,this[t]=function(){var e,i;if(arguments.length)switch(arguments.length){case 1:"string"==typeof arguments[0]||arguments[0].nodeType||arguments[0]instanceof jQuery?e=n(arguments[0]):i=arguments[0];break;case 2:e=n(arguments[0]),i=arguments[1]}return e&&e.data(t)?e.data(t):new o.components[t](e,i)},o.domready&&o.component.boot(t),i},o.plugin=function(t,n,e){this.components[t].plugins[n]=e},o.component.boot=function(t){o.components[t].prototype&&o.components[t].prototype.boot&&!o.components[t].booted&&(o.components[t].prototype.boot.apply(o,[]),o.components[t].booted=!0)},o.component.bootComponents=function(){for(var t in o.components)o.component.boot(t)},o.domObservers=[],o.domready=!1,o.ready=function(t){o.domObservers.push(t),o.domready&&t(document)},o.on=function(t,n,e){return t&&t.indexOf("ready.uk.dom")>-1&&o.domready&&n.apply(o.$doc),o.$doc.on(t,n,e)},o.one=function(t,n,e){return t&&t.indexOf("ready.uk.dom")>-1&&o.domready?(n.apply(o.$doc),o.$doc):o.$doc.one(t,n,e)},o.trigger=function(t,n){return o.$doc.trigger(t,n)},o.domObserve=function(t,n){o.support.mutationobserver&&(n=n||function(){},o.$(t).each(function(){var t=this,e=o.$(t);if(!e.data("observer"))try{var i=new o.support.mutationobserver(o.Utils.debounce(function(){n.apply(t,[]),e.trigger("changed.uk.dom")},50),{childList:!0,subtree:!0});i.observe(t,{childList:!0,subtree:!0}),e.data("observer",i)}catch(r){}}))},o.init=function(t){t=t||document,o.domObservers.forEach(function(n){n(t)})},o.on("domready.uk.dom",function(){o.init(),o.domready&&o.Utils.checkDisplay()}),document.addEventListener("DOMContentLoaded",function(){var t=function(){o.$body=o.$("body"),o.trigger("beforeready.uk.dom"),o.component.bootComponents();var t=requestAnimationFrame(function(){var n={dir:{x:0,y:0},x:window.pageXOffset,y:window.pageYOffset},e=function(){var i=window.pageXOffset,r=window.pageYOffset;(n.x!=i||n.y!=r)&&(n.dir.x=i!=n.x?i>n.x?1:-1:0,n.dir.y=r!=n.y?r>n.y?1:-1:0,n.x=i,n.y=r,o.$doc.trigger("scrolling.uk.document",[{dir:{x:n.dir.x,y:n.dir.y},x:i,y:r}])),cancelAnimationFrame(t),t=requestAnimationFrame(e)};return o.support.touch&&o.$html.on("touchmove touchend MSPointerMove MSPointerUp pointermove pointerup",e),(n.x||n.y)&&e(),e}());if(o.trigger("domready.uk.dom"),o.support.touch&&navigator.userAgent.match(/(iPad|iPhone|iPod)/g)&&o.$win.on("load orientationchange resize",o.Utils.debounce(function(){var t=function(){return n(".uk-height-viewport").css("height",window.innerHeight),t};return t()}(),100)),o.trigger("afterready.uk.dom"),o.domready=!0,o.support.mutationobserver){var e=o.Utils.debounce(function(){requestAnimationFrame(function(){o.init(document.body)})},10);new o.support.mutationobserver(function(t){var n=!1;t.every(function(t){if("childList"!=t.type)return!0;for(var e,o=0;o -1 ? '&':'?'), 'enablejsapi=1&api=1'].join('')); + } + }, + + check: function() { + + this.element.css({ + 'width' : '', + 'height' : '' + }); + + this.dimension = {w: this.element.width(), h: this.element.height()}; + + if (this.element.attr('width') && !isNaN(this.element.attr('width'))) { + this.dimension.w = this.element.attr('width'); + } + + if (this.element.attr('height') && !isNaN(this.element.attr('height'))) { + this.dimension.h = this.element.attr('height'); + } + + this.ratio = this.dimension.w / this.dimension.h; + + var w = this.parent.width(), h = this.parent.height(), width, height; + + // if element height < parent height (gap underneath) + if ((w / this.ratio) < h) { + + width = Math.ceil(h * this.ratio); + height = h; + + // element width < parent width (gap to right) + } else { + + width = w; + height = Math.ceil(w / this.ratio); + } + + this.element.css({ + 'width' : width, + 'height' : height + }); + } + }); + +})(UIkit); diff --git a/js/core/cover.min.js b/js/core/cover.min.js new file mode 100755 index 0000000..6bc18a9 --- /dev/null +++ b/js/core/cover.min.js @@ -0,0 +1,2 @@ +/*! UIkit 2.26.4 | http://www.getuikit.com | (c) 2014 YOOtheme | MIT License */ +!function(t){"use strict";t.component("cover",{defaults:{automute:!0},boot:function(){t.ready(function(i){t.$("[data-uk-cover]",i).each(function(){var i=t.$(this);if(!i.data("cover")){t.cover(i,t.Utils.options(i.attr("data-uk-cover")))}})})},init:function(){if(this.parent=this.element.parent(),t.$win.on("load resize orientationchange",t.Utils.debounce(function(){this.check()}.bind(this),100)),this.on("display.uk.check",function(){this.element.is(":visible")&&this.check()}.bind(this)),this.check(),this.element.is("iframe")&&this.options.automute){var i=this.element.attr("src");this.element.attr("src","").on("load",function(){this.contentWindow.postMessage('{ "event": "command", "func": "mute", "method":"setVolume", "value":0}',"*")}).attr("src",[i,i.indexOf("?")>-1?"&":"?","enablejsapi=1&api=1"].join(""))}},check:function(){this.element.css({width:"",height:""}),this.dimension={w:this.element.width(),h:this.element.height()},this.element.attr("width")&&!isNaN(this.element.attr("width"))&&(this.dimension.w=this.element.attr("width")),this.element.attr("height")&&!isNaN(this.element.attr("height"))&&(this.dimension.h=this.element.attr("height")),this.ratio=this.dimension.w/this.dimension.h;var t,i,e=this.parent.width(),n=this.parent.height();e/this.ratio boundarywidth) { + dropdown.addClass("uk-dropdown-stack"); + this.trigger('stack.uk.dropdown', [this]); + } + + dropdown.css(css).css("display", "").addClass('uk-dropdown-'+pp[0]); + }, + + checkBoundary: function(left, top, width, height, boundarywidth) { + + var axis = ""; + + if (left < 0 || ((left - UI.$win.scrollLeft())+width) > boundarywidth) { + axis += "x"; + } + + if ((top - UI.$win.scrollTop()) < 0 || ((top - UI.$win.scrollTop())+height) > window.innerHeight) { + axis += "y"; + } + + return axis; + } + }); + + + UI.component('dropdownOverlay', { + + defaults: { + 'justify' : false, + 'cls' : '', + 'duration': 200 + }, + + boot: function() { + + // init code + UI.ready(function(context) { + + UI.$("[data-uk-dropdown-overlay]", context).each(function() { + var ele = UI.$(this); + + if (!ele.data("dropdownOverlay")) { + UI.dropdownOverlay(ele, UI.Utils.options(ele.attr("data-uk-dropdown-overlay"))); + } + }); + }); + }, + + init: function() { + + var $this = this; + + this.justified = this.options.justify ? UI.$(this.options.justify) : false; + this.overlay = this.element.find('uk-dropdown-overlay'); + + if (!this.overlay.length) { + this.overlay = UI.$('
          ').appendTo(this.element); + } + + this.overlay.addClass(this.options.cls); + + this.on({ + + 'beforeshow.uk.dropdown': function(e, dropdown) { + $this.dropdown = dropdown; + + if ($this.justified && $this.justified.length) { + justify($this.overlay.css({'display':'block', 'margin-left':'','margin-right':''}), $this.justified, $this.justified.outerWidth()); + } + }, + + 'show.uk.dropdown': function(e, dropdown) { + + var h = $this.dropdown.dropdown.outerHeight(true); + + $this.dropdown.element.removeClass('uk-open'); + + $this.overlay.stop().css('display', 'block').animate({height: h}, $this.options.duration, function() { + + $this.dropdown.dropdown.css('visibility', ''); + $this.dropdown.element.addClass('uk-open'); + + UI.Utils.checkDisplay($this.dropdown.dropdown, true); + }); + + $this.pointerleave = false; + }, + + 'hide.uk.dropdown': function() { + $this.overlay.stop().animate({height: 0}, $this.options.duration); + }, + + 'pointerenter.uk.dropdown': function(e, dropdown) { + clearTimeout($this.remainIdle); + }, + + 'pointerleave.uk.dropdown': function(e, dropdown) { + $this.pointerleave = true; + } + }); + + + this.overlay.on({ + + 'mouseenter': function() { + if ($this.remainIdle) { + clearTimeout($this.dropdown.remainIdle); + clearTimeout($this.remainIdle); + } + }, + + 'mouseleave': function(){ + + if ($this.pointerleave && active) { + + $this.remainIdle = setTimeout(function() { + if(active) active.hide(); + }, active.options.remaintime); + } + } + }) + } + + }); + + + function justify(ele, justifyTo, boundarywidth, offset) { + + ele = UI.$(ele); + justifyTo = UI.$(justifyTo); + boundarywidth = boundarywidth || window.innerWidth; + offset = offset || ele.offset(); + + if (justifyTo.length) { + + var jwidth = justifyTo.outerWidth(); + + ele.css("min-width", jwidth); + + if (UI.langdirection == 'right') { + + var right1 = boundarywidth - (justifyTo.offset().left + jwidth), + right2 = boundarywidth - (ele.offset().left + ele.outerWidth()); + + ele.css("margin-right", right1 - right2); + + } else { + ele.css("margin-left", justifyTo.offset().left - offset.left); + } + } + } + +})(UIkit); diff --git a/js/core/dropdown.min.js b/js/core/dropdown.min.js new file mode 100755 index 0000000..410c82e --- /dev/null +++ b/js/core/dropdown.min.js @@ -0,0 +1,2 @@ +/*! UIkit 2.26.4 | http://www.getuikit.com | (c) 2014 YOOtheme | MIT License */ +!function(t){"use strict";function o(o,e,i,n){if(o=t.$(o),e=t.$(e),i=i||window.innerWidth,n=n||o.offset(),e.length){var r=e.outerWidth();if(o.css("min-width",r),"right"==t.langdirection){var s=i-(e.offset().left+r),d=i-(o.offset().left+o.outerWidth());o.css("margin-right",s-d)}else o.css("margin-left",e.offset().left-n.left)}}var e,i=!1,n={x:{"bottom-left":"bottom-right","bottom-right":"bottom-left","bottom-center":"bottom-center","top-left":"top-right","top-right":"top-left","top-center":"top-center","left-top":"right-top","left-bottom":"right-bottom","left-center":"right-center","right-top":"left-top","right-bottom":"left-bottom","right-center":"left-center"},y:{"bottom-left":"top-left","bottom-right":"top-right","bottom-center":"top-center","top-left":"bottom-left","top-right":"bottom-right","top-center":"bottom-center","left-top":"left-bottom","left-bottom":"left-top","left-center":"left-center","right-top":"right-bottom","right-bottom":"right-top","right-center":"right-center"},xy:{"bottom-left":"top-right","bottom-right":"top-left","bottom-center":"top-center","top-left":"bottom-right","top-right":"bottom-left","top-center":"bottom-center","left-top":"right-bottom","left-bottom":"right-top","left-center":"right-center","right-top":"left-bottom","right-bottom":"left-top","right-center":"left-center"}};t.component("dropdown",{defaults:{mode:"hover",pos:"bottom-left",offset:0,remaintime:800,justify:!1,boundary:t.$win,delay:0,dropdownSelector:".uk-dropdown,.uk-dropdown-blank",hoverDelayIdle:250,preventflip:!1},remainIdle:!1,boot:function(){var o=t.support.touch?"click":"mouseenter";t.$html.on(o+".dropdown.uikit","[data-uk-dropdown]",function(e){var i=t.$(this);if(!i.data("dropdown")){var n=t.dropdown(i,t.Utils.options(i.attr("data-uk-dropdown")));("click"==o||"mouseenter"==o&&"hover"==n.options.mode)&&n.element.trigger(o),n.element.find(n.options.dropdownSelector).length&&e.preventDefault()}})},init:function(){var o=this;this.dropdown=this.find(this.options.dropdownSelector),this.offsetParent=this.dropdown.parents().filter(function(){return-1!==t.$.inArray(t.$(this).css("position"),["relative","fixed","absolute"])}).slice(0,1),this.centered=this.dropdown.hasClass("uk-dropdown-center"),this.justified=this.options.justify?t.$(this.options.justify):!1,this.boundary=t.$(this.options.boundary),this.boundary.length||(this.boundary=t.$win),this.dropdown.hasClass("uk-dropdown-up")&&(this.options.pos="top-left"),this.dropdown.hasClass("uk-dropdown-flip")&&(this.options.pos=this.options.pos.replace("left","right")),this.dropdown.hasClass("uk-dropdown-center")&&(this.options.pos=this.options.pos.replace(/(left|right)/,"center")),this.element.attr("aria-haspopup","true"),this.element.attr("aria-expanded",this.element.hasClass("uk-open")),"click"==this.options.mode||t.support.touch?this.on("click.uk.dropdown",function(e){var i=t.$(e.target);i.parents(o.options.dropdownSelector).length||((i.is("a[href='#']")||i.parent().is("a[href='#']")||o.dropdown.length&&!o.dropdown.is(":visible"))&&e.preventDefault(),i.blur()),o.element.hasClass("uk-open")?(!o.dropdown.find(e.target).length||i.is(".uk-dropdown-close")||i.parents(".uk-dropdown-close").length)&&o.hide():o.show()}):this.on("mouseenter",function(){o.trigger("pointerenter.uk.dropdown",[o]),o.remainIdle&&clearTimeout(o.remainIdle),e&&clearTimeout(e),i&&i==o||(e=i&&i!=o?setTimeout(function(){e=setTimeout(o.show.bind(o),o.options.delay)},o.options.hoverDelayIdle):setTimeout(o.show.bind(o),o.options.delay))}).on("mouseleave",function(){e&&clearTimeout(e),o.remainIdle=setTimeout(function(){i&&i==o&&o.hide()},o.options.remaintime),o.trigger("pointerleave.uk.dropdown",[o])}).on("click",function(e){var n=t.$(e.target);return o.remainIdle&&clearTimeout(o.remainIdle),i&&i==o?((!o.dropdown.find(e.target).length||n.is(".uk-dropdown-close")||n.parents(".uk-dropdown-close").length)&&o.hide(),void 0):((n.is("a[href='#']")||n.parent().is("a[href='#']"))&&e.preventDefault(),o.show(),void 0)})},show:function(){t.$html.off("click.outer.dropdown"),i&&i!=this&&i.hide(!0),e&&clearTimeout(e),this.trigger("beforeshow.uk.dropdown",[this]),this.checkDimensions(),this.element.addClass("uk-open"),this.element.attr("aria-expanded","true"),this.trigger("show.uk.dropdown",[this]),t.Utils.checkDisplay(this.dropdown,!0),i=this,this.registerOuterClick()},hide:function(t){this.trigger("beforehide.uk.dropdown",[this,t]),this.element.removeClass("uk-open"),this.remainIdle&&clearTimeout(this.remainIdle),this.remainIdle=!1,this.element.attr("aria-expanded","false"),this.trigger("hide.uk.dropdown",[this,t]),i==this&&(i=!1)},registerOuterClick:function(){var o=this;t.$html.off("click.outer.dropdown"),setTimeout(function(){t.$html.on("click.outer.dropdown",function(n){e&&clearTimeout(e);t.$(n.target);i!=o||o.element.find(n.target).length||(o.hide(!0),t.$html.off("click.outer.dropdown"))})},10)},checkDimensions:function(){if(this.dropdown.length){this.dropdown.removeClass("uk-dropdown-top uk-dropdown-bottom uk-dropdown-left uk-dropdown-right uk-dropdown-stack").css({"top-left":"",left:"","margin-left":"","margin-right":""}),this.justified&&this.justified.length&&this.dropdown.css("min-width","");var e,i=t.$.extend({},this.offsetParent.offset(),{width:this.offsetParent[0].offsetWidth,height:this.offsetParent[0].offsetHeight}),r=this.options.offset,s=this.dropdown,d=(s.show().offset()||{left:0,top:0},s.outerWidth()),h=s.outerHeight(),l=this.boundary.width(),p=(this.boundary[0]!==window&&this.boundary.offset()?this.boundary.offset():{top:0,left:0},this.options.pos),a={"bottom-left":{top:0+i.height+r,left:0},"bottom-right":{top:0+i.height+r,left:0+i.width-d},"bottom-center":{top:0+i.height+r,left:0+i.width/2-d/2},"top-left":{top:0-h-r,left:0},"top-right":{top:0-h-r,left:0+i.width-d},"top-center":{top:0-h-r,left:0+i.width/2-d/2},"left-top":{top:0,left:0-d-r},"left-bottom":{top:0+i.height-h,left:0-d-r},"left-center":{top:0+i.height/2-h/2,left:0-d-r},"right-top":{top:0,left:0+i.width+r},"right-bottom":{top:0+i.height-h,left:0+i.width+r},"right-center":{top:0+i.height/2-h/2,left:0+i.width+r}},f={};if(e=p.split("-"),f=a[p]?a[p]:a["bottom-left"],this.justified&&this.justified.length)o(s.css({left:0}),this.justified,l);else if(this.options.preventflip!==!0){var u;switch(this.checkBoundary(i.left+f.left,i.top+f.top,d,h,l)){case"x":"x"!==this.options.preventflip&&(u=n.x[p]||"right-top");break;case"y":"y"!==this.options.preventflip&&(u=n.y[p]||"top-left");break;case"xy":this.options.preventflip||(u=n.xy[p]||"right-bottom")}u&&(e=u.split("-"),f=a[u]?a[u]:a["bottom-left"],this.checkBoundary(i.left+f.left,i.top+f.top,d,h,l)&&(e=p.split("-"),f=a[p]?a[p]:a["bottom-left"]))}d>l&&(s.addClass("uk-dropdown-stack"),this.trigger("stack.uk.dropdown",[this])),s.css(f).css("display","").addClass("uk-dropdown-"+e[0])}},checkBoundary:function(o,e,i,n,r){var s="";return(0>o||o-t.$win.scrollLeft()+i>r)&&(s+="x"),(e-t.$win.scrollTop()<0||e-t.$win.scrollTop()+n>window.innerHeight)&&(s+="y"),s}}),t.component("dropdownOverlay",{defaults:{justify:!1,cls:"",duration:200},boot:function(){t.ready(function(o){t.$("[data-uk-dropdown-overlay]",o).each(function(){var o=t.$(this);o.data("dropdownOverlay")||t.dropdownOverlay(o,t.Utils.options(o.attr("data-uk-dropdown-overlay")))})})},init:function(){var e=this;this.justified=this.options.justify?t.$(this.options.justify):!1,this.overlay=this.element.find("uk-dropdown-overlay"),this.overlay.length||(this.overlay=t.$('
          ').appendTo(this.element)),this.overlay.addClass(this.options.cls),this.on({"beforeshow.uk.dropdown":function(t,i){e.dropdown=i,e.justified&&e.justified.length&&o(e.overlay.css({display:"block","margin-left":"","margin-right":""}),e.justified,e.justified.outerWidth())},"show.uk.dropdown":function(){var o=e.dropdown.dropdown.outerHeight(!0);e.dropdown.element.removeClass("uk-open"),e.overlay.stop().css("display","block").animate({height:o},e.options.duration,function(){e.dropdown.dropdown.css("visibility",""),e.dropdown.element.addClass("uk-open"),t.Utils.checkDisplay(e.dropdown.dropdown,!0)}),e.pointerleave=!1},"hide.uk.dropdown":function(){e.overlay.stop().animate({height:0},e.options.duration)},"pointerenter.uk.dropdown":function(){clearTimeout(e.remainIdle)},"pointerleave.uk.dropdown":function(){e.pointerleave=!0}}),this.overlay.on({mouseenter:function(){e.remainIdle&&(clearTimeout(e.dropdown.remainIdle),clearTimeout(e.remainIdle))},mouseleave:function(){e.pointerleave&&i&&(e.remainIdle=setTimeout(function(){i&&i.hide()},i.options.remaintime))}})}})}(UIkit); \ No newline at end of file diff --git a/js/core/grid.js b/js/core/grid.js new file mode 100755 index 0000000..2552f93 --- /dev/null +++ b/js/core/grid.js @@ -0,0 +1,117 @@ +/*! UIkit 2.26.4 | http://www.getuikit.com | (c) 2014 YOOtheme | MIT License */ +(function(UI) { + + "use strict"; + + var grids = []; + + UI.component('gridMatchHeight', { + + defaults: { + "target" : false, + "row" : true, + "ignorestacked" : false, + "observe" : false + }, + + boot: function() { + + // init code + UI.ready(function(context) { + + UI.$("[data-uk-grid-match]", context).each(function() { + var grid = UI.$(this), obj; + + if (!grid.data("gridMatchHeight")) { + obj = UI.gridMatchHeight(grid, UI.Utils.options(grid.attr("data-uk-grid-match"))); + } + }); + }); + }, + + init: function() { + + var $this = this; + + this.columns = this.element.children(); + this.elements = this.options.target ? this.find(this.options.target) : this.columns; + + if (!this.columns.length) return; + + UI.$win.on('load resize orientationchange', (function() { + + var fn = function() { + if ($this.element.is(":visible")) $this.match(); + }; + + UI.$(function() { fn(); }); + + return UI.Utils.debounce(fn, 50); + })()); + + if (this.options.observe) { + + UI.domObserve(this.element, function(e) { + if ($this.element.is(":visible")) $this.match(); + }); + } + + this.on("display.uk.check", function(e) { + if(this.element.is(":visible")) this.match(); + }.bind(this)); + + grids.push(this); + }, + + match: function() { + + var firstvisible = this.columns.filter(":visible:first"); + + if (!firstvisible.length) return; + + var stacked = Math.ceil(100 * parseFloat(firstvisible.css('width')) / parseFloat(firstvisible.parent().css('width'))) >= 100; + + if (stacked && !this.options.ignorestacked) { + this.revert(); + } else { + UI.Utils.matchHeights(this.elements, this.options); + } + + return this; + }, + + revert: function() { + this.elements.css('min-height', ''); + return this; + } + }); + + UI.component('gridMargin', { + + defaults: { + cls : 'uk-grid-margin', + rowfirst : 'uk-row-first' + }, + + boot: function() { + + // init code + UI.ready(function(context) { + + UI.$("[data-uk-grid-margin]", context).each(function() { + var grid = UI.$(this), obj; + + if (!grid.data("gridMargin")) { + obj = UI.gridMargin(grid, UI.Utils.options(grid.attr("data-uk-grid-margin"))); + } + }); + }); + }, + + init: function() { + + var stackMargin = UI.stackMargin(this.element, this.options); + } + }); + +})(UIkit); diff --git a/js/core/grid.min.js b/js/core/grid.min.js new file mode 100755 index 0000000..fe52a52 --- /dev/null +++ b/js/core/grid.min.js @@ -0,0 +1,2 @@ +/*! UIkit 2.26.4 | http://www.getuikit.com | (c) 2014 YOOtheme | MIT License */ +!function(t){"use strict";var i=[];t.component("gridMatchHeight",{defaults:{target:!1,row:!0,ignorestacked:!1,observe:!1},boot:function(){t.ready(function(i){t.$("[data-uk-grid-match]",i).each(function(){var i,n=t.$(this);n.data("gridMatchHeight")||(i=t.gridMatchHeight(n,t.Utils.options(n.attr("data-uk-grid-match"))))})})},init:function(){var n=this;this.columns=this.element.children(),this.elements=this.options.target?this.find(this.options.target):this.columns,this.columns.length&&(t.$win.on("load resize orientationchange",function(){var i=function(){n.element.is(":visible")&&n.match()};return t.$(function(){i()}),t.Utils.debounce(i,50)}()),this.options.observe&&t.domObserve(this.element,function(){n.element.is(":visible")&&n.match()}),this.on("display.uk.check",function(){this.element.is(":visible")&&this.match()}.bind(this)),i.push(this))},match:function(){var i=this.columns.filter(":visible:first");if(i.length){var n=Math.ceil(100*parseFloat(i.css("width"))/parseFloat(i.parent().css("width")))>=100;return n&&!this.options.ignorestacked?this.revert():t.Utils.matchHeights(this.elements,this.options),this}},revert:function(){return this.elements.css("min-height",""),this}}),t.component("gridMargin",{defaults:{cls:"uk-grid-margin",rowfirst:"uk-row-first"},boot:function(){t.ready(function(i){t.$("[data-uk-grid-margin]",i).each(function(){var i,n=t.$(this);n.data("gridMargin")||(i=t.gridMargin(n,t.Utils.options(n.attr("data-uk-grid-margin"))))})})},init:function(){t.stackMargin(this.element,this.options)}})}(UIkit); \ No newline at end of file diff --git a/js/core/modal.js b/js/core/modal.js new file mode 100755 index 0000000..74d122d --- /dev/null +++ b/js/core/modal.js @@ -0,0 +1,393 @@ +/*! UIkit 2.26.4 | http://www.getuikit.com | (c) 2014 YOOtheme | MIT License */ +(function(UI) { + + "use strict"; + + var active = false, activeCount = 0, $html = UI.$html, body; + + UI.$win.on("resize orientationchange", UI.Utils.debounce(function(){ + UI.$('.uk-modal.uk-open').each(function(){ + UI.$(this).data('modal').resize(); + }); + }, 150)); + + UI.component('modal', { + + defaults: { + keyboard: true, + bgclose: true, + minScrollHeight: 150, + center: false, + modal: true + }, + + scrollable: false, + transition: false, + hasTransitioned: true, + + init: function() { + + if (!body) body = UI.$('body'); + + if (!this.element.length) return; + + var $this = this; + + this.paddingdir = "padding-" + (UI.langdirection == 'left' ? "right":"left"); + this.dialog = this.find(".uk-modal-dialog"); + + this.active = false; + + // Update ARIA + this.element.attr('aria-hidden', this.element.hasClass("uk-open")); + + this.on("click", ".uk-modal-close", function(e) { + e.preventDefault(); + $this.hide(); + }).on("click", function(e) { + + var target = UI.$(e.target); + + if (target[0] == $this.element[0] && $this.options.bgclose) { + $this.hide(); + } + }); + + UI.domObserve(this.element, function(e) { $this.resize(); }); + }, + + toggle: function() { + return this[this.isActive() ? "hide" : "show"](); + }, + + show: function() { + + if (!this.element.length) return; + + var $this = this; + + if (this.isActive()) return; + + if (this.options.modal && active) { + active.hide(true); + } + + this.element.removeClass("uk-open").show(); + this.resize(true); + + if (this.options.modal) { + active = this; + } + + this.active = true; + + activeCount++; + + if (UI.support.transition) { + this.hasTransitioned = false; + this.element.one(UI.support.transition.end, function(){ + $this.hasTransitioned = true; + }).addClass("uk-open"); + } else { + this.element.addClass("uk-open"); + } + + $html.addClass("uk-modal-page").height(); // force browser engine redraw + + // Update ARIA + this.element.attr('aria-hidden', 'false'); + + this.element.trigger("show.uk.modal"); + + UI.Utils.checkDisplay(this.dialog, true); + + return this; + }, + + hide: function(force) { + + if (!force && UI.support.transition && this.hasTransitioned) { + + var $this = this; + + this.one(UI.support.transition.end, function() { + $this._hide(); + }).removeClass("uk-open"); + + } else { + + this._hide(); + } + + return this; + }, + + resize: function(force) { + + if (!this.isActive() && !force) return; + + var bodywidth = body.width(); + + this.scrollbarwidth = window.innerWidth - bodywidth; + + body.css(this.paddingdir, this.scrollbarwidth); + + this.element.css('overflow-y', this.scrollbarwidth ? 'scroll' : 'auto'); + + if (!this.updateScrollable() && this.options.center) { + + var dh = this.dialog.outerHeight(), + pad = parseInt(this.dialog.css('margin-top'), 10) + parseInt(this.dialog.css('margin-bottom'), 10); + + if ((dh + pad) < window.innerHeight) { + this.dialog.css({'top': (window.innerHeight/2 - dh/2) - pad }); + } else { + this.dialog.css({'top': ''}); + } + } + }, + + updateScrollable: function() { + + // has scrollable? + var scrollable = this.dialog.find('.uk-overflow-container:visible:first'); + + if (scrollable.length) { + + scrollable.css('height', 0); + + var offset = Math.abs(parseInt(this.dialog.css('margin-top'), 10)), + dh = this.dialog.outerHeight(), + wh = window.innerHeight, + h = wh - 2*(offset < 20 ? 20:offset) - dh; + + scrollable.css({ + 'max-height': (h < this.options.minScrollHeight ? '':h), + 'height':'' + }); + + return true; + } + + return false; + }, + + _hide: function() { + + this.active = false; + if (activeCount > 0) activeCount--; + else activeCount = 0; + + this.element.hide().removeClass('uk-open'); + + // Update ARIA + this.element.attr('aria-hidden', 'true'); + + if (!activeCount) { + $html.removeClass('uk-modal-page'); + body.css(this.paddingdir, ""); + } + + if (active===this) active = false; + + this.trigger('hide.uk.modal'); + }, + + isActive: function() { + return this.element.hasClass('uk-open'); + } + + }); + + UI.component('modalTrigger', { + + boot: function() { + + // init code + UI.$html.on("click.modal.uikit", "[data-uk-modal]", function(e) { + + var ele = UI.$(this); + + if (ele.is("a")) { + e.preventDefault(); + } + + if (!ele.data("modalTrigger")) { + var modal = UI.modalTrigger(ele, UI.Utils.options(ele.attr("data-uk-modal"))); + modal.show(); + } + + }); + + // close modal on esc button + UI.$html.on('keydown.modal.uikit', function (e) { + + if (active && e.keyCode === 27 && active.options.keyboard) { // ESC + e.preventDefault(); + active.hide(); + } + }); + }, + + init: function() { + + var $this = this; + + this.options = UI.$.extend({ + "target": $this.element.is("a") ? $this.element.attr("href") : false + }, this.options); + + this.modal = UI.modal(this.options.target, this.options); + + this.on("click", function(e) { + e.preventDefault(); + $this.show(); + }); + + //methods + this.proxy(this.modal, "show hide isActive"); + } + }); + + UI.modal.dialog = function(content, options) { + + var modal = UI.modal(UI.$(UI.modal.dialog.template).appendTo("body"), options); + + modal.on("hide.uk.modal", function(){ + if (modal.persist) { + modal.persist.appendTo(modal.persist.data("modalPersistParent")); + modal.persist = false; + } + modal.element.remove(); + }); + + setContent(content, modal); + + return modal; + }; + + UI.modal.dialog.template = '
          '; + + UI.modal.alert = function(content, options) { + + options = UI.$.extend(true, {bgclose:false, keyboard:false, modal:false, labels:UI.modal.labels}, options); + + var modal = UI.modal.dialog(([ + '
          '+String(content)+'
          ', + '' + ]).join(""), options); + + modal.on('show.uk.modal', function(){ + setTimeout(function(){ + modal.element.find('button:first').focus(); + }, 50); + }); + + return modal.show(); + }; + + UI.modal.confirm = function(content, onconfirm, oncancel) { + + var options = arguments.length > 1 && arguments[arguments.length-1] ? arguments[arguments.length-1] : {}; + + onconfirm = UI.$.isFunction(onconfirm) ? onconfirm : function(){}; + oncancel = UI.$.isFunction(oncancel) ? oncancel : function(){}; + options = UI.$.extend(true, {bgclose:false, keyboard:false, modal:false, labels:UI.modal.labels}, UI.$.isFunction(options) ? {}:options); + + var modal = UI.modal.dialog(([ + '
          '+String(content)+'
          ', + '' + ]).join(""), options); + + modal.element.find(".js-modal-confirm, .js-modal-confirm-cancel").on("click", function(){ + UI.$(this).is('.js-modal-confirm') ? onconfirm() : oncancel(); + modal.hide(); + }); + + modal.on('show.uk.modal', function(){ + setTimeout(function(){ + modal.element.find('.js-modal-confirm').focus(); + }, 50); + }); + + return modal.show(); + }; + + UI.modal.prompt = function(text, value, onsubmit, options) { + + onsubmit = UI.$.isFunction(onsubmit) ? onsubmit : function(value){}; + options = UI.$.extend(true, {bgclose:false, keyboard:false, modal:false, labels:UI.modal.labels}, options); + + var modal = UI.modal.dialog(([ + text ? '
          '+String(text)+'
          ':'', + '

          ', + '' + ]).join(""), options), + + input = modal.element.find("input[type='text']").val(value || '').on('keyup', function(e){ + if (e.keyCode == 13) { + modal.element.find(".js-modal-ok").trigger('click'); + } + }); + + modal.element.find(".js-modal-ok").on("click", function(){ + if (onsubmit(input.val())!==false){ + modal.hide(); + } + }); + + modal.on('show.uk.modal', function(){ + setTimeout(function(){ + input.focus(); + }, 50); + }); + + return modal.show(); + }; + + UI.modal.blockUI = function(content, options) { + + var modal = UI.modal.dialog(([ + '
          '+String(content || '
          ...
          ')+'
          ' + ]).join(""), UI.$.extend({bgclose:false, keyboard:false, modal:false}, options)); + + modal.content = modal.element.find('.uk-modal-content:first'); + + return modal.show(); + }; + + + UI.modal.labels = { + 'Ok': 'Ok', + 'Cancel': 'Cancel' + }; + + + // helper functions + function setContent(content, modal){ + + if(!modal) return; + + if (typeof content === 'object') { + + // convert DOM object to a jQuery object + content = content instanceof jQuery ? content : UI.$(content); + + if(content.parent().length) { + modal.persist = content; + modal.persist.data("modalPersistParent", content.parent()); + } + }else if (typeof content === 'string' || typeof content === 'number') { + // just insert the data as innerHTML + content = UI.$('
          ').html(content); + }else { + // unsupported data type! + content = UI.$('
          ').html('UIkit.modal Error: Unsupported data type: ' + typeof content); + } + + content.appendTo(modal.element.find('.uk-modal-dialog')); + + return modal; + } + +})(UIkit); diff --git a/js/core/modal.min.js b/js/core/modal.min.js new file mode 100755 index 0000000..6dc903a --- /dev/null +++ b/js/core/modal.min.js @@ -0,0 +1,2 @@ +/*! UIkit 2.26.4 | http://www.getuikit.com | (c) 2014 YOOtheme | MIT License */ +!function(t){"use strict";function i(i,e){return e?("object"==typeof i?(i=i instanceof jQuery?i:t.$(i),i.parent().length&&(e.persist=i,e.persist.data("modalPersistParent",i.parent()))):i="string"==typeof i||"number"==typeof i?t.$("
          ").html(i):t.$("
          ").html("UIkit.modal Error: Unsupported data type: "+typeof i),i.appendTo(e.element.find(".uk-modal-dialog")),e):void 0}var e,o=!1,n=0,s=t.$html;t.$win.on("resize orientationchange",t.Utils.debounce(function(){t.$(".uk-modal.uk-open").each(function(){t.$(this).data("modal").resize()})},150)),t.component("modal",{defaults:{keyboard:!0,bgclose:!0,minScrollHeight:150,center:!1,modal:!0},scrollable:!1,transition:!1,hasTransitioned:!0,init:function(){if(e||(e=t.$("body")),this.element.length){var i=this;this.paddingdir="padding-"+("left"==t.langdirection?"right":"left"),this.dialog=this.find(".uk-modal-dialog"),this.active=!1,this.element.attr("aria-hidden",this.element.hasClass("uk-open")),this.on("click",".uk-modal-close",function(t){t.preventDefault(),i.hide()}).on("click",function(e){var o=t.$(e.target);o[0]==i.element[0]&&i.options.bgclose&&i.hide()}),t.domObserve(this.element,function(){i.resize()})}},toggle:function(){return this[this.isActive()?"hide":"show"]()},show:function(){if(this.element.length){var i=this;if(!this.isActive())return this.options.modal&&o&&o.hide(!0),this.element.removeClass("uk-open").show(),this.resize(!0),this.options.modal&&(o=this),this.active=!0,n++,t.support.transition?(this.hasTransitioned=!1,this.element.one(t.support.transition.end,function(){i.hasTransitioned=!0}).addClass("uk-open")):this.element.addClass("uk-open"),s.addClass("uk-modal-page").height(),this.element.attr("aria-hidden","false"),this.element.trigger("show.uk.modal"),t.Utils.checkDisplay(this.dialog,!0),this}},hide:function(i){if(!i&&t.support.transition&&this.hasTransitioned){var e=this;this.one(t.support.transition.end,function(){e._hide()}).removeClass("uk-open")}else this._hide();return this},resize:function(t){if(this.isActive()||t){var i=e.width();if(this.scrollbarwidth=window.innerWidth-i,e.css(this.paddingdir,this.scrollbarwidth),this.element.css("overflow-y",this.scrollbarwidth?"scroll":"auto"),!this.updateScrollable()&&this.options.center){var o=this.dialog.outerHeight(),n=parseInt(this.dialog.css("margin-top"),10)+parseInt(this.dialog.css("margin-bottom"),10);o+ni?20:i)-e;return t.css({"max-height":n0?n--:n=0,this.element.hide().removeClass("uk-open"),this.element.attr("aria-hidden","true"),n||(s.removeClass("uk-modal-page"),e.css(this.paddingdir,"")),o===this&&(o=!1),this.trigger("hide.uk.modal")},isActive:function(){return this.element.hasClass("uk-open")}}),t.component("modalTrigger",{boot:function(){t.$html.on("click.modal.uikit","[data-uk-modal]",function(i){var e=t.$(this);if(e.is("a")&&i.preventDefault(),!e.data("modalTrigger")){var o=t.modalTrigger(e,t.Utils.options(e.attr("data-uk-modal")));o.show()}}),t.$html.on("keydown.modal.uikit",function(t){o&&27===t.keyCode&&o.options.keyboard&&(t.preventDefault(),o.hide())})},init:function(){var i=this;this.options=t.$.extend({target:i.element.is("a")?i.element.attr("href"):!1},this.options),this.modal=t.modal(this.options.target,this.options),this.on("click",function(t){t.preventDefault(),i.show()}),this.proxy(this.modal,"show hide isActive")}}),t.modal.dialog=function(e,o){var n=t.modal(t.$(t.modal.dialog.template).appendTo("body"),o);return n.on("hide.uk.modal",function(){n.persist&&(n.persist.appendTo(n.persist.data("modalPersistParent")),n.persist=!1),n.element.remove()}),i(e,n),n},t.modal.dialog.template='
          ',t.modal.alert=function(i,e){e=t.$.extend(!0,{bgclose:!1,keyboard:!1,modal:!1,labels:t.modal.labels},e);var o=t.modal.dialog(['
          '+String(i)+"
          ",'"].join(""),e);return o.on("show.uk.modal",function(){setTimeout(function(){o.element.find("button:first").focus()},50)}),o.show()},t.modal.confirm=function(i,e,o){var n=arguments.length>1&&arguments[arguments.length-1]?arguments[arguments.length-1]:{};e=t.$.isFunction(e)?e:function(){},o=t.$.isFunction(o)?o:function(){},n=t.$.extend(!0,{bgclose:!1,keyboard:!1,modal:!1,labels:t.modal.labels},t.$.isFunction(n)?{}:n);var s=t.modal.dialog(['
          '+String(i)+"
          ",'"].join(""),n);return s.element.find(".js-modal-confirm, .js-modal-confirm-cancel").on("click",function(){t.$(this).is(".js-modal-confirm")?e():o(),s.hide()}),s.on("show.uk.modal",function(){setTimeout(function(){s.element.find(".js-modal-confirm").focus()},50)}),s.show()},t.modal.prompt=function(i,e,o,n){o=t.$.isFunction(o)?o:function(){},n=t.$.extend(!0,{bgclose:!1,keyboard:!1,modal:!1,labels:t.modal.labels},n);var s=t.modal.dialog([i?'
          '+String(i)+"
          ":"",'

          ','"].join(""),n),a=s.element.find("input[type='text']").val(e||"").on("keyup",function(t){13==t.keyCode&&s.element.find(".js-modal-ok").trigger("click")});return s.element.find(".js-modal-ok").on("click",function(){o(a.val())!==!1&&s.hide()}),s.on("show.uk.modal",function(){setTimeout(function(){a.focus()},50)}),s.show()},t.modal.blockUI=function(i,e){var o=t.modal.dialog(['
          '+String(i||'
          ...
          ')+"
          "].join(""),t.$.extend({bgclose:!1,keyboard:!1,modal:!1},e));return o.content=o.element.find(".uk-modal-content:first"),o.show()},t.modal.labels={Ok:"Ok",Cancel:"Cancel"}}(UIkit); \ No newline at end of file diff --git a/js/core/nav.js b/js/core/nav.js new file mode 100755 index 0000000..a6157ab --- /dev/null +++ b/js/core/nav.js @@ -0,0 +1,136 @@ +/*! UIkit 2.26.4 | http://www.getuikit.com | (c) 2014 YOOtheme | MIT License */ +(function(UI) { + + "use strict"; + + UI.component('nav', { + + defaults: { + "toggle": ">li.uk-parent > a[href='#']", + "lists": ">li.uk-parent > ul", + "multiple": false + }, + + boot: function() { + + // init code + UI.ready(function(context) { + + UI.$("[data-uk-nav]", context).each(function() { + var nav = UI.$(this); + + if (!nav.data("nav")) { + var obj = UI.nav(nav, UI.Utils.options(nav.attr("data-uk-nav"))); + } + }); + }); + }, + + init: function() { + + var $this = this; + + this.on("click.uk.nav", this.options.toggle, function(e) { + e.preventDefault(); + var ele = UI.$(this); + $this.open(ele.parent()[0] == $this.element[0] ? ele : ele.parent("li")); + }); + + this.find(this.options.lists).each(function() { + var $ele = UI.$(this), + parent = $ele.parent(), + active = parent.hasClass("uk-active"); + + $ele.wrap('
          '); + parent.data("list-container", $ele.parent()[active ? 'removeClass':'addClass']('uk-hidden')); + + // Init ARIA + parent.attr('aria-expanded', parent.hasClass("uk-open")); + + if (active) $this.open(parent, true); + }); + + }, + + open: function(li, noanimation) { + + var $this = this, element = this.element, $li = UI.$(li), $container = $li.data('list-container'); + + if (!this.options.multiple) { + + element.children('.uk-open').not(li).each(function() { + + var ele = UI.$(this); + + if (ele.data('list-container')) { + ele.data('list-container').stop().animate({height: 0}, function() { + UI.$(this).parent().removeClass('uk-open').end().addClass('uk-hidden'); + }); + } + }); + } + + $li.toggleClass('uk-open'); + + // Update ARIA + $li.attr('aria-expanded', $li.hasClass('uk-open')); + + if ($container) { + + if ($li.hasClass('uk-open')) { + $container.removeClass('uk-hidden'); + } + + if (noanimation) { + + $container.stop().height($li.hasClass('uk-open') ? 'auto' : 0); + + if (!$li.hasClass('uk-open')) { + $container.addClass('uk-hidden'); + } + + this.trigger('display.uk.check'); + + } else { + + $container.stop().animate({ + height: ($li.hasClass('uk-open') ? getHeight($container.find('ul:first')) : 0) + }, function() { + + if (!$li.hasClass('uk-open')) { + $container.addClass('uk-hidden'); + } else { + $container.css('height', ''); + } + + $this.trigger('display.uk.check'); + }); + } + } + } + }); + + + // 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; + } + +})(UIkit); diff --git a/js/core/nav.min.js b/js/core/nav.min.js new file mode 100755 index 0000000..3ee579c --- /dev/null +++ b/js/core/nav.min.js @@ -0,0 +1,2 @@ +/*! UIkit 2.26.4 | http://www.getuikit.com | (c) 2014 YOOtheme | MIT License */ +!function(i){"use strict";function t(t){var s=i.$(t),a="auto";if(s.is(":visible"))a=s.outerHeight();else{var e={position:s.css("position"),visibility:s.css("visibility"),display:s.css("display")};a=s.css({position:"absolute",visibility:"hidden",display:"block"}).outerHeight(),s.css(e)}return a}i.component("nav",{defaults:{toggle:">li.uk-parent > a[href='#']",lists:">li.uk-parent > ul",multiple:!1},boot:function(){i.ready(function(t){i.$("[data-uk-nav]",t).each(function(){var t=i.$(this);if(!t.data("nav")){i.nav(t,i.Utils.options(t.attr("data-uk-nav")))}})})},init:function(){var t=this;this.on("click.uk.nav",this.options.toggle,function(s){s.preventDefault();var a=i.$(this);t.open(a.parent()[0]==t.element[0]?a:a.parent("li"))}),this.find(this.options.lists).each(function(){var s=i.$(this),a=s.parent(),e=a.hasClass("uk-active");s.wrap('
          '),a.data("list-container",s.parent()[e?"removeClass":"addClass"]("uk-hidden")),a.attr("aria-expanded",a.hasClass("uk-open")),e&&t.open(a,!0)})},open:function(s,a){var e=this,n=this.element,o=i.$(s),l=o.data("list-container");this.options.multiple||n.children(".uk-open").not(s).each(function(){var t=i.$(this);t.data("list-container")&&t.data("list-container").stop().animate({height:0},function(){i.$(this).parent().removeClass("uk-open").end().addClass("uk-hidden")})}),o.toggleClass("uk-open"),o.attr("aria-expanded",o.hasClass("uk-open")),l&&(o.hasClass("uk-open")&&l.removeClass("uk-hidden"),a?(l.stop().height(o.hasClass("uk-open")?"auto":0),o.hasClass("uk-open")||l.addClass("uk-hidden"),this.trigger("display.uk.check")):l.stop().animate({height:o.hasClass("uk-open")?t(l.find("ul:first")):0},function(){o.hasClass("uk-open")?l.css("height",""):l.addClass("uk-hidden"),e.trigger("display.uk.check")}))}})}(UIkit); \ No newline at end of file diff --git a/js/core/offcanvas.js b/js/core/offcanvas.js new file mode 100755 index 0000000..9b2c289 --- /dev/null +++ b/js/core/offcanvas.js @@ -0,0 +1,180 @@ +/*! UIkit 2.26.4 | http://www.getuikit.com | (c) 2014 YOOtheme | MIT License */ +(function(UI) { + + "use strict"; + + var scrollpos = {x: window.scrollX, y: window.scrollY}, + $win = UI.$win, + $doc = UI.$doc, + $html = UI.$html, + Offcanvas = { + + show: function(element) { + + element = UI.$(element); + + if (!element.length) return; + + var $body = UI.$('body'), + bar = element.find(".uk-offcanvas-bar:first"), + rtl = (UI.langdirection == "right"), + flip = bar.hasClass("uk-offcanvas-bar-flip") ? -1:1, + dir = flip * (rtl ? -1 : 1), + + scrollbarwidth = window.innerWidth - $body.width(); + + scrollpos = {x: window.pageXOffset, y: window.pageYOffset}; + + element.addClass("uk-active"); + + $body.css({"width": window.innerWidth - scrollbarwidth, "height": window.innerHeight}).addClass("uk-offcanvas-page"); + $body.css((rtl ? "margin-right" : "margin-left"), (rtl ? -1 : 1) * (bar.outerWidth() * dir)).width(); // .width() - force redraw + + $html.css('margin-top', scrollpos.y * -1); + + bar.addClass("uk-offcanvas-bar-show"); + + this._initElement(element); + + bar.trigger('show.uk.offcanvas', [element, bar]); + + // Update ARIA + element.attr('aria-hidden', 'false'); + }, + + hide: function(force) { + + var $body = UI.$('body'), + panel = UI.$(".uk-offcanvas.uk-active"), + rtl = (UI.langdirection == "right"), + bar = panel.find(".uk-offcanvas-bar:first"), + finalize = function() { + $body.removeClass("uk-offcanvas-page").css({"width": "", "height": "", "margin-left": "", "margin-right": ""}); + panel.removeClass("uk-active"); + + bar.removeClass("uk-offcanvas-bar-show"); + $html.css('margin-top', ''); + window.scrollTo(scrollpos.x, scrollpos.y); + bar.trigger('hide.uk.offcanvas', [panel, bar]); + + // Update ARIA + panel.attr('aria-hidden', 'true'); + }; + + if (!panel.length) return; + + if (UI.support.transition && !force) { + + $body.one(UI.support.transition.end, function() { + finalize(); + }).css((rtl ? "margin-right" : "margin-left"), ""); + + setTimeout(function(){ + bar.removeClass("uk-offcanvas-bar-show"); + }, 0); + + } else { + finalize(); + } + }, + + _initElement: function(element) { + + if (element.data("OffcanvasInit")) return; + + element.on("click.uk.offcanvas swipeRight.uk.offcanvas swipeLeft.uk.offcanvas", function(e) { + + var target = UI.$(e.target); + + if (!e.type.match(/swipe/)) { + + if (!target.hasClass("uk-offcanvas-close")) { + if (target.hasClass("uk-offcanvas-bar")) return; + if (target.parents(".uk-offcanvas-bar:first").length) return; + } + } + + e.stopImmediatePropagation(); + Offcanvas.hide(); + }); + + element.on("click", "a[href*='#']", function(e){ + + var link = UI.$(this), + href = link.attr("href"); + + if (href == "#") { + return; + } + + UI.$doc.one('hide.uk.offcanvas', function() { + + var target; + + try { + target = UI.$(link[0].hash); + } catch (e){ + target = ''; + } + + if (!target.length) { + target = UI.$('[name="'+link[0].hash.replace('#','')+'"]'); + } + + if (target.length && UI.Utils.scrollToElement) { + UI.Utils.scrollToElement(target, UI.Utils.options(link.attr('data-uk-smooth-scroll') || '{}')); + } else { + window.location.href = href; + } + }); + + Offcanvas.hide(); + }); + + element.data("OffcanvasInit", true); + } + }; + + UI.component('offcanvasTrigger', { + + boot: function() { + + // init code + $html.on("click.offcanvas.uikit", "[data-uk-offcanvas]", function(e) { + + e.preventDefault(); + + var ele = UI.$(this); + + if (!ele.data("offcanvasTrigger")) { + var obj = UI.offcanvasTrigger(ele, UI.Utils.options(ele.attr("data-uk-offcanvas"))); + ele.trigger("click"); + } + }); + + $html.on('keydown.uk.offcanvas', function(e) { + + if (e.keyCode === 27) { // ESC + Offcanvas.hide(); + } + }); + }, + + init: function() { + + var $this = this; + + this.options = UI.$.extend({ + "target": $this.element.is("a") ? $this.element.attr("href") : false + }, this.options); + + this.on("click", function(e) { + e.preventDefault(); + Offcanvas.show($this.options.target); + }); + } + }); + + UI.offcanvas = Offcanvas; + +})(UIkit); diff --git a/js/core/offcanvas.min.js b/js/core/offcanvas.min.js new file mode 100755 index 0000000..faa3887 --- /dev/null +++ b/js/core/offcanvas.min.js @@ -0,0 +1,2 @@ +/*! UIkit 2.26.4 | http://www.getuikit.com | (c) 2014 YOOtheme | MIT License */ +!function(a){"use strict";var t={x:window.scrollX,y:window.scrollY},n=(a.$win,a.$doc,a.$html),i={show:function(i){if(i=a.$(i),i.length){var o=a.$("body"),s=i.find(".uk-offcanvas-bar:first"),e="right"==a.langdirection,f=s.hasClass("uk-offcanvas-bar-flip")?-1:1,r=f*(e?-1:1),c=window.innerWidth-o.width();t={x:window.pageXOffset,y:window.pageYOffset},i.addClass("uk-active"),o.css({width:window.innerWidth-c,height:window.innerHeight}).addClass("uk-offcanvas-page"),o.css(e?"margin-right":"margin-left",(e?-1:1)*s.outerWidth()*r).width(),n.css("margin-top",-1*t.y),s.addClass("uk-offcanvas-bar-show"),this._initElement(i),s.trigger("show.uk.offcanvas",[i,s]),i.attr("aria-hidden","false")}},hide:function(i){var o=a.$("body"),s=a.$(".uk-offcanvas.uk-active"),e="right"==a.langdirection,f=s.find(".uk-offcanvas-bar:first"),r=function(){o.removeClass("uk-offcanvas-page").css({width:"",height:"","margin-left":"","margin-right":""}),s.removeClass("uk-active"),f.removeClass("uk-offcanvas-bar-show"),n.css("margin-top",""),window.scrollTo(t.x,t.y),f.trigger("hide.uk.offcanvas",[s,f]),s.attr("aria-hidden","true")};s.length&&(a.support.transition&&!i?(o.one(a.support.transition.end,function(){r()}).css(e?"margin-right":"margin-left",""),setTimeout(function(){f.removeClass("uk-offcanvas-bar-show")},0)):r())},_initElement:function(t){t.data("OffcanvasInit")||(t.on("click.uk.offcanvas swipeRight.uk.offcanvas swipeLeft.uk.offcanvas",function(t){var n=a.$(t.target);if(!t.type.match(/swipe/)&&!n.hasClass("uk-offcanvas-close")){if(n.hasClass("uk-offcanvas-bar"))return;if(n.parents(".uk-offcanvas-bar:first").length)return}t.stopImmediatePropagation(),i.hide()}),t.on("click","a[href*='#']",function(){var t=a.$(this),n=t.attr("href");"#"!=n&&(a.$doc.one("hide.uk.offcanvas",function(){var i;try{i=a.$(t[0].hash)}catch(o){i=""}i.length||(i=a.$('[name="'+t[0].hash.replace("#","")+'"]')),i.length&&a.Utils.scrollToElement?a.Utils.scrollToElement(i,a.Utils.options(t.attr("data-uk-smooth-scroll")||"{}")):window.location.href=n}),i.hide())}),t.data("OffcanvasInit",!0))}};a.component("offcanvasTrigger",{boot:function(){n.on("click.offcanvas.uikit","[data-uk-offcanvas]",function(t){t.preventDefault();var n=a.$(this);if(!n.data("offcanvasTrigger")){{a.offcanvasTrigger(n,a.Utils.options(n.attr("data-uk-offcanvas")))}n.trigger("click")}}),n.on("keydown.uk.offcanvas",function(a){27===a.keyCode&&i.hide()})},init:function(){var t=this;this.options=a.$.extend({target:t.element.is("a")?t.element.attr("href"):!1},this.options),this.on("click",function(a){a.preventDefault(),i.show(t.options.target)})}}),a.offcanvas=i}(UIkit); \ No newline at end of file diff --git a/js/core/scrollspy.js b/js/core/scrollspy.js new file mode 100755 index 0000000..a67e2c8 --- /dev/null +++ b/js/core/scrollspy.js @@ -0,0 +1,209 @@ +/*! UIkit 2.26.4 | http://www.getuikit.com | (c) 2014 YOOtheme | MIT License */ +(function(UI) { + + "use strict"; + + var $win = UI.$win, + $doc = UI.$doc, + scrollspies = [], + checkScrollSpy = function() { + for(var i=0; i < scrollspies.length; i++) { + window.requestAnimationFrame.apply(window, [scrollspies[i].check]); + } + }; + + UI.component('scrollspy', { + + defaults: { + "target" : false, + "cls" : "uk-scrollspy-inview", + "initcls" : "uk-scrollspy-init-inview", + "topoffset" : 0, + "leftoffset" : 0, + "repeat" : false, + "delay" : 0 + }, + + boot: function() { + + // listen to scroll and resize + $doc.on("scrolling.uk.document", checkScrollSpy); + $win.on("load resize orientationchange", UI.Utils.debounce(checkScrollSpy, 50)); + + // init code + UI.ready(function(context) { + + UI.$("[data-uk-scrollspy]", context).each(function() { + + var element = UI.$(this); + + if (!element.data("scrollspy")) { + var obj = UI.scrollspy(element, UI.Utils.options(element.attr("data-uk-scrollspy"))); + } + }); + }); + }, + + init: function() { + + var $this = this, inviewstate, initinview, togglecls = this.options.cls.split(/,/), fn = function(){ + + var elements = $this.options.target ? $this.element.find($this.options.target) : $this.element, + delayIdx = elements.length === 1 ? 1 : 0, + toggleclsIdx = 0; + + elements.each(function(idx){ + + var element = UI.$(this), + inviewstate = element.data('inviewstate'), + inview = UI.Utils.isInView(element, $this.options), + toggle = element.data('ukScrollspyCls') || togglecls[toggleclsIdx].trim(); + + if (inview && !inviewstate && !element.data('scrollspy-idle')) { + + if (!initinview) { + element.addClass($this.options.initcls); + $this.offset = element.offset(); + initinview = true; + + element.trigger("init.uk.scrollspy"); + } + + element.data('scrollspy-idle', setTimeout(function(){ + + element.addClass("uk-scrollspy-inview").toggleClass(toggle).width(); + element.trigger("inview.uk.scrollspy"); + + element.data('scrollspy-idle', false); + element.data('inviewstate', true); + + }, $this.options.delay * delayIdx)); + + delayIdx++; + } + + if (!inview && inviewstate && $this.options.repeat) { + + if (element.data('scrollspy-idle')) { + clearTimeout(element.data('scrollspy-idle')); + element.data('scrollspy-idle', false); + } + + element.removeClass("uk-scrollspy-inview").toggleClass(toggle); + element.data('inviewstate', false); + + element.trigger("outview.uk.scrollspy"); + } + + toggleclsIdx = togglecls[toggleclsIdx + 1] ? (toggleclsIdx + 1) : 0; + + }); + }; + + fn(); + + this.check = fn; + + scrollspies.push(this); + } + }); + + + var scrollspynavs = [], + checkScrollSpyNavs = function() { + for(var i=0; i < scrollspynavs.length; i++) { + window.requestAnimationFrame.apply(window, [scrollspynavs[i].check]); + } + }; + + UI.component('scrollspynav', { + + defaults: { + "cls" : 'uk-active', + "closest" : false, + "topoffset" : 0, + "leftoffset" : 0, + "smoothscroll" : false + }, + + boot: function() { + + // listen to scroll and resize + $doc.on("scrolling.uk.document", checkScrollSpyNavs); + $win.on("resize orientationchange", UI.Utils.debounce(checkScrollSpyNavs, 50)); + + // init code + UI.ready(function(context) { + + UI.$("[data-uk-scrollspy-nav]", context).each(function() { + + var element = UI.$(this); + + if (!element.data("scrollspynav")) { + var obj = UI.scrollspynav(element, UI.Utils.options(element.attr("data-uk-scrollspy-nav"))); + } + }); + }); + }, + + init: function() { + + var ids = [], + links = this.find("a[href^='#']").each(function(){ if(this.getAttribute("href").trim()!=='#') ids.push(this.getAttribute("href")); }), + targets = UI.$(ids.join(",")), + + clsActive = this.options.cls, + clsClosest = this.options.closest || this.options.closest; + + var $this = this, inviews, fn = function(){ + + inviews = []; + + for (var i=0 ; i < targets.length ; i++) { + if (UI.Utils.isInView(targets.eq(i), $this.options)) { + inviews.push(targets.eq(i)); + } + } + + if (inviews.length) { + + var navitems, + scrollTop = $win.scrollTop(), + target = (function(){ + for(var i=0; i< inviews.length;i++){ + if (inviews[i].offset().top - $this.options.topoffset >= scrollTop){ + return inviews[i]; + } + } + })(); + + if (!target) return; + + if ($this.options.closest) { + links.blur().closest(clsClosest).removeClass(clsActive); + navitems = links.filter("a[href='#"+target.attr("id")+"']").closest(clsClosest).addClass(clsActive); + } else { + navitems = links.removeClass(clsActive).filter("a[href='#"+target.attr("id")+"']").addClass(clsActive); + } + + $this.element.trigger("inview.uk.scrollspynav", [target, navitems]); + } + }; + + if (this.options.smoothscroll && UI.smoothScroll) { + links.each(function(){ + UI.smoothScroll(this, $this.options.smoothscroll); + }); + } + + fn(); + + this.element.data("scrollspynav", this); + + this.check = fn; + scrollspynavs.push(this); + + } + }); + +})(UIkit); diff --git a/js/core/scrollspy.min.js b/js/core/scrollspy.min.js new file mode 100755 index 0000000..74d651b --- /dev/null +++ b/js/core/scrollspy.min.js @@ -0,0 +1,2 @@ +/*! UIkit 2.26.4 | http://www.getuikit.com | (c) 2014 YOOtheme | MIT License */ +!function(t){"use strict";var s=t.$win,o=t.$doc,i=[],e=function(){for(var t=0;t=p)return o[t]}();if(!f)return;c.options.closest?(e.blur().closest(r).removeClass(a),l=e.filter("a[href='#"+f.attr("id")+"']").closest(r).addClass(a)):l=e.removeClass(a).filter("a[href='#"+f.attr("id")+"']").addClass(a),c.element.trigger("inview.uk.scrollspynav",[f,l])}};this.options.smoothscroll&&t.smoothScroll&&e.each(function(){t.smoothScroll(this,c.options.smoothscroll)}),p(),this.element.data("scrollspynav",this),this.check=p,l.push(this)}})}(UIkit); \ No newline at end of file diff --git a/js/core/smooth-scroll.js b/js/core/smooth-scroll.js new file mode 100755 index 0000000..789e426 --- /dev/null +++ b/js/core/smooth-scroll.js @@ -0,0 +1,62 @@ +/*! UIkit 2.26.4 | http://www.getuikit.com | (c) 2014 YOOtheme | MIT License */ +(function(UI) { + + "use strict"; + + UI.component('smoothScroll', { + + boot: function() { + + // init code + UI.$html.on("click.smooth-scroll.uikit", "[data-uk-smooth-scroll]", function(e) { + var ele = UI.$(this); + + if (!ele.data("smoothScroll")) { + var obj = UI.smoothScroll(ele, UI.Utils.options(ele.attr("data-uk-smooth-scroll"))); + ele.trigger("click"); + } + + return false; + }); + }, + + init: function() { + + var $this = this; + + this.on("click", function(e) { + e.preventDefault(); + scrollToElement(UI.$(this.hash).length ? UI.$(this.hash) : UI.$("body"), $this.options); + }); + } + }); + + function scrollToElement(ele, options) { + + options = UI.$.extend({ + duration: 1000, + transition: 'easeOutExpo', + offset: 0, + complete: function(){} + }, options); + + // get / set parameters + var target = ele.offset().top - options.offset, + docheight = UI.$doc.height(), + winheight = window.innerHeight; + + if ((target + winheight) > docheight) { + target = docheight - winheight; + } + + // animate to target, fire callback when done + UI.$("html,body").stop().animate({scrollTop: target}, options.duration, options.transition).promise().done(options.complete); + } + + UI.Utils.scrollToElement = scrollToElement; + + if (!UI.$.easing.easeOutExpo) { + UI.$.easing.easeOutExpo = function(x, t, b, c, d) { return (t == d) ? b + c : c * (-Math.pow(2, -10 * t / d) + 1) + b; }; + } + +})(UIkit); diff --git a/js/core/smooth-scroll.min.js b/js/core/smooth-scroll.min.js new file mode 100755 index 0000000..5968d4e --- /dev/null +++ b/js/core/smooth-scroll.min.js @@ -0,0 +1,2 @@ +/*! UIkit 2.26.4 | http://www.getuikit.com | (c) 2014 YOOtheme | MIT License */ +!function(t){"use strict";function o(o,i){i=t.$.extend({duration:1e3,transition:"easeOutExpo",offset:0,complete:function(){}},i);var n=o.offset().top-i.offset,s=t.$doc.height(),e=window.innerHeight;n+e>s&&(n=s-e),t.$("html,body").stop().animate({scrollTop:n},i.duration,i.transition).promise().done(i.complete)}t.component("smoothScroll",{boot:function(){t.$html.on("click.smooth-scroll.uikit","[data-uk-smooth-scroll]",function(){var o=t.$(this);if(!o.data("smoothScroll")){{t.smoothScroll(o,t.Utils.options(o.attr("data-uk-smooth-scroll")))}o.trigger("click")}return!1})},init:function(){var i=this;this.on("click",function(n){n.preventDefault(),o(t.$(this.hash).length?t.$(this.hash):t.$("body"),i.options)})}}),t.Utils.scrollToElement=o,t.$.easing.easeOutExpo||(t.$.easing.easeOutExpo=function(t,o,i,n,s){return o==s?i+n:n*(-Math.pow(2,-10*o/s)+1)+i})}(UIkit); \ No newline at end of file diff --git a/js/core/switcher.js b/js/core/switcher.js new file mode 100755 index 0000000..793eb3c --- /dev/null +++ b/js/core/switcher.js @@ -0,0 +1,307 @@ +/*! UIkit 2.26.4 | http://www.getuikit.com | (c) 2014 YOOtheme | MIT License */ +(function(UI) { + + "use strict"; + + var Animations; + + UI.component('switcher', { + + defaults: { + connect : false, + toggle : ">*", + active : 0, + animation : false, + duration : 200, + swiping : true + }, + + animating: false, + + boot: function() { + + // init code + UI.ready(function(context) { + + UI.$("[data-uk-switcher]", context).each(function() { + var switcher = UI.$(this); + + if (!switcher.data("switcher")) { + var obj = UI.switcher(switcher, UI.Utils.options(switcher.attr("data-uk-switcher"))); + } + }); + }); + }, + + init: function() { + + var $this = this; + + this.on("click.uk.switcher", this.options.toggle, function(e) { + e.preventDefault(); + $this.show(this); + }); + + if (this.options.connect) { + + this.connect = UI.$(this.options.connect); + + this.connect.children().removeClass("uk-active"); + + // delegate switch commands within container content + if (this.connect.length) { + + // Init ARIA for connect + this.connect.children().attr('aria-hidden', 'true'); + + this.connect.on("click", '[data-uk-switcher-item]', function(e) { + + e.preventDefault(); + + var item = UI.$(this).attr('data-uk-switcher-item'); + + if ($this.index == item) return; + + switch(item) { + case 'next': + case 'previous': + $this.show($this.index + (item=='next' ? 1:-1)); + break; + default: + $this.show(parseInt(item, 10)); + } + }); + + if (this.options.swiping) { + + this.connect.on('swipeRight swipeLeft', function(e) { + e.preventDefault(); + if(!window.getSelection().toString()) { + $this.show($this.index + (e.type == 'swipeLeft' ? 1 : -1)); + } + }); + } + } + + var toggles = this.find(this.options.toggle), + active = toggles.filter(".uk-active"); + + if (active.length) { + this.show(active, false); + } else { + + if (this.options.active===false) return; + + active = toggles.eq(this.options.active); + this.show(active.length ? active : toggles.eq(0), false); + } + + // Init ARIA for toggles + toggles.not(active).attr('aria-expanded', 'false'); + active.attr('aria-expanded', 'true'); + } + + }, + + show: function(tab, animate) { + + if (this.animating) { + return; + } + + if (isNaN(tab)) { + tab = UI.$(tab); + } else { + + var toggles = this.find(this.options.toggle); + + tab = tab < 0 ? toggles.length-1 : tab; + tab = toggles.eq(toggles[tab] ? tab : 0); + } + + var $this = this, + toggles = this.find(this.options.toggle), + active = UI.$(tab), + animation = Animations[this.options.animation] || function(current, next) { + + if (!$this.options.animation) { + return Animations.none.apply($this); + } + + var anim = $this.options.animation.split(','); + + if (anim.length == 1) { + anim[1] = anim[0]; + } + + anim[0] = anim[0].trim(); + anim[1] = anim[1].trim(); + + return coreAnimation.apply($this, [anim, current, next]); + }; + + if (animate===false || !UI.support.animation) { + animation = Animations.none; + } + + if (active.hasClass("uk-disabled")) return; + + // Update ARIA for Toggles + toggles.attr('aria-expanded', 'false'); + active.attr('aria-expanded', 'true'); + + toggles.filter(".uk-active").removeClass("uk-active"); + active.addClass("uk-active"); + + if (this.options.connect && this.connect.length) { + + this.index = this.find(this.options.toggle).index(active); + + if (this.index == -1 ) { + this.index = 0; + } + + this.connect.each(function() { + + var container = UI.$(this), + children = UI.$(container.children()), + current = UI.$(children.filter('.uk-active')), + next = UI.$(children.eq($this.index)); + + $this.animating = true; + + animation.apply($this, [current, next]).then(function(){ + + current.removeClass("uk-active"); + next.addClass("uk-active"); + + // Update ARIA for connect + current.attr('aria-hidden', 'true'); + next.attr('aria-hidden', 'false'); + + UI.Utils.checkDisplay(next, true); + + $this.animating = false; + + }); + }); + } + + this.trigger("show.uk.switcher", [active]); + } + }); + + 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 (current && current.index() > next.index()) { + anim.reverse(); + } + + return coreAnimation.apply(this, [anim, current, next]); + }, + + 'slide-left': function(current, next) { + return coreAnimation.apply(this, ['uk-animation-slide-left', current, next]); + }, + + 'slide-right': function(current, next) { + return coreAnimation.apply(this, ['uk-animation-slide-right', current, next]); + }, + + 'slide-horizontal': function(current, next, dir) { + + var anim = ['uk-animation-slide-right', 'uk-animation-slide-left']; + + if (current && current.index() > next.index()) { + anim.reverse(); + } + + return coreAnimation.apply(this, [anim, current, next]); + }, + + 'scale': function(current, next) { + return coreAnimation.apply(this, ['uk-animation-scale-up', current, next]); + } + }; + + UI.switcher.animations = Animations; + + + // helpers + + function coreAnimation(cls, current, next) { + + var d = UI.$.Deferred(), clsIn = cls, clsOut = cls, release; + + if (next[0]===current[0]) { + d.resolve(); + return d.promise(); + } + + if (typeof(cls) == 'object') { + clsIn = cls[0]; + clsOut = cls[1] || cls[0]; + } + + UI.$body.css('overflow-x', 'hidden'); // fix scroll jumping in iOS + + release = function() { + + if (current) current.hide().removeClass('uk-active '+clsOut+' uk-animation-reverse'); + + next.addClass(clsIn).one(UI.support.animation.end, function() { + + setTimeout(function () { + next.removeClass(''+clsIn+'').css({opacity:'', display:''}); + }, 0); + + d.resolve(); + + UI.$body.css('overflow-x', ''); + + if (current) current.css({opacity:'', display:''}); + + }.bind(this)).show(); + }; + + next.css('animation-duration', this.options.duration+'ms'); + + if (current && current.length) { + + current.css('animation-duration', this.options.duration+'ms'); + + current.css('display', 'none').addClass(clsOut+' uk-animation-reverse').one(UI.support.animation.end, function() { + release(); + }.bind(this)).css('display', ''); + + } else { + next.addClass('uk-active'); + release(); + } + + return d.promise(); + } + +})(UIkit); diff --git a/js/core/switcher.min.js b/js/core/switcher.min.js new file mode 100755 index 0000000..9c4bc36 --- /dev/null +++ b/js/core/switcher.min.js @@ -0,0 +1,2 @@ +/*! UIkit 2.26.4 | http://www.getuikit.com | (c) 2014 YOOtheme | MIT License */ +!function(t){"use strict";function i(i,n,e){var s,a=t.$.Deferred(),o=i,r=i;return e[0]===n[0]?(a.resolve(),a.promise()):("object"==typeof i&&(o=i[0],r=i[1]||i[0]),t.$body.css("overflow-x","hidden"),s=function(){n&&n.hide().removeClass("uk-active "+r+" uk-animation-reverse"),e.addClass(o).one(t.support.animation.end,function(){setTimeout(function(){e.removeClass(""+o).css({opacity:"",display:""})},0),a.resolve(),t.$body.css("overflow-x",""),n&&n.css({opacity:"",display:""})}.bind(this)).show()},e.css("animation-duration",this.options.duration+"ms"),n&&n.length?(n.css("animation-duration",this.options.duration+"ms"),n.css("display","none").addClass(r+" uk-animation-reverse").one(t.support.animation.end,function(){s()}.bind(this)).css("display","")):(e.addClass("uk-active"),s()),a.promise())}var n;t.component("switcher",{defaults:{connect:!1,toggle:">*",active:0,animation:!1,duration:200,swiping:!0},animating:!1,boot:function(){t.ready(function(i){t.$("[data-uk-switcher]",i).each(function(){var i=t.$(this);if(!i.data("switcher")){t.switcher(i,t.Utils.options(i.attr("data-uk-switcher")))}})})},init:function(){var i=this;if(this.on("click.uk.switcher",this.options.toggle,function(t){t.preventDefault(),i.show(this)}),this.options.connect){this.connect=t.$(this.options.connect),this.connect.children().removeClass("uk-active"),this.connect.length&&(this.connect.children().attr("aria-hidden","true"),this.connect.on("click","[data-uk-switcher-item]",function(n){n.preventDefault();var e=t.$(this).attr("data-uk-switcher-item");if(i.index!=e)switch(e){case"next":case"previous":i.show(i.index+("next"==e?1:-1));break;default:i.show(parseInt(e,10))}}),this.options.swiping&&this.connect.on("swipeRight swipeLeft",function(t){t.preventDefault(),window.getSelection().toString()||i.show(i.index+("swipeLeft"==t.type?1:-1))}));var n=this.find(this.options.toggle),e=n.filter(".uk-active");if(e.length)this.show(e,!1);else{if(this.options.active===!1)return;e=n.eq(this.options.active),this.show(e.length?e:n.eq(0),!1)}n.not(e).attr("aria-expanded","false"),e.attr("aria-expanded","true")}},show:function(e,s){if(!this.animating){if(isNaN(e))e=t.$(e);else{var a=this.find(this.options.toggle);e=0>e?a.length-1:e,e=a.eq(a[e]?e:0)}var o=this,a=this.find(this.options.toggle),r=t.$(e),c=n[this.options.animation]||function(t,e){if(!o.options.animation)return n.none.apply(o);var s=o.options.animation.split(",");return 1==s.length&&(s[1]=s[0]),s[0]=s[0].trim(),s[1]=s[1].trim(),i.apply(o,[s,t,e])};s!==!1&&t.support.animation||(c=n.none),r.hasClass("uk-disabled")||(a.attr("aria-expanded","false"),r.attr("aria-expanded","true"),a.filter(".uk-active").removeClass("uk-active"),r.addClass("uk-active"),this.options.connect&&this.connect.length&&(this.index=this.find(this.options.toggle).index(r),-1==this.index&&(this.index=0),this.connect.each(function(){var i=t.$(this),n=t.$(i.children()),e=t.$(n.filter(".uk-active")),s=t.$(n.eq(o.index));o.animating=!0,c.apply(o,[e,s]).then(function(){e.removeClass("uk-active"),s.addClass("uk-active"),e.attr("aria-hidden","true"),s.attr("aria-hidden","false"),t.Utils.checkDisplay(s,!0),o.animating=!1})})),this.trigger("show.uk.switcher",[r]))}}}),n={none:function(){var i=t.$.Deferred();return i.resolve(),i.promise()},fade:function(t,n){return i.apply(this,["uk-animation-fade",t,n])},"slide-bottom":function(t,n){return i.apply(this,["uk-animation-slide-bottom",t,n])},"slide-top":function(t,n){return i.apply(this,["uk-animation-slide-top",t,n])},"slide-vertical":function(t,n){var e=["uk-animation-slide-top","uk-animation-slide-bottom"];return t&&t.index()>n.index()&&e.reverse(),i.apply(this,[e,t,n])},"slide-left":function(t,n){return i.apply(this,["uk-animation-slide-left",t,n])},"slide-right":function(t,n){return i.apply(this,["uk-animation-slide-right",t,n])},"slide-horizontal":function(t,n){var e=["uk-animation-slide-right","uk-animation-slide-left"];return t&&t.index()>n.index()&&e.reverse(),i.apply(this,[e,t,n])},scale:function(t,n){return i.apply(this,["uk-animation-scale-up",t,n])}},t.switcher.animations=n}(UIkit); \ No newline at end of file diff --git a/js/core/tab.js b/js/core/tab.js new file mode 100755 index 0000000..4784a6f --- /dev/null +++ b/js/core/tab.js @@ -0,0 +1,167 @@ +/*! UIkit 2.26.4 | http://www.getuikit.com | (c) 2014 YOOtheme | MIT License */ +(function(UI) { + + "use strict"; + + UI.component('tab', { + + defaults: { + 'target' : '>li:not(.uk-tab-responsive, .uk-disabled)', + 'connect' : false, + 'active' : 0, + 'animation' : false, + 'duration' : 200, + 'swiping' : true + }, + + boot: function() { + + // init code + UI.ready(function(context) { + + UI.$("[data-uk-tab]", context).each(function() { + + var tab = UI.$(this); + + if (!tab.data("tab")) { + var obj = UI.tab(tab, UI.Utils.options(tab.attr("data-uk-tab"))); + } + }); + }); + }, + + init: function() { + + var $this = this; + + this.current = false; + + this.on("click.uk.tab", this.options.target, function(e) { + + e.preventDefault(); + + if ($this.switcher && $this.switcher.animating) { + return; + } + + var current = $this.find($this.options.target).not(this); + + current.removeClass("uk-active").blur(); + + $this.trigger("change.uk.tab", [UI.$(this).addClass("uk-active"), $this.current]); + + $this.current = UI.$(this); + + // Update ARIA + if (!$this.options.connect) { + current.attr('aria-expanded', 'false'); + UI.$(this).attr('aria-expanded', 'true'); + } + }); + + if (this.options.connect) { + this.connect = UI.$(this.options.connect); + } + + // init responsive tab + this.responsivetab = UI.$('
        • ').append('
            '); + + this.responsivetab.dropdown = this.responsivetab.find('.uk-dropdown'); + this.responsivetab.lst = this.responsivetab.dropdown.find('ul'); + this.responsivetab.caption = this.responsivetab.find('a:first'); + + if (this.element.hasClass("uk-tab-bottom")) this.responsivetab.dropdown.addClass("uk-dropdown-up"); + + // handle click + this.responsivetab.lst.on('click.uk.tab', 'a', function(e) { + + e.preventDefault(); + e.stopPropagation(); + + var link = UI.$(this); + + $this.element.children('li:not(.uk-tab-responsive)').eq(link.data('index')).trigger('click'); + }); + + this.on('show.uk.switcher change.uk.tab', function(e, tab) { + $this.responsivetab.caption.html(tab.text()); + }); + + this.element.append(this.responsivetab); + + // init UIkit components + if (this.options.connect) { + this.switcher = UI.switcher(this.element, { + 'toggle' : '>li:not(.uk-tab-responsive)', + 'connect' : this.options.connect, + 'active' : this.options.active, + 'animation' : this.options.animation, + 'duration' : this.options.duration, + 'swiping' : this.options.swiping + }); + } + + UI.dropdown(this.responsivetab, {"mode": "click", "preventflip": "y"}); + + // init + $this.trigger("change.uk.tab", [this.element.find(this.options.target).not('.uk-tab-responsive').filter('.uk-active')]); + + this.check(); + + UI.$win.on('resize orientationchange', UI.Utils.debounce(function(){ + if ($this.element.is(":visible")) $this.check(); + }, 100)); + + this.on('display.uk.check', function(){ + if ($this.element.is(":visible")) $this.check(); + }); + }, + + check: function() { + + var children = this.element.children('li:not(.uk-tab-responsive)').removeClass('uk-hidden'); + + if (!children.length) { + this.responsivetab.addClass('uk-hidden'); + return; + } + + var top = (children.eq(0).offset().top + Math.ceil(children.eq(0).height()/2)), + doresponsive = false, + item, link, clone; + + this.responsivetab.lst.empty(); + + children.each(function(){ + + if (UI.$(this).offset().top > top) { + doresponsive = true; + } + }); + + if (doresponsive) { + + for (var i = 0; i < children.length; i++) { + + item = UI.$(children.eq(i)); + link = item.find('a'); + + if (item.css('float') != 'none' && !item.attr('uk-dropdown')) { + + if (!item.hasClass('uk-disabled')) { + + clone = item[0].outerHTML.replace('li:not(.uk-tab-responsive, .uk-disabled)",connect:!1,active:0,animation:!1,duration:200,swiping:!0},boot:function(){t.ready(function(i){t.$("[data-uk-tab]",i).each(function(){var i=t.$(this);if(!i.data("tab")){t.tab(i,t.Utils.options(i.attr("data-uk-tab")))}})})},init:function(){var i=this;this.current=!1,this.on("click.uk.tab",this.options.target,function(e){if(e.preventDefault(),!i.switcher||!i.switcher.animating){var s=i.find(i.options.target).not(this);s.removeClass("uk-active").blur(),i.trigger("change.uk.tab",[t.$(this).addClass("uk-active"),i.current]),i.current=t.$(this),i.options.connect||(s.attr("aria-expanded","false"),t.$(this).attr("aria-expanded","true"))}}),this.options.connect&&(this.connect=t.$(this.options.connect)),this.responsivetab=t.$('
          • ').append('
              '),this.responsivetab.dropdown=this.responsivetab.find(".uk-dropdown"),this.responsivetab.lst=this.responsivetab.dropdown.find("ul"),this.responsivetab.caption=this.responsivetab.find("a:first"),this.element.hasClass("uk-tab-bottom")&&this.responsivetab.dropdown.addClass("uk-dropdown-up"),this.responsivetab.lst.on("click.uk.tab","a",function(e){e.preventDefault(),e.stopPropagation();var s=t.$(this);i.element.children("li:not(.uk-tab-responsive)").eq(s.data("index")).trigger("click")}),this.on("show.uk.switcher change.uk.tab",function(t,e){i.responsivetab.caption.html(e.text())}),this.element.append(this.responsivetab),this.options.connect&&(this.switcher=t.switcher(this.element,{toggle:">li:not(.uk-tab-responsive)",connect:this.options.connect,active:this.options.active,animation:this.options.animation,duration:this.options.duration,swiping:this.options.swiping})),t.dropdown(this.responsivetab,{mode:"click",preventflip:"y"}),i.trigger("change.uk.tab",[this.element.find(this.options.target).not(".uk-tab-responsive").filter(".uk-active")]),this.check(),t.$win.on("resize orientationchange",t.Utils.debounce(function(){i.element.is(":visible")&&i.check()},100)),this.on("display.uk.check",function(){i.element.is(":visible")&&i.check()})},check:function(){var i=this.element.children("li:not(.uk-tab-responsive)").removeClass("uk-hidden");if(!i.length)return this.responsivetab.addClass("uk-hidden"),void 0;var e,s,n,a=i.eq(0).offset().top+Math.ceil(i.eq(0).height()/2),o=!1;if(this.responsivetab.lst.empty(),i.each(function(){t.$(this).offset().top>a&&(o=!0)}),o)for(var r=0;r= Math.abs(y1 - y2) ? (x1 - x2 > 0 ? 'Left' : 'Right') : (y1 - y2 > 0 ? 'Up' : 'Down'); + } + + function longTap() { + longTapTimeout = null; + if (touch.last) { + if ( touch.el !== undefined ) touch.el.trigger('longTap'); + touch = {}; + } + } + + function cancelLongTap() { + if (longTapTimeout) clearTimeout(longTapTimeout); + longTapTimeout = null; + } + + function cancelAll() { + if (touchTimeout) clearTimeout(touchTimeout); + if (tapTimeout) clearTimeout(tapTimeout); + if (swipeTimeout) clearTimeout(swipeTimeout); + if (longTapTimeout) clearTimeout(longTapTimeout); + touchTimeout = tapTimeout = swipeTimeout = longTapTimeout = null; + touch = {}; + } + + function isPrimaryTouch(event){ + return event.pointerType == event.MSPOINTER_TYPE_TOUCH && event.isPrimary; + } + + $(function(){ + var now, delta, deltaX = 0, deltaY = 0, firstTouch; + + if ('MSGesture' in window) { + gesture = new MSGesture(); + gesture.target = document.body; + } + + $(document) + .on('MSGestureEnd gestureend', function(e){ + + var swipeDirectionFromVelocity = e.originalEvent.velocityX > 1 ? 'Right' : e.originalEvent.velocityX < -1 ? 'Left' : e.originalEvent.velocityY > 1 ? 'Down' : e.originalEvent.velocityY < -1 ? 'Up' : null; + + if (swipeDirectionFromVelocity && touch.el !== undefined) { + touch.el.trigger('swipe'); + touch.el.trigger('swipe'+ swipeDirectionFromVelocity); + } + }) + // MSPointerDown: for IE10 + // pointerdown: for IE11 + .on('touchstart MSPointerDown pointerdown', function(e){ + + if(e.type == 'MSPointerDown' && !isPrimaryTouch(e.originalEvent)) return; + + firstTouch = (e.type == 'MSPointerDown' || e.type == 'pointerdown') ? e : e.originalEvent.touches[0]; + + now = Date.now(); + delta = now - (touch.last || now); + touch.el = $('tagName' in firstTouch.target ? firstTouch.target : firstTouch.target.parentNode); + + if(touchTimeout) clearTimeout(touchTimeout); + + touch.x1 = firstTouch.pageX; + touch.y1 = firstTouch.pageY; + + if (delta > 0 && delta <= 250) touch.isDoubleTap = true; + + touch.last = now; + longTapTimeout = setTimeout(longTap, longTapDelay); + + // adds the current touch contact for IE gesture recognition + if (gesture && ( e.type == 'MSPointerDown' || e.type == 'pointerdown' || e.type == 'touchstart' ) ) { + gesture.addPointer(e.originalEvent.pointerId); + } + + }) + // MSPointerMove: for IE10 + // pointermove: for IE11 + .on('touchmove MSPointerMove pointermove', function(e){ + + if (e.type == 'MSPointerMove' && !isPrimaryTouch(e.originalEvent)) return; + + firstTouch = (e.type == 'MSPointerMove' || e.type == 'pointermove') ? e : e.originalEvent.touches[0]; + + cancelLongTap(); + touch.x2 = firstTouch.pageX; + touch.y2 = firstTouch.pageY; + + deltaX += Math.abs(touch.x1 - touch.x2); + deltaY += Math.abs(touch.y1 - touch.y2); + }) + // MSPointerUp: for IE10 + // pointerup: for IE11 + .on('touchend MSPointerUp pointerup', function(e){ + + if (e.type == 'MSPointerUp' && !isPrimaryTouch(e.originalEvent)) return; + + cancelLongTap(); + + // swipe + if ((touch.x2 && Math.abs(touch.x1 - touch.x2) > 30) || (touch.y2 && Math.abs(touch.y1 - touch.y2) > 30)){ + + swipeTimeout = setTimeout(function() { + if ( touch.el !== undefined ) { + touch.el.trigger('swipe'); + touch.el.trigger('swipe' + (swipeDirection(touch.x1, touch.x2, touch.y1, touch.y2))); + } + touch = {}; + }, 0); + + // normal tap + } else if ('last' in touch) { + + // don't fire tap when delta position changed by more than 30 pixels, + // for instance when moving to a point and back to origin + if (isNaN(deltaX) || (deltaX < 30 && deltaY < 30)) { + // delay by one tick so we can cancel the 'tap' event if 'scroll' fires + // ('tap' fires before 'scroll') + tapTimeout = setTimeout(function() { + + // trigger universal 'tap' with the option to cancelTouch() + // (cancelTouch cancels processing of single vs double taps for faster 'tap' response) + var event = $.Event('tap'); + event.cancelTouch = cancelAll; + if ( touch.el !== undefined ) touch.el.trigger(event); + + // trigger double tap immediately + if (touch.isDoubleTap) { + if ( touch.el !== undefined ) touch.el.trigger('doubleTap'); + touch = {}; + } + + // trigger single tap after 250ms of inactivity + else { + touchTimeout = setTimeout(function(){ + touchTimeout = null; + if ( touch.el !== undefined ) touch.el.trigger('singleTap'); + touch = {}; + }, 250); + } + }, 0); + } else { + touch = {}; + } + deltaX = deltaY = 0; + } + }) + // when the browser window loses focus, + // for example when a modal dialog is shown, + // cancel all ongoing events + .on('touchcancel MSPointerCancel', cancelAll); + + // scrolling the window indicates intention of the user + // to scroll, not tap or swipe, so cancel all ongoing events + $(window).on('scroll', cancelAll); + }); + + ['swipe', 'swipeLeft', 'swipeRight', 'swipeUp', 'swipeDown', 'doubleTap', 'tap', 'singleTap', 'longTap'].forEach(function(eventName){ + $.fn[eventName] = function(callback){ return $(this).on(eventName, callback); }; + }); +})(jQuery); diff --git a/js/core/touch.min.js b/js/core/touch.min.js new file mode 100755 index 0000000..b86dfd1 --- /dev/null +++ b/js/core/touch.min.js @@ -0,0 +1,2 @@ +/*! UIkit 2.26.4 | http://www.getuikit.com | (c) 2014 YOOtheme | MIT License */ +!function(e){function t(e,t,n,o){return Math.abs(e-t)>=Math.abs(n-o)?e-t>0?"Left":"Right":n-o>0?"Up":"Down"}function n(){p=null,g.last&&(void 0!==g.el&&g.el.trigger("longTap"),g={})}function o(){p&&clearTimeout(p),p=null}function i(){a&&clearTimeout(a),l&&clearTimeout(l),u&&clearTimeout(u),p&&clearTimeout(p),a=l=u=p=null,g={}}function r(e){return e.pointerType==e.MSPOINTER_TYPE_TOUCH&&e.isPrimary}if(!e.fn.swipeLeft){var a,l,u,p,c,g={},s=750;e(function(){var v,y,w,f=0,d=0;"MSGesture"in window&&(c=new MSGesture,c.target=document.body),e(document).on("MSGestureEnd gestureend",function(e){var t=e.originalEvent.velocityX>1?"Right":e.originalEvent.velocityX<-1?"Left":e.originalEvent.velocityY>1?"Down":e.originalEvent.velocityY<-1?"Up":null;t&&void 0!==g.el&&(g.el.trigger("swipe"),g.el.trigger("swipe"+t))}).on("touchstart MSPointerDown pointerdown",function(t){("MSPointerDown"!=t.type||r(t.originalEvent))&&(w="MSPointerDown"==t.type||"pointerdown"==t.type?t:t.originalEvent.touches[0],v=Date.now(),y=v-(g.last||v),g.el=e("tagName"in w.target?w.target:w.target.parentNode),a&&clearTimeout(a),g.x1=w.pageX,g.y1=w.pageY,y>0&&250>=y&&(g.isDoubleTap=!0),g.last=v,p=setTimeout(n,s),!c||"MSPointerDown"!=t.type&&"pointerdown"!=t.type&&"touchstart"!=t.type||c.addPointer(t.originalEvent.pointerId))}).on("touchmove MSPointerMove pointermove",function(e){("MSPointerMove"!=e.type||r(e.originalEvent))&&(w="MSPointerMove"==e.type||"pointermove"==e.type?e:e.originalEvent.touches[0],o(),g.x2=w.pageX,g.y2=w.pageY,f+=Math.abs(g.x1-g.x2),d+=Math.abs(g.y1-g.y2))}).on("touchend MSPointerUp pointerup",function(n){("MSPointerUp"!=n.type||r(n.originalEvent))&&(o(),g.x2&&Math.abs(g.x1-g.x2)>30||g.y2&&Math.abs(g.y1-g.y2)>30?u=setTimeout(function(){void 0!==g.el&&(g.el.trigger("swipe"),g.el.trigger("swipe"+t(g.x1,g.x2,g.y1,g.y2))),g={}},0):"last"in g&&(isNaN(f)||30>f&&30>d?l=setTimeout(function(){var t=e.Event("tap");t.cancelTouch=i,void 0!==g.el&&g.el.trigger(t),g.isDoubleTap?(void 0!==g.el&&g.el.trigger("doubleTap"),g={}):a=setTimeout(function(){a=null,void 0!==g.el&&g.el.trigger("singleTap"),g={}},250)},0):g={},f=d=0))}).on("touchcancel MSPointerCancel",i),e(window).on("scroll",i)}),["swipe","swipeLeft","swipeRight","swipeUp","swipeDown","doubleTap","tap","singleTap","longTap"].forEach(function(t){e.fn[t]=function(n){return e(this).on(t,n)}})}}(jQuery); \ No newline at end of file diff --git a/js/core/utility.js b/js/core/utility.js new file mode 100755 index 0000000..0090b8c --- /dev/null +++ b/js/core/utility.js @@ -0,0 +1,319 @@ +/*! UIkit 2.26.4 | http://www.getuikit.com | (c) 2014 YOOtheme | MIT License */ +(function(UI) { + + "use strict"; + + var stacks = []; + + UI.component('stackMargin', { + + defaults: { + cls: 'uk-margin-small-top', + rowfirst: false, + observe: false + }, + + boot: function() { + + // init code + UI.ready(function(context) { + + UI.$("[data-uk-margin]", context).each(function() { + + var ele = UI.$(this); + + if (!ele.data("stackMargin")) { + UI.stackMargin(ele, UI.Utils.options(ele.attr("data-uk-margin"))); + } + }); + }); + }, + + init: function() { + + var $this = this; + + UI.$win.on('resize orientationchange', (function() { + + var fn = function() { + $this.process(); + }; + + UI.$(function() { + fn(); + UI.$win.on("load", fn); + }); + + return UI.Utils.debounce(fn, 20); + })()); + + this.on("display.uk.check", function(e) { + if (this.element.is(":visible")) this.process(); + }.bind(this)); + + if (this.options.observe) { + + UI.domObserve(this.element, function(e) { + if ($this.element.is(":visible")) $this.process(); + }); + } + + stacks.push(this); + }, + + process: function() { + + var $this = this, columns = this.element.children(); + + UI.Utils.stackMargin(columns, this.options); + + if (!this.options.rowfirst || !columns.length) { + return this; + } + + // Mark first column elements + var group = {}, minleft = false; + + columns.removeClass(this.options.rowfirst).each(function(offset, $ele){ + + $ele = UI.$(this); + + if (this.style.display != 'none') { + offset = $ele.offset().left; + ((group[offset] = group[offset] || []) && group[offset]).push(this); + minleft = minleft === false ? offset : Math.min(minleft, offset); + } + }); + + UI.$(group[minleft]).addClass(this.options.rowfirst); + + return this; + } + + }); + + + // responsive element e.g. iframes + + (function(){ + + var elements = [], check = function(ele) { + + if (!ele.is(':visible')) return; + + var width = ele.parent().width(), + iwidth = ele.data('width'), + ratio = (width / iwidth), + height = Math.floor(ratio * ele.data('height')); + + ele.css({'height': (width < iwidth) ? height : ele.data('height')}); + }; + + UI.component('responsiveElement', { + + defaults: {}, + + boot: function() { + + // init code + UI.ready(function(context) { + + UI.$("iframe.uk-responsive-width, [data-uk-responsive]", context).each(function() { + + var ele = UI.$(this), obj; + + if (!ele.data("responsiveElement")) { + obj = UI.responsiveElement(ele, {}); + } + }); + }); + }, + + init: function() { + + var ele = this.element; + + if (ele.attr('width') && ele.attr('height')) { + + ele.data({ + + 'width' : ele.attr('width'), + 'height': ele.attr('height') + + }).on('display.uk.check', function(){ + check(ele); + }); + + check(ele); + + elements.push(ele); + } + } + }); + + UI.$win.on('resize load', UI.Utils.debounce(function(){ + + elements.forEach(function(ele){ + check(ele); + }); + + }, 15)); + + })(); + + + + // helper + + UI.Utils.stackMargin = function(elements, options) { + + options = UI.$.extend({ + 'cls': 'uk-margin-small-top' + }, options); + + elements = UI.$(elements).removeClass(options.cls); + + var min = false; + + elements.each(function(offset, height, pos, $ele){ + + $ele = UI.$(this); + + if ($ele.css('display') != 'none') { + + offset = $ele.offset(); + height = $ele.outerHeight(); + pos = offset.top + height; + + $ele.data({ + 'ukMarginPos': pos, + 'ukMarginTop': offset.top + }); + + if (min === false || (offset.top < min.top) ) { + + min = { + top : offset.top, + left : offset.left, + pos : pos + }; + } + } + + }).each(function($ele) { + + $ele = UI.$(this); + + if ($ele.css('display') != 'none' && $ele.data('ukMarginTop') > min.top && $ele.data('ukMarginPos') > min.pos) { + $ele.addClass(options.cls); + } + }); + }; + + UI.Utils.matchHeights = function(elements, options) { + + elements = UI.$(elements).css('min-height', ''); + options = UI.$.extend({ row : true }, options); + + var matchHeights = function(group){ + + if (group.length < 2) return; + + var max = 0; + + group.each(function() { + max = Math.max(max, UI.$(this).outerHeight()); + }).each(function() { + + var element = UI.$(this), + height = max - (element.css('box-sizing') == 'border-box' ? 0 : (element.outerHeight() - element.height())); + + element.css('min-height', height + 'px'); + }); + }; + + if (options.row) { + + elements.first().width(); // force redraw + + setTimeout(function(){ + + var lastoffset = false, group = []; + + elements.each(function() { + + var ele = UI.$(this), offset = ele.offset().top; + + if (offset != lastoffset && group.length) { + + matchHeights(UI.$(group)); + group = []; + offset = ele.offset().top; + } + + group.push(ele); + lastoffset = offset; + }); + + if (group.length) { + matchHeights(UI.$(group)); + } + + }, 0); + + } else { + matchHeights(elements); + } + }; + + (function(cacheSvgs){ + + UI.Utils.inlineSvg = function(selector, root) { + + var images = UI.$(selector || 'img[src$=".svg"]', root || document).each(function(){ + + var img = UI.$(this), + src = img.attr('src'); + + if (!cacheSvgs[src]) { + + var d = UI.$.Deferred(); + + UI.$.get(src, {nc: Math.random()}, function(data){ + d.resolve(UI.$(data).find('svg')); + }); + + cacheSvgs[src] = d.promise(); + } + + cacheSvgs[src].then(function(svg) { + + var $svg = UI.$(svg).clone(); + + if (img.attr('id')) $svg.attr('id', img.attr('id')); + if (img.attr('class')) $svg.attr('class', img.attr('class')); + if (img.attr('style')) $svg.attr('style', img.attr('style')); + + if (img.attr('width')) { + $svg.attr('width', img.attr('width')); + if (!img.attr('height')) $svg.removeAttr('height'); + } + + if (img.attr('height')){ + $svg.attr('height', img.attr('height')); + if (!img.attr('width')) $svg.removeAttr('width'); + } + + img.replaceWith($svg); + }); + }); + }; + + // init code + UI.ready(function(context) { + UI.Utils.inlineSvg('[data-uk-svg]', context); + }); + + })({}); + +})(UIkit); diff --git a/js/core/utility.min.js b/js/core/utility.min.js new file mode 100755 index 0000000..1b8e7ab --- /dev/null +++ b/js/core/utility.min.js @@ -0,0 +1,2 @@ +/*! UIkit 2.26.4 | http://www.getuikit.com | (c) 2014 YOOtheme | MIT License */ +!function(t){"use strict";var i=[];t.component("stackMargin",{defaults:{cls:"uk-margin-small-top",rowfirst:!1,observe:!1},boot:function(){t.ready(function(i){t.$("[data-uk-margin]",i).each(function(){var i=t.$(this);i.data("stackMargin")||t.stackMargin(i,t.Utils.options(i.attr("data-uk-margin")))})})},init:function(){var n=this;t.$win.on("resize orientationchange",function(){var i=function(){n.process()};return t.$(function(){i(),t.$win.on("load",i)}),t.Utils.debounce(i,20)}()),this.on("display.uk.check",function(){this.element.is(":visible")&&this.process()}.bind(this)),this.options.observe&&t.domObserve(this.element,function(){n.element.is(":visible")&&n.process()}),i.push(this)},process:function(){var i=this.element.children();if(t.Utils.stackMargin(i,this.options),!this.options.rowfirst||!i.length)return this;var n={},e=!1;return i.removeClass(this.options.rowfirst).each(function(i,s){s=t.$(this),"none"!=this.style.display&&(i=s.offset().left,((n[i]=n[i]||[])&&n[i]).push(this),e=e===!1?i:Math.min(e,i))}),t.$(n[e]).addClass(this.options.rowfirst),this}}),function(){var i=[],n=function(t){if(t.is(":visible")){var i=t.parent().width(),n=t.data("width"),e=i/n,s=Math.floor(e*t.data("height"));t.css({height:n>i?s:t.data("height")})}};t.component("responsiveElement",{defaults:{},boot:function(){t.ready(function(i){t.$("iframe.uk-responsive-width, [data-uk-responsive]",i).each(function(){var i,n=t.$(this);n.data("responsiveElement")||(i=t.responsiveElement(n,{}))})})},init:function(){var t=this.element;t.attr("width")&&t.attr("height")&&(t.data({width:t.attr("width"),height:t.attr("height")}).on("display.uk.check",function(){n(t)}),n(t),i.push(t))}}),t.$win.on("resize load",t.Utils.debounce(function(){i.forEach(function(t){n(t)})},15))}(),t.Utils.stackMargin=function(i,n){n=t.$.extend({cls:"uk-margin-small-top"},n),i=t.$(i).removeClass(n.cls);var e=!1;i.each(function(i,n,s,a){a=t.$(this),"none"!=a.css("display")&&(i=a.offset(),n=a.outerHeight(),s=i.top+n,a.data({ukMarginPos:s,ukMarginTop:i.top}),(e===!1||i.tope.top&&i.data("ukMarginPos")>e.pos&&i.addClass(n.cls)})},t.Utils.matchHeights=function(i,n){i=t.$(i).css("min-height",""),n=t.$.extend({row:!0},n);var e=function(i){if(!(i.length<2)){var n=0;i.each(function(){n=Math.max(n,t.$(this).outerHeight())}).each(function(){var i=t.$(this),e=n-("border-box"==i.css("box-sizing")?0:i.outerHeight()-i.height());i.css("min-height",e+"px")})}};n.row?(i.first().width(),setTimeout(function(){var n=!1,s=[];i.each(function(){var i=t.$(this),a=i.offset().top;a!=n&&s.length&&(e(t.$(s)),s=[],a=i.offset().top),s.push(i),n=a}),s.length&&e(t.$(s))},0)):e(i)},function(i){t.Utils.inlineSvg=function(n,e){t.$(n||'img[src$=".svg"]',e||document).each(function(){var n=t.$(this),e=n.attr("src");if(!i[e]){var s=t.$.Deferred();t.$.get(e,{nc:Math.random()},function(i){s.resolve(t.$(i).find("svg"))}),i[e]=s.promise()}i[e].then(function(i){var e=t.$(i).clone();n.attr("id")&&e.attr("id",n.attr("id")),n.attr("class")&&e.attr("class",n.attr("class")),n.attr("style")&&e.attr("style",n.attr("style")),n.attr("width")&&(e.attr("width",n.attr("width")),n.attr("height")||e.removeAttr("height")),n.attr("height")&&(e.attr("height",n.attr("height")),n.attr("width")||e.removeAttr("width")),n.replaceWith(e)})})},t.ready(function(i){t.Utils.inlineSvg("[data-uk-svg]",i)})}({})}(UIkit); \ No newline at end of file diff --git a/js/uikit.js b/js/uikit.js new file mode 100755 index 0000000..cf8b403 --- /dev/null +++ b/js/uikit.js @@ -0,0 +1,3814 @@ +/*! UIkit 2.26.4 | http://www.getuikit.com | (c) 2014 YOOtheme | MIT License */ +(function(core) { + + if (typeof define == "function" && define.amd) { // AMD + + define("uikit", function(){ + + var uikit = window.UIkit || core(window, window.jQuery, window.document); + + uikit.load = function(res, req, onload, config) { + + var resources = res.split(','), load = [], i, base = (config.config && config.config.uikit && config.config.uikit.base ? config.config.uikit.base : "").replace(/\/+$/g, ""); + + if (!base) { + throw new Error( "Please define base path to UIkit in the requirejs config." ); + } + + for (i = 0; i < resources.length; i += 1) { + var resource = resources[i].replace(/\./g, '/'); + load.push(base+'/components/'+resource); + } + + req(load, function() { + onload(uikit); + }); + }; + + return uikit; + }); + } + + if (!window.jQuery) { + throw new Error( "UIkit requires jQuery" ); + } + + if (window && window.jQuery) { + core(window, window.jQuery, window.document); + } + + +})(function(global, $, doc) { + + "use strict"; + + var UI = {}, _UI = global.UIkit ? Object.create(global.UIkit) : undefined; + + UI.version = '2.26.4'; + + UI.noConflict = function() { + // restore UIkit version + if (_UI) { + global.UIkit = _UI; + $.UIkit = _UI; + $.fn.uk = _UI.fn; + } + + return UI; + }; + + UI.prefix = function(str) { + return str; + }; + + // cache jQuery + UI.$ = $; + + UI.$doc = UI.$(document); + UI.$win = UI.$(window); + UI.$html = UI.$('html'); + + UI.support = {}; + UI.support.transition = (function() { + + var transitionEnd = (function() { + + var element = doc.body || doc.documentElement, + transEndEventNames = { + WebkitTransition : 'webkitTransitionEnd', + MozTransition : 'transitionend', + OTransition : 'oTransitionEnd otransitionend', + transition : 'transitionend' + }, name; + + for (name in transEndEventNames) { + if (element.style[name] !== undefined) return transEndEventNames[name]; + } + }()); + + return transitionEnd && { end: transitionEnd }; + })(); + + UI.support.animation = (function() { + + var animationEnd = (function() { + + var element = doc.body || doc.documentElement, + animEndEventNames = { + WebkitAnimation : 'webkitAnimationEnd', + MozAnimation : 'animationend', + OAnimation : 'oAnimationEnd oanimationend', + animation : 'animationend' + }, name; + + for (name in animEndEventNames) { + if (element.style[name] !== undefined) return animEndEventNames[name]; + } + }()); + + return animationEnd && { end: animationEnd }; + })(); + + // requestAnimationFrame polyfill + //https://github.com/darius/requestAnimationFrame + (function() { + + Date.now = Date.now || function() { return new Date().getTime(); }; + + var vendors = ['webkit', 'moz']; + for (var i = 0; i < vendors.length && !window.requestAnimationFrame; ++i) { + var vp = vendors[i]; + window.requestAnimationFrame = window[vp+'RequestAnimationFrame']; + window.cancelAnimationFrame = (window[vp+'CancelAnimationFrame'] + || window[vp+'CancelRequestAnimationFrame']); + } + if (/iP(ad|hone|od).*OS 6/.test(window.navigator.userAgent) // iOS6 is buggy + || !window.requestAnimationFrame || !window.cancelAnimationFrame) { + var lastTime = 0; + window.requestAnimationFrame = function(callback) { + var now = Date.now(); + var nextTime = Math.max(lastTime + 16, now); + return setTimeout(function() { callback(lastTime = nextTime); }, + nextTime - now); + }; + window.cancelAnimationFrame = clearTimeout; + } + }()); + + UI.support.touch = ( + ('ontouchstart' in document) || + (global.DocumentTouch && document instanceof global.DocumentTouch) || + (global.navigator.msPointerEnabled && global.navigator.msMaxTouchPoints > 0) || //IE 10 + (global.navigator.pointerEnabled && global.navigator.maxTouchPoints > 0) || //IE >=11 + false + ); + + UI.support.mutationobserver = (global.MutationObserver || global.WebKitMutationObserver || null); + + UI.Utils = {}; + + UI.Utils.isFullscreen = function() { + return document.webkitFullscreenElement || document.mozFullScreenElement || document.msFullscreenElement || document.fullscreenElement || false; + }; + + UI.Utils.str2json = function(str, notevil) { + try { + if (notevil) { + return JSON.parse(str + // wrap keys without quote with valid double quote + .replace(/([\$\w]+)\s*:/g, function(_, $1){return '"'+$1+'":';}) + // replacing single quote wrapped ones to double quote + .replace(/'([^']+)'/g, function(_, $1){return '"'+$1+'"';}) + ); + } else { + return (new Function("", "var json = " + str + "; return JSON.parse(JSON.stringify(json));"))(); + } + } catch(e) { return false; } + }; + + UI.Utils.debounce = function(func, wait, immediate) { + var timeout; + return function() { + var context = this, args = arguments; + var later = function() { + timeout = null; + if (!immediate) func.apply(context, args); + }; + var callNow = immediate && !timeout; + clearTimeout(timeout); + timeout = setTimeout(later, wait); + if (callNow) func.apply(context, args); + }; + }; + + UI.Utils.throttle = function (func, limit) { + var wait = false; + return function () { + if (!wait) { + func.call(); + wait = true; + setTimeout(function () { + wait = false; + }, limit); + } + } + }; + + UI.Utils.removeCssRules = function(selectorRegEx) { + var idx, idxs, stylesheet, _i, _j, _k, _len, _len1, _len2, _ref; + + if(!selectorRegEx) return; + + setTimeout(function(){ + try { + _ref = document.styleSheets; + for (_i = 0, _len = _ref.length; _i < _len; _i++) { + stylesheet = _ref[_i]; + idxs = []; + stylesheet.cssRules = stylesheet.cssRules; + for (idx = _j = 0, _len1 = stylesheet.cssRules.length; _j < _len1; idx = ++_j) { + if (stylesheet.cssRules[idx].type === CSSRule.STYLE_RULE && selectorRegEx.test(stylesheet.cssRules[idx].selectorText)) { + idxs.unshift(idx); + } + } + for (_k = 0, _len2 = idxs.length; _k < _len2; _k++) { + stylesheet.deleteRule(idxs[_k]); + } + } + } catch (_error) {} + }, 0); + }; + + UI.Utils.isInView = function(element, options) { + + var $element = $(element); + + if (!$element.is(':visible')) { + return false; + } + + var window_left = UI.$win.scrollLeft(), window_top = UI.$win.scrollTop(), offset = $element.offset(), left = offset.left, top = offset.top; + + options = $.extend({topoffset:0, leftoffset:0}, options); + + if (top + $element.height() >= window_top && top - options.topoffset <= window_top + UI.$win.height() && + left + $element.width() >= window_left && left - options.leftoffset <= window_left + UI.$win.width()) { + return true; + } else { + return false; + } + }; + + UI.Utils.checkDisplay = function(context, initanimation) { + + var elements = UI.$('[data-uk-margin], [data-uk-grid-match], [data-uk-grid-margin], [data-uk-check-display]', context || document), animated; + + if (context && !elements.length) { + elements = $(context); + } + + elements.trigger('display.uk.check'); + + // fix firefox / IE animations + if (initanimation) { + + if (typeof(initanimation)!='string') { + initanimation = '[class*="uk-animation-"]'; + } + + elements.find(initanimation).each(function(){ + + var ele = UI.$(this), + cls = ele.attr('class'), + anim = cls.match(/uk-animation-(.+)/); + + ele.removeClass(anim[0]).width(); + + ele.addClass(anim[0]); + }); + } + + return elements; + }; + + UI.Utils.options = function(string) { + + if ($.type(string)!='string') return string; + + if (string.indexOf(':') != -1 && string.trim().substr(-1) != '}') { + string = '{'+string+'}'; + } + + var start = (string ? string.indexOf("{") : -1), options = {}; + + if (start != -1) { + try { + options = UI.Utils.str2json(string.substr(start)); + } catch (e) {} + } + + return options; + }; + + UI.Utils.animate = function(element, cls) { + + var d = $.Deferred(); + + element = UI.$(element); + + element.css('display', 'none').addClass(cls).one(UI.support.animation.end, function() { + element.removeClass(cls); + d.resolve(); + }); + + element.css('display', ''); + + return d.promise(); + }; + + UI.Utils.uid = function(prefix) { + return (prefix || 'id') + (new Date().getTime())+"RAND"+(Math.ceil(Math.random() * 100000)); + }; + + UI.Utils.template = function(str, data) { + + var tokens = str.replace(/\n/g, '\\n').replace(/\{\{\{\s*(.+?)\s*\}\}\}/g, "{{!$1}}").split(/(\{\{\s*(.+?)\s*\}\})/g), + i=0, toc, cmd, prop, val, fn, output = [], openblocks = 0; + + while(i < tokens.length) { + + toc = tokens[i]; + + if(toc.match(/\{\{\s*(.+?)\s*\}\}/)) { + i = i + 1; + toc = tokens[i]; + cmd = toc[0]; + prop = toc.substring(toc.match(/^(\^|\#|\!|\~|\:)/) ? 1:0); + + switch(cmd) { + case '~': + output.push("for(var $i=0;$i<"+prop+".length;$i++) { var $item = "+prop+"[$i];"); + openblocks++; + break; + case ':': + output.push("for(var $key in "+prop+") { var $val = "+prop+"[$key];"); + openblocks++; + break; + case '#': + output.push("if("+prop+") {"); + openblocks++; + break; + case '^': + output.push("if(!"+prop+") {"); + openblocks++; + break; + case '/': + output.push("}"); + openblocks--; + break; + case '!': + output.push("__ret.push("+prop+");"); + break; + default: + output.push("__ret.push(escape("+prop+"));"); + break; + } + } else { + output.push("__ret.push('"+toc.replace(/\'/g, "\\'")+"');"); + } + i = i + 1; + } + + fn = new Function('$data', [ + 'var __ret = [];', + 'try {', + 'with($data){', (!openblocks ? output.join('') : '__ret = ["Not all blocks are closed correctly."]'), '};', + '}catch(e){__ret = [e.message];}', + 'return __ret.join("").replace(/\\n\\n/g, "\\n");', + "function escape(html) { return String(html).replace(/&/g, '&').replace(/\"/g, '"').replace(//g, '>');}" + ].join("\n")); + + return data ? fn(data) : fn; + }; + + UI.Utils.events = {}; + UI.Utils.events.click = UI.support.touch ? 'tap' : 'click'; + + global.UIkit = UI; + + // deprecated + + UI.fn = function(command, options) { + + var args = arguments, cmd = command.match(/^([a-z\-]+)(?:\.([a-z]+))?/i), component = cmd[1], method = cmd[2]; + + if (!UI[component]) { + $.error("UIkit component [" + component + "] does not exist."); + return this; + } + + return this.each(function() { + var $this = $(this), data = $this.data(component); + if (!data) $this.data(component, (data = UI[component](this, method ? undefined : options))); + if (method) data[method].apply(data, Array.prototype.slice.call(args, 1)); + }); + }; + + $.UIkit = UI; + $.fn.uk = UI.fn; + + UI.langdirection = UI.$html.attr("dir") == "rtl" ? "right" : "left"; + + UI.components = {}; + + UI.component = function(name, def) { + + var fn = function(element, options) { + + var $this = this; + + this.UIkit = UI; + this.element = element ? UI.$(element) : null; + this.options = $.extend(true, {}, this.defaults, options); + this.plugins = {}; + + if (this.element) { + this.element.data(name, this); + } + + this.init(); + + (this.options.plugins.length ? this.options.plugins : Object.keys(fn.plugins)).forEach(function(plugin) { + + if (fn.plugins[plugin].init) { + fn.plugins[plugin].init($this); + $this.plugins[plugin] = true; + } + + }); + + this.trigger('init.uk.component', [name, this]); + + return this; + }; + + fn.plugins = {}; + + $.extend(true, fn.prototype, { + + defaults : {plugins: []}, + + boot: function(){}, + init: function(){}, + + on: function(a1,a2,a3){ + return UI.$(this.element || this).on(a1,a2,a3); + }, + + one: function(a1,a2,a3){ + return UI.$(this.element || this).one(a1,a2,a3); + }, + + off: function(evt){ + return UI.$(this.element || this).off(evt); + }, + + trigger: function(evt, params) { + return UI.$(this.element || this).trigger(evt, params); + }, + + find: function(selector) { + return UI.$(this.element ? this.element: []).find(selector); + }, + + proxy: function(obj, methods) { + + var $this = this; + + methods.split(' ').forEach(function(method) { + if (!$this[method]) $this[method] = function() { return obj[method].apply(obj, arguments); }; + }); + }, + + mixin: function(obj, methods) { + + var $this = this; + + methods.split(' ').forEach(function(method) { + if (!$this[method]) $this[method] = obj[method].bind($this); + }); + }, + + option: function() { + + if (arguments.length == 1) { + return this.options[arguments[0]] || undefined; + } else if (arguments.length == 2) { + this.options[arguments[0]] = arguments[1]; + } + } + + }, def); + + this.components[name] = fn; + + this[name] = function() { + + var element, options; + + if (arguments.length) { + + switch(arguments.length) { + case 1: + + if (typeof arguments[0] === "string" || arguments[0].nodeType || arguments[0] instanceof jQuery) { + element = $(arguments[0]); + } else { + options = arguments[0]; + } + + break; + case 2: + + element = $(arguments[0]); + options = arguments[1]; + break; + } + } + + if (element && element.data(name)) { + return element.data(name); + } + + return (new UI.components[name](element, options)); + }; + + if (UI.domready) { + UI.component.boot(name); + } + + return fn; + }; + + UI.plugin = function(component, name, def) { + this.components[component].plugins[name] = def; + }; + + UI.component.boot = function(name) { + + if (UI.components[name].prototype && UI.components[name].prototype.boot && !UI.components[name].booted) { + UI.components[name].prototype.boot.apply(UI, []); + UI.components[name].booted = true; + } + }; + + UI.component.bootComponents = function() { + + for (var component in UI.components) { + UI.component.boot(component); + } + }; + + + // DOM mutation save ready helper function + + UI.domObservers = []; + UI.domready = false; + + UI.ready = function(fn) { + + UI.domObservers.push(fn); + + if (UI.domready) { + fn(document); + } + }; + + UI.on = function(a1,a2,a3){ + + if (a1 && a1.indexOf('ready.uk.dom') > -1 && UI.domready) { + a2.apply(UI.$doc); + } + + return UI.$doc.on(a1,a2,a3); + }; + + UI.one = function(a1,a2,a3){ + + if (a1 && a1.indexOf('ready.uk.dom') > -1 && UI.domready) { + a2.apply(UI.$doc); + return UI.$doc; + } + + return UI.$doc.one(a1,a2,a3); + }; + + UI.trigger = function(evt, params) { + return UI.$doc.trigger(evt, params); + }; + + UI.domObserve = function(selector, fn) { + + if(!UI.support.mutationobserver) return; + + fn = fn || function() {}; + + UI.$(selector).each(function() { + + var element = this, + $element = UI.$(element); + + if ($element.data('observer')) { + return; + } + + try { + + var observer = new UI.support.mutationobserver(UI.Utils.debounce(function(mutations) { + fn.apply(element, []); + $element.trigger('changed.uk.dom'); + }, 50), {childList: true, subtree: true}); + + // pass in the target node, as well as the observer options + observer.observe(element, { childList: true, subtree: true }); + + $element.data('observer', observer); + + } catch(e) {} + }); + }; + + UI.init = function(root) { + + root = root || document; + + UI.domObservers.forEach(function(fn){ + fn(root); + }); + }; + + UI.on('domready.uk.dom', function(){ + + UI.init(); + + if (UI.domready) UI.Utils.checkDisplay(); + }); + + document.addEventListener('DOMContentLoaded', function(){ + + var domReady = function() { + + UI.$body = UI.$('body'); + + UI.trigger('beforeready.uk.dom'); + + UI.component.bootComponents(); + + // custom scroll observer + var rafToken = requestAnimationFrame((function(){ + + var memory = {dir: {x:0, y:0}, x: window.pageXOffset, y:window.pageYOffset}; + + var fn = function(){ + // reading this (window.page[X|Y]Offset) causes a full page recalc of the layout in Chrome, + // so we only want to do this once + var wpxo = window.pageXOffset; + var wpyo = window.pageYOffset; + + // Did the scroll position change since the last time we were here? + if (memory.x != wpxo || memory.y != wpyo) { + + // Set the direction of the scroll and store the new position + if (wpxo != memory.x) {memory.dir.x = wpxo > memory.x ? 1:-1; } else { memory.dir.x = 0; } + if (wpyo != memory.y) {memory.dir.y = wpyo > memory.y ? 1:-1; } else { memory.dir.y = 0; } + + memory.x = wpxo; + memory.y = wpyo; + + // Trigger the scroll event, this could probably be sent using memory.clone() but this is + // more explicit and easier to see exactly what is being sent in the event. + UI.$doc.trigger('scrolling.uk.document', [{ + "dir": {"x": memory.dir.x, "y": memory.dir.y}, "x": wpxo, "y": wpyo + }]); + } + + cancelAnimationFrame(rafToken); + rafToken = requestAnimationFrame(fn); + }; + + if (UI.support.touch) { + UI.$html.on('touchmove touchend MSPointerMove MSPointerUp pointermove pointerup', fn); + } + + if (memory.x || memory.y) fn(); + + return fn; + + })()); + + // run component init functions on dom + UI.trigger('domready.uk.dom'); + + if (UI.support.touch) { + + // remove css hover rules for touch devices + // UI.Utils.removeCssRules(/\.uk-(?!navbar).*:hover/); + + // viewport unit fix for uk-height-viewport - should be fixed in iOS 8 + if (navigator.userAgent.match(/(iPad|iPhone|iPod)/g)) { + + UI.$win.on('load orientationchange resize', UI.Utils.debounce((function(){ + + var fn = function() { + $('.uk-height-viewport').css('height', window.innerHeight); + return fn; + }; + + return fn(); + + })(), 100)); + } + } + + UI.trigger('afterready.uk.dom'); + + // mark that domready is left behind + UI.domready = true; + + // auto init js components + if (UI.support.mutationobserver) { + + var initFn = UI.Utils.debounce(function(){ + requestAnimationFrame(function(){ UI.init(document.body);}); + }, 10); + + (new UI.support.mutationobserver(function(mutations) { + + var init = false; + + mutations.every(function(mutation){ + + if (mutation.type != 'childList') return true; + + for (var i = 0, node; i < mutation.addedNodes.length; ++i) { + + node = mutation.addedNodes[i]; + + if (node.outerHTML && node.outerHTML.indexOf('data-uk-') !== -1) { + return (init = true) && false; + } + } + return true; + }); + + if (init) initFn(); + + })).observe(document.body, {childList: true, subtree: true}); + } + }; + + if (document.readyState == 'complete' || document.readyState == 'interactive') { + setTimeout(domReady); + } + + return domReady; + + }()); + + // add touch identifier class + UI.$html.addClass(UI.support.touch ? "uk-touch" : "uk-notouch"); + + // add uk-hover class on tap to support overlays on touch devices + if (UI.support.touch) { + + var hoverset = false, + exclude, + hovercls = 'uk-hover', + selector = '.uk-overlay, .uk-overlay-hover, .uk-overlay-toggle, .uk-animation-hover, .uk-has-hover'; + + UI.$html.on('mouseenter touchstart MSPointerDown pointerdown', selector, function() { + + if (hoverset) $('.'+hovercls).removeClass(hovercls); + + hoverset = $(this).addClass(hovercls); + + }).on('mouseleave touchend MSPointerUp pointerup', function(e) { + + exclude = $(e.target).parents(selector); + + if (hoverset) { + hoverset.not(exclude).removeClass(hovercls); + } + }); + } + + return UI; +}); + +// Based on Zeptos touch.js +// https://raw.github.com/madrobby/zepto/master/src/touch.js +// Zepto.js may be freely distributed under the MIT license. + +;(function($){ + + if ($.fn.swipeLeft) { + return; + } + + + var touch = {}, touchTimeout, tapTimeout, swipeTimeout, longTapTimeout, longTapDelay = 750, gesture; + + function swipeDirection(x1, x2, y1, y2) { + return Math.abs(x1 - x2) >= Math.abs(y1 - y2) ? (x1 - x2 > 0 ? 'Left' : 'Right') : (y1 - y2 > 0 ? 'Up' : 'Down'); + } + + function longTap() { + longTapTimeout = null; + if (touch.last) { + if ( touch.el !== undefined ) touch.el.trigger('longTap'); + touch = {}; + } + } + + function cancelLongTap() { + if (longTapTimeout) clearTimeout(longTapTimeout); + longTapTimeout = null; + } + + function cancelAll() { + if (touchTimeout) clearTimeout(touchTimeout); + if (tapTimeout) clearTimeout(tapTimeout); + if (swipeTimeout) clearTimeout(swipeTimeout); + if (longTapTimeout) clearTimeout(longTapTimeout); + touchTimeout = tapTimeout = swipeTimeout = longTapTimeout = null; + touch = {}; + } + + function isPrimaryTouch(event){ + return event.pointerType == event.MSPOINTER_TYPE_TOUCH && event.isPrimary; + } + + $(function(){ + var now, delta, deltaX = 0, deltaY = 0, firstTouch; + + if ('MSGesture' in window) { + gesture = new MSGesture(); + gesture.target = document.body; + } + + $(document) + .on('MSGestureEnd gestureend', function(e){ + + var swipeDirectionFromVelocity = e.originalEvent.velocityX > 1 ? 'Right' : e.originalEvent.velocityX < -1 ? 'Left' : e.originalEvent.velocityY > 1 ? 'Down' : e.originalEvent.velocityY < -1 ? 'Up' : null; + + if (swipeDirectionFromVelocity && touch.el !== undefined) { + touch.el.trigger('swipe'); + touch.el.trigger('swipe'+ swipeDirectionFromVelocity); + } + }) + // MSPointerDown: for IE10 + // pointerdown: for IE11 + .on('touchstart MSPointerDown pointerdown', function(e){ + + if(e.type == 'MSPointerDown' && !isPrimaryTouch(e.originalEvent)) return; + + firstTouch = (e.type == 'MSPointerDown' || e.type == 'pointerdown') ? e : e.originalEvent.touches[0]; + + now = Date.now(); + delta = now - (touch.last || now); + touch.el = $('tagName' in firstTouch.target ? firstTouch.target : firstTouch.target.parentNode); + + if(touchTimeout) clearTimeout(touchTimeout); + + touch.x1 = firstTouch.pageX; + touch.y1 = firstTouch.pageY; + + if (delta > 0 && delta <= 250) touch.isDoubleTap = true; + + touch.last = now; + longTapTimeout = setTimeout(longTap, longTapDelay); + + // adds the current touch contact for IE gesture recognition + if (gesture && ( e.type == 'MSPointerDown' || e.type == 'pointerdown' || e.type == 'touchstart' ) ) { + gesture.addPointer(e.originalEvent.pointerId); + } + + }) + // MSPointerMove: for IE10 + // pointermove: for IE11 + .on('touchmove MSPointerMove pointermove', function(e){ + + if (e.type == 'MSPointerMove' && !isPrimaryTouch(e.originalEvent)) return; + + firstTouch = (e.type == 'MSPointerMove' || e.type == 'pointermove') ? e : e.originalEvent.touches[0]; + + cancelLongTap(); + touch.x2 = firstTouch.pageX; + touch.y2 = firstTouch.pageY; + + deltaX += Math.abs(touch.x1 - touch.x2); + deltaY += Math.abs(touch.y1 - touch.y2); + }) + // MSPointerUp: for IE10 + // pointerup: for IE11 + .on('touchend MSPointerUp pointerup', function(e){ + + if (e.type == 'MSPointerUp' && !isPrimaryTouch(e.originalEvent)) return; + + cancelLongTap(); + + // swipe + if ((touch.x2 && Math.abs(touch.x1 - touch.x2) > 30) || (touch.y2 && Math.abs(touch.y1 - touch.y2) > 30)){ + + swipeTimeout = setTimeout(function() { + if ( touch.el !== undefined ) { + touch.el.trigger('swipe'); + touch.el.trigger('swipe' + (swipeDirection(touch.x1, touch.x2, touch.y1, touch.y2))); + } + touch = {}; + }, 0); + + // normal tap + } else if ('last' in touch) { + + // don't fire tap when delta position changed by more than 30 pixels, + // for instance when moving to a point and back to origin + if (isNaN(deltaX) || (deltaX < 30 && deltaY < 30)) { + // delay by one tick so we can cancel the 'tap' event if 'scroll' fires + // ('tap' fires before 'scroll') + tapTimeout = setTimeout(function() { + + // trigger universal 'tap' with the option to cancelTouch() + // (cancelTouch cancels processing of single vs double taps for faster 'tap' response) + var event = $.Event('tap'); + event.cancelTouch = cancelAll; + if ( touch.el !== undefined ) touch.el.trigger(event); + + // trigger double tap immediately + if (touch.isDoubleTap) { + if ( touch.el !== undefined ) touch.el.trigger('doubleTap'); + touch = {}; + } + + // trigger single tap after 250ms of inactivity + else { + touchTimeout = setTimeout(function(){ + touchTimeout = null; + if ( touch.el !== undefined ) touch.el.trigger('singleTap'); + touch = {}; + }, 250); + } + }, 0); + } else { + touch = {}; + } + deltaX = deltaY = 0; + } + }) + // when the browser window loses focus, + // for example when a modal dialog is shown, + // cancel all ongoing events + .on('touchcancel MSPointerCancel', cancelAll); + + // scrolling the window indicates intention of the user + // to scroll, not tap or swipe, so cancel all ongoing events + $(window).on('scroll', cancelAll); + }); + + ['swipe', 'swipeLeft', 'swipeRight', 'swipeUp', 'swipeDown', 'doubleTap', 'tap', 'singleTap', 'longTap'].forEach(function(eventName){ + $.fn[eventName] = function(callback){ return $(this).on(eventName, callback); }; + }); +})(jQuery); + +(function(UI) { + + "use strict"; + + var stacks = []; + + UI.component('stackMargin', { + + defaults: { + cls: 'uk-margin-small-top', + rowfirst: false, + observe: false + }, + + boot: function() { + + // init code + UI.ready(function(context) { + + UI.$("[data-uk-margin]", context).each(function() { + + var ele = UI.$(this); + + if (!ele.data("stackMargin")) { + UI.stackMargin(ele, UI.Utils.options(ele.attr("data-uk-margin"))); + } + }); + }); + }, + + init: function() { + + var $this = this; + + UI.$win.on('resize orientationchange', (function() { + + var fn = function() { + $this.process(); + }; + + UI.$(function() { + fn(); + UI.$win.on("load", fn); + }); + + return UI.Utils.debounce(fn, 20); + })()); + + this.on("display.uk.check", function(e) { + if (this.element.is(":visible")) this.process(); + }.bind(this)); + + if (this.options.observe) { + + UI.domObserve(this.element, function(e) { + if ($this.element.is(":visible")) $this.process(); + }); + } + + stacks.push(this); + }, + + process: function() { + + var $this = this, columns = this.element.children(); + + UI.Utils.stackMargin(columns, this.options); + + if (!this.options.rowfirst || !columns.length) { + return this; + } + + // Mark first column elements + var group = {}, minleft = false; + + columns.removeClass(this.options.rowfirst).each(function(offset, $ele){ + + $ele = UI.$(this); + + if (this.style.display != 'none') { + offset = $ele.offset().left; + ((group[offset] = group[offset] || []) && group[offset]).push(this); + minleft = minleft === false ? offset : Math.min(minleft, offset); + } + }); + + UI.$(group[minleft]).addClass(this.options.rowfirst); + + return this; + } + + }); + + + // responsive element e.g. iframes + + (function(){ + + var elements = [], check = function(ele) { + + if (!ele.is(':visible')) return; + + var width = ele.parent().width(), + iwidth = ele.data('width'), + ratio = (width / iwidth), + height = Math.floor(ratio * ele.data('height')); + + ele.css({'height': (width < iwidth) ? height : ele.data('height')}); + }; + + UI.component('responsiveElement', { + + defaults: {}, + + boot: function() { + + // init code + UI.ready(function(context) { + + UI.$("iframe.uk-responsive-width, [data-uk-responsive]", context).each(function() { + + var ele = UI.$(this), obj; + + if (!ele.data("responsiveElement")) { + obj = UI.responsiveElement(ele, {}); + } + }); + }); + }, + + init: function() { + + var ele = this.element; + + if (ele.attr('width') && ele.attr('height')) { + + ele.data({ + + 'width' : ele.attr('width'), + 'height': ele.attr('height') + + }).on('display.uk.check', function(){ + check(ele); + }); + + check(ele); + + elements.push(ele); + } + } + }); + + UI.$win.on('resize load', UI.Utils.debounce(function(){ + + elements.forEach(function(ele){ + check(ele); + }); + + }, 15)); + + })(); + + + + // helper + + UI.Utils.stackMargin = function(elements, options) { + + options = UI.$.extend({ + 'cls': 'uk-margin-small-top' + }, options); + + elements = UI.$(elements).removeClass(options.cls); + + var min = false; + + elements.each(function(offset, height, pos, $ele){ + + $ele = UI.$(this); + + if ($ele.css('display') != 'none') { + + offset = $ele.offset(); + height = $ele.outerHeight(); + pos = offset.top + height; + + $ele.data({ + 'ukMarginPos': pos, + 'ukMarginTop': offset.top + }); + + if (min === false || (offset.top < min.top) ) { + + min = { + top : offset.top, + left : offset.left, + pos : pos + }; + } + } + + }).each(function($ele) { + + $ele = UI.$(this); + + if ($ele.css('display') != 'none' && $ele.data('ukMarginTop') > min.top && $ele.data('ukMarginPos') > min.pos) { + $ele.addClass(options.cls); + } + }); + }; + + UI.Utils.matchHeights = function(elements, options) { + + elements = UI.$(elements).css('min-height', ''); + options = UI.$.extend({ row : true }, options); + + var matchHeights = function(group){ + + if (group.length < 2) return; + + var max = 0; + + group.each(function() { + max = Math.max(max, UI.$(this).outerHeight()); + }).each(function() { + + var element = UI.$(this), + height = max - (element.css('box-sizing') == 'border-box' ? 0 : (element.outerHeight() - element.height())); + + element.css('min-height', height + 'px'); + }); + }; + + if (options.row) { + + elements.first().width(); // force redraw + + setTimeout(function(){ + + var lastoffset = false, group = []; + + elements.each(function() { + + var ele = UI.$(this), offset = ele.offset().top; + + if (offset != lastoffset && group.length) { + + matchHeights(UI.$(group)); + group = []; + offset = ele.offset().top; + } + + group.push(ele); + lastoffset = offset; + }); + + if (group.length) { + matchHeights(UI.$(group)); + } + + }, 0); + + } else { + matchHeights(elements); + } + }; + + (function(cacheSvgs){ + + UI.Utils.inlineSvg = function(selector, root) { + + var images = UI.$(selector || 'img[src$=".svg"]', root || document).each(function(){ + + var img = UI.$(this), + src = img.attr('src'); + + if (!cacheSvgs[src]) { + + var d = UI.$.Deferred(); + + UI.$.get(src, {nc: Math.random()}, function(data){ + d.resolve(UI.$(data).find('svg')); + }); + + cacheSvgs[src] = d.promise(); + } + + cacheSvgs[src].then(function(svg) { + + var $svg = UI.$(svg).clone(); + + if (img.attr('id')) $svg.attr('id', img.attr('id')); + if (img.attr('class')) $svg.attr('class', img.attr('class')); + if (img.attr('style')) $svg.attr('style', img.attr('style')); + + if (img.attr('width')) { + $svg.attr('width', img.attr('width')); + if (!img.attr('height')) $svg.removeAttr('height'); + } + + if (img.attr('height')){ + $svg.attr('height', img.attr('height')); + if (!img.attr('width')) $svg.removeAttr('width'); + } + + img.replaceWith($svg); + }); + }); + }; + + // init code + UI.ready(function(context) { + UI.Utils.inlineSvg('[data-uk-svg]', context); + }); + + })({}); + +})(UIkit); + +(function(UI) { + + "use strict"; + + UI.component('smoothScroll', { + + boot: function() { + + // init code + UI.$html.on("click.smooth-scroll.uikit", "[data-uk-smooth-scroll]", function(e) { + var ele = UI.$(this); + + if (!ele.data("smoothScroll")) { + var obj = UI.smoothScroll(ele, UI.Utils.options(ele.attr("data-uk-smooth-scroll"))); + ele.trigger("click"); + } + + return false; + }); + }, + + init: function() { + + var $this = this; + + this.on("click", function(e) { + e.preventDefault(); + scrollToElement(UI.$(this.hash).length ? UI.$(this.hash) : UI.$("body"), $this.options); + }); + } + }); + + function scrollToElement(ele, options) { + + options = UI.$.extend({ + duration: 1000, + transition: 'easeOutExpo', + offset: 0, + complete: function(){} + }, options); + + // get / set parameters + var target = ele.offset().top - options.offset, + docheight = UI.$doc.height(), + winheight = window.innerHeight; + + if ((target + winheight) > docheight) { + target = docheight - winheight; + } + + // animate to target, fire callback when done + UI.$("html,body").stop().animate({scrollTop: target}, options.duration, options.transition).promise().done(options.complete); + } + + UI.Utils.scrollToElement = scrollToElement; + + if (!UI.$.easing.easeOutExpo) { + UI.$.easing.easeOutExpo = function(x, t, b, c, d) { return (t == d) ? b + c : c * (-Math.pow(2, -10 * t / d) + 1) + b; }; + } + +})(UIkit); + +(function(UI) { + + "use strict"; + + var $win = UI.$win, + $doc = UI.$doc, + scrollspies = [], + checkScrollSpy = function() { + for(var i=0; i < scrollspies.length; i++) { + window.requestAnimationFrame.apply(window, [scrollspies[i].check]); + } + }; + + UI.component('scrollspy', { + + defaults: { + "target" : false, + "cls" : "uk-scrollspy-inview", + "initcls" : "uk-scrollspy-init-inview", + "topoffset" : 0, + "leftoffset" : 0, + "repeat" : false, + "delay" : 0 + }, + + boot: function() { + + // listen to scroll and resize + $doc.on("scrolling.uk.document", checkScrollSpy); + $win.on("load resize orientationchange", UI.Utils.debounce(checkScrollSpy, 50)); + + // init code + UI.ready(function(context) { + + UI.$("[data-uk-scrollspy]", context).each(function() { + + var element = UI.$(this); + + if (!element.data("scrollspy")) { + var obj = UI.scrollspy(element, UI.Utils.options(element.attr("data-uk-scrollspy"))); + } + }); + }); + }, + + init: function() { + + var $this = this, inviewstate, initinview, togglecls = this.options.cls.split(/,/), fn = function(){ + + var elements = $this.options.target ? $this.element.find($this.options.target) : $this.element, + delayIdx = elements.length === 1 ? 1 : 0, + toggleclsIdx = 0; + + elements.each(function(idx){ + + var element = UI.$(this), + inviewstate = element.data('inviewstate'), + inview = UI.Utils.isInView(element, $this.options), + toggle = element.data('ukScrollspyCls') || togglecls[toggleclsIdx].trim(); + + if (inview && !inviewstate && !element.data('scrollspy-idle')) { + + if (!initinview) { + element.addClass($this.options.initcls); + $this.offset = element.offset(); + initinview = true; + + element.trigger("init.uk.scrollspy"); + } + + element.data('scrollspy-idle', setTimeout(function(){ + + element.addClass("uk-scrollspy-inview").toggleClass(toggle).width(); + element.trigger("inview.uk.scrollspy"); + + element.data('scrollspy-idle', false); + element.data('inviewstate', true); + + }, $this.options.delay * delayIdx)); + + delayIdx++; + } + + if (!inview && inviewstate && $this.options.repeat) { + + if (element.data('scrollspy-idle')) { + clearTimeout(element.data('scrollspy-idle')); + element.data('scrollspy-idle', false); + } + + element.removeClass("uk-scrollspy-inview").toggleClass(toggle); + element.data('inviewstate', false); + + element.trigger("outview.uk.scrollspy"); + } + + toggleclsIdx = togglecls[toggleclsIdx + 1] ? (toggleclsIdx + 1) : 0; + + }); + }; + + fn(); + + this.check = fn; + + scrollspies.push(this); + } + }); + + + var scrollspynavs = [], + checkScrollSpyNavs = function() { + for(var i=0; i < scrollspynavs.length; i++) { + window.requestAnimationFrame.apply(window, [scrollspynavs[i].check]); + } + }; + + UI.component('scrollspynav', { + + defaults: { + "cls" : 'uk-active', + "closest" : false, + "topoffset" : 0, + "leftoffset" : 0, + "smoothscroll" : false + }, + + boot: function() { + + // listen to scroll and resize + $doc.on("scrolling.uk.document", checkScrollSpyNavs); + $win.on("resize orientationchange", UI.Utils.debounce(checkScrollSpyNavs, 50)); + + // init code + UI.ready(function(context) { + + UI.$("[data-uk-scrollspy-nav]", context).each(function() { + + var element = UI.$(this); + + if (!element.data("scrollspynav")) { + var obj = UI.scrollspynav(element, UI.Utils.options(element.attr("data-uk-scrollspy-nav"))); + } + }); + }); + }, + + init: function() { + + var ids = [], + links = this.find("a[href^='#']").each(function(){ if(this.getAttribute("href").trim()!=='#') ids.push(this.getAttribute("href")); }), + targets = UI.$(ids.join(",")), + + clsActive = this.options.cls, + clsClosest = this.options.closest || this.options.closest; + + var $this = this, inviews, fn = function(){ + + inviews = []; + + for (var i=0 ; i < targets.length ; i++) { + if (UI.Utils.isInView(targets.eq(i), $this.options)) { + inviews.push(targets.eq(i)); + } + } + + if (inviews.length) { + + var navitems, + scrollTop = $win.scrollTop(), + target = (function(){ + for(var i=0; i< inviews.length;i++){ + if (inviews[i].offset().top - $this.options.topoffset >= scrollTop){ + return inviews[i]; + } + } + })(); + + if (!target) return; + + if ($this.options.closest) { + links.blur().closest(clsClosest).removeClass(clsActive); + navitems = links.filter("a[href='#"+target.attr("id")+"']").closest(clsClosest).addClass(clsActive); + } else { + navitems = links.removeClass(clsActive).filter("a[href='#"+target.attr("id")+"']").addClass(clsActive); + } + + $this.element.trigger("inview.uk.scrollspynav", [target, navitems]); + } + }; + + if (this.options.smoothscroll && UI.smoothScroll) { + links.each(function(){ + UI.smoothScroll(this, $this.options.smoothscroll); + }); + } + + fn(); + + this.element.data("scrollspynav", this); + + this.check = fn; + scrollspynavs.push(this); + + } + }); + +})(UIkit); + +(function(UI){ + + "use strict"; + + var toggles = []; + + UI.component('toggle', { + + defaults: { + target : false, + cls : 'uk-hidden', + animation : false, + duration : 200 + }, + + boot: function(){ + + // init code + UI.ready(function(context) { + + UI.$("[data-uk-toggle]", context).each(function() { + var ele = UI.$(this); + + if (!ele.data("toggle")) { + var obj = UI.toggle(ele, UI.Utils.options(ele.attr("data-uk-toggle"))); + } + }); + + setTimeout(function(){ + + toggles.forEach(function(toggle){ + toggle.getToggles(); + }); + + }, 0); + }); + }, + + init: function() { + + var $this = this; + + this.aria = (this.options.cls.indexOf('uk-hidden') !== -1); + + this.getToggles(); + + this.on("click", function(e) { + if ($this.element.is('a[href="#"]')) e.preventDefault(); + $this.toggle(); + }); + + toggles.push(this); + }, + + toggle: function() { + + if(!this.totoggle.length) return; + + if (this.options.animation && UI.support.animation) { + + var $this = this, animations = this.options.animation.split(','); + + if (animations.length == 1) { + animations[1] = animations[0]; + } + + animations[0] = animations[0].trim(); + animations[1] = animations[1].trim(); + + this.totoggle.css('animation-duration', this.options.duration+'ms'); + + this.totoggle.each(function(){ + + var ele = UI.$(this); + + if (ele.hasClass($this.options.cls)) { + + ele.toggleClass($this.options.cls); + + UI.Utils.animate(ele, animations[0]).then(function(){ + ele.css('animation-duration', ''); + UI.Utils.checkDisplay(ele); + }); + + } else { + + UI.Utils.animate(this, animations[1]+' uk-animation-reverse').then(function(){ + ele.toggleClass($this.options.cls).css('animation-duration', ''); + UI.Utils.checkDisplay(ele); + }); + + } + + }); + + } else { + this.totoggle.toggleClass(this.options.cls); + UI.Utils.checkDisplay(this.totoggle); + } + + this.updateAria(); + + }, + + getToggles: function() { + this.totoggle = this.options.target ? UI.$(this.options.target):[]; + this.updateAria(); + }, + + updateAria: function() { + if (this.aria && this.totoggle.length) { + this.totoggle.each(function(){ + UI.$(this).attr('aria-hidden', UI.$(this).hasClass('uk-hidden')); + }); + } + } + }); + +})(UIkit); + +(function(UI) { + + "use strict"; + + UI.component('alert', { + + defaults: { + "fade": true, + "duration": 200, + "trigger": ".uk-alert-close" + }, + + boot: function() { + + // init code + UI.$html.on("click.alert.uikit", "[data-uk-alert]", function(e) { + + var ele = UI.$(this); + + if (!ele.data("alert")) { + + var alert = UI.alert(ele, UI.Utils.options(ele.attr("data-uk-alert"))); + + if (UI.$(e.target).is(alert.options.trigger)) { + e.preventDefault(); + alert.close(); + } + } + }); + }, + + init: function() { + + var $this = this; + + this.on("click", this.options.trigger, function(e) { + e.preventDefault(); + $this.close(); + }); + }, + + close: function() { + + var element = this.trigger("close.uk.alert"), + removeElement = function () { + this.trigger("closed.uk.alert").remove(); + }.bind(this); + + if (this.options.fade) { + element.css("overflow", "hidden").css("max-height", element.height()).animate({ + "height" : 0, + "opacity" : 0, + "padding-top" : 0, + "padding-bottom" : 0, + "margin-top" : 0, + "margin-bottom" : 0 + }, this.options.duration, removeElement); + } else { + removeElement(); + } + } + + }); + +})(UIkit); + +(function(UI) { + + "use strict"; + + UI.component('buttonRadio', { + + defaults: { + "activeClass": 'uk-active', + "target": ".uk-button" + }, + + boot: function() { + + // init code + UI.$html.on("click.buttonradio.uikit", "[data-uk-button-radio]", function(e) { + + var ele = UI.$(this); + + if (!ele.data("buttonRadio")) { + + var obj = UI.buttonRadio(ele, UI.Utils.options(ele.attr("data-uk-button-radio"))), + target = UI.$(e.target); + + if (target.is(obj.options.target)) { + target.trigger("click"); + } + } + }); + }, + + init: function() { + + var $this = this; + + // Init ARIA + this.find($this.options.target).attr('aria-checked', 'false').filter('.' + $this.options.activeClass).attr('aria-checked', 'true'); + + this.on("click", this.options.target, function(e) { + + var ele = UI.$(this); + + if (ele.is('a[href="#"]')) e.preventDefault(); + + $this.find($this.options.target).not(ele).removeClass($this.options.activeClass).blur(); + ele.addClass($this.options.activeClass); + + // Update ARIA + $this.find($this.options.target).not(ele).attr('aria-checked', 'false'); + ele.attr('aria-checked', 'true'); + + $this.trigger("change.uk.button", [ele]); + }); + + }, + + getSelected: function() { + return this.find('.' + this.options.activeClass); + } + }); + + UI.component('buttonCheckbox', { + + defaults: { + "activeClass": 'uk-active', + "target": ".uk-button" + }, + + boot: function() { + + UI.$html.on("click.buttoncheckbox.uikit", "[data-uk-button-checkbox]", function(e) { + var ele = UI.$(this); + + if (!ele.data("buttonCheckbox")) { + + var obj = UI.buttonCheckbox(ele, UI.Utils.options(ele.attr("data-uk-button-checkbox"))), + target = UI.$(e.target); + + if (target.is(obj.options.target)) { + target.trigger("click"); + } + } + }); + }, + + init: function() { + + var $this = this; + + // Init ARIA + this.find($this.options.target).attr('aria-checked', 'false').filter('.' + $this.options.activeClass).attr('aria-checked', 'true'); + + this.on("click", this.options.target, function(e) { + var ele = UI.$(this); + + if (ele.is('a[href="#"]')) e.preventDefault(); + + ele.toggleClass($this.options.activeClass).blur(); + + // Update ARIA + ele.attr('aria-checked', ele.hasClass($this.options.activeClass)); + + $this.trigger("change.uk.button", [ele]); + }); + + }, + + getSelected: function() { + return this.find('.' + this.options.activeClass); + } + }); + + + UI.component('button', { + + defaults: {}, + + boot: function() { + + UI.$html.on("click.button.uikit", "[data-uk-button]", function(e) { + var ele = UI.$(this); + + if (!ele.data("button")) { + + var obj = UI.button(ele, UI.Utils.options(ele.attr("data-uk-button"))); + ele.trigger("click"); + } + }); + }, + + init: function() { + + var $this = this; + + // Init ARIA + this.element.attr('aria-pressed', this.element.hasClass("uk-active")); + + this.on("click", function(e) { + + if ($this.element.is('a[href="#"]')) e.preventDefault(); + + $this.toggle(); + $this.trigger("change.uk.button", [$this.element.blur().hasClass("uk-active")]); + }); + + }, + + toggle: function() { + this.element.toggleClass("uk-active"); + + // Update ARIA + this.element.attr('aria-pressed', this.element.hasClass("uk-active")); + } + }); + +})(UIkit); + + +(function(UI) { + + "use strict"; + + var active = false, hoverIdle, flips = { + 'x': { + "bottom-left" : 'bottom-right', + "bottom-right" : 'bottom-left', + "bottom-center" : 'bottom-center', + "top-left" : 'top-right', + "top-right" : 'top-left', + "top-center" : 'top-center', + "left-top" : 'right-top', + "left-bottom" : 'right-bottom', + "left-center" : 'right-center', + "right-top" : 'left-top', + "right-bottom" : 'left-bottom', + "right-center" : 'left-center' + }, + 'y': { + "bottom-left" : 'top-left', + "bottom-right" : 'top-right', + "bottom-center" : 'top-center', + "top-left" : 'bottom-left', + "top-right" : 'bottom-right', + "top-center" : 'bottom-center', + "left-top" : 'left-bottom', + "left-bottom" : 'left-top', + "left-center" : 'left-center', + "right-top" : 'right-bottom', + "right-bottom" : 'right-top', + "right-center" : 'right-center' + }, + 'xy': { + "bottom-left" : 'top-right', + "bottom-right" : 'top-left', + "bottom-center" : 'top-center', + "top-left" : 'bottom-right', + "top-right" : 'bottom-left', + "top-center" : 'bottom-center', + "left-top" : 'right-bottom', + "left-bottom" : 'right-top', + "left-center" : 'right-center', + "right-top" : 'left-bottom', + "right-bottom" : 'left-top', + "right-center" : 'left-center' + } + }; + + UI.component('dropdown', { + + defaults: { + 'mode' : 'hover', + 'pos' : 'bottom-left', + 'offset' : 0, + 'remaintime' : 800, + 'justify' : false, + 'boundary' : UI.$win, + 'delay' : 0, + 'dropdownSelector': '.uk-dropdown,.uk-dropdown-blank', + 'hoverDelayIdle' : 250, + 'preventflip' : false + }, + + remainIdle: false, + + boot: function() { + + var triggerevent = UI.support.touch ? "click" : "mouseenter"; + + // init code + UI.$html.on(triggerevent+".dropdown.uikit", "[data-uk-dropdown]", function(e) { + + var ele = UI.$(this); + + if (!ele.data("dropdown")) { + + var dropdown = UI.dropdown(ele, UI.Utils.options(ele.attr("data-uk-dropdown"))); + + if (triggerevent=="click" || (triggerevent=="mouseenter" && dropdown.options.mode=="hover")) { + dropdown.element.trigger(triggerevent); + } + + if (dropdown.element.find(dropdown.options.dropdownSelector).length) { + e.preventDefault(); + } + } + }); + }, + + init: function() { + + var $this = this; + + this.dropdown = this.find(this.options.dropdownSelector); + this.offsetParent = this.dropdown.parents().filter(function() { + return UI.$.inArray(UI.$(this).css('position'), ['relative', 'fixed', 'absolute']) !== -1; + }).slice(0,1); + + this.centered = this.dropdown.hasClass('uk-dropdown-center'); + this.justified = this.options.justify ? UI.$(this.options.justify) : false; + + this.boundary = UI.$(this.options.boundary); + + if (!this.boundary.length) { + this.boundary = UI.$win; + } + + // legacy DEPRECATED! + if (this.dropdown.hasClass('uk-dropdown-up')) { + this.options.pos = 'top-left'; + } + if (this.dropdown.hasClass('uk-dropdown-flip')) { + this.options.pos = this.options.pos.replace('left','right'); + } + if (this.dropdown.hasClass('uk-dropdown-center')) { + this.options.pos = this.options.pos.replace(/(left|right)/,'center'); + } + //-- end legacy + + // Init ARIA + this.element.attr('aria-haspopup', 'true'); + this.element.attr('aria-expanded', this.element.hasClass("uk-open")); + + if (this.options.mode == "click" || UI.support.touch) { + + this.on("click.uk.dropdown", function(e) { + + var $target = UI.$(e.target); + + if (!$target.parents($this.options.dropdownSelector).length) { + + if ($target.is("a[href='#']") || $target.parent().is("a[href='#']") || ($this.dropdown.length && !$this.dropdown.is(":visible")) ){ + e.preventDefault(); + } + + $target.blur(); + } + + if (!$this.element.hasClass('uk-open')) { + + $this.show(); + + } else { + + if (!$this.dropdown.find(e.target).length || $target.is(".uk-dropdown-close") || $target.parents(".uk-dropdown-close").length) { + $this.hide(); + } + } + }); + + } else { + + this.on("mouseenter", function(e) { + + $this.trigger('pointerenter.uk.dropdown', [$this]); + + if ($this.remainIdle) { + clearTimeout($this.remainIdle); + } + + if (hoverIdle) { + clearTimeout(hoverIdle); + } + + if (active && active == $this) { + return; + } + + // pseudo manuAim + if (active && active != $this) { + + hoverIdle = setTimeout(function() { + hoverIdle = setTimeout($this.show.bind($this), $this.options.delay); + }, $this.options.hoverDelayIdle); + + } else { + + hoverIdle = setTimeout($this.show.bind($this), $this.options.delay); + } + + }).on("mouseleave", function() { + + if (hoverIdle) { + clearTimeout(hoverIdle); + } + + $this.remainIdle = setTimeout(function() { + if (active && active == $this) $this.hide(); + }, $this.options.remaintime); + + $this.trigger('pointerleave.uk.dropdown', [$this]); + + }).on("click", function(e){ + + var $target = UI.$(e.target); + + if ($this.remainIdle) { + clearTimeout($this.remainIdle); + } + + if (active && active == $this) { + if (!$this.dropdown.find(e.target).length || $target.is(".uk-dropdown-close") || $target.parents(".uk-dropdown-close").length) { + $this.hide(); + } + return; + } + + if ($target.is("a[href='#']") || $target.parent().is("a[href='#']")){ + e.preventDefault(); + } + + $this.show(); + }); + } + }, + + show: function(){ + + UI.$html.off("click.outer.dropdown"); + + if (active && active != this) { + active.hide(true); + } + + if (hoverIdle) { + clearTimeout(hoverIdle); + } + + this.trigger('beforeshow.uk.dropdown', [this]); + + this.checkDimensions(); + this.element.addClass('uk-open'); + + // Update ARIA + this.element.attr('aria-expanded', 'true'); + + this.trigger('show.uk.dropdown', [this]); + + UI.Utils.checkDisplay(this.dropdown, true); + active = this; + + this.registerOuterClick(); + }, + + hide: function(force) { + + this.trigger('beforehide.uk.dropdown', [this, force]); + + this.element.removeClass('uk-open'); + + if (this.remainIdle) { + clearTimeout(this.remainIdle); + } + + this.remainIdle = false; + + // Update ARIA + this.element.attr('aria-expanded', 'false'); + + this.trigger('hide.uk.dropdown', [this, force]); + + if (active == this) active = false; + }, + + registerOuterClick: function(){ + + var $this = this; + + UI.$html.off("click.outer.dropdown"); + + setTimeout(function() { + + UI.$html.on("click.outer.dropdown", function(e) { + + if (hoverIdle) { + clearTimeout(hoverIdle); + } + + var $target = UI.$(e.target); + + if (active == $this && !$this.element.find(e.target).length) { + $this.hide(true); + UI.$html.off("click.outer.dropdown"); + } + }); + }, 10); + }, + + checkDimensions: function() { + + if (!this.dropdown.length) return; + + // reset + this.dropdown.removeClass('uk-dropdown-top uk-dropdown-bottom uk-dropdown-left uk-dropdown-right uk-dropdown-stack').css({ + 'top-left':'', + 'left':'', + 'margin-left' :'', + 'margin-right':'' + }); + + if (this.justified && this.justified.length) { + this.dropdown.css("min-width", ""); + } + + var $this = this, + pos = UI.$.extend({}, this.offsetParent.offset(), {width: this.offsetParent[0].offsetWidth, height: this.offsetParent[0].offsetHeight}), + posoffset = this.options.offset, + dropdown = this.dropdown, + offset = dropdown.show().offset() || {left: 0, top: 0}, + width = dropdown.outerWidth(), + height = dropdown.outerHeight(), + boundarywidth = this.boundary.width(), + boundaryoffset = this.boundary[0] !== window && this.boundary.offset() ? this.boundary.offset(): {top:0, left:0}, + dpos = this.options.pos; + + var variants = { + "bottom-left" : {top: 0 + pos.height + posoffset, left: 0}, + "bottom-right" : {top: 0 + pos.height + posoffset, left: 0 + pos.width - width}, + "bottom-center" : {top: 0 + pos.height + posoffset, left: 0 + pos.width / 2 - width / 2}, + "top-left" : {top: 0 - height - posoffset, left: 0}, + "top-right" : {top: 0 - height - posoffset, left: 0 + pos.width - width}, + "top-center" : {top: 0 - height - posoffset, left: 0 + pos.width / 2 - width / 2}, + "left-top" : {top: 0, left: 0 - width - posoffset}, + "left-bottom" : {top: 0 + pos.height - height, left: 0 - width - posoffset}, + "left-center" : {top: 0 + pos.height / 2 - height / 2, left: 0 - width - posoffset}, + "right-top" : {top: 0, left: 0 + pos.width + posoffset}, + "right-bottom" : {top: 0 + pos.height - height, left: 0 + pos.width + posoffset}, + "right-center" : {top: 0 + pos.height / 2 - height / 2, left: 0 + pos.width + posoffset} + }, + css = {}, + pp; + + pp = dpos.split('-'); + css = variants[dpos] ? variants[dpos] : variants['bottom-left']; + + // justify dropdown + if (this.justified && this.justified.length) { + justify(dropdown.css({left:0}), this.justified, boundarywidth); + } else { + + if (this.options.preventflip !== true) { + + var fdpos; + + switch(this.checkBoundary(pos.left + css.left, pos.top + css.top, width, height, boundarywidth)) { + case "x": + if(this.options.preventflip !=='x') fdpos = flips['x'][dpos] || 'right-top'; + break; + case "y": + if(this.options.preventflip !=='y') fdpos = flips['y'][dpos] || 'top-left'; + break; + case "xy": + if(!this.options.preventflip) fdpos = flips['xy'][dpos] || 'right-bottom'; + break; + } + + if (fdpos) { + + pp = fdpos.split('-'); + css = variants[fdpos] ? variants[fdpos] : variants['bottom-left']; + + // check flipped + if (this.checkBoundary(pos.left + css.left, pos.top + css.top, width, height, boundarywidth)) { + pp = dpos.split('-'); + css = variants[dpos] ? variants[dpos] : variants['bottom-left']; + } + } + } + } + + if (width > boundarywidth) { + dropdown.addClass("uk-dropdown-stack"); + this.trigger('stack.uk.dropdown', [this]); + } + + dropdown.css(css).css("display", "").addClass('uk-dropdown-'+pp[0]); + }, + + checkBoundary: function(left, top, width, height, boundarywidth) { + + var axis = ""; + + if (left < 0 || ((left - UI.$win.scrollLeft())+width) > boundarywidth) { + axis += "x"; + } + + if ((top - UI.$win.scrollTop()) < 0 || ((top - UI.$win.scrollTop())+height) > window.innerHeight) { + axis += "y"; + } + + return axis; + } + }); + + + UI.component('dropdownOverlay', { + + defaults: { + 'justify' : false, + 'cls' : '', + 'duration': 200 + }, + + boot: function() { + + // init code + UI.ready(function(context) { + + UI.$("[data-uk-dropdown-overlay]", context).each(function() { + var ele = UI.$(this); + + if (!ele.data("dropdownOverlay")) { + UI.dropdownOverlay(ele, UI.Utils.options(ele.attr("data-uk-dropdown-overlay"))); + } + }); + }); + }, + + init: function() { + + var $this = this; + + this.justified = this.options.justify ? UI.$(this.options.justify) : false; + this.overlay = this.element.find('uk-dropdown-overlay'); + + if (!this.overlay.length) { + this.overlay = UI.$('
              ').appendTo(this.element); + } + + this.overlay.addClass(this.options.cls); + + this.on({ + + 'beforeshow.uk.dropdown': function(e, dropdown) { + $this.dropdown = dropdown; + + if ($this.justified && $this.justified.length) { + justify($this.overlay.css({'display':'block', 'margin-left':'','margin-right':''}), $this.justified, $this.justified.outerWidth()); + } + }, + + 'show.uk.dropdown': function(e, dropdown) { + + var h = $this.dropdown.dropdown.outerHeight(true); + + $this.dropdown.element.removeClass('uk-open'); + + $this.overlay.stop().css('display', 'block').animate({height: h}, $this.options.duration, function() { + + $this.dropdown.dropdown.css('visibility', ''); + $this.dropdown.element.addClass('uk-open'); + + UI.Utils.checkDisplay($this.dropdown.dropdown, true); + }); + + $this.pointerleave = false; + }, + + 'hide.uk.dropdown': function() { + $this.overlay.stop().animate({height: 0}, $this.options.duration); + }, + + 'pointerenter.uk.dropdown': function(e, dropdown) { + clearTimeout($this.remainIdle); + }, + + 'pointerleave.uk.dropdown': function(e, dropdown) { + $this.pointerleave = true; + } + }); + + + this.overlay.on({ + + 'mouseenter': function() { + if ($this.remainIdle) { + clearTimeout($this.dropdown.remainIdle); + clearTimeout($this.remainIdle); + } + }, + + 'mouseleave': function(){ + + if ($this.pointerleave && active) { + + $this.remainIdle = setTimeout(function() { + if(active) active.hide(); + }, active.options.remaintime); + } + } + }) + } + + }); + + + function justify(ele, justifyTo, boundarywidth, offset) { + + ele = UI.$(ele); + justifyTo = UI.$(justifyTo); + boundarywidth = boundarywidth || window.innerWidth; + offset = offset || ele.offset(); + + if (justifyTo.length) { + + var jwidth = justifyTo.outerWidth(); + + ele.css("min-width", jwidth); + + if (UI.langdirection == 'right') { + + var right1 = boundarywidth - (justifyTo.offset().left + jwidth), + right2 = boundarywidth - (ele.offset().left + ele.outerWidth()); + + ele.css("margin-right", right1 - right2); + + } else { + ele.css("margin-left", justifyTo.offset().left - offset.left); + } + } + } + +})(UIkit); + +(function(UI) { + + "use strict"; + + var grids = []; + + UI.component('gridMatchHeight', { + + defaults: { + "target" : false, + "row" : true, + "ignorestacked" : false, + "observe" : false + }, + + boot: function() { + + // init code + UI.ready(function(context) { + + UI.$("[data-uk-grid-match]", context).each(function() { + var grid = UI.$(this), obj; + + if (!grid.data("gridMatchHeight")) { + obj = UI.gridMatchHeight(grid, UI.Utils.options(grid.attr("data-uk-grid-match"))); + } + }); + }); + }, + + init: function() { + + var $this = this; + + this.columns = this.element.children(); + this.elements = this.options.target ? this.find(this.options.target) : this.columns; + + if (!this.columns.length) return; + + UI.$win.on('load resize orientationchange', (function() { + + var fn = function() { + if ($this.element.is(":visible")) $this.match(); + }; + + UI.$(function() { fn(); }); + + return UI.Utils.debounce(fn, 50); + })()); + + if (this.options.observe) { + + UI.domObserve(this.element, function(e) { + if ($this.element.is(":visible")) $this.match(); + }); + } + + this.on("display.uk.check", function(e) { + if(this.element.is(":visible")) this.match(); + }.bind(this)); + + grids.push(this); + }, + + match: function() { + + var firstvisible = this.columns.filter(":visible:first"); + + if (!firstvisible.length) return; + + var stacked = Math.ceil(100 * parseFloat(firstvisible.css('width')) / parseFloat(firstvisible.parent().css('width'))) >= 100; + + if (stacked && !this.options.ignorestacked) { + this.revert(); + } else { + UI.Utils.matchHeights(this.elements, this.options); + } + + return this; + }, + + revert: function() { + this.elements.css('min-height', ''); + return this; + } + }); + + UI.component('gridMargin', { + + defaults: { + cls : 'uk-grid-margin', + rowfirst : 'uk-row-first' + }, + + boot: function() { + + // init code + UI.ready(function(context) { + + UI.$("[data-uk-grid-margin]", context).each(function() { + var grid = UI.$(this), obj; + + if (!grid.data("gridMargin")) { + obj = UI.gridMargin(grid, UI.Utils.options(grid.attr("data-uk-grid-margin"))); + } + }); + }); + }, + + init: function() { + + var stackMargin = UI.stackMargin(this.element, this.options); + } + }); + +})(UIkit); + +(function(UI) { + + "use strict"; + + var active = false, activeCount = 0, $html = UI.$html, body; + + UI.$win.on("resize orientationchange", UI.Utils.debounce(function(){ + UI.$('.uk-modal.uk-open').each(function(){ + UI.$(this).data('modal').resize(); + }); + }, 150)); + + UI.component('modal', { + + defaults: { + keyboard: true, + bgclose: true, + minScrollHeight: 150, + center: false, + modal: true + }, + + scrollable: false, + transition: false, + hasTransitioned: true, + + init: function() { + + if (!body) body = UI.$('body'); + + if (!this.element.length) return; + + var $this = this; + + this.paddingdir = "padding-" + (UI.langdirection == 'left' ? "right":"left"); + this.dialog = this.find(".uk-modal-dialog"); + + this.active = false; + + // Update ARIA + this.element.attr('aria-hidden', this.element.hasClass("uk-open")); + + this.on("click", ".uk-modal-close", function(e) { + e.preventDefault(); + $this.hide(); + }).on("click", function(e) { + + var target = UI.$(e.target); + + if (target[0] == $this.element[0] && $this.options.bgclose) { + $this.hide(); + } + }); + + UI.domObserve(this.element, function(e) { $this.resize(); }); + }, + + toggle: function() { + return this[this.isActive() ? "hide" : "show"](); + }, + + show: function() { + + if (!this.element.length) return; + + var $this = this; + + if (this.isActive()) return; + + if (this.options.modal && active) { + active.hide(true); + } + + this.element.removeClass("uk-open").show(); + this.resize(true); + + if (this.options.modal) { + active = this; + } + + this.active = true; + + activeCount++; + + if (UI.support.transition) { + this.hasTransitioned = false; + this.element.one(UI.support.transition.end, function(){ + $this.hasTransitioned = true; + }).addClass("uk-open"); + } else { + this.element.addClass("uk-open"); + } + + $html.addClass("uk-modal-page").height(); // force browser engine redraw + + // Update ARIA + this.element.attr('aria-hidden', 'false'); + + this.element.trigger("show.uk.modal"); + + UI.Utils.checkDisplay(this.dialog, true); + + return this; + }, + + hide: function(force) { + + if (!force && UI.support.transition && this.hasTransitioned) { + + var $this = this; + + this.one(UI.support.transition.end, function() { + $this._hide(); + }).removeClass("uk-open"); + + } else { + + this._hide(); + } + + return this; + }, + + resize: function(force) { + + if (!this.isActive() && !force) return; + + var bodywidth = body.width(); + + this.scrollbarwidth = window.innerWidth - bodywidth; + + body.css(this.paddingdir, this.scrollbarwidth); + + this.element.css('overflow-y', this.scrollbarwidth ? 'scroll' : 'auto'); + + if (!this.updateScrollable() && this.options.center) { + + var dh = this.dialog.outerHeight(), + pad = parseInt(this.dialog.css('margin-top'), 10) + parseInt(this.dialog.css('margin-bottom'), 10); + + if ((dh + pad) < window.innerHeight) { + this.dialog.css({'top': (window.innerHeight/2 - dh/2) - pad }); + } else { + this.dialog.css({'top': ''}); + } + } + }, + + updateScrollable: function() { + + // has scrollable? + var scrollable = this.dialog.find('.uk-overflow-container:visible:first'); + + if (scrollable.length) { + + scrollable.css('height', 0); + + var offset = Math.abs(parseInt(this.dialog.css('margin-top'), 10)), + dh = this.dialog.outerHeight(), + wh = window.innerHeight, + h = wh - 2*(offset < 20 ? 20:offset) - dh; + + scrollable.css({ + 'max-height': (h < this.options.minScrollHeight ? '':h), + 'height':'' + }); + + return true; + } + + return false; + }, + + _hide: function() { + + this.active = false; + if (activeCount > 0) activeCount--; + else activeCount = 0; + + this.element.hide().removeClass('uk-open'); + + // Update ARIA + this.element.attr('aria-hidden', 'true'); + + if (!activeCount) { + $html.removeClass('uk-modal-page'); + body.css(this.paddingdir, ""); + } + + if (active===this) active = false; + + this.trigger('hide.uk.modal'); + }, + + isActive: function() { + return this.element.hasClass('uk-open'); + } + + }); + + UI.component('modalTrigger', { + + boot: function() { + + // init code + UI.$html.on("click.modal.uikit", "[data-uk-modal]", function(e) { + + var ele = UI.$(this); + + if (ele.is("a")) { + e.preventDefault(); + } + + if (!ele.data("modalTrigger")) { + var modal = UI.modalTrigger(ele, UI.Utils.options(ele.attr("data-uk-modal"))); + modal.show(); + } + + }); + + // close modal on esc button + UI.$html.on('keydown.modal.uikit', function (e) { + + if (active && e.keyCode === 27 && active.options.keyboard) { // ESC + e.preventDefault(); + active.hide(); + } + }); + }, + + init: function() { + + var $this = this; + + this.options = UI.$.extend({ + "target": $this.element.is("a") ? $this.element.attr("href") : false + }, this.options); + + this.modal = UI.modal(this.options.target, this.options); + + this.on("click", function(e) { + e.preventDefault(); + $this.show(); + }); + + //methods + this.proxy(this.modal, "show hide isActive"); + } + }); + + UI.modal.dialog = function(content, options) { + + var modal = UI.modal(UI.$(UI.modal.dialog.template).appendTo("body"), options); + + modal.on("hide.uk.modal", function(){ + if (modal.persist) { + modal.persist.appendTo(modal.persist.data("modalPersistParent")); + modal.persist = false; + } + modal.element.remove(); + }); + + setContent(content, modal); + + return modal; + }; + + UI.modal.dialog.template = '
              '; + + UI.modal.alert = function(content, options) { + + options = UI.$.extend(true, {bgclose:false, keyboard:false, modal:false, labels:UI.modal.labels}, options); + + var modal = UI.modal.dialog(([ + '
              '+String(content)+'
              ', + '' + ]).join(""), options); + + modal.on('show.uk.modal', function(){ + setTimeout(function(){ + modal.element.find('button:first').focus(); + }, 50); + }); + + return modal.show(); + }; + + UI.modal.confirm = function(content, onconfirm, oncancel) { + + var options = arguments.length > 1 && arguments[arguments.length-1] ? arguments[arguments.length-1] : {}; + + onconfirm = UI.$.isFunction(onconfirm) ? onconfirm : function(){}; + oncancel = UI.$.isFunction(oncancel) ? oncancel : function(){}; + options = UI.$.extend(true, {bgclose:false, keyboard:false, modal:false, labels:UI.modal.labels}, UI.$.isFunction(options) ? {}:options); + + var modal = UI.modal.dialog(([ + '
              '+String(content)+'
              ', + '' + ]).join(""), options); + + modal.element.find(".js-modal-confirm, .js-modal-confirm-cancel").on("click", function(){ + UI.$(this).is('.js-modal-confirm') ? onconfirm() : oncancel(); + modal.hide(); + }); + + modal.on('show.uk.modal', function(){ + setTimeout(function(){ + modal.element.find('.js-modal-confirm').focus(); + }, 50); + }); + + return modal.show(); + }; + + UI.modal.prompt = function(text, value, onsubmit, options) { + + onsubmit = UI.$.isFunction(onsubmit) ? onsubmit : function(value){}; + options = UI.$.extend(true, {bgclose:false, keyboard:false, modal:false, labels:UI.modal.labels}, options); + + var modal = UI.modal.dialog(([ + text ? '
              '+String(text)+'
              ':'', + '

              ', + '' + ]).join(""), options), + + input = modal.element.find("input[type='text']").val(value || '').on('keyup', function(e){ + if (e.keyCode == 13) { + modal.element.find(".js-modal-ok").trigger('click'); + } + }); + + modal.element.find(".js-modal-ok").on("click", function(){ + if (onsubmit(input.val())!==false){ + modal.hide(); + } + }); + + modal.on('show.uk.modal', function(){ + setTimeout(function(){ + input.focus(); + }, 50); + }); + + return modal.show(); + }; + + UI.modal.blockUI = function(content, options) { + + var modal = UI.modal.dialog(([ + '
              '+String(content || '
              ...
              ')+'
              ' + ]).join(""), UI.$.extend({bgclose:false, keyboard:false, modal:false}, options)); + + modal.content = modal.element.find('.uk-modal-content:first'); + + return modal.show(); + }; + + + UI.modal.labels = { + 'Ok': 'Ok', + 'Cancel': 'Cancel' + }; + + + // helper functions + function setContent(content, modal){ + + if(!modal) return; + + if (typeof content === 'object') { + + // convert DOM object to a jQuery object + content = content instanceof jQuery ? content : UI.$(content); + + if(content.parent().length) { + modal.persist = content; + modal.persist.data("modalPersistParent", content.parent()); + } + }else if (typeof content === 'string' || typeof content === 'number') { + // just insert the data as innerHTML + content = UI.$('
              ').html(content); + }else { + // unsupported data type! + content = UI.$('
              ').html('UIkit.modal Error: Unsupported data type: ' + typeof content); + } + + content.appendTo(modal.element.find('.uk-modal-dialog')); + + return modal; + } + +})(UIkit); + +(function(UI) { + + "use strict"; + + UI.component('nav', { + + defaults: { + "toggle": ">li.uk-parent > a[href='#']", + "lists": ">li.uk-parent > ul", + "multiple": false + }, + + boot: function() { + + // init code + UI.ready(function(context) { + + UI.$("[data-uk-nav]", context).each(function() { + var nav = UI.$(this); + + if (!nav.data("nav")) { + var obj = UI.nav(nav, UI.Utils.options(nav.attr("data-uk-nav"))); + } + }); + }); + }, + + init: function() { + + var $this = this; + + this.on("click.uk.nav", this.options.toggle, function(e) { + e.preventDefault(); + var ele = UI.$(this); + $this.open(ele.parent()[0] == $this.element[0] ? ele : ele.parent("li")); + }); + + this.find(this.options.lists).each(function() { + var $ele = UI.$(this), + parent = $ele.parent(), + active = parent.hasClass("uk-active"); + + $ele.wrap('
              '); + parent.data("list-container", $ele.parent()[active ? 'removeClass':'addClass']('uk-hidden')); + + // Init ARIA + parent.attr('aria-expanded', parent.hasClass("uk-open")); + + if (active) $this.open(parent, true); + }); + + }, + + open: function(li, noanimation) { + + var $this = this, element = this.element, $li = UI.$(li), $container = $li.data('list-container'); + + if (!this.options.multiple) { + + element.children('.uk-open').not(li).each(function() { + + var ele = UI.$(this); + + if (ele.data('list-container')) { + ele.data('list-container').stop().animate({height: 0}, function() { + UI.$(this).parent().removeClass('uk-open').end().addClass('uk-hidden'); + }); + } + }); + } + + $li.toggleClass('uk-open'); + + // Update ARIA + $li.attr('aria-expanded', $li.hasClass('uk-open')); + + if ($container) { + + if ($li.hasClass('uk-open')) { + $container.removeClass('uk-hidden'); + } + + if (noanimation) { + + $container.stop().height($li.hasClass('uk-open') ? 'auto' : 0); + + if (!$li.hasClass('uk-open')) { + $container.addClass('uk-hidden'); + } + + this.trigger('display.uk.check'); + + } else { + + $container.stop().animate({ + height: ($li.hasClass('uk-open') ? getHeight($container.find('ul:first')) : 0) + }, function() { + + if (!$li.hasClass('uk-open')) { + $container.addClass('uk-hidden'); + } else { + $container.css('height', ''); + } + + $this.trigger('display.uk.check'); + }); + } + } + } + }); + + + // 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; + } + +})(UIkit); + +(function(UI) { + + "use strict"; + + var scrollpos = {x: window.scrollX, y: window.scrollY}, + $win = UI.$win, + $doc = UI.$doc, + $html = UI.$html, + Offcanvas = { + + show: function(element) { + + element = UI.$(element); + + if (!element.length) return; + + var $body = UI.$('body'), + bar = element.find(".uk-offcanvas-bar:first"), + rtl = (UI.langdirection == "right"), + flip = bar.hasClass("uk-offcanvas-bar-flip") ? -1:1, + dir = flip * (rtl ? -1 : 1), + + scrollbarwidth = window.innerWidth - $body.width(); + + scrollpos = {x: window.pageXOffset, y: window.pageYOffset}; + + element.addClass("uk-active"); + + $body.css({"width": window.innerWidth - scrollbarwidth, "height": window.innerHeight}).addClass("uk-offcanvas-page"); + $body.css((rtl ? "margin-right" : "margin-left"), (rtl ? -1 : 1) * (bar.outerWidth() * dir)).width(); // .width() - force redraw + + $html.css('margin-top', scrollpos.y * -1); + + bar.addClass("uk-offcanvas-bar-show"); + + this._initElement(element); + + bar.trigger('show.uk.offcanvas', [element, bar]); + + // Update ARIA + element.attr('aria-hidden', 'false'); + }, + + hide: function(force) { + + var $body = UI.$('body'), + panel = UI.$(".uk-offcanvas.uk-active"), + rtl = (UI.langdirection == "right"), + bar = panel.find(".uk-offcanvas-bar:first"), + finalize = function() { + $body.removeClass("uk-offcanvas-page").css({"width": "", "height": "", "margin-left": "", "margin-right": ""}); + panel.removeClass("uk-active"); + + bar.removeClass("uk-offcanvas-bar-show"); + $html.css('margin-top', ''); + window.scrollTo(scrollpos.x, scrollpos.y); + bar.trigger('hide.uk.offcanvas', [panel, bar]); + + // Update ARIA + panel.attr('aria-hidden', 'true'); + }; + + if (!panel.length) return; + + if (UI.support.transition && !force) { + + $body.one(UI.support.transition.end, function() { + finalize(); + }).css((rtl ? "margin-right" : "margin-left"), ""); + + setTimeout(function(){ + bar.removeClass("uk-offcanvas-bar-show"); + }, 0); + + } else { + finalize(); + } + }, + + _initElement: function(element) { + + if (element.data("OffcanvasInit")) return; + + element.on("click.uk.offcanvas swipeRight.uk.offcanvas swipeLeft.uk.offcanvas", function(e) { + + var target = UI.$(e.target); + + if (!e.type.match(/swipe/)) { + + if (!target.hasClass("uk-offcanvas-close")) { + if (target.hasClass("uk-offcanvas-bar")) return; + if (target.parents(".uk-offcanvas-bar:first").length) return; + } + } + + e.stopImmediatePropagation(); + Offcanvas.hide(); + }); + + element.on("click", "a[href*='#']", function(e){ + + var link = UI.$(this), + href = link.attr("href"); + + if (href == "#") { + return; + } + + UI.$doc.one('hide.uk.offcanvas', function() { + + var target; + + try { + target = UI.$(link[0].hash); + } catch (e){ + target = ''; + } + + if (!target.length) { + target = UI.$('[name="'+link[0].hash.replace('#','')+'"]'); + } + + if (target.length && UI.Utils.scrollToElement) { + UI.Utils.scrollToElement(target, UI.Utils.options(link.attr('data-uk-smooth-scroll') || '{}')); + } else { + window.location.href = href; + } + }); + + Offcanvas.hide(); + }); + + element.data("OffcanvasInit", true); + } + }; + + UI.component('offcanvasTrigger', { + + boot: function() { + + // init code + $html.on("click.offcanvas.uikit", "[data-uk-offcanvas]", function(e) { + + e.preventDefault(); + + var ele = UI.$(this); + + if (!ele.data("offcanvasTrigger")) { + var obj = UI.offcanvasTrigger(ele, UI.Utils.options(ele.attr("data-uk-offcanvas"))); + ele.trigger("click"); + } + }); + + $html.on('keydown.uk.offcanvas', function(e) { + + if (e.keyCode === 27) { // ESC + Offcanvas.hide(); + } + }); + }, + + init: function() { + + var $this = this; + + this.options = UI.$.extend({ + "target": $this.element.is("a") ? $this.element.attr("href") : false + }, this.options); + + this.on("click", function(e) { + e.preventDefault(); + Offcanvas.show($this.options.target); + }); + } + }); + + UI.offcanvas = Offcanvas; + +})(UIkit); + +(function(UI) { + + "use strict"; + + var Animations; + + UI.component('switcher', { + + defaults: { + connect : false, + toggle : ">*", + active : 0, + animation : false, + duration : 200, + swiping : true + }, + + animating: false, + + boot: function() { + + // init code + UI.ready(function(context) { + + UI.$("[data-uk-switcher]", context).each(function() { + var switcher = UI.$(this); + + if (!switcher.data("switcher")) { + var obj = UI.switcher(switcher, UI.Utils.options(switcher.attr("data-uk-switcher"))); + } + }); + }); + }, + + init: function() { + + var $this = this; + + this.on("click.uk.switcher", this.options.toggle, function(e) { + e.preventDefault(); + $this.show(this); + }); + + if (this.options.connect) { + + this.connect = UI.$(this.options.connect); + + this.connect.children().removeClass("uk-active"); + + // delegate switch commands within container content + if (this.connect.length) { + + // Init ARIA for connect + this.connect.children().attr('aria-hidden', 'true'); + + this.connect.on("click", '[data-uk-switcher-item]', function(e) { + + e.preventDefault(); + + var item = UI.$(this).attr('data-uk-switcher-item'); + + if ($this.index == item) return; + + switch(item) { + case 'next': + case 'previous': + $this.show($this.index + (item=='next' ? 1:-1)); + break; + default: + $this.show(parseInt(item, 10)); + } + }); + + if (this.options.swiping) { + + this.connect.on('swipeRight swipeLeft', function(e) { + e.preventDefault(); + if(!window.getSelection().toString()) { + $this.show($this.index + (e.type == 'swipeLeft' ? 1 : -1)); + } + }); + } + } + + var toggles = this.find(this.options.toggle), + active = toggles.filter(".uk-active"); + + if (active.length) { + this.show(active, false); + } else { + + if (this.options.active===false) return; + + active = toggles.eq(this.options.active); + this.show(active.length ? active : toggles.eq(0), false); + } + + // Init ARIA for toggles + toggles.not(active).attr('aria-expanded', 'false'); + active.attr('aria-expanded', 'true'); + } + + }, + + show: function(tab, animate) { + + if (this.animating) { + return; + } + + if (isNaN(tab)) { + tab = UI.$(tab); + } else { + + var toggles = this.find(this.options.toggle); + + tab = tab < 0 ? toggles.length-1 : tab; + tab = toggles.eq(toggles[tab] ? tab : 0); + } + + var $this = this, + toggles = this.find(this.options.toggle), + active = UI.$(tab), + animation = Animations[this.options.animation] || function(current, next) { + + if (!$this.options.animation) { + return Animations.none.apply($this); + } + + var anim = $this.options.animation.split(','); + + if (anim.length == 1) { + anim[1] = anim[0]; + } + + anim[0] = anim[0].trim(); + anim[1] = anim[1].trim(); + + return coreAnimation.apply($this, [anim, current, next]); + }; + + if (animate===false || !UI.support.animation) { + animation = Animations.none; + } + + if (active.hasClass("uk-disabled")) return; + + // Update ARIA for Toggles + toggles.attr('aria-expanded', 'false'); + active.attr('aria-expanded', 'true'); + + toggles.filter(".uk-active").removeClass("uk-active"); + active.addClass("uk-active"); + + if (this.options.connect && this.connect.length) { + + this.index = this.find(this.options.toggle).index(active); + + if (this.index == -1 ) { + this.index = 0; + } + + this.connect.each(function() { + + var container = UI.$(this), + children = UI.$(container.children()), + current = UI.$(children.filter('.uk-active')), + next = UI.$(children.eq($this.index)); + + $this.animating = true; + + animation.apply($this, [current, next]).then(function(){ + + current.removeClass("uk-active"); + next.addClass("uk-active"); + + // Update ARIA for connect + current.attr('aria-hidden', 'true'); + next.attr('aria-hidden', 'false'); + + UI.Utils.checkDisplay(next, true); + + $this.animating = false; + + }); + }); + } + + this.trigger("show.uk.switcher", [active]); + } + }); + + 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 (current && current.index() > next.index()) { + anim.reverse(); + } + + return coreAnimation.apply(this, [anim, current, next]); + }, + + 'slide-left': function(current, next) { + return coreAnimation.apply(this, ['uk-animation-slide-left', current, next]); + }, + + 'slide-right': function(current, next) { + return coreAnimation.apply(this, ['uk-animation-slide-right', current, next]); + }, + + 'slide-horizontal': function(current, next, dir) { + + var anim = ['uk-animation-slide-right', 'uk-animation-slide-left']; + + if (current && current.index() > next.index()) { + anim.reverse(); + } + + return coreAnimation.apply(this, [anim, current, next]); + }, + + 'scale': function(current, next) { + return coreAnimation.apply(this, ['uk-animation-scale-up', current, next]); + } + }; + + UI.switcher.animations = Animations; + + + // helpers + + function coreAnimation(cls, current, next) { + + var d = UI.$.Deferred(), clsIn = cls, clsOut = cls, release; + + if (next[0]===current[0]) { + d.resolve(); + return d.promise(); + } + + if (typeof(cls) == 'object') { + clsIn = cls[0]; + clsOut = cls[1] || cls[0]; + } + + UI.$body.css('overflow-x', 'hidden'); // fix scroll jumping in iOS + + release = function() { + + if (current) current.hide().removeClass('uk-active '+clsOut+' uk-animation-reverse'); + + next.addClass(clsIn).one(UI.support.animation.end, function() { + + setTimeout(function () { + next.removeClass(''+clsIn+'').css({opacity:'', display:''}); + }, 0); + + d.resolve(); + + UI.$body.css('overflow-x', ''); + + if (current) current.css({opacity:'', display:''}); + + }.bind(this)).show(); + }; + + next.css('animation-duration', this.options.duration+'ms'); + + if (current && current.length) { + + current.css('animation-duration', this.options.duration+'ms'); + + current.css('display', 'none').addClass(clsOut+' uk-animation-reverse').one(UI.support.animation.end, function() { + release(); + }.bind(this)).css('display', ''); + + } else { + next.addClass('uk-active'); + release(); + } + + return d.promise(); + } + +})(UIkit); + +(function(UI) { + + "use strict"; + + UI.component('tab', { + + defaults: { + 'target' : '>li:not(.uk-tab-responsive, .uk-disabled)', + 'connect' : false, + 'active' : 0, + 'animation' : false, + 'duration' : 200, + 'swiping' : true + }, + + boot: function() { + + // init code + UI.ready(function(context) { + + UI.$("[data-uk-tab]", context).each(function() { + + var tab = UI.$(this); + + if (!tab.data("tab")) { + var obj = UI.tab(tab, UI.Utils.options(tab.attr("data-uk-tab"))); + } + }); + }); + }, + + init: function() { + + var $this = this; + + this.current = false; + + this.on("click.uk.tab", this.options.target, function(e) { + + e.preventDefault(); + + if ($this.switcher && $this.switcher.animating) { + return; + } + + var current = $this.find($this.options.target).not(this); + + current.removeClass("uk-active").blur(); + + $this.trigger("change.uk.tab", [UI.$(this).addClass("uk-active"), $this.current]); + + $this.current = UI.$(this); + + // Update ARIA + if (!$this.options.connect) { + current.attr('aria-expanded', 'false'); + UI.$(this).attr('aria-expanded', 'true'); + } + }); + + if (this.options.connect) { + this.connect = UI.$(this.options.connect); + } + + // init responsive tab + this.responsivetab = UI.$('
            • ').append('
                '); + + this.responsivetab.dropdown = this.responsivetab.find('.uk-dropdown'); + this.responsivetab.lst = this.responsivetab.dropdown.find('ul'); + this.responsivetab.caption = this.responsivetab.find('a:first'); + + if (this.element.hasClass("uk-tab-bottom")) this.responsivetab.dropdown.addClass("uk-dropdown-up"); + + // handle click + this.responsivetab.lst.on('click.uk.tab', 'a', function(e) { + + e.preventDefault(); + e.stopPropagation(); + + var link = UI.$(this); + + $this.element.children('li:not(.uk-tab-responsive)').eq(link.data('index')).trigger('click'); + }); + + this.on('show.uk.switcher change.uk.tab', function(e, tab) { + $this.responsivetab.caption.html(tab.text()); + }); + + this.element.append(this.responsivetab); + + // init UIkit components + if (this.options.connect) { + this.switcher = UI.switcher(this.element, { + 'toggle' : '>li:not(.uk-tab-responsive)', + 'connect' : this.options.connect, + 'active' : this.options.active, + 'animation' : this.options.animation, + 'duration' : this.options.duration, + 'swiping' : this.options.swiping + }); + } + + UI.dropdown(this.responsivetab, {"mode": "click", "preventflip": "y"}); + + // init + $this.trigger("change.uk.tab", [this.element.find(this.options.target).not('.uk-tab-responsive').filter('.uk-active')]); + + this.check(); + + UI.$win.on('resize orientationchange', UI.Utils.debounce(function(){ + if ($this.element.is(":visible")) $this.check(); + }, 100)); + + this.on('display.uk.check', function(){ + if ($this.element.is(":visible")) $this.check(); + }); + }, + + check: function() { + + var children = this.element.children('li:not(.uk-tab-responsive)').removeClass('uk-hidden'); + + if (!children.length) { + this.responsivetab.addClass('uk-hidden'); + return; + } + + var top = (children.eq(0).offset().top + Math.ceil(children.eq(0).height()/2)), + doresponsive = false, + item, link, clone; + + this.responsivetab.lst.empty(); + + children.each(function(){ + + if (UI.$(this).offset().top > top) { + doresponsive = true; + } + }); + + if (doresponsive) { + + for (var i = 0; i < children.length; i++) { + + item = UI.$(children.eq(i)); + link = item.find('a'); + + if (item.css('float') != 'none' && !item.attr('uk-dropdown')) { + + if (!item.hasClass('uk-disabled')) { + + clone = item[0].outerHTML.replace(' -1 ? '&':'?'), 'enablejsapi=1&api=1'].join('')); + } + }, + + check: function() { + + this.element.css({ + 'width' : '', + 'height' : '' + }); + + this.dimension = {w: this.element.width(), h: this.element.height()}; + + if (this.element.attr('width') && !isNaN(this.element.attr('width'))) { + this.dimension.w = this.element.attr('width'); + } + + if (this.element.attr('height') && !isNaN(this.element.attr('height'))) { + this.dimension.h = this.element.attr('height'); + } + + this.ratio = this.dimension.w / this.dimension.h; + + var w = this.parent.width(), h = this.parent.height(), width, height; + + // if element height < parent height (gap underneath) + if ((w / this.ratio) < h) { + + width = Math.ceil(h * this.ratio); + height = h; + + // element width < parent width (gap to right) + } else { + + width = w; + height = Math.ceil(w / this.ratio); + } + + this.element.css({ + 'width' : width, + 'height' : height + }); + } + }); + +})(UIkit); diff --git a/js/uikit.min.js b/js/uikit.min.js new file mode 100755 index 0000000..ce54d56 --- /dev/null +++ b/js/uikit.min.js @@ -0,0 +1,3 @@ +/*! UIkit 2.26.4 | http://www.getuikit.com | (c) 2014 YOOtheme | MIT License */ +!function(t){if("function"==typeof define&&define.amd&&define("uikit",function(){var i=window.UIkit||t(window,window.jQuery,window.document);return i.load=function(t,e,n,o){var s,a=t.split(","),r=[],l=(o.config&&o.config.uikit&&o.config.uikit.base?o.config.uikit.base:"").replace(/\/+$/g,"");if(!l)throw new Error("Please define base path to UIkit in the requirejs config.");for(s=0;s0||t.navigator.pointerEnabled&&t.navigator.maxTouchPoints>0||!1,n.support.mutationobserver=t.MutationObserver||t.WebKitMutationObserver||null,n.Utils={},n.Utils.isFullscreen=function(){return document.webkitFullscreenElement||document.mozFullScreenElement||document.msFullscreenElement||document.fullscreenElement||!1},n.Utils.str2json=function(t,i){try{return i?JSON.parse(t.replace(/([\$\w]+)\s*:/g,function(t,i){return'"'+i+'":'}).replace(/'([^']+)'/g,function(t,i){return'"'+i+'"'})):new Function("","var json = "+t+"; return JSON.parse(JSON.stringify(json));")()}catch(e){return!1}},n.Utils.debounce=function(t,i,e){var n;return function(){var o=this,s=arguments,a=function(){n=null,e||t.apply(o,s)},r=e&&!n;clearTimeout(n),n=setTimeout(a,i),r&&t.apply(o,s)}},n.Utils.throttle=function(t,i){var e=!1;return function(){e||(t.call(),e=!0,setTimeout(function(){e=!1},i))}},n.Utils.removeCssRules=function(t){var i,e,n,o,s,a,r,l,c,u;t&&setTimeout(function(){try{for(u=document.styleSheets,o=0,r=u.length;r>o;o++){for(n=u[o],e=[],n.cssRules=n.cssRules,i=s=0,l=n.cssRules.length;l>s;i=++s)n.cssRules[i].type===CSSRule.STYLE_RULE&&t.test(n.cssRules[i].selectorText)&&e.unshift(i);for(a=0,c=e.length;c>a;a++)n.deleteRule(e[a])}}catch(h){}},0)},n.Utils.isInView=function(t,e){var o=i(t);if(!o.is(":visible"))return!1;var s=n.$win.scrollLeft(),a=n.$win.scrollTop(),r=o.offset(),l=r.left,c=r.top;return e=i.extend({topoffset:0,leftoffset:0},e),c+o.height()>=a&&c-e.topoffset<=a+n.$win.height()&&l+o.width()>=s&&l-e.leftoffset<=s+n.$win.width()?!0:!1},n.Utils.checkDisplay=function(t,e){var o=n.$("[data-uk-margin], [data-uk-grid-match], [data-uk-grid-margin], [data-uk-check-display]",t||document);return t&&!o.length&&(o=i(t)),o.trigger("display.uk.check"),e&&("string"!=typeof e&&(e='[class*="uk-animation-"]'),o.find(e).each(function(){var t=n.$(this),i=t.attr("class"),e=i.match(/uk-animation-(.+)/);t.removeClass(e[0]).width(),t.addClass(e[0])})),o},n.Utils.options=function(t){if("string"!=i.type(t))return t;-1!=t.indexOf(":")&&"}"!=t.trim().substr(-1)&&(t="{"+t+"}");var e=t?t.indexOf("{"):-1,o={};if(-1!=e)try{o=n.Utils.str2json(t.substr(e))}catch(s){}return o},n.Utils.animate=function(t,e){var o=i.Deferred();return t=n.$(t),t.css("display","none").addClass(e).one(n.support.animation.end,function(){t.removeClass(e),o.resolve()}),t.css("display",""),o.promise()},n.Utils.uid=function(t){return(t||"id")+(new Date).getTime()+"RAND"+Math.ceil(1e5*Math.random())},n.Utils.template=function(t,i){for(var e,n,o,s,a=t.replace(/\n/g,"\\n").replace(/\{\{\{\s*(.+?)\s*\}\}\}/g,"{{!$1}}").split(/(\{\{\s*(.+?)\s*\}\})/g),r=0,l=[],c=0;r/g, '>');}"].join("\n")),i?s(i):s},n.Utils.events={},n.Utils.events.click=n.support.touch?"tap":"click",t.UIkit=n,n.fn=function(t,e){var o=arguments,s=t.match(/^([a-z\-]+)(?:\.([a-z]+))?/i),a=s[1],r=s[2];return n[a]?this.each(function(){var t=i(this),s=t.data(a);s||t.data(a,s=n[a](this,r?void 0:e)),r&&s[r].apply(s,Array.prototype.slice.call(o,1))}):(i.error("UIkit component ["+a+"] does not exist."),this)},i.UIkit=n,i.fn.uk=n.fn,n.langdirection="rtl"==n.$html.attr("dir")?"right":"left",n.components={},n.component=function(t,e){var o=function(e,s){var a=this;return this.UIkit=n,this.element=e?n.$(e):null,this.options=i.extend(!0,{},this.defaults,s),this.plugins={},this.element&&this.element.data(t,this),this.init(),(this.options.plugins.length?this.options.plugins:Object.keys(o.plugins)).forEach(function(t){o.plugins[t].init&&(o.plugins[t].init(a),a.plugins[t]=!0)}),this.trigger("init.uk.component",[t,this]),this};return o.plugins={},i.extend(!0,o.prototype,{defaults:{plugins:[]},boot:function(){},init:function(){},on:function(t,i,e){return n.$(this.element||this).on(t,i,e)},one:function(t,i,e){return n.$(this.element||this).one(t,i,e)},off:function(t){return n.$(this.element||this).off(t)},trigger:function(t,i){return n.$(this.element||this).trigger(t,i)},find:function(t){return n.$(this.element?this.element:[]).find(t)},proxy:function(t,i){var e=this;i.split(" ").forEach(function(i){e[i]||(e[i]=function(){return t[i].apply(t,arguments)})})},mixin:function(t,i){var e=this;i.split(" ").forEach(function(i){e[i]||(e[i]=t[i].bind(e))})},option:function(){return 1==arguments.length?this.options[arguments[0]]||void 0:(2==arguments.length&&(this.options[arguments[0]]=arguments[1]),void 0)}},e),this.components[t]=o,this[t]=function(){var e,o;if(arguments.length)switch(arguments.length){case 1:"string"==typeof arguments[0]||arguments[0].nodeType||arguments[0]instanceof jQuery?e=i(arguments[0]):o=arguments[0];break;case 2:e=i(arguments[0]),o=arguments[1]}return e&&e.data(t)?e.data(t):new n.components[t](e,o)},n.domready&&n.component.boot(t),o},n.plugin=function(t,i,e){this.components[t].plugins[i]=e},n.component.boot=function(t){n.components[t].prototype&&n.components[t].prototype.boot&&!n.components[t].booted&&(n.components[t].prototype.boot.apply(n,[]),n.components[t].booted=!0)},n.component.bootComponents=function(){for(var t in n.components)n.component.boot(t)},n.domObservers=[],n.domready=!1,n.ready=function(t){n.domObservers.push(t),n.domready&&t(document)},n.on=function(t,i,e){return t&&t.indexOf("ready.uk.dom")>-1&&n.domready&&i.apply(n.$doc),n.$doc.on(t,i,e)},n.one=function(t,i,e){return t&&t.indexOf("ready.uk.dom")>-1&&n.domready?(i.apply(n.$doc),n.$doc):n.$doc.one(t,i,e)},n.trigger=function(t,i){return n.$doc.trigger(t,i)},n.domObserve=function(t,i){n.support.mutationobserver&&(i=i||function(){},n.$(t).each(function(){var t=this,e=n.$(t);if(!e.data("observer"))try{var o=new n.support.mutationobserver(n.Utils.debounce(function(){i.apply(t,[]),e.trigger("changed.uk.dom")},50),{childList:!0,subtree:!0});o.observe(t,{childList:!0,subtree:!0}),e.data("observer",o)}catch(s){}}))},n.init=function(t){t=t||document,n.domObservers.forEach(function(i){i(t)})},n.on("domready.uk.dom",function(){n.init(),n.domready&&n.Utils.checkDisplay()}),document.addEventListener("DOMContentLoaded",function(){var t=function(){n.$body=n.$("body"),n.trigger("beforeready.uk.dom"),n.component.bootComponents();var t=requestAnimationFrame(function(){var i={dir:{x:0,y:0},x:window.pageXOffset,y:window.pageYOffset},e=function(){var o=window.pageXOffset,s=window.pageYOffset;(i.x!=o||i.y!=s)&&(i.dir.x=o!=i.x?o>i.x?1:-1:0,i.dir.y=s!=i.y?s>i.y?1:-1:0,i.x=o,i.y=s,n.$doc.trigger("scrolling.uk.document",[{dir:{x:i.dir.x,y:i.dir.y},x:o,y:s}])),cancelAnimationFrame(t),t=requestAnimationFrame(e)};return n.support.touch&&n.$html.on("touchmove touchend MSPointerMove MSPointerUp pointermove pointerup",e),(i.x||i.y)&&e(),e}());if(n.trigger("domready.uk.dom"),n.support.touch&&navigator.userAgent.match(/(iPad|iPhone|iPod)/g)&&n.$win.on("load orientationchange resize",n.Utils.debounce(function(){var t=function(){return i(".uk-height-viewport").css("height",window.innerHeight),t};return t()}(),100)),n.trigger("afterready.uk.dom"),n.domready=!0,n.support.mutationobserver){var e=n.Utils.debounce(function(){requestAnimationFrame(function(){n.init(document.body)})},10);new n.support.mutationobserver(function(t){var i=!1;t.every(function(t){if("childList"!=t.type)return!0;for(var e,n=0;n=Math.abs(e-n)?t-i>0?"Left":"Right":e-n>0?"Up":"Down"}function e(){c=null,h.last&&(void 0!==h.el&&h.el.trigger("longTap"),h={})}function n(){c&&clearTimeout(c),c=null}function o(){a&&clearTimeout(a),r&&clearTimeout(r),l&&clearTimeout(l),c&&clearTimeout(c),a=r=l=c=null,h={}}function s(t){return t.pointerType==t.MSPOINTER_TYPE_TOUCH&&t.isPrimary}if(!t.fn.swipeLeft){var a,r,l,c,u,h={},d=750;t(function(){var p,f,m,g=0,v=0;"MSGesture"in window&&(u=new MSGesture,u.target=document.body),t(document).on("MSGestureEnd gestureend",function(t){var i=t.originalEvent.velocityX>1?"Right":t.originalEvent.velocityX<-1?"Left":t.originalEvent.velocityY>1?"Down":t.originalEvent.velocityY<-1?"Up":null;i&&void 0!==h.el&&(h.el.trigger("swipe"),h.el.trigger("swipe"+i))}).on("touchstart MSPointerDown pointerdown",function(i){("MSPointerDown"!=i.type||s(i.originalEvent))&&(m="MSPointerDown"==i.type||"pointerdown"==i.type?i:i.originalEvent.touches[0],p=Date.now(),f=p-(h.last||p),h.el=t("tagName"in m.target?m.target:m.target.parentNode),a&&clearTimeout(a),h.x1=m.pageX,h.y1=m.pageY,f>0&&250>=f&&(h.isDoubleTap=!0),h.last=p,c=setTimeout(e,d),!u||"MSPointerDown"!=i.type&&"pointerdown"!=i.type&&"touchstart"!=i.type||u.addPointer(i.originalEvent.pointerId))}).on("touchmove MSPointerMove pointermove",function(t){("MSPointerMove"!=t.type||s(t.originalEvent))&&(m="MSPointerMove"==t.type||"pointermove"==t.type?t:t.originalEvent.touches[0],n(),h.x2=m.pageX,h.y2=m.pageY,g+=Math.abs(h.x1-h.x2),v+=Math.abs(h.y1-h.y2))}).on("touchend MSPointerUp pointerup",function(e){("MSPointerUp"!=e.type||s(e.originalEvent))&&(n(),h.x2&&Math.abs(h.x1-h.x2)>30||h.y2&&Math.abs(h.y1-h.y2)>30?l=setTimeout(function(){void 0!==h.el&&(h.el.trigger("swipe"),h.el.trigger("swipe"+i(h.x1,h.x2,h.y1,h.y2))),h={}},0):"last"in h&&(isNaN(g)||30>g&&30>v?r=setTimeout(function(){var i=t.Event("tap");i.cancelTouch=o,void 0!==h.el&&h.el.trigger(i),h.isDoubleTap?(void 0!==h.el&&h.el.trigger("doubleTap"),h={}):a=setTimeout(function(){a=null,void 0!==h.el&&h.el.trigger("singleTap"),h={}},250)},0):h={},g=v=0))}).on("touchcancel MSPointerCancel",o),t(window).on("scroll",o)}),["swipe","swipeLeft","swipeRight","swipeUp","swipeDown","doubleTap","tap","singleTap","longTap"].forEach(function(i){t.fn[i]=function(e){return t(this).on(i,e)}})}}(jQuery),function(t){"use strict";var i=[];t.component("stackMargin",{defaults:{cls:"uk-margin-small-top",rowfirst:!1,observe:!1},boot:function(){t.ready(function(i){t.$("[data-uk-margin]",i).each(function(){var i=t.$(this);i.data("stackMargin")||t.stackMargin(i,t.Utils.options(i.attr("data-uk-margin")))})})},init:function(){var e=this;t.$win.on("resize orientationchange",function(){var i=function(){e.process()};return t.$(function(){i(),t.$win.on("load",i)}),t.Utils.debounce(i,20)}()),this.on("display.uk.check",function(){this.element.is(":visible")&&this.process()}.bind(this)),this.options.observe&&t.domObserve(this.element,function(){e.element.is(":visible")&&e.process()}),i.push(this)},process:function(){var i=this.element.children();if(t.Utils.stackMargin(i,this.options),!this.options.rowfirst||!i.length)return this;var e={},n=!1;return i.removeClass(this.options.rowfirst).each(function(i,o){o=t.$(this),"none"!=this.style.display&&(i=o.offset().left,((e[i]=e[i]||[])&&e[i]).push(this),n=n===!1?i:Math.min(n,i))}),t.$(e[n]).addClass(this.options.rowfirst),this}}),function(){var i=[],e=function(t){if(t.is(":visible")){var i=t.parent().width(),e=t.data("width"),n=i/e,o=Math.floor(n*t.data("height"));t.css({height:e>i?o:t.data("height")})}};t.component("responsiveElement",{defaults:{},boot:function(){t.ready(function(i){t.$("iframe.uk-responsive-width, [data-uk-responsive]",i).each(function(){var i,e=t.$(this);e.data("responsiveElement")||(i=t.responsiveElement(e,{}))})})},init:function(){var t=this.element;t.attr("width")&&t.attr("height")&&(t.data({width:t.attr("width"),height:t.attr("height")}).on("display.uk.check",function(){e(t)}),e(t),i.push(t))}}),t.$win.on("resize load",t.Utils.debounce(function(){i.forEach(function(t){e(t)})},15))}(),t.Utils.stackMargin=function(i,e){e=t.$.extend({cls:"uk-margin-small-top"},e),i=t.$(i).removeClass(e.cls);var n=!1;i.each(function(i,e,o,s){s=t.$(this),"none"!=s.css("display")&&(i=s.offset(),e=s.outerHeight(),o=i.top+e,s.data({ukMarginPos:o,ukMarginTop:i.top}),(n===!1||i.topn.top&&i.data("ukMarginPos")>n.pos&&i.addClass(e.cls)})},t.Utils.matchHeights=function(i,e){i=t.$(i).css("min-height",""),e=t.$.extend({row:!0},e);var n=function(i){if(!(i.length<2)){var e=0;i.each(function(){e=Math.max(e,t.$(this).outerHeight())}).each(function(){var i=t.$(this),n=e-("border-box"==i.css("box-sizing")?0:i.outerHeight()-i.height());i.css("min-height",n+"px")})}};e.row?(i.first().width(),setTimeout(function(){var e=!1,o=[];i.each(function(){var i=t.$(this),s=i.offset().top;s!=e&&o.length&&(n(t.$(o)),o=[],s=i.offset().top),o.push(i),e=s}),o.length&&n(t.$(o))},0)):n(i)},function(i){t.Utils.inlineSvg=function(e,n){t.$(e||'img[src$=".svg"]',n||document).each(function(){var e=t.$(this),n=e.attr("src");if(!i[n]){var o=t.$.Deferred();t.$.get(n,{nc:Math.random()},function(i){o.resolve(t.$(i).find("svg"))}),i[n]=o.promise()}i[n].then(function(i){var n=t.$(i).clone();e.attr("id")&&n.attr("id",e.attr("id")),e.attr("class")&&n.attr("class",e.attr("class")),e.attr("style")&&n.attr("style",e.attr("style")),e.attr("width")&&(n.attr("width",e.attr("width")),e.attr("height")||n.removeAttr("height")),e.attr("height")&&(n.attr("height",e.attr("height")),e.attr("width")||n.removeAttr("width")),e.replaceWith(n)})})},t.ready(function(i){t.Utils.inlineSvg("[data-uk-svg]",i)})}({})}(UIkit),function(t){"use strict";function i(i,e){e=t.$.extend({duration:1e3,transition:"easeOutExpo",offset:0,complete:function(){}},e);var n=i.offset().top-e.offset,o=t.$doc.height(),s=window.innerHeight;n+s>o&&(n=o-s),t.$("html,body").stop().animate({scrollTop:n},e.duration,e.transition).promise().done(e.complete)}t.component("smoothScroll",{boot:function(){t.$html.on("click.smooth-scroll.uikit","[data-uk-smooth-scroll]",function(){var i=t.$(this);if(!i.data("smoothScroll")){{t.smoothScroll(i,t.Utils.options(i.attr("data-uk-smooth-scroll")))}i.trigger("click")}return!1})},init:function(){var e=this;this.on("click",function(n){n.preventDefault(),i(t.$(this.hash).length?t.$(this.hash):t.$("body"),e.options)})}}),t.Utils.scrollToElement=i,t.$.easing.easeOutExpo||(t.$.easing.easeOutExpo=function(t,i,e,n,o){return i==o?e+n:n*(-Math.pow(2,-10*i/o)+1)+e})}(UIkit),function(t){"use strict";var i=t.$win,e=t.$doc,n=[],o=function(){for(var t=0;t=u)return e[t]}();if(!h)return;c.options.closest?(o.blur().closest(l).removeClass(r),s=o.filter("a[href='#"+h.attr("id")+"']").closest(l).addClass(r)):s=o.removeClass(r).filter("a[href='#"+h.attr("id")+"']").addClass(r),c.element.trigger("inview.uk.scrollspynav",[h,s])}};this.options.smoothscroll&&t.smoothScroll&&o.each(function(){t.smoothScroll(this,c.options.smoothscroll)}),u(),this.element.data("scrollspynav",this),this.check=u,s.push(this)}})}(UIkit),function(t){"use strict";var i=[];t.component("toggle",{defaults:{target:!1,cls:"uk-hidden",animation:!1,duration:200},boot:function(){t.ready(function(e){t.$("[data-uk-toggle]",e).each(function(){var i=t.$(this);if(!i.data("toggle")){t.toggle(i,t.Utils.options(i.attr("data-uk-toggle")))}}),setTimeout(function(){i.forEach(function(t){t.getToggles()})},0)})},init:function(){var t=this;this.aria=-1!==this.options.cls.indexOf("uk-hidden"),this.getToggles(),this.on("click",function(i){t.element.is('a[href="#"]')&&i.preventDefault(),t.toggle()}),i.push(this)},toggle:function(){if(this.totoggle.length){if(this.options.animation&&t.support.animation){var i=this,e=this.options.animation.split(",");1==e.length&&(e[1]=e[0]),e[0]=e[0].trim(),e[1]=e[1].trim(),this.totoggle.css("animation-duration",this.options.duration+"ms"),this.totoggle.each(function(){var n=t.$(this);n.hasClass(i.options.cls)?(n.toggleClass(i.options.cls),t.Utils.animate(n,e[0]).then(function(){n.css("animation-duration",""),t.Utils.checkDisplay(n)})):t.Utils.animate(this,e[1]+" uk-animation-reverse").then(function(){n.toggleClass(i.options.cls).css("animation-duration",""),t.Utils.checkDisplay(n)})})}else this.totoggle.toggleClass(this.options.cls),t.Utils.checkDisplay(this.totoggle);this.updateAria()}},getToggles:function(){this.totoggle=this.options.target?t.$(this.options.target):[],this.updateAria()},updateAria:function(){this.aria&&this.totoggle.length&&this.totoggle.each(function(){t.$(this).attr("aria-hidden",t.$(this).hasClass("uk-hidden"))})}})}(UIkit),function(t){"use strict";t.component("alert",{defaults:{fade:!0,duration:200,trigger:".uk-alert-close"},boot:function(){t.$html.on("click.alert.uikit","[data-uk-alert]",function(i){var e=t.$(this);if(!e.data("alert")){var n=t.alert(e,t.Utils.options(e.attr("data-uk-alert")));t.$(i.target).is(n.options.trigger)&&(i.preventDefault(),n.close())}})},init:function(){var t=this;this.on("click",this.options.trigger,function(i){i.preventDefault(),t.close()})},close:function(){var t=this.trigger("close.uk.alert"),i=function(){this.trigger("closed.uk.alert").remove()}.bind(this);this.options.fade?t.css("overflow","hidden").css("max-height",t.height()).animate({height:0,opacity:0,"padding-top":0,"padding-bottom":0,"margin-top":0,"margin-bottom":0},this.options.duration,i):i()}})}(UIkit),function(t){"use strict";t.component("buttonRadio",{defaults:{activeClass:"uk-active",target:".uk-button"},boot:function(){t.$html.on("click.buttonradio.uikit","[data-uk-button-radio]",function(i){var e=t.$(this);if(!e.data("buttonRadio")){var n=t.buttonRadio(e,t.Utils.options(e.attr("data-uk-button-radio"))),o=t.$(i.target);o.is(n.options.target)&&o.trigger("click")}})},init:function(){var i=this;this.find(i.options.target).attr("aria-checked","false").filter("."+i.options.activeClass).attr("aria-checked","true"),this.on("click",this.options.target,function(e){var n=t.$(this);n.is('a[href="#"]')&&e.preventDefault(),i.find(i.options.target).not(n).removeClass(i.options.activeClass).blur(),n.addClass(i.options.activeClass),i.find(i.options.target).not(n).attr("aria-checked","false"),n.attr("aria-checked","true"),i.trigger("change.uk.button",[n])})},getSelected:function(){return this.find("."+this.options.activeClass)}}),t.component("buttonCheckbox",{defaults:{activeClass:"uk-active",target:".uk-button"},boot:function(){t.$html.on("click.buttoncheckbox.uikit","[data-uk-button-checkbox]",function(i){var e=t.$(this);if(!e.data("buttonCheckbox")){var n=t.buttonCheckbox(e,t.Utils.options(e.attr("data-uk-button-checkbox"))),o=t.$(i.target);o.is(n.options.target)&&o.trigger("click")}})},init:function(){var i=this;this.find(i.options.target).attr("aria-checked","false").filter("."+i.options.activeClass).attr("aria-checked","true"),this.on("click",this.options.target,function(e){var n=t.$(this);n.is('a[href="#"]')&&e.preventDefault(),n.toggleClass(i.options.activeClass).blur(),n.attr("aria-checked",n.hasClass(i.options.activeClass)),i.trigger("change.uk.button",[n])})},getSelected:function(){return this.find("."+this.options.activeClass)}}),t.component("button",{defaults:{},boot:function(){t.$html.on("click.button.uikit","[data-uk-button]",function(){var i=t.$(this);if(!i.data("button")){{t.button(i,t.Utils.options(i.attr("data-uk-button")))}i.trigger("click")}})},init:function(){var t=this;this.element.attr("aria-pressed",this.element.hasClass("uk-active")),this.on("click",function(i){t.element.is('a[href="#"]')&&i.preventDefault(),t.toggle(),t.trigger("change.uk.button",[t.element.blur().hasClass("uk-active")])})},toggle:function(){this.element.toggleClass("uk-active"),this.element.attr("aria-pressed",this.element.hasClass("uk-active"))}})}(UIkit),function(t){"use strict";function i(i,e,n,o){if(i=t.$(i),e=t.$(e),n=n||window.innerWidth,o=o||i.offset(),e.length){var s=e.outerWidth();if(i.css("min-width",s),"right"==t.langdirection){var a=n-(e.offset().left+s),r=n-(i.offset().left+i.outerWidth());i.css("margin-right",a-r)}else i.css("margin-left",e.offset().left-o.left)}}var e,n=!1,o={x:{"bottom-left":"bottom-right","bottom-right":"bottom-left","bottom-center":"bottom-center","top-left":"top-right","top-right":"top-left","top-center":"top-center","left-top":"right-top","left-bottom":"right-bottom","left-center":"right-center","right-top":"left-top","right-bottom":"left-bottom","right-center":"left-center"},y:{"bottom-left":"top-left","bottom-right":"top-right","bottom-center":"top-center","top-left":"bottom-left","top-right":"bottom-right","top-center":"bottom-center","left-top":"left-bottom","left-bottom":"left-top","left-center":"left-center","right-top":"right-bottom","right-bottom":"right-top","right-center":"right-center"},xy:{"bottom-left":"top-right","bottom-right":"top-left","bottom-center":"top-center","top-left":"bottom-right","top-right":"bottom-left","top-center":"bottom-center","left-top":"right-bottom","left-bottom":"right-top","left-center":"right-center","right-top":"left-bottom","right-bottom":"left-top","right-center":"left-center"}};t.component("dropdown",{defaults:{mode:"hover",pos:"bottom-left",offset:0,remaintime:800,justify:!1,boundary:t.$win,delay:0,dropdownSelector:".uk-dropdown,.uk-dropdown-blank",hoverDelayIdle:250,preventflip:!1},remainIdle:!1,boot:function(){var i=t.support.touch?"click":"mouseenter";t.$html.on(i+".dropdown.uikit","[data-uk-dropdown]",function(e){var n=t.$(this);if(!n.data("dropdown")){var o=t.dropdown(n,t.Utils.options(n.attr("data-uk-dropdown")));("click"==i||"mouseenter"==i&&"hover"==o.options.mode)&&o.element.trigger(i),o.element.find(o.options.dropdownSelector).length&&e.preventDefault()}})},init:function(){var i=this;this.dropdown=this.find(this.options.dropdownSelector),this.offsetParent=this.dropdown.parents().filter(function(){return-1!==t.$.inArray(t.$(this).css("position"),["relative","fixed","absolute"])}).slice(0,1),this.centered=this.dropdown.hasClass("uk-dropdown-center"),this.justified=this.options.justify?t.$(this.options.justify):!1,this.boundary=t.$(this.options.boundary),this.boundary.length||(this.boundary=t.$win),this.dropdown.hasClass("uk-dropdown-up")&&(this.options.pos="top-left"),this.dropdown.hasClass("uk-dropdown-flip")&&(this.options.pos=this.options.pos.replace("left","right")),this.dropdown.hasClass("uk-dropdown-center")&&(this.options.pos=this.options.pos.replace(/(left|right)/,"center")),this.element.attr("aria-haspopup","true"),this.element.attr("aria-expanded",this.element.hasClass("uk-open")),"click"==this.options.mode||t.support.touch?this.on("click.uk.dropdown",function(e){var n=t.$(e.target);n.parents(i.options.dropdownSelector).length||((n.is("a[href='#']")||n.parent().is("a[href='#']")||i.dropdown.length&&!i.dropdown.is(":visible"))&&e.preventDefault(),n.blur()),i.element.hasClass("uk-open")?(!i.dropdown.find(e.target).length||n.is(".uk-dropdown-close")||n.parents(".uk-dropdown-close").length)&&i.hide():i.show()}):this.on("mouseenter",function(){i.trigger("pointerenter.uk.dropdown",[i]),i.remainIdle&&clearTimeout(i.remainIdle),e&&clearTimeout(e),n&&n==i||(e=n&&n!=i?setTimeout(function(){e=setTimeout(i.show.bind(i),i.options.delay)},i.options.hoverDelayIdle):setTimeout(i.show.bind(i),i.options.delay))}).on("mouseleave",function(){e&&clearTimeout(e),i.remainIdle=setTimeout(function(){n&&n==i&&i.hide()},i.options.remaintime),i.trigger("pointerleave.uk.dropdown",[i])}).on("click",function(e){var o=t.$(e.target);return i.remainIdle&&clearTimeout(i.remainIdle),n&&n==i?((!i.dropdown.find(e.target).length||o.is(".uk-dropdown-close")||o.parents(".uk-dropdown-close").length)&&i.hide(),void 0):((o.is("a[href='#']")||o.parent().is("a[href='#']"))&&e.preventDefault(),i.show(),void 0)})},show:function(){t.$html.off("click.outer.dropdown"),n&&n!=this&&n.hide(!0),e&&clearTimeout(e),this.trigger("beforeshow.uk.dropdown",[this]),this.checkDimensions(),this.element.addClass("uk-open"),this.element.attr("aria-expanded","true"),this.trigger("show.uk.dropdown",[this]),t.Utils.checkDisplay(this.dropdown,!0),n=this,this.registerOuterClick()},hide:function(t){this.trigger("beforehide.uk.dropdown",[this,t]),this.element.removeClass("uk-open"),this.remainIdle&&clearTimeout(this.remainIdle),this.remainIdle=!1,this.element.attr("aria-expanded","false"),this.trigger("hide.uk.dropdown",[this,t]),n==this&&(n=!1)},registerOuterClick:function(){var i=this;t.$html.off("click.outer.dropdown"),setTimeout(function(){t.$html.on("click.outer.dropdown",function(o){e&&clearTimeout(e);t.$(o.target);n!=i||i.element.find(o.target).length||(i.hide(!0),t.$html.off("click.outer.dropdown"))})},10)},checkDimensions:function(){if(this.dropdown.length){this.dropdown.removeClass("uk-dropdown-top uk-dropdown-bottom uk-dropdown-left uk-dropdown-right uk-dropdown-stack").css({"top-left":"",left:"","margin-left":"","margin-right":""}),this.justified&&this.justified.length&&this.dropdown.css("min-width","");var e,n=t.$.extend({},this.offsetParent.offset(),{width:this.offsetParent[0].offsetWidth,height:this.offsetParent[0].offsetHeight}),s=this.options.offset,a=this.dropdown,r=(a.show().offset()||{left:0,top:0},a.outerWidth()),l=a.outerHeight(),c=this.boundary.width(),u=(this.boundary[0]!==window&&this.boundary.offset()?this.boundary.offset():{top:0,left:0},this.options.pos),h={"bottom-left":{top:0+n.height+s,left:0},"bottom-right":{top:0+n.height+s,left:0+n.width-r},"bottom-center":{top:0+n.height+s,left:0+n.width/2-r/2},"top-left":{top:0-l-s,left:0},"top-right":{top:0-l-s,left:0+n.width-r},"top-center":{top:0-l-s,left:0+n.width/2-r/2},"left-top":{top:0,left:0-r-s},"left-bottom":{top:0+n.height-l,left:0-r-s},"left-center":{top:0+n.height/2-l/2,left:0-r-s},"right-top":{top:0,left:0+n.width+s},"right-bottom":{top:0+n.height-l,left:0+n.width+s},"right-center":{top:0+n.height/2-l/2,left:0+n.width+s}},d={};if(e=u.split("-"),d=h[u]?h[u]:h["bottom-left"],this.justified&&this.justified.length)i(a.css({left:0}),this.justified,c);else if(this.options.preventflip!==!0){var p;switch(this.checkBoundary(n.left+d.left,n.top+d.top,r,l,c)){case"x":"x"!==this.options.preventflip&&(p=o.x[u]||"right-top");break;case"y":"y"!==this.options.preventflip&&(p=o.y[u]||"top-left");break;case"xy":this.options.preventflip||(p=o.xy[u]||"right-bottom")}p&&(e=p.split("-"),d=h[p]?h[p]:h["bottom-left"],this.checkBoundary(n.left+d.left,n.top+d.top,r,l,c)&&(e=u.split("-"),d=h[u]?h[u]:h["bottom-left"]))}r>c&&(a.addClass("uk-dropdown-stack"),this.trigger("stack.uk.dropdown",[this])),a.css(d).css("display","").addClass("uk-dropdown-"+e[0]) +}},checkBoundary:function(i,e,n,o,s){var a="";return(0>i||i-t.$win.scrollLeft()+n>s)&&(a+="x"),(e-t.$win.scrollTop()<0||e-t.$win.scrollTop()+o>window.innerHeight)&&(a+="y"),a}}),t.component("dropdownOverlay",{defaults:{justify:!1,cls:"",duration:200},boot:function(){t.ready(function(i){t.$("[data-uk-dropdown-overlay]",i).each(function(){var i=t.$(this);i.data("dropdownOverlay")||t.dropdownOverlay(i,t.Utils.options(i.attr("data-uk-dropdown-overlay")))})})},init:function(){var e=this;this.justified=this.options.justify?t.$(this.options.justify):!1,this.overlay=this.element.find("uk-dropdown-overlay"),this.overlay.length||(this.overlay=t.$('
                ').appendTo(this.element)),this.overlay.addClass(this.options.cls),this.on({"beforeshow.uk.dropdown":function(t,n){e.dropdown=n,e.justified&&e.justified.length&&i(e.overlay.css({display:"block","margin-left":"","margin-right":""}),e.justified,e.justified.outerWidth())},"show.uk.dropdown":function(){var i=e.dropdown.dropdown.outerHeight(!0);e.dropdown.element.removeClass("uk-open"),e.overlay.stop().css("display","block").animate({height:i},e.options.duration,function(){e.dropdown.dropdown.css("visibility",""),e.dropdown.element.addClass("uk-open"),t.Utils.checkDisplay(e.dropdown.dropdown,!0)}),e.pointerleave=!1},"hide.uk.dropdown":function(){e.overlay.stop().animate({height:0},e.options.duration)},"pointerenter.uk.dropdown":function(){clearTimeout(e.remainIdle)},"pointerleave.uk.dropdown":function(){e.pointerleave=!0}}),this.overlay.on({mouseenter:function(){e.remainIdle&&(clearTimeout(e.dropdown.remainIdle),clearTimeout(e.remainIdle))},mouseleave:function(){e.pointerleave&&n&&(e.remainIdle=setTimeout(function(){n&&n.hide()},n.options.remaintime))}})}})}(UIkit),function(t){"use strict";var i=[];t.component("gridMatchHeight",{defaults:{target:!1,row:!0,ignorestacked:!1,observe:!1},boot:function(){t.ready(function(i){t.$("[data-uk-grid-match]",i).each(function(){var i,e=t.$(this);e.data("gridMatchHeight")||(i=t.gridMatchHeight(e,t.Utils.options(e.attr("data-uk-grid-match"))))})})},init:function(){var e=this;this.columns=this.element.children(),this.elements=this.options.target?this.find(this.options.target):this.columns,this.columns.length&&(t.$win.on("load resize orientationchange",function(){var i=function(){e.element.is(":visible")&&e.match()};return t.$(function(){i()}),t.Utils.debounce(i,50)}()),this.options.observe&&t.domObserve(this.element,function(){e.element.is(":visible")&&e.match()}),this.on("display.uk.check",function(){this.element.is(":visible")&&this.match()}.bind(this)),i.push(this))},match:function(){var i=this.columns.filter(":visible:first");if(i.length){var e=Math.ceil(100*parseFloat(i.css("width"))/parseFloat(i.parent().css("width")))>=100;return e&&!this.options.ignorestacked?this.revert():t.Utils.matchHeights(this.elements,this.options),this}},revert:function(){return this.elements.css("min-height",""),this}}),t.component("gridMargin",{defaults:{cls:"uk-grid-margin",rowfirst:"uk-row-first"},boot:function(){t.ready(function(i){t.$("[data-uk-grid-margin]",i).each(function(){var i,e=t.$(this);e.data("gridMargin")||(i=t.gridMargin(e,t.Utils.options(e.attr("data-uk-grid-margin"))))})})},init:function(){t.stackMargin(this.element,this.options)}})}(UIkit),function(t){"use strict";function i(i,e){return e?("object"==typeof i?(i=i instanceof jQuery?i:t.$(i),i.parent().length&&(e.persist=i,e.persist.data("modalPersistParent",i.parent()))):i="string"==typeof i||"number"==typeof i?t.$("
                ").html(i):t.$("
                ").html("UIkit.modal Error: Unsupported data type: "+typeof i),i.appendTo(e.element.find(".uk-modal-dialog")),e):void 0}var e,n=!1,o=0,s=t.$html;t.$win.on("resize orientationchange",t.Utils.debounce(function(){t.$(".uk-modal.uk-open").each(function(){t.$(this).data("modal").resize()})},150)),t.component("modal",{defaults:{keyboard:!0,bgclose:!0,minScrollHeight:150,center:!1,modal:!0},scrollable:!1,transition:!1,hasTransitioned:!0,init:function(){if(e||(e=t.$("body")),this.element.length){var i=this;this.paddingdir="padding-"+("left"==t.langdirection?"right":"left"),this.dialog=this.find(".uk-modal-dialog"),this.active=!1,this.element.attr("aria-hidden",this.element.hasClass("uk-open")),this.on("click",".uk-modal-close",function(t){t.preventDefault(),i.hide()}).on("click",function(e){var n=t.$(e.target);n[0]==i.element[0]&&i.options.bgclose&&i.hide()}),t.domObserve(this.element,function(){i.resize()})}},toggle:function(){return this[this.isActive()?"hide":"show"]()},show:function(){if(this.element.length){var i=this;if(!this.isActive())return this.options.modal&&n&&n.hide(!0),this.element.removeClass("uk-open").show(),this.resize(!0),this.options.modal&&(n=this),this.active=!0,o++,t.support.transition?(this.hasTransitioned=!1,this.element.one(t.support.transition.end,function(){i.hasTransitioned=!0}).addClass("uk-open")):this.element.addClass("uk-open"),s.addClass("uk-modal-page").height(),this.element.attr("aria-hidden","false"),this.element.trigger("show.uk.modal"),t.Utils.checkDisplay(this.dialog,!0),this}},hide:function(i){if(!i&&t.support.transition&&this.hasTransitioned){var e=this;this.one(t.support.transition.end,function(){e._hide()}).removeClass("uk-open")}else this._hide();return this},resize:function(t){if(this.isActive()||t){var i=e.width();if(this.scrollbarwidth=window.innerWidth-i,e.css(this.paddingdir,this.scrollbarwidth),this.element.css("overflow-y",this.scrollbarwidth?"scroll":"auto"),!this.updateScrollable()&&this.options.center){var n=this.dialog.outerHeight(),o=parseInt(this.dialog.css("margin-top"),10)+parseInt(this.dialog.css("margin-bottom"),10);n+oi?20:i)-e;return t.css({"max-height":o0?o--:o=0,this.element.hide().removeClass("uk-open"),this.element.attr("aria-hidden","true"),o||(s.removeClass("uk-modal-page"),e.css(this.paddingdir,"")),n===this&&(n=!1),this.trigger("hide.uk.modal")},isActive:function(){return this.element.hasClass("uk-open")}}),t.component("modalTrigger",{boot:function(){t.$html.on("click.modal.uikit","[data-uk-modal]",function(i){var e=t.$(this);if(e.is("a")&&i.preventDefault(),!e.data("modalTrigger")){var n=t.modalTrigger(e,t.Utils.options(e.attr("data-uk-modal")));n.show()}}),t.$html.on("keydown.modal.uikit",function(t){n&&27===t.keyCode&&n.options.keyboard&&(t.preventDefault(),n.hide())})},init:function(){var i=this;this.options=t.$.extend({target:i.element.is("a")?i.element.attr("href"):!1},this.options),this.modal=t.modal(this.options.target,this.options),this.on("click",function(t){t.preventDefault(),i.show()}),this.proxy(this.modal,"show hide isActive")}}),t.modal.dialog=function(e,n){var o=t.modal(t.$(t.modal.dialog.template).appendTo("body"),n);return o.on("hide.uk.modal",function(){o.persist&&(o.persist.appendTo(o.persist.data("modalPersistParent")),o.persist=!1),o.element.remove()}),i(e,o),o},t.modal.dialog.template='
                ',t.modal.alert=function(i,e){e=t.$.extend(!0,{bgclose:!1,keyboard:!1,modal:!1,labels:t.modal.labels},e);var n=t.modal.dialog(['
                '+String(i)+"
                ",'"].join(""),e);return n.on("show.uk.modal",function(){setTimeout(function(){n.element.find("button:first").focus()},50)}),n.show()},t.modal.confirm=function(i,e,n){var o=arguments.length>1&&arguments[arguments.length-1]?arguments[arguments.length-1]:{};e=t.$.isFunction(e)?e:function(){},n=t.$.isFunction(n)?n:function(){},o=t.$.extend(!0,{bgclose:!1,keyboard:!1,modal:!1,labels:t.modal.labels},t.$.isFunction(o)?{}:o);var s=t.modal.dialog(['
                '+String(i)+"
                ",'"].join(""),o);return s.element.find(".js-modal-confirm, .js-modal-confirm-cancel").on("click",function(){t.$(this).is(".js-modal-confirm")?e():n(),s.hide()}),s.on("show.uk.modal",function(){setTimeout(function(){s.element.find(".js-modal-confirm").focus()},50)}),s.show()},t.modal.prompt=function(i,e,n,o){n=t.$.isFunction(n)?n:function(){},o=t.$.extend(!0,{bgclose:!1,keyboard:!1,modal:!1,labels:t.modal.labels},o);var s=t.modal.dialog([i?'
                '+String(i)+"
                ":"",'

                ','"].join(""),o),a=s.element.find("input[type='text']").val(e||"").on("keyup",function(t){13==t.keyCode&&s.element.find(".js-modal-ok").trigger("click")});return s.element.find(".js-modal-ok").on("click",function(){n(a.val())!==!1&&s.hide()}),s.on("show.uk.modal",function(){setTimeout(function(){a.focus()},50)}),s.show()},t.modal.blockUI=function(i,e){var n=t.modal.dialog(['
                '+String(i||'
                ...
                ')+"
                "].join(""),t.$.extend({bgclose:!1,keyboard:!1,modal:!1},e));return n.content=n.element.find(".uk-modal-content:first"),n.show()},t.modal.labels={Ok:"Ok",Cancel:"Cancel"}}(UIkit),function(t){"use strict";function i(i){var e=t.$(i),n="auto";if(e.is(":visible"))n=e.outerHeight();else{var o={position:e.css("position"),visibility:e.css("visibility"),display:e.css("display")};n=e.css({position:"absolute",visibility:"hidden",display:"block"}).outerHeight(),e.css(o)}return n}t.component("nav",{defaults:{toggle:">li.uk-parent > a[href='#']",lists:">li.uk-parent > ul",multiple:!1},boot:function(){t.ready(function(i){t.$("[data-uk-nav]",i).each(function(){var i=t.$(this);if(!i.data("nav")){t.nav(i,t.Utils.options(i.attr("data-uk-nav")))}})})},init:function(){var i=this;this.on("click.uk.nav",this.options.toggle,function(e){e.preventDefault();var n=t.$(this);i.open(n.parent()[0]==i.element[0]?n:n.parent("li"))}),this.find(this.options.lists).each(function(){var e=t.$(this),n=e.parent(),o=n.hasClass("uk-active");e.wrap('
                '),n.data("list-container",e.parent()[o?"removeClass":"addClass"]("uk-hidden")),n.attr("aria-expanded",n.hasClass("uk-open")),o&&i.open(n,!0)})},open:function(e,n){var o=this,s=this.element,a=t.$(e),r=a.data("list-container");this.options.multiple||s.children(".uk-open").not(e).each(function(){var i=t.$(this);i.data("list-container")&&i.data("list-container").stop().animate({height:0},function(){t.$(this).parent().removeClass("uk-open").end().addClass("uk-hidden")})}),a.toggleClass("uk-open"),a.attr("aria-expanded",a.hasClass("uk-open")),r&&(a.hasClass("uk-open")&&r.removeClass("uk-hidden"),n?(r.stop().height(a.hasClass("uk-open")?"auto":0),a.hasClass("uk-open")||r.addClass("uk-hidden"),this.trigger("display.uk.check")):r.stop().animate({height:a.hasClass("uk-open")?i(r.find("ul:first")):0},function(){a.hasClass("uk-open")?r.css("height",""):r.addClass("uk-hidden"),o.trigger("display.uk.check")}))}})}(UIkit),function(t){"use strict";var i={x:window.scrollX,y:window.scrollY},e=(t.$win,t.$doc,t.$html),n={show:function(n){if(n=t.$(n),n.length){var o=t.$("body"),s=n.find(".uk-offcanvas-bar:first"),a="right"==t.langdirection,r=s.hasClass("uk-offcanvas-bar-flip")?-1:1,l=r*(a?-1:1),c=window.innerWidth-o.width();i={x:window.pageXOffset,y:window.pageYOffset},n.addClass("uk-active"),o.css({width:window.innerWidth-c,height:window.innerHeight}).addClass("uk-offcanvas-page"),o.css(a?"margin-right":"margin-left",(a?-1:1)*s.outerWidth()*l).width(),e.css("margin-top",-1*i.y),s.addClass("uk-offcanvas-bar-show"),this._initElement(n),s.trigger("show.uk.offcanvas",[n,s]),n.attr("aria-hidden","false")}},hide:function(n){var o=t.$("body"),s=t.$(".uk-offcanvas.uk-active"),a="right"==t.langdirection,r=s.find(".uk-offcanvas-bar:first"),l=function(){o.removeClass("uk-offcanvas-page").css({width:"",height:"","margin-left":"","margin-right":""}),s.removeClass("uk-active"),r.removeClass("uk-offcanvas-bar-show"),e.css("margin-top",""),window.scrollTo(i.x,i.y),r.trigger("hide.uk.offcanvas",[s,r]),s.attr("aria-hidden","true")};s.length&&(t.support.transition&&!n?(o.one(t.support.transition.end,function(){l()}).css(a?"margin-right":"margin-left",""),setTimeout(function(){r.removeClass("uk-offcanvas-bar-show")},0)):l())},_initElement:function(i){i.data("OffcanvasInit")||(i.on("click.uk.offcanvas swipeRight.uk.offcanvas swipeLeft.uk.offcanvas",function(i){var e=t.$(i.target);if(!i.type.match(/swipe/)&&!e.hasClass("uk-offcanvas-close")){if(e.hasClass("uk-offcanvas-bar"))return;if(e.parents(".uk-offcanvas-bar:first").length)return}i.stopImmediatePropagation(),n.hide()}),i.on("click","a[href*='#']",function(){var i=t.$(this),e=i.attr("href");"#"!=e&&(t.$doc.one("hide.uk.offcanvas",function(){var n;try{n=t.$(i[0].hash)}catch(o){n=""}n.length||(n=t.$('[name="'+i[0].hash.replace("#","")+'"]')),n.length&&t.Utils.scrollToElement?t.Utils.scrollToElement(n,t.Utils.options(i.attr("data-uk-smooth-scroll")||"{}")):window.location.href=e}),n.hide())}),i.data("OffcanvasInit",!0))}};t.component("offcanvasTrigger",{boot:function(){e.on("click.offcanvas.uikit","[data-uk-offcanvas]",function(i){i.preventDefault();var e=t.$(this);if(!e.data("offcanvasTrigger")){{t.offcanvasTrigger(e,t.Utils.options(e.attr("data-uk-offcanvas")))}e.trigger("click")}}),e.on("keydown.uk.offcanvas",function(t){27===t.keyCode&&n.hide()})},init:function(){var i=this;this.options=t.$.extend({target:i.element.is("a")?i.element.attr("href"):!1},this.options),this.on("click",function(t){t.preventDefault(),n.show(i.options.target)})}}),t.offcanvas=n}(UIkit),function(t){"use strict";function i(i,e,n){var o,s=t.$.Deferred(),a=i,r=i;return n[0]===e[0]?(s.resolve(),s.promise()):("object"==typeof i&&(a=i[0],r=i[1]||i[0]),t.$body.css("overflow-x","hidden"),o=function(){e&&e.hide().removeClass("uk-active "+r+" uk-animation-reverse"),n.addClass(a).one(t.support.animation.end,function(){setTimeout(function(){n.removeClass(""+a).css({opacity:"",display:""})},0),s.resolve(),t.$body.css("overflow-x",""),e&&e.css({opacity:"",display:""})}.bind(this)).show()},n.css("animation-duration",this.options.duration+"ms"),e&&e.length?(e.css("animation-duration",this.options.duration+"ms"),e.css("display","none").addClass(r+" uk-animation-reverse").one(t.support.animation.end,function(){o()}.bind(this)).css("display","")):(n.addClass("uk-active"),o()),s.promise())}var e;t.component("switcher",{defaults:{connect:!1,toggle:">*",active:0,animation:!1,duration:200,swiping:!0},animating:!1,boot:function(){t.ready(function(i){t.$("[data-uk-switcher]",i).each(function(){var i=t.$(this);if(!i.data("switcher")){t.switcher(i,t.Utils.options(i.attr("data-uk-switcher")))}})})},init:function(){var i=this;if(this.on("click.uk.switcher",this.options.toggle,function(t){t.preventDefault(),i.show(this)}),this.options.connect){this.connect=t.$(this.options.connect),this.connect.children().removeClass("uk-active"),this.connect.length&&(this.connect.children().attr("aria-hidden","true"),this.connect.on("click","[data-uk-switcher-item]",function(e){e.preventDefault();var n=t.$(this).attr("data-uk-switcher-item");if(i.index!=n)switch(n){case"next":case"previous":i.show(i.index+("next"==n?1:-1));break;default:i.show(parseInt(n,10))}}),this.options.swiping&&this.connect.on("swipeRight swipeLeft",function(t){t.preventDefault(),window.getSelection().toString()||i.show(i.index+("swipeLeft"==t.type?1:-1))}));var e=this.find(this.options.toggle),n=e.filter(".uk-active");if(n.length)this.show(n,!1);else{if(this.options.active===!1)return;n=e.eq(this.options.active),this.show(n.length?n:e.eq(0),!1)}e.not(n).attr("aria-expanded","false"),n.attr("aria-expanded","true")}},show:function(n,o){if(!this.animating){if(isNaN(n))n=t.$(n);else{var s=this.find(this.options.toggle);n=0>n?s.length-1:n,n=s.eq(s[n]?n:0)}var a=this,s=this.find(this.options.toggle),r=t.$(n),l=e[this.options.animation]||function(t,n){if(!a.options.animation)return e.none.apply(a);var o=a.options.animation.split(",");return 1==o.length&&(o[1]=o[0]),o[0]=o[0].trim(),o[1]=o[1].trim(),i.apply(a,[o,t,n])};o!==!1&&t.support.animation||(l=e.none),r.hasClass("uk-disabled")||(s.attr("aria-expanded","false"),r.attr("aria-expanded","true"),s.filter(".uk-active").removeClass("uk-active"),r.addClass("uk-active"),this.options.connect&&this.connect.length&&(this.index=this.find(this.options.toggle).index(r),-1==this.index&&(this.index=0),this.connect.each(function(){var i=t.$(this),e=t.$(i.children()),n=t.$(e.filter(".uk-active")),o=t.$(e.eq(a.index));a.animating=!0,l.apply(a,[n,o]).then(function(){n.removeClass("uk-active"),o.addClass("uk-active"),n.attr("aria-hidden","true"),o.attr("aria-hidden","false"),t.Utils.checkDisplay(o,!0),a.animating=!1})})),this.trigger("show.uk.switcher",[r]))}}}),e={none:function(){var i=t.$.Deferred();return i.resolve(),i.promise()},fade:function(t,e){return i.apply(this,["uk-animation-fade",t,e])},"slide-bottom":function(t,e){return i.apply(this,["uk-animation-slide-bottom",t,e])},"slide-top":function(t,e){return i.apply(this,["uk-animation-slide-top",t,e])},"slide-vertical":function(t,e){var n=["uk-animation-slide-top","uk-animation-slide-bottom"];return t&&t.index()>e.index()&&n.reverse(),i.apply(this,[n,t,e])},"slide-left":function(t,e){return i.apply(this,["uk-animation-slide-left",t,e])},"slide-right":function(t,e){return i.apply(this,["uk-animation-slide-right",t,e])},"slide-horizontal":function(t,e){var n=["uk-animation-slide-right","uk-animation-slide-left"];return t&&t.index()>e.index()&&n.reverse(),i.apply(this,[n,t,e])},scale:function(t,e){return i.apply(this,["uk-animation-scale-up",t,e])}},t.switcher.animations=e}(UIkit),function(t){"use strict";t.component("tab",{defaults:{target:">li:not(.uk-tab-responsive, .uk-disabled)",connect:!1,active:0,animation:!1,duration:200,swiping:!0},boot:function(){t.ready(function(i){t.$("[data-uk-tab]",i).each(function(){var i=t.$(this);if(!i.data("tab")){t.tab(i,t.Utils.options(i.attr("data-uk-tab")))}})})},init:function(){var i=this;this.current=!1,this.on("click.uk.tab",this.options.target,function(e){if(e.preventDefault(),!i.switcher||!i.switcher.animating){var n=i.find(i.options.target).not(this);n.removeClass("uk-active").blur(),i.trigger("change.uk.tab",[t.$(this).addClass("uk-active"),i.current]),i.current=t.$(this),i.options.connect||(n.attr("aria-expanded","false"),t.$(this).attr("aria-expanded","true"))}}),this.options.connect&&(this.connect=t.$(this.options.connect)),this.responsivetab=t.$('
              • ').append('
                  '),this.responsivetab.dropdown=this.responsivetab.find(".uk-dropdown"),this.responsivetab.lst=this.responsivetab.dropdown.find("ul"),this.responsivetab.caption=this.responsivetab.find("a:first"),this.element.hasClass("uk-tab-bottom")&&this.responsivetab.dropdown.addClass("uk-dropdown-up"),this.responsivetab.lst.on("click.uk.tab","a",function(e){e.preventDefault(),e.stopPropagation();var n=t.$(this);i.element.children("li:not(.uk-tab-responsive)").eq(n.data("index")).trigger("click")}),this.on("show.uk.switcher change.uk.tab",function(t,e){i.responsivetab.caption.html(e.text())}),this.element.append(this.responsivetab),this.options.connect&&(this.switcher=t.switcher(this.element,{toggle:">li:not(.uk-tab-responsive)",connect:this.options.connect,active:this.options.active,animation:this.options.animation,duration:this.options.duration,swiping:this.options.swiping})),t.dropdown(this.responsivetab,{mode:"click",preventflip:"y"}),i.trigger("change.uk.tab",[this.element.find(this.options.target).not(".uk-tab-responsive").filter(".uk-active")]),this.check(),t.$win.on("resize orientationchange",t.Utils.debounce(function(){i.element.is(":visible")&&i.check()},100)),this.on("display.uk.check",function(){i.element.is(":visible")&&i.check()})},check:function(){var i=this.element.children("li:not(.uk-tab-responsive)").removeClass("uk-hidden");if(!i.length)return this.responsivetab.addClass("uk-hidden"),void 0;var e,n,o,s=i.eq(0).offset().top+Math.ceil(i.eq(0).height()/2),a=!1;if(this.responsivetab.lst.empty(),i.each(function(){t.$(this).offset().top>s&&(a=!0)}),a)for(var r=0;r-1?"&":"?","enablejsapi=1&api=1"].join(""))}},check:function(){this.element.css({width:"",height:""}),this.dimension={w:this.element.width(),h:this.element.height()},this.element.attr("width")&&!isNaN(this.element.attr("width"))&&(this.dimension.w=this.element.attr("width")),this.element.attr("height")&&!isNaN(this.element.attr("height"))&&(this.dimension.h=this.element.attr("height")),this.ratio=this.dimension.w/this.dimension.h;var t,i,e=this.parent.width(),n=this.parent.height();e/this.ratio