Built files from Bizgaze WebServer
Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

ribbon.js 65KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832
  1. var Unibase;
  2. (function (Unibase) {
  3. let Apps;
  4. (function (Apps) {
  5. let Collaboration;
  6. (function (Collaboration) {
  7. let Components;
  8. (function (Components) {
  9. let DocEditor;
  10. (function (DocEditor) {
  11. class Ribbon {
  12. init(docobj, result) {
  13. this.FileName = result.FileName;
  14. this.FileId = result.FileId;
  15. this.documentGroup = result.DocumentGroup;
  16. this.wordDocumentObj = docobj;
  17. this.docBase = Unibase.Apps.Collaboration.Components.DocEditor.Base.Instance();
  18. this.fileDownload = Unibase.Apps.Collaboration.Components.Common.Download.Instance();
  19. this.util = Unibase.Apps.Collaboration.Components.Common.Util.Instance();
  20. this.render();
  21. }
  22. render() {
  23. this.wordDocumentMenubar(this.FileId, this.documentGroup, this.FileName);
  24. this.appendToolbarElements();
  25. this.createResponsiveToolbar();
  26. this.updateProp();
  27. }
  28. updateProp() {
  29. this.fontSize = document.getElementById("DocumentViewer_editor_font_properties_fontSize").ej2_instances[0];
  30. }
  31. setFontSize(size) {
  32. this.wordDocumentObj.textProperties.text.isRetrieving = false;
  33. this.fontSize.value = size;
  34. }
  35. wordDocumentMenubar(FileId, documentGroup, FileName) {
  36. var instance = this;
  37. var menuItems = [
  38. {
  39. text: 'File',
  40. items: [
  41. { text: 'New', iconCss: 'e-icons add-new' },
  42. { text: 'Open', iconCss: 'e-icons e-open' },
  43. { text: 'Make a copy', iconCss: 'e-icons biz_make_a_copy' },
  44. {
  45. text: 'Download', iconCss: 'e-icons e-save',
  46. items: [
  47. { text: 'Microsoft Word Document (.docx)', iconCss: 'e-icons' },
  48. { text: 'Portable Document Format (.pdf)', iconCss: 'e-icons Pdf_Export' },
  49. { text: 'Text Document (.txt)', iconCss: 'e-icons' }
  50. ]
  51. },
  52. { text: 'Close', iconCss: 'e-icons cross-close' },
  53. ]
  54. },
  55. {
  56. text: 'Edit',
  57. items: [
  58. { text: 'Undo', iconCss: 'e-icons biz-doc-undo-icon' },
  59. { text: 'Redo', iconCss: 'e-icons biz-doc-redo-icon' },
  60. { separator: true },
  61. { text: 'Cut', iconCss: 'e-icons biz-doc-cut-icon' },
  62. { text: 'Copy', iconCss: 'e-icons biz-doc-copy-icon' },
  63. { text: 'Paste', iconCss: 'e-icons biz-doc-paste-icon' },
  64. {
  65. text: 'Special paste', iconCss: 'e-icons biz-doc-paste-icon', items: [
  66. { text: "Keep source formatting", iconCss: 'e-icons MT_PasteStyle' },
  67. { text: "Match destination formatting", iconCss: 'e-icons M_MergeFormatting' },
  68. { text: "Text only", iconCss: 'e-icons MT_PasteTextonly' },
  69. ]
  70. },
  71. { separator: true },
  72. { text: 'Delete', iconCss: 'e-icons MT_Delete' },
  73. { text: 'Select all', iconCss: 'e-icons MT_SelectAll' },
  74. { text: 'Search', iconCss: 'e-icons MT_Search' },
  75. ]
  76. },
  77. {
  78. text: 'View',
  79. items: [
  80. { text: 'Page Setup', iconCss: 'e-icons M_PageSetup' },
  81. { text: 'Page Number', iconCss: 'e-icons M_PageNumber' },
  82. {
  83. text: 'Mode', iconCss: 'e-icons MT_Preview',
  84. items: [
  85. { text: 'Editing', iconCss: 'e-icons biz_edit_icon' },
  86. { text: 'View only', iconCss: 'e-icons MT_Preview' },
  87. ]
  88. },
  89. {
  90. text: 'Break', iconCss: 'e-icons M_Break',
  91. items: [
  92. { text: 'Page Break', iconCss: 'e-icons M_PageBreak' },
  93. { text: 'Section Break', iconCss: 'e-icons M_SectionBreak' },
  94. ]
  95. },
  96. { separator: true },
  97. { text: 'Full screen', iconCss: 'e-icons biz-enterfullscreen' },
  98. ]
  99. },
  100. {
  101. text: 'Insert',
  102. items: [
  103. { text: 'Header', iconCss: 'e-icons M_Header' },
  104. { text: 'Footer', iconCss: 'e-icons M_Footer' },
  105. { separator: true },
  106. { text: 'Image', iconCss: 'e-icons B_Image' },
  107. { text: 'Table', iconCss: 'e-icons table-02' },
  108. { text: 'Link', iconCss: 'e-icons e-Hyperlink' },
  109. { text: 'Bookmark', iconCss: 'e-icons M_Bookmark' },
  110. { text: 'Table Of Contents', iconCss: 'e-icons M_TableOfContent' },
  111. { separator: true },
  112. { text: 'Footnote', iconCss: 'e-icons M_Footnote' },
  113. { text: 'Endnote', iconCss: 'e-icons M_Endnote' },
  114. ]
  115. },
  116. {
  117. text: 'Format',
  118. items: [
  119. {
  120. text: 'Text', iconCss: 'e-icons ',
  121. items: [
  122. { text: 'Bold', iconCss: 'e-icons ' },
  123. { text: 'Italic', iconCss: 'e-icons ' },
  124. { text: 'Underline', iconCss: 'e-icons ' },
  125. { text: 'Strikethrough', iconCss: 'e-icons ' },
  126. { text: 'Superscript', iconCss: 'e-icons ' },
  127. { text: 'Subscript', iconCss: 'e-icons ' },
  128. ]
  129. },
  130. {
  131. text: 'Font size', iconCss: 'e-icons ',
  132. items: [
  133. { text: '8', iconCss: 'e-icons ' },
  134. { text: '9', iconCss: 'e-icons ' },
  135. { text: '10', iconCss: 'e-icons ' },
  136. { text: '11', iconCss: 'e-icons ' },
  137. { text: '12', iconCss: 'e-icons ' },
  138. { text: '14', iconCss: 'e-icons ' },
  139. { text: '16', iconCss: 'e-icons ' },
  140. { text: '18', iconCss: 'e-icons ' },
  141. { text: '20', iconCss: 'e-icons ' },
  142. { text: '22', iconCss: 'e-icons ' },
  143. { text: '24', iconCss: 'e-icons ' },
  144. { text: '26', iconCss: 'e-icons ' },
  145. { text: '28', iconCss: 'e-icons ' },
  146. { text: '36', iconCss: 'e-icons ' },
  147. { text: '48', iconCss: 'e-icons ' },
  148. { text: '72', iconCss: 'e-icons ' },
  149. { text: '96', iconCss: 'e-icons ' },
  150. ]
  151. },
  152. {
  153. text: 'Paragraph styles', iconCss: 'e-icons ',
  154. items: [
  155. { text: 'Normal', iconCss: 'e-icons ' },
  156. { text: 'Heading 1', iconCss: 'e-icons ' },
  157. { text: 'Heading 2', iconCss: 'e-icons ' },
  158. { text: 'Heading 3', iconCss: 'e-icons ' },
  159. { text: 'Heading 4', iconCss: 'e-icons ' },
  160. { text: 'Heading 5', iconCss: 'e-icons ' },
  161. { text: 'Heading 6', iconCss: 'e-icons ' },
  162. ]
  163. },
  164. {
  165. text: 'Align & indent', iconCss: 'e-icons ',
  166. items: [
  167. { text: 'Left', iconCss: 'e-icons ' },
  168. { text: 'Center', iconCss: 'e-icons ' },
  169. { text: 'Right', iconCss: 'e-icons ' },
  170. { text: 'Justified', iconCss: 'e-icons ' },
  171. { separator: true },
  172. { text: 'Increase indent', iconCss: 'e-icons ' },
  173. { text: 'Decrease indent', iconCss: 'e-icons ' },
  174. ]
  175. },
  176. {
  177. text: 'Line spacing', iconCss: 'e-icons ',
  178. items: [
  179. { text: 'Single' },
  180. { text: '1.15' },
  181. { text: '1.5' },
  182. { text: 'Double' },
  183. ]
  184. },
  185. {
  186. text: 'Bulletes & numbering', iconCss: 'e-icons ', items: [
  187. {
  188. text: 'Bullets',
  189. items: [
  190. { text: 'None' },
  191. { text: 'Bullet dot' },
  192. { text: 'Bullet circle' },
  193. { text: 'Bullet square' },
  194. { text: 'Bullet flower' },
  195. { text: 'Bullet arrow' },
  196. { text: 'Bullet tick' },
  197. ]
  198. },
  199. {
  200. text: 'Numbering', items: [
  201. { text: 'No numbering' },
  202. { text: 'Numbers' },
  203. { text: 'Lower case' },
  204. { text: 'Upper case' },
  205. { text: 'roman' },
  206. { text: 'roman two' },
  207. ]
  208. },
  209. ]
  210. },
  211. { separator: true },
  212. { text: 'Clear formatting', iconCss: 'e-icons ' },
  213. ]
  214. },
  215. {
  216. text: 'Tools',
  217. items: [
  218. { text: 'Comments', iconCss: 'e-icons AddComment' },
  219. { text: 'Track Changes', iconCss: 'e-icons M_TrackChanges' },
  220. { text: 'Local ClipBoard', iconCss: 'e-icons MT_Paste' },
  221. { text: 'Restrict Editing', iconCss: 'e-icons M_Lock', items: [{ text: "Read Only" }, { text: "Protections" }] },
  222. ]
  223. },
  224. {
  225. text: 'Add-ons',
  226. items: [
  227. {
  228. text: 'Form Fields', iconCss: 'e-icons M_FormField', items: [{ text: "Text Form", iconCss: 'e-icons M_Textform' },
  229. { text: "Check Box", iconCss: 'e-icons M_CheckBox' }, { text: "Drop-Down", iconCss: 'e-icons M_Dropdown' }]
  230. },
  231. { text: 'Update Fields', iconCss: 'e-icons M_UpdateField' },
  232. ]
  233. }
  234. ];
  235. if (!this.wordDocumentMenubarObj) {
  236. let menubaritems = ["File", "Edit", "View", "Insert", "Format", "Tools", "Add-ons"];
  237. this.wordDocumentMenubarObj = new ej.navigations.Menu({
  238. cssClass: 'biz-doc-menu',
  239. showItemOnClick: true,
  240. beforeItemRender: (e) => {
  241. let popupitems = ["Text", "Font size", "Paragraph styles", "Align & indent", "Line spacing",
  242. "Bullets & numbering", "Bold", "Italic", "Underline", "Strikethrough", "Superscript",
  243. "Subscript", "Normal", "Heading 1", "Heading 2", "Heading 3", "Heading 4", "Heading 5",
  244. "Heading 6", "8", "9", "10", "11", "12", "16", "14", "18", "20", "22", "24", "26", "48", "28", "36", "72", "96"];
  245. if (popupitems.includes(e.item.text)) {
  246. if (this.docBase.formatInfo && this.docBase.formatInfo.element && this.docBase.formatInfo.element.characterFormat) {
  247. (this.docBase.formatInfo.element.characterFormat.bold) && (e.item.text == "Bold") && (this.addOrRemoveSelectIcon(e));
  248. (this.docBase.formatInfo.element.characterFormat.italic) && (e.item.text == "Italic") && (this.addOrRemoveSelectIcon(e));
  249. (this.docBase.formatInfo.element.characterFormat.baselineAlignment == e.item.text) && (this.addOrRemoveSelectIcon(e));
  250. (e.item.text == "Underline") && (this.docBase.formatInfo.element.characterFormat.underline == "Single") && (this.addOrRemoveSelectIcon(e));
  251. (e.item.text == "Strikethrough") && (this.docBase.formatInfo.element.characterFormat.strikethrough == "SingleStrike") && (this.addOrRemoveSelectIcon(e));
  252. (e.item.text == "Text") && ((this.docBase.formatInfo.element.characterFormat.bold) || (this.docBase.formatInfo.element.characterFormat.italic) ||
  253. (this.docBase.formatInfo.element.characterFormat.baselineAlignment == e.item.text) ||
  254. (this.docBase.formatInfo.element.characterFormat.underline == "Single") ||
  255. (this.docBase.formatInfo.element.characterFormat.strikethrough == "SingleStrike")) && (this.addOrRemoveSelectIcon(e));
  256. (this.docBase.formatInfo.element.characterFormat.fontSize == e.item.text) && (this.addOrRemoveSelectIcon(e));
  257. if (this.docBase.formatInfo.element.characterFormat.baseCharStyle) {
  258. ((this.docBase.formatInfo.element.characterFormat.baseCharStyle.name).slice(0, -5) == e.item.text) && (this.addOrRemoveSelectIcon(e));
  259. }
  260. else {
  261. (e.item.text == "Normal") && (this.addOrRemoveSelectIcon(e));
  262. }
  263. (e.item.text == "Paragraph styles") && (this.addOrRemoveSelectIcon(e));
  264. var fontsizes = ["8", "9", "10", "11", "12", "16", "14", "18", "20", "22", "24", "26", "48", "28", "36", "72", "96"];
  265. (e.item.text == "Font size") && (fontsizes.includes(this.docBase.formatInfo.element.characterFormat.fontSize.toString())) && (this.addOrRemoveSelectIcon(e));
  266. }
  267. }
  268. },
  269. beforeClose: e => {
  270. if (menubaritems.indexOf(e.parentItem.text) > -1) {
  271. this.wordDocumentMenubarObj.showItemOnClick = true;
  272. }
  273. },
  274. beforeOpen: (e) => {
  275. if (menubaritems.indexOf(e.parentItem.text) > -1) {
  276. this.wordDocumentMenubarObj.showItemOnClick = false;
  277. }
  278. let editItems = ["Undo", "Redo", "Paste", "Special paste"];
  279. if (e.items.find(x => x.text == "Undo") != null) {
  280. let undoOverley = document.getElementById("DocumentViewer_toolbar_undo").parentElement.classList.contains("e-overlay");
  281. if (undoOverley) {
  282. this.wordDocumentMenubarObj.enableItems(["Undo"], false);
  283. }
  284. }
  285. if (e.items.find(x => x.text == "Redo") != null) {
  286. let redoOverley = document.getElementById("DocumentViewer_toolbar_redo").parentElement.classList.contains("e-overlay");
  287. if (redoOverley) {
  288. this.wordDocumentMenubarObj.enableItems(["Redo"], false);
  289. }
  290. }
  291. },
  292. select: (e) => {
  293. var lineHeight = document.getElementById("DocumentViewer_editor_font_properties_lineHeight").ej2_instances[0];
  294. var bullets = document.getElementById("DocumentViewer_editor_font_properties_bullet_dropdownbtn").ej2_instances[0];
  295. console.log(e);
  296. switch (e.item.text) {
  297. case "New":
  298. this.processNewWord();
  299. break;
  300. case "Microsoft Word Document (.docx)":
  301. this.fileDownload.downloadDocumentFile(FileId, documentGroup, FileName, 'Docx', instance.docBase.documentContainer);
  302. break;
  303. case "Portable Document Format (.pdf)":
  304. this.docBase.convertDocsToPdfDownload(FileId);
  305. break;
  306. case "Text Document (.txt)":
  307. this.fileDownload.downloadDocumentFile(FileId, documentGroup, FileName, 'Txt', instance.docBase.documentContainer);
  308. break;
  309. case "Open":
  310. this.renderOpenNewDialogue();
  311. break;
  312. case "Close":
  313. this.closePopup();
  314. break;
  315. case "Undo":
  316. document.getElementById("DocumentViewer_toolbar_undo").click();
  317. break;
  318. case "Redo":
  319. document.getElementById("DocumentViewer_toolbar_redo").click();
  320. break;
  321. case "Cut":
  322. this.docBase.wordDocumentObj.documentEditor.editor.cut();
  323. break;
  324. case "Copy":
  325. this.docBase.wordDocumentObj.documentEditor.selection.copy();
  326. break;
  327. case "Paste":
  328. this.docBase.wordDocumentObj.documentEditor.editor.paste();
  329. break;
  330. case "Match destination formatting":
  331. this.closePopup();
  332. break;
  333. case "Text only":
  334. this.closePopup();
  335. break;
  336. case "Keep source formatting":
  337. this.closePopup();
  338. break;
  339. case "Delete":
  340. this.docBase.wordDocumentObj.documentEditor.editor.delete();
  341. break;
  342. case "Select all":
  343. this.docBase.wordDocumentObj.documentEditor.selection.selectAll();
  344. break;
  345. case "Search":
  346. this.docBase.wordDocumentObj.documentEditor.showOptionsPane();
  347. break;
  348. case "View only":
  349. this.docBase.wordDocumentObj.documentEditor.isReadOnly = true;
  350. break;
  351. case "Editing":
  352. this.docBase.wordDocumentObj.documentEditor.isReadOnly = false;
  353. break;
  354. case "Header":
  355. this.wordDocumentObj.toolbarModule.clickHandler({ item: { id: this.wordDocumentObj.element.id + "_toolbar_header" }, name: "clicked", originalEvent: { target: this.wordDocumentObj.element } });
  356. break;
  357. case "Footer":
  358. this.wordDocumentObj.toolbarModule.clickHandler({ item: { id: this.wordDocumentObj.element.id + "_toolbar_footer" }, name: "clicked", originalEvent: { target: this.wordDocumentObj.element } });
  359. break;
  360. case "Page Setup":
  361. this.wordDocumentObj.toolbarModule.clickHandler({ item: { id: this.wordDocumentObj.element.id + "_toolbar_page_setup" }, name: "clicked", originalEvent: { target: this.wordDocumentObj.element } });
  362. break;
  363. case "Page Number":
  364. this.wordDocumentObj.toolbarModule.clickHandler({ item: { id: this.wordDocumentObj.element.id + "_toolbar_page_number" }, name: "clicked", originalEvent: { target: this.wordDocumentObj.element } });
  365. break;
  366. case "Page Break":
  367. this.wordDocumentObj.toolbarModule.container.documentEditor.editorModule.insertPageBreak();
  368. break;
  369. case "Section Break":
  370. this.wordDocumentObj.toolbarModule.container.documentEditor.editorModule.insertSectionBreak();
  371. break;
  372. case "Footnote":
  373. this.wordDocumentObj.toolbarModule.clickHandler({ item: { id: this.wordDocumentObj.element.id + "_toolbar_footnote" }, name: "clicked", originalEvent: { target: this.wordDocumentObj.element } });
  374. break;
  375. case "Endnote":
  376. this.wordDocumentObj.toolbarModule.clickHandler({ item: { id: this.wordDocumentObj.element.id + "_toolbar_endnote" }, name: "clicked", originalEvent: { target: this.wordDocumentObj.element } });
  377. break;
  378. case "Full screen":
  379. Unibase.Apps.Collaboration.Components.Fullscreen.Instance().refreshWordDocumentHeight(this.wordDocumentObj);
  380. break;
  381. case "Image":
  382. this.wordDocumentObj.toolbarModule.imagePicker.value = "";
  383. this.wordDocumentObj.toolbarModule.imagePicker.click();
  384. setTimeout(() => { this.wordDocumentObj.toolbarModule.documentEditor.focusIn(); }, 30);
  385. break;
  386. case "Table":
  387. this.wordDocumentObj.toolbarModule.clickHandler({ item: { id: this.wordDocumentObj.element.id + "_toolbar_table" }, name: "clicked", originalEvent: { target: this.wordDocumentObj.element } });
  388. break;
  389. case "Link":
  390. this.wordDocumentObj.toolbarModule.clickHandler({ item: { id: this.wordDocumentObj.element.id + "_toolbar_link" }, name: "clicked", originalEvent: { target: this.wordDocumentObj.element } });
  391. break;
  392. case "Bookmark":
  393. this.wordDocumentObj.toolbarModule.clickHandler({ item: { id: this.wordDocumentObj.element.id + "_toolbar_bookmark" }, name: "clicked", originalEvent: { target: this.wordDocumentObj.element } });
  394. break;
  395. case "Table Of Contents":
  396. this.wordDocumentObj.documentEditor.showDialog('TableOfContents');
  397. break;
  398. case "Bold":
  399. document.getElementById("DocumentViewer_editor_font_properties_bold").click();
  400. break;
  401. case "Italic":
  402. document.getElementById("DocumentViewer_editor_font_properties_italic").click();
  403. break;
  404. case "Underline":
  405. document.getElementById("DocumentViewer_editor_font_properties_underline").click();
  406. break;
  407. case "Strikethrough":
  408. document.getElementById("DocumentViewer_editor_font_properties_strikethrough").click();
  409. break;
  410. case "Superscript":
  411. document.getElementById("DocumentViewer_editor_font_properties_superscript").click();
  412. break;
  413. case "Subscript":
  414. document.getElementById("DocumentViewer_editor_font_properties_subscript").click();
  415. break;
  416. case "Clear formatting":
  417. document.getElementById("DocumentViewer_editor_font_properties_clearFormat").click();
  418. break;
  419. case "Left":
  420. document.getElementById("DocumentViewer_editor_font_properties_leftIndent").click();
  421. break;
  422. case "Center":
  423. document.getElementById("DocumentViewer_editor_font_properties_centerIndent").click();
  424. break;
  425. case "Right":
  426. document.getElementById("DocumentViewer_editor_font_properties_rightIndent").click();
  427. break;
  428. case "Justified":
  429. document.getElementById("DocumentViewer_editor_font_properties_justify").click();
  430. break;
  431. case "Increase indent":
  432. document.getElementById("DocumentViewer_editor_font_properties_increaseIndent").click();
  433. break;
  434. case "Decrease indent":
  435. document.getElementById("DocumentViewer_editor_font_properties_decreaseIndent").click();
  436. break;
  437. case "Single":
  438. lineHeight.trigger('select', { item: lineHeight.items[0] });
  439. break;
  440. case "1.15":
  441. lineHeight.trigger('select', { item: lineHeight.items[1] });
  442. break;
  443. case "1.5":
  444. lineHeight.trigger('select', { item: lineHeight.items[2] });
  445. break;
  446. case "Double":
  447. lineHeight.trigger('select', { item: lineHeight.items[3] });
  448. break;
  449. case "None":
  450. this.wordDocumentObj.textProperties.paragraph.numberedNoneClick();
  451. break;
  452. case "Bullet dot":
  453. this.wordDocumentObj.textProperties.paragraph.bulletDotClick();
  454. break;
  455. case "Bullet circle":
  456. this.wordDocumentObj.textProperties.paragraph.bulletCircleClick();
  457. break;
  458. case "Bullet square":
  459. this.wordDocumentObj.textProperties.paragraph.bulletSquareClick();
  460. break;
  461. case "Bullet flower":
  462. this.wordDocumentObj.textProperties.paragraph.bulletFlowerClick();
  463. break;
  464. case "Bullet arrow":
  465. this.wordDocumentObj.textProperties.paragraph.bulletArrowClick();
  466. break;
  467. case "Bullet tick":
  468. this.wordDocumentObj.textProperties.paragraph.bulletTickClick();
  469. break;
  470. case "Numbers":
  471. this.wordDocumentObj.textProperties.paragraph.numberedNumberDotClick();
  472. break;
  473. case "Lower case":
  474. this.wordDocumentObj.textProperties.paragraph.numberedLowLetterClick();
  475. break;
  476. case "Upper case":
  477. this.wordDocumentObj.textProperties.paragraph.numberedUpLetterClick();
  478. break;
  479. case "roman":
  480. this.wordDocumentObj.textProperties.paragraph.numberedLowRomanClick();
  481. break;
  482. case "roman two":
  483. this.wordDocumentObj.textProperties.paragraph.numberedUpRomanClick();
  484. break;
  485. case "No numbering":
  486. this.wordDocumentObj.textProperties.paragraph.numberedNoneClick();
  487. break;
  488. case "Normal":
  489. this.wordDocumentObj.documentEditor.editorModule.applyStyle('Normal', true);
  490. break;
  491. case "Heading 1":
  492. this.wordDocumentObj.documentEditor.editorModule.applyStyle('Heading 1', true);
  493. break;
  494. case "Heading 2":
  495. this.wordDocumentObj.documentEditor.editorModule.applyStyle('Heading 2', true);
  496. break;
  497. case "Heading 3":
  498. this.wordDocumentObj.documentEditor.editorModule.applyStyle('Heading 3', true);
  499. break;
  500. case "Heading 4":
  501. this.wordDocumentObj.documentEditor.editorModule.applyStyle('Heading 4', true);
  502. break;
  503. case "Heading 5":
  504. this.wordDocumentObj.documentEditor.editorModule.applyStyle('Heading 5', true);
  505. break;
  506. case "Heading 6":
  507. this.wordDocumentObj.documentEditor.editorModule.applyStyle('Heading 6', true);
  508. break;
  509. case "8":
  510. this.setFontSize('8');
  511. break;
  512. case "9":
  513. this.setFontSize('9');
  514. break;
  515. case "10":
  516. this.setFontSize('10');
  517. break;
  518. case "11":
  519. this.setFontSize('11');
  520. break;
  521. case "12":
  522. this.setFontSize('12');
  523. break;
  524. case "14":
  525. this.setFontSize('14');
  526. break;
  527. case "16":
  528. this.setFontSize('16');
  529. break;
  530. case "18":
  531. this.setFontSize('18');
  532. break;
  533. case "20":
  534. this.setFontSize('20');
  535. break;
  536. case "22":
  537. this.setFontSize('22');
  538. break;
  539. case "24":
  540. this.setFontSize('24');
  541. break;
  542. case "36":
  543. this.setFontSize('36');
  544. break;
  545. case "Find":
  546. this.wordDocumentObj.toolbarModule.clickHandler({ item: { id: this.wordDocumentObj.element.id + "_toolbar_find" }, name: "clicked", originalEvent: { target: this.wordDocumentObj.element } });
  547. break;
  548. case "Comments":
  549. this.wordDocumentObj.toolbarModule.clickHandler({ item: { id: this.wordDocumentObj.element.id + "_toolbar_comment" }, name: "clicked", originalEvent: { target: this.wordDocumentObj.element } });
  550. break;
  551. case "Track Changes":
  552. this.wordDocumentObj.toolbarModule.clickHandler({ item: { id: this.wordDocumentObj.element.id + "_toolbar_track" }, name: "clicked", originalEvent: { target: this.wordDocumentObj.element } });
  553. break;
  554. case "Local ClipBoard":
  555. this.wordDocumentObj.toolbarModule.clickHandler({ item: { id: this.wordDocumentObj.element.id + "_toolbar_use_local_clipboard" }, name: "clicked", originalEvent: { target: this.wordDocumentObj.element } });
  556. break;
  557. case "Read Only":
  558. var ele = $('li[aria-label="Read Only"]').children('span').toggleClass('Selection');
  559. const value = 12;
  560. this.wordDocumentObj.toolbarModule.toggleEditing();
  561. break;
  562. case "Protections":
  563. this.wordDocumentObj.toolbarModule.documentEditor.documentHelper.restrictEditingPane.showHideRestrictPane(true);
  564. break;
  565. case "Text Form":
  566. this.wordDocumentObj.toolbarModule.documentEditor.editor.insertFormField('Text');
  567. break;
  568. case "Check Box":
  569. this.wordDocumentObj.toolbarModule.documentEditor.editor.insertFormField('CheckBox');
  570. break;
  571. case "Drop-Down":
  572. this.wordDocumentObj.toolbarModule.documentEditor.editor.insertFormField('DropDown');
  573. break;
  574. case "Update Fields":
  575. this.wordDocumentObj.toolbarModule.clickHandler({ item: { id: this.wordDocumentObj.element.id + "_toolbar_update_fields" }, name: "clicked", originalEvent: { target: this.wordDocumentObj.element } });
  576. break;
  577. }
  578. },
  579. items: menuItems,
  580. }, '#menu');
  581. }
  582. }
  583. addOrRemoveSelectIcon(ele) {
  584. if (!ele.element.firstElementChild.classList.contains("biz-ss-selecticon")) {
  585. ele.element.firstElementChild.classList.add("biz-ss-selecticon");
  586. }
  587. }
  588. processNewWord() {
  589. Unibase.Platform.Helpers.FileCacheHelper.Instance().loadJsFile("apps/collaboration/components/common/util.js", () => {
  590. let urlStr = Unibase.Apps.Collaboration.Components.Common.Util.Instance().makeid(40);
  591. window.open(window.origin + "#/documents/" + urlStr + "/newword/0");
  592. });
  593. }
  594. renderOpenNewDialogue() {
  595. this.OpenSelectButton = new ej.buttons.Button({ cssClass: `e-flat` });
  596. this.OpenCancelButton = new ej.buttons.Button({ cssClass: `e-flat` });
  597. var elem = document.getElementById("opendocfile");
  598. if (elem == null) {
  599. this.docOpenDialougObj = new ej.popups.Dialog({
  600. isModal: true,
  601. header: 'Open File',
  602. content: `<div id='tabobjforopendoc'></div>`,
  603. target: document.getElementById("container"),
  604. width: '470px',
  605. height: '330px',
  606. animationSettings: { effect: 'Zoom' },
  607. cssClass: "biz-doc-importopen-dialog"
  608. });
  609. this.docOpenDialougObj.appendTo('#dialog');
  610. var tabObjForOpen = new ej.navigations.Tab({
  611. items: [{
  612. header: { 'text': 'Upload' },
  613. content: `<div id="opendocfile-wrapper">
  614. <h2 style="color: #ccc">Drag a file...</h2>
  615. <label id='opendocfilelable'>
  616. select file from device
  617. <br>
  618. <input type="file" name="" id="opendocfile" accept=".doc, .docx, .txt , .rtf" placeholder="select a file from your device" >
  619. </label>
  620. <div id="filename"></div>
  621. </div>
  622. </div>
  623. <button id='opendocfile-select-btn' class='e-disabled'>select</button>
  624. <button id='opendocfile-cancel-btn'>cancel</button>`
  625. }]
  626. });
  627. tabObjForOpen.appendTo('#tabobjforopendoc');
  628. }
  629. else {
  630. this.docOpenDialougObj.show();
  631. }
  632. this.importOpenDialogcreated();
  633. }
  634. importOpenDialogcreated() {
  635. document.getElementById('opendocfile-select-btn').setAttribute("disabled", 'true');
  636. document.getElementById('opendocfile-select-btn').addEventListener('click', () => {
  637. this.openWordDocument();
  638. this.docOpenDialougObj.hide();
  639. });
  640. document.getElementById('opendocfile-cancel-btn').addEventListener('click', () => {
  641. this.docOpenDialougObj.hide();
  642. document.getElementById('opendocfile-select-btn').classList.add('e-disabled');
  643. document.getElementById('filename').innerHTML = "";
  644. this.importedFile.value = null;
  645. if (this.docOpenDialougObj) {
  646. this.docOpenDialougObj.destroy();
  647. }
  648. });
  649. this.OpenSelectButton.appendTo('#opendocfile-select-btn');
  650. this.OpenCancelButton.appendTo('#opendocfile-cancel-btn');
  651. document.body.addEventListener('dragover', (e) => {
  652. e.preventDefault();
  653. });
  654. document.getElementsByClassName('biz-doc-importopen-dialog')[0].addEventListener('dragover', (e) => {
  655. e.preventDefault();
  656. });
  657. document.getElementsByClassName('biz-doc-importopen-dialog')[0].addEventListener("drop", (e) => {
  658. e.preventDefault();
  659. document.getElementById('opendocfile').files = e.dataTransfer.files;
  660. var ele = { target: { files: e.dataTransfer.files } };
  661. this.fileSelected(ele);
  662. });
  663. document.getElementById('opendocfile').addEventListener('change', (e) => {
  664. debugger;
  665. this.fileSelected(e);
  666. });
  667. }
  668. fileSelected(e) {
  669. document.getElementById('opendocfile-select-btn').removeAttribute('disabled');
  670. document.getElementById('opendocfile-select-btn').classList.remove('e-disabled');
  671. this.importedFile = document.getElementById('opendocfile');
  672. document.getElementById('filename').innerHTML = this.importedFile.files[0].name;
  673. Unibase.Platform.Helpers.FileCacheHelper.Instance().loadJsFile('platform/core/helpers/file/filehelper.js', () => {
  674. Unibase.Platform.Helpers.FileHelper.Instance().getBase64(e).then((response) => {
  675. if (Unibase.Themes.Providers.Detail_Settings.Instance().InputParameters.length != 0) {
  676. var InstalledAppId = Unibase.Themes.Providers.DetailHelper.installedAppId;
  677. var refId = Number(Unibase.Themes.Providers.Detail_Settings.Instance().InputParameters.find(x => x.Key == "hf_" + InstalledAppId + "_recordid").Value);
  678. if (refId != 0 && refId != null && refId != undefined) {
  679. }
  680. }
  681. var fileobject = {
  682. filedata: response.FileData,
  683. filename: response.FileName,
  684. filetype: response.FileType,
  685. RefId: refId,
  686. FileId: this.FileId,
  687. };
  688. this.documentOpenFileData = fileobject;
  689. });
  690. });
  691. }
  692. openWordDocument() {
  693. Unibase.Apps.Collaboration.DocumentManager.Instance().importCreateSpreadSheet(this.documentOpenFileData).then((response) => {
  694. var result = response.result;
  695. });
  696. }
  697. closePopup() {
  698. if (!this.docBase.NewDocument) {
  699. Unibase.Apps.Collaboration.Components.DocConnector.Instance().closeDoc();
  700. }
  701. window.close();
  702. }
  703. appendToolbarElements() {
  704. let sideBarElementsText = [];
  705. let sideBarElementsIndent = [];
  706. let sideBarElementsParagraph = [];
  707. var idsText = ['DocumentViewer_editor_font_properties_fontFamilyDiv', 'DocumentViewer_editor_font_properties_fontSizeDiv', 'DocumentViewer_editor_font_properties_leftDiv',
  708. 'DocumentViewer_editor_font_properties_rightDiv'];
  709. let idsParagraph = ['DocumentViewer_editor_font_properties_color', 'DocumentViewer_editor_font_properties_styleDiv'];
  710. var idsIndent = ['DocumentViewer_editor_font_properties_leftIndent', 'DocumentViewer_editor_font_properties_centerIndent', 'DocumentViewer_editor_font_properties_rightIndent', 'DocumentViewer_editor_font_properties_justify',
  711. 'DocumentViewer_editor_font_properties_decreaseIndent', 'DocumentViewer_editor_font_properties_increaseIndent', 'DocumentViewer_editor_font_properties_lineHeight',
  712. 'DocumentViewer_editor_font_properties_listDropDiv'];
  713. idsText.forEach(element => {
  714. sideBarElementsText.push(document.getElementById(element));
  715. });
  716. idsIndent.forEach(element => {
  717. sideBarElementsIndent.push(document.getElementById(element));
  718. });
  719. idsParagraph.forEach(element => {
  720. sideBarElementsParagraph.push(document.getElementById(element));
  721. });
  722. sideBarElementsText.forEach(element => {
  723. this.util.appendChildren('biz-doc-bottomtoolbar-text', 0, element);
  724. });
  725. sideBarElementsIndent.forEach(element => {
  726. this.util.appendChildren('biz-doc-bottomtoolbar-indent', 0, element);
  727. });
  728. sideBarElementsParagraph.forEach(element => {
  729. this.util.appendChildren('biz-doc-bottomtoolbar-paragraph', 0, element);
  730. });
  731. this.docBase.bottomtoolbartext = document.getElementsByClassName('biz-doc-bottomtoolbar-text')[0];
  732. this.util.appendChildren('biz-doc-bottomtoolbar-undoredo', 0, this.util.createElement("button", 'class', 'biz-doc-undo e-disabled e-btn e-lib'));
  733. this.util.appendChildren('biz-doc-undo', 0, this.util.createElement("span", 'class', 'e-icons e-icon-left biz-doc-undo-icon e-btn-icon'));
  734. this.util.appendChildren('biz-doc-bottomtoolbar-undoredo', 0, this.util.createElement("button", 'class', 'biz-doc-redo e-disabled e-btn e-lib'));
  735. this.util.appendChildren('biz-doc-redo', 0, this.util.createElement("span", 'class', 'e-icons e-icon-left biz-doc-redo-icon e-btn-icon'));
  736. document.getElementsByClassName("biz-doc-undo")[0].id = "biz_doc_undobtn";
  737. document.getElementsByClassName("biz-doc-redo")[0].id = "biz_doc_redobtn";
  738. this.docBase.bottomtoolbartext.insertBefore(this.util.createElement('div', 'class', 'biz-doc-toobarspace'), document.getElementsByClassName('biz-doc-bottomtoolbar-text')[0].childNodes[0]);
  739. this.docBase.bottomtoolbartext.insertBefore(this.util.createElement('div', 'class', 'biz-doc-toobarspace'), document.getElementsByClassName('biz-doc-bottomtoolbar-text')[0].childNodes[2]);
  740. document.getElementsByClassName('biz-doc-bottomtoolbar-indent')[0].insertBefore(this.util.createElement('div', 'class', 'biz-doc-toobarspace'), document.getElementsByClassName('biz-doc-bottomtoolbar-indent')[0].childNodes[0]);
  741. document.getElementById('biz_doc_undobtn').insertBefore(this.util.createElement('div', 'class', 'biz-doc-toobarspace'), document.getElementById('biz_doc_undobtn').childNodes[0]);
  742. document.getElementById('DocumentViewer_editor_font_properties_increaseIndent').after(this.util.createElement('div', 'class', 'biz-doc-toobarspace'));
  743. document.getElementById('DocumentViewer_editor_font_properties_clearFormat').after(this.util.createElement('div', 'class', 'biz-doc-toobarspace'));
  744. document.getElementById('DocumentViewer_editor_font_properties_fontSizeDiv').after(this.util.createElement('div', 'class', 'e-toolbar-item e-separator biz-doc-seperator'));
  745. document.getElementById('DocumentViewer_editor_font_properties_rightDiv').after(this.util.createElement('div', 'class', 'e-toolbar-item e-separator biz-doc-seperator'));
  746. document.getElementById('DocumentViewer_editor_font_properties_styleDiv').after(this.util.createElement('div', 'class', 'e-toolbar-item e-separator biz-doc-seperator'));
  747. document.getElementById('DocumentViewer_editor_font_properties_lineHeight').after(this.util.createElement('div', 'class', 'e-toolbar-item e-separator biz-doc-seperator'));
  748. document.getElementById('DocumentViewer_editor_font_properties_color').getElementsByClassName("e-colorpicker-wrapper")[0].after(this.util.createElement('div', 'class', 'e-toolbar-item e-separator biz-doc-seperator'));
  749. this.util.appendChildren('biz-doc-bottomtoolbar-undoredo', 0, this.util.createElement("button", 'class', 'biz-doc-undo e-disabled e-btn e-lib'));
  750. this.util.appendChildren('biz-doc-undo', 0, this.util.createElement("span", 'class', 'e-icons e-icon-left biz-doc-undo-icon e-btn-icon'));
  751. this.util.appendChildren('biz-doc-bottomtoolbar-undoredo', 0, this.util.createElement("button", 'class', 'biz-doc-redo e-disabled e-btn e-lib'));
  752. this.util.appendChildren('biz-doc-redo', 0, this.util.createElement("span", 'class', 'e-icons e-icon-left biz-doc-redo-icon e-btn-icon'));
  753. this.docBase.toolbarWidth = document.querySelector('.biz-doc-bottomtoolbar-undoredo').getBoundingClientRect().width + document.querySelector('.biz-doc-bottomtoolbar-text').getBoundingClientRect().width + document.querySelector('.biz-doc-bottomtoolbar-paragraph').getBoundingClientRect().width + document.querySelector('.biz-doc-bottomtoolbar-indent').getBoundingClientRect().width;
  754. }
  755. createResponsiveToolbar() {
  756. var instance = this;
  757. document.getElementsByClassName('biz-doc-bottomtoolbar')[0].insertBefore(this.util.createElement('div', 'class', 'leftarrow-wrapper'), document.getElementsByClassName('biz-doc-bottomtoolbar')[0].childNodes[0]);
  758. document.getElementsByClassName('biz-doc-bottomtoolbar')[0].appendChild(this.util.createElement('div', 'class', 'rightarrow-wrapper'));
  759. document.getElementsByClassName('leftarrow-wrapper')[0].appendChild(this.util.createElement('button', 'id', 'leftarrow-btn'));
  760. document.getElementsByClassName('rightarrow-wrapper')[0].appendChild(this.util.createElement('button', 'id', 'rightarrow-btn'));
  761. this.docBase.rightArrowBtn = document.getElementById('rightarrow-btn');
  762. this.docBase.leftArrowBtn = document.getElementById('leftarrow-btn');
  763. this.docBase.leftArrowWrapper = document.getElementsByClassName('leftarrow-wrapper')[0];
  764. this.docBase.rightArrowWrapper = document.getElementsByClassName('rightarrow-wrapper')[0];
  765. this.docBase.toolbarWrapper = document.getElementsByClassName('biz-doc-toolbar-wrapper')[0];
  766. this.docBase.rightArrowBtn.classList.add('e-icons');
  767. this.docBase.rightArrowBtn.classList.add('biz_right_arrow');
  768. this.docBase.leftArrowBtn.classList.add('e-icons');
  769. this.docBase.leftArrowBtn.classList.add('biz_left_arrow');
  770. this.docBase.leftArrowBtn.classList.add('e-disabled');
  771. this.docBase.leftArrowWrapper.style.display = 'none';
  772. this.docBase.rightArrowWrapper.style.display = 'none';
  773. this.setToolbarWidth();
  774. this.docBase.rightArrowBtn.addEventListener('click', () => {
  775. this.docBase.toolbarWrapper.scrollBy({
  776. top: 0,
  777. left: 300,
  778. behavior: "smooth"
  779. });
  780. this.docBase.leftArrowBtn.classList.remove('e-disabled');
  781. });
  782. this.docBase.leftArrowBtn.addEventListener('click', () => {
  783. this.docBase.toolbarWrapper.scrollBy({
  784. top: 0,
  785. left: -300,
  786. behavior: "smooth"
  787. });
  788. this.docBase.rightArrowBtn.classList.remove('e-disabled');
  789. });
  790. this.docBase.toolbarWrapper.addEventListener('scroll', () => {
  791. if (this.docBase.toolbarWrapper.scrollWidth - this.docBase.toolbarWrapper.scrollLeft - this.docBase.toolbarWrapper.clientWidth < 1) {
  792. this.docBase.rightArrowBtn.classList.add("e-disabled");
  793. }
  794. else if (this.docBase.toolbarWrapper.scrollLeft == 0) {
  795. this.docBase.leftArrowBtn.classList.add("e-disabled");
  796. }
  797. });
  798. window.addEventListener('resize', () => {
  799. this.setToolbarWidth();
  800. });
  801. }
  802. setDisplay(value) {
  803. this.docBase.leftArrowWrapper.style.display = value;
  804. this.docBase.rightArrowWrapper.style.display = value;
  805. }
  806. getBtnsWidth() {
  807. return document.getElementsByClassName('leftarrow-wrapper')[0].getBoundingClientRect().width + document.getElementsByClassName('rightarrow-wrapper')[0].getBoundingClientRect().width;
  808. }
  809. setToolbarWidth() {
  810. if (window.innerWidth <= this.docBase.toolbarWidth + this.getBtnsWidth()) {
  811. this.setDisplay('');
  812. this.docBase.toolbarWrapper.style.width = 'calc(100% - 72px)';
  813. }
  814. else {
  815. this.setDisplay('none');
  816. this.docBase.toolbarWrapper.style.width = this.docBase.toolbarWidth + 3 + 'px';
  817. }
  818. }
  819. static Instance() {
  820. if (this.instance === undefined) {
  821. this.instance = new Ribbon();
  822. }
  823. return this.instance;
  824. }
  825. }
  826. DocEditor.Ribbon = Ribbon;
  827. })(DocEditor = Components.DocEditor || (Components.DocEditor = {}));
  828. })(Components = Collaboration.Components || (Collaboration.Components = {}));
  829. })(Collaboration = Apps.Collaboration || (Apps.Collaboration = {}));
  830. })(Apps = Unibase.Apps || (Unibase.Apps = {}));
  831. })(Unibase || (Unibase = {}));