| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165 |
- var wd = wd || {};
- wd.drag = wd.drag || {};
- var ismousedown = 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 wd.drag.DragPanel();
- document.body.appendChild(panel.element);
- }
- return;
- }
- }
- function docMouseUp(event) {
- ismousedown = false;
- currentMouseDownItem = null;
- DM.dragingPanel != null && DM.dragingPanel.destroy();
- clearMouseIcon();
- }
- wd.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 () {
- window.getSelection().removeAllRanges();
- }
- :
- function () {
- document.selection.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;
- });
- };
- wd.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;
- //获取查询表单
- /* 再改,"ddpSelectedId" 改为 "ddpSelId" -- 规范 ddp 命名。Lin
- var form = document.getElementsByName(name + "OptionForm")[0] || document.getElementById(name + "OptionForm");
- */ const form = document.getElementsByName(name + "OptForm")[0] || document.getElementById(name + "OptForm")
- || document.getElementsByName(name + "OptionForm")[0] || document.getElementById(name + "OptionForm");
- if (form) {
- this_.form = new wd.drag.Form(form);
- this_.form.drager = this;
- }
- var selectedList = document.getElementById(name +"Sel") || document.getElementById(name + "Selected"); // 兼容旧页面 id。
- if (selectedList) {
- var list = new wd.drag.DragList(name, selectedList);
- list.isSelectedList = true;
- /* 再改,"ddpSelectedId" 改为 "ddpSelId" -- 规范 ddp 命名。Lin
- 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";
- */
- let input = document.getElementsByName(name + "SelId")[0]
- || document.getElementsByName(name + "SelectedId")[0];
- input = input || document.createElement("input");
- input.type = "hidden";
- input.name = name +"SelId";
- 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 + "Opt") || document.getElementById(name + "Option"); // 兼容旧页面 id。
- if (optionList) {
- var list = new wd.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 () {
- /* 再去掉,只支持一种写法 -- 不需要在页面写 <script>var isWriteOut=true;</script> 了。Lin
- if (typeof (isWriteOut) == "undefined") {
- alert("注意下,这是旧的写法,以后不再自动初始化拖拽了,\n记得新的拖拽需要通过commonwrite输出^_^");
- return;
- }
- */
- var drager = DM.instances[name] = new this_.drager(name, group, functions, baseOptions);
- drager.init();
- return drager
- }
- (name, group, functions, baseOptions);
- }
- };
- wd.drag.Shadow = function (element) {
- wd.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;
- }
- };
- wd.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 () { /* 摘自jquery */
- 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 wd.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 wd.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 wd.drag.Base(ele));
- };
- this.prevAll = function (selector) {
- selector = selector || "*"
- var pe = this.element.parentNode;
- // var cs = pe.children;
- var cs = new wd.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 wd.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("注意,该节点不在文档里面,无法获取元素相关信息");
- 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 = {},
- 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"];
- wd.drag.DragPanel = function () {
- wd.drag.Base.call(this);
- var dragList = DM.currentDrager.focusedList;
- var ghost = this.ghost = new wd.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 wd.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).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;
- };
- wd.drag.DragList = function (name, element) {
- wd.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 wd.drag.Item && this.select();
- });
- this.each(this.currentMouseDownItem.nextAll(this.drager.itemSelector), function () {
- if (this instanceof wd.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 wd.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 wd.drag.Base(this).is(this_.drager.itemSelector)) {
- var item = this.isItem ? this : new wd.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 () { // ("[wdObjectID]"),。是 wdObjectID,不是 wdObjectId。Lin
- 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();
- };
- };
- /* 改,改用 .list-color -- 原 .list 增加了来自列表行外层的 <div style=。Lin
- var textWrapperClass = ["list", "list", "list-highlight", "list-highlight"];
- */
- /* 再去掉,去掉列表行的文字样式区分 -- 图标区分了。Lin
- var textWrapperClass = ["list-color", "list-color", "list-highlight", "list-highlight"];
- */
- var iconClassName = ["icon-doc", "icon-point", "icon-openFolder", "icon-folder"];
- wd.drag.ShowBtn = function (itemelement) {
- wd.drag.Base.call(this);
- var element = this.element = $("<span> </span>")[0];
- element.confs = this;
- // element.style.cursor = 'pointer';
- var itemEle = this.itemEle = itemelement;
- 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]);
- /* 再去掉,去掉列表行的文字样式区分 -- 图标区分了。Lin
- $(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;
- };
- wd.drag.Item = function (name, element) {
- wd.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 wd.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 wd.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;
- if (this.parentid) // 增加,不输出 ssPobjId="null"。Lin
- 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 wd.drag.ShowBtn(this.element);
- this.imgBtn.element.textwrapper = $div[0];
- this.dragList = new wd.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';
- /* 再改,把 style= 移到新加的 .list .icon { -- 不在 js 里写样式属性。Lin
- _checkbox.style.cssText = 'display: inline-block; width: 28px;height: 40px;float: left;';
- _checkbox.className = "icon-unchecked";
- */ _checkbox.className = "icon icon-unchecked";
- _checkbox.onmousedown = _checkbox.onmouseup = function (e) {
- e.stopPropagation();
- }
- _checkbox.onclick = function (e) {
- if (!me.isSelected()) {
- me.select();
- } else {
- me.unselect();
- }
- e.stopPropagation();
- }
- /* 再改,增加 .icon 了 -- 把 style= 移到新加的 .list .icon { -- 不在 js 里写样式属性。Lin
- * 同时拥有 icon 和 icon-unchecked 两个 class 的同一个元素,要写为 .find(".icon.icon-unchecked") -- 中间无空格
- * 原来只有一个样式,这样写 .find("." + _checkbox.className) 没问题
- * 两个样式,就变为 .find(".icon icon-unchecked") 了
- $(this.element).find("." + _checkbox.className).length < 1 && $(this.element).prepend(_checkbox);
- */ $(this.element).find(".icon.icon-unchecked").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 || this.isFunctionKeyDown;
- 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();
- dragItemDown = true;
- if (this.drager.list != null) {
- return false;
- }
- dragStartPoint = {
- x: event.clientX,
- y: event.clientY
- };
- event.stopPropagation();
- docMouseDown();
- return false;
- });
- this.off("mouseup").on("mouseup", function (event) {
- docMouseUp();
- 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
- if (this.parentid) // 增加,不输出 ssPobjId="null"。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 = wd.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)
- }
- })
- }
- };
- wd.drag.Form = function (element) {
- wd.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
- wd.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();
- /* 再改回,去掉 output 了 -- 见上面。Lin
- resultdiv.innerHTML = output; // = data。Lin
- */ resultdiv.innerHTML = data;
- 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();
- }
- });
- };
- //? 再增加,增加支持直接调用新加的 wdDrag.js > wrDdpOptList( -- 不写 <form name="ddpOptionForm" action=,不绕圈!Lin
- /*? 移到顶层。Lin
- this.wrDdpOptList = function (optList) {
- console.log("wrDdpOptList:"+ optList);
- };
- ?*/
- 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 wd.drag.Base(btn);
- this.submitBtn.on("click", function (event) {
- this_.trigger("submit");
- event.stopPropagation();
- event.preventDefault();
- return false;
- });
- }
- };
- this.init();
- };
- wd.drag.Ghost = function (element) {
- wd.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) {
- delay = 1000;
- if (item.intervalid == null)
- item.intervalid = setInterval(function () { //切换鼠标,达到gif效果
- 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 = wd.drag.DM = DM || new wd.drag.DragerManager();
- setDrag = function (name, group, functions, options, _window) {
- return DM.getInstance(name, group, functions, options, _window);
- };
- // 再增加,增加支持直接调用新加的 wdDrag.js > wrDdpOptList( -- 不写 <form name="ddpOptionForm" action=,不绕圈!Lin
- /* 再去掉,new wd.drag.Form() 会抛出错误 -- Cannot read properties of undefined (reading 'tagName')。Lin
- * wd.drag.Form = function (element) { > this.init = function () { 里,this.element.tagName 时,this.element 没有值
- var Form = window.Form = wd.drag.Form = Form || new wd.drag.Form();
- wrDdpOptList = function (optList) {
- return Form.wrDdpOptList(optList);
- };
- */
- // 再增加,增加支持直接提交纯备选记录到这,不绕圈 <form -- 不写 <form name="ddpOptionForm" action=。Lin
- // 抄自 wd.drag.Form = function (element) { > this.submit = function () { > success: function (data) { 里的
- wrDdpOptList = function (optList) {
- // console.log("wrDdpOptList:"+ optList);
- /* 重写,改为纯备选记录 optList 了。Lin
- var resultdiv = document.createElement("div");
- resultdiv.style.display = "none";
- resultdiv.id = new Date().getTime();
- resultdiv.innerHTML = data;
- 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) {
- try {
- meWin.eval(s.innerHTML);
- } catch (e) {
- console.error(e)
- }
- } else {
- //$(s).remove();
- }
- }
- drager.optionList.reload();
- */
- const optionList = DM.getDrager().optionList;
- optionList.empty();
- optList.forEach(function (opt) {
- const optDiv = document.createElement("div");
- optDiv.setAttribute("ssObjId", opt.ddpid);
- /* 改,去掉 .list-background,.list 改为 .ddp-list -- 再,不改名了 -- 老的 .list 还有好多样式。老 UI,将就。Lin
- * .list-background 老 UI 没有定义,也没有作用
- * 把原来的 <div style= 合并到原来的 .list 里
- optDiv.classList.add("list-background list");
- optDiv.style.cssText = "min-height: 41px;line-height: 41px;width: calc(100% - 4px);box-sizing: border-box;overflow: hidden;text-overflow: ellipsis;white-space: nowrap;";
- */ optDiv.classList.add("list");
- const optSpan = document.createElement("span");
- optSpan.textContent = opt.ddpdesc;
- optDiv.appendChild(optSpan);
- optionList.append(optDiv);
- });
- optionList.reload();
- };
- // 再增加,增加支持直接提交纯已选记录到这 -- 抄自 wrDdpOptList(optList)。Lin
- // 去掉页面里写的
- // <div ssObjId="${item.ddpid}" class="list-background list" style="min-height: 41px;line-height: 41px;width: calc(100% - 4px);box-sizing: border-box;overflow: hidden;text-overflow: ellipsis;white-space: nowrap;">
- // <span><ss:txt val='${item.ddpdesc}'/></span>
- // </div>
- // .list-background 老 UI 没有定义,也没有作用
- // 把原来的 <div style= 合并到原来的 .list 里
- wrDdpSelList = function (selList) {
- const selectedList = DM.getDrager().selectedList;
- selectedList.empty();
- selList.forEach(function (opt) {
- const optDiv = document.createElement("div");
- optDiv.setAttribute("ssObjId", opt.ddpid);
- optDiv.classList.add("list");
- const optSpan = document.createElement("span");
- optSpan.textContent = opt.ddpdesc;
- optDiv.appendChild(optSpan);
- selectedList.append(optDiv);
- });
- selectedList.reload();
- };
|