AyaWo.Web/Content/zui/dist/lib/selectable/zui.selectable.min.js

(完整代码) 4KB

/*!
 * ZUI: 拖拽选择 - v1.7.0 - 2017-06-17
 * http://zui.sexy
 * GitHub: https://github.com/easysoft/zui.git 
 * Copyright (c) 2017 cnezsoft.com; Licensed MIT
 */
!function(t){"use strict";var e="zui.selectable",i=function(i,n){this.name=e,this.$=t(i),this.id=t.zui.uuid(),this.selectOrder=1,this.selections={},this.getOptions(n),this._init()},n=function(t,e,i){return t>=i.left&&t<=i.left+i.width&&e>=i.top&&e<=i.top+i.height},o=function(t,e){var i=Math.max(t.left,e.left),o=Math.max(t.top,e.top),l=Math.min(t.left+t.width,e.left+e.width),s=Math.min(t.top+t.height,e.top+e.height);return n(i,o,t)&&n(l,s,t)&&n(i,o,e)&&n(l,s,e)};i.DEFAULTS={selector:"li,tr,div",trigger:"",selectClass:"active",rangeStyle:{border:"1px solid "+(t.zui.colorset?t.zui.colorset.primary:"#3280fc"),backgroundColor:t.zui.colorset?new t.zui.Color(t.zui.colorset.primary).fade(20).toCssStr():"rgba(50, 128, 252, 0.2)"},clickBehavior:"toggle",ignoreVal:3},i.prototype.getOptions=function(e){this.options=t.extend({},i.DEFAULTS,this.$.data(),e)},i.prototype.select=function(t){this.toggle(t,!0)},i.prototype.unselect=function(t){this.toggle(t,!1)},i.prototype.toggle=function(e,i,n){var o,l,s=this.options.selector,c=this;if(void 0===e)return void this.$.find(s).each(function(){c.toggle(this,i)});if("object"==typeof e?(o=t(e).closest(s),l=o.data("id")):(l=e,o=c.$.find('.slectable-item[data-id="'+l+'"]')),o&&o.length){if(l||(l=t.zui.uuid(),o.attr("data-id",l)),void 0!==i&&null!==i||(i=!c.selections[l]),!!i!=!!c.selections[l]){var a;t.isFunction(n)&&(a=n(i)),a!==!0&&(c.selections[l]=!!i&&c.selectOrder++,c.callEvent(i?"select":"unselect",{id:l,selections:c.selections,target:o,selected:c.getSelectedArray()},c))}o.toggleClass(c.options.selectClass,i)}},i.prototype.getSelectedArray=function(){var e=[];return t.each(this.selections,function(t,i){i&&e.push(t)}),e},i.prototype._init=function(){var e,i,n,l,s,c,a,r=this.options,u=this,h=r.ignoreVal,d=!0,g="."+this.name+"."+this.id,f=t.isFunction(r.checkFunc)?r.checkFunc:null,p=t.isFunction(r.rangeFunc)?r.rangeFunc:null,v=!1,m=null,y="mousedown"+g,b=function(){l&&u.$children.each(function(){var e=t(this),i=e.offset();i.width=e.outerWidth(),i.height=e.outerHeight();var n=p?p.call(this,l,i):o(l,i);if(f){var s=f.call(u,{intersect:n,target:e,range:l,targetRange:i});s===!0?u.select(e):s===!1&&u.unselect(e)}else n?u.select(e):u.multiKey||u.unselect(e)})},w=function(o){v&&(s=o.pageX,c=o.pageY,l={width:Math.abs(s-e),height:Math.abs(c-i),left:s>e?e:s,top:c>i?i:c},d&&l.width<h&&l.height<h||(n||(n=t('.selectable-range[data-id="'+u.id+'"]'),n.length||(n=t('<div class="selectable-range" data-id="'+u.id+'"></div>').css(t.extend({zIndex:1060,position:"absolute",top:e,left:i,pointerEvents:"none"},u.options.rangeStyle)).appendTo(t("body")))),n.css(l),clearTimeout(a),a=setTimeout(b,10),d=!1))},z=function(e){t(document).off(g),clearTimeout(m),v&&(v=!1,n&&n.remove(),d||l&&(clearTimeout(a),b(),l=null),u.callEvent("finish",{selections:u.selections,selected:u.getSelectedArray()}),e.preventDefault())},C=function(o){if(v)return z(o);var l=t.zui.getMouseButtonCode(r.mouseButton);if(!(l>-1&&o.button!==l||u.altKey||3===o.which||u.callEvent("start",o)===!1)){var s=u.$children=u.$.find(r.selector);s.addClass("slectable-item");var c=u.multiKey?"multi":r.clickBehavior;if("multi"===c?u.toggle(o.target):"single"===c?(u.unselect(),u.select(o.target)):"toggle"===c&&u.toggle(o.target,null,function(t){u.unselect()}),u.callEvent("startDrag",o)===!1)return void u.callEvent("finish",{selections:u.selections,selected:u.getSelectedArray()});e=o.pageX,i=o.pageY,n=null,d=!0,v=!0,t(document).on("mousemove"+g,w).on("mouseup"+g,z),m=setTimeout(function(){t(document).on(y,z)},10),o.preventDefault()}},E=r.container&&"default"!==r.container?t(r.container):this.$;r.trigger?E.on(y,r.trigger,C):E.on(y,C),t(document).on("keydown",function(t){var e=t.keyCode;17===e||91==e?u.multiKey=e:18===e&&(u.altKey=!0)}).on("keyup",function(t){u.multiKey=!1,u.altKey=!1})},i.prototype.callEvent=function(e,i){var n=t.Event(e+"."+this.name);this.$.trigger(n,i);var o=n.result,l=this.options[e];return t.isFunction(l)&&(o=l.apply(this,t.isArray(i)?i:[i])),o},t.fn.selectable=function(n){return this.each(function(){var o=t(this),l=o.data(e),s="object"==typeof n&&n;l||o.data(e,l=new i(this,s)),"string"==typeof n&&l[n]()})},t.fn.selectable.Constructor=i,t(function(){t('[data-ride="selectable"]').selectable()})}(jQuery);

24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明

AI 解读 AI

登录后可用,每次 10 算力,解读结果公开显示在下面。

还没有人解读过这个文件。