artDialogUtil.js 60 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852
  1. function FindParam(url111, name) {
  2. var url = url111; //获取url中"?"符后的字串
  3. var theRequest = new Object();
  4. if (url.indexOf("?") != -1) {
  5. var str = url.substr(url.indexOf("?") + 1);
  6. strs = str.split("&");
  7. for (var i = 0; i < strs.length; i++) {
  8. theRequest[strs[i].split("=")[0]] = unescape(strs[i].split("=")[1]);
  9. }
  10. }
  11. return theRequest[name];
  12. }
  13. /**
  14. * 跟随元素显示 follow_id:跟随元素id, title:弹出层标题,可空, htmlContent:显示的HTML片段
  15. */
  16. function followAlertHtml(follow_id, title, htmlContent) {
  17. if (!follow_id) {} else {
  18. if (!htmlContent) {
  19. return;
  20. }
  21. var dialog = null;
  22. if (title == null || title == "") {
  23. title = false;
  24. }
  25. $('#' + follow_id).hover(function() {
  26. dialog = artDialog({
  27. // id : 'follow',
  28. title: title,
  29. fixed: false,
  30. // cancel: true,
  31. // cancelVal:"关闭",
  32. lock: false,
  33. padding: '0',
  34. content: htmlContent,
  35. follow: document.getElementById(follow_id),
  36. });
  37. dialog.flag = false;
  38. /**
  39. * for(var i in dialog){ console.log(i); }
  40. */
  41. }, function() {
  42. closeFollowDialog(dialog);
  43. });
  44. }
  45. }
  46. /**
  47. * 跟随元素显示 follow_dom:跟随dom元素, title:弹出层标题,可空, htmlContent:显示的HTML片段
  48. */
  49. function followAlertHtmlByDom(follow_dom, title, htmlContent) {
  50. if (!follow_dom) {} else {
  51. if (!htmlContent) {
  52. return;
  53. }
  54. var dialog = null;
  55. if (title == null || title == "") {
  56. title = false;
  57. }
  58. $(follow_dom).hover(function() {
  59. dialog = artDialog({
  60. // id : 'follow',
  61. title: title,
  62. fixed: false,
  63. // cancel: true,
  64. // cancelVal:"关闭",
  65. lock: false,
  66. padding: '0',
  67. content: htmlContent,
  68. follow: follow_dom
  69. });
  70. dialog.flag = false;
  71. }, function() {
  72. closeFollowDialog(dialog);
  73. });
  74. }
  75. }
  76. function followAjaxAlterHtmlByDom(follow_dom, title, helpHaShCode) {
  77. if (!follow_dom) {} else {
  78. if (!helpHaShCode) {
  79. return;
  80. }
  81. var htmlContent = null;
  82. $
  83. .ajax({
  84. url: "/service?ssServ=queryHelpByHaHex",
  85. type: "POST",
  86. data: {
  87. helpHaHex: helpHaShCode
  88. },
  89. async: false,
  90. success: function(data) {
  91. htmlContent = '<html><head><title></title><meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\"></head><body>' +
  92. '代码:' +
  93. helpHaShCode +
  94. '<br>' +
  95. data +
  96. '</body></html>';
  97. }
  98. });
  99. var dialog = null;
  100. if (title == null || title == "") {
  101. title = false;
  102. }
  103. $(follow_dom).hover(function() {
  104. dialog = artDialog({
  105. // id : 'follow',
  106. title: title,
  107. fixed: false,
  108. // cancel: true,
  109. // cancelVal:"关闭",
  110. lock: false,
  111. padding: '0',
  112. content: htmlContent,
  113. follow: follow_dom
  114. });
  115. dialog.flag = false;
  116. }, function() {
  117. closeFollowDialog(dialog);
  118. });
  119. }
  120. }
  121. function followAlertHtml1(follow_id, title, htmlContent) {
  122. if (!follow_id) {} else {
  123. if (!htmlContent) {
  124. return;
  125. }
  126. var dialog = null;
  127. if (title == null || title == "") {
  128. title = false;
  129. }
  130. $('#' + follow_id).hover(function() {
  131. dialog = artDialog({
  132. // id : 'follow',
  133. title: title,
  134. fixed: false,
  135. // cancel: true,
  136. // cancelVal:"关闭",
  137. lock: false,
  138. padding: '0',
  139. content: htmlContent,
  140. follow: document.getElementById(follow_id)
  141. });
  142. dialog.flag = false;
  143. }, function() {
  144. closeFollowDialog(dialog);
  145. });
  146. }
  147. }
  148. /**
  149. * 跟随元素显示 follow_id:元素id, url:显示的url页面路径, title:弹出层标题,可空 param:传递参数
  150. * ,格式:name1=value1&name2=value2&name3=value3
  151. */
  152. function followAlertUrlByid(follow_id, title, url, param) {
  153. if (!follow_id) {} else {
  154. if (!url) {
  155. return;
  156. }
  157. var dialog = null;
  158. if (title == null || title == "") {
  159. title = false;
  160. }
  161. $('#' + follow_id).hover(function() {
  162. $.ajax({
  163. // async : false,
  164. url: url,
  165. data: param,
  166. success: function(data) {
  167. if (data != null && data != "") {
  168. dialog = art.dialog({
  169. // id : 'follow1',
  170. title: title,
  171. // cancel: true,
  172. // cancelVal:"关闭",
  173. fixed: false,
  174. lock: false,
  175. overflow: "auto",
  176. padding: '0',
  177. content: data,
  178. follow: document.getElementById(follow_id)
  179. });
  180. }
  181. },
  182. cache: false
  183. });
  184. }, function() {
  185. });
  186. }
  187. }
  188. /**
  189. * 跟随元素显示 follow_object:元素对象(jquery对象), url:显示的url页面路径, title:弹出层标题,可空
  190. * param:传递参数 ,格式:name1=value1&name2=value2&name3=value3
  191. */
  192. function followAlertUrlByObject(follow_object, title, url, param) {
  193. if (!follow_object) {} else {
  194. if (!url) {
  195. return;
  196. }
  197. var dialog = null;
  198. if (title == null || title == "") {
  199. title = false;
  200. }
  201. $(follow_object).hover(function() {
  202. $.ajax({
  203. // async : false,
  204. url: url,
  205. data: param,
  206. success: function(data) {
  207. if (data != null && data != "") {
  208. dialog = art.dialog({
  209. // id : 'follow_object',
  210. title: title,
  211. // cancel: true,
  212. // cancelVal:"关闭",
  213. fixed: true,
  214. lock: false,
  215. overflow: "auto",
  216. padding: '0',
  217. content: data,
  218. follow: follow_object.get(0)
  219. });
  220. }
  221. },
  222. cache: false
  223. });
  224. dialog.flag = false;
  225. }, function() {
  226. closeFollowDialog(dialog);
  227. });
  228. }
  229. }
  230. /**
  231. * 跟随元素显示 follow_dom:元素对象(dom对象), url:显示的url页面路径, title:弹出层标题,可空 param:传递参数
  232. * ,格式:name1=value1&name2=value2&name3=value3
  233. */
  234. function followAlertUrlByDom(follow_dom, title, url, param) {
  235. if (!follow_dom) {} else {
  236. if (!url) {
  237. return;
  238. }
  239. var dialog = null;
  240. if (title == null || title == "") {
  241. title = false;
  242. }
  243. $(follow_dom).hover(function() {
  244. $.ajax({
  245. // async : false,
  246. url: url,
  247. data: param,
  248. success: function(data) {
  249. if (data != null && data != "") {
  250. dialog = art.dialog({
  251. // id : 'follow_dom',
  252. title: title,
  253. // cancel: true,
  254. // cancelVal:"关闭",
  255. fixed: true,
  256. lock: false,
  257. overflow: "auto",
  258. padding: '0',
  259. content: data,
  260. follow: follow_dom
  261. });
  262. }
  263. },
  264. cache: false
  265. });
  266. dialog.flag = false;
  267. }, function() {
  268. closeFollowDialog(dialog);
  269. });
  270. }
  271. }
  272. function followAlertHelp(title, url, appName) {
  273. if (!url || appName == null || appName.trim() == "") {
  274. return;
  275. }
  276. $("[wdHelp]").each(
  277. function(i) {
  278. var follow_object = $(this);
  279. var helpCode = $(this).attr("wdHelp");
  280. if (follow_object != null && helpCode != null &&
  281. helpCode.trim() != "") {
  282. followAlertUrlByObject(follow_object, title, url,
  283. "helpCode=" + helpCode + "&appName=" + appName);
  284. }
  285. });
  286. }
  287. function onFollowAlertHelp(follow_dom, title, url, helpCode) {
  288. var param = "helpCode=" + helpCode;
  289. $.ajax({
  290. // async : false,
  291. url: url,
  292. data: param,
  293. success: function(data) {
  294. if (data != null && data != "") {
  295. var dialog = art.dialog({
  296. id: 'follow_dom',
  297. title: title,
  298. // cancel: true,
  299. // cancelVal:"关闭",
  300. fixed: true,
  301. lock: false,
  302. overflow: "auto",
  303. padding: '0',
  304. content: data,
  305. follow: follow_dom
  306. });
  307. if (dialog != null) {
  308. dialog.DOM.wrap.bind('mouseleave', function() {
  309. dialog.close();
  310. });
  311. }
  312. }
  313. },
  314. cache: false
  315. });
  316. }
  317. //右键显示(根据id)
  318. function onRightfollowAlertHtml(follow_id, title, htmlContent) {
  319. if (!follow_id) {} else {
  320. if (!htmlContent) {
  321. return;
  322. }
  323. var dialog = null;
  324. if (title == null || title == "") {
  325. title = false;
  326. }
  327. $('#' + follow_id).bind('contextmenu', function(e) {
  328. return false;
  329. });
  330. $('#' + follow_id).mousedown(function(e) {
  331. if (e.which == 3) { // 1 = 鼠标左键 left; 2 = 鼠标中键; 3 = 鼠标右键
  332. dialog = artDialog({
  333. //id : 'follow',
  334. title: title,
  335. fixed: false,
  336. // cancel: true,
  337. // cancelVal:"关闭",
  338. lock: false,
  339. padding: '0',
  340. content: htmlContent,
  341. follow: document.getElementById(follow_id),
  342. });
  343. dialog.flag = false;
  344. $('#' + follow_id).bind('mouseleave', function(e) {
  345. closeFollowDialog(dialog);
  346. $(this).unbind('mouseleave');
  347. });
  348. }
  349. });
  350. }
  351. }
  352. //右键显示(根据dom元素)
  353. function onRightfollowAjaxAlterHtmlByDom(name, title, helpsize, helpHaShCode,token) {
  354. try {
  355. // var selector = "[name=" + name + "]";
  356. // var follow_dom = document.querySelector(selector);
  357. // if (!follow_dom) return;
  358. // changeImage(selector);
  359. var data = { helpContent: document.querySelector("#helpcontent" + helpHaShCode).innerHTML, helpSize: helpsize ,token:token};
  360. data.title = title;
  361. data.name = name;
  362. data.helpHaShCode = helpHaShCode;
  363. //计算当前页面有效的帮助
  364. var count=0;
  365. //选项卡3级帮助
  366. if(token){
  367. /* 再改,规范 <li wdTabClick= 命名。Lin
  368. * 先改,是 wdtabclick,不是 wdTabClick
  369. var tabli=$("[wdtabclick]").filter(function(){return this.getAttribute("wdtabclick").indexOf(token)!=-1;})
  370. */ var tabli=$("[ssTabClick]").filter(function(){return this.getAttribute("ssTabClick").indexOf(token)!=-1;})
  371. if(tabli.length==1){
  372. initwdHelpElement(tabli[0], "rightclick", title, data, helpHaShCode, window);
  373. changeImage(tabli[0]);
  374. count++;
  375. }
  376. }else{
  377. var elements=[];
  378. var inputbox=wd.display.getInputBox(name);
  379. //4级帮助
  380. if(inputbox!=null){
  381. elements.push(inputbox.container);
  382. }else{
  383. $("[name=" + name + "]").each(function() {
  384. // initwdHelpElement(this, "rightclick", title, data, helpHaShCode, window);
  385. // changeImage(this);
  386. // count++;
  387. elements.push(this);
  388. })
  389. }
  390. for(var i=0;i<elements.length;i++){
  391. initwdHelpElement(elements[i], "rightclick", title, data, helpHaShCode, window);
  392. changeImage(elements[i]);
  393. count++;
  394. }
  395. }
  396. if(count>0){
  397. addHelpData(data, true);
  398. var wdDialogId = wd.display.getwdDialogId();
  399. showwdHelpButton(wdDialogId);
  400. }
  401. } catch (e) {
  402. console.log(e)
  403. }
  404. }
  405. function closeFollowDialog(dialog) {
  406. if (dialog != null) {
  407. dialog.DOM.wrap.bind('mouseover', function() {
  408. dialog.flag = true;
  409. });
  410. dialog.DOM.wrap.bind('mouseleave', function() {
  411. dialog.close();
  412. dialog.flag = false;
  413. });
  414. window.setTimeout(function() {
  415. if (!dialog.flag) {
  416. // console.log('flag:'+dialog.flag);
  417. dialog.close();
  418. }
  419. }, 10);
  420. }
  421. }
  422. function getClass(obj, attr) {
  423. if (obj.currentStyle) {
  424. if (attr == "backgroundPosition") {
  425. return obj.currentStyle.backgroundPositionX + " " +
  426. obj.currentStyle.backgroundPositionY;
  427. } else {
  428. return obj.currentStyle[attr];
  429. }
  430. } else {
  431. return document.defaultView.getComputedStyle(obj, null)[attr];
  432. }
  433. }
  434. function changeImage(dom) {
  435. // var domBgUrl = getClass(dom, "backgroundImage");
  436. // domBgUrl = domBgUrl.substring(4, domBgUrl.length - 1);
  437. // domBgUrl = domBgUrl.replace(/http:\/\/([^\s\/])+/, "");
  438. //
  439. // var imgPath = domBgUrl.substring(0, domBgUrl.lastIndexOf("?"));
  440. // if (domBgUrl.lastIndexOf("?") != -1) {
  441. // imgPath = imgPath.substring(0, imgPath.lastIndexOf("/") + 1);// 图片所在的文件位置
  442. // var changeImgStartIndex = domBgUrl.lastIndexOf("=") + 1;
  443. // var changeImg = domBgUrl.substring(parseInt(changeImgStartIndex),
  444. // parseInt(domBgUrl.length));
  445. // changeImg = imgPath + changeImg;
  446. // changeImg = changeImg.replace(/\"/g, "");
  447. // var imgUrl = "url(" + changeImg + ")";// 图片URL
  448. //
  449. // dom.style.backgroundImage = imgUrl;
  450. // }
  451. // dom.style.cursor = "url(data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAAAQABAAD/2wCEAAYEBQYFBAYGBQYHBwYIChAKCgkJChQODwwQFxQYGBcUFhYaHSUfGhsjHBYWICwgIyYnKSopGR8tMC0oMCUoKSgBBwcHCggKEwoKEygaFhooKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKP/AABEIABoAGgMBEQACEQEDEQH/xAGiAAABBQEBAQEBAQAAAAAAAAAAAQIDBAUGBwgJCgsQAAIBAwMCBAMFBQQEAAABfQECAwAEEQUSITFBBhNRYQcicRQygZGhCCNCscEVUtHwJDNicoIJChYXGBkaJSYnKCkqNDU2Nzg5OkNERUZHSElKU1RVVldYWVpjZGVmZ2hpanN0dXZ3eHl6g4SFhoeIiYqSk5SVlpeYmZqio6Slpqeoqaqys7S1tre4ubrCw8TFxsfIycrS09TV1tfY2drh4uPk5ebn6Onq8fLz9PX29/j5+gEAAwEBAQEBAQEBAQAAAAAAAAECAwQFBgcICQoLEQACAQIEBAMEBwUEBAABAncAAQIDEQQFITEGEkFRB2FxEyIygQgUQpGhscEJIzNS8BVictEKFiQ04SXxFxgZGiYnKCkqNTY3ODk6Q0RFRkdISUpTVFVWV1hZWmNkZWZnaGlqc3R1dnd4eXqCg4SFhoeIiYqSk5SVlpeYmZqio6Slpqeoqaqys7S1tre4ubrCw8TFxsfIycrS09TV1tfY2dri4+Tl5ufo6ery8/T19vf4+fr/2gAMAwEAAhEDEQA/APTvjhbwS3f2mWGN7mw8L63e2czIC9tcRmzMcsZ6o6nkMMEdjQB2Om+PNHub46ff/aNI1JZltnt9QjCATsFZIRMpaF5WV0YRpIzEN04IAB1VAHwB+1H/AMl28Tf9uv8A6SxUAfUfhfwcZ9Zl0zW7++1COx0q60fUor+9lla7+0i2K3URcl1SVInDKHCo8bKgJV3YA7bUvCOkX90s9zb7y9419PG2HjuXa0a0IkVgQVMTY2jAJUHnJyAcJ4N+JFyuh+GNL8iC/wBTfSrN5Td37x3Ny5s1nd0HlsG+Xd8zuoZlcA5U07AfK/7Rt/Bqvxh1rUbMs1tdw2VxEWGCUezhYZHbgikB9t+Lo7vTdf0jXdM0+7vid9hfwWiqWeAq0kchBK7ikiBVyflE8uB8xoAyPFepah4j0G60O38N67ANU22M09xFEqwwSsI5pMiQ8rGzsODyBxQBT8f6Tf33juDyIrxrO8trOymMVs7boftLtOizrxbjZtL5/wBYoULgqDTTA+Tv2nYo4Pjh4jhgjSOKNbVERAAqqLWEAADoKQD/APhoP4n/APQzf+SFr/8AG6AD/hoP4n/9DN/5IWv/AMboAP8AhoP4n/8AQzf+SFr/APG6AOA8U+IdU8Va7dazr119r1K52+bN5ax7tqhF+VQAPlUDgdqAP//Z),auto";
  452. // dom.style.cursor='url("/wd/theme/standard/img/wdHelp_mouse.png")';
  453. // dom.setAttribute("wdHelp_mark","true");
  454. //
  455. //pointer手
  456. var cursor = $(dom).css("cursor");
  457. // $(dom).attr("ceeee",cursor);
  458. if (cursor == "pointer") {
  459. $(dom).addClass("cursor-clickHelp")
  460. } else {
  461. $(dom).addClass("cursor-help");
  462. }
  463. $(dom).children("textarea").each(function(){
  464. changeImage(this);
  465. })
  466. }
  467. function jsCopy(text) {
  468. const isRTL = document.documentElement.getAttribute('dir') == 'rtl';
  469. var fakeElem = document.createElement('textarea');
  470. // Prevent zooming on iOS
  471. fakeElem.style.fontSize = '12pt';
  472. // Reset box model
  473. fakeElem.style.border = '0';
  474. fakeElem.style.padding = '0';
  475. fakeElem.style.margin = '0';
  476. // Move element out of screen horizontally
  477. fakeElem.style.position = 'absolute';
  478. fakeElem.style[isRTL ? 'right' : 'left'] = '-9999px';
  479. // Move element to the same position vertically
  480. fakeElem.style.top = (window.pageYOffset || document.documentElement.scrollTop) + 'px';
  481. fakeElem.setAttribute('readonly', '');
  482. fakeElem.value = text;
  483. document.body.appendChild(fakeElem);
  484. fakeElem.select();
  485. let succeeded;
  486. try {
  487. succeeded = document.execCommand('copy');
  488. } catch (err) {
  489. succeeded = false;
  490. }
  491. removeFake(fakeElem);
  492. return succeeded;
  493. }
  494. function removeFake(fakeElem) {
  495. if (fakeElem) {
  496. document.body.removeChild(fakeElem);
  497. fakeElem = null;
  498. }
  499. }
  500. var showWdHelp = null;
  501. function showwdHelpButton(wdDialogId){
  502. // console.log(wdDialogId);
  503. var win = wd.topWindow.dhxWins.window(wdDialogId);
  504. // if(win.getFrame().contentWindow.window!=window)
  505. // return;
  506. if(!win)return;
  507. // if(!$(win.button("wdHelp")).is(":hidden"))return;
  508. win.button("wdHelp").show()
  509. win.button("wdHelp").onclick = function() {
  510. var url = wd.display.replaceDynamicParam(wd.topWindow.helpDialogUrl, { dialogid: wdDialogId });
  511. eval(url);
  512. }
  513. }
  514. /**
  515. * 控制帮助按钮显示和隐藏
  516. * 帮助按钮绑定事件
  517. * @param {Object} title
  518. * @param {Object} helpHaShCode
  519. */
  520. function setupWdHelpIcon(title, helpsize, helpHaShCode) {
  521. var wdDialogId = wd.display.getwdDialogId();
  522. var data = { helpContent: document.querySelector("#helpcontent" + helpHaShCode).innerHTML, helpSize: helpsize, win: wd.topWindow }
  523. data.title = title;
  524. data.name = name;
  525. data.helpHaShCode = helpHaShCode;
  526. if (wdDialogId) {
  527. showwdHelpButton(wdDialogId);
  528. //弹出窗口
  529. } else if (wd.topWindow.wdHelpIcon) { //应用页面
  530. var url = wd.topWindow.document.querySelector("iframe[name=win2]").contentWindow.location.href;
  531. //个人首页
  532. var isgrsy = false;
  533. if (url.indexOf("yeMianEdit") != -1) {
  534. isgrsy = true;
  535. //页面
  536. }
  537. if (isgrsy) {
  538. var $b = $("#helpcontent" + helpHaShCode).parents("[initurl]").first().find(".icon-helpButton").show();
  539. initwdHelpElement($b[0], "click", title, data, helpHaShCode, window);
  540. } else {
  541. wd.topWindow.wdHelpIcon.style.display = "inline";
  542. wd.topWindow.wdHelpIcon.onclick = function() {
  543. var url = wd.display.replaceDynamicParam(wd.topWindow.helpDialogUrl, { dialogid: "" });
  544. eval(url);
  545. }
  546. }
  547. }
  548. addHelpData(data, false);
  549. }
  550. function initwdHelpElement(ele, eventName, title, data, helpHaShCode, environment) {
  551. var win = environment ? environment.window : window
  552. var artDialogFunction = environment ? environment.artDialog : artDialog;
  553. win.wdHelpDailog(ele, eventName, title, data, helpHaShCode);
  554. }
  555. var wdhelpdialogid = null;
  556. var wdhelpTimeOutObj = null;
  557. function wdHelpDailog(ele, eventName, title, data, helpHaShCode) {
  558. $(ele).bind('contextmenu', function(e) {
  559. return false;
  560. });
  561. // console.log(data)
  562. //仅仅右键
  563. // if(eventName=="rightclick"){
  564. $(ele).mouseleave(function(e) {
  565. var helpdiv = wd.topWindow.document.getElementById("wdhelpdialog");
  566. if (helpdiv != null) {
  567. if (!wd.topWindow.helpdialogid) {
  568. wd.topWindow.helpdialogid = [];
  569. }
  570. for (var i = 0; i < wd.topWindow.helpdialogid.length; i++) {
  571. wd.topWindow.clearTimeout(wd.topWindow.helpdialogid[i]);
  572. }
  573. if (!/l.*/i.test(data.helpSize)) {
  574. var timeoutid = wd.topWindow.setTimeout(function() {
  575. if ($(wd.topWindow.document).find("#wdhelpdialog .close").is(":visible") == false) {
  576. $(wd.topWindow.document).find("#wdhelpdialog").remove();
  577. }
  578. }, 1000);
  579. wd.topWindow.helpdialogid.push(timeoutid);
  580. }
  581. }
  582. })
  583. $(ele).mousedown(function(e) {
  584. if (eventName == "rightclick" && e.which != 3) return;
  585. e.stopPropagation();
  586. e.preventDefault();
  587. //防止重复点击
  588. if (wd.topWindow.dhxWins.window(wdhelpdialogid)) {
  589. return
  590. } else {
  591. wdhelpdialogid = null;
  592. }
  593. var params = { show: ["wdhelpdialog"], url: data.helpContent, 'title': title, 'helpHaShCode': helpHaShCode }
  594. wdHelpDailogParams(data, params, this);
  595. var helpContent = data.helpContent + "";
  596. //替换正文class
  597. // help-title 标题行
  598. // help-content 正文默认字体
  599. // help-content-title 帮助标题(文章顶部居中的那个)
  600. // help-content-title1 一级标题
  601. // help-content-title2 二级标题
  602. // help-content-item 项目
  603. //
  604. //
  605. // smallHelp-content 正文默认字体
  606. // smallHelp-content-title 帮助标题(文章顶部居中的那个)
  607. // smallHelp-content-title1 一级标题
  608. // smallHelp-content-title2 二级标题
  609. // smallHelp-content-item 项目
  610. //大窗口
  611. // if (/l.*/i.test(data.helpSize)) {
  612. // helpContent = helpContent.replace(/help\-text/g, "help")
  613. // helpContent = helpContent.replace(/help\-titleText/g, "help-title")
  614. // helpContent = helpContent.replace(/help\-title1Text/g, "help-title1")
  615. // helpContent = helpContent.replace(/help\-title2Text/g, "help-title2")
  616. // helpContent = helpContent.replace(/help\-itemText/g, "help-itemText")
  617. // //
  618. // } else {
  619. // helpContent = helpContent.replace(/help\-text/g, "smallHelp")
  620. // helpContent = helpContent.replace(/help\-titleText/g, "smallHelp-title")
  621. // helpContent = helpContent.replace(/help\-title1Text/g, "smallHelp-title1")
  622. // helpContent = helpContent.replace(/help\-title2Text/g, "smallHelp-title2")
  623. // helpContent = helpContent.replace(/help\-itemText/g, "smallHelp-item")
  624. // }
  625. if (/l.*/i.test(data.helpSize)) {
  626. // helpContent = helpContent.replace(/help\-text/g, "help")
  627. // helpContent = helpContent.replace(/help\-titleText/g, "help-title")
  628. // helpContent = helpContent.replace(/help\-title1Text/g, "help-title1")
  629. // helpContent = helpContent.replace(/help\-title2Text/g, "help-title2")
  630. // helpContent = helpContent.replace(/help\-itemText/g, "help-itemText")
  631. //
  632. } else {
  633. helpContent = helpContent.replace(/class=\"help/g, "class=\"smallHelp")
  634. // helpContent = helpContent.replace(/class=\"help\"/g, "class=\"smallHelp\"")
  635. // helpContent = helpContent.replace(/class=\"help\-title\"/g, "class=\"smallHelp-title\"")
  636. // helpContent = helpContent.replace(/class=\"help\-title1\"/g, "class=\"smallHelp-title1\"")
  637. // helpContent = helpContent.replace(/class=\"help\-title2\"/g, "class=\"smallHelp-title2\"")
  638. // helpContent = helpContent.replace(/class=\"help\-item\"/g, "class=\"smallHelp-item\"")
  639. }
  640. var helpdiv = null;
  641. helpdiv = wd.topWindow.document.getElementById("wdhelpdialog");
  642. if (helpdiv) {
  643. helpdiv.parentNode.removeChild(helpdiv)
  644. }
  645. // if(!wd.topWindow.document.querySelector("#wdhelpcss")){
  646. // $(wd.topWindow.document).find("head").append("<link id=\"wdhelpcss\" rel='stylesheet' type='text/css' href='/env/js/artDialog/artDialog.css'/>");
  647. // }
  648. var closeClass, copyClass, pinClass, helpDivClass, helpTitleClass, contentClass
  649. var styleContent="";
  650. if (/l.*/i.test(data.helpSize)) { //大窗口
  651. closeClass = "icon-close"
  652. copyClass = "icon-key"
  653. pinClass = "lightDialog-fixButton"
  654. helpDivClass = "lightDialog-div"
  655. helpTitleClass = "lightDialog-title hLine"
  656. contentClass = "help-div"
  657. styleContent="<style>.copy{position: absolute;right: 45px;}</style>";
  658. } else { //小只窗口
  659. closeClass = "invertIcon-close"
  660. copyClass = "invertIcon-key"
  661. pinClass = "invertIcon-unpin"
  662. helpDivClass = "flashMsg-div"
  663. helpTitleClass = "flashMsg-title"
  664. contentClass = ""
  665. }
  666. helpDivClass += " help-size-" + data.helpSize.toLowerCase();
  667. $(wd.topWindow.document.body).append(""
  668. +
  669. "<div id=\"wdhelpdialog\" style=\"position: absolute;z-index: 999;opacity:0;\" class=\"" + helpDivClass + "\">"
  670. +"<style>.help-size-l{width: 700px;}.help-size-m{width: 500px;}.help-size-s{width: 300px;}</style>"
  671. +styleContent
  672. // + ((data.helpSize.toLowerCase() == "l") ? "" : "<div class=\"triangle smallHelp-div-triangle\"><span></span></div>")
  673. +
  674. ((data.helpSize.toLowerCase() == "l") ? "" : "<div class=\"flashMsg-up\"></div>") +
  675. "<div class=\"" + helpTitleClass + "\">" +
  676. " <div title=\"帮助标题\">" + params.title + "</div>" +
  677. " <div title=\"复制代码\" class=\"copy " + copyClass + "\" ></div>" +
  678. " <div title=\"已锁定\" class=\"pin " + pinClass + "\" ></div>" +
  679. " <div title=\"关闭\" class=\"close " + closeClass + "\" ></div>" +
  680. "</div>" +
  681. "<div class=\"" + contentClass + "\">" +
  682. helpContent +
  683. "</div></div>"
  684. )
  685. helpdiv = wd.topWindow.document.getElementById("wdhelpdialog");
  686. // $(helpdiv).css({'width':params.width,
  687. // 'left':params.x,
  688. // 'top':params.y});
  689. // if(params.height)
  690. // $(helpdiv).css({'height':params.height})
  691. function calHelpDislogPos(){
  692. var pos = calPso(ele, helpdiv, params.win ? params.win : window, params.center);
  693. var triangle = helpdiv.querySelector(".triangle");
  694. $(helpdiv).css({ 'opacity':1,'left': pos.left, 'top': (triangle ? 15 : 0) + pos.top });
  695. if(pos.tooRight){
  696. var $tail=$(helpdiv).find(".flashMsg-up");
  697. var tailleft= parseInt($tail.css("left"));
  698. $tail.css({left:pos.dialogwidth+tailleft});
  699. }
  700. }
  701. //calHelpDislogPos();
  702. setTimeout(calHelpDislogPos,500);
  703. // setTimeout(calHelpDislogPos,1000);
  704. // 记时消失
  705. // var timeout = data.helpSize.toLowerCase() == "s" ? 2000 : 4000;
  706. var timeout = 5000;
  707. clearTimeout(wdhelpTimeOutObj);
  708. wdhelpTimeOutObj = setTimeout(function() {
  709. if (top.$("#wdhelpdialog .close").css("display") != "block") {
  710. top.$("#wdhelpdialog").remove();
  711. }
  712. }, timeout);
  713. if (!/l.*/i.test(data.helpSize)) {
  714. $(helpdiv).find(".close").hide();
  715. } else {
  716. $(helpdiv).find(".pin").hide();
  717. }
  718. //表单事件
  719. wd.topWindow.$(helpdiv).on("click", ".close", function() {
  720. var helpdiv = wd.topWindow.document.getElementById("wdhelpdialog");
  721. if (helpdiv) {
  722. helpdiv.parentNode.removeChild(helpdiv)
  723. }
  724. }).on("click", ".copy", function() {
  725. //复制帮助代码
  726. supplyCopy(params.helpHaShCode);
  727. }).on("click", ".pin", function() {
  728. //点击锁定后,显示关闭按钮
  729. $(helpdiv).find(".close").show();
  730. $(this).hide();
  731. }).on("mouseleave", function() {
  732. //鼠标移除后,定时关闭
  733. // if(!wd.topWindow.helpdialogid){
  734. // wd.topWindow.helpdialogid=[];
  735. // }
  736. // for(var i=0;i<wd.topWindow.helpdialogid.length;i++){
  737. // wd.topWindow.clearTimeout(wd.topWindow.helpdialogid[i]);
  738. // }
  739. // wd.topWindow.helpdialogid=[]
  740. // var helpdiv=wd.topWindow.document.getElementById("wdhelpdialog");
  741. // if (!/l.*/i.test(data.helpSize)) {
  742. // var timeoutid= wd.topWindow.setTimeout(function(){
  743. // if ($(wd.topWindow.document).find("#wdhelpdialog .close").is(":visible") == false) {
  744. // $(wd.topWindow.document).find("#wdhelpdialog").remove();
  745. // }
  746. // },2000);
  747. // wd.topWindow.helpdialogid.push(timeoutid);
  748. // }
  749. this.allowmove = false;
  750. // console.log(wd.topWindow.helpdialogid);
  751. // var helpdiv=wd.topWindow.document.getElementById("wdhelpdialog");
  752. // if(helpdiv){
  753. // helpdiv.parentNode.removeChild(helpdiv)
  754. // }
  755. }).on("mousedown", function(e) {
  756. var event = e || window.event;
  757. if ($(this).find(".close").is(":hidden") == false) {
  758. this.allowmove = true;
  759. //开始坐标
  760. this.startleft = parseInt(this.style.left);
  761. this.starttop = parseInt(this.style.top);
  762. //点击位置坐标
  763. this.startx = event.clientX;
  764. this.starty = event.clientY;
  765. }
  766. }).on("mousemove", function(e) {
  767. if (!wd.topWindow.helpdialogid) {
  768. wd.topWindow.helpdialogid = [];
  769. }
  770. for (var i = 0; i < wd.topWindow.helpdialogid.length; i++) {
  771. wd.topWindow.clearTimeout(wd.topWindow.helpdialogid[i]);
  772. }
  773. var event = e || window.event;
  774. if (this.allowmove) {
  775. var x = event.clientX;
  776. var y = event.clientY;
  777. this.style.left = this.startleft + x - this.startx + "px";
  778. this.style.top = this.starttop + y - this.starty + "px";
  779. }
  780. }).on("mouseup", function() {
  781. this.allowmove = false;
  782. })
  783. $(window).unload(function() {
  784. $(wd.topWindow.document).find("#wdhelpdialog").remove();
  785. })
  786. })
  787. // }
  788. // //左击键
  789. // if(eventName=="click"){
  790. // $(ele).mousedown(function(e){
  791. // //防止重复点击
  792. // if(wd.topWindow.dhxWins.window(wdhelpdialogid)){
  793. // return
  794. // }else{
  795. // wdhelpdialogid=null;
  796. // }
  797. //
  798. // var params={show:["wdhelpdialog"],url:data.helpContent,'title':title,'helpHaShCode':helpHaShCode}
  799. // params.center=true;
  800. // wdHelpDailogParams(data,params,this)
  801. //
  802. // var id=wd.display.showComponent(params);
  803. // wdhelpdialogid=id
  804. // return false
  805. // })
  806. // }
  807. }
  808. function calPso(ele, dialog, wind, center) {
  809. var winXY = (function(win) {
  810. function getTop(e) {
  811. var offset = e.offsetTop;
  812. if (e.offsetParent != null) offset += arguments.callee(e.offsetParent);
  813. return offset;
  814. }
  815. function getLeft(e) {
  816. var offset = e.offsetLeft;
  817. if (e.offsetParent != null) offset += arguments.callee(e.offsetParent);
  818. return offset;
  819. }
  820. function recursionIframe(win) {
  821. win = win || window;
  822. function getTop(e) {
  823. var offset = e.offsetTop;
  824. if (e.offsetParent != null)
  825. offset += getTop(e.offsetParent);
  826. return offset;
  827. }
  828. function getLeft(e) {
  829. var offset = e.offsetLeft;
  830. if (e.offsetParent != null)
  831. offset += getLeft(e.offsetParent);
  832. return offset;
  833. }
  834. if (win.parent == top && win.parent == win) {
  835. return {
  836. "left": 0,
  837. "top": 0
  838. };
  839. }
  840. var winPar = win.parent;
  841. var iframeArr = winPar.document.getElementsByTagName('IFRAME');
  842. var targetIframe;
  843. var iframeArr1 = win.document.getElementsByTagName('IFRAME');
  844. for (var i = 0; i < iframeArr1.length; i++) {
  845. var iframeElem = iframeArr1[i];
  846. if (iframeElem.contentWindow == win) {
  847. targetIframe = iframeElem;
  848. break;
  849. }
  850. }
  851. for (var i = 0; i < iframeArr.length; i++) {
  852. var iframeElem = iframeArr[i];
  853. if (iframeElem.contentWindow == win) {
  854. targetIframe = iframeElem;
  855. break;
  856. }
  857. }
  858. var xy = {
  859. left: getLeft(targetIframe),
  860. top: getTop(targetIframe)
  861. }
  862. if (winPar.parent != winPar) {
  863. var xy2 = arguments.callee(winPar);
  864. xy.left += xy2.left;
  865. xy.top += xy2.top;
  866. }
  867. return xy
  868. }
  869. if (win.parent == top && win.parent == win) {
  870. return { "left": 0, "top": 0 };
  871. }
  872. var winPar = win.parent; // .opener
  873. var iframeArr = winPar.document.getElementsByTagName('IFRAME');
  874. var targetIframe;
  875. for (var i = 0; i < iframeArr.length; i++) {
  876. var iframeElem = iframeArr[i];
  877. if (iframeElem.contentWindow == win) {
  878. targetIframe = iframeElem;
  879. break;
  880. }
  881. }
  882. var xy = { left: getLeft(targetIframe), top: getTop(targetIframe) }
  883. if (winPar.parent != winPar) {
  884. var xy2 = recursionIframe(winPar);
  885. xy.left += xy2.left;
  886. xy.top += xy2.top;
  887. }
  888. xy.top = xy.top;
  889. return xy
  890. })(wind)
  891. var result = { left: 0, top: 0 }
  892. var dialogwidth = parseInt($(dialog).width());
  893. var dialogheight = parseInt($(dialog).height());
  894. var winHeight = (wind.document.body.scrollTop + wind.document.body.scrollHeight) ||
  895. (wind.document.documentElement.scrollTop + wind.document.documentElement.scrollHeight);
  896. var winWidth = (wind.document.body.scrollLeft + wind.document.body.scrollWidth) ||
  897. (wind.document.documentElement.scrollLeft + wind.document.documentElement.scrollWidth);
  898. result.dialogwidth=dialogwidth;
  899. result.dialogheight=dialogheight;
  900. if (center) {
  901. wind = wd.topWindow;
  902. result.left = (winWidth - dialogwidth) * 0.5;
  903. result.top = (winHeight - dialogheight) * 0.5;
  904. } else {
  905. var bouding = ele.getBoundingClientRect();
  906. //整屏宽
  907. // var winWidth = recursionIframe(win).left * 2 + win.innerWidth;
  908. result.left += winXY.left + bouding.left;
  909. result.top += winXY.top + bouding.top + bouding.height;
  910. //太靠右
  911. if(result.left+dialogwidth>winWidth){
  912. result.left=winXY.left + bouding.left-dialogwidth;
  913. result.tooRight=true;
  914. }
  915. }
  916. return result;
  917. }
  918. function wdHelpDailogParams(data, params, ele) {
  919. console.log(data)
  920. if (data.helpTitle) {
  921. params.title = data.helpTitle;
  922. }
  923. //大
  924. if (/l.*/i.test(data.helpSize)) {
  925. // params.width=700;
  926. // params.height=500;
  927. //图钉自动按下
  928. params.pin = true;
  929. params.center = true;
  930. // params.className="help-div";
  931. console.log("大窗口");
  932. //中
  933. } else if (/m.*/i.test(data.helpSize)) {
  934. // params.width=500;
  935. // params.height=200;
  936. // params.className="smallHelp-div";
  937. console.log("中窗口");
  938. //小,默认
  939. } else {
  940. // params.width=300;
  941. // params.height=100;
  942. // params.className="smallHelp-div";
  943. console.log("小窗口");
  944. }
  945. console.log(params)
  946. return params;
  947. }
  948. /**
  949. * 复制文本到粘贴
  950. * @param {Object} val
  951. */
  952. function supplyCopy(val) {
  953. const isRTL = document.documentElement.getAttribute('dir') == 'rtl';
  954. var fakeElem = document.createElement('textarea');
  955. // Prevent zooming on iOS
  956. fakeElem.style.fontSize = '12pt';
  957. // Reset box model
  958. fakeElem.style.border = '0';
  959. fakeElem.style.padding = '0';
  960. fakeElem.style.margin = '0';
  961. // Move element out of screen horizontally
  962. fakeElem.style.position = 'absolute';
  963. fakeElem.style[isRTL ? 'right' : 'left'] = '-9999px';
  964. // Move element to the same position vertically
  965. fakeElem.style.top = (window.pageYOffset || document.documentElement.scrollTop) + 'px';
  966. fakeElem.setAttribute('readonly', '');
  967. fakeElem.value = val;
  968. document.body.appendChild(fakeElem);
  969. fakeElem.select();
  970. let succeeded;
  971. try {
  972. succeeded = document.execCommand('copy');
  973. wd.display.alert("复制成功");
  974. } catch (err) {
  975. succeeded = false;
  976. wd.display.alert("复制失败");
  977. }
  978. removeFake(fakeElem);
  979. return succeeded;
  980. }
  981. /**
  982. * 编辑帮助
  983. */
  984. if (!wd) {
  985. var wd = {}
  986. }
  987. if (!wd.edit) {
  988. wd.edit = {};
  989. }
  990. if (!wd.edit.wdHelp) {
  991. wd.edit.wdHelp = {};
  992. }
  993. wd.edit.wdHelp.show = function() {
  994. if (!wd.wdHelpObj) {
  995. wd.wdHelpObj = new wd.edit.wdHelp.wdHelpFunction().init();
  996. }
  997. wd.wdHelpObj.show();
  998. }
  999. wd.edit.wdHelp.hide = function(real) {
  1000. if (!wd.wdHelpObj) {
  1001. wd.wdHelpObj = new wd.edit.wdHelp.wdHelpFunction().init();
  1002. }
  1003. wd.wdHelpObj.hide(real);
  1004. }
  1005. wd.edit.wdHelp.wdHelpFunction = function() {
  1006. this.dialogClassName = "wdHelp";
  1007. this.secondClick = false;
  1008. this.wdHelpValue = {};
  1009. this.init = function() {
  1010. return this;
  1011. }
  1012. this.show = function() {
  1013. $("[wdSecondaryTab]").attr("wdSecondaryTab","false").find("#tabOption").show();
  1014. var wdHelpElement = this.findWdHelpElement();
  1015. // console.log(wdHelpElement);
  1016. if (wdHelpElement.length == 0) {
  1017. // alert("找不到元素设置帮助信息");
  1018. return;
  1019. }
  1020. for (var i=0;i<wdHelpElement.length;i++) {
  1021. this.showDialog(wdHelpElement[i]);
  1022. }
  1023. }
  1024. this.hide = function(real) {
  1025. if(real)
  1026. $("[wdSecondaryTab]").attr("wdSecondaryTab","true");
  1027. $("." + this.dialogClassName).remove();
  1028. }
  1029. this.showDialog = function(group) {
  1030. var ele=group.container;
  1031. var topDoc = window.document;
  1032. var chartDiv = topDoc.createElement('div');
  1033. chartDiv.className = this.dialogClassName;
  1034. chartDiv.record = ele;
  1035. chartDiv.innerHTML = this.buildCheckBox(ele) //根据数据库已经保存结果返回checkbox
  1036. // with(chartDiv.style) {
  1037. // zIndex = 65535;
  1038. // background = 'bisque';
  1039. // cursor= 'pointer';
  1040. // width="10px";
  1041. // }
  1042. chartDiv.style.display = $(ele).css("display");
  1043. chartDiv.setAttribute("class", "icon-empty " + this.dialogClassName)
  1044. chartDiv.style.position = 'absolute';
  1045. $(ele).after(chartDiv)
  1046. // var bounding=ele.getBoundingClientRect();
  1047. // var $p=$(ele).parents().filter(function(){
  1048. // if($(this).css("position")=="relative"|| $(this).css("position") == "absolute"|| $(this).css("position") == "fixed")return true;
  1049. // }).first()
  1050. // var $p=$(ele).offsetParent();
  1051. // if($p.length==0)$p=null
  1052. //
  1053. // var chartDivWidth=chartDiv.offsetWidth;
  1054. //
  1055. // var pbounding=$p? $p[0].getBoundingClientRect():null;
  1056. //
  1057. // chartDiv.style.left =(bounding.width+bounding.left-(pbounding?pbounding.left:0) )+"px"
  1058. // chartDiv.style.top =(bounding.top-(pbounding?pbounding.top:0)+(bounding.height-chartDiv.offsetHeight)*0.5)+"px"
  1059. var position = $(ele).position();
  1060. chartDiv.style.left = position.left + $(ele).width() + "px"
  1061. chartDiv.style.top = position.top + ($(ele).height() - $(chartDiv).height()) * 0.5 + "px"
  1062. var leftx = $(chartDiv).offset().left + $(chartDiv).width() - $(window).width();
  1063. if (leftx > 0) {
  1064. $(chartDiv).animate({ left: "-=" + leftx });
  1065. }
  1066. // chartDiv.style.marginLeft="-"+chartDiv.offsetWidth;
  1067. // var top=this.getTop(ele)
  1068. // var left=this.getLeft(ele)
  1069. // var xy={x:0,y:0}
  1070. // chartDiv.style.left = xy.x+left+ele.offsetWidth+"px"
  1071. // chartDiv.style.top = xy.y+top+"px";
  1072. // chartDiv.style.left =ele.offsetWidth+"px"
  1073. // function FindParam(url,name){
  1074. // //获取url中"?"符后的字串
  1075. // var theRequest = new Object();
  1076. // if (url.indexOf("?") != -1) {
  1077. // var str = url.substr(1);
  1078. // strs = str.split("&");
  1079. // for(var i = 0; i < strs.length; i ++) {
  1080. // theRequest[strs[i].split("=")[0]]=unescape(strs[i].split("=")[1]);
  1081. // }
  1082. // }
  1083. //
  1084. // return theRequest[name];
  1085. //
  1086. // }
  1087. var exist = false;
  1088. $.ajax({
  1089. url: "/service?ssServ=queryHelpByCode",
  1090. type: "POST",
  1091. data: {
  1092. tokenstring:(group.token|| FindParam(window.location.href, "ssToken")), // , "token")),。Lin
  1093. helpElementName: group.name,
  1094. resultType: "ajax"
  1095. },
  1096. async: false,
  1097. dataType: "json",
  1098. success: function(data) {
  1099. if (data) {
  1100. exist = true;
  1101. // chartDiv.style.background = 'red';
  1102. }
  1103. }
  1104. });
  1105. //chartDiv.style.background = 'red';
  1106. if (exist)
  1107. chartDiv.setAttribute("class", "icon-warningFull " + this.dialogClassName)
  1108. $(chartDiv).on("click", (function() {
  1109. var helpElementName = group.name;
  1110. return function() {
  1111. // top.editHelpDialog
  1112. // var url= '/service?wdApplication=wd&wdService=queryHelpByCode&wdOutputComponent=440164702'
  1113. var pageurl = window.location.href;
  1114. // url+="&helpElementName="+helpElementName;
  1115. // url+="&tokenstring="+;
  1116. //// url+="&pageurl="+pageurl;
  1117. // wd.display.showComponent({show:["wdDialog"],hide:[],url:url,title:"编辑帮助",width:500,height:500});
  1118. var url = wd.display.replaceDynamicParam(wd.topWindow.editHelpDialog,
  1119. {tokenstring:(group.token|| FindParam(location.search, "ssToken")), // , "token")),。Lin
  1120. helpElementName: helpElementName
  1121. });
  1122. eval(url);
  1123. }
  1124. })())
  1125. }
  1126. this.buildCheckBox = function(ele) {
  1127. var eleName = ele.getAttribute("name")
  1128. var result = "";
  1129. // result+='<input title=\"设置帮助\" value=\"h\" type="button" style=\"opacity: 0.5;\" />';
  1130. // result+='<input title=\"设置帮助\" type="checkbox" style=\"opacity: 0.5;cursor: pointer;\" />';
  1131. return result;
  1132. }
  1133. this.recursionIframe = function(win) {
  1134. if (win.parent == top && win.parent == win) {
  1135. // var xy = this.getAbsPoint(win);
  1136. return { "x": 0, "y": 0, "w": 0, "h": 0 };
  1137. }
  1138. var winPar = win.parent; // .opener
  1139. var iframeArr = winPar.document.getElementsByTagName('IFRAME');
  1140. var targetIframe;
  1141. for (var i = 0; i < iframeArr.length; i++) {
  1142. var iframeElem = iframeArr[i];
  1143. if (iframeElem.contentWindow == win) {
  1144. targetIframe = iframeElem;
  1145. break;
  1146. }
  1147. }
  1148. // alert(targetIframe==null)
  1149. // var xy = this.getAbsPoint(targetIframe);
  1150. var xy = { x: this.getLeft(targetIframe), y: this.getTop(targetIframe) }
  1151. if (winPar.parent != winPar) {
  1152. var xy2 = this.recursionIframe(winPar);
  1153. xy.x += xy2.x;
  1154. xy.y += xy2.y;
  1155. }
  1156. return xy
  1157. }
  1158. this.getTop = function(e) {
  1159. var offset = e.offsetTop;
  1160. if (e.offsetParent != null) offset += this.getTop(e.offsetParent);
  1161. return offset;
  1162. }
  1163. this.getLeft = function(e) {
  1164. var offset = e.offsetLeft;
  1165. if (e.offsetParent != null) offset += this.getLeft(e.offsetParent);
  1166. return offset;
  1167. }
  1168. /*
  1169. * 返回页面所有带wdRecord="true"的元素
  1170. */
  1171. this.findWdHelpElement = function() {
  1172. var wdRecordList = []
  1173. // var selectList2 = document.querySelectorAll("[name]");
  1174. // for (var i = 0; i < selectList2.length; i++) {
  1175. // if (selectList2[i].clientWidth > 0 && selectList2[i].tagName != "IFRAME") {
  1176. // // if(!/^wd.*/.test(selectList2[i].getAttribute("name")))
  1177. // var p = selectList2[i].parentNode;
  1178. //
  1179. // if (p.offsetWidth > 0 && p.getAttribute("name"))
  1180. // continue;
  1181. //
  1182. //
  1183. // wdRecordList.push(selectList2[i]);
  1184. // }
  1185. // }
  1186. //输入框
  1187. var groups=wd.display.getInputsGroups();
  1188. for(var key in groups){
  1189. wdRecordList.push(groups[key]);
  1190. }
  1191. //选项卡:三级帮助 所以不需要name
  1192. var iframe=document.querySelector("iframe");
  1193. if(iframe&&iframe.tabObj){
  1194. var tabList= iframe.tabObj.wdTabList;
  1195. for(var i=0;i<tabList.length;i++){
  1196. if(tabList[i].secondaryTabList.length>0){
  1197. for(var j=0;j<tabList[i].secondaryTabList.length;j++){
  1198. var secondary=tabList[i].secondaryTabList[j];
  1199. /* 再改,规范 <li wdTabClick=、&token= 命名。Lin
  1200. * 先改,是 wdtabclick,不是 wdTabClick
  1201. wdRecordList.push({container:secondary,token:FindParam(secondary.getAttribute("wdtabclick"),"token"),name:""});
  1202. */ wdRecordList.push({container:secondary,token:FindParam(secondary.getAttribute("ssTabClick"),"ssToken"),name:""});
  1203. }
  1204. continue;
  1205. }
  1206. var li= tabList[i].dom;
  1207. /* 再改,规范 <li wdTabClick= 命名。Lin
  1208. * 先改,是 wdtabclick,不是 wdTabClick
  1209. var url=li.getAttribute("wdtabclick");
  1210. */ var url=li.getAttribute("ssTabClick");
  1211. if(li.offsetWidth==0||!url)continue;
  1212. wdRecordList.push({container:li,token:FindParam(url,"ssToken"),name:""}); // ,"token"),。Lin
  1213. }
  1214. }
  1215. //其他
  1216. var allContainer=[];
  1217. var allName={};
  1218. for(var i=0;i<wdRecordList.length;i++){
  1219. allContainer.push(wdRecordList[i].container);
  1220. var name=wdRecordList[i].name;
  1221. if(name){
  1222. allName[name]=1;
  1223. }
  1224. }
  1225. var $allContainer=$(allContainer);
  1226. $("input[name][class]").each(function(){
  1227. var name=this.getAttribute("name");
  1228. if(!$allContainer.is(this)&&!$.contains($allContainer,this)&&!allName[name]&&!wd.display.filterInputBoxNames[name]){
  1229. wdRecordList.push({container:this,name:name});
  1230. }
  1231. })
  1232. return wdRecordList;
  1233. }
  1234. this.findDialog = function() {
  1235. return document.getElementsByClassName(this.dialogClassName)
  1236. }
  1237. /*删除勾选框*/
  1238. this.removeDialog = function() {
  1239. while (this.findDialog().length > 0) {
  1240. var record = {}
  1241. var removeEle = this.findDialog()[0];
  1242. // console.log(removeEle.record)
  1243. removeEle.parentNode.removeChild(removeEle)
  1244. }
  1245. }
  1246. /*获得部件ID:bjid */
  1247. getBjid = function() {
  1248. var bjid = document.getElementsByName("wdComponentID")[0].value
  1249. return bjid
  1250. }
  1251. /*根据勾选框+元素值生成数据 */
  1252. this.getRecordData = function() {
  1253. var recordZhi = {};
  1254. var dialogList = this.findDialog();
  1255. // {"nrid": {value:"440120001400",defualt:true},"bt":{"nrid": {value:"标题",defualt:false} }
  1256. for (var i = 0; i < dialogList.length; i++) {
  1257. var recordName = dialogList[i].record.getAttribute("name");
  1258. var recordValue = dialogList[i].record.value
  1259. var recordDefault = dialogList[i].getElementsByTagName("input")[0].checked;
  1260. var lastValue = dialogList[i].getElementsByTagName("input")[1].checked;
  1261. if (recordDefault || lastValue) {
  1262. recordZhi[recordName] = { value: recordValue, default: recordDefault }
  1263. }
  1264. }
  1265. return recordZhi;
  1266. }
  1267. }
  1268. function addHelpData(data, isdialog) {
  1269. var a = window.wdHelpData;
  1270. if (!a) {
  1271. window.wdHelpData = [];
  1272. a = window.wdHelpData;
  1273. }
  1274. for (var i = 0; i < a.length; i++) {
  1275. if (a[i].helpHaShCode == data.helpHaShCode) {
  1276. a[i] = data;
  1277. return;
  1278. }
  1279. }
  1280. if (data.title)
  1281. a.push(data);
  1282. // if(data.helpContent){
  1283. // data.helpContent=data.helpContent.replace(/style=\".*?\"/g,"")
  1284. // }
  1285. //
  1286. console.log(data)
  1287. // var topiframe=wd.topWindow.document.querySelector("iframe[name="+wd.topWindow.MenuSetting.target+"]")
  1288. // if(isdialog){
  1289. // console.log(wd.display.getwdDialogWindows())
  1290. // console.log(wd.display.getwdDialogId());
  1291. // }else{
  1292. // console.log(wd.display.getwdDialogWindows())
  1293. //
  1294. // console.log(wd.display.getwdDialogId());
  1295. // }
  1296. //
  1297. //
  1298. //
  1299. // console.log(data);
  1300. }
  1301. wd.edit.findAllHelpData = function(wdDialogId) {
  1302. var result = [];
  1303. if (wdDialogId) {
  1304. console.log(wdDialogId);
  1305. var allWindows = wd.display.getwdDialogWindowObjects(parseInt(wdDialogId));
  1306. for (var i = 0; i < allWindows.length; i++) {
  1307. if (allWindows[i].wdHelpData) {
  1308. result = result.concat(allWindows[i].wdHelpData);
  1309. }
  1310. }
  1311. } else {
  1312. var topiframe = wd.topWindow.document.querySelector("iframe[name=" + wd.topWindow.MenuSetting.target + "]")
  1313. // console.log(topiframe.contentWindow);
  1314. if (topiframe.contentWindow) {
  1315. if (topiframe.contentWindow.wdHelpData)
  1316. result = result.concat(topiframe.contentWindow.wdHelpData);
  1317. var alliframe = topiframe.contentWindow.document.querySelectorAll("iframe");
  1318. for (var i = 0; i < alliframe.length; i++) {
  1319. if (alliframe[i].contentWindow && alliframe[i].contentWindow.wdHelpData) {
  1320. result = result.concat(alliframe[i].contentWindow.wdHelpData);
  1321. }
  1322. }
  1323. }
  1324. }
  1325. return result;
  1326. }
  1327. $(function() {
  1328. if (window.location.href.indexOf("view") > 0) return;
  1329. //非开发模式下隐藏
  1330. if (!wd.topWindow.wd.edit)
  1331. wd.topWindow.wd.edit = {};
  1332. if (!wd.topWindow.wd.edit.findAllHelpData) {
  1333. wd.topWindow.wd.edit.findAllHelpData = wd.edit.findAllHelpData;
  1334. }
  1335. if (!wd.topWindow.IS_ALLOW_EDIT_WDHELP) return;
  1336. var wdDialogId = wd.display.getwdDialogId();
  1337. //窗口状态
  1338. if (wdDialogId) {
  1339. if ("0" == window.loginStatus)
  1340. return;
  1341. var win = wd.topWindow.dhxWins.window(wdDialogId);
  1342. //没有提供按钮
  1343. if (!win.button("editWdHelp")) return;
  1344. win.button("editWdHelp").show();
  1345. var editbutton = win.button("editWdHelp");
  1346. var savebutton = win.button("editWdHelp_save");
  1347. var allWindows = wd.display.getwdDialogWindowObjects(wdDialogId);
  1348. for (var i = 0; i < allWindows.length; i++) {
  1349. try{
  1350. if (allWindows[i].wd && allWindows[i].wd.edit && allWindows[i].wd.edit.wdHelp) {
  1351. allWindows[i].wd.edit.wdHelp.hide();
  1352. }
  1353. }catch(e){
  1354. console.error(e);
  1355. }
  1356. }
  1357. editbutton.edit = false;
  1358. var thisUrl = win.getFrame().contentWindow.location.href
  1359. editbutton.onclick = function() {
  1360. var edit = editbutton.edit;
  1361. editbutton.edit = !(editbutton.edit ? true : false);
  1362. edit = true;
  1363. for (var i = 0; i < allWindows.length; i++) {
  1364. try{
  1365. if (!allWindows[i].wd.edit || !allWindows[i].wd.edit.wdHelp) continue;
  1366. allWindows[i].wd.edit.wdHelp.show();
  1367. }catch(e){
  1368. console.error(e);
  1369. }
  1370. }
  1371. var url = wd.display.replaceDynamicParam(wd.topWindow.editHelpDialog, { tokenstring: FindParam(thisUrl, "ssToken"), helpElementName: "" }); // , "token"),。Lin
  1372. eval(url);
  1373. this.hide();
  1374. savebutton.show()
  1375. }
  1376. savebutton.onclick = function() {
  1377. for (var i = 0; i < allWindows.length; i++) {
  1378. try{
  1379. if (!allWindows[i].wd.edit || !allWindows[i].wd.edit.wdHelp) continue;
  1380. allWindows[i].wd.edit.wdHelp.hide(true);
  1381. }catch(e){
  1382. console.error(e);
  1383. }
  1384. }
  1385. this.hide();
  1386. editbutton.show()
  1387. }
  1388. //页面状态
  1389. } else if (wd.topWindow.editWdHelp) {
  1390. var url = wd.topWindow.document.querySelector("iframe[name=win2]").contentWindow.location.href;
  1391. var THIS = window;
  1392. //个人首页
  1393. var isgrsy = false;
  1394. if (url.indexOf("yeMianEdit") != -1) {
  1395. isgrsy = true;
  1396. function initsybjBodyHelp(ele,t){
  1397. var mytt;
  1398. var myttime=0;
  1399. mytt=setInterval(function(){
  1400. //console.log(mytt)
  1401. myttime++;
  1402. if(myttime>10)
  1403. clearInterval(mytt);
  1404. var $button=$(ele).find(".icon-setHelpButton");
  1405. if($button.length==0)
  1406. return true;
  1407. clearInterval(mytt);
  1408. $button.show().on("click", function() {
  1409. var thisUrl = $(this).parents("[initurl]").first().attr("initurl");
  1410. var url = THIS.wd.display.replaceDynamicParam(wd.topWindow.editHelpDialog, { tokenstring: THIS.FindParam(thisUrl, "ssToken"), helpElementName: "" }); // , "token"),。Lin
  1411. eval(url);
  1412. })
  1413. },t?t:2000);
  1414. }
  1415. function initGrsyHelp(){
  1416. //刷新之后,重新 绑定点击事件
  1417. window.gridster.$el.on("click", ".img-header", function() {
  1418. var $this1=$(this).parents("[initurl]");
  1419. initsybjBodyHelp($this1,10000)
  1420. })
  1421. THIS.gridster.$widgets.each(function(){
  1422. initsybjBodyHelp(this);
  1423. })
  1424. }
  1425. if(THIS.json&&THIS.json!="[]"){
  1426. var tt=THIS.setInterval(function(){
  1427. try{
  1428. console.log(tt);
  1429. if( THIS.gridster.$widgets.length==0)
  1430. throw "wait wait";
  1431. initGrsyHelp();
  1432. THIS.clearInterval(tt);
  1433. }catch(e){
  1434. console.log(e);
  1435. }
  1436. },3000);
  1437. }
  1438. $(wd.topWindow.editWdHelp).show();
  1439. //页面
  1440. } else {
  1441. $(wd.topWindow.editWdHelp).show();
  1442. setTimeout(function() {
  1443. $(wd.topWindow.editWdHelp).show();
  1444. }, 5000)
  1445. }
  1446. var settingClass="largeIcon-setHelp";
  1447. var okClass="largeInvertIcon-save";
  1448. wd.topWindow.editWdHelp.isSaveButton=false;
  1449. wd.topWindow.editWdHelp.setAttribute("class",settingClass);
  1450. wd.topWindow.editWdHelp.onclick = function() {
  1451. if(isgrsy){
  1452. eval(wd.topWindow.editHelpEditTab);
  1453. return;
  1454. }
  1455. if(this.isSaveButton){
  1456. THIS.wd.edit.wdHelp.hide();
  1457. this.isSaveButton=false;
  1458. this.setAttribute("class",settingClass);
  1459. }else{
  1460. this.setAttribute("class",okClass);
  1461. this.isSaveButton=true;
  1462. THIS.wd.edit.wdHelp.hide();
  1463. THIS.wd.edit.wdHelp.show(wd.topWindow.editWdHelp);
  1464. var url="";
  1465. if(!isgrsy){
  1466. var thisUrl = THIS.location.href;
  1467. url= wd.display.replaceDynamicParam(wd.topWindow.editHelpDialog, { tokenstring: FindParam(thisUrl, "ssToken"), helpElementName: "" }); // , "token"),。Lin
  1468. eval(url);
  1469. }
  1470. }
  1471. }
  1472. // wd.topWindow.editWdHelp.onclick=(function(){
  1473. // var thiswindow=window;
  1474. // return function(){
  1475. // thiswindow.wd.edit.wdHelp.hide();
  1476. // thiswindow.wd.edit.wdHelp.show(wd.topWindow.editWdHelp);
  1477. // var thisUrl=window.location.href;
  1478. // var url=wd.display.replaceDynamicParam(wd.topWindow.editHelpDialog,{tokenstring:FindParam(thisUrl,"token"),helpElementName:""});
  1479. // eval(url);
  1480. //
  1481. // }
  1482. // })()
  1483. }
  1484. })
  1485. //刷新单前窗口
  1486. function refreshHelpChart(wind) {
  1487. //refreshHelpChart(wd.display.getwdDialogOpener())
  1488. var wdDialogId = wind.wd.display.getwdDialogId();
  1489. //窗口状态
  1490. if (wdDialogId) {
  1491. var win = wd.topWindow.dhxWins.window(wdDialogId);
  1492. var allWindows = wd.display.getwdDialogWindowObjects(wdDialogId);
  1493. for (var i = 0; i < allWindows.length; i++) {
  1494. if (allWindows[i].wd && allWindows[i].wd.edit && allWindows[i].wd.edit.wdHelp) {
  1495. allWindows[i].wd.edit.wdHelp.hide();
  1496. allWindows[i].wd.edit.wdHelp.show();
  1497. }
  1498. }
  1499. //页面状态
  1500. } else if (wd.topWindow.editWdHelp) {
  1501. wind.wd.edit.wdHelp.hide();
  1502. wind.wd.edit.wdHelp.show(wd.topWindow.editWdHelp);
  1503. }
  1504. }