uikit-rails 0.0.2 → 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (177) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +9 -3
  3. data/Gemfile +2 -1
  4. data/LICENSE.txt +21 -0
  5. data/README.md +65 -0
  6. data/Rakefile +0 -1
  7. data/assets/fonts/FontAwesome.otf +0 -0
  8. data/assets/fonts/fontawesome-webfont.ttf +0 -0
  9. data/assets/fonts/fontawesome-webfont.woff +0 -0
  10. data/assets/fonts/fontawesome-webfont.woff2 +0 -0
  11. data/assets/javascripts/components/accordion.js +174 -0
  12. data/assets/javascripts/components/accordion.min.js +2 -0
  13. data/assets/javascripts/components/autocomplete.js +334 -0
  14. data/assets/javascripts/components/autocomplete.min.js +2 -0
  15. data/assets/javascripts/components/datepicker.js +3166 -0
  16. data/assets/javascripts/components/datepicker.min.js +3 -0
  17. data/assets/javascripts/components/form-password.js +67 -0
  18. data/assets/javascripts/components/form-password.min.js +2 -0
  19. data/assets/javascripts/components/form-select.js +70 -0
  20. data/assets/javascripts/components/form-select.min.js +2 -0
  21. data/assets/javascripts/components/grid.js +527 -0
  22. data/assets/javascripts/components/grid.min.js +2 -0
  23. data/assets/javascripts/components/htmleditor.js +623 -0
  24. data/assets/javascripts/components/htmleditor.min.js +2 -0
  25. data/assets/javascripts/components/lightbox.js +555 -0
  26. data/assets/javascripts/components/lightbox.min.js +2 -0
  27. data/assets/javascripts/components/nestable.js +638 -0
  28. data/assets/javascripts/components/nestable.min.js +2 -0
  29. data/assets/javascripts/components/notify.js +189 -0
  30. data/assets/javascripts/components/notify.min.js +2 -0
  31. data/assets/javascripts/components/pagination.js +147 -0
  32. data/assets/javascripts/components/pagination.min.js +2 -0
  33. data/assets/javascripts/components/parallax.js +435 -0
  34. data/assets/javascripts/components/parallax.min.js +2 -0
  35. data/assets/javascripts/components/search.js +92 -0
  36. data/assets/javascripts/components/search.min.js +2 -0
  37. data/assets/javascripts/components/slider.js +531 -0
  38. data/assets/javascripts/components/slider.min.js +2 -0
  39. data/assets/javascripts/components/slideset.js +506 -0
  40. data/assets/javascripts/components/slideset.min.js +2 -0
  41. data/assets/javascripts/components/slideshow-fx.js +375 -0
  42. data/assets/javascripts/components/slideshow-fx.min.js +2 -0
  43. data/assets/javascripts/components/slideshow.js +562 -0
  44. data/assets/javascripts/components/slideshow.min.js +2 -0
  45. data/assets/javascripts/components/sortable.js +688 -0
  46. data/assets/javascripts/components/sortable.min.js +2 -0
  47. data/assets/javascripts/components/sticky.js +359 -0
  48. data/assets/javascripts/components/sticky.min.js +2 -0
  49. data/assets/javascripts/components/timepicker.js +192 -0
  50. data/assets/javascripts/components/timepicker.min.js +2 -0
  51. data/assets/javascripts/components/tooltip.js +234 -0
  52. data/assets/javascripts/components/tooltip.min.js +2 -0
  53. data/assets/javascripts/components/upload.js +260 -0
  54. data/assets/javascripts/components/upload.min.js +2 -0
  55. data/assets/javascripts/core/alert.js +66 -0
  56. data/assets/javascripts/core/alert.min.js +2 -0
  57. data/assets/javascripts/core/button.js +157 -0
  58. data/assets/javascripts/core/button.min.js +2 -0
  59. data/assets/javascripts/core/core.js +730 -0
  60. data/assets/javascripts/core/core.min.js +2 -0
  61. data/assets/javascripts/core/cover.js +95 -0
  62. data/assets/javascripts/core/cover.min.js +2 -0
  63. data/assets/javascripts/core/dropdown.js +514 -0
  64. data/assets/javascripts/core/dropdown.min.js +2 -0
  65. data/assets/javascripts/core/grid.js +114 -0
  66. data/assets/javascripts/core/grid.min.js +2 -0
  67. data/assets/javascripts/core/modal.js +384 -0
  68. data/assets/javascripts/core/modal.min.js +2 -0
  69. data/assets/javascripts/core/nav.js +136 -0
  70. data/assets/javascripts/core/nav.min.js +2 -0
  71. data/assets/javascripts/core/offcanvas.js +180 -0
  72. data/assets/javascripts/core/offcanvas.min.js +2 -0
  73. data/assets/javascripts/core/scrollspy.js +208 -0
  74. data/assets/javascripts/core/scrollspy.min.js +2 -0
  75. data/assets/javascripts/core/smooth-scroll.js +62 -0
  76. data/assets/javascripts/core/smooth-scroll.min.js +2 -0
  77. data/assets/javascripts/core/switcher.js +309 -0
  78. data/assets/javascripts/core/switcher.min.js +2 -0
  79. data/assets/javascripts/core/tab.js +167 -0
  80. data/assets/javascripts/core/tab.min.js +2 -0
  81. data/assets/javascripts/core/toggle.js +120 -0
  82. data/assets/javascripts/core/toggle.min.js +2 -0
  83. data/assets/javascripts/core/touch.js +175 -0
  84. data/assets/javascripts/core/touch.min.js +2 -0
  85. data/assets/javascripts/core/utility.js +289 -0
  86. data/assets/javascripts/core/utility.min.js +2 -0
  87. data/assets/javascripts/uikit-components.js +23 -0
  88. data/assets/javascripts/uikit.js +3706 -0
  89. data/assets/javascripts/uikit.min.js +3 -0
  90. data/assets/stylesheets/components/accordion.scss +94 -0
  91. data/assets/stylesheets/components/autocomplete.scss +102 -0
  92. data/assets/stylesheets/components/datepicker.scss +197 -0
  93. data/assets/stylesheets/components/dotnav.scss +212 -0
  94. data/assets/stylesheets/components/form-advanced.scss +128 -0
  95. data/assets/stylesheets/components/form-file.scss +63 -0
  96. data/assets/stylesheets/components/form-password.scss +74 -0
  97. data/assets/stylesheets/components/form-select.scss +66 -0
  98. data/assets/stylesheets/components/htmleditor.scss +269 -0
  99. data/assets/stylesheets/components/nestable.scss +229 -0
  100. data/assets/stylesheets/components/notify.scss +190 -0
  101. data/assets/stylesheets/components/placeholder.scss +66 -0
  102. data/assets/stylesheets/components/progress.scss +173 -0
  103. data/assets/stylesheets/components/search.scss +309 -0
  104. data/assets/stylesheets/components/slidenav.scss +183 -0
  105. data/assets/stylesheets/components/slider.scss +131 -0
  106. data/assets/stylesheets/components/slideshow.scss +208 -0
  107. data/assets/stylesheets/components/sortable.scss +122 -0
  108. data/assets/stylesheets/components/sticky.scss +64 -0
  109. data/assets/stylesheets/components/tooltip.scss +177 -0
  110. data/assets/stylesheets/components/upload.scss +34 -0
  111. data/assets/stylesheets/core/alert.scss +141 -0
  112. data/assets/stylesheets/core/animation.scss +599 -0
  113. data/assets/stylesheets/core/article.scss +139 -0
  114. data/assets/stylesheets/core/badge.scss +110 -0
  115. data/assets/stylesheets/core/base-noconflict.scss +397 -0
  116. data/assets/stylesheets/core/base.scss +541 -0
  117. data/assets/stylesheets/core/block.scss +153 -0
  118. data/assets/stylesheets/core/breadcrumb.scss +86 -0
  119. data/assets/stylesheets/core/button.scss +406 -0
  120. data/assets/stylesheets/core/close.scss +132 -0
  121. data/assets/stylesheets/core/column.scss +209 -0
  122. data/assets/stylesheets/core/comment.scss +172 -0
  123. data/assets/stylesheets/core/contrast.scss +493 -0
  124. data/assets/stylesheets/core/cover.scss +70 -0
  125. data/assets/stylesheets/core/description-list.scss +71 -0
  126. data/assets/stylesheets/core/dropdown.scss +280 -0
  127. data/assets/stylesheets/core/flex.scss +320 -0
  128. data/assets/stylesheets/core/form.scss +627 -0
  129. data/assets/stylesheets/core/grid.scss +688 -0
  130. data/assets/stylesheets/core/icon.scss +897 -0
  131. data/assets/stylesheets/core/list.scss +102 -0
  132. data/assets/stylesheets/core/modal.scss +341 -0
  133. data/assets/stylesheets/core/nav.scss +468 -0
  134. data/assets/stylesheets/core/navbar.scss +325 -0
  135. data/assets/stylesheets/core/offcanvas.scss +168 -0
  136. data/assets/stylesheets/core/overlay.scss +534 -0
  137. data/assets/stylesheets/core/pagination.scss +197 -0
  138. data/assets/stylesheets/core/panel.scss +332 -0
  139. data/assets/stylesheets/core/print.scss +59 -0
  140. data/assets/stylesheets/core/subnav.scss +213 -0
  141. data/assets/stylesheets/core/switcher.scss +38 -0
  142. data/assets/stylesheets/core/tab.scss +368 -0
  143. data/assets/stylesheets/core/table.scss +147 -0
  144. data/assets/stylesheets/core/text.scss +128 -0
  145. data/assets/stylesheets/core/thumbnail.scss +122 -0
  146. data/assets/stylesheets/core/thumbnav.scss +122 -0
  147. data/assets/stylesheets/core/utility.scss +606 -0
  148. data/assets/stylesheets/core/variables.scss +23 -0
  149. data/assets/stylesheets/uikit-components.scss +22 -0
  150. data/assets/stylesheets/uikit-mixins.scss +327 -0
  151. data/assets/stylesheets/uikit-variables.scss +817 -0
  152. data/assets/stylesheets/uikit.scss +56 -0
  153. data/lib/uikit-rails.rb +2 -2
  154. data/lib/uikit-rails/engine.rb +11 -1
  155. data/lib/uikit-rails/version.rb +1 -3
  156. data/uikit-rails.gemspec +15 -16
  157. metadata +169 -44
  158. data/README.rb +0 -1
  159. data/vendor/assets/javascripts/ui.card.js +0 -115
  160. data/vendor/assets/javascripts/ui.color-picker.js +0 -351
  161. data/vendor/assets/javascripts/ui.confirmation.js +0 -133
  162. data/vendor/assets/javascripts/ui.dialog.js +0 -252
  163. data/vendor/assets/javascripts/ui.emitter.js +0 -99
  164. data/vendor/assets/javascripts/ui.js +0 -1641
  165. data/vendor/assets/javascripts/ui.menu.js +0 -238
  166. data/vendor/assets/javascripts/ui.notification.js +0 -240
  167. data/vendor/assets/javascripts/ui.overlay.js +0 -79
  168. data/vendor/assets/javascripts/ui.split-button.js +0 -108
  169. data/vendor/assets/stylesheets/ui.card.css +0 -55
  170. data/vendor/assets/stylesheets/ui.color-picker.css +0 -6
  171. data/vendor/assets/stylesheets/ui.confirmation.css +0 -7
  172. data/vendor/assets/stylesheets/ui.css +0 -337
  173. data/vendor/assets/stylesheets/ui.dialog.css +0 -92
  174. data/vendor/assets/stylesheets/ui.menu.css +0 -32
  175. data/vendor/assets/stylesheets/ui.notification.css +0 -107
  176. data/vendor/assets/stylesheets/ui.overlay.css +0 -16
  177. data/vendor/assets/stylesheets/ui.split-button.css +0 -27
@@ -0,0 +1,2 @@
1
+ /*! UIkit 2.24.2 | http://www.getuikit.com | (c) 2014 YOOtheme | MIT License */
2
+ !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")),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.$('<div class="uk-cover-background uk-position-cover"></div>').css({"background-image":"url("+r.attr("src")+")"});r.attr("width")&&r.attr("height")&&(d=i.$("<canvas></canvas>").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.$("<canvas></canvas>").attr({width:r[0].width,height:r[0].height});var l=i.$('<img style="width:100%;height:auto;">').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.uikit.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<s?-1:1,d=n.data("media"),u=t[this.options.animation]?this.options.animation:"fade",h=o.data("media"),c=function(){a.animating&&(d&&d.is("video,iframe")&&a.pausemedia(d),h&&h.is("video,iframe")&&a.playmedia(h),o.addClass("uk-active").attr("aria-hidden","false"),n.removeClass("uk-active").attr("aria-hidden","true"),a.animating=!1,a.current=s,i.Utils.checkDisplay(o,'[class*="uk-animation-"]:not(.uk-cover-background.uk-position-cover)'),a.trigger("show.uk.slideshow",[o,n,a]))};a.applyKenBurns(o),i.support.animation||(u="none"),n=i.$(n),o=i.$(o),a.trigger("beforeshow.uk.slideshow",[o,n,a]),t[u].apply(this,[n,o,r]).then(c),a.triggers.removeClass("uk-active"),a.triggers.filter('[data-uk-slideshow-item="'+s+'"]').addClass("uk-active")}},applyKenBurns:function(i){if(this.hasKenBurns(i)){var t=this.options.kenburnsanimations,s=this.kbindex||0;i.data("cover").attr("class","uk-cover-background uk-position-cover").width(),i.data("cover").addClass(["uk-animation-scale","uk-animation-reverse",t[s].trim()].join(" ")),this.kbindex=t[s+1]?s+1:0}},hasKenBurns:function(i){return this.options.kenburns&&i.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 i=this;this.interval=setInterval(function(){i.hovering||i.next()},this.options.autoplayInterval)},stop:function(){this.interval&&clearInterval(this.interval)},playmedia:function(i){if(i&&i[0])switch(i[0].nodeName){case"VIDEO":this.options.videomute||(i[0].muted=!1),i[0].play();break;case"IFRAME":this.options.videomute||i[0].contentWindow.postMessage('{ "event": "command", "func": "unmute", "method":"setVolume", "value":1}',"*"),i[0].contentWindow.postMessage('{ "event": "command", "func": "playVideo", "method":"play"}',"*")}},pausemedia:function(i){switch(i[0].nodeName){case"VIDEO":i[0].pause();break;case"IFRAME":i[0].contentWindow.postMessage('{ "event": "command", "func": "pauseVideo", "method":"pause"}',"*")}},mutemedia:function(i){switch(i[0].nodeName){case"VIDEO":i[0].muted=!0;break;case"IFRAME":i[0].contentWindow.postMessage('{ "event": "command", "func": "mute", "method":"setVolume", "value":0}',"*")}}}),t={none:function(){var t=i.$.Deferred();return t.resolve(),t.promise()},scroll:function(t,s,e){var a=i.$.Deferred();return t.css("animation-duration",this.options.duration+"ms"),s.css("animation-duration",this.options.duration+"ms"),s.css("opacity",1).one(i.support.animation.end,function(){t.removeClass(1===e?"uk-slideshow-scroll-backward-out":"uk-slideshow-scroll-forward-out"),s.css("opacity","").removeClass(1===e?"uk-slideshow-scroll-backward-in":"uk-slideshow-scroll-forward-in"),a.resolve()}.bind(this)),t.addClass(1==e?"uk-slideshow-scroll-backward-out":"uk-slideshow-scroll-forward-out"),s.addClass(1==e?"uk-slideshow-scroll-backward-in":"uk-slideshow-scroll-forward-in"),s.width(),a.promise()},swipe:function(t,s,e){var a=i.$.Deferred();return t.css("animation-duration",this.options.duration+"ms"),s.css("animation-duration",this.options.duration+"ms"),s.css("opacity",1).one(i.support.animation.end,function(){t.removeClass(1===e?"uk-slideshow-swipe-backward-out":"uk-slideshow-swipe-forward-out"),s.css("opacity","").removeClass(1===e?"uk-slideshow-swipe-backward-in":"uk-slideshow-swipe-forward-in"),a.resolve()}.bind(this)),t.addClass(1==e?"uk-slideshow-swipe-backward-out":"uk-slideshow-swipe-forward-out"),s.addClass(1==e?"uk-slideshow-swipe-backward-in":"uk-slideshow-swipe-forward-in"),s.width(),a.promise()},scale:function(t,s){var e=i.$.Deferred();return t.css("animation-duration",this.options.duration+"ms"),s.css("animation-duration",this.options.duration+"ms"),s.css("opacity",1),t.one(i.support.animation.end,function(){t.removeClass("uk-slideshow-scale-out"),s.css("opacity",""),e.resolve()}.bind(this)),t.addClass("uk-slideshow-scale-out"),t.width(),e.promise()},fade:function(t,s){var e=i.$.Deferred();return t.css("animation-duration",this.options.duration+"ms"),s.css("animation-duration",this.options.duration+"ms"),s.css("opacity",1),s.data("cover")||s.data("placeholder")||s.css("opacity",1).one(i.support.animation.end,function(){s.removeClass("uk-slideshow-fade-in")}).addClass("uk-slideshow-fade-in"),t.one(i.support.animation.end,function(){t.removeClass("uk-slideshow-fade-out"),s.css("opacity",""),e.resolve()}.bind(this)),t.addClass("uk-slideshow-fade-out"),t.width(),e.promise()}},i.slideshow.animations=t,window.addEventListener("message",function(t){var s,e=t.data;if("string"==typeof e)try{e=JSON.parse(e)}catch(a){e={}}t.origin&&t.origin.indexOf("vimeo")>-1&&"ready"==e.event&&e.player_id&&(s=i.$('[data-player-id="'+e.player_id+'"]'),s.length&&s.data("slideshow").mutemedia(s))},!1)});
@@ -0,0 +1,688 @@
1
+ /*! UIkit 2.24.2 | http://www.getuikit.com | (c) 2014 YOOtheme | MIT License */
2
+ /*
3
+ * Based on nativesortable - Copyright (c) Brian Grinstead - https://github.com/bgrins/nativesortable
4
+ */
5
+ (function(addon) {
6
+
7
+ var component;
8
+
9
+ if (window.UIkit) {
10
+ component = addon(UIkit);
11
+ }
12
+
13
+ if (typeof define == "function" && define.amd) {
14
+ define("uikit-sortable", ["uikit"], function(){
15
+ return component || addon(UIkit);
16
+ });
17
+ }
18
+
19
+ })(function(UI){
20
+
21
+ "use strict";
22
+
23
+ var supportsTouch = ('ontouchstart' in window) || (window.DocumentTouch && document instanceof DocumentTouch),
24
+ draggingPlaceholder, currentlyDraggingElement, currentlyDraggingTarget, dragging, moving, clickedlink, delayIdle, touchedlists, moved, overElement;
25
+
26
+ function closestSortable(ele) {
27
+
28
+ ele = UI.$(ele);
29
+
30
+ do {
31
+ if (ele.data('sortable')) {
32
+ return ele;
33
+ }
34
+ ele = UI.$(ele).parent();
35
+ } while(ele.length);
36
+
37
+ return ele;
38
+ }
39
+
40
+ UI.component('sortable', {
41
+
42
+ defaults: {
43
+
44
+ animation : 150,
45
+ threshold : 10,
46
+
47
+ childClass : 'uk-sortable-item',
48
+ placeholderClass : 'uk-sortable-placeholder',
49
+ overClass : 'uk-sortable-over',
50
+ draggingClass : 'uk-sortable-dragged',
51
+ dragMovingClass : 'uk-sortable-moving',
52
+ baseClass : 'uk-sortable',
53
+ noDragClass : 'uk-sortable-nodrag',
54
+ emptyClass : 'uk-sortable-empty',
55
+ dragCustomClass : '',
56
+ handleClass : false,
57
+ group : false,
58
+
59
+ stop : function() {},
60
+ start : function() {},
61
+ change : function() {}
62
+ },
63
+
64
+ boot: function() {
65
+
66
+ // auto init
67
+ UI.ready(function(context) {
68
+
69
+ UI.$("[data-uk-sortable]", context).each(function(){
70
+
71
+ var ele = UI.$(this);
72
+
73
+ if(!ele.data("sortable")) {
74
+ UI.sortable(ele, UI.Utils.options(ele.attr("data-uk-sortable")));
75
+ }
76
+ });
77
+ });
78
+
79
+ UI.$html.on('mousemove touchmove', function(e) {
80
+
81
+ if (delayIdle) {
82
+
83
+ var src = e.originalEvent.targetTouches ? e.originalEvent.targetTouches[0] : e;
84
+
85
+ if (Math.abs(src.pageX - delayIdle.pos.x) > delayIdle.threshold || Math.abs(src.pageY - delayIdle.pos.y) > delayIdle.threshold) {
86
+ delayIdle.apply(src);
87
+ }
88
+ }
89
+
90
+ if (draggingPlaceholder) {
91
+
92
+ if (!moving) {
93
+ moving = true;
94
+ draggingPlaceholder.show();
95
+
96
+ draggingPlaceholder.$current.addClass(draggingPlaceholder.$sortable.options.placeholderClass);
97
+ draggingPlaceholder.$sortable.element.children().addClass(draggingPlaceholder.$sortable.options.childClass);
98
+
99
+ UI.$html.addClass(draggingPlaceholder.$sortable.options.dragMovingClass);
100
+ }
101
+
102
+ var offset = draggingPlaceholder.data('mouse-offset'),
103
+ left = parseInt(e.originalEvent.pageX, 10) + offset.left,
104
+ top = parseInt(e.originalEvent.pageY, 10) + offset.top;
105
+
106
+ draggingPlaceholder.css({'left': left, 'top': top });
107
+
108
+ // adjust document scrolling
109
+
110
+ if (top + (draggingPlaceholder.height()/3) > document.body.offsetHeight) {
111
+ return;
112
+ }
113
+
114
+ if (top < UI.$win.scrollTop()) {
115
+ UI.$win.scrollTop(UI.$win.scrollTop() - Math.ceil(draggingPlaceholder.height()/3));
116
+ } else if ( (top + (draggingPlaceholder.height()/3)) > (window.innerHeight + UI.$win.scrollTop()) ) {
117
+ UI.$win.scrollTop(UI.$win.scrollTop() + Math.ceil(draggingPlaceholder.height()/3));
118
+ }
119
+ }
120
+ });
121
+
122
+ UI.$html.on('mouseup touchend', function(e) {
123
+
124
+ delayIdle = clickedlink = false;
125
+
126
+ // dragging?
127
+ if (!currentlyDraggingElement || !draggingPlaceholder) {
128
+ // completely reset dragging attempt. will cause weird delay behavior elsewise
129
+ currentlyDraggingElement = draggingPlaceholder = null;
130
+ return;
131
+ }
132
+
133
+ // inside or outside of sortable?
134
+ var sortable = closestSortable(e.target),
135
+ component = draggingPlaceholder.$sortable,
136
+ ev = { type: e.type };
137
+
138
+ if (sortable[0]) {
139
+ component.dragDrop(ev, component.element);
140
+ }
141
+ component.dragEnd(ev, component.element);
142
+ });
143
+ },
144
+
145
+ init: function() {
146
+
147
+ var $this = this,
148
+ element = this.element[0];
149
+
150
+ touchedlists = [];
151
+
152
+ this.checkEmptyList();
153
+
154
+ this.element.data('sortable-group', this.options.group ? this.options.group : UI.Utils.uid('sortable-group'));
155
+
156
+ var handleDragStart = delegate(function(e) {
157
+
158
+ if (e.data && e.data.sortable) {
159
+ return;
160
+ }
161
+
162
+ var $target = UI.$(e.target),
163
+ $link = $target.is('a[href]') ? $target:$target.parents('a[href]');
164
+
165
+ if ($target.is(':input')) {
166
+ return;
167
+ }
168
+
169
+ e.preventDefault();
170
+
171
+ if (!supportsTouch && $link.length) {
172
+
173
+ $link.one('click', function(e){
174
+ e.preventDefault();
175
+ }).one('mouseup', function(){
176
+ if(!moved) $link.trigger('click');
177
+ });
178
+ }
179
+
180
+ e.data = e.data || {};
181
+
182
+ e.data.sortable = element;
183
+
184
+ return $this.dragStart(e, this);
185
+ });
186
+
187
+ var handleDragOver = delegate(function(e) {
188
+
189
+ if (!currentlyDraggingElement) {
190
+ return true;
191
+ }
192
+
193
+ if (e.preventDefault) {
194
+ e.preventDefault();
195
+ }
196
+
197
+ return false;
198
+ });
199
+
200
+ var handleDragEnter = delegate(UI.Utils.debounce(function(e) {
201
+ return $this.dragEnter(e, this);
202
+ }), 40);
203
+
204
+ var handleDragLeave = delegate(function(e) {
205
+
206
+ // Prevent dragenter on a child from allowing a dragleave on the container
207
+ var previousCounter = $this.dragenterData(this);
208
+ $this.dragenterData(this, previousCounter - 1);
209
+
210
+ // This is a fix for child elements firing dragenter before the parent fires dragleave
211
+ if (!$this.dragenterData(this)) {
212
+ UI.$(this).removeClass($this.options.overClass);
213
+ $this.dragenterData(this, false);
214
+ }
215
+ });
216
+
217
+ var handleTouchMove = delegate(function(e) {
218
+
219
+ if (!currentlyDraggingElement ||
220
+ currentlyDraggingElement === this ||
221
+ currentlyDraggingTarget === this) {
222
+ return true;
223
+ }
224
+
225
+ $this.element.children().removeClass($this.options.overClass);
226
+ currentlyDraggingTarget = this;
227
+
228
+ $this.moveElementNextTo(currentlyDraggingElement, this);
229
+
230
+ return prevent(e);
231
+ });
232
+
233
+ // Bind/unbind standard mouse/touch events as a polyfill.
234
+ function addDragHandlers() {
235
+ if (supportsTouch) {
236
+ element.addEventListener("touchmove", handleTouchMove, false);
237
+ } else {
238
+ element.addEventListener('mouseover', handleDragEnter, false);
239
+ element.addEventListener('mouseout', handleDragLeave, false);
240
+ }
241
+
242
+ // document.addEventListener("selectstart", prevent, false);
243
+ }
244
+
245
+ function removeDragHandlers() {
246
+ if (supportsTouch) {
247
+ element.removeEventListener("touchmove", handleTouchMove, false);
248
+ } else {
249
+ element.removeEventListener('mouseover', handleDragEnter, false);
250
+ element.removeEventListener('mouseout', handleDragLeave, false);
251
+ }
252
+
253
+ // document.removeEventListener("selectstart", prevent, false);
254
+ }
255
+
256
+ this.addDragHandlers = addDragHandlers;
257
+ this.removeDragHandlers = removeDragHandlers;
258
+
259
+ function handleDragMove(e) {
260
+
261
+ if (!currentlyDraggingElement) {
262
+ return;
263
+ }
264
+
265
+ $this.dragMove(e, $this);
266
+ }
267
+
268
+ function delegate(fn) {
269
+
270
+ return function(e) {
271
+
272
+ var touch, target, context;
273
+
274
+ if (e) {
275
+ touch = (supportsTouch && e.touches && e.touches[0]) || { };
276
+ target = touch.target || e.target;
277
+
278
+ // Fix event.target for a touch event
279
+ if (supportsTouch && document.elementFromPoint) {
280
+ target = document.elementFromPoint(e.pageX - document.body.scrollLeft, e.pageY - document.body.scrollTop);
281
+ }
282
+
283
+ overElement = UI.$(target);
284
+ }
285
+
286
+ if (UI.$(target).hasClass($this.options.childClass)) {
287
+ fn.apply(target, [e]);
288
+ } else if (target !== element) {
289
+
290
+ // If a child is initiating the event or ending it, then use the container as context for the callback.
291
+ context = moveUpToChildNode(element, target);
292
+
293
+ if (context) {
294
+ fn.apply(context, [e]);
295
+ }
296
+ }
297
+ };
298
+ }
299
+
300
+ window.addEventListener(supportsTouch ? 'touchmove' : 'mousemove', handleDragMove, false);
301
+ element.addEventListener(supportsTouch ? 'touchstart': 'mousedown', handleDragStart, false);
302
+ },
303
+
304
+ dragStart: function(e, elem) {
305
+
306
+ moved = false;
307
+ moving = false;
308
+ dragging = false;
309
+
310
+ var $this = this,
311
+ target = UI.$(e.target);
312
+
313
+ if (!supportsTouch && e.button==2) {
314
+ return;
315
+ }
316
+
317
+ if ($this.options.handleClass) {
318
+
319
+ var handle = target.hasClass($this.options.handleClass) ? target : target.closest('.'+$this.options.handleClass, $this.element);
320
+
321
+ if (!handle.length) {
322
+ //e.preventDefault();
323
+ return;
324
+ }
325
+ }
326
+
327
+ if (target.is('.'+$this.options.noDragClass) || target.closest('.'+$this.options._noDragClass).length) {
328
+ return;
329
+ }
330
+
331
+ // prevent dragging if taget is a form field
332
+ if (target.is(':input')) {
333
+ return;
334
+ }
335
+
336
+ currentlyDraggingElement = elem;
337
+
338
+ // init drag placeholder
339
+ if (draggingPlaceholder) {
340
+ draggingPlaceholder.remove();
341
+ }
342
+
343
+ var $current = UI.$(currentlyDraggingElement), offset = $current.offset();
344
+
345
+ delayIdle = {
346
+
347
+ pos : { x:e.pageX, y:e.pageY },
348
+ threshold : $this.options.threshold,
349
+ apply : function(evt) {
350
+
351
+ draggingPlaceholder = UI.$('<div class="'+([$this.options.draggingClass, $this.options.dragCustomClass].join(' '))+'"></div>').css({
352
+ display : 'none',
353
+ top : offset.top,
354
+ left : offset.left,
355
+ width : $current.width(),
356
+ height : $current.height(),
357
+ padding : $current.css('padding')
358
+ }).data({
359
+ 'mouse-offset': {
360
+ 'left' : offset.left - parseInt(evt.pageX, 10),
361
+ 'top' : offset.top - parseInt(evt.pageY, 10)
362
+ },
363
+ 'origin' : $this.element,
364
+ 'index' : $current.index()
365
+ }).append($current.html()).appendTo('body');
366
+
367
+ draggingPlaceholder.$current = $current;
368
+ draggingPlaceholder.$sortable = $this;
369
+
370
+ $current.data({
371
+ 'start-list': $current.parent(),
372
+ 'start-index': $current.index(),
373
+ 'sortable-group': $this.options.group
374
+ });
375
+
376
+ $this.addDragHandlers();
377
+
378
+ $this.options.start(this, currentlyDraggingElement);
379
+ $this.trigger('start.uk.sortable', [$this, currentlyDraggingElement]);
380
+
381
+ moved = true;
382
+ delayIdle = false;
383
+ }
384
+ };
385
+ },
386
+
387
+ dragMove: function(e, elem) {
388
+
389
+ overElement = UI.$(document.elementFromPoint(e.pageX - (document.body.scrollLeft || document.scrollLeft || 0), e.pageY - (document.body.scrollTop || document.documentElement.scrollTop || 0)));
390
+
391
+ var overRoot = overElement.closest('.'+this.options.baseClass),
392
+ groupOver = overRoot.data("sortable-group"),
393
+ $current = UI.$(currentlyDraggingElement),
394
+ currentRoot = $current.parent(),
395
+ groupCurrent = $current.data("sortable-group"),
396
+ overChild;
397
+
398
+ if (overRoot[0] !== currentRoot[0] && groupCurrent !== undefined && groupOver === groupCurrent) {
399
+
400
+ overRoot.data('sortable').addDragHandlers();
401
+
402
+ touchedlists.push(overRoot);
403
+ overRoot.children().addClass(this.options.childClass);
404
+
405
+ // swap root
406
+ if (overRoot.children().length > 0) {
407
+ overChild = overElement.closest('.'+this.options.childClass);
408
+
409
+ if (overChild.length) {
410
+ overChild.before($current);
411
+ } else {
412
+ overRoot.append($current);
413
+ }
414
+
415
+ } else { // empty list
416
+ overElement.append($current);
417
+ }
418
+
419
+ UIkit.$doc.trigger('mouseover');
420
+ }
421
+
422
+ this.checkEmptyList();
423
+ this.checkEmptyList(currentRoot);
424
+ },
425
+
426
+ dragEnter: function(e, elem) {
427
+
428
+ if (!currentlyDraggingElement || currentlyDraggingElement === elem) {
429
+ return true;
430
+ }
431
+
432
+ var previousCounter = this.dragenterData(elem);
433
+
434
+ this.dragenterData(elem, previousCounter + 1);
435
+
436
+ // Prevent dragenter on a child from allowing a dragleave on the container
437
+ if (previousCounter === 0) {
438
+
439
+ var currentlist = UI.$(elem).parent(),
440
+ startlist = UI.$(currentlyDraggingElement).data("start-list");
441
+
442
+ if (currentlist[0] !== startlist[0]) {
443
+
444
+ var groupOver = currentlist.data('sortable-group'),
445
+ groupCurrent = UI.$(currentlyDraggingElement).data("sortable-group");
446
+
447
+ if ((groupOver || groupCurrent) && (groupOver != groupCurrent)) {
448
+ return false;
449
+ }
450
+ }
451
+
452
+ UI.$(elem).addClass(this.options.overClass);
453
+ this.moveElementNextTo(currentlyDraggingElement, elem);
454
+ }
455
+
456
+ return false;
457
+ },
458
+
459
+ dragEnd: function(e, elem) {
460
+
461
+ var $this = this;
462
+
463
+ // avoid triggering event twice
464
+ if (currentlyDraggingElement) {
465
+ // TODO: trigger on right element?
466
+ this.options.stop(elem);
467
+ this.trigger('stop.uk.sortable', [this]);
468
+ }
469
+
470
+ currentlyDraggingElement = null;
471
+ currentlyDraggingTarget = null;
472
+
473
+ touchedlists.push(this.element);
474
+ touchedlists.forEach(function(el, i) {
475
+ UI.$(el).children().each(function() {
476
+ if (this.nodeType === 1) {
477
+ UI.$(this).removeClass($this.options.overClass)
478
+ .removeClass($this.options.placeholderClass)
479
+ .removeClass($this.options.childClass);
480
+ $this.dragenterData(this, false);
481
+ }
482
+ });
483
+ });
484
+
485
+ touchedlists = [];
486
+
487
+ UI.$html.removeClass(this.options.dragMovingClass);
488
+
489
+ this.removeDragHandlers();
490
+
491
+ if (draggingPlaceholder) {
492
+ draggingPlaceholder.remove();
493
+ draggingPlaceholder = null;
494
+ }
495
+ },
496
+
497
+ dragDrop: function(e, elem) {
498
+
499
+ if (e.type === 'drop') {
500
+
501
+ if (e.stopPropagation) {
502
+ e.stopPropagation();
503
+ }
504
+
505
+ if (e.preventDefault) {
506
+ e.preventDefault();
507
+ }
508
+ }
509
+
510
+ this.triggerChangeEvents();
511
+ },
512
+
513
+ triggerChangeEvents: function() {
514
+
515
+ // trigger events once
516
+ if (!currentlyDraggingElement) return;
517
+
518
+ var $current = UI.$(currentlyDraggingElement),
519
+ oldRoot = draggingPlaceholder.data("origin"),
520
+ newRoot = $current.closest('.'+this.options.baseClass),
521
+ triggers = [],
522
+ el = UI.$(currentlyDraggingElement);
523
+
524
+ // events depending on move inside lists or across lists
525
+ if (oldRoot[0] === newRoot[0] && draggingPlaceholder.data('index') != $current.index() ) {
526
+ triggers.push({sortable: this, mode: 'moved'});
527
+ } else if (oldRoot[0] != newRoot[0]) {
528
+ triggers.push({sortable: UI.$(newRoot).data('sortable'), mode: 'added'}, {sortable: UI.$(oldRoot).data('sortable'), mode: 'removed'});
529
+ }
530
+
531
+ triggers.forEach(function (trigger, i) {
532
+ trigger.sortable.element.trigger('change.uk.sortable', [trigger.sortable, el, trigger.mode]);
533
+ });
534
+ },
535
+
536
+ dragenterData: function(element, val) {
537
+
538
+ element = UI.$(element);
539
+
540
+ if (arguments.length == 1) {
541
+ return parseInt(element.data('child-dragenter'), 10) || 0;
542
+ } else if (!val) {
543
+ element.removeData('child-dragenter');
544
+ } else {
545
+ element.data('child-dragenter', Math.max(0, val));
546
+ }
547
+ },
548
+
549
+ moveElementNextTo: function(element, elementToMoveNextTo) {
550
+
551
+ dragging = true;
552
+
553
+ var $this = this,
554
+ list = UI.$(element).parent().css('min-height', ''),
555
+ next = isBelow(element, elementToMoveNextTo) ? elementToMoveNextTo : elementToMoveNextTo.nextSibling,
556
+ children = list.children(),
557
+ count = children.length;
558
+
559
+ if (!$this.options.animation) {
560
+ elementToMoveNextTo.parentNode.insertBefore(element, next);
561
+ UI.Utils.checkDisplay($this.element.parent());
562
+ return;
563
+ }
564
+
565
+ list.css('min-height', list.height());
566
+
567
+ children.stop().each(function(){
568
+ var ele = UI.$(this),
569
+ offset = ele.position();
570
+
571
+ offset.width = ele.width();
572
+
573
+ ele.data('offset-before', offset);
574
+ });
575
+
576
+ elementToMoveNextTo.parentNode.insertBefore(element, next);
577
+
578
+ UI.Utils.checkDisplay($this.element.parent());
579
+
580
+ children = list.children().each(function() {
581
+ var ele = UI.$(this);
582
+ ele.data('offset-after', ele.position());
583
+ }).each(function() {
584
+ var ele = UI.$(this),
585
+ before = ele.data('offset-before');
586
+ ele.css({'position':'absolute', 'top':before.top, 'left':before.left, 'min-width':before.width });
587
+ });
588
+
589
+ children.each(function(){
590
+
591
+ var ele = UI.$(this),
592
+ before = ele.data('offset-before'),
593
+ offset = ele.data('offset-after');
594
+
595
+ ele.css('pointer-events', 'none').width();
596
+
597
+ setTimeout(function(){
598
+ ele.animate({'top':offset.top, 'left':offset.left}, $this.options.animation, function() {
599
+ ele.css({'position':'','top':'', 'left':'', 'min-width': '', 'pointer-events':''}).removeClass($this.options.overClass).removeData('child-dragenter');
600
+ count--;
601
+ if (!count) {
602
+ list.css('min-height', '');
603
+ UI.Utils.checkDisplay($this.element.parent());
604
+ }
605
+ });
606
+ }, 0);
607
+ });
608
+ },
609
+
610
+ serialize: function() {
611
+
612
+ var data = [], item, attribute;
613
+
614
+ this.element.children().each(function(j, child) {
615
+ item = {};
616
+ for (var i = 0; i < child.attributes.length; i++) {
617
+ attribute = child.attributes[i];
618
+ if (attribute.name.indexOf('data-') === 0) {
619
+ item[attribute.name.substr(5)] = UI.Utils.str2json(attribute.value);
620
+ }
621
+ }
622
+ data.push(item);
623
+ });
624
+
625
+ return data;
626
+ },
627
+
628
+ checkEmptyList: function(list) {
629
+
630
+ list = list ? UI.$(list) : this.element;
631
+
632
+ if (this.options.emptyClass) {
633
+ list[!list.children().length ? 'addClass':'removeClass'](this.options.emptyClass);
634
+ }
635
+ }
636
+ });
637
+
638
+ // helpers
639
+
640
+ function isBelow(el1, el2) {
641
+
642
+ var parent = el1.parentNode;
643
+
644
+ if (el2.parentNode != parent) {
645
+ return false;
646
+ }
647
+
648
+ var cur = el1.previousSibling;
649
+
650
+ while (cur && cur.nodeType !== 9) {
651
+ if (cur === el2) {
652
+ return true;
653
+ }
654
+ cur = cur.previousSibling;
655
+ }
656
+
657
+ return false;
658
+ }
659
+
660
+ function moveUpToChildNode(parent, child) {
661
+ var cur = child;
662
+ if (cur == parent) { return null; }
663
+
664
+ while (cur) {
665
+ if (cur.parentNode === parent) {
666
+ return cur;
667
+ }
668
+
669
+ cur = cur.parentNode;
670
+ if ( !cur || !cur.ownerDocument || cur.nodeType === 11 ) {
671
+ break;
672
+ }
673
+ }
674
+ return null;
675
+ }
676
+
677
+ function prevent(e) {
678
+ if (e.stopPropagation) {
679
+ e.stopPropagation();
680
+ }
681
+ if (e.preventDefault) {
682
+ e.preventDefault();
683
+ }
684
+ e.returnValue = false;
685
+ }
686
+
687
+ return UI.sortable;
688
+ });