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.
- checksums.yaml +7 -0
- data/.gitignore +9 -3
- data/Gemfile +2 -1
- data/LICENSE.txt +21 -0
- data/README.md +65 -0
- data/Rakefile +0 -1
- data/assets/fonts/FontAwesome.otf +0 -0
- data/assets/fonts/fontawesome-webfont.ttf +0 -0
- data/assets/fonts/fontawesome-webfont.woff +0 -0
- data/assets/fonts/fontawesome-webfont.woff2 +0 -0
- data/assets/javascripts/components/accordion.js +174 -0
- data/assets/javascripts/components/accordion.min.js +2 -0
- data/assets/javascripts/components/autocomplete.js +334 -0
- data/assets/javascripts/components/autocomplete.min.js +2 -0
- data/assets/javascripts/components/datepicker.js +3166 -0
- data/assets/javascripts/components/datepicker.min.js +3 -0
- data/assets/javascripts/components/form-password.js +67 -0
- data/assets/javascripts/components/form-password.min.js +2 -0
- data/assets/javascripts/components/form-select.js +70 -0
- data/assets/javascripts/components/form-select.min.js +2 -0
- data/assets/javascripts/components/grid.js +527 -0
- data/assets/javascripts/components/grid.min.js +2 -0
- data/assets/javascripts/components/htmleditor.js +623 -0
- data/assets/javascripts/components/htmleditor.min.js +2 -0
- data/assets/javascripts/components/lightbox.js +555 -0
- data/assets/javascripts/components/lightbox.min.js +2 -0
- data/assets/javascripts/components/nestable.js +638 -0
- data/assets/javascripts/components/nestable.min.js +2 -0
- data/assets/javascripts/components/notify.js +189 -0
- data/assets/javascripts/components/notify.min.js +2 -0
- data/assets/javascripts/components/pagination.js +147 -0
- data/assets/javascripts/components/pagination.min.js +2 -0
- data/assets/javascripts/components/parallax.js +435 -0
- data/assets/javascripts/components/parallax.min.js +2 -0
- data/assets/javascripts/components/search.js +92 -0
- data/assets/javascripts/components/search.min.js +2 -0
- data/assets/javascripts/components/slider.js +531 -0
- data/assets/javascripts/components/slider.min.js +2 -0
- data/assets/javascripts/components/slideset.js +506 -0
- data/assets/javascripts/components/slideset.min.js +2 -0
- data/assets/javascripts/components/slideshow-fx.js +375 -0
- data/assets/javascripts/components/slideshow-fx.min.js +2 -0
- data/assets/javascripts/components/slideshow.js +562 -0
- data/assets/javascripts/components/slideshow.min.js +2 -0
- data/assets/javascripts/components/sortable.js +688 -0
- data/assets/javascripts/components/sortable.min.js +2 -0
- data/assets/javascripts/components/sticky.js +359 -0
- data/assets/javascripts/components/sticky.min.js +2 -0
- data/assets/javascripts/components/timepicker.js +192 -0
- data/assets/javascripts/components/timepicker.min.js +2 -0
- data/assets/javascripts/components/tooltip.js +234 -0
- data/assets/javascripts/components/tooltip.min.js +2 -0
- data/assets/javascripts/components/upload.js +260 -0
- data/assets/javascripts/components/upload.min.js +2 -0
- data/assets/javascripts/core/alert.js +66 -0
- data/assets/javascripts/core/alert.min.js +2 -0
- data/assets/javascripts/core/button.js +157 -0
- data/assets/javascripts/core/button.min.js +2 -0
- data/assets/javascripts/core/core.js +730 -0
- data/assets/javascripts/core/core.min.js +2 -0
- data/assets/javascripts/core/cover.js +95 -0
- data/assets/javascripts/core/cover.min.js +2 -0
- data/assets/javascripts/core/dropdown.js +514 -0
- data/assets/javascripts/core/dropdown.min.js +2 -0
- data/assets/javascripts/core/grid.js +114 -0
- data/assets/javascripts/core/grid.min.js +2 -0
- data/assets/javascripts/core/modal.js +384 -0
- data/assets/javascripts/core/modal.min.js +2 -0
- data/assets/javascripts/core/nav.js +136 -0
- data/assets/javascripts/core/nav.min.js +2 -0
- data/assets/javascripts/core/offcanvas.js +180 -0
- data/assets/javascripts/core/offcanvas.min.js +2 -0
- data/assets/javascripts/core/scrollspy.js +208 -0
- data/assets/javascripts/core/scrollspy.min.js +2 -0
- data/assets/javascripts/core/smooth-scroll.js +62 -0
- data/assets/javascripts/core/smooth-scroll.min.js +2 -0
- data/assets/javascripts/core/switcher.js +309 -0
- data/assets/javascripts/core/switcher.min.js +2 -0
- data/assets/javascripts/core/tab.js +167 -0
- data/assets/javascripts/core/tab.min.js +2 -0
- data/assets/javascripts/core/toggle.js +120 -0
- data/assets/javascripts/core/toggle.min.js +2 -0
- data/assets/javascripts/core/touch.js +175 -0
- data/assets/javascripts/core/touch.min.js +2 -0
- data/assets/javascripts/core/utility.js +289 -0
- data/assets/javascripts/core/utility.min.js +2 -0
- data/assets/javascripts/uikit-components.js +23 -0
- data/assets/javascripts/uikit.js +3706 -0
- data/assets/javascripts/uikit.min.js +3 -0
- data/assets/stylesheets/components/accordion.scss +94 -0
- data/assets/stylesheets/components/autocomplete.scss +102 -0
- data/assets/stylesheets/components/datepicker.scss +197 -0
- data/assets/stylesheets/components/dotnav.scss +212 -0
- data/assets/stylesheets/components/form-advanced.scss +128 -0
- data/assets/stylesheets/components/form-file.scss +63 -0
- data/assets/stylesheets/components/form-password.scss +74 -0
- data/assets/stylesheets/components/form-select.scss +66 -0
- data/assets/stylesheets/components/htmleditor.scss +269 -0
- data/assets/stylesheets/components/nestable.scss +229 -0
- data/assets/stylesheets/components/notify.scss +190 -0
- data/assets/stylesheets/components/placeholder.scss +66 -0
- data/assets/stylesheets/components/progress.scss +173 -0
- data/assets/stylesheets/components/search.scss +309 -0
- data/assets/stylesheets/components/slidenav.scss +183 -0
- data/assets/stylesheets/components/slider.scss +131 -0
- data/assets/stylesheets/components/slideshow.scss +208 -0
- data/assets/stylesheets/components/sortable.scss +122 -0
- data/assets/stylesheets/components/sticky.scss +64 -0
- data/assets/stylesheets/components/tooltip.scss +177 -0
- data/assets/stylesheets/components/upload.scss +34 -0
- data/assets/stylesheets/core/alert.scss +141 -0
- data/assets/stylesheets/core/animation.scss +599 -0
- data/assets/stylesheets/core/article.scss +139 -0
- data/assets/stylesheets/core/badge.scss +110 -0
- data/assets/stylesheets/core/base-noconflict.scss +397 -0
- data/assets/stylesheets/core/base.scss +541 -0
- data/assets/stylesheets/core/block.scss +153 -0
- data/assets/stylesheets/core/breadcrumb.scss +86 -0
- data/assets/stylesheets/core/button.scss +406 -0
- data/assets/stylesheets/core/close.scss +132 -0
- data/assets/stylesheets/core/column.scss +209 -0
- data/assets/stylesheets/core/comment.scss +172 -0
- data/assets/stylesheets/core/contrast.scss +493 -0
- data/assets/stylesheets/core/cover.scss +70 -0
- data/assets/stylesheets/core/description-list.scss +71 -0
- data/assets/stylesheets/core/dropdown.scss +280 -0
- data/assets/stylesheets/core/flex.scss +320 -0
- data/assets/stylesheets/core/form.scss +627 -0
- data/assets/stylesheets/core/grid.scss +688 -0
- data/assets/stylesheets/core/icon.scss +897 -0
- data/assets/stylesheets/core/list.scss +102 -0
- data/assets/stylesheets/core/modal.scss +341 -0
- data/assets/stylesheets/core/nav.scss +468 -0
- data/assets/stylesheets/core/navbar.scss +325 -0
- data/assets/stylesheets/core/offcanvas.scss +168 -0
- data/assets/stylesheets/core/overlay.scss +534 -0
- data/assets/stylesheets/core/pagination.scss +197 -0
- data/assets/stylesheets/core/panel.scss +332 -0
- data/assets/stylesheets/core/print.scss +59 -0
- data/assets/stylesheets/core/subnav.scss +213 -0
- data/assets/stylesheets/core/switcher.scss +38 -0
- data/assets/stylesheets/core/tab.scss +368 -0
- data/assets/stylesheets/core/table.scss +147 -0
- data/assets/stylesheets/core/text.scss +128 -0
- data/assets/stylesheets/core/thumbnail.scss +122 -0
- data/assets/stylesheets/core/thumbnav.scss +122 -0
- data/assets/stylesheets/core/utility.scss +606 -0
- data/assets/stylesheets/core/variables.scss +23 -0
- data/assets/stylesheets/uikit-components.scss +22 -0
- data/assets/stylesheets/uikit-mixins.scss +327 -0
- data/assets/stylesheets/uikit-variables.scss +817 -0
- data/assets/stylesheets/uikit.scss +56 -0
- data/lib/uikit-rails.rb +2 -2
- data/lib/uikit-rails/engine.rb +11 -1
- data/lib/uikit-rails/version.rb +1 -3
- data/uikit-rails.gemspec +15 -16
- metadata +169 -44
- data/README.rb +0 -1
- data/vendor/assets/javascripts/ui.card.js +0 -115
- data/vendor/assets/javascripts/ui.color-picker.js +0 -351
- data/vendor/assets/javascripts/ui.confirmation.js +0 -133
- data/vendor/assets/javascripts/ui.dialog.js +0 -252
- data/vendor/assets/javascripts/ui.emitter.js +0 -99
- data/vendor/assets/javascripts/ui.js +0 -1641
- data/vendor/assets/javascripts/ui.menu.js +0 -238
- data/vendor/assets/javascripts/ui.notification.js +0 -240
- data/vendor/assets/javascripts/ui.overlay.js +0 -79
- data/vendor/assets/javascripts/ui.split-button.js +0 -108
- data/vendor/assets/stylesheets/ui.card.css +0 -55
- data/vendor/assets/stylesheets/ui.color-picker.css +0 -6
- data/vendor/assets/stylesheets/ui.confirmation.css +0 -7
- data/vendor/assets/stylesheets/ui.css +0 -337
- data/vendor/assets/stylesheets/ui.dialog.css +0 -92
- data/vendor/assets/stylesheets/ui.menu.css +0 -32
- data/vendor/assets/stylesheets/ui.notification.css +0 -107
- data/vendor/assets/stylesheets/ui.overlay.css +0 -16
- 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
|
+
});
|