You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

564 lines
16 KiB

  1. //Copyright (c) 2001-2016 Aspose Pty Ltd. All Rights Reserved.
  2. //Copyright (c) 2001-2011 Aspose Pty Ltd. All Rights Reserved.
  3. /*****************************************************
  4. * Aspose.Cells.GridWeb Component Script File
  5. * Copyright 2003-2011, All Rights Reserverd.
  6. * V2.5.1
  7. *****************************************************/
  8. var acell;
  9. var olist = null;
  10. var setborder = null;
  11. function initDlg()
  12. {
  13. acell = dialogArguments;
  14. if (acell.list != null && (typeof acell.list.length) == "number" && acell.list.length > 0)
  15. {
  16. olist = acell;
  17. var range = olist.list[0];
  18. acell = olist.g.getCell(range.startRow, range.startCol);
  19. }
  20. table2.style.height = table1.offsetHeight;
  21. window.returnValue = false;
  22. getSystemFonts();
  23. preview.style.fontFamily = txtFont.value = acell.currentStyle.fontFamily;
  24. preview.style.fontStyle = acell.currentStyle.fontStyle;
  25. preview.style.fontWeight = acell.currentStyle.fontWeight;
  26. preview.style.display = "table-cell";
  27. preview_parent_td.style.verticalAlign = acell.currentStyle.verticalAlign;
  28. preview.style.textAlign = acell.currentStyle.textAlign;
  29. //alert(preview_parent_td.style.height + ";" + acell.id + "---" + acell.style.verticalAlign + "acell.currentStyle.verticalAlign----------init;" + acell.currentStyle.verticalAlign + " & " + acell.align);
  30. var tmps = "";
  31. if (acell.currentStyle.fontStyle != "normal")
  32. tmps += "Italic";
  33. if (acell.currentStyle.fontWeight != "normal" && acell.currentStyle.fontWeight != "400")
  34. {
  35. if (tmps != "")
  36. tmps += " Bold";
  37. else
  38. tmps = "Bold";
  39. }
  40. if (tmps == "")
  41. tmps = "Regular";
  42. txtStyle.value = tmps;
  43. preview.style.fontSize = txtSize.value = acell.currentStyle.fontSize;
  44. preview.style.color = btnFC.style.backgroundColor = acell.orgColor;
  45. preview.style.backgroundColor = btnBG.style.backgroundColor = acell.orgBgColor;
  46. //chkSub.checked = acell.parentElement.currentStyle.verticalAlign == "sub";
  47. //chkSuper.checked = acell.parentElement.currentStyle.verticalAlign == "super";
  48. //preview.style.verticalAlign = acell.parentElement.currentStyle.verticalAlign;
  49. for (var op1 = 0; op1 < selHalign.options.length; op1++)
  50. {
  51. if (selHalign.options[op1].value == acell.currentStyle.textAlign)
  52. {
  53. selHalign.selectedIndex = op1;
  54. break;
  55. }
  56. }
  57. for (var op1 = 0; op1 < selValign.options.length; op1++)
  58. {
  59. if (selValign.options[op1].value == acell.currentStyle.verticalAlign)
  60. {
  61. selValign.selectedIndex = op1;
  62. break;
  63. }
  64. }
  65. if (acell.tdstyle)
  66. {
  67. preview.style.textDecorationUnderline = chkUnderline.checked = acell.style.textDecorationUnderline;
  68. preview.style.textDecorationLineThrough = chkStrike.checked = acell.style.textDecorationLineThrough;
  69. }
  70. else
  71. {
  72. acell.tdstyle = true;
  73. acell.style.textDecoration = "none";
  74. for (var s1 = 0; s1 < acell.ownerDocument.styleSheets.length; s1++)
  75. {
  76. var styleSheet = acell.ownerDocument.styleSheets[s1];
  77. for (var s2 = 0; s2 < styleSheet.rules.length; s2++)
  78. {
  79. var rule = styleSheet.rules[s2];
  80. if (rule.selectorText == "."+acell.className)
  81. {
  82. acell.style.textDecorationUnderline = preview.style.textDecorationUnderline = chkUnderline.checked = rule.style.textDecorationUnderline;
  83. acell.style.textDecorationLineThrough = preview.style.textDecorationLineThrough = chkStrike.checked = rule.style.textDecorationLineThrough;
  84. s1 = acell.ownerDocument.styleSheets.length;
  85. break;
  86. }
  87. }
  88. }
  89. }
  90. var ss = acell.all.tags("SPAN");
  91. if (ss.length > 0)
  92. {
  93. var txt = ss[0].innerText;
  94. if (txt != "")
  95. preview.innerText = txt;
  96. }
  97. else if (acell.innerText != "")
  98. preview.innerText = acell.innerText;
  99. selValign.onchange = function () {
  100. preview_parent_td.style.verticalAlign = this.value;
  101. // preview.style.verticalAlign = this.value;
  102. //alert("value updated1");
  103. };
  104. selHalign.onchange = function () {
  105. preview.style.textAlign = this.value;
  106. // alert("value updated2");
  107. };
  108. }
  109. function getSystemFonts()
  110. {
  111. var a=dlgHelper.fonts.count;
  112. var fArray = new Array();
  113. var oDropDown = selFont;
  114. for (var i = 1;i < dlgHelper.fonts.count;i++){
  115. fArray[i] = dlgHelper.fonts(i);
  116. var oOption = document.createElement("OPTION");
  117. oDropDown.add(oOption);
  118. oOption.text = fArray[i];
  119. oOption.Value = i;
  120. }
  121. }
  122. function convertRGBDecimalToHex(rgb)
  123. {
  124. var regex = /rgb *\( *([0-9]{1,3}) *, *([0-9]{1,3}) *, *([0-9]{1,3}) *\)/;
  125. var values = regex.exec(rgb);
  126. if(values==null||values.length != 4)
  127. {
  128. return rgb; // fall back to what was given.
  129. }
  130. var r = Math.round(parseFloat(values[1]));
  131. var g = Math.round(parseFloat(values[2]));
  132. var b = Math.round(parseFloat(values[3]));
  133. return "#"
  134. + (r + 0x10000).toString(16).substring(3).toUpperCase()
  135. + (g + 0x10000).toString(16).substring(3).toUpperCase()
  136. + (b + 0x10000).toString(16).substring(3).toUpperCase();
  137. }
  138. function chooseColor(rgbColor)
  139. {
  140. var sColor = dlgHelper.ChooseColorDlg(rgbColor);
  141. //change decimal to hex
  142. sColor = sColor.toString(16);
  143. //add extra zeroes if hex number is less than 6 digits
  144. if (sColor.length < 6) {
  145. var sTempString = "000000".substring(0,6-sColor.length);
  146. sColor = sTempString.concat(sColor);
  147. }
  148. //btnBorderColor.style.backgroundColor=sColor;
  149. //btnBorderColor.style.backgroundColor="#"+sColor;
  150. // alert("ie raise:"+(convertRGBDecimalToHex(btnBorderColor.style.backgroundColor))+";"+("#"+sColor));
  151. return "#"+sColor;
  152. }
  153. function OnForeColorChange()
  154. {
  155. preview.style.color = btnFC.style.backgroundColor;
  156. }
  157. function OnBGColorChange()
  158. {
  159. preview.style.backgroundColor = btnBG.style.backgroundColor;
  160. preview_parent_td.style.backgroundColor = btnBG.style.backgroundColor;
  161. }
  162. function OnFontChange()
  163. {
  164. txtFont.value = selFont.options[selFont.selectedIndex].text;
  165. OnFontChange1();
  166. }
  167. function OnFontChange1()
  168. {
  169. preview.style.fontFamily = txtFont.value;
  170. }
  171. function OnStyleChange()
  172. {
  173. txtStyle.value = selStyle.options[selStyle.selectedIndex].text;
  174. switch (txtStyle.value)
  175. {
  176. case "Regular":
  177. preview.style.fontStyle="normal";
  178. preview.style.fontWeight="normal";
  179. break;
  180. case "Italic":
  181. preview.style.fontStyle="italic";
  182. preview.style.fontWeight="normal";
  183. break;
  184. case "Bold":
  185. preview.style.fontStyle="normal";
  186. preview.style.fontWeight="bold";
  187. break;
  188. case "Italic Bold":
  189. preview.style.fontStyle="italic";
  190. preview.style.fontWeight="bold";
  191. break;
  192. }
  193. }
  194. function OnSizeChange()
  195. {
  196. txtSize.value = selSize.options[selSize.selectedIndex].text;
  197. OnSizeChange1();
  198. }
  199. function OnSizeChange1()
  200. {
  201. preview.style.fontSize = txtSize.value;
  202. }
  203. function OnUnderline()
  204. {
  205. preview.style.textDecorationUnderline = chkUnderline.checked;
  206. }
  207. function OnLineThrough()
  208. {
  209. preview.style.textDecorationLineThrough = chkStrike.checked;
  210. }
  211. function FontOk()
  212. {
  213. if (setborder != null)
  214. setBorders();
  215. if (getattr(acell, "protected") == "1")
  216. acell = document.createElement("TD");
  217. acell.styleStr = acell.style.fontFamily = txtFont.value;
  218. acell.styleStr += "|";
  219. switch (txtStyle.value)
  220. {
  221. case "Regular":
  222. acell.style.fontStyle = "normal";
  223. acell.style.fontWeight = "normal";
  224. acell.styleStr += "r|";
  225. break;
  226. case "Italic":
  227. acell.style.fontStyle = "italic";
  228. acell.style.fontWeight = "normal";
  229. acell.styleStr += "i|";
  230. break;
  231. case "Bold":
  232. acell.style.fontStyle = "normal";
  233. acell.style.fontWeight = "bold";
  234. acell.styleStr += "b|";
  235. break;
  236. case "Italic Bold":
  237. acell.style.fontStyle = "italic";
  238. acell.style.fontWeight = "bold";
  239. acell.styleStr += "ib|";
  240. break;
  241. }
  242. acell.style.fontSize = txtSize.value;
  243. acell.style.textDecorationUnderline = chkUnderline.checked;
  244. acell.style.textDecorationLineThrough = chkStrike.checked;
  245. acell.orgColor = btnFC.style.backgroundColor;
  246. acell.orgBgColor = btnBG.style.backgroundColor;
  247. acell.style.textAlign = selHalign.options[selHalign.selectedIndex].value;
  248. acell.style.verticalAlign = selValign.options[selValign.selectedIndex].value;
  249. acell.align = selHalign.options[selHalign.selectedIndex].value;
  250. acell.styleStr += txtSize.value + "|" + chkUnderline.checked + "|"
  251. + chkStrike.checked + "|" + convertRGBDecimalToHex(btnFC.style.backgroundColor) + "|" + convertRGBDecimalToHex(btnBG.style.backgroundColor)
  252. + "|" + selHalign.options[selHalign.selectedIndex].value + "|" + selValign.options[selValign.selectedIndex].value;
  253. if (olist != null)
  254. {
  255. for (var i = 0; i < olist.list.length; i++)
  256. {
  257. var range = olist.list[i];
  258. for (var r = range.startRow; r <= range.endRow; r++)
  259. {
  260. for (var c = range.startCol; c <= range.endCol; c++)
  261. {
  262. var cell = olist.g.getCell(r, c);
  263. if (cell != null && cell != acell && getattr(cell, "protected") != "1")
  264. {
  265. cell.styleStr = acell.styleStr + "|" + (cell.tbstr!=null?cell.tbstr:"") + "|" + (cell.bbstr!=null?cell.bbstr:"") + "|" + (cell.lbstr!=null?cell.lbstr:"") + "|" + (cell.rbstr!=null?cell.rbstr:"");
  266. cell.style.fontFamily = acell.style.fontFamily;
  267. cell.style.fontStyle = acell.style.fontStyle;
  268. cell.style.fontWeight = acell.style.fontWeight;
  269. cell.style.fontSize = acell.style.fontSize;
  270. cell.style.textDecorationUnderline = acell.style.textDecorationUnderline;
  271. cell.style.textDecorationLineThrough = acell.style.textDecorationLineThrough;
  272. cell.orgColor = acell.orgColor;
  273. cell.orgBgColor = acell.orgBgColor;
  274. //cell.style.textAlign = acell.style.textAlign;
  275. cell.align = acell.align;
  276. cell.style.verticalAlign = acell.style.verticalAlign;
  277. }
  278. }
  279. }
  280. }
  281. }
  282. acell.styleStr = acell.styleStr + "|" + (acell.tbstr!=null?acell.tbstr:"") + "|" + (acell.bbstr!=null?acell.bbstr:"") + "|" + (acell.lbstr!=null?acell.lbstr:"") + "|" + (acell.rbstr!=null?acell.rbstr:"");
  283. window.returnValue = true;
  284. window.close();
  285. }
  286. function showFont()
  287. {
  288. btnFont.style.border = "1px inset white";
  289. btnBorders.style.border = "1px outset white";
  290. table1.style.display = "block";
  291. table2.style.display = "none";
  292. }
  293. function showBorders()
  294. {
  295. btnBorders.style.border = "1px inset white";
  296. btnFont.style.border = "1px outset white";
  297. table1.style.display = "none";
  298. table2.style.display = "block";
  299. }
  300. function clickBorderBtn()
  301. {
  302. var o = event.srcElement;
  303. var id = o.id;
  304. var i;
  305. for (i = 1; i<=8; i++)
  306. {
  307. eval("b"+i+".style.border='3px ridge white';");
  308. }
  309. o.style.border = "3px inset white";
  310. setborder = id;
  311. }
  312. function setBorderWidthSelect (it) {
  313. if(it=="Dashed")
  314. { //only thin ,medium for dashed options
  315. if(borderWidth.options.length==3)
  316. {borderWidth.options.remove(2);
  317. }
  318. }else
  319. { //thin,medium,thick for other options
  320. if(borderWidth.options.length==2){
  321. var option=document.createElement("option");
  322. option.value="3px";
  323. option.text="thick";
  324. borderWidth.options.add(option);
  325. }
  326. }
  327. if(it=="Double"||it=="Dotted")
  328. {borderlinelabel.style.display="none";
  329. borderWidth.style.display="none";
  330. if(it=="Double")
  331. {//3px for double
  332. borderWidth.selectedIndex=2;
  333. }else{
  334. //2px for dotted in order to show it,if we set 1px,we can not see the effect in the browser,
  335. //however in the server code ,the dotted is only dotted type it does not care the border width
  336. borderWidth.selectedIndex=1;
  337. }
  338. }else
  339. { borderlinelabel.style.display="block";
  340. borderWidth.style.display="block";
  341. }
  342. }
  343. function setBorders()
  344. {
  345. var bstr = borderWidth.options[borderWidth.selectedIndex].value + " " + borderStyle.options[borderStyle.selectedIndex].text + " " + convertRGBDecimalToHex(btnBorderColor.style.backgroundColor);
  346. if (olist == null)
  347. {
  348. switch (setborder)
  349. {
  350. case "b1":
  351. acell.style.borderTop = "none";
  352. acell.style.borderBottom = "none";
  353. acell.style.borderLeft = "none";
  354. acell.style.borderRight = "none";
  355. acell.tbstr = acell.bbstr = acell.lbstr = acell.rbstr = "none";
  356. break;
  357. case "b2":
  358. acell.style.borderBottom = bstr;
  359. acell.bbstr = bstr;
  360. break;
  361. case "b3":
  362. acell.style.borderLeft = bstr;
  363. acell.lbstr = bstr;
  364. break;
  365. case "b4":
  366. acell.style.borderRight = bstr;
  367. acell.rbstr = bstr;
  368. break;
  369. case "b5":
  370. acell.style.borderTop = bstr;
  371. acell.tbstr = bstr;
  372. break;
  373. case "b6":
  374. case "b7":
  375. acell.style.borderBottom = bstr;
  376. acell.style.borderLeft = bstr;
  377. acell.style.borderRight = bstr;
  378. acell.style.borderTop = bstr;
  379. acell.tbstr = acell.bbstr = acell.lbstr = acell.rbstr = bstr;
  380. break;
  381. case "b8":
  382. acell.style.borderTop = bstr;
  383. acell.style.borderBottom = bstr;
  384. acell.tbstr = acell.bbstr = bstr;
  385. break;
  386. }
  387. }
  388. else
  389. {
  390. switch (setborder)
  391. {
  392. case "b1":
  393. for (var i = 0; i < olist.list.length; i++)
  394. {
  395. var range = olist.list[i];
  396. for (var r = range.startRow; r <= range.endRow; r++)
  397. {
  398. for (var c = range.startCol; c <= range.endCol; c++)
  399. {
  400. var o = olist.g.getCell(r, c);
  401. if (o == null || getattr(o, "protected") == "1") continue;
  402. o.style.borderTop = "none";
  403. o.style.borderBottom = "none";
  404. o.style.borderLeft = "none";
  405. o.style.borderRight = "none";
  406. o.tbstr = o.bbstr = o.lbstr = o.rbstr = "none";
  407. }
  408. }
  409. }
  410. break;
  411. case "b2":
  412. for (var i = 0; i < olist.list.length; i++)
  413. {
  414. var range = olist.list[i];
  415. var r = range.endRow;
  416. for (var c = range.startCol; c <= range.endCol; c++)
  417. {
  418. var o = olist.g.getCell(r, c);
  419. if (o == null || getattr(o, "protected") == "1") continue;
  420. o.style.borderBottom = bstr;
  421. o.bbstr = bstr;
  422. }
  423. }
  424. break;
  425. case "b3":
  426. for (var i = 0; i < olist.list.length; i++)
  427. {
  428. var range = olist.list[i];
  429. for (var r = range.startRow; r <= range.endRow; r++)
  430. {
  431. var o = olist.g.getCell(r, range.startCol);
  432. if (o == null || getattr(o, "protected") == "1") continue;
  433. o.style.borderLeft = bstr;
  434. o.lbstr = bstr;
  435. }
  436. }
  437. break;
  438. case "b4":
  439. for (var i = 0; i < olist.list.length; i++)
  440. {
  441. var range = olist.list[i];
  442. for (var r = range.startRow; r <= range.endRow; r++)
  443. {
  444. var o = olist.g.getCell(r, range.endCol);
  445. if (o == null || getattr(o, "protected") == "1") continue;
  446. o.style.borderRight = bstr;
  447. o.rbstr = bstr;
  448. }
  449. }
  450. break;
  451. case "b5":
  452. for (var i = 0; i < olist.list.length; i++)
  453. {
  454. var range = olist.list[i];
  455. for (var c = range.startCol; c <= range.endCol; c++)
  456. {
  457. var o = olist.g.getCell(range.startRow, c);
  458. if (o == null || getattr(o, "protected") == "1") continue;
  459. o.style.borderTop = bstr;
  460. o.tbstr = bstr;
  461. }
  462. }
  463. break;
  464. case "b6":
  465. for (var i = 0; i < olist.list.length; i++)
  466. {
  467. var range = olist.list[i];
  468. for (var r = range.startRow; r <= range.endRow; r++)
  469. {
  470. for (var c = range.startCol; c <= range.endCol; c++)
  471. {
  472. var o = olist.g.getCell(r, c);
  473. if (o == null || getattr(o, "protected") == "1") continue;
  474. o.style.borderTop = bstr;
  475. o.style.borderBottom = bstr;
  476. o.style.borderLeft = bstr;
  477. o.style.borderRight = bstr;
  478. o.tbstr = o.bbstr = o.lbstr = o.rbstr = bstr;
  479. }
  480. }
  481. }
  482. break;
  483. case "b7":
  484. setborder = "b2";
  485. setBorders();
  486. setborder = "b3";
  487. setBorders();
  488. setborder = "b4";
  489. setBorders();
  490. setborder = "b5";
  491. setBorders();
  492. break;
  493. case "b8":
  494. setborder = "b2";
  495. setBorders();
  496. setborder = "b5";
  497. setBorders();
  498. break;
  499. }
  500. }
  501. }
  502. function getattr(o, name)
  503. {
  504. if (o.attributes[name] != null)
  505. return o.attributes[name].nodeValue;
  506. return o.attributes[name];
  507. }