|
|
@@ -0,0 +1,2050 @@
|
|
|
+window.ss = window.ss || {};
|
|
|
+window.ss.drag = window.ss.drag || {};
|
|
|
+var ismousedown = false;
|
|
|
+var functionKeyDown = false;
|
|
|
+var setDrag, DM, itemid = 0, readyMouseIcoLen = 12;
|
|
|
+function isEventTargetIsEditable(event) {
|
|
|
+ var tg = event.target;
|
|
|
+ return tg.nodeName == 'textarea' || (tg.nodeName == '#text' && $(tg).parent("[contenteditable]").length > 0) || isContenteditable(tg);
|
|
|
+}
|
|
|
+;
|
|
|
+function isContenteditable(ele) {
|
|
|
+ return $(ele).is("[contenteditable]");
|
|
|
+}
|
|
|
+;
|
|
|
+function clearMouseIcon() {
|
|
|
+ for (var iii = 1; iii <= readyMouseIcoLen; iii++) {
|
|
|
+ $(".cursor-timing" + iii).removeClass("cursor-timing" + iii);
|
|
|
+ }
|
|
|
+}
|
|
|
+function docMouseDown(event) {
|
|
|
+ ismousedown = true;
|
|
|
+ if (!isEventTargetIsEditable(event || window.event)) {
|
|
|
+ $("[ssObjId] [editable]").removeAttr("contenteditable"); // ("[wdObjectId] [。Lin
|
|
|
+ }
|
|
|
+}
|
|
|
+function docMouseMove(event) {
|
|
|
+ // clearSlct();
|
|
|
+ var panel = DM.dragingPanel;
|
|
|
+ var currentdrager = DM.currentDrager;
|
|
|
+ var flist = (currentdrager || {}).focusedList;
|
|
|
+ if (currentdrager && !currentdrager.editGroup && !currentdrager.editOrder && currentdrager.getLists().length < 2) { }
|
|
|
+ else if (ismousedown && (panel || (currentdrager && flist && flist.currentMouseDownItem))) { //拖动中
|
|
|
+ if ((panel = DM.dragingPanel) == null) {
|
|
|
+ var ci = flist.currentMouseDownItem;
|
|
|
+ var tcx = event.clientX;
|
|
|
+ var tcy = event.clientY;
|
|
|
+ var cx = ci.cx || tcx;
|
|
|
+ var cy = ci.cy || tcy;
|
|
|
+ var xdiff = cx - tcx; // 计算两个点的横坐标之差
|
|
|
+ var ydiff = cy - tcy; // 计算两个点的纵坐标之差
|
|
|
+ if (Math.pow((xdiff * xdiff + ydiff * ydiff), 0.5) < 10) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ panel = DM.dragingPanel = new window.ss.drag.DragPanel();
|
|
|
+ document.body.appendChild(panel.element);
|
|
|
+ }
|
|
|
+ return;
|
|
|
+ }
|
|
|
+}
|
|
|
+function docMouseUp(event) {
|
|
|
+ ismousedown = false;
|
|
|
+ DM.currentMouseDownItem = null;
|
|
|
+ DM.dragingPanel != null && DM.dragingPanel.destroy();
|
|
|
+ clearMouseIcon();
|
|
|
+}
|
|
|
+window.ss.drag.DragerManager = function () {
|
|
|
+ console.log("new DragerManager");
|
|
|
+ try {
|
|
|
+ $("body").append("<link id='dragcss' rel='stylesheet' href='/ss/js/drag.css' />");
|
|
|
+ $("head").append("<style>.subList .hLine-warning{width: calc(100% - 56px);float: right;} .vLine-warning{ display:inline-block;float:left;height:20px;position:unset;height:35px} .subList{min-height: 40px;}</style>");
|
|
|
+ }
|
|
|
+ catch (e) { }
|
|
|
+ /**
|
|
|
+ * 清除选中的文字
|
|
|
+ */
|
|
|
+ var clearSlct = "getSelection" in window ? function () {
|
|
|
+ var _a;
|
|
|
+ (_a = window.getSelection()) === null || _a === void 0 ? void 0 : _a.removeAllRanges();
|
|
|
+ } : function () {
|
|
|
+ var _a;
|
|
|
+ (_a = document.selection) === null || _a === void 0 ? void 0 : _a.empty();
|
|
|
+ };
|
|
|
+ // /**
|
|
|
+ // *
|
|
|
+ // * @param {Object} event
|
|
|
+ // */
|
|
|
+ // document.onselectstart = function (event) {
|
|
|
+ // return false;
|
|
|
+ // };
|
|
|
+ /**
|
|
|
+ *
|
|
|
+ * @param {Object} event
|
|
|
+ */
|
|
|
+ document.addEventListener("mousedown", docMouseDown);
|
|
|
+ /**
|
|
|
+ *
|
|
|
+ * @param {Object} event
|
|
|
+ */
|
|
|
+ document.addEventListener("mousemove", docMouseMove);
|
|
|
+ /**
|
|
|
+ * 触发移动时候的item的进出事件
|
|
|
+ * @param {Object} dragList
|
|
|
+ * @param {Object} panel
|
|
|
+ * @param {Object} haschild
|
|
|
+ * @param {Object} event
|
|
|
+ */
|
|
|
+ function eachListItem(dragList, panel, haschild, event) {
|
|
|
+ return;
|
|
|
+ var ghost = panel.ghost;
|
|
|
+ var dr = dragList.drager;
|
|
|
+ // var visibleItem=
|
|
|
+ dragList.each(/*dragList.getItems()*/ dragList.visibleElements, function () {
|
|
|
+ var location = this.isMouseOver(event);
|
|
|
+ dr = this.drager;
|
|
|
+ /*触发进出事件*/
|
|
|
+ if (location > 0) { //这里触发item的鼠标进出事件,以后可能会调整,同时这里的逻辑有点问题但是能用,以后处理
|
|
|
+ !this.isEnter && this.trigger("mouseover");
|
|
|
+ this.isEnter && this.trigger("mousemove");
|
|
|
+ this.isEnter = true; //进来了
|
|
|
+ DM.dragingPanel.currentHoverItem = this;
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ this.isEnter && this.trigger("mouseleave");
|
|
|
+ this.isEnter = false; //出去了
|
|
|
+ }
|
|
|
+ if (location > 0 && (this.drager.editGroup || this.drager.editOrder) && this.isExpand && !this.getDragList().isChild) { //鼠标在展开的group上面
|
|
|
+ if (haschild) {
|
|
|
+ panel.notAllowDrop();
|
|
|
+ }
|
|
|
+ else if (this.dragList.isMouseOver(event) > 0) {
|
|
|
+ ghost.getDragList() != this.dragList && this.dragList.append(ghost);
|
|
|
+ eachListItem(this.dragList, panel, haschild, event);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ ghost.lineMode();
|
|
|
+ });
|
|
|
+ !dr.editGroup && !dr.editOrder && (dragList.element.scrollTop = dragList.element.scrollHeight);
|
|
|
+ }
|
|
|
+ ;
|
|
|
+ /**
|
|
|
+ *
|
|
|
+ * @param {Object} event
|
|
|
+ */
|
|
|
+ document.addEventListener("mouseup", docMouseUp);
|
|
|
+ /**
|
|
|
+ *
|
|
|
+ * @param {Object} event
|
|
|
+ */
|
|
|
+ document.addEventListener("keydown", function (event) {
|
|
|
+ functionKeyDown = event.ctrlKey || event.altKey || event.shiftKey;
|
|
|
+ event.ctrlKey && event.keyCode === 65 && DM.currentDrager.focusedList != null && DM.currentDrager.focusedList.selectAll();
|
|
|
+ });
|
|
|
+ /**
|
|
|
+ *
|
|
|
+ * @param {Object} event
|
|
|
+ */
|
|
|
+ document.addEventListener("keyup", function (event) {
|
|
|
+ functionKeyDown = event.ctrlKey || event.altKey || event.shiftKey;
|
|
|
+ });
|
|
|
+};
|
|
|
+window.ss.drag.DragerManager.prototype = {
|
|
|
+ constVars: {
|
|
|
+ editOrder: "editOrder",
|
|
|
+ editGroup: "editGroup"
|
|
|
+ },
|
|
|
+ instances: {},
|
|
|
+ utils: {
|
|
|
+ contains: function (arr, val) {
|
|
|
+ if (typeof arr == 'object' && (arr instanceof Array || arr instanceof NodeList)) {
|
|
|
+ for (var i = 0; i < arr.length; i++) {
|
|
|
+ if (arr[i] == val) {
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return false;
|
|
|
+ },
|
|
|
+ parseForm2Url: function (form) {
|
|
|
+ var arr = [];
|
|
|
+ var action_ = form.getAttribute("action");
|
|
|
+ var param = (action_ || "?").split("?");
|
|
|
+ arr = arr.concat((param[1] || "").split("&"));
|
|
|
+ var elements = form.querySelectorAll("input,select,textarea");
|
|
|
+ for (var i = 0; i < elements; i++) {
|
|
|
+ var feled = elements[i];
|
|
|
+ switch (feled.type) {
|
|
|
+ case undefined:
|
|
|
+ case 'button':
|
|
|
+ case 'file':
|
|
|
+ case 'reset':
|
|
|
+ case 'submit':
|
|
|
+ break;
|
|
|
+ case 'checkbox':
|
|
|
+ case 'radio':
|
|
|
+ if (!feled.checked) {
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ default:
|
|
|
+ if (feled.value != null && feled.value != '' && feled.name != null && !feled.disabled) {
|
|
|
+ arr.push(feled.name + "=" + feled.value);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return param[0] + "?" + arr.join("&");
|
|
|
+ },
|
|
|
+ containsKey: function (obj, key) {
|
|
|
+ for (var key_ in obj) {
|
|
|
+ if (key_ == key) {
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ },
|
|
|
+ getDrager: function (name) {
|
|
|
+ if (name) {
|
|
|
+ return this.instances[name];
|
|
|
+ }
|
|
|
+ for (var key in this.instances) {
|
|
|
+ return this.instances[key];
|
|
|
+ }
|
|
|
+ return;
|
|
|
+ },
|
|
|
+ getCurrentFocusList: function () {
|
|
|
+ return (this.currentDrager || {}).focusedList;
|
|
|
+ },
|
|
|
+ getCurrentSelectedItems: function () {
|
|
|
+ if (this.getCurrentFocusList()) {
|
|
|
+ return this.getCurrentFocusList().getSelectedItems();
|
|
|
+ }
|
|
|
+ },
|
|
|
+ addItem: function (id, item, index, isCover) {
|
|
|
+ return this.getDrager().addItem(id, item, index, isCover);
|
|
|
+ },
|
|
|
+ drager: function (name, group, functions, baseOptions) {
|
|
|
+ this.itemSelector = "div[ssObjId]"; // [wdObjectID]。是 wdObjectID,不是 wdObjectId。Lin
|
|
|
+ this.name = name;
|
|
|
+ this.imgleft = 30;
|
|
|
+ this.dragerManager = this;
|
|
|
+ this.items = {};
|
|
|
+ this.name = name;
|
|
|
+ this.getItems = function () {
|
|
|
+ var tmp = [];
|
|
|
+ this.selectedList != null && (tmp = tmp.concat(this.selectedList.getAllItems()));
|
|
|
+ this.optionList != null && (tmp = tmp.concat(this.optionList.getAllItems()));
|
|
|
+ return tmp;
|
|
|
+ };
|
|
|
+ this.destroy = function () {
|
|
|
+ this.selectedList && this.selectedList.destroy();
|
|
|
+ this.optionList && this.optionList.destroy();
|
|
|
+ delete DM.instances[this.name];
|
|
|
+ };
|
|
|
+ this.getLists = function () {
|
|
|
+ var arr = [];
|
|
|
+ this.selectedList && arr.push(this.selectedList);
|
|
|
+ this.optionList && arr.push(this.optionList);
|
|
|
+ return arr;
|
|
|
+ };
|
|
|
+ this.getSelectedResult = function () {
|
|
|
+ return this.selectedList.getResult();
|
|
|
+ };
|
|
|
+ this.addItem = function (id, element, index, isCover) {
|
|
|
+ return this.addItemTo(id, element, this.selectedList, index);
|
|
|
+ };
|
|
|
+ this.addItemToFocusedList = function (id, element, index, isCover) {
|
|
|
+ this.addItemTo(id, element, this.focusedList, index, isCover);
|
|
|
+ };
|
|
|
+ this.addItemTo = function (id, element, list, index, isCover) {
|
|
|
+ if (list == this.focusedList) { }
|
|
|
+ else if (this.focusedList.isChild && this.focusedList.thisItem.getDragList() == list) {
|
|
|
+ list = this.focusedList;
|
|
|
+ }
|
|
|
+ return list.insertItemByHtml(id, element, index, isCover);
|
|
|
+ };
|
|
|
+ this.init = function () {
|
|
|
+ var this_ = this;
|
|
|
+ for (var key in baseOptions) {
|
|
|
+ this_[key] = baseOptions[key];
|
|
|
+ }
|
|
|
+ //处理functions
|
|
|
+ this_.functions = functions || [];
|
|
|
+ this_.group = group == true || group == "true";
|
|
|
+ this_.editOrder = this_.functions.indexOf(DM.constVars.editOrder) > -1;
|
|
|
+ this_.editGroup = this_.functions.indexOf(DM.constVars.editGroup) > -1;
|
|
|
+ //获取查询表单
|
|
|
+ var form = document.getElementsByName(name + "OptionForm")[0] || document.getElementById(name + "OptionForm");
|
|
|
+ if (form) {
|
|
|
+ this_.form = new window.ss.drag.Form(form);
|
|
|
+ this_.form.drager = this;
|
|
|
+ }
|
|
|
+ var selectedList = document.getElementById(name + "Selected");
|
|
|
+ if (selectedList) {
|
|
|
+ var list = new window.ss.drag.DragList(name, selectedList);
|
|
|
+ list.isSelectedList = true;
|
|
|
+ var input = document.getElementsByName(name + "SelectedId")[0];
|
|
|
+ input = input || document.getElementsByName(name + "SelectedId")[0];
|
|
|
+ input = input || document.createElement("input");
|
|
|
+ input.type = "hidden";
|
|
|
+ input.name = name + "SelectedId";
|
|
|
+ list.before(input);
|
|
|
+ list.result_input = input;
|
|
|
+ list.init();
|
|
|
+ list.alignMode = this.selectedListAlignMode || this.alignMode || "vertical";
|
|
|
+ this.selectedList = list;
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ console.log("没有找到selectedList");
|
|
|
+ }
|
|
|
+ var optionList = document.getElementById(name + "Option");
|
|
|
+ if (optionList) {
|
|
|
+ var list = new window.ss.drag.DragList(name, optionList);
|
|
|
+ list.isOptionList = true;
|
|
|
+ list.init();
|
|
|
+ // list.functions = this.functions || [];
|
|
|
+ // if(this.optionFunctions)
|
|
|
+ // list.functions = list.functions.concat(this.optionFunctions);
|
|
|
+ list.alignMode = this.optionListAlignMode || this.alignMode || "vertical";
|
|
|
+ this.optionList = list;
|
|
|
+ }
|
|
|
+ //获取按钮区域
|
|
|
+ function moveEnd(items) {
|
|
|
+ DM.getDrager(name).optionList.updateInfo();
|
|
|
+ DM.getDrager(name).optionList.clearSelect();
|
|
|
+ DM.getDrager(name).optionList.trigger("dragend");
|
|
|
+ DM.getDrager(name).selectedList.updateInfo();
|
|
|
+ DM.getDrager(name).selectedList.clearSelect();
|
|
|
+ DM.getDrager(name).selectedList.trigger("dragend");
|
|
|
+ if (DM.getDrager(name).dragend) {
|
|
|
+ var doms = [];
|
|
|
+ $.each(items, function () {
|
|
|
+ doms.push(this.element);
|
|
|
+ });
|
|
|
+ DM.getDrager(name).dragend.call(this, doms);
|
|
|
+ }
|
|
|
+ ;
|
|
|
+ }
|
|
|
+ var moveButtons = {
|
|
|
+ 'PickAll': function () {
|
|
|
+ var items = DM.getDrager(name).optionList.getSelectedItems();
|
|
|
+ if (items.length < 1) {
|
|
|
+ items = $(DM.getDrager(name).optionList.element).children("[ssObjId]:not(:hidden)"); // [wdObjectId]:。Lin
|
|
|
+ }
|
|
|
+ $.each(items, function () {
|
|
|
+ var eee = this.confs ? this : this.element;
|
|
|
+ if (eee && $(eee).not(":hidden")) {
|
|
|
+ DM.getDrager(name).selectedList.append(eee);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ moveEnd(items);
|
|
|
+ },
|
|
|
+ 'DropAll': function () {
|
|
|
+ var items = DM.getDrager(name).selectedList.getSelectedItems();
|
|
|
+ if (items.length < 1) {
|
|
|
+ items = $(DM.getDrager(name).selectedList.element).children("[ssObjId]:not(:hidden)"); // [wdObjectId]:。Lin
|
|
|
+ }
|
|
|
+ $.each(items, function () {
|
|
|
+ var eee = this.confs ? this : this.element;
|
|
|
+ if (eee && $(eee).not(":hidden")) {
|
|
|
+ DM.getDrager(name).optionList.append(eee);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ moveEnd(items);
|
|
|
+ }
|
|
|
+ };
|
|
|
+ for (var key in moveButtons) {
|
|
|
+ console.log("#" + name + key);
|
|
|
+ $("#" + name + key).click(moveButtons[key]);
|
|
|
+ }
|
|
|
+ this.getLists().length < 1 && console.info("没找到要初始化的Draglist\"" + name + "\"");
|
|
|
+ };
|
|
|
+ },
|
|
|
+ getInstance: function (name, group, functions, baseOptions) {
|
|
|
+ baseOptions = baseOptions || {};
|
|
|
+ var this_ = this;
|
|
|
+ return DM.instances[name] || function () {
|
|
|
+ if (typeof (this.isWriteOut) == "undefined") {
|
|
|
+ alert("注意下,这是旧的写法,以后不再自动初始化拖拽了,\n记得新的拖拽需要通过commonwrite输出^_^");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ var drager = DM.instances[name] = new this_.drager(name, group, functions, baseOptions);
|
|
|
+ drager.init();
|
|
|
+ return drager;
|
|
|
+ }();
|
|
|
+ }
|
|
|
+};
|
|
|
+window.ss.drag.Shadow = function (element) {
|
|
|
+ window.ss.drag.Base.call(this);
|
|
|
+ this.drager = element.confs.drager;
|
|
|
+ var clone = this.element = element.cloneNode(true);
|
|
|
+ clone.confs = this;
|
|
|
+ this.src = element;
|
|
|
+ this.isShadow = true;
|
|
|
+ // clone.style.opacity = "0.5";
|
|
|
+ this.addClass("shadow");
|
|
|
+ element.confs.isSelected() && this.removeClass(element.confs.getTopDragList({}).wdSelectedClass);
|
|
|
+ $(this.element).find(".icon-checked").addClass('icon-unchecked').removeClass('icon-checked');
|
|
|
+ this.getTopDragList = function (emptyObj) {
|
|
|
+ if (!this.exist())
|
|
|
+ return emptyObj;
|
|
|
+ var list = this.getDragList();
|
|
|
+ list.isChild && (list = list.thisItem.getDragList());
|
|
|
+ return list;
|
|
|
+ };
|
|
|
+ this.getDragList = function () {
|
|
|
+ return (this.element.parentNode || {}).confs;
|
|
|
+ };
|
|
|
+};
|
|
|
+window.ss.drag.Base = function (element) {
|
|
|
+ this.bindedEvent = (element || {}).bindedEvent = (element || {}).bindedEvent || {};
|
|
|
+ this.isConfs = true;
|
|
|
+ this.isshow = true;
|
|
|
+ this.element = element;
|
|
|
+ this.exist = function () {
|
|
|
+ return $.contains(document.body, this.element);
|
|
|
+ };
|
|
|
+ this.getScrollInfo = function () {
|
|
|
+ var scrollinfo = {
|
|
|
+ left: 0,
|
|
|
+ top: 0
|
|
|
+ };
|
|
|
+ getScroll(this.element);
|
|
|
+ return scrollinfo;
|
|
|
+ function getScroll(node) {
|
|
|
+ // 非Element 终止递归
|
|
|
+ if (!node) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if (node.nodeType !== 1) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if (node.parentNode && node.parentNode.tagName == "body") {
|
|
|
+ getScroll(node.parentNode);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ scrollinfo.top += node.scrollTop;
|
|
|
+ scrollinfo.left += node.scrollLeft; // position = fixed: 获取值后退出递归
|
|
|
+ if (node.parentNode)
|
|
|
+ getScroll(node.parentNode);
|
|
|
+ }
|
|
|
+ };
|
|
|
+ this.offset = function () {
|
|
|
+ var docElem, win, box = {
|
|
|
+ top: 0,
|
|
|
+ left: 0
|
|
|
+ }, elem = this.element, doc = elem && elem.ownerDocument;
|
|
|
+ if (!doc) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ docElem = doc.documentElement;
|
|
|
+ if (!DM.utils.contains(document.querySelectorAll("*"), this.element)) {
|
|
|
+ return box;
|
|
|
+ }
|
|
|
+ if (typeof elem.getBoundingClientRect !== typeof undefined) {
|
|
|
+ box = elem.getBoundingClientRect();
|
|
|
+ }
|
|
|
+ function getWindow(elem) {
|
|
|
+ return (elem && elem == elem.window) ?
|
|
|
+ elem :
|
|
|
+ elem.nodeType === 9 ?
|
|
|
+ elem.defaultView || elem.parentWindow :
|
|
|
+ false;
|
|
|
+ }
|
|
|
+ win = getWindow(doc);
|
|
|
+ return {
|
|
|
+ top: box.top + (win.pageYOffset || docElem.scrollTop) - (docElem.clientTop || 0),
|
|
|
+ left: box.left + (win.pageXOffset || docElem.scrollLeft) - (docElem.clientLeft || 0)
|
|
|
+ };
|
|
|
+ };
|
|
|
+ this.hide = function () {
|
|
|
+ $(this.element).hide();
|
|
|
+ this.isshow = false;
|
|
|
+ };
|
|
|
+ this.show = function () {
|
|
|
+ $(this.element).show();
|
|
|
+ this.isshow = true;
|
|
|
+ };
|
|
|
+ this.find = function (selector) {
|
|
|
+ return this.element.querySelectorAll(selector);
|
|
|
+ };
|
|
|
+ this.children = function (selector) {
|
|
|
+ selector = selector || "*";
|
|
|
+ var children = [];
|
|
|
+ $(this.element).children(selector).each(function () {
|
|
|
+ children.push(this.confs == null ? new window.ss.drag.Base(this) : this.confs);
|
|
|
+ });
|
|
|
+ return children;
|
|
|
+ };
|
|
|
+ this.is = function (selector) {
|
|
|
+ return $(this.element).is(selector);
|
|
|
+ };
|
|
|
+ this.isDom = function (obj) {
|
|
|
+ return typeof HTMLElement === 'object' ?
|
|
|
+ obj instanceof HTMLElement :
|
|
|
+ obj && typeof obj === 'object' && obj.nodeType === 1 && typeof obj.nodeName === 'string';
|
|
|
+ };
|
|
|
+ this.prev = function () {
|
|
|
+ var ele = this.element.previousSibling;
|
|
|
+ while (ele != null && ele.nodeType == 3) {
|
|
|
+ ele = ele.previousSibling;
|
|
|
+ }
|
|
|
+ return ele == null ? null : (ele.confs || new window.ss.drag.Base(ele));
|
|
|
+ };
|
|
|
+ this.next = function () {
|
|
|
+ var ele = this.element.nextSibling;
|
|
|
+ while (ele != null && ele.nodeType == 3) {
|
|
|
+ ele = ele.nextSibling;
|
|
|
+ }
|
|
|
+ return ele == null ? null : (ele.confs || new window.ss.drag.Base(ele));
|
|
|
+ };
|
|
|
+ this.prevAll = function (selector) {
|
|
|
+ selector = selector || "*";
|
|
|
+ var pe = this.element.parentNode;
|
|
|
+ // var cs = pe.children;
|
|
|
+ var cs = new window.ss.drag.Base(pe).children(selector);
|
|
|
+ var arr = [];
|
|
|
+ for (var i = 0; i < cs.length; i++) {
|
|
|
+ var csi = cs[i];
|
|
|
+ if (csi.element == this.element) {
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ arr.push(csi);
|
|
|
+ }
|
|
|
+ return arr;
|
|
|
+ };
|
|
|
+ this.nextAll = function (selector) {
|
|
|
+ selector = selector || "*";
|
|
|
+ var pe = this.element.parentNode;
|
|
|
+ // var cs = pe.children;
|
|
|
+ var cs = new window.ss.drag.Base(pe).children(selector);
|
|
|
+ var arr = [];
|
|
|
+ for (var i = cs.length - 1; i >= 0; i--) {
|
|
|
+ var csi = cs[i];
|
|
|
+ if (csi.element == this.element) {
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ arr.unshift(csi);
|
|
|
+ }
|
|
|
+ return arr;
|
|
|
+ };
|
|
|
+ this.remove = function () {
|
|
|
+ if (this.bindedEvent) {
|
|
|
+ for (var key in this.bindedEvent) {
|
|
|
+ this.off(key);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ this.element.parentNode.removeChild(this.element);
|
|
|
+ };
|
|
|
+ this.isMouseOver = function (event) {
|
|
|
+ event = event || window.event;
|
|
|
+ var target = this.element;
|
|
|
+ if (this.is("#ghost"))
|
|
|
+ return 0;
|
|
|
+ var sizeInfo = this.getSize();
|
|
|
+ var result = 0;
|
|
|
+ var cx = event.clientX;
|
|
|
+ var cy = event.clientY;
|
|
|
+ var left = sizeInfo.left;
|
|
|
+ var top = sizeInfo.top;
|
|
|
+ var width = sizeInfo.width;
|
|
|
+ var height = sizeInfo.height;
|
|
|
+ try {
|
|
|
+ (cx >= left) && (cx <= (left + width)) && (cy >= top) && (cy <= (top + height)) && (result = 1);
|
|
|
+ if (result == 0)
|
|
|
+ return 0;
|
|
|
+ if (cx >= left && cx <= parseInt(left + width / 2)) {
|
|
|
+ result *= 1; //左边
|
|
|
+ }
|
|
|
+ else if (cx > parseInt(left + width / 2) && cx <= parseInt(left + width)) {
|
|
|
+ result *= 2; //右边
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ result *= 0; //不在上面
|
|
|
+ }
|
|
|
+ if (cy >= top && cy <= parseInt(top + height / 3 * 2)) {
|
|
|
+ result *= 3; //上半部分
|
|
|
+ }
|
|
|
+ else if (cy > parseInt(top + height / 3 * 2) && cy <= parseInt(top + height)) {
|
|
|
+ result *= 4; //下半部分
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ result *= 0; //不在上面
|
|
|
+ }
|
|
|
+ }
|
|
|
+ catch (e) {
|
|
|
+ console.error(e);
|
|
|
+ return 0;
|
|
|
+ }
|
|
|
+ //左上1*3=3,右上2*3=6,左下1*4=4,右下2*4=8,不在0*0
|
|
|
+ return result;
|
|
|
+ };
|
|
|
+ this.isChildOf = function (b) {
|
|
|
+ return this.isDom(b) && $.contains(b, this.element);
|
|
|
+ };
|
|
|
+ this.getStyles = function () {
|
|
|
+ var _style;
|
|
|
+ if (!this.exist()) {
|
|
|
+ console.warn("注意,该节点不在文档里面,无法获取元素相关信息");
|
|
|
+ var offset = {
|
|
|
+ top: this.element.offsetTop,
|
|
|
+ left: this.element.offsetLeft
|
|
|
+ };
|
|
|
+ _style = this.element.style;
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ _style = window.getComputedStyle(this.element);
|
|
|
+ offset = this.offset();
|
|
|
+ }
|
|
|
+ return _style;
|
|
|
+ };
|
|
|
+ this.getSize = function () {
|
|
|
+ var offset, _style;
|
|
|
+ if (!this.exist()) {
|
|
|
+ console.warn("注意,该节点不在文档里面,无法获取元素相关信息");
|
|
|
+ offset = {
|
|
|
+ top: this.element.offsetTop,
|
|
|
+ left: this.element.offsetLeft
|
|
|
+ };
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ offset = this.offset();
|
|
|
+ }
|
|
|
+ _style = this.getStyles();
|
|
|
+ var scrollinfo = this.getScrollInfo();
|
|
|
+ var ele = this.element, sizeInfo = {
|
|
|
+ top: 0,
|
|
|
+ left: 0,
|
|
|
+ width: 0,
|
|
|
+ height: 0,
|
|
|
+ scrollleft: 0,
|
|
|
+ scrolltop: 0
|
|
|
+ }, marginTop = parseInt(_style.marginTop.replace("px", "")) || 0, marginRight = parseInt(_style.marginRight.replace("px", "")) || 0, marginBottom = parseInt(_style.marginBottom.replace("px", "")) || 0, marginLeft = parseInt(_style.marginLeft.replace("px", "")) || 0, width = parseInt(_style.width.replace("px", "")) || 0, height = parseInt(_style.height.replace("px", "")) || 0, scrollleft = scrollinfo.left || document.documentElement.scrollLeft || document.body.scrollLeft || 0, scrolltop = scrollinfo.top || document.documentElement.scrollTop || document.body.scrollTop ||
|
|
|
+ 0;
|
|
|
+ // offset = $(this.element).offset();
|
|
|
+ if (offset) {
|
|
|
+ sizeInfo.top = offset.top - (document.documentElement.offsetTop || document.body.scrollTop); // 距离body的top
|
|
|
+ sizeInfo.left = offset.left - (document.documentElement.offsetLeft || document.body.offsetLeft); // 距离body的left
|
|
|
+ sizeInfo.width = width + marginLeft + marginRight; // 宽
|
|
|
+ sizeInfo.height = height + marginTop + marginBottom; // 高
|
|
|
+ sizeInfo.scrollleft = scrollleft;
|
|
|
+ sizeInfo.scrolltop = scrolltop;
|
|
|
+ }
|
|
|
+ return sizeInfo;
|
|
|
+ };
|
|
|
+ this.each = $.each;
|
|
|
+ this.off = function (eventNames, fn) {
|
|
|
+ var ele = this.element;
|
|
|
+ var enl = eventNames.split(" ");
|
|
|
+ for (var i = 0; i < enl.length; i++) {
|
|
|
+ var eventName = enl[i];
|
|
|
+ if (this.bindedEvent[eventName]) {
|
|
|
+ var fnNameL = this.bindedEvent[eventName];
|
|
|
+ if (!fnNameL || fnNameL.length > 0) {
|
|
|
+ this.each(fnNameL, function () {
|
|
|
+ ele.removeEventListener && ele.removeEventListener(eventName, eval(this.toString()));
|
|
|
+ ele.detachEvent && ele.detachEvent("on" + eventName, eval(this.toString()));
|
|
|
+ window[this.toString()] == null;
|
|
|
+ });
|
|
|
+ if (fn) {
|
|
|
+ fn.call(this, window.event);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ this.element && (this.element.bindedEvent = this.bindedEvent);
|
|
|
+ return this;
|
|
|
+ };
|
|
|
+ this.trigger = function (eventNames) {
|
|
|
+ var enl = eventNames.split(" ");
|
|
|
+ for (var i = 0; i < enl.length; i++) {
|
|
|
+ var eventName = enl[i];
|
|
|
+ if (this.bindedEvent[eventName]) {
|
|
|
+ var events = this.bindedEvent[eventName];
|
|
|
+ this.each(events, function () {
|
|
|
+ try {
|
|
|
+ window[this.toString()].call(this, window.event);
|
|
|
+ }
|
|
|
+ catch (e) {
|
|
|
+ console.error(e);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return this;
|
|
|
+ };
|
|
|
+ this.on = function (eventNames, fn) {
|
|
|
+ var ele = this.element;
|
|
|
+ var this_ = this;
|
|
|
+ var enl = eventNames.split(/\s+/i);
|
|
|
+ for (var i = 0; i < enl.length; i++) {
|
|
|
+ var eventName = enl[i];
|
|
|
+ if (eventName == "")
|
|
|
+ continue;
|
|
|
+ var fnl = this.bindedEvent[eventName];
|
|
|
+ if (!fnl) {
|
|
|
+ fnl = this.bindedEvent[eventName] = [];
|
|
|
+ }
|
|
|
+ var fnName = "event_" + (this.id || "_") + "_" + new Date().getTime() + "_" + eventName + "_" + fnl.length;
|
|
|
+ fnName = fnName.split(/\W+/).join("_");
|
|
|
+ fnl.push(fnName);
|
|
|
+ window[fnName] = function () {
|
|
|
+ var event = window.event;
|
|
|
+ if (fn.call(this_, event) === false) {
|
|
|
+ event.preventDefault && event.preventDefault();
|
|
|
+ event.stopPropagation && event.stopPropagation();
|
|
|
+ event.cancelBubble && (event.cancelBubble = true);
|
|
|
+ }
|
|
|
+ };
|
|
|
+ ele.addEventListener && ele.addEventListener(eventName, eval(fnName), false);
|
|
|
+ ele.attachEvent && ele.attachEvent("on" + eventName, eval(fnName));
|
|
|
+ }
|
|
|
+ this.element && (this.element.bindedEvent = this.bindedEvent);
|
|
|
+ return this;
|
|
|
+ };
|
|
|
+ this.addClass = function (name) {
|
|
|
+ $(this.element).addClass(name);
|
|
|
+ return this;
|
|
|
+ };
|
|
|
+ this.toggleClass = function (name) {
|
|
|
+ if (!name) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if (this.hasClass(name)) {
|
|
|
+ this.removeClass(name);
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ this.addClass(name);
|
|
|
+ }
|
|
|
+ return this;
|
|
|
+ };
|
|
|
+ this.hasClass = function (name) {
|
|
|
+ return name && this.element.className.indexOf(name) > -1;
|
|
|
+ };
|
|
|
+ this.append = function (ele) {
|
|
|
+ var e;
|
|
|
+ if (this.isDom(ele)) {
|
|
|
+ e = ele;
|
|
|
+ }
|
|
|
+ else if (this.isConfs) {
|
|
|
+ e = ele.element;
|
|
|
+ }
|
|
|
+ $(this.element).append(e);
|
|
|
+ };
|
|
|
+ this.before = function (item) {
|
|
|
+ if (!item) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ else if (this.isDom(item)) {
|
|
|
+ this.element.parentNode.insertBefore(item, this.element);
|
|
|
+ }
|
|
|
+ else if (item.isConfs) {
|
|
|
+ this.element.parentNode.insertBefore(item.element, this.element);
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ console.log("??");
|
|
|
+ }
|
|
|
+ };
|
|
|
+ this.after = function (item) {
|
|
|
+ if (!item) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ else if (this.isDom(item)) {
|
|
|
+ this.element.parentNode.insertBefore(item, this.element.nextSibling);
|
|
|
+ }
|
|
|
+ else if (item.isConfs) {
|
|
|
+ this.element.parentNode.insertBefore(item.element, this.element.nextSibling);
|
|
|
+ }
|
|
|
+ };
|
|
|
+ this.removeClass = function (name) {
|
|
|
+ $(this.element).removeClass(name);
|
|
|
+ return this;
|
|
|
+ };
|
|
|
+ if (element && (element.confs || element.isConfs)) {
|
|
|
+ var con = element.isConfs ? element : element.confs;
|
|
|
+ for (var key in con) {
|
|
|
+ this.element.confs[key] = con[key];
|
|
|
+ }
|
|
|
+ // return;
|
|
|
+ }
|
|
|
+};
|
|
|
+var dragCursor = ["cursor-vDragMultiple", "cursor-vDrag", "cursor-timing", "cursor-hDragMultiple", "cursor-hDrag", "cursor-timing"];
|
|
|
+window.ss.drag.DragPanel = function () {
|
|
|
+ window.ss.drag.Base.call(this);
|
|
|
+ var dragList = DM.currentDrager.focusedList;
|
|
|
+ var ghost = this.ghost = new window.ss.drag.Ghost(dragList.currentMouseDownItem.element);
|
|
|
+ dragList.element.appendChild(ghost.element);
|
|
|
+ if (dragList.alignMode != "vertical") {
|
|
|
+ // $(ghost.element).removeClass("hLine-warning").addClass("vLine-warning");
|
|
|
+ // $(ghost.element).css({
|
|
|
+ // "display": "inline-block",
|
|
|
+ // "float": "left",
|
|
|
+ // "height": "20px",
|
|
|
+ // "position": "unset",
|
|
|
+ // "height": "35px"
|
|
|
+ // });
|
|
|
+ }
|
|
|
+ var box = this.element = dragList.element.cloneNode();
|
|
|
+ // var styles = document.querySelectorAll("style");
|
|
|
+ // this.each(styles, function () {
|
|
|
+ // box.appendChild(this.cloneNode(true));
|
|
|
+ // });
|
|
|
+ // styles = document.querySelectorAll("link");
|
|
|
+ // this.each(styles, function () {
|
|
|
+ // box.appendChild(this.cloneNode(true));
|
|
|
+ // });
|
|
|
+ // styles = document.querySelectorAll("LINK");
|
|
|
+ // this.each(styles, function () {
|
|
|
+ // box.appendChild(this.cloneNode(true));
|
|
|
+ // });
|
|
|
+ box.confs = this;
|
|
|
+ this.drager = dragList.drager;
|
|
|
+ this.sizeInfo = dragList.currentMouseDownItem.getSize();
|
|
|
+ this.left = dragList.currentMouseDownItem.cx - this.sizeInfo.left;
|
|
|
+ this.top = dragList.currentMouseDownItem.cy - this.sizeInfo.top;
|
|
|
+ box.style.zIndex = "9999";
|
|
|
+ box.style.background = "white";
|
|
|
+ box.style.border = "1px dashed black";
|
|
|
+ box.style.borderRadius = ".3em";
|
|
|
+ box.style.position = "fixed";
|
|
|
+ box.style.padding = ".3em";
|
|
|
+ box.id = "list";
|
|
|
+ this.notAllowDrop = function () {
|
|
|
+ this.isAllowDrop = false;
|
|
|
+ this.mask.cursor_old = DM.dragingPanel.mask.style.cursor;
|
|
|
+ this.mask.style.cursor = "not-allowed";
|
|
|
+ this.ghost.hide();
|
|
|
+ };
|
|
|
+ this.allowDrop = function () {
|
|
|
+ this.isAllowDrop = true;
|
|
|
+ this.mask.style.cursor = this.mask.cursor_old || "move";
|
|
|
+ this.mask.cursor_old = null;
|
|
|
+ this.ghost.show();
|
|
|
+ };
|
|
|
+ var items = this.items = [];
|
|
|
+ var shadows = this.shadows = [];
|
|
|
+ var count = 0;
|
|
|
+ var its = dragList.getSelectedItems();
|
|
|
+ its[0].hideDragList();
|
|
|
+ var ss = its[0].getSize();
|
|
|
+ this.each(its, function () {
|
|
|
+ var item = this;
|
|
|
+ var shadow = item.createShadow();
|
|
|
+ if (item.isExpand)
|
|
|
+ item.hideDragList();
|
|
|
+ item.shadow = shadow;
|
|
|
+ items.push(item);
|
|
|
+ shadows.push(shadow);
|
|
|
+ item.removeClass(item.getTopDragList({}).wdSelectedClass);
|
|
|
+ $(item.element).find('.icon-checked').addClass('icon-unchecked').removeClass('icon-checked');
|
|
|
+ // item.removeClass(item.getTopDragList({}).wdNormalClass);
|
|
|
+ item.removeClass(item.getTopDragList({}).wdHoverClass);
|
|
|
+ box.appendChild(item.element);
|
|
|
+ });
|
|
|
+ box.style.width = ss.width + 10 + "px";
|
|
|
+ box.style.height = ss.height * its.length + "px";
|
|
|
+ dragList.selectedItems = {};
|
|
|
+ dragList.updateVisibleElements();
|
|
|
+ dragList.trigger("mouseup");
|
|
|
+ dragList.currentMouseDownItem = null;
|
|
|
+ this.move = function (event) {
|
|
|
+ var ele = this.element;
|
|
|
+ ele.style.left = (event.clientX - this.left) + "px";
|
|
|
+ ele.style.top = (event.clientY - this.top) + "px";
|
|
|
+ };
|
|
|
+ this.getDragList = function () {
|
|
|
+ return (this.ghost.element.parentNode || {}).confs;
|
|
|
+ };
|
|
|
+ this.hasChild = function () {
|
|
|
+ for (var i = 0; i < items.length; i++) {
|
|
|
+ if (items[i].dragList && items[i].dragList.getItems().length > 0) {
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return false;
|
|
|
+ };
|
|
|
+ var t = this.getDragList().alignMode != "vertical" ? 3 : 0;
|
|
|
+ var c = items.length > 1 ? dragCursor[0 + t] : dragCursor[1 + t];
|
|
|
+ this.destroy = function () {
|
|
|
+ this.drager.selectedList && this.drager.selectedList.updateVisibleElements();
|
|
|
+ this.drager.optionList && this.drager.optionList.updateVisibleElements();
|
|
|
+ $("body,html").removeClass(dragCursor.join(" "));
|
|
|
+ $(".notallow_item").removeClass("notallow_item");
|
|
|
+ var this_ = this;
|
|
|
+ var list = this.getDragList();
|
|
|
+ this.each(this_.items, function () {
|
|
|
+ try {
|
|
|
+ var item__ = list.getItemById(this.id);
|
|
|
+ if (item__.isGhost || item__.isShadow || item__ == this) { }
|
|
|
+ else {
|
|
|
+ item__.remove();
|
|
|
+ console.log("找到重复的ID“" + this.id + "”,覆盖");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ catch (e) { }
|
|
|
+ if (this_.ghost.isshow) {
|
|
|
+ this_.ghost.before(this);
|
|
|
+ this.select();
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ this.shadow.before(this);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ this.each(this_.shadows, function () {
|
|
|
+ this.remove();
|
|
|
+ });
|
|
|
+ this.each(this.drager.getLists(), function () {
|
|
|
+ var this_ = this;
|
|
|
+ setTimeout(function () {
|
|
|
+ this_.trigger("dragend");
|
|
|
+ }, 1);
|
|
|
+ });
|
|
|
+ this.each(this.items, function () {
|
|
|
+ var this_ = this;
|
|
|
+ setTimeout(function () {
|
|
|
+ this_.trigger("dragend");
|
|
|
+ });
|
|
|
+ });
|
|
|
+ this.each(this.drager.getLists(), function () {
|
|
|
+ this.clearSelect();
|
|
|
+ });
|
|
|
+ this.each(items, function () {
|
|
|
+ this.select();
|
|
|
+ });
|
|
|
+ if (this.drager.dragend) {
|
|
|
+ var doms = [];
|
|
|
+ this.each(items, function () {
|
|
|
+ doms.push(this.element);
|
|
|
+ });
|
|
|
+ this.drager.dragend.call(this, doms, this.ghost.element);
|
|
|
+ }
|
|
|
+ ;
|
|
|
+ this.ghost.getDragList().focus();
|
|
|
+ this.ghost.destroy();
|
|
|
+ this.remove();
|
|
|
+ DM.dragingPanel = null;
|
|
|
+ };
|
|
|
+ var mask = this.mask = $("<div style='clear:both;position:absolute;top:-1em;left:-1em;right:-1em;bottom:-1em;z-index:110000' class='panel'/>")[0];
|
|
|
+ new window.ss.drag.Base(mask).on("mousewheel DOMMouseScroll", function (e) {
|
|
|
+ function isCanScroll(obj) {
|
|
|
+ if (obj) {
|
|
|
+ var of = window.getComputedStyle(obj)["overflow-y"];
|
|
|
+ return ("scroll|auto".indexOf(of) > -1) && (obj.scrollHeight > 0);
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ ;
|
|
|
+ function findObjScrollParent(obj, i) {
|
|
|
+ i = i || 0;
|
|
|
+ i++;
|
|
|
+ var par = obj.parentNode;
|
|
|
+ if (obj.tagName == "HTML") {
|
|
|
+ return obj.querySelector("body");
|
|
|
+ }
|
|
|
+ if (isCanScroll(par)) {
|
|
|
+ return par;
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ return findObjScrollParent(par, i);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ ;
|
|
|
+ var delta = (e.wheelDelta && (e.wheelDelta > 0 ? 1 : -1)) || // chrome & ie
|
|
|
+ (e.detail && (e.detail > 0 ? -1 : 1)); // firefox
|
|
|
+ findObjScrollParent(ghost.element, 0).scrollTop -= delta * 35;
|
|
|
+ ghost.getDragList().updateVisibleElements();
|
|
|
+ });
|
|
|
+ $("body,html").addClass(c);
|
|
|
+ if (this.hasChild()) {
|
|
|
+ $.each(this.drager.getLists(), function () {
|
|
|
+ $(this.element).children(this.drager.itemSelector).addClass("notallow_item");
|
|
|
+ });
|
|
|
+ }
|
|
|
+ box.appendChild(mask);
|
|
|
+ document.body.appendChild(box);
|
|
|
+ box.style.display = "none";
|
|
|
+ DM.justEnd = true;
|
|
|
+};
|
|
|
+window.ss.drag.DragList = function (name, element) {
|
|
|
+ window.ss.drag.Base.call(this);
|
|
|
+ var drager = this.drager = DM.getInstance(name);
|
|
|
+ this.visibleElements = [];
|
|
|
+ this.wdNormalClass = element.getAttribute("ssNormClazz") || ""; // ("wdNormalClass")。Lin
|
|
|
+ this.wdHoverClass = element.getAttribute("ssHovClazz") || ""; // ("wdHoverClass")。Lin
|
|
|
+ this.wdSelectedClass = element.getAttribute("ssSelClazz") || ""; // ("wdSelectedClass")。Lin
|
|
|
+ this.wdSelectedParentClass = element.getAttribute("wdSelectedParentClass") || "";
|
|
|
+ this.element = element.isConfs ? element.element : element;
|
|
|
+ this.isChild = false;
|
|
|
+ this.isDragList = true;
|
|
|
+ this.dragerName = name;
|
|
|
+ this.id = this.element.id;
|
|
|
+ this.element.confs = this;
|
|
|
+ this.unfocus = function () {
|
|
|
+ this.removeClass(this.wdSelectedParentClass);
|
|
|
+ this.clearSelect();
|
|
|
+ this.drager.focusedList = null;
|
|
|
+ DM.currentDrager = null;
|
|
|
+ };
|
|
|
+ this.focus = function () {
|
|
|
+ if (drager.focusedList && this != drager.focusedList) {
|
|
|
+ drager.focusedList.clearSelect();
|
|
|
+ drager.focusedList.unfocus();
|
|
|
+ }
|
|
|
+ drager.focusedList = this;
|
|
|
+ DM.currentDrager = this.drager;
|
|
|
+ DM.currentDrager.focusedList = this;
|
|
|
+ this.addClass(this.wdSelectedParentClass);
|
|
|
+ };
|
|
|
+ this.empty = function () {
|
|
|
+ this.each(this.getItems(), function () {
|
|
|
+ this.remove();
|
|
|
+ });
|
|
|
+ this.element.innerHTML = '';
|
|
|
+ this.trigger("dragend");
|
|
|
+ };
|
|
|
+ this.selectAll = function () {
|
|
|
+ this.each(this.element.children, function () {
|
|
|
+ this.confs && this.confs.select && this.confs.select();
|
|
|
+ });
|
|
|
+ };
|
|
|
+ this.clearSelect = function () {
|
|
|
+ this.each(this.element.children, function () {
|
|
|
+ if (this.confs && this.confs.exist() && !this.confs.isShadow && this.confs.isGhost != true) {
|
|
|
+ this.confs.unselect();
|
|
|
+ this.hasDragList && this.dragList && this.dragList.clearSelect();
|
|
|
+ }
|
|
|
+ });
|
|
|
+ this.selectedItems = {};
|
|
|
+ };
|
|
|
+ this.destroy = function () {
|
|
|
+ this.off("mousedown mouseup click dragend");
|
|
|
+ this.element.confs = null;
|
|
|
+ this.each(this.getItems(), function () {
|
|
|
+ this.destroy();
|
|
|
+ });
|
|
|
+ };
|
|
|
+ this.reload = function (fn) {
|
|
|
+ var this_ = this;
|
|
|
+ console.time();
|
|
|
+ this.init();
|
|
|
+ console.timeEnd();
|
|
|
+ this.each(this.drager.getLists(), function () {
|
|
|
+ this.each(this.getAllItems(), function () {
|
|
|
+ this.drager.items[this.id] = this;
|
|
|
+ });
|
|
|
+ });
|
|
|
+ fn && typeof fn == 'function' && fn();
|
|
|
+ };
|
|
|
+ this.shiftSelect = function () {
|
|
|
+ this.each(this.shiftSelectStartItem.nextAll(this.drager.itemSelector), function () {
|
|
|
+ this instanceof window.ss.drag.Item && this.select();
|
|
|
+ });
|
|
|
+ this.each(this.currentMouseDownItem.nextAll(this.drager.itemSelector), function () {
|
|
|
+ if (this instanceof window.ss.drag.Item)
|
|
|
+ if (this.isSelected()) {
|
|
|
+ this.unselect();
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ this.select();
|
|
|
+ }
|
|
|
+ });
|
|
|
+ this.shiftSelectStartItem.select();
|
|
|
+ this.currentMouseDownItem.select();
|
|
|
+ };
|
|
|
+ this.insertItemByHtml = function (objectid, html, index, isCover) {
|
|
|
+ var element = html;
|
|
|
+ !this.isDom(element) && (element = $(element)[0]);
|
|
|
+ objectid != null && element.setAttribute("ssObjId", objectid); // ("wdObjectID",。是 wdObjectID,不是 wdObjectId。Lin
|
|
|
+ var item = new window.ss.drag.Item(this.drager.name, element);
|
|
|
+ objectid && (item.id = objectid);
|
|
|
+ return this.insertItem(item, index, isCover);
|
|
|
+ };
|
|
|
+ this.insertItem = function (item, index, isCover) {
|
|
|
+ index = (index != null && index > -1) ? index : (this.getSelectedItems().length < 1 ? this.getItems().length : this.getSelectedItems()[0].getIndex());
|
|
|
+ this.drager.items[item.id] = item;
|
|
|
+ var items = this.getItems();
|
|
|
+ var old = this.getItemById(item.id);
|
|
|
+ if (old) {
|
|
|
+ console.log("找到重复的id:\"" + old.id + "\",覆盖(默认覆盖)?:" + ((isCover != false || isCover != "false") ? "覆盖" : "不覆盖"));
|
|
|
+ if (isCover != false || isCover != "false") {
|
|
|
+ old.remove();
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ console.warn("不覆盖,跳过处理");
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ var bool = false;
|
|
|
+ this.each(items, function () {
|
|
|
+ if (this.getIndex() == index) {
|
|
|
+ this.after(item);
|
|
|
+ bool = true;
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ });
|
|
|
+ !bool && this.append(item);
|
|
|
+ item.init();
|
|
|
+ item.trigger("dragend");
|
|
|
+ return item;
|
|
|
+ };
|
|
|
+ this.getSelectedItems = function () {
|
|
|
+ var arr = [];
|
|
|
+ for (var key in this.selectedItems) {
|
|
|
+ arr.push(this.selectedItems[key]);
|
|
|
+ }
|
|
|
+ return arr;
|
|
|
+ };
|
|
|
+ this.distnict = function () {
|
|
|
+ var ids = [];
|
|
|
+ this.each(this.getItems(), function () { });
|
|
|
+ };
|
|
|
+ this.updateInfo = function () {
|
|
|
+ this.each(this.getItems(), function () {
|
|
|
+ this.updateInfo();
|
|
|
+ });
|
|
|
+ };
|
|
|
+ this.getResult = function () {
|
|
|
+ this.updateInfo();
|
|
|
+ var result = [];
|
|
|
+ this.each(this.element.children, function () {
|
|
|
+ if (this.isGhost || this.isShadow || this.confs == null)
|
|
|
+ return;
|
|
|
+ var itemdata = {
|
|
|
+ ID: this.confs.id,
|
|
|
+ PID: this.confs.parentid || null
|
|
|
+ };
|
|
|
+ itemdata.PID == null && delete itemdata.PID;
|
|
|
+ itemdata.ID != null && result.push(itemdata);
|
|
|
+ if (this.confs.hasDragList && this.confs.dragList) {
|
|
|
+ this.confs.each(this.confs.dragList.getResult(), function () {
|
|
|
+ result.push(this);
|
|
|
+ });
|
|
|
+ }
|
|
|
+ });
|
|
|
+ return result;
|
|
|
+ };
|
|
|
+ this.getAllItems = function () {
|
|
|
+ var thisitems = this.getItems();
|
|
|
+ var tmp = [];
|
|
|
+ this.each(thisitems, function () {
|
|
|
+ this.hasDragList && this.dragList && (tmp = tmp.concat(this.dragList.getItems()));
|
|
|
+ });
|
|
|
+ return thisitems.concat(tmp);
|
|
|
+ };
|
|
|
+ this.getItemByIndex = function (index) {
|
|
|
+ if (this.getItems()[index])
|
|
|
+ return this.getItems()[index];
|
|
|
+ else
|
|
|
+ return null;
|
|
|
+ };
|
|
|
+ this.getItemListObj = function () {
|
|
|
+ var obj = {};
|
|
|
+ this.each(this.getItems(), function () {
|
|
|
+ obj[this.id] = this;
|
|
|
+ });
|
|
|
+ return obj;
|
|
|
+ };
|
|
|
+ this.getItemById = function (id) {
|
|
|
+ var result;
|
|
|
+ this.each(this.getItems(), function () {
|
|
|
+ if (this.id == id) {
|
|
|
+ result = this;
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ });
|
|
|
+ return result;
|
|
|
+ };
|
|
|
+ this.updateVisibleElements = function () {
|
|
|
+ if (this.alignMode == "vertical") {
|
|
|
+ this.visibleElements = this.getItems();
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ var start = this.getScrollInfo().top - 15;
|
|
|
+ var end = this.getSize().height + start + 15;
|
|
|
+ this.visibleElements = [];
|
|
|
+ while (start++ <= end) {
|
|
|
+ try {
|
|
|
+ this.visibleElements.push(this.element.querySelector("[ssObjId][tp='" + start + "']").confs); // ("[wdObjectID][。是 wdObjectID,不是 wdObjectId。Lin
|
|
|
+ }
|
|
|
+ catch (e) { }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ };
|
|
|
+ this.getItems = function () {
|
|
|
+ var result = [];
|
|
|
+ this.each(this.children(this.drager.itemSelector), function () {
|
|
|
+ (this.isItem || this.isShadow) && this.isConfs && result.push(this);
|
|
|
+ });
|
|
|
+ return result;
|
|
|
+ };
|
|
|
+ this.init = function () {
|
|
|
+ this.selectedItems = {};
|
|
|
+ var this_ = this;
|
|
|
+ var t = {};
|
|
|
+ this.on("selectstart", function (event) {
|
|
|
+ if (isEventTargetIsEditable(event)) {
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ event.preventDefault();
|
|
|
+ event.stopPropagation();
|
|
|
+ return false;
|
|
|
+ });
|
|
|
+ this.on("mousewheel DOMMouseScroll", function () {
|
|
|
+ this.updateVisibleElements();
|
|
|
+ });
|
|
|
+ this.on("mouseover", function (event) {
|
|
|
+ var panel = DM.dragingPanel;
|
|
|
+ if (panel && panel.drager == this.drager && !$.contains(this.element, panel.ghost.element)) {
|
|
|
+ this.append(panel.ghost.element);
|
|
|
+ }
|
|
|
+ return false;
|
|
|
+ });
|
|
|
+ this.each(this.children(this_.drager.itemSelector), function (index) {
|
|
|
+ // if(new window.ss.drag.Base(this).is(this_.drager.itemSelector)) {
|
|
|
+ var item = this.isItem ? this : new window.ss.drag.Item(name, this);
|
|
|
+ var id = item.id;
|
|
|
+ if (t[id] == null) {
|
|
|
+ t[id] = item;
|
|
|
+ item.init();
|
|
|
+ this_.drager.items[item.id] = item;
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ console.log("找到重复的ID“" + id + "”,删除");
|
|
|
+ item.remove();
|
|
|
+ }
|
|
|
+ if (item.id != null && !this_.isSelectedList && this_.drager.selectedList && this_.drager.selectedList.getItemById(item.id) != null) {
|
|
|
+ item.remove();
|
|
|
+ }
|
|
|
+ // }
|
|
|
+ });
|
|
|
+ if (drager.group) {
|
|
|
+ //判断是否存在环
|
|
|
+ var tmp = {};
|
|
|
+ this.each(this.getItems(), function () {
|
|
|
+ var t = tmp[this.id] = tmp[this.id] || {
|
|
|
+ id: this.id
|
|
|
+ };
|
|
|
+ if (this.parentid) {
|
|
|
+ tmp[this.parentid] = tmp[this.parentid] || {};
|
|
|
+ tmp[this.parentid].child = t;
|
|
|
+ }
|
|
|
+ });
|
|
|
+ try {
|
|
|
+ var items = this.getItemListObj();
|
|
|
+ JSON.stringify(tmp);
|
|
|
+ for (var key in items) {
|
|
|
+ if (items[key].parentid && this_.drager.items[items[key].parentid]) {
|
|
|
+ this_.drager.items[items[key].parentid].dragList.insertItem(items[key]);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ catch (e) {
|
|
|
+ console.log(items);
|
|
|
+ console.error("错误:上下级关系存在环,不进行分组放置处理");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ this.each(this.find("[ssObjId]"), function () {
|
|
|
+ this_.append(this);
|
|
|
+ });
|
|
|
+ }
|
|
|
+ if (this.isChild || this.thisItem) {
|
|
|
+ this.element.id = this.thisItem.id + new Date().getTime();
|
|
|
+ this.isChild = true;
|
|
|
+ }
|
|
|
+ this.on("dragend", function () {
|
|
|
+ var its = this.getItems();
|
|
|
+ var l = 30; //个一组
|
|
|
+ var ii = 0;
|
|
|
+ while (ii < its.length) {
|
|
|
+ (function (arr) {
|
|
|
+ setTimeout(function () {
|
|
|
+ for (var i = 0; i < arr.length; i++) {
|
|
|
+ arr[i] && arr[i].trigger("dragend");
|
|
|
+ }
|
|
|
+ });
|
|
|
+ })(its.slice(ii, ii += l));
|
|
|
+ }
|
|
|
+ if (this.result_input) {
|
|
|
+ this.result_input.value = JSON.stringify(this.getResult());
|
|
|
+ }
|
|
|
+ this.updateInfo();
|
|
|
+ });
|
|
|
+ this.off("mousedown").on("mousedown", function (event) {
|
|
|
+ if (isEventTargetIsEditable(event)) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ this.focus();
|
|
|
+ event.stopPropagation();
|
|
|
+ return false;
|
|
|
+ });
|
|
|
+ this.off("mouseup").on("mouseup", function () {
|
|
|
+ // event.stopPropagation();
|
|
|
+ // return false;
|
|
|
+ });
|
|
|
+ this.off("click").on("click", function (event) {
|
|
|
+ event.stopPropagation();
|
|
|
+ return false;
|
|
|
+ });
|
|
|
+ this.trigger("dragend");
|
|
|
+ this.updateVisibleElements();
|
|
|
+ };
|
|
|
+};
|
|
|
+var textWrapperClass = ["list", "list", "list-highlight", "list-highlight"];
|
|
|
+var iconClassName = ["icon-doc", "icon-point", "icon-openFolder", "icon-folder"];
|
|
|
+window.ss.drag.ShowBtn = function (itemelement) {
|
|
|
+ window.ss.drag.Base.call(this);
|
|
|
+ var element = this.element = $("<span> </span>")[0];
|
|
|
+ element.confs = this;
|
|
|
+ // element.style.cursor = 'pointer';
|
|
|
+ var itemEle = this.itemEle = itemelement;
|
|
|
+ this.commonHeight = 0;
|
|
|
+ this.init = function () {
|
|
|
+ // this.element.style.display = "inline-block";
|
|
|
+ // this.element.style.width = this.itemEle.confs.drager.imgleft + "px";
|
|
|
+ // this.element.style.background = "url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAQAAAC1+jfqAAAABGdBTUEAAK/INwWK6QAAABl0RVh0U29mdHdhcmUAQWRvYmUgSW1hZ2VSZWFkeXHJZTwAAADoSURBVBgZBcExblNBGAbA2ceegTRBuIKOgiihSZNTcC5LUHAihNJR0kGKCDcYJY6D3/77MdOinTvzAgCw8ysThIvn/VojIyMjIyPP+bS1sUQIV2s95pBDDvmbP/mdkft83tpYguZq5Jh/OeaYh+yzy8hTHvNlaxNNczm+la9OTlar1UdA/+C2A4trRCnD3jS8BB1obq2Gk6GU6QbQAS4BUaYSQAf4bhhKKTFdAzrAOwAxEUAH+KEM01SY3gM6wBsEAQB0gJ+maZoC3gI6iPYaAIBJsiRmHU0AALOeFC3aK2cWAACUXe7+AwO0lc9eTHYTAAAAAElFTkSuQmCC) no-repeat right ";
|
|
|
+ // this.element.style.backgroundSize = 'auto 100%';
|
|
|
+ };
|
|
|
+ this.destroy = function () {
|
|
|
+ this.remove();
|
|
|
+ };
|
|
|
+ this.initEvent = function () {
|
|
|
+ this.on("click", function () {
|
|
|
+ if (functionKeyDown)
|
|
|
+ return;
|
|
|
+ var cfs = itemEle.confs;
|
|
|
+ if ((cfs.dragList && cfs.isExpand) || (!cfs.drager.group || (cfs.dragList && cfs.dragList.getItems().length == 0))) {
|
|
|
+ cfs.hideDragList();
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ cfs.showDragList();
|
|
|
+ }
|
|
|
+ event.stopPropagation();
|
|
|
+ return false;
|
|
|
+ });
|
|
|
+ };
|
|
|
+ this.switchImg = function () {
|
|
|
+ var cfs = itemEle.confs;
|
|
|
+ if (!cfs.drager.group || (cfs.dragList && cfs.dragList.getItems() == 0)) { //不是分组,也没有子内容
|
|
|
+ this.fileStyle();
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ if (cfs.isExpand) {
|
|
|
+ this.expandFolderStyle();
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ this.normalFolderStyle();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ };
|
|
|
+ this.toggleIcon = function (state) {
|
|
|
+ $(this.element).removeClass(iconClassName.join(" ")).addClass(iconClassName[state]);
|
|
|
+ $(this.element.textwrapper).removeClass(textWrapperClass.join(" ")).addClass(textWrapperClass[state]);
|
|
|
+ var cn = this.itemEle.confs;
|
|
|
+ if (state > 1) { //文件夹样式
|
|
|
+ cn.addClass("filelist");
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ cn.removeClass("filelist");
|
|
|
+ }
|
|
|
+ };
|
|
|
+ this.expandFolderStyle = function () {
|
|
|
+ this.toggleIcon(2);
|
|
|
+ };
|
|
|
+ this.normalFolderStyle = function () {
|
|
|
+ this.toggleIcon(3);
|
|
|
+ };
|
|
|
+ this.fileStyle = function () {
|
|
|
+ if (itemEle.confs.getDragList().isChild) {
|
|
|
+ this.toggleIcon(1);
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ this.toggleIcon(0);
|
|
|
+ }
|
|
|
+ };
|
|
|
+ itemEle.insertBefore(element, itemEle.childNodes[0]);
|
|
|
+ this.init();
|
|
|
+ return this;
|
|
|
+};
|
|
|
+window.ss.drag.Item = function (name, element) {
|
|
|
+ window.ss.drag.Base.call(this);
|
|
|
+ this.element = element.isConfs ? element.element : element;
|
|
|
+ this.element.confs = this;
|
|
|
+ this.isItem = true;
|
|
|
+ this.id = (this.element.getAttribute("ssObjId") || (itemid++) + "").split("#").join("").split(".").join(""); // ("wdObjectID")。是 wdObjectID,不是 wdObjectId。Lin
|
|
|
+ this.parentid = (this.element.getAttribute("ssPobjId") || "").split("#").join("").split(".").join(""); // ("wdParentObjectID")。是 wdParentObjectID,不是 wdParentObjectId。Lin
|
|
|
+ var drager = this.drager = DM.getInstance(name);
|
|
|
+ this.hasDragList = false;
|
|
|
+ this.createShadow = function () {
|
|
|
+ var clone = new window.ss.drag.Shadow(this.element);
|
|
|
+ this.element.parentNode.insertBefore(clone.element, this.element);
|
|
|
+ this.shadow = clone;
|
|
|
+ return clone;
|
|
|
+ };
|
|
|
+ this.isSelected = function () {
|
|
|
+ return this.hasClass(this.getTopDragList({}).wdSelectedClass);
|
|
|
+ };
|
|
|
+ this.getTopDragList = function (emptyObj) {
|
|
|
+ if (!this.exist())
|
|
|
+ console.log("!!!");
|
|
|
+ var list = this.getDragList();
|
|
|
+ if (list.isChild)
|
|
|
+ list = list.thisItem.getDragList();
|
|
|
+ return list;
|
|
|
+ };
|
|
|
+ this.select = function () {
|
|
|
+ if (!this.drager.editGroup && !this.drager.editOrder && this.drager.getLists().length < 2) { }
|
|
|
+ else {
|
|
|
+ this.isFunctionKeyDown = functionKeyDown || event.ctrlKey || event.altKey || event.shiftKey;
|
|
|
+ this.getDragList().selectedItems[this.id] = this;
|
|
|
+ this.addClass(this.getTopDragList({}).wdSelectedClass);
|
|
|
+ $(this.element).find(".icon-unchecked").addClass('icon-checked').removeClass('icon-unchecked');
|
|
|
+ }
|
|
|
+ };
|
|
|
+ this.unselect = function () {
|
|
|
+ this.isFunctionKeyDown = false;
|
|
|
+ delete this.getDragList().selectedItems[this.id];
|
|
|
+ this.removeClass(this.getTopDragList({}).wdSelectedClass);
|
|
|
+ $(this.element).find(".icon-checked").addClass('icon-unchecked').removeClass('icon-checked');
|
|
|
+ };
|
|
|
+ this.getParentItem = function () {
|
|
|
+ var list = this.getDragList();
|
|
|
+ if (list && list.isChild) {
|
|
|
+ return list.thisItem;
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ };
|
|
|
+ this.getDragList = function () {
|
|
|
+ return (this.element.parentNode || {}).confs;
|
|
|
+ };
|
|
|
+ this.hideDragList = function () {
|
|
|
+ this.isExpand = false;
|
|
|
+ if (this.getDragList() && !this.drager.group)
|
|
|
+ return;
|
|
|
+ if (this.getDragList().isChild && this.imgBtn) {
|
|
|
+ this.dragList.hide();
|
|
|
+ // this.dragList.element.style.height = "auto";
|
|
|
+ }
|
|
|
+ else if (!this.getDragList().isChild && this.imgBtn) {
|
|
|
+ this.dragList.hide();
|
|
|
+ // this.dragList.element.style.height = "auto";
|
|
|
+ }
|
|
|
+ if (this.imgBtn)
|
|
|
+ this.imgBtn.switchImg();
|
|
|
+ this.getDragList().focus();
|
|
|
+ };
|
|
|
+ this.showDragList = function () {
|
|
|
+ if (!this.drager.group)
|
|
|
+ return;
|
|
|
+ if (DM.dragingPanel && DM.dragingPanel.hasChild())
|
|
|
+ return;
|
|
|
+ if (this.getDragList().isChild /*|| !(this.getDragList()instanceof window.ss.drag.DragList)*/)
|
|
|
+ return;
|
|
|
+ if (this.imgBtn) {
|
|
|
+ this.isExpand = true;
|
|
|
+ if (this.dragList.getItems().length > 0) {
|
|
|
+ this.dragList.element.style.height = "auto";
|
|
|
+ }
|
|
|
+ else if (this.dragList.getSize().height == 0) {
|
|
|
+ this.dragList.element.style.minHeight = this.getSize().height + "px";
|
|
|
+ }
|
|
|
+ this.dragList.show();
|
|
|
+ this.dragList.focus();
|
|
|
+ this.imgBtn.switchImg();
|
|
|
+ }
|
|
|
+ };
|
|
|
+ this.getIndex = function () {
|
|
|
+ this.index = this.prevAll().length;
|
|
|
+ return this.index;
|
|
|
+ };
|
|
|
+ this.updateInfo = function () {
|
|
|
+ this.parentid = this.getDragList().thisItem == null ? null : this.getDragList().thisItem.id;
|
|
|
+ this.element.setAttribute("ssPobjId", this.parentid); // ("wdParentObjectID",。是 wdParentObjectID,不是 wdParentObjectId。Lin
|
|
|
+ this.index = this.prevAll().length;
|
|
|
+ if (!this.getDragList().isChild && this.dragList) {
|
|
|
+ this.dragList.isChild = true;
|
|
|
+ if (this.imgBtn) {
|
|
|
+ var len = this.dragList.children().length;
|
|
|
+ this.imgBtn.element.innerText = len > 0 ? len : "";
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else if (this.dragList) {
|
|
|
+ this.dragList.isChild = false;
|
|
|
+ }
|
|
|
+ if (this.dragList && this.dragList.getItems().length == 0) {
|
|
|
+ this.hideDragList();
|
|
|
+ }
|
|
|
+ if (this.imgBtn)
|
|
|
+ this.imgBtn.switchImg();
|
|
|
+ };
|
|
|
+ this.destroy = function () {
|
|
|
+ this.off("dblclick selectedClick click dragend mousedown mouseup mousemove mouseover mouseout mouseleave");
|
|
|
+ this.off("dblclick selectedClick click dragend mousedown mouseup mousemove mouseover mouseout mouseleave");
|
|
|
+ this.imgBtn && this.imgBtn.destroy();
|
|
|
+ this.hasDragList && this.dragList && (this.drager.functions.indexOf('group') > -1) && this.dragList.destroy();
|
|
|
+ this.element.confs = null;
|
|
|
+ };
|
|
|
+ this.init = function () {
|
|
|
+ var me = this;
|
|
|
+ this.isExpand = false;
|
|
|
+ if (this.drager.group) {
|
|
|
+ //初始化第二层,包住
|
|
|
+ var $div = $("<div>");
|
|
|
+ $div.attr("id", "wrapper_" + this.id);
|
|
|
+ $div.append($(this.element.childNodes));
|
|
|
+ $(this.element).append($div);
|
|
|
+ this.imgBtn = this.imgBtn || new window.ss.drag.ShowBtn(this.element);
|
|
|
+ this.imgBtn.element.textwrapper = $div[0];
|
|
|
+ this.dragList = new window.ss.drag.DragList(name, document.createElement("div"));
|
|
|
+ this.append(this.dragList.element);
|
|
|
+ this.dragList.thisItem = this;
|
|
|
+ this.dragList.addClass("subList");
|
|
|
+ this.dragList.hide();
|
|
|
+ this.imgBtn.initEvent();
|
|
|
+ this.hasDragList = true;
|
|
|
+ }
|
|
|
+ ;
|
|
|
+ var _checkbox = this.checkbox = document.createElement("span");
|
|
|
+ // _checkbox.innerHTML = "";
|
|
|
+ // _checkbox.className='dragcheckbox';
|
|
|
+ // _checkbox.style.width="15px";
|
|
|
+ // _checkbox.style.border='1px dashed black';
|
|
|
+ _checkbox.style.cssText = 'display: inline-block; width: 28px;height: 40px;float: left;';
|
|
|
+ _checkbox.className = "icon-unchecked";
|
|
|
+ _checkbox.onmousedown = _checkbox.onmouseup = function (e) {
|
|
|
+ e.stopPropagation();
|
|
|
+ };
|
|
|
+ _checkbox.onclick = function (e) {
|
|
|
+ if (!me.isSelected()) {
|
|
|
+ me.select();
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ me.unselect();
|
|
|
+ }
|
|
|
+ e.stopPropagation();
|
|
|
+ };
|
|
|
+ $(this.element).find("." + _checkbox.className).length < 1 && $(this.element).prepend(_checkbox);
|
|
|
+ this.element.styleinfo = this.getStyles();
|
|
|
+ // this.element.style.position = "relative";
|
|
|
+ this.addClass(this.getTopDragList({}).wdNormalClass);
|
|
|
+ var this_ = this;
|
|
|
+ this_.element.setAttribute("tp", this.element.offsetTop);
|
|
|
+ this.off("dblclick").on("dblclick", function () {
|
|
|
+ if (this.imgBtn) {
|
|
|
+ this.imgBtn.trigger("click");
|
|
|
+ }
|
|
|
+ if (this.drager.onDblClick) {
|
|
|
+ this.drager.onDblClick.call(this);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ this.off("selectedClick").on("selectedClick", function (event) {
|
|
|
+ this_.drager.selectedClick && this_.drager.selectedClick.call(this, this.element);
|
|
|
+ });
|
|
|
+ this.off("click").on("click", function (event) {
|
|
|
+ if (isEventTargetIsEditable(event)) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ this.triggerSelectedClick && this.trigger("selectedClick");
|
|
|
+ this_.drager.itemClick && this_.drager.itemClick.call(this, this.element);
|
|
|
+ });
|
|
|
+ this.off("dragend").on("dragend", function () {
|
|
|
+ this.hasDragList && this.getDragList() && !this.getDragList().isChild && this.dragList.trigger("dragend");
|
|
|
+ if (this.getDragList() && this.getDragList().isChild) {
|
|
|
+ this.hideDragList();
|
|
|
+ }
|
|
|
+ else if (this.isExpand) {
|
|
|
+ this.showDragList();
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ this.hideDragList();
|
|
|
+ }
|
|
|
+ if (this.getTopDragList({}).isSelectedList) {
|
|
|
+ this.each(this.find('[wdSelected="true"]'), function () {
|
|
|
+ this.style.display = "";
|
|
|
+ });
|
|
|
+ this.each(this.find('[wdOption="true"]'), function () {
|
|
|
+ this.display = this.style.display;
|
|
|
+ this.style.display = 'none';
|
|
|
+ });
|
|
|
+ }
|
|
|
+ else if (this.getTopDragList({}).isOptionList) {
|
|
|
+ this.each(this.find('[wdOption="true"]'), function () {
|
|
|
+ this.style.display = "";
|
|
|
+ });
|
|
|
+ this.each(this.find('[wdSelected="true"]'), function () {
|
|
|
+ this.display = this.style.display;
|
|
|
+ this.style.display = 'none';
|
|
|
+ });
|
|
|
+ }
|
|
|
+ this.addClass(this.getTopDragList({}).wdNormalClass);
|
|
|
+ this.updateInfo();
|
|
|
+ });
|
|
|
+ this.off("mousedown").on("mousedown", function (event) {
|
|
|
+ if (isEventTargetIsEditable(event)) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ $("[ssObjId] [editable][contenteditable]").blur().removeAttr("contenteditable"); // ("[wdObjectId] [。Lin
|
|
|
+ DM.justEnd = false;
|
|
|
+ this.cx = event.clientX;
|
|
|
+ this.cy = event.clientY;
|
|
|
+ this.getDragList().focus();
|
|
|
+ var selected = this.selected = this.isSelected();
|
|
|
+ this.isFunctionKeyDown = functionKeyDown || event.ctrlKey || event.altKey || event.shiftKey;
|
|
|
+ this.getDragList().currentMouseDownItem = this;
|
|
|
+ if (event.shiftKey) {
|
|
|
+ var s = this.getDragList().shiftSelectStartItem;
|
|
|
+ if (s) {
|
|
|
+ if (this.isChildOf(s.getDragList().element)) {
|
|
|
+ this.getDragList().shiftSelect();
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ this.getDragList().currentMouseDownItem = null;
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ this.getDragList().shiftSelectStartItem = null;
|
|
|
+ }
|
|
|
+ this.select();
|
|
|
+ if (selected) { //第二次或以上选中
|
|
|
+ this.triggerSelectedClick = true;
|
|
|
+ }
|
|
|
+ else { //第一次选中
|
|
|
+ this.triggerSelectedClick = false;
|
|
|
+ }
|
|
|
+ this.getDragList().focus();
|
|
|
+ var dragItemDown = true;
|
|
|
+ if (this.drager.list != null) {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ var dragStartPoint = {
|
|
|
+ x: event.clientX,
|
|
|
+ y: event.clientY
|
|
|
+ };
|
|
|
+ event.stopPropagation();
|
|
|
+ docMouseDown(event);
|
|
|
+ return false;
|
|
|
+ });
|
|
|
+ this.off("mouseup").on("mouseup", function (event) {
|
|
|
+ docMouseUp(event);
|
|
|
+ var isSelected = this.isSelected();
|
|
|
+ this.getDragList().shiftSelectStartItem = this.getDragList().shiftSelectStartItem || this;
|
|
|
+ this.getDragList().currentMouseDownItem = null;
|
|
|
+ if (!(event.ctrlKey || event.shiftKey)) {
|
|
|
+ this.getDragList().clearSelect();
|
|
|
+ this.select();
|
|
|
+ }
|
|
|
+ this.selected && event.ctrlKey && this.unselect();
|
|
|
+ event.stopPropagation();
|
|
|
+ return false;
|
|
|
+ });
|
|
|
+ this.off("mouseleave").on("mouseleave", function (event) {
|
|
|
+ if (isEventTargetIsEditable(event)) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ this.addClass(this.getTopDragList({}).wdNormalClass);
|
|
|
+ this.removeClass(this.getTopDragList({}).wdHoverClass);
|
|
|
+ // this.element.style.border = "";
|
|
|
+ if (this.intervalid) {
|
|
|
+ clearInterval(this.intervalid);
|
|
|
+ this.intervalid = null;
|
|
|
+ }
|
|
|
+ if (this.timeoutid) {
|
|
|
+ clearTimeout(this.timeoutid);
|
|
|
+ this.timeoutid = null;
|
|
|
+ }
|
|
|
+ clearMouseIcon();
|
|
|
+ this.isEnter = false;
|
|
|
+ // this.element.style.border = "";
|
|
|
+ });
|
|
|
+ this.off("mouseover").on("mouseover", function () {
|
|
|
+ this.addClass(this.getTopDragList({}).wdHoverClass);
|
|
|
+ itemMouseEvent.call(this, event);
|
|
|
+ this.isEnter = true;
|
|
|
+ return false;
|
|
|
+ });
|
|
|
+ // this.off("mousemove").on("mousemove", function () {
|
|
|
+ // !this.isEnter && itemMouseEvent.call(this, event);
|
|
|
+ // });
|
|
|
+ this.element.setAttribute("ssObjId", this.id); // ("wdObjectID",。是 wdObjectID,不是 wdObjectId。Lin
|
|
|
+ this.element.setAttribute("ssPobjId", this.parentid); // ("wdParentObjectID",。是 wdParentObjectID,不是 wdParentObjectId。Lin
|
|
|
+ this.drager.functions && this.drager.group && this.dragList && this.dragList.init();
|
|
|
+ var $editable = $(this.element).find("[editable]");
|
|
|
+ $editable.click(function (event) {
|
|
|
+ if (isContenteditable(this)) {
|
|
|
+ event.stopPropagation();
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ else if (this_.triggerSelectedClick) {
|
|
|
+ if ($(event.target).is("[editable]")) {
|
|
|
+ $(event.target).attr("contenteditable", "true");
|
|
|
+ event.target.focus();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+ var keyAction = function (event) {
|
|
|
+ var e = event || window.event;
|
|
|
+ var keycode = e.charCode || e.keyCode;
|
|
|
+ if (keycode == 13) {
|
|
|
+ if (window.event) {
|
|
|
+ window.event.returnValue = false;
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ e.preventDefault(); //for firefox
|
|
|
+ }
|
|
|
+ e.stopPropagation();
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ else if (isContenteditable(this)) {
|
|
|
+ this.realContent = this.innerHtml;
|
|
|
+ try {
|
|
|
+ this_.drager.onItemInput && this_.drager.onItemInput.apply(this, [event, this_]);
|
|
|
+ }
|
|
|
+ catch (e) {
|
|
|
+ console.error(e);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ };
|
|
|
+ $editable.keyup(keyAction);
|
|
|
+ // $editable.keydown(keyAction);
|
|
|
+ $editable.each(function () {
|
|
|
+ this.commonHeight = $(this).height();
|
|
|
+ });
|
|
|
+ $editable.blur(function () {
|
|
|
+ this.realContent = this.innerHTML;
|
|
|
+ this.setAttribute("title", this.realContent);
|
|
|
+ console.log(this.realContent);
|
|
|
+ var content = ss.display.ellipsisContent(this, this.commonHeight);
|
|
|
+ this.innerHTML = content;
|
|
|
+ console.log("blur");
|
|
|
+ });
|
|
|
+ $editable.focus(function () {
|
|
|
+ if (!isContenteditable(this)) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ console.log(this.realContent);
|
|
|
+ var content = this.realContent;
|
|
|
+ if (content) {
|
|
|
+ this.innerHTML = content;
|
|
|
+ console.log(content);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ };
|
|
|
+};
|
|
|
+window.ss.drag.Form = function (element) {
|
|
|
+ window.ss.drag.Base.call(this);
|
|
|
+ this.element = element;
|
|
|
+ this.parseForm2Url = function () {
|
|
|
+ var form = this.element;
|
|
|
+ var arr = [];
|
|
|
+ var action_ = form.getAttribute("action");
|
|
|
+ var param = (action_ || "?").split("?");
|
|
|
+ arr = arr.concat((param[1] || "").split("&"));
|
|
|
+ var elements = form.querySelectorAll("input,select,textarea");
|
|
|
+ for (var i = 0; i < elements; i++) {
|
|
|
+ var feled = elements[i];
|
|
|
+ switch (feled.type) {
|
|
|
+ case undefined:
|
|
|
+ case 'button':
|
|
|
+ case 'file':
|
|
|
+ case 'reset':
|
|
|
+ case 'submit':
|
|
|
+ break;
|
|
|
+ case 'checkbox':
|
|
|
+ case 'radio':
|
|
|
+ if (!feled.checked) {
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ default:
|
|
|
+ if (feled.value != null && feled.value != '' && feled.name != null && !feled.disabled) {
|
|
|
+ arr.push(feled.name + "=" + feled.value);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return param[0] + "?" + arr.join("&");
|
|
|
+ };
|
|
|
+ this.parseFormData = function () {
|
|
|
+ var form = this.element;
|
|
|
+ var params = {};
|
|
|
+ var elements = form.querySelectorAll("input,select,textarea");
|
|
|
+ for (var i = 0; i < elements.length; i++) {
|
|
|
+ var feled = elements[i];
|
|
|
+ console.log(feled.name, feled.value);
|
|
|
+ switch (feled.type) {
|
|
|
+ case undefined:
|
|
|
+ case 'button':
|
|
|
+ case 'file':
|
|
|
+ case 'reset':
|
|
|
+ case 'submit':
|
|
|
+ break;
|
|
|
+ case 'checkbox':
|
|
|
+ case 'radio':
|
|
|
+ if (!feled.checked) {
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ default:
|
|
|
+ feled.value != null && feled.value != '' && feled.name != null && !feled.disabled && (params[feled.name] = feled.value);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ console.log(params);
|
|
|
+ return params;
|
|
|
+ };
|
|
|
+ this.submit = function () {
|
|
|
+ var data = this.parseFormData(), url = this.element.getAttribute("action"), this_ = this, meWin = window, drager = this_.drager;
|
|
|
+ ss.c.wdAjax({
|
|
|
+ url: url,
|
|
|
+ type: "post",
|
|
|
+ data: data,
|
|
|
+ async: false,
|
|
|
+ success: function (data) {
|
|
|
+ /// 增加,把 <、> 转为 <、> -- 解决 .querySelectorAll() 取不到 Dom 的问题。Lin
|
|
|
+ /* 再去掉,<、> 已经在上层转为 <、> 了 -- 再转,就成了 "\n\n\n\n学员文件人员班级部门初始岗位单位生产任务初始部门初始人员项目岗位来访校区专业\n\n\n"。Lin
|
|
|
+ var temp = document.createElement("div");
|
|
|
+ temp.innerHTML = data;
|
|
|
+ var output = temp.innerText;
|
|
|
+ temp = null;
|
|
|
+ */
|
|
|
+ ///
|
|
|
+ var resultdiv = document.createElement("div");
|
|
|
+ resultdiv.style.display = "none";
|
|
|
+ resultdiv.id = new Date().getTime().toString();
|
|
|
+ /* 再改回,去掉 output 了 -- 见上面。Lin
|
|
|
+ resultdiv.innerHTML = output; // = data。Lin
|
|
|
+ */ resultdiv.innerHTML = data;
|
|
|
+ var doms = resultdiv.querySelectorAll(drager.itemSelector);
|
|
|
+ drager.optionList.empty();
|
|
|
+ $.each(doms, function () {
|
|
|
+ drager.optionList.append(this);
|
|
|
+ });
|
|
|
+ var scripts = resultdiv.querySelectorAll("script");
|
|
|
+ for (var i = 0; i < scripts.length; i++) {
|
|
|
+ var s = scripts[i];
|
|
|
+ if (s.innerHTML != null /*&& s.innerHTML.indexOf(tokenCleanser) > -1*/) {
|
|
|
+ try {
|
|
|
+ meWin.eval(s.innerHTML);
|
|
|
+ }
|
|
|
+ catch (e) {
|
|
|
+ console.error(e);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ //$(s).remove();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ drager.optionList.reload();
|
|
|
+ }
|
|
|
+ });
|
|
|
+ };
|
|
|
+ this.init = function () {
|
|
|
+ console.log(this.element.tagName);
|
|
|
+ this.element.tagName.toLowerCase() == "form" && (this.element.tagName = "div");
|
|
|
+ var this_ = this, btn = this.element.querySelector("input[type='submit']");
|
|
|
+ this.on("submit onsubmit", function () {
|
|
|
+ this.submit();
|
|
|
+ });
|
|
|
+ this.element.submit = function () {
|
|
|
+ this_.submit();
|
|
|
+ };
|
|
|
+ if (btn != null) {
|
|
|
+ this.submitBtn = new window.ss.drag.Base(btn);
|
|
|
+ this.submitBtn.on("click", function (event) {
|
|
|
+ this_.trigger("submit");
|
|
|
+ event.stopPropagation();
|
|
|
+ event.preventDefault();
|
|
|
+ return false;
|
|
|
+ });
|
|
|
+ }
|
|
|
+ };
|
|
|
+ this.init();
|
|
|
+};
|
|
|
+window.ss.drag.Ghost = function (element) {
|
|
|
+ window.ss.drag.Base.call(this);
|
|
|
+ this.drager = element.confs.drager;
|
|
|
+ this.isGhost = true;
|
|
|
+ var sizeInfo = this.sizeInfo = element.confs.getSize();
|
|
|
+ var ele = this.element = document.createElement(element.tagName);
|
|
|
+ ele.className = element.className;
|
|
|
+ ele.confs = this;
|
|
|
+ ele.setAttribute("class", "" /*"hLine-warning"*/);
|
|
|
+ ele.style.cssText = "";
|
|
|
+ ele.innerHTML = "";
|
|
|
+ ele.id = "ghost";
|
|
|
+ this.dashMode = function () {
|
|
|
+ // ele.style.width = sizeInfo.width + "px";
|
|
|
+ // ele.style.height = sizeInfo.height + "px";
|
|
|
+ // ele.style.border = "1px dashed red";
|
|
|
+ // ele.style.borderRadius = "5px";
|
|
|
+ // ele.style.background = "white";
|
|
|
+ };
|
|
|
+ this.getDragList = function () {
|
|
|
+ return (this.element.parentNode || {}).confs;
|
|
|
+ };
|
|
|
+ this.getTopDragList = function () {
|
|
|
+ var list = this.getDragList();
|
|
|
+ if (list.isChild)
|
|
|
+ list = list.thisItem.getDragList();
|
|
|
+ return list;
|
|
|
+ };
|
|
|
+ this.lineMode = function () {
|
|
|
+ // ele.style.borderRadius = "0";
|
|
|
+ // ele.style.margin = 0;
|
|
|
+ // ele.style.background = "padding-box red";
|
|
|
+ // ele.style.borderStyle = "solid";
|
|
|
+ // ele.style.borderWidth = "2px";
|
|
|
+ // ele.style.padding = '0';
|
|
|
+ // if (this.getDragList() && this.getTopDragList({}).alignMode == 'vertical') {
|
|
|
+ // ele.style.width = "2px";
|
|
|
+ // ele.style.height = sizeInfo.height + "px";
|
|
|
+ // ele.style.minWidth = "0px";
|
|
|
+ // ele.style.borderColor = "red transparent";
|
|
|
+ // } else {
|
|
|
+ // ele.style.width = "auto";
|
|
|
+ // ele.style.height = "2px";
|
|
|
+ // ele.style.minHeight = "0px";
|
|
|
+ // ele.style.borderColor = "transparent red";
|
|
|
+ // }
|
|
|
+ };
|
|
|
+ this.destroy = function () {
|
|
|
+ this.interval && clearInterval(this.interval);
|
|
|
+ this.remove();
|
|
|
+ };
|
|
|
+ this.init = function () {
|
|
|
+ var this_ = this;
|
|
|
+ this.interval = setInterval(function () {
|
|
|
+ var allow = true;
|
|
|
+ if (DM.dragingPanel == null)
|
|
|
+ clearInterval(this_.interval);
|
|
|
+ if (DM.dragingPanel.isAllowDrop == false) {
|
|
|
+ allow = false;
|
|
|
+ }
|
|
|
+ else if (this_.drager != this_.getDragList().drager) {
|
|
|
+ allow = false;
|
|
|
+ }
|
|
|
+ else if (this_.drager.editGroup) { //最多功能的
|
|
|
+ allow = true;
|
|
|
+ }
|
|
|
+ else if (this_.drager.editOrder) { //只能同级拖拽
|
|
|
+ }
|
|
|
+ else { //不能上下拖拽
|
|
|
+ }
|
|
|
+ allow && DM.dragingPanel.allowDrop();
|
|
|
+ !allow && DM.dragingPanel.notAllowDrop();
|
|
|
+ }, 5);
|
|
|
+ this.hide();
|
|
|
+ };
|
|
|
+ this.init();
|
|
|
+ this.lineMode();
|
|
|
+};
|
|
|
+function itemMouseEvent(event) {
|
|
|
+ var panel = DM.dragingPanel;
|
|
|
+ if (panel != null) {
|
|
|
+ var item = this;
|
|
|
+ var location = item.isMouseOver(event);
|
|
|
+ var dragList = item.getDragList();
|
|
|
+ var ghost = panel.ghost;
|
|
|
+ if (item.drager.editOrder || item.drager.editGroup) {
|
|
|
+ ghost.addClass("ghost");
|
|
|
+ if (location && item.getTopDragList({}).alignMode != "horizontal") { //如果不是水平分布,就上下拖动排序
|
|
|
+ ghost.removeClass("vLine-warning").addClass("hLine-warning");
|
|
|
+ switch (location) {
|
|
|
+ case 3: //左上
|
|
|
+ case 6: //右上
|
|
|
+ item.before(ghost);
|
|
|
+ break;
|
|
|
+ case 4:
|
|
|
+ case 8:
|
|
|
+ item.after(ghost);
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else if (location) { //不然就左右分布
|
|
|
+ ghost.removeClass("hLine-warning").addClass("vLine-warning");
|
|
|
+ switch (location) {
|
|
|
+ case 3: //左上
|
|
|
+ case 4: //左下
|
|
|
+ item.before(ghost);
|
|
|
+ break;
|
|
|
+ case 6: //右上
|
|
|
+ case 8: //右下
|
|
|
+ item.after(ghost);
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (!item.drager.editGroup) { //只能同级拖拽
|
|
|
+ var allow = true;
|
|
|
+ item.each(panel.shadows, function () {
|
|
|
+ var shadow = this;
|
|
|
+ if ((shadow.getDragList() != ghost.getDragList() && shadow.getTopDragList({}) == ghost.getTopDragList({})) //同列表不同级
|
|
|
+ ||
|
|
|
+ (shadow.getDragList().isChild && shadow.getTopDragList({}) != ghost.getTopDragList({})) //不同列表不同级
|
|
|
+ ) {
|
|
|
+ allow = false;
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ });
|
|
|
+ if (item.isShadow || item.isGhost) { }
|
|
|
+ else if (item.isExpand) { //展开了的
|
|
|
+ if (!allow) { }
|
|
|
+ else if (item.dragList.isMouseOver(event) && panel.hasChild()) {
|
|
|
+ allow = false;
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ allow = true;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ //没展开但是不是editgroup不作处理
|
|
|
+ }
|
|
|
+ allow && DM.dragingPanel.allowDrop();
|
|
|
+ !allow && DM.dragingPanel.notAllowDrop();
|
|
|
+ }
|
|
|
+ else { // editGroup的情况
|
|
|
+ if (item.isShadow || item.isGhost) { }
|
|
|
+ else if (!item.isExpand) { //没展开的
|
|
|
+ !item.getDragList().isChild && !panel.hasChild();
|
|
|
+ if (item.timeoutid == null) {
|
|
|
+ var delay = 1000;
|
|
|
+ if (item.intervalid == null)
|
|
|
+ item.intervalid = setInterval(function () {
|
|
|
+ item.ri = item.ri || 0;
|
|
|
+ item.addClass("cursor-timing" + ((item.ri++) % readyMouseIcoLen + 1));
|
|
|
+ }, delay / readyMouseIcoLen);
|
|
|
+ var id = setTimeout(function () {
|
|
|
+ item.drager.editGroup && item.showDragList && !item.getDragList().isChild && item.showDragList() && item.hasDragList && item.dragList.append(ghost);
|
|
|
+ clearInterval(item.intervalid);
|
|
|
+ item.timeoutid = null;
|
|
|
+ item.intervalid = null;
|
|
|
+ clearMouseIcon();
|
|
|
+ }, delay);
|
|
|
+ item.timeoutid = id;
|
|
|
+ }
|
|
|
+ panel.allowDrop();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else { //既不是editorder也不是editgroup
|
|
|
+ var allow = true;
|
|
|
+ ghost.each(panel.shadows, function () {
|
|
|
+ var shadow = this;
|
|
|
+ if (ghost.getTopDragList() == shadow.getTopDragList()) {
|
|
|
+ allow = false;
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ });
|
|
|
+ allow && DM.dragingPanel.allowDrop();
|
|
|
+ !allow && DM.dragingPanel.notAllowDrop();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return false;
|
|
|
+}
|
|
|
+;
|
|
|
+//绑定document的事件
|
|
|
+var DM = window.DM = window.ss.drag.DM = DM || new window.ss.drag.DragerManager();
|
|
|
+setDrag = function (name, group, functions, options, _window) {
|
|
|
+ return DM.getInstance(name, group, functions, options, _window);
|
|
|
+};
|
|
|
+//# sourceMappingURL=wdDrag.js.map
|