@progress/kendo-ui
Version:
This package is part of the [Kendo UI for jQuery](http://www.telerik.com/kendo-ui) suite.
1 lines • 7.59 kB
JavaScript
module.exports=function(n){var i={};function s(e){if(i[e])return i[e].exports;var t=i[e]={exports:{},id:e,loaded:!1};return n[e].call(t.exports,t,t.exports,s),t.loaded=!0,t.exports}return s.m=n,s.c=i,s.p="",s(0)}({0:function(e,t,n){e.exports=n(1434)},3:function(e,t){e.exports=function(){throw Error("define cannot be used indirect")}},1051:function(e,t){e.exports=require("./kendo.core")},1113:function(e,t){e.exports=require("./kendo.userevents")},1434:function(e,t,n){var i;n(3),n=[n(1051),n(1113)],void 0===(t="function"==typeof(i=function(){var e={id:"selectable",name:"Selectable",category:"framework",depends:["core","userevents"],advanced:true},u=window.kendo.jQuery,t=void 0,f=window.kendo,r=f.ui.Widget,i=Math.abs,l="aria-selected",d="k-state-selected",c="k-state-selecting",v="k-selectable",p="change",n=".kendoSelectable",s="unselect",h="k-state-unselecting",a="input,a,textarea,.k-multiselect-wrap,select,button,.k-button>span,.k-button>img,span.k-icon.k-i-arrow-60-down,span.k-icon.k-i-arrow-60-up,label.k-checkbox-label.k-no-text,.k-icon.k-i-collapse,.k-icon.k-i-expand,span.k-numeric-wrap,.k-focusable",o=f.support.browser.msie,m=false,g=u.extend,_,b=(u('<div class="parent"><span></span></div>').on("click",">*",function(){m=true}).find("span").trigger("click").end().off(),r.extend({init:function(e,t){var n=this,i,s;r.fn.init.call(n,e,t);n._marquee=u("<div class='k-marquee'><div class='k-marquee-color'></div></div>");n._lastActive=null;n.element.addClass(v);n.relatedTarget=n.options.relatedTarget;i=n.options.multiple;s=n.options.dragToSelect;n.userEvents=new f.UserEvents(n.element,{global:true,allowSelection:true,filter:(!m?"."+v+" ":"")+n.options.filter,tap:n._tap.bind(n),touchAction:i?"none":"pan-x pan-y"});if(i){if(s)n.userEvents.bind("start",n._start.bind(n)).bind("move",n._move.bind(n)).bind("end",n._end.bind(n));n.userEvents.bind("select",n._select.bind(n))}},events:[p,s],options:{name:"Selectable",filter:">*",inputSelectors:a,multiple:false,dragToSelect:true,relatedTarget:u.noop,ignoreOverlapped:false,addIdToRanges:false},_isElement:function(e){var t=this.element;var n,i=t.length,s=false;e=e[0];for(n=0;n<i;n++)if(t[n]===e){s=true;break}return s},_tap:function(e){var t=u(e.target),n=this,i=e.event.ctrlKey||e.event.metaKey,s=n.options.multiple,r=s&&e.event.shiftKey,l=n.options.selectedClass||d,a,o=e.event.which,c=e.event.button;if(!n._isElement(t.closest("."+v))||o&&o==3||c&&c==2)return;if(!this._allowSelection(e.event.target))return;a=t.hasClass(l);if(!s||!i)n.clear();t=t.add(n.relatedTarget(t));if(r)n.selectRange(n._firstSelectee(),t,e);else{if(a&&i){n._unselect(t);n._notify(p,e)}else n.value(t,e);n._lastActive=n._downTarget=t}},_start:function(e){var t=this,n=u(e.target),i=t.options.selectedClass||d,s=n.hasClass(i),r,l=e.event.ctrlKey||e.event.metaKey;if(!this._allowSelection(e.event.target))return;t._downTarget=n;if(!t._isElement(n.closest("."+v))){t.userEvents.cancel();return}if(t.options.useAllItems)t._items=t.element.find(t.options.filter);else{r=n.closest(t.element);t._items=r.find(t.options.filter)}e.sender.capture();t._marquee.appendTo(document.body).css({left:e.x.client+1,top:e.y.client+1,width:0,height:0});if(!l)t.clear();n=n.add(t.relatedTarget(n));if(s){t._selectElement(n,true);if(l)n.addClass(h)}},_move:function(e){var t=this,n={left:e.x.startLocation>e.x.location?e.x.location:e.x.startLocation,top:e.y.startLocation>e.y.location?e.y.location:e.y.startLocation,width:i(e.x.initialDelta),height:i(e.y.initialDelta)};t._marquee.css(n);t._invalidateSelectables(n,e.event.ctrlKey||e.event.metaKey);e.preventDefault()},_end:function(e){var t=this,n=f.attr("range-selected"),i=f.guid();t._marquee.remove();t._unselect(t.element.find(t.options.filter+"."+h)).removeClass(h);var s=t.element.find(t.options.filter+"."+c);s=s.add(t.relatedTarget(s));if(t.options.addIdToRanges)for(var r=0;r<t._currentlyActive.length;r++)u(t._currentlyActive[r]).attr(n,i);t.value(s,e);t._lastActive=t._downTarget;t._items=null},_invalidateSelectables:function(e,t){var n,i,s=this._downTarget[0],r=this._items,l=this.options.selectedClass||d,a,o;this._currentlyActive=[];for(n=0,i=r.length;n<i;n++){o=r.eq(n);a=o.add(this.relatedTarget(o));if(y(o,e)){if(o.hasClass(l)){if(t&&s!==o[0])a.removeClass(l).addClass(h)}else if(!o.hasClass(c)&&!o.hasClass(h)&&!this._collidesWithActiveElement(a,e))a.addClass(c);this._currentlyActive.push(a[0])}else if(o.hasClass(c))a.removeClass(c);else if(t&&o.hasClass(h))a.removeClass(h).addClass(l)}},_collidesWithActiveElement:function(e,t){if(!this.options.ignoreOverlapped)return false;var n=this._currentlyActive;var i=e[0].getBoundingClientRect();var s;var r=false;var l=f.support.isRtl(e);var a=l?"right":"left";var o={};t.right=t.left+t.width;t.bottom=t.top+t.height;for(var c=0;c<n.length;c++){s=n[c].getBoundingClientRect();if(k(i,s)){o[a]=a==="left"?s.right:s.left;i=g({},i,o);if(i.left>i.right)return true;r=!k(i,t)}}return r},value:function(e,t){var n=this,i=n._selectElement.bind(n);if(e){e.each(function(){i(this)});n._notify(p,t);return}return n.element.find(n.options.filter+"."+(n.options.selectedClass||d))},selectedRanges:function(){var e=this;var s=f.attr("range-selected");var r={};e.element.find("["+s+"]").each(function(e,t){var n=u(t).attr(s);var i=r[n];if(!i)i=r[n]=[];i.push(u(t))});return r},selectedSingleItems:function(){var e=this;var t=f.attr("range-selected");return e.element.find(e.options.filter+"."+(e.options.selectedClass||d)+":not(["+t+"])").toArray().map(function(e){return u(e)})},_firstSelectee:function(){var e=this,t;if(e._lastActive!==null)return e._lastActive;t=e.value();return t.length>0?t[0]:e.element.find(e.options.filter)[0]},_selectElement:function(e,t){var n=u(e),i=this.options.selectedClass||d,s=!t&&this._notify("select",{element:e});n.removeClass(c);if(!s){n.addClass(i);if(this.options.aria)n.attr(l,true)}},_notify:function(e,t){t=t||{};return this.trigger(e,t)},_unselect:function(e){if(this.trigger(s,{element:e}))return;var t=f.attr("range-selected");e.removeClass(this.options.selectedClass||d).removeAttr(t);if(this.options.aria)e.attr(l,false);return e},_select:function(e){if(this._allowSelection(e.event.target))if(!o||o&&!u(f._activeElement()).is(this.options.inputSelectors))e.preventDefault()},_allowSelection:function(e){if(u(e).is(this.options.inputSelectors)){this.userEvents.cancel();this._downTarget=null;return false}return true},resetTouchEvents:function(){this.userEvents.cancel()},clear:function(){var e=this.element.find(this.options.filter+"."+(this.options.selectedClass||d));this._unselect(e)},selectRange:function(e,t,n){var i=this,s,r,l;i.clear();if(i.element.length>1)l=i.options.continuousItems();if(!l||!l.length)l=i.element.find(i.options.filter);e=u.inArray(u(e)[0],l);t=u.inArray(u(t)[0],l);if(e>t){r=e;e=t;t=r}if(!i.options.useAllItems)t+=i.element.length-1;for(s=e;s<=t;s++)i._selectElement(l[s]);i._notify(p,n)},destroy:function(){var e=this;r.fn.destroy.call(e);e.element.off(n);e.userEvents.destroy();e._marquee=e._lastActive=e.element=e.userEvents=null}}));function y(e,t){if(!e.is(":visible"))return false;var n=f.getOffset(e),i=t.left+t.width,s=t.top+t.height;n.right=n.left+f._outerWidth(e);n.bottom=n.top+f._outerHeight(e);return!(n.left>i||n.right<t.left||n.top>s||n.bottom<t.top)}function k(e,t){return!(e.right<=t.left||e.left>=t.right||e.bottom<=t.top||e.top>=t.bottom)}return b.parseOptions=function(e){var t=e.mode||e;var n=typeof t==="string"&&t.toLowerCase();return{multiple:n&&n.indexOf("multiple")>-1,cell:n&&n.indexOf("cell")>-1}},f.ui.plugin(b),window.kendo})?i.apply(t,n):i)||(e.exports=t)}});