From 5e365721f80fdbd6eeff3beab31c8fb19bccbae0 Mon Sep 17 00:00:00 2001 From: halaya Date: Tue, 18 Mar 2025 15:39:13 +0100 Subject: [PATCH 1/2] Task-77677: Create FB meeds-qaui and update projects versions/dependencies --- apps/pom.xml | 2 +- apps/portlet-documents/pom.xml | 2 +- apps/portlet-editors/pom.xml | 2 +- apps/portlet-transferrules/pom.xml | 2 +- apps/resources-wcm/pom.xml | 2 +- core/connector/pom.xml | 2 +- core/core-configuration/pom.xml | 2 +- core/pom.xml | 2 +- core/search/pom.xml | 2 +- core/services/pom.xml | 2 +- core/viewer/pom.xml | 2 +- ecm-wcm-extension/pom.xml | 2 +- ecms-packaging/pom.xml | 2 +- ecms-social-integration/pom.xml | 2 +- pom.xml | 4 ++-- testsuite/pom.xml | 2 +- testsuite/test/pom.xml | 2 +- 17 files changed, 18 insertions(+), 18 deletions(-) diff --git a/apps/pom.xml b/apps/pom.xml index 6d4ff34acb4..857f447b383 100644 --- a/apps/pom.xml +++ b/apps/pom.xml @@ -4,7 +4,7 @@ ecms org.exoplatform.ecms - 7.1.x-SNAPSHOT + 7.1.x-meeds-qaui-SNAPSHOT ecms-apps pom diff --git a/apps/portlet-documents/pom.xml b/apps/portlet-documents/pom.xml index e8455237770..99148f2bd9d 100644 --- a/apps/portlet-documents/pom.xml +++ b/apps/portlet-documents/pom.xml @@ -25,7 +25,7 @@ ecms-apps org.exoplatform.ecms - 7.1.x-SNAPSHOT + 7.1.x-meeds-qaui-SNAPSHOT ecms-apps-portlet-documents war diff --git a/apps/portlet-editors/pom.xml b/apps/portlet-editors/pom.xml index e0538e8265c..33c881f839f 100644 --- a/apps/portlet-editors/pom.xml +++ b/apps/portlet-editors/pom.xml @@ -25,7 +25,7 @@ ecms-apps org.exoplatform.ecms - 7.1.x-SNAPSHOT + 7.1.x-meeds-qaui-SNAPSHOT ecms-apps-portlet-editors war diff --git a/apps/portlet-transferrules/pom.xml b/apps/portlet-transferrules/pom.xml index c05810fd013..e03a6b51825 100644 --- a/apps/portlet-transferrules/pom.xml +++ b/apps/portlet-transferrules/pom.xml @@ -25,7 +25,7 @@ ecms-apps org.exoplatform.ecms - 7.1.x-SNAPSHOT + 7.1.x-meeds-qaui-SNAPSHOT ecms-apps-portlet-transferrules war diff --git a/apps/resources-wcm/pom.xml b/apps/resources-wcm/pom.xml index 8e4d68cbee5..9576266c0d0 100644 --- a/apps/resources-wcm/pom.xml +++ b/apps/resources-wcm/pom.xml @@ -4,7 +4,7 @@ ecms-apps org.exoplatform.ecms - 7.1.x-SNAPSHOT + 7.1.x-meeds-qaui-SNAPSHOT ecms-apps-resources-wcm war diff --git a/core/connector/pom.xml b/core/connector/pom.xml index 0220b00805d..7d8d8ac620b 100644 --- a/core/connector/pom.xml +++ b/core/connector/pom.xml @@ -5,7 +5,7 @@ ecms-core org.exoplatform.ecms - 7.1.x-SNAPSHOT + 7.1.x-meeds-qaui-SNAPSHOT ecms-core-connector jar diff --git a/core/core-configuration/pom.xml b/core/core-configuration/pom.xml index 9646c578ce7..9ec56abaf73 100644 --- a/core/core-configuration/pom.xml +++ b/core/core-configuration/pom.xml @@ -4,7 +4,7 @@ ecms-core org.exoplatform.ecms - 7.1.x-SNAPSHOT + 7.1.x-meeds-qaui-SNAPSHOT ecms-core-webapp war diff --git a/core/pom.xml b/core/pom.xml index 0ceeb0f2c80..acd72daf214 100644 --- a/core/pom.xml +++ b/core/pom.xml @@ -4,7 +4,7 @@ ecms org.exoplatform.ecms - 7.1.x-SNAPSHOT + 7.1.x-meeds-qaui-SNAPSHOT ecms-core pom diff --git a/core/search/pom.xml b/core/search/pom.xml index 56cfa9812bb..7dbfe2509d9 100644 --- a/core/search/pom.xml +++ b/core/search/pom.xml @@ -4,7 +4,7 @@ ecms-core org.exoplatform.ecms - 7.1.x-SNAPSHOT + 7.1.x-meeds-qaui-SNAPSHOT ecms-core-search eXo PLF:: WCM Search Service diff --git a/core/services/pom.xml b/core/services/pom.xml index 6f854eb1049..bcec2a716fc 100644 --- a/core/services/pom.xml +++ b/core/services/pom.xml @@ -4,7 +4,7 @@ ecms-core org.exoplatform.ecms - 7.1.x-SNAPSHOT + 7.1.x-meeds-qaui-SNAPSHOT ecms-core-services eXo PLF:: CMS Service diff --git a/core/viewer/pom.xml b/core/viewer/pom.xml index ae90d63a72e..249f00151b6 100644 --- a/core/viewer/pom.xml +++ b/core/viewer/pom.xml @@ -4,7 +4,7 @@ ecms-core org.exoplatform.ecms - 7.1.x-SNAPSHOT + 7.1.x-meeds-qaui-SNAPSHOT ecms-core-viewer eXo PLF:: DMS Document Viewer diff --git a/ecm-wcm-extension/pom.xml b/ecm-wcm-extension/pom.xml index 4c240388b0d..b1ab0e34343 100644 --- a/ecm-wcm-extension/pom.xml +++ b/ecm-wcm-extension/pom.xml @@ -4,7 +4,7 @@ ecms org.exoplatform.ecms - 7.1.x-SNAPSHOT + 7.1.x-meeds-qaui-SNAPSHOT ecm-wcm-extension war diff --git a/ecms-packaging/pom.xml b/ecms-packaging/pom.xml index 932801a9a8a..4b8d63b7e45 100644 --- a/ecms-packaging/pom.xml +++ b/ecms-packaging/pom.xml @@ -24,7 +24,7 @@ org.exoplatform.ecms ecms - 7.1.x-SNAPSHOT + 7.1.x-meeds-qaui-SNAPSHOT ecms-packaging pom diff --git a/ecms-social-integration/pom.xml b/ecms-social-integration/pom.xml index 07c7a857bc0..247299f581b 100644 --- a/ecms-social-integration/pom.xml +++ b/ecms-social-integration/pom.xml @@ -4,7 +4,7 @@ org.exoplatform.ecms ecms - 7.1.x-SNAPSHOT + 7.1.x-meeds-qaui-SNAPSHOT ecms-social-integration jar diff --git a/pom.xml b/pom.xml index ff2553ac02c..ff1c10a97b2 100644 --- a/pom.xml +++ b/pom.xml @@ -9,7 +9,7 @@ org.exoplatform.ecms ecms - 7.1.x-SNAPSHOT + 7.1.x-meeds-qaui-SNAPSHOT pom eXo PLF:: ECM Suite eXo Entreprise Content Management Suite @@ -39,7 +39,7 @@ - 7.1.x-SNAPSHOT + 7.1.x-meeds-qaui-SNAPSHOT diff --git a/testsuite/pom.xml b/testsuite/pom.xml index 81f03240c63..9e6b1a33994 100644 --- a/testsuite/pom.xml +++ b/testsuite/pom.xml @@ -4,7 +4,7 @@ ecms org.exoplatform.ecms - 7.1.x-SNAPSHOT + 7.1.x-meeds-qaui-SNAPSHOT ecms-testsuite pom diff --git a/testsuite/test/pom.xml b/testsuite/test/pom.xml index bdc7c635a68..59096856689 100644 --- a/testsuite/test/pom.xml +++ b/testsuite/test/pom.xml @@ -4,7 +4,7 @@ ecms-testsuite org.exoplatform.ecms - 7.1.x-SNAPSHOT + 7.1.x-meeds-qaui-SNAPSHOT ecms-testsuite-test eXo PLF:: ECMS Testing From d2a19d2671995700c55c348e43049642747f8f69 Mon Sep 17 00:00:00 2001 From: Boubaker Khanfir Date: Tue, 26 Aug 2025 18:01:09 +0100 Subject: [PATCH 2/2] feat: Drop WebUI Portlet Framework - MEED-9616 - Meeds-io/meeds#3321 (#2515) This change will drop the usage of WebUI Portlet Components and its Style and JS dependencies. --- apps/portlet-documents/.eslintrc.json | 3 - .../main/webapp/WEB-INF/gatein-resources.xml | 6 - apps/resources-wcm/pom.xml | 1 - .../main/webapp/WEB-INF/gatein-resources.xml | 174 -- .../webapp/javascript/eXo/ecm/ECMUtils.js | 1829 ----------------- .../javascript/eXo/ecm/document-preview.js | 1372 ------------- .../src/main/webapp/javascript/eXo/wcm/ECM.js | 5 - .../eXo/wcm/backoffice/private/WCMUtils.js | 928 --------- .../backoffice/private/bootstrap-typeahead.js | 346 ---- .../public/OpenDocumentInOffice.js | 241 --- .../portlets/cloudStorage/cloud-storage.less | 47 - .../ecms/skin/UIDocumentPreview/Style.less | 1345 ------------ .../ecms/skin/ecms-resources-wcmskin.less | 1 - .../exoplatform/services/wcm/utils/Utils.java | 2 - .../ecms-core-service-test-configuration.xml | 5 - .../conf/standalone/test-configuration.xml | 5 - .../filters/AbstractCloudDriveNodeFilter.java | 205 -- .../ecm/webui/filters/CloudFileFilter.java | 120 -- .../webui/viewer/AbstractCloudFileViewer.java | 144 -- .../ecm/webui/viewer/CloudFileViewer.java | 44 - .../webui/viewer/DefaultCloudFileViewer.java | 95 - .../ecm/webui/viewer/FlashViewer.java | 33 - .../ecm/webui/viewer/HTML5VideoViewer.java | 33 - .../ecm/webui/viewer/ImageViewer.java | 34 - .../ecm/webui/viewer/MpegVideoViewer.java | 33 - .../ecm/webui/viewer/PDFViewer.java | 436 ---- .../ecm/webui/viewer/TextViewer.java | 56 - .../ecm/webui/viewer/VideoAudioViewer.java | 95 - .../clouddrives/webui/BaseCloudDriveForm.java | 60 - .../webui/viewer/AbstractFileForm.java | 127 -- .../clouddrives/webui/viewer/FlashViewer.java | 38 - .../webui/viewer/H264VideoViewer.java | 37 - .../clouddrives/webui/viewer/ImageViewer.java | 30 - .../webui/viewer/MpegVideoViewer.java | 37 - .../clouddrives/webui/viewer/PDFViewer.java | 502 ----- .../clouddrives/webui/viewer/TextViewer.java | 94 - .../webui/viewer/VideoAudioViewer.java | 37 - .../dms/dms-clouddrives-configuration.xml | 33 - 38 files changed, 8633 deletions(-) delete mode 100644 apps/resources-wcm/src/main/webapp/javascript/eXo/ecm/ECMUtils.js delete mode 100644 apps/resources-wcm/src/main/webapp/javascript/eXo/ecm/document-preview.js delete mode 100644 apps/resources-wcm/src/main/webapp/javascript/eXo/wcm/ECM.js delete mode 100644 apps/resources-wcm/src/main/webapp/javascript/eXo/wcm/backoffice/private/WCMUtils.js delete mode 100644 apps/resources-wcm/src/main/webapp/javascript/eXo/wcm/backoffice/private/bootstrap-typeahead.js delete mode 100644 apps/resources-wcm/src/main/webapp/javascript/eXo/wcm/frontoffice/public/OpenDocumentInOffice.js delete mode 100644 apps/resources-wcm/src/main/webapp/skin/less/ecms/portlets/cloudStorage/cloud-storage.less delete mode 100644 apps/resources-wcm/src/main/webapp/skin/less/ecms/skin/UIDocumentPreview/Style.less delete mode 100644 core/viewer/src/main/java/org/exoplatform/ecm/webui/filters/AbstractCloudDriveNodeFilter.java delete mode 100644 core/viewer/src/main/java/org/exoplatform/ecm/webui/filters/CloudFileFilter.java delete mode 100644 core/viewer/src/main/java/org/exoplatform/ecm/webui/viewer/AbstractCloudFileViewer.java delete mode 100644 core/viewer/src/main/java/org/exoplatform/ecm/webui/viewer/CloudFileViewer.java delete mode 100644 core/viewer/src/main/java/org/exoplatform/ecm/webui/viewer/DefaultCloudFileViewer.java delete mode 100644 core/viewer/src/main/java/org/exoplatform/ecm/webui/viewer/FlashViewer.java delete mode 100644 core/viewer/src/main/java/org/exoplatform/ecm/webui/viewer/HTML5VideoViewer.java delete mode 100644 core/viewer/src/main/java/org/exoplatform/ecm/webui/viewer/ImageViewer.java delete mode 100644 core/viewer/src/main/java/org/exoplatform/ecm/webui/viewer/MpegVideoViewer.java delete mode 100644 core/viewer/src/main/java/org/exoplatform/ecm/webui/viewer/PDFViewer.java delete mode 100644 core/viewer/src/main/java/org/exoplatform/ecm/webui/viewer/TextViewer.java delete mode 100644 core/viewer/src/main/java/org/exoplatform/ecm/webui/viewer/VideoAudioViewer.java delete mode 100644 core/viewer/src/main/java/org/exoplatform/services/cms/clouddrives/webui/BaseCloudDriveForm.java delete mode 100644 core/viewer/src/main/java/org/exoplatform/services/cms/clouddrives/webui/viewer/AbstractFileForm.java delete mode 100644 core/viewer/src/main/java/org/exoplatform/services/cms/clouddrives/webui/viewer/FlashViewer.java delete mode 100644 core/viewer/src/main/java/org/exoplatform/services/cms/clouddrives/webui/viewer/H264VideoViewer.java delete mode 100644 core/viewer/src/main/java/org/exoplatform/services/cms/clouddrives/webui/viewer/ImageViewer.java delete mode 100644 core/viewer/src/main/java/org/exoplatform/services/cms/clouddrives/webui/viewer/MpegVideoViewer.java delete mode 100644 core/viewer/src/main/java/org/exoplatform/services/cms/clouddrives/webui/viewer/PDFViewer.java delete mode 100644 core/viewer/src/main/java/org/exoplatform/services/cms/clouddrives/webui/viewer/TextViewer.java delete mode 100644 core/viewer/src/main/java/org/exoplatform/services/cms/clouddrives/webui/viewer/VideoAudioViewer.java diff --git a/apps/portlet-documents/.eslintrc.json b/apps/portlet-documents/.eslintrc.json index 7056dbcb10d..4d0c36f8799 100644 --- a/apps/portlet-documents/.eslintrc.json +++ b/apps/portlet-documents/.eslintrc.json @@ -2,9 +2,6 @@ "extends": [ "eslint-config-meedsio" ], - "globals": { - "documentPreview": true - }, "rules": { "vue/multi-word-component-names": "off", "vue/no-mutating-props": "warn" diff --git a/apps/portlet-documents/src/main/webapp/WEB-INF/gatein-resources.xml b/apps/portlet-documents/src/main/webapp/WEB-INF/gatein-resources.xml index dc7535339d0..852057addbc 100644 --- a/apps/portlet-documents/src/main/webapp/WEB-INF/gatein-resources.xml +++ b/apps/portlet-documents/src/main/webapp/WEB-INF/gatein-resources.xml @@ -54,9 +54,6 @@ extensionRegistry - - documentPreview - jquery @@ -80,9 +77,6 @@ eXoVueI18n - - documentPreview - jquery $ diff --git a/apps/resources-wcm/pom.xml b/apps/resources-wcm/pom.xml index 9576266c0d0..f21d0e22489 100644 --- a/apps/resources-wcm/pom.xml +++ b/apps/resources-wcm/pom.xml @@ -75,7 +75,6 @@ ecms/skin/ecms-resources-wcmskin.less ecms/portlets/editors/editors-admin.less ecms/portlets/transferRules/transfer-rules.less - ecms/portlets/cloudStorage/cloud-storage.less ecms/portlets/documents/documents.less ecms/portlets/attachments/attachmentsApp.less diff --git a/apps/resources-wcm/src/main/webapp/WEB-INF/gatein-resources.xml b/apps/resources-wcm/src/main/webapp/WEB-INF/gatein-resources.xml index 5b543459dc9..6a4744a04b0 100644 --- a/apps/resources-wcm/src/main/webapp/WEB-INF/gatein-resources.xml +++ b/apps/resources-wcm/src/main/webapp/WEB-INF/gatein-resources.xml @@ -59,78 +59,6 @@ true - - - clouddrives - cloudStoragePortlet - Enterprise - /skin/css/ecms/portlets/cloudStorage/cloud-storage.css - true - - - - - - wcm_bts_typeahead - - - jquery - - - - - - ecm-bootstrap - ecm_bootstrap - - - bts_button - - - bts_collapse - - - bts_dropdown - - - bts_tab - - - bts_tooltip - - - wcm_bts_typeahead - - - - - wcm-utils - wcm_utils - - - jquery - gj - - - base - - - bts_popover - - - flowplayer - - openDocumentInOffice - openDocumentInOffice - - - bts_modal - - - jquery - gj - - - - - documentPreview - de - en - fr - ru - vi - es-ES - sv-SE - ja - ar - ar-OM - pt-BR - pt-PT - it - tr - zh-CN - fi - lt - no - zh-TW - cs - uk - fa - el - ro - pl - ca - he - hu - nl - sl - sq - in - fil - - - jquery - - - wcm-utils - - - mentionsPlugin - - - mentionsLib - mentions - - - suggester - - - xss-utils - - - openDocumentInOffice - - - editorbuttons - - - bts_dropdown - - - - - ecm-utils - ecm_utils - - - ecm-bootstrap - - - jquery - gj - - - webui-ext - - - jQueryUI12 jqueryUI diff --git a/apps/resources-wcm/src/main/webapp/javascript/eXo/ecm/ECMUtils.js b/apps/resources-wcm/src/main/webapp/javascript/eXo/ecm/ECMUtils.js deleted file mode 100644 index da12fd6d0b4..00000000000 --- a/apps/resources-wcm/src/main/webapp/javascript/eXo/ecm/ECMUtils.js +++ /dev/null @@ -1,1829 +0,0 @@ -(function(gj, ecm_bootstrap, webuiExt) { - function ECMUtils() { - this.previewThumbnailAction; - var Self = this; - var showSideBar = true; - var editFullScreen = false; - //set private property; - var Browser = eXo.core.Browser; - Self.waitContainerRetry = 0; - Self.waitContainerRetryMax = 200; - Self.MiniumLeftContainerWidth = 240; - Self.MiniumRightContainerWidth = 251; - Self.waitInterval = 25; - Self.UIBrokenCheckingInterval = 150; - Self.driveActionSize = 0; - Self.undo = "Undo"; - window.UIBrokenCheckingHandler = null; - var RightClick = eXo.webui.UIRightClickPopupMenu; - if (!RightClick) { - RightClick = eXo.webui.UIRightClickPopupMenu; - } - // DOM.hideElements(); - ECMUtils.prototype.popupArray = []; - ECMUtils.prototype.voteRate = 0; - ECMUtils.prototype.init = function (portletId) { - gj(window).resize(function() { - Self.loadContainerWidth(); - }); - var portlet = document.getElementById(portletId); - if (!portlet) return; - RightClick.disableContextMenu(portletId); - portlet.onclick = function (event) { - eXo.ecm.ECMUtils.closeAllPopup(); - } - portlet.onkeydown = function (event) { - eXo.ecm.ECMUtils.closeAllPopup(); - } - if (document.getElementById("UIPageDesktop")) { - Self.fixHeight(portletId); - var uiPageDeskTop = document.getElementById("UIPageDesktop"); - var uiJCRExplorers = gj(uiPageDeskTop).find('div.UIJCRExplorer'); - if (uiJCRExplorers.length) { - for (var i = 0; i < uiJCRExplorers.length; i++) { - var uiResizeBlock = gj(uiJCRExplorers[i]).parents(".uiResizableBlock:first")[0]; - if (uiResizeBlock) uiResizeBlock.style.overflow = "hidden"; - } - } - } else { - Self.controlLayout(portletId); - eXo.core.Browser.addOnResizeCallback('controlLayout', - - function () { - eXo.ecm.ECMUtils.controlLayout(portletId); - }); - } - }; - - - /** - * @function getCookie - * @return return a saved cookie with given name or return null if that cookie's field haven't been saved - * @author vinh_nguyen@exoplatform.com - */ - ECMUtils.prototype.getCookie = function (c_name) { - var i, x, y, ARRcookies = document.cookie.split(";"); - for (i = 0; i < ARRcookies.length; i++) { - x = ARRcookies[i].substr(0, ARRcookies[i].indexOf("=")); - y = ARRcookies[i].substr(ARRcookies[i].indexOf("=") + 1); - x = x.replace(/^\s+|\s+$/g, ""); - if (x == c_name) { - return unescape(y); - } - } - return null; - } - - /** - * @function setCookie - * @return saved cookie with given name - * @author vinh_nguyen@exoplatform.com - */ - ECMUtils.prototype.setCookie = function (c_name, value, exdays) { - var exdate = new Date(); - exdate.setDate(exdate.getDate() + exdays); - var c_value = escape(value) + ((exdays == null) ? "" : "; expires=" + exdate.toUTCString()); - document.cookie = c_name + "=" + c_value; - } - ECMUtils.prototype.fixPDFViewerHeight = function() { - if (gj('#outerContainer').is(':visible') && gj('#UIJCRExplorer').length > 0) { - gj('#outerContainer') - .css('min-height', - 'calc(100vh - ' + (gj('#outerContainer').offset().top + 60) + 'px)'); - } - } - ECMUtils.prototype.fixHeight = function (portletId) { - var portlet = document.getElementById(portletId); - var refElement = gj(portlet).parents(".UIApplication:first")[0]; - if (!refElement) return; - - // 30/06/2009 - //Recalculate height of UIResizableBlock in the UISideBarContainer - //var delta = parseInt(refElement.style.height) - portlet.offsetHeight; - - var uiControl = document.getElementById('UIControl'); - var uiSideBar = document.getElementById('UISideBar'); - if (!uiControl || !uiSideBar) return; - var uiSideBarControl = gj(uiSideBar).find('div.UISideBarControl:first')[0]; - if (!uiSideBarControl) return; - var deltaH = refElement.offsetHeight - uiControl.offsetHeight - uiSideBarControl.offsetHeight; - var resizeObj = gj(portlet).find('div.uiResizableBlock'); - if (resizeObj.length) { - for (var i = 0; i < resizeObj.length; i++) { - resizeObj[i].style.display = 'block'; - resizeObj[i].style.height = (resizeObj[i].offsetHeight + deltaH) + "px"; - } - } - }; - - ECMUtils.prototype.controlLayout = function (portletId) { - var portlet = document.getElementById(portletId); - if (!Self.uiWorkingArea) return; - var delta = document.body.scrollHeight - gj(window).height(); - if (delta < 0) { - var resizeObj = gj(portlet).find('div.uiResizableBlock'); - if (resizeObj.length) { - for (var i = 0; i < resizeObj.length; i++) { - resizeObj[i].style.height = resizeObj[i].offsetHeight - delta + "px"; - } - } - } - eXo.core.Browser.addOnResizeCallback('controlLayout', function () { - eXo.ecm.ECMUtils.controlLayout(portletId) - }); - }; - - ECMUtils.prototype.clickLeftMouse = function (event, clickedElement, position, option) { - var event = event || window.event; - event.cancelBubble = true; - var popupSelector = gj(clickedElement).parents(".uiPopupSelector:first")[0]; - var showBlock = gj(popupSelector).find("div.uiSelectContent")[0]; - var inputAddress = gj(popupSelector).find("input#address")[0]; - if (option == 1) { - gj(showBlock).css("width", inputAddress.offsetWidth + "px"); - //showBlock.style.width = (popupSelector.offsetWidth - 2) + "px"; - } - if (showBlock.style.display == "block") { - eXo.webui.UIPopup.hide(showBlock); - return; - } - eXo.webui.UIPopup.show(showBlock); - showBlock.onmousedown = function (event) { - var event = event || window.event; - event.cancelBubble = true; - } - showBlock.onkeydown = function (event) { - var event = event || window.event; - event.cancelBubble = true; - } - Self.popupArray.push(showBlock); - showBlock.style.top = popupSelector.offsetHeight + "px"; - }; - - ECMUtils.prototype.closeAllPopup = function (exceptElement) { - for (var i = 0; i < Self.popupArray.length; i++) { - if (Self.popupArray[i] == exceptElement) continue; - var moreParent = gj(Self.popupArray[i]).parents(".MoreContainerActivated:first")[0]; - if (moreParent) gj(moreParent).removeClass("MoreContainerActivated"); - Self.popupArray[i].style.display = "none"; - } - Self.popupArray = []; - }; - - ECMUtils.prototype.closeASPopup = function () { - var closeBtn = gj("#UIUserActivityStreamPortlet #UISocialPopupWindow .popupHeader .uiIconClose"); - if(closeBtn!==undefined) closeBtn.trigger("click"); - gj("body").removeClass("modal-open"); - }; - - - ECMUtils.prototype.initVote = function (voteId, rate) { - var vote = document.getElementById(voteId); - voteRate = vote.rate = rate = parseInt(rate); - var optsContainer = gj(vote).find("div.optionsContainer:first")[0]; - var options = gj(optsContainer).children("div"); - for (var i = 0; i < options.length; i++) { - options[i].onmouseover = Self.overVote; - if (i < rate) options[i].className = "uiIconRatedVote"; - } - - vote.onmouseover = function () { - var optsCon = gj(this).find("div.optionsContainer:first")[0]; - var opts = gj(optsCon).children("div"); - for (var j = 0; j < opts.length; j++) { - if (j < this.rate && (opts[j] == "uiIconNormalVote" || opts[j].className == "uiIconOverVote")) opts[j].className = "uiIconRatedVote"; - if (j >= this.rate && (opts[j] == "uiIconRatedVote" || opts[j].className == "uiIconOverVote")) opts[j].className = "uiIconNormalVote"; - } - } - optsContainer.onmouseover = function (event) { - var event = event || window.event; - event.cancelBubble = true; - } - }; - - ECMUtils.prototype.overVote = function (event) { - var optionsContainer = gj(this).parents(".optionsContainer:first")[0]; - var opts = gj(optionsContainer).children("div"); - var i = opts.length; - for (--i; i >= 0; i--) { - if (opts[i] == this) break; - if (i < voteRate && (opts[i].className=="uiIconNormalVote" || opts[i].className == "uiIconOverVote")) opts[i].className = "uiIconRatedVote"; - else if (i >= voteRate && (opts[i].className == "uiIconRatedVote" || opts[i].className == "uiIconOverVote")) opts[i].className = "uiIconNormalVote"; - } - if (opts[i].className == "uiIconOverVote") return; - for (; i >= 0; i--) { - if (opts[i].className == "uiIconNormalVote" || opts[i].className == "uiIconRatedVote") opts[i].className = "uiIconOverVote"; - } - }; - - ECMUtils.prototype.showHideExtendedView = function (event) { - var elemt = document.getElementById("ListExtendedView"); - event = event || window.event; - event.cancelBubble = true; - if (elemt.style.display == 'none') { - elemt.style.display = 'block'; - } else { - elemt.style.display = 'none'; - } - } - - ECMUtils.prototype.showHideComponent = function (elemtClicked) { - - var nodeReference = gj(elemtClicked).parents(".ShowHideContainer:first")[0]; - var elemt = gj(nodeReference).find("div.ShowHideComponent:first")[0]; - - if (elemt.style.display == 'none') { - elemtClicked.childNodes[0].style.display = 'none'; - elemtClicked.childNodes[1].style.display = 'block'; - elemt.style.display = 'block'; - eXo.ecm.ECMUtils.setScrollBar(); - } else { - elemtClicked.childNodes[0].style.display = 'block'; - elemtClicked.childNodes[1].style.display = 'none'; - elemt.style.display = 'none'; - } - }; - - ECMUtils.prototype.setScrollBar = function () { - try { - var parent = document.getElementById('TabContainerParent'); - if (parent != null) { - var elements = gj(parent).find("div.UITabContent"); - if (elements != null) { - for (i = 0; i < elements.length; i++) { - var obj = elements[i]; - if (obj.style.display != "none") { - var height = obj.offsetHeight; - if (height > 430) { - //obj.style.height="470px"; - obj.style.height = Self.uiWorkingArea.offsetHeight - 50 + "px"; - obj.style.overflow = "auto"; - } - } - } - } - } - } catch (err) {} - } - - ECMUtils.prototype.showHideContentOnRow = function (elemtClicked) { - - var nodeReference = gj(elemtClicked).parents(".Text:first")[0]; - var elemt = gj(nodeReference).find("div.ShowHideComponent:first")[0]; - var shortContent = gj(elemt).find("div.ShortContentPermission:first")[0]; - var fullContent = gj(elemt).find("div.FullContentPermission:first")[0]; - - if (shortContent.style.display == 'none') { - fullContent.style.display = 'none'; - shortContent.style.display = 'block'; - } else { - fullContent.style.display = 'block'; - shortContent.style.display = 'none'; - } - }; - - ECMUtils.prototype.isEventTarget = function (element, e) { - if (window.event) e = window.event; - var srcEl = e.srcElement ? e.srcElement : e.target; - if (element == srcEl) { - return true; - } - return false; - }; - - ECMUtils.prototype.focusCurrentNodeInTree = function (id) { - var element = document.getElementById(id); - var uiTreeExplorer = document.getElementById("UITreeExplorer"); - if (!element || !uiTreeExplorer) return; - var top = element.offsetTop; - uiTreeExplorer.scrollTop = (top - uiTreeExplorer.offsetTop); - }; - - ECMUtils.prototype.collapseExpand = function (element) { - var node = element.parentNode; - var subGroup = gj(node).children("ul.nodeGroup:first")[0]; - if (!subGroup) return false; - if (subGroup.style.display == "none") { - if (element.className.match("expandIcon")) element.className = element.className.replace("expandIcon", "collapseIcon"); - subGroup.style.display = "block"; - } else { - if (element.className.match("collapseIcon")) element.className = element.className.replace("collapseIcon", "expandIcon"); - subGroup.style.display = "none"; - } - return true; - }; - - ECMUtils.prototype.collapseExpandPart = function (element) { - var node = element.parentNode; - var subGroup1 = gj(node).children("div.NodeGroup1:first")[0]; - var subGroup2 = gj(node).children("div.NodeGroup2:first")[0]; - if (subGroup1.style.display == "none") { - if (element.className == "collapseIcon") element.className = "expandIcon"; - subGroup1.style.display = "block"; - subGroup2.style.display = "none"; - } else { - if (element.className == "expandIcon") element.className = "collapseIcon"; - subGroup1.style.display = "none"; - subGroup2.style.display = "block"; - } - return true; - }; - - ECMUtils.prototype.filterValue = function (frmId) { - var form = document.getElementById(frmId); - if (eXo.core.Browser.browserType == "ie") { - var text = document.createTextNode(form['tempSel'].innerHTML); - form['result'].appendChild(text); - } else { - form['result'].innerHTML = form['tempSel'].innerHTML; - } - var filterValue = form['filter'].value; - filterValue = filterValue.replace("*", ".*"); - var re = new RegExp(filterValue, "i"); - var elSel = form['result']; - var i; - for (i = elSel.length - 1; i >= 0; i--) { - if (!re.test(elSel.options[i].value)) { - elSel.remove(i); - } - } - }; - - ECMUtils.prototype.convertElemtToHTML = function (id) { - var elemt = document.getElementById(id); - var text = elemt.innerHTML; - text = text.toString(); - - text = text.replace(/&/g, "&").replace(/"/g, """) - .replace(//g, ">"); - - elemt.innerHTML = text; - }; - - ECMUtils.prototype.onKeyAddressBarPress = function () { - var uiAddressBarControl = document.getElementById("AddressBarControl"); - if (uiAddressBarControl) { - uiAddressBarControl.onkeypress = Self.onAddressBarEnterPress; - } - }; - - ECMUtils.prototype.onKeySimpleSearchPress = function () { - var uiAddressBarControl = document.getElementById("SimpleSearchControl"); - if (uiAddressBarControl) { - uiAddressBarControl.onkeypress = Self.onSimpleSearchEnterPress; - } - }; - - ECMUtils.prototype.onSimpleSearchEnterPress = function (event) { - var gotoLocation = document.getElementById("SimpleSearch"); - var event = event || window.event; - if (gotoLocation && event.keyCode == 13) { - eval(gotoLocation.href); - return false; - } - }; - - ECMUtils.prototype.onAddressBarEnterPress = function (event) { - var gotoLocation = document.getElementById("GotoLocation"); - var event = event || window.event; - if (gotoLocation && event.keyCode == 13) { - eval(gotoLocation.href); - return false; - } - }; - - ECMUtils.prototype.insertContentToIframe = function (i) { - var original = document.getElementById("original" + i); - var resived = document.getElementById("revised" + i); - var css = '' + - ''; - try { - if (resived != null) { - resivedDoc = resived.contentWindow.document; - resivedDoc.open(); - resivedDoc.write(css); - resivedDoc.write(resived.getAttribute("content")); - resivedDoc.close(); - } - if (original != null) { - var originaleDoc = original.contentWindow.document; - originaleDoc.open(); - originaleDoc.write(css); - originaleDoc.write(original.getAttribute("content")); - originaleDoc.close(); - } - } catch (ex) {} - }; - - ECMUtils.prototype.generatePublicWebDAVLink = function (serverInfo, restContextName, repository, workspace, nodePath) { - // query parameter s must be encoded. - var path = "/"; - nodePath = nodePath.substr(1).split("\/"); - for (var i = 0; i < nodePath.length; i++) { - path += encodeURIComponent(nodePath[i]) + "/"; - } - window.open(serverInfo + "/" + restContextName + "/jcr/" + repository + "/" + workspace + path, '_new'); - }; - - ECMUtils.prototype.generateWebDAVLink = function (serverInfo, portalName, restContextName, repository, workspace, nodePath, mimetype) { - // query parameter s must be encoded. - var path = "/"; - var fEncode = false; - nodePath = nodePath.substr(1).split("\/"); - for (var i = 0; i < nodePath.length; i++) { - path += encodeURIComponent(nodePath[i]) + "/"; - fEncode = true; - } - if (fEncode) path = path.substr(0, path.length - 1); - if (eXo.core.Browser.isIE()) { - if (mimetype == "application/xls" || mimetype == "application/msword" || mimetype == "application/ppt" || - mimetype == "application/vnd.ms-excel" || mimetype == "application/vnd.ms-powerpoint") { - window.open(serverInfo + "/" + restContextName + "/private/lnkproducer/openit.lnk?path=/" + repository + "/" + workspace + path, '_new'); - } else { - eXo.ecm.ECMUtils.generateWebDAVUrl(serverInfo, restContextName, repository, workspace, path, mimetype); - } - } else { - window.open(serverInfo + "/" + restContextName + "/private/jcr/" + repository + "/" + workspace + path, '_new'); - } - }; - - ECMUtils.prototype.generateWebDAVUrl = function (serverInfo, restContextName, repository, workspace, nodePath, mimetype) { - my_window = window.open(""); - var downloadLink = serverInfo + "/" + restContextName + "/private/jcr/" + repository + "/" + workspace + nodePath; - my_window.document.write(''); - }; - - /** - * Init clipboard for copying url - */ - ECMUtils.prototype.initClipboard = function () { - var contextMenu = document.getElementById('ECMContextMenu'); - var copyUrlsButtons = contextMenu.querySelectorAll('i.uiIconEcmsCopyUrlToClipboard'); - for(var i = 0; i < copyUrlsButtons.length; i++) { - var parent = copyUrlsButtons[i].parentNode; - parent.addEventListener('click', function() { - var urlInput = document.createElement('input'); - // DOM element cannot be hidden so we move it outside of the screen to hide it - urlInput.style.position = 'absolute'; - urlInput.style.left = '-9999px'; - urlInput.setAttribute('value', parent.getAttribute('path')); - parent.appendChild(urlInput); - urlInput.select(); - // copy selected content in clipboard - document.execCommand('copy'); - parent.removeChild(urlInput); - }, false); - } - }; - - ECMUtils.prototype.closeContextMenu = function (element) { - var contextMenu = document.getElementById("ECMContextMenu"); - if (contextMenu) { - contextMenu.style.display = "none"; - } - }; - - ECMUtils.prototype.concatMethod = function () { - var oArg = arguments; - var nSize = oArg.length; - if (nSize < 2) return; - var mSelf = oArg[0]; - return function () { - var aArg = []; - for (var i = 0; i < arguments.length; ++i) { - aArg.push(arguments[i]); - } - mSelf.apply(mSelf, aArg); - for (i = 1; i < nSize; ++i) { - var oSet = { - method: oArg[i].method || function () {}, - param: oArg[i].param || aArg - } - oSet.method.apply(oSet.method, oSet.param); - } - } - }; - - - ECMUtils.prototype.showDocumentInformation = function (obj, event) { - if (!obj) return; - event = event || window.event; - event.cancelBubble = true; - var infor = document.getElementById('metadatas'); - if (infor.style.display == 'none') { - infor.style.display = 'block'; - infor.style.left = obj.offsetLeft + 'px'; - } else { - infor.style.display = 'none'; - } - // DOM.listHideElements(infor); - }; - - ECMUtils.prototype.onKeyPDFViewerPress = function () { - var uiPDFViewer = document.getElementById("PageControl"); - if (uiPDFViewer) { - uiPDFViewer.onkeypress = Self.onGotoPageEnterPress; - } - }; - - ECMUtils.prototype.onGotoPageEnterPress = function (event) { - var gotoPage = document.getElementById("GotoPage"); - var event = event || window.event; - if (gotoPage && event.keyCode == 13) { - eval(gotoPage.href); - return false; - } - }; - ECMUtils.prototype.initWithoutLeftContainer = function () { - Self.uiWorkingArea = gj(document).find('div.uiWorkingArea:first')[0]; - var value = gj(Self.uiWorkingArea).attr("initWithoutLeftContainer")!='true'; - return value; - } - ECMUtils.prototype.checkLeftContainerInPreferences = function (value) { - Self.uiWorkingArea = gj(document).find('div.uiWorkingArea:first')[0]; - gj(Self.uiWorkingArea).attr("initWithoutLeftContainer", value); - } - ECMUtils.prototype.resizeSideBar = function (event) { - var event = event || window.event; - if (Self.initWithoutLeftContainer()) return; - Self.loadContainerReference(); - var resizableBlock = gj(Self.uiLeftContainer).find("div.uiResizableBlock:first")[0]; - if (Self.uiLeftContainer.style.display=="none") return; - eXo.ecm.ECMUtils.currentMouseX = event.clientX; - if (Self.uiResizeSideBar) gj(Self.uiResizeSideBar).addClass("resizeBarDisplay"); - eXo.ecm.ECMUtils.resizableBlockWidth = resizableBlock.offsetWidth; - eXo.ecm.ECMUtils.currentWidth = Self.uiLeftContainer.offsetWidth; - var title = gj(Self.uiLeftContainer).find("h5.title:first")[0] || - gj(Self.uiLeftContainer).find("h6.title:first")[0]; - eXo.ecm.ECMUtils.currentTitleWidth = title.offsetWidth; - window.clearTimeout(window.UIBrokenCheckingHandler); - if (Self.uiLeftContainer.style.display == '' || Self.uiLeftContainer.style.display == 'block') { - document.onmousemove = eXo.ecm.ECMUtils.resizeMouseMoveSideBar; - document.onmouseup = eXo.ecm.ECMUtils.resizeMouseUpSideBar; - } - //VinhNT disable selection of text - var jcrExpPortlet = document.getElementById("UIJCRExplorer"); - gj(jcrExpPortlet).addClass("UIJCRExplorerNoSelect"); - } - - ECMUtils.prototype.resizeMouseMoveSideBar = function (event) { - var event = event || window.event; - if (Self.initWithoutLeftContainer()) return; - - var allowedWidth = parseInt(Self.uiWorkingArea.offsetWidth) - Self.MiniumRightContainerWidth; - // Fix minimium width can be resized - var X_Pos = eXo.core.Browser.findMouseRelativeX(Self.uiWorkingArea, event); - X_Pos = X_Pos>0?Math.floor(X_Pos):-Math.ceil(X_Pos); - if (X_Pos > allowedWidth) { - X_Pos = allowedWidth; - } else if (X_Pos < Self.MiniumLeftContainerWidth) { - X_Pos = Self.MiniumLeftContainerWidth; - } - Self.loadContainerWidth(X_Pos); - } - - ECMUtils.prototype.resizeVisibleComponent = function () { - if (Self.initWithoutLeftContainer()) return; - var container = document.getElementById("LeftContainer"); - var rightContainer = gj(Self.uiWorkingArea).find("div.rightContainer:first")[0]; - var resizableBlock = gj(container).find("div.uiResizableBlock:first")[0]; - var selectContent = gj(resizableBlock).find("div.uiSelectContent:first")[0]; - - var selectedItem = gj(selectContent).find("div.selectedItem:first")[0]; - var lstNormalItem = gj(selectContent).find("div.normalItem"); - var moreButton = gj(selectContent).find("div.moreItem:first")[0]; - - //count the visible items - var visibleItemsCount = 0; - if (selectedItem != null) { - visibleItemsCount++; - } - - if (lstNormalItem != null) { - visibleItemsCount += lstNormalItem.length; - } - - if (moreButton != null && moreButton.style.display == 'block') { - visibleItemsCount++; - } - - var resizableBlockWidth = resizableBlock.offsetWidth; - var componentWidth = selectedItem ? selectedItem.offsetWidth : lstNormalItem[0].offsetWidth; - var newVisibleItemCount = Math.floor(resizableBlockWidth / componentWidth); - if (newVisibleItemCount < visibleItemsCount) { - //display 'More' button - if (moreButton != null && moreButton.style.display == 'none') { - moreButton.style.display = 'block'; - } - - var newVisibleComponentCount = newVisibleItemCount - 1; //one space for 'more' button - var newVisibleNormalComponentCount = newVisibleComponentCount - 1; //discount the selected component - - for (var i = lstNormalItem.length - 1; i >= newVisibleNormalComponentCount; i--) { - //move item to dropdown box - eXo.ecm.ECMUtils.moveItemToDropDown(lstNormalItem[i]); - } - } else { - var lstExtendedComponent = document.getElementById('ListExtendedComponent'); - var lstHiddenComponent = gj(lstExtendedComponent).children('a'); - - if (lstHiddenComponent.length > 0) { - var movedComponentCount = (newVisibleItemCount - visibleItemsCount) > lstHiddenComponent.length ? lstHiddenComponent.length : (newVisibleItemCount - visibleItemsCount); - for (var i = 0; i < movedComponentCount; i++) { - eXo.ecm.ECMUtils.moveItemToVisible(lstHiddenComponent[i]); - } - - lstHiddenComponent = gj(lstExtendedComponent).children('a'); - if (lstHiddenComponent.length <= 0) { - moreButton.style.display = 'none'; - } - } - } - } - - ECMUtils.prototype.moveItemToDropDown = function (movedItem) { - var lstExtendedComponent = document.getElementById('ListExtendedComponent'); - var iconOfMovedItem = gj(movedItem).children('div')[0]; - if (!iconOfMovedItem) return; - var classesOfIcon = iconOfMovedItem.className.split(' '); - - var link = document.createElement('a'); - link.setAttribute('title', movedItem.getAttribute('title')); - link.className = 'IconPopup ' + classesOfIcon[classesOfIcon.length - 1]; - link.setAttribute('onclick', movedItem.getAttribute('onclick')); - link.setAttribute('href', 'javascript:void(0);'); - - var lstHiddenComponent = gj(lstExtendedComponent).children('a'); - if (lstHiddenComponent.length > 0) { - lstExtendedComponent.insertBefore(link, lstHiddenComponent[0]); - } else { - lstExtendedComponent.appendChild(link); - } - - //remove from visible area - var parentOfMovedNode = movedItem.parentNode; - parentOfMovedNode.removeChild(movedItem); - } - - ECMUtils.prototype.moveItemToVisible = function (movedItem) { - - var container = document.getElementById("LeftContainer"); - var resizableBlock = gj(container).find("div.uiResizableBlock:first")[0]; - var selectContent = gj(resizableBlock).find("div.uiSelectContent:first")[0]; - var moreButton = gj(selectContent).find("div.moreItem:first")[0]; - - var normalItem = document.createElement('div'); - normalItem.className = 'normalItem'; - normalItem.setAttribute('title', movedItem.getAttribute('title')); - normalItem.setAttribute('onclick', movedItem.getAttribute('onclick')); - - var iconItem = document.createElement('div'); - var lstClassOfMovedItem = movedItem.className.split(' '); - iconItem.className = 'itemIcon defaultIcon ' + lstClassOfMovedItem[lstClassOfMovedItem.length - 1]; - - var emptySpan = document.createElement('span'); - - iconItem.appendChild(emptySpan); - normalItem.appendChild(iconItem); - - selectContent.insertBefore(normalItem, moreButton); - - //remove from visible area - var parentOfMovedNode = movedItem.parentNode; - parentOfMovedNode.removeChild(movedItem); - } - /** - * Handle for the resize event of Content Explorer - * Calculate to determine which actionButton will be visible, which will be put - * in HiddenActionList - * - * @function actionbarContainer_OnResize - * @author vinh_nguyen@exoplatform.com - */ - ECMUtils.prototype.actionbarContainer_OnResize = function () { - var divAction = document.getElementById("uiActionsBarContainer"); - - var actionbar= gj('#UIActionBar'); - var viewbar = gj('#UIViewBarContainer')[0]; - var uiMainActionContainer = gj(divAction).find("ul.nav-pills")[0]; - if (!uiMainActionContainer) return; - var listHiddenActionContainer = gj(uiMainActionContainer).find("li.listHiddenActionsContainer:first")[0]; - var uiDropdownContainer = gj(listHiddenActionContainer).find("ul.dropdown-menu:first")[0]; - var allowedSpace = uiMainActionContainer.offsetWidth - viewbar.offsetWidth - 20 ; //left&right padding - Self.containerWithDropDownItem_OnResize(uiMainActionContainer, allowedSpace, listHiddenActionContainer, uiDropdownContainer, "active"); - // show/hide more button if right container is too narrow. - var moreButton = gj(uiMainActionContainer).find("a.dropdown-toggle:first")[0]; - var driveAction = gj(viewbar).find("#driveAction:first")[0]; - if (moreButton && driveAction) { - var driveActionSize = driveAction.offsetWidth; - var backButton = gj(viewbar).find(".urlBackToButton:first")[0]; - var backButtonSize = backButton ? backButton.offsetWidth : 0; - var prefButtonSize = gj(viewbar).find(".setupPreferencesButton:first")[0].offsetWidth; - if (driveActionSize > 0) { //== 0 when driveAction is hidden - Self.driveActionSize = driveActionSize; - } - //real processing - if (backButtonSize + prefButtonSize + Self.driveActionSize + 60 > actionbar.width()) { - gj(viewbar).find("#driveAction").hide(); - } else { - gj(viewbar).find("#driveAction").show(); - } - } - }; - - /** - * Handle for the resize event of Content Explorer - * Calculate to determine which actionButton will be visible, which will be put - * in HiddenActionList for context bar (when selecting nodes in TreeList template) - * - * @function contextActionBarContainer_OnResize - */ - ECMUtils.prototype.contextActionBarContainer_OnResize = function () { - var divAction = document.getElementById("ActionMenuPlaceHolder"); - var actionbar= gj('#UIActionBar')[0]; - var uiMainActionContainer = gj(divAction).find("ul.dropdown-menu")[0]; - if (!uiMainActionContainer) return; - var listHiddenActionContainer = gj(uiMainActionContainer).find("li.listHiddenActionsContainer:first")[0]; - var uiDropdownContainer = gj(listHiddenActionContainer).find("ul.dropdown-menu:first")[0]; - - var fileViewStatus = gj(actionbar).find("#FileViewStatus:first")[0]; - var allowedSpace = actionbar.offsetWidth - (fileViewStatus?fileViewStatus.offsetWidth : 50); - gj(uiMainActionContainer).find("li").removeClass("last"); - Self.containerWithDropDownItem_OnResize(uiMainActionContainer, allowedSpace, listHiddenActionContainer, uiDropdownContainer, "active"); - var visibleTabsChildren = gj(uiMainActionContainer).children("li").not(".dropdown"); - gj(visibleTabsChildren[visibleTabsChildren.length-1]).addClass("last"); - }; - /** - * Re-arrange the TabsContainer inside Right Container - * - * @function tabsContainer_OnResize - * @author vinh_nguyen@exoplatform.com - */ - ECMUtils.prototype.tabsContainer_OnResize = function () { - var uiMainTabsContainer = gj(Self.uiRightContainer).find("ul.uiTabsContainer:first")[0]; - if (!uiMainTabsContainer) return; - var listHiddenTabsContainer = gj(uiMainTabsContainer).find("li.listHiddenTabsContainer:first")[0]; - var uiDropdownContainer = gj(listHiddenTabsContainer).find("ul.dropdown-menu:first")[0]; - var paddingLeft = gj(uiMainTabsContainer).css("padding-left").replace("px",""); - var paddingRight = gj(uiMainTabsContainer).css("padding-right").replace("px",""); - var allowedSpace = uiMainTabsContainer.offsetWidth - paddingLeft - paddingRight; - gj(uiMainTabsContainer).find("li").removeClass("last"); - Self.containerWithDropDownItem_OnResize(uiMainTabsContainer, allowedSpace, listHiddenTabsContainer, uiDropdownContainer, "active"); - var visibleTabsChildren = gj(uiMainTabsContainer).children("li").not(".dropdown"); - gj(visibleTabsChildren[visibleTabsChildren.length-1]).addClass("last"); - } - /** - * Re-arrange the a Container that contains visible items and dropdown list for the invisible items - * - * @function containerWithDropDownItem_OnResize - * @author vinh_nguyen@exoplatform.com - */ - ECMUtils.prototype.containerWithDropDownItem_OnResize = function (mainContainer, allowedSpace, listHiddenContainer, dropdownContainer, activeClass) { - - var visibleTabsChildren = gj(mainContainer).children("li").not(".dropdown"); - var hiddenTabsChildren = gj(dropdownContainer).children("li"); - var sumWidth = 0, i=0; - var hiddenFlag = true; - var showListContainerFlag; - var visitedItemIndex; - var removedItem; - var moveFlag; - //First, calculate the consumer space - if (visibleTabsChildren.length > 0) { - for (i=0; i < visibleTabsChildren.length; i++ ) { - sumWidth += visibleTabsChildren[i].offsetWidth; - } - if (hiddenTabsChildren.length > 0) { - gj(listHiddenContainer).css("display", "block"); - sumWidth += listHiddenContainer.offsetWidth; - } else { - gj(listHiddenContainer).css("display", "none"); - } - moveFlag = typeof activeClass === 'undefined'?false:true; - - //Move from visible container to hidden - visitedItemIndex = visibleTabsChildren.length - 1; - showListContainerFlag = gj(listHiddenContainer).css("display") == "none"; - while (sumWidth > allowedSpace && visitedItemIndex >= 0) { - if (!moveFlag || (moveFlag && !gj(visibleTabsChildren[visitedItemIndex]).hasClass(activeClass))) { - if (showListContainerFlag) { - gj(listHiddenContainer).css("display", "block"); - sumWidth += listHiddenContainer.offsetWidth; - showListContainerFlag = false; - } - sumWidth -= visibleTabsChildren[visitedItemIndex].offsetWidth; - removedItem = mainContainer.removeChild(visibleTabsChildren[visitedItemIndex]); - gj(dropdownContainer).prepend(removedItem); - hiddenFlag = false; - } - visitedItemIndex--; - } - } //Process with visbile - while (hiddenFlag) { - visibleTabsChildren = gj(mainContainer).children("li").not(".dropdown"); - hiddenTabsChildren = gj(dropdownContainer).children("li"); - var remainItem = hiddenTabsChildren.length; - sumWidth = 0; - for (i=0; i < visibleTabsChildren.length; i++ ) { - sumWidth += visibleTabsChildren[i].offsetWidth; - } - if (remainItem > 0) { - gj(listHiddenContainer).css("display", "block"); - sumWidth += listHiddenContainer.offsetWidth; - } else { - gj(listHiddenContainer).css("display", "none"); - mainContainer.removeChild(listHiddenContainer); - gj(mainContainer).append(listHiddenContainer); - return; - } - removedItem = dropdownContainer.removeChild(hiddenTabsChildren[0]); - gj(mainContainer).append(removedItem); - sumWidth += removedItem.offsetWidth; - if (sumWidth >= (allowedSpace + (remainItem>1?0:listHiddenContainer.offsetWidth)) ) { - hiddenFlag = false; - mainContainer.removeChild(removedItem); - gj(dropdownContainer).prepend(removedItem); - } else { - hiddenTabsChildren = gj(dropdownContainer).children("li"); - remainItem = hiddenTabsChildren.length; - if (remainItem <= 0) { - gj(listHiddenContainer).css("display", "none"); - hiddenFlag = false; - } - } - } - mainContainer.removeChild(listHiddenContainer); - gj(mainContainer).append(listHiddenContainer); - } - - /** - * Maintain object reference to some container which are accessed during resize - * - * @function loadContainerReference - * @author vinh_nguyen@exoplatform.com - */ - ECMUtils.prototype.loadContainerReference = function () { - Self.uiWorkingArea = gj(document).find('div.uiWorkingArea:first')[0]; - Self.uiLeftContainer = gj(Self.uiWorkingArea).find('div.leftContainer:first')[0]; - Self.uiRightContainer = gj(Self.uiWorkingArea).find("div.rightContainer:first")[0]; - Self.uiDocumentWorkspace = gj(Self.uiRightContainer).find("div.UIDocumentWorkspace:first")[0]; - Self.uiDrivesArea = gj(Self.uiRightContainer).find("div.uiDrivesArea:first")[0]; - Self.uiResizeSideBar = gj(Self.uiWorkingArea).find("div.resizeBar:first")[0]; - } - /** - * Load container width from cookies - * - * @function loadContainerWidth - * @author vinh_nguyen@exoplatform.com - */ - ECMUtils.prototype.loadContainerWidth = function (leftWidth) { - Self.loadContainerReference(); - var leftContainerWidth, actualLeftContainerWidth; - - if (leftWidth) { - leftContainerWidth = leftWidth; - } - if (!Self.initWithoutLeftContainer()) { - if (leftContainerWidth) { - if (Self.uiWorkingArea.offsetWidth - leftContainerWidth < Self.MiniumRightContainerWidth) { - leftContainerWidth = Self.uiWorkingArea.offsetWidth - Self.MiniumRightContainerWidth; - Self.setCookie(eXo.env.portal.userName + "_leftContainerWidth", leftContainerWidth, 20); - } - Self.uiLeftContainer.style.width = leftContainerWidth + "px"; - } - if (Self.uiLeftContainer.offsetWidth > 0 || Self.uiLeftContainer.offsetHeight > 0) { - actualLeftContainerWidth = Self.uiLeftContainer.offsetWidth; - } else { - actualLeftContainerWidth = 0; - } - } - - Self.resizeVisibleComponent(); - Self.actionbarContainer_OnResize(); - Self.contextActionBarContainer_OnResize(); - if (Self.documentContainer_OnResize) Self.documentContainer_OnResize(); - Self.tabsContainer_OnResize(); - if (eXo.core.Browser.isIE()) { - var jcrContainer = document.getElementById("UIJCRExplorerPortlet"); - if (jcrContainer) gj(jcrContainer).css("height", "100%"); - } - } - /** - * - */ - ECMUtils.prototype.pushMoreBlock = function (obj) { - var blocks= gj(obj).find("div.UIRightClickPopupMenu:first"); - blocks = (blocks==null||blocks.length==0)?gj(obj).find("div.UIDropDownMenu:first"):blocks; - if (blocks.length >0) { - blocks[0].onmousedown = function (event) { - var event = event || window.event; - event.cancelBubble = true; - } - blocks[0].onkeydown = function (event) { - var event = event || window.event; - event.cancelBubble = true; - } - Self.popupArray.push(blocks[0]); - return; - } - } - ECMUtils.prototype.resizeMouseUpSideBar = function (event) { - if (Self.initWithoutLeftContainer()) return; - document.onmousemove = null; - document.onmouseup = null; - var allowedWidth = parseInt(Self.uiWorkingArea.offsetWidth) - Self.MiniumRightContainerWidth; - var savedWidth = eXo.core.Browser.findMouseRelativeX(Self.uiWorkingArea, event); - - if (savedWidth > allowedWidth) { - savedWidth = allowedWidth; - } else if (savedWidth < Self.MiniumLeftContainerWidth) { - savedWidth = Self.MiniumLeftContainerWidth; - } - Self.setCookie(eXo.env.portal.userName + "_leftContainerWidth", savedWidth, 20); - Self.loadContainerWidth(savedWidth); - eXo.ecm.ECMUtils.isResizedLeft = true; - //VinhNT Reenable selection of text - var jcrExpPortlet = document.getElementById("UIJCRExplorer"); - gj(jcrExpPortlet).removeClass("UIJCRExplorerNoSelect"); - if (Self.uiResizeSideBar) gj(Self.uiResizeSideBar).removeClass("resizeBarDisplay"); - window.UIBrokenCheckingHandler = window.setTimeout("eXo.ecm.ECMUtils.UIBrokenChecking();", Self.UIBrokenCheckingInterval); - delete eXo.ecm.ECMUtils.currentWidth; - delete eXo.ecm.ECMUtils.currentMouseX; - delete eXo.ecm.ECMUtils.resizableBlockWidth; - delete eXo.ecm.ECMUtils.savedResizeDistance; - } - - ECMUtils.prototype.showHideSideBar = function (event) { - var event = event || window.event; - if (Self.initWithoutLeftContainer()) return; - event.cancelBubble = true; - window.clearTimeout(window.UIBrokenCheckingHandler); - var leftContainer = document.getElementById("LeftContainer"); - var rightContainer = gj(Self.uiWorkingArea).find("div.rightContainer:first")[0]; - var resizeButton = gj(Self.uiWorkingArea).find("a.resizeButton:first")[0]; - var iArrow = gj(resizeButton).children("i")[0]; - // The bellow block are updated - if (gj(leftContainer).hasClass('collapsed')) { - gj(leftContainer).removeClass('collapsed'); - gj(Self.uiResizeSideBar).removeClass("resizeNoneBorder"); - showSideBar = true; - if (iArrow) iArrow.className = "uiIconArrowLeft"; - } else { - gj(leftContainer).addClass('collapsed'); - gj(Self.uiResizeSideBar).addClass("resizeNoneBorder"); - showSideBar = false; - if (iArrow) iArrow.className = "uiIconArrowRight"; - } - Self.setCookie(eXo.env.portal.userName + "_CEShowSideBar", showSideBar, 20); - Self.loadContainerWidth(); - } - - ECMUtils.prototype.loadEffectedSideBar = function (id) { - var leftContainer = document.getElementById("LeftContainer"); - var resizableBlock = gj(leftContainer).find("div.uiResizableBlock:first")[0]; - if (eXo.ecm.ECMUtils.savedLeftContainer && eXo.ecm.ECMUtils.savedResizableMouseX) { - if (eXo.ecm.ECMUtils.isResizedLeft == true) leftContainer.style.width = eXo.ecm.ECMUtils.savedLeftContainer; - var documentInfo = document.getElementById("UIDocumentInfo"); - var listGrid = gj(documentInfo).find("div.uiListGrid:first")[0]; - if (listGrid) listGrid.style.width = listGrid.offsetWidth + 200 + parseInt(eXo.ecm.ECMUtils.savedResizableMouseX) + "px"; - } - eXo.ecm.ECMUtils.focusCurrentNodeInTree(id); - } - - ECMUtils.prototype.resizeTreeInSideBar = function (event) { - var event = event || window.event; - eXo.ecm.ECMUtils.currentMouseY = event.clientY; - var workingArea = document.getElementById('UIWorkingArea'); - var uiResizableBlock = gj(workingArea).find("div.uiResizableBlock:first")[0]; - var container = document.getElementById("UITreeExplorer"); - //var isOtherTabs=false; - var listContainers; - if (!container) { - listContainers = gj(uiResizableBlock).find("div.SideBarContent"); - for (var k = 0; k < listContainers.length; k++) { - if (listContainers[k].parentNode.className != "UIResizableBlock") { - container = listContainers[k - 1]; - //isOtherTabs = true; - break; - } - } - } - eXo.ecm.ECMUtils.currentHeight = container.offsetHeight; - checkRoot(); - - eXo.ecm.ECMUtils.resizableHeight = uiResizableBlock.offsetHeight; - eXo.ecm.ECMUtils.containerResize = container; - document.onmousemove = eXo.ecm.ECMUtils.resizeMouseMoveItemsInSideBar; - document.onmouseup = eXo.ecm.ECMUtils.resizeMouseUpItemsInSideBar; - } - - ECMUtils.prototype.resizeMouseMoveItemsInSideBar = function (event) { - var event = event || window.event; - //var container = document.getElementById("UITreeExplorer"); - var container = eXo.ecm.ECMUtils.containerResize; - var deltaY = event.clientY - eXo.ecm.ECMUtils.currentMouseY; - eXo.ecm.ECMUtils.resizableY = deltaY; - - var resizeDiv = document.getElementById("ResizeVerticalSideBarDiv"); - if (resizeDiv == null) { - resizeDiv = document.createElement("div"); - resizeDiv.className = "VResizeHandle"; - resizeDiv.id = "ResizeVerticalSideBarDiv"; - var workingArea = gj(container).parents(".UIWorkingArea:first")[0]; - var uiResizableBlock = gj(workingArea).find("div.uiResizableBlock:first")[0]; - resizeDiv.style.width = container.offsetWidth + "px"; - uiResizableBlock.appendChild(resizeDiv); - } - var Y_Resize = eXo.core.Browser.findMouseRelativeY(uiResizableBlock, event); - var X_Resize = eXo.core.Browser.findPosXInContainer(container, uiResizableBlock); - eXo.core.Browser.setPositionInContainer(uiResizableBlock, resizeDiv, X_Resize, Y_Resize); - eXo.ecm.ECMUtils.savedTreeSizeMouseY = eXo.ecm.ECMUtils.currentHeight + deltaY + "px"; - } - - ECMUtils.prototype.resizeMouseUpItemsInSideBar = function (event) { - document.onmousemove = null; - // The block are updated - var workingArea = document.getElementById('UIWorkingArea'); - var sizeBarContainer = gj(workingArea).find("div.uiSideBarContainer:first")[0]; - - // Remove new added div - var uiResizableBlock = gj(workingArea).find("div.uiResizableBlock:first")[0]; - if (uiResizableBlock) { - var resizeDiv = document.getElementById("ResizeVerticalSideBarDiv"); - if (resizeDiv) uiResizableBlock.removeChild(resizeDiv); - } - - // The bellow block are updated - sizeBarContainer.style.height = eXo.ecm.ECMUtils.resizableHeight + eXo.ecm.ECMUtils.resizableY + 20 + "px"; - var root = checkRoot(); - root.style.height = eXo.ecm.ECMUtils.resizableHeight + eXo.ecm.ECMUtils.resizableY + 20 + "px"; - if (eXo.ecm.ECMUtils.resizableHeight + eXo.ecm.ECMUtils.resizableY < eXo.ecm.ECMUtils.defaultHeight) { - sizeBarContainer.style.height = eXo.ecm.ECMUtils.defaultHeight + 20 + "px"; - } - var container = eXo.ecm.ECMUtils.containerResize; - if (container) container.style.height = eXo.ecm.ECMUtils.currentHeight + eXo.ecm.ECMUtils.resizableY + "px" - delete eXo.ecm.ECMUtils.currentHeight; - delete eXo.ecm.ECMUtils.currentMouseY; - delete eXo.ecm.ECMUtils.resizableHeight - delete eXo.ecm.ECMUtils.resizableY; - delete eXo.ecm.ECMUtils.containerResize; - } - - ECMUtils.prototype.showHideItemsInSideBar = function (event) { - var borderSize = 2; - var sideBarContainer = gj("div.uiSideBar").find("div.uiResizableBlock")[0]; - //Let say we have 3 item for this resize function - var topBox = gj(sideBarContainer).find("div.uiBox:first")[0]; - var midBox = gj(sideBarContainer).find("div.resizeTreeExplorer:first")[0]; - var bottomBox = gj(sideBarContainer).find("div.selectItem:first")[0]; - var avaiableHeight = sideBarContainer.offsetHeight; - var gjTop = gj(topBox); - var arrowIcon = gj(midBox).find("i")[0]; - var expandChild = gjTop.find("div.uiContentBox:last")[0]; - var selectItemsBar = gjTop.find("div.uiSelectContent")[0]; - if (bottomBox.style.display == 'none') { - gj(expandChild).css("height", ""); - if (gjTop.attr("savedHeight")) { - gjTop.css("height", gjTop.attr("savedHeight") + "px"); - } - gj(bottomBox).css("display", "block"); - arrowIcon.className = "uiIconArrowDown"; - } else { - var currentTopBoxHeight = topBox.offsetHeight; - var currentExpandChildHeight = expandChild.offsetHeight; - gjTop.attr("savedHeight", topBox.offsetHeight -borderSize); - gj(bottomBox).css("display", "none"); - gjTop.css("height", avaiableHeight - midBox.offsetHeight -borderSize + "px"); - var deltaHeight = topBox.offsetHeight - currentTopBoxHeight - midBox.offsetHeight -borderSize; - gj(expandChild).css("height", currentExpandChildHeight + deltaHeight + "px"); - arrowIcon.className = "uiIconArrowUp"; - } - } - - //get SideBarContent for resizing - ECMUtils.prototype.getContainerToResize = function () { - var treeExplorer = document.getElementById("UITreeExplorer"); - if (treeExplorer) { - return treeExplorer; - } - - var workingArea = document.getElementById('UIWorkingArea'); - var listContainers = gj(workingArea).find("div.uiResizableBlock:first")[0]; - var box = gj(listContainers).find("div.uiContentBox"); - var lastDiv = gj(box).find("div:first")[0] - return lastDiv; - } - - ECMUtils.prototype.loadEffectedItemsInSideBar = function () { - Self.waitContainerRetry = 0; - Self.waitForContainer(); - } - - ECMUtils.prototype.UIBrokenChecking = function () { - Self.uiWorkingArea = gj(document).find('div.uiWorkingArea:first')[0]; - Self.uiLeftContainer = gj(Self.uiWorkingArea).find('div.leftContainer:first')[0]; - Self.uiRightContainer = gj(Self.uiWorkingArea).find("div.rightContainer:first")[0]; - Self.uiResizeSideBar = gj(Self.uiWorkingArea).find("div.resizeBar:first")[0]; - if (!Self.uiLeftContainer || Self.uiLeftContainer.offsetHeight==0 || Self.uiLeftContainer.offsetWidth==0) return; - if (Self.uiLeftContainer && Self.uiRightContainer && Self.uiWorkingArea) { - if (Self.uiLeftContainer.offsetWidth + Self.uiRightContainer.offsetWidth + Self.uiResizeSideBar.offsetWidth > Self.uiWorkingArea.offsetWidth) { - Self.loadContainerWidth(); - }else if (Self.uiLeftContainer.offsetWidth + Self.uiRightContainer.offsetWidth + Self.uiResizeSideBar.offsetWidth < Self.uiWorkingArea.offsetWidth -2) { - Self.loadContainerWidth(); - }else if (Self.uiLeftContainer.offsetTop < Self.uiRightContainer.offsetTop) { - Self.loadContainerWidth(); - } else if (Self.uiLeftContainer.offsetHeight > Self.uiRightContainer.offsetHeight) { - if (gj("div.FillOutElement:visible").length >0) { - Self.loadContainerWidth(); - } - } - } - window.UIBrokenCheckingHandler = window.setTimeout("eXo.ecm.ECMUtils.UIBrokenChecking();", Self.UIBrokenCheckingInterval); - } - /** - * Wait for leftContainer, RightContainer and other container related to resize ready - * - * @function waitForContainer - * @author vinh_nguyen@exoplatform.com - */ - ECMUtils.prototype.waitForContainer = function () { - Self.waitContainerRetry++; - if (Self.waitContainerRetry > Self.waitContainerRetryMax) { - var fixToolbar = gj(document).find("div.UIToolbarContainer:first")[0]; - if (fixToolbar) gj(fixToolbar).css('z-index', 10); - console.log("Load Container time out"); - Self.loadContainerWidth(); - window.UIBrokenCheckingHandler = window.setTimeout("eXo.ecm.ECMUtils.UIBrokenChecking();", Self.UIBrokenCheckingInterval); - return; - } - Self.uiWorkingArea = gj(document).find('div.uiWorkingArea:first')[0]; - if (!Self.uiWorkingArea) { - window.setTimeout("eXo.ecm.ECMUtils.waitForContainer();", Self.waitInterval); - return; - } - if (!Self.initWithoutLeftContainer()) { - Self.uiLeftContainer = gj(Self.uiWorkingArea).find('div.leftContainer:first')[0]; - if (!Self.uiLeftContainer) { - window.setTimeout("eXo.ecm.ECMUtils.waitForContainer();", Self.waitInterval); - return; - } - } - Self.uiRightContainer = gj(Self.uiWorkingArea).find("div.rightContainer:first")[0]; - if (!Self.uiRightContainer) { - window.setTimeout("eXo.ecm.ECMUtils.waitForContainer();", Self.waitInterval); - return; - } - - Self.uiDocumentWorkspace = gj(Self.uiWorkingArea).find("div.UIDocumentWorkspace:first")[0]; - Self.uiDrivesArea = gj(Self.uiWorkingArea).find("div.uiDrivesArea:first")[0]; - if (!(Self.uiDocumentWorkspace || Self.uiDrivesArea)) { - window.setTimeout("eXo.ecm.ECMUtils.waitForContainer();", Self.waitInterval); - return; - } - Self.loadContainerWidth(); - window.clearTimeout(window.UIBrokenCheckingHandler); - window.UIBrokenCheckingHandler = window.setTimeout("eXo.ecm.ECMUtils.UIBrokenChecking();", Self.UIBrokenCheckingInterval); - var fixToolbar = gj(document).find("div.UIToolbarContainer:first")[0]; - if (fixToolbar) gj(fixToolbar).css( 'z-index', 10 ); - } - - ECMUtils.prototype.activateWCMDeleteNotice = function(nodePathDelete, deleteNotice) { - var noticeElem = document.getElementById("wcm-notice"); - if(nodePathDelete == null || nodePathDelete == '') { - noticeElem.style.display = "none"; - noticeElem.innerHTML = ""; - } else { - var addressBar = gj("#UIAddressBar"); - if(addressBar) { - var pos = gj("#UIAddressBar").position(); - noticeElem.style.display = "block"; - noticeElem.style.top = (pos.top + 5) + "px"; - } - noticeElem.style.display = "block"; - nodePathDelete = " "+Self.undo+""; - deleteNotice = deleteNotice + nodePathDelete; - noticeElem.innerHTML = '' + deleteNotice; - noticeElem.style.marginLeft = "-" + noticeElem.offsetWidth/2 + "px"; - } - } - ECMUtils.prototype.setUndo = function(undo) { - Self.undo = undo; - } - - ECMUtils.prototype.activateWCMRestoreNotice = function(restoreNotice) { - var noticeElem = document.getElementById("wcm-notice"); - if(restoreNotice == null || restoreNotice == '') { - noticeElem.style.display = "none"; - noticeElem.innerHTML = ""; - } else { - var addressBar = gj("#UIAddressBar"); - if(addressBar) { - var pos = gj("#UIAddressBar").position(); - noticeElem.style.display = "block"; - noticeElem.style.top = (pos.top + 5) + "px"; - } - noticeElem.style.display = "block"; - noticeElem.innerHTML = '' + restoreNotice; - noticeElem.style.marginLeft = "-" + noticeElem.offsetWidth/2 + "px"; - } - } - } - - ECMUtils.prototype.disableAutocomplete = function (id) { - var clickedElement = document.getElementById(id); - tagNameInput = gj(clickedElement).find("div.uiTagNameInput:first")[0]; - gj(tagNameInput).find("#names:first")[0].setAttribute("autocomplete", "off"); - } - - ECMUtils.prototype.selectedPath = function (id) { - var select = document.getElementById(id); - if (select) select.className = select.className + " " + "SelectedNode"; - } - - ECMUtils.prototype.hiddenExtendedListTrigger = function (event, obj) { - var elemt = document.getElementById("ListExtendedComponent"); - var event = event || window.event; - event.cancelBubble = true; - if (elemt.style.display == 'none') { - elemt.style.display = 'block'; - Self.pushMoreBlock(obj); - } else { - elemt.style.display = 'none'; - } - } - - //private method - function checkRoot() { - var workingArea = document.getElementById('UIWorkingArea'); - root = document.getElementById("UIDocumentWorkspace"); - if (root) { - eXo.ecm.ECMUtils.defaultHeight = root.offsetHeight; - var actionBar = document.getElementById('UIActionBar'); - - if (actionBar) { - eXo.ecm.ECMUtils.defaultHeight += actionBar.offsetHeight; - } - - } else { - root = gj(workingArea).find("div.rightContainer:first")[0]; - eXo.ecm.ECMUtils.defaultHeight = root.offsetHeight; - } - return root; - } - - ECMUtils.prototype.updateListGridWidth = function () { - var documentInfo = document.getElementById("UIDocumentInfo"); - var listGrid = gj(documentInfo).find("div.uiListGrid:first")[0]; - if (listGrid) { - var minimumWidth = eXo.ecm.ECMUtils.getMinimumWidthOfUIListGrid(listGrid); - listGrid.style.width = (documentInfo.offsetWidth < minimumWidth) ? minimumWidth + 'px' : 'auto'; - } - } - - ECMUtils.prototype.getMinimumWidthOfUIListGrid = function (listGrid) { - if (!listGrid) return 0; - var titleTable = gj(listGrid).find("div.titleTable:first")[0]; - var uiClearFix = gj(listGrid).find("div.clearfix")[0]; - var chidrenItems = gj(uiClearFix).children("div"); - - var minimumWidth = 0; - for (var i = 0; i < chidrenItems.length; i++) { - if (chidrenItems[i].className == "lineLeft" || chidrenItems[i].className.indexOf("Column") == 0) { - minimumWidth += chidrenItems[i].offsetWidth; - } - } - - minimumWidth += 5; //for border - return minimumWidth; - } - - ECMUtils.prototype.showInContextHelp = function () { - var parentElm = document.getElementById("idAllDrivers"); - var inContextContentHelp = gj(parentElm).find("div.InContextHelpContent:first")[0]; - if (inContextContentHelp) { - setTimeout(function () { - inContextContentHelp.style.display = "none"; - }, 6 * 1000); - } - }; - - ECMUtils.prototype.onDbClickOnTreeExplorer = function () { - if (new RegExp("MSIE 8").test(navigator.userAgent)) { - document.ondblclick = function () { - if (window.getSelection) window.getSelection().removeAllRanges(); - else if (document.selection) document.selection.empty(); - } - } - }; - - ECMUtils.prototype.displayFullAlternativeText = function (displayDiv) { - if (displayDiv) { - var parentDiv = gj(displayDiv).parents("div:first")[0]; - if (parentDiv) { - parentDiv.style.display = "none"; - var closeDiv = gj(parentDiv).nextAll("div:first")[0]; - if (closeDiv) { - closeDiv.style.display = "block"; - } - } - } - }; - - ECMUtils.prototype.collapseAlternativeText = function (displayDiv) { - if (displayDiv) { - var parentDiv = gj(displayDiv).parents("div:first")[0]; - if (parentDiv) { - parentDiv.style.display = "none"; - var closeDiv = gj(parentDiv).prevAll("div:first")[0]; - if (closeDiv) { - closeDiv.style.display = "block"; - } - } - } - }; - - ECMUtils.prototype.setSelecteddItem = function(el) { - gj('.accordion a[class="functionItem selected"]').each(function(i,e) { - gj(e).removeClass('selected'); - }); - gj(el).addClass('selected'); - } - - ECMUtils.prototype.ajaxRedirect = function(url) { - url = url.replace(/&/g, "&") ; - window.location.href = url ; - }; - - ECMUtils.prototype.initTagsTypeAhead = function(tags) { - gj("#UITaggingForm").find('#names').typeahead({minLength: 0, source: tags.split(",")}); - }; - - ECMUtils.prototype.onLoadUIThumbnailForm = function(previewAction) { - eXo.ecm.ECMUtils.previewThumbnailAction = previewAction; - // - var uploadProgressTimer; - gj("div.uploadButton").mouseup(function (e){ - uploadProgressTimer = setInterval(function() { - var percent = gj("div.uiThumbnailForm").find("div.uploadContainer").find('div.percent').text(); - if (percent == "100%") { - gj("div.uploadButton").unbind(e); - clearInterval(uploadProgressTimer); - - // Request preview - eXo.webui.UIForm.submitForm('UIThumbnailForm','Preview',true); - } - }, 1*1000); - }); - }; - - ECMUtils.prototype.onLoadNodeTypeInfo = function() { - var uiNodeTypeInfo = gj("#UINodeTypeInfoPopup"); - var nav = gj(uiNodeTypeInfo).find("ul.nav-tabs:first")[0]; - var listHiddenTabsContainer = gj(nav).find("li.listHiddenTabsContainer:first")[0]; - var uiDropdownContainer = gj(listHiddenTabsContainer).find("ul.dropdown-menu:first")[0]; - var navPaddingLeft = gj(nav).css("padding-left").replace("px",""); - var navPaddingRight = gj(nav).css("padding-right").replace("px",""); - var allowedSpace = nav.offsetWidth - navPaddingLeft - navPaddingRight - gj(listHiddenTabsContainer).width(); - var totalNavsLength = 0; - - // Total length of navigation items - gj(nav).children("li").not(".dropdown").each(function(i) { - totalNavsLength += gj(this).width(); - }); - - // Remove dropdown if only a few node types avaiable - if (totalNavsLength < allowedSpace) { - gj(listHiddenTabsContainer).hide(); - } - - // Move navigation item to dropdown menu if there are too many nav items - while (totalNavsLength > allowedSpace) { - var lastNavItem = gj(nav).children("li").not(".dropdown").last()[0]; - totalNavsLength = totalNavsLength - gj(lastNavItem).width(); - gj(uiDropdownContainer).prepend(lastNavItem); - } - }; - - eXo.ecm.ECMUtils = new ECMUtils(); - - function Instance(ifrm) { - this.win = ifrm.contentWindow ; - this.isWYSIWYG = true ; - }; - - Instance.prototype.setWYSIWYG = function(bln) { - this.isWYSIWYG = bln ; - }; - - Instance.prototype.getWin = function() { - return this.win; - }; - - Instance.prototype.getDoc = function() { - return this.win.document; - }; - - Instance.prototype.setContent = function(html) { - this.getDoc().body.innerHTML = html ; - }; - - Instance.prototype.getContent = function() { - return this.getDoc().body.innerHTML ; - }; - - Instance.prototype.writeContent = function(html) { - try { - var doc = this.getDoc() ; - doc.open() ; - doc.write(html) ; - doc.close() ; - doc.designMode = 'on' ; - doc.execCommand("useCSS", false, true); - } catch (ex) {} - }; - - Instance.prototype.execCommand = function(command, user_interface, value) { - }; - - function MyToolbar() { - this.buttonstest = new Object() ; - this.buttonstest["Default"] = [ - ['Source','Bold','Italic','Underline','JustifyLeft','JustifyCenter','JustifyRight','JustifyFull','Undo','Redo','InsertHorizontalRule','SubScript','SuperScript','Indent','Outdent'], - ['FormatBlock','FontSize','Unlink','RemoveFormat','InsertUnorderedList','InsertOrderedList','Cut','Copy','Paste','StrikeThrough'] - ] ; - - this.buttonstest["Basic"] = [ - ['Source','Bold','Italic','Underline','JustifyLeft','JustifyCenter','JustifyRight','JustifyFull','Undo','InsertHorizontalRule','SubScript','SuperScript','FormatBlock','FontSize'] - ] ; - }; - - MyToolbar.prototype.create = function(instance, mode) { - var tBarMode = this.buttonstest[mode] ; - var tBar = document.createElement('DIV') ; - tBar.id = instance + '_Toolbar' ; - tBar.className = 'MyEditorToolbar' ; - - var str = '' ; - for(var i = 0; i < tBarMode.length; i++) { - var bars = tBarMode[i] ; - for(var j = 0; j < bars.length; j++) { - str += this.getButton(instance, bars[j]) ; - } - str += '
' ; - } - tBar.innerHTML += str ; - return tBar ; - }; - - MyToolbar.prototype.getButton = function(instance, btName) { - switch (btName) { - case "FormatBlock": - return ''; - case "FontSize": - return ''; - } - return '' + btName + '' ; - }; - var myToolbar = new MyToolbar() ; - - function ExoEditor() { - this.myConfig = { - width : "400px", - height : "200px", - mode : "Default" - } - - var ua = navigator.userAgent ; - this.isIE = (navigator.appName == "Microsoft Internet Explorer") ; - this.isGecko = ua.indexOf('Gecko') != -1 ; - this.instances = new Object() ; - }; - - ExoEditor.prototype.init = function(instId, settings) { - this.createInstance(instId, settings) ; - }; - - ExoEditor.prototype.createInstance = function(instId, settings) { - var txtAreaObj = document.getElementById(instId) ; - txtAreaObj.style.height = settings["height"] || this.myConfig.height ; - - var editorObj = document.createElement("DIV") ; - editorObj.className = "MyEditor" ; - editorObj.style.width = settings["width"] || this.myConfig.width ; - editorObj.appendChild(myToolbar.create(instId, settings["mode"] || this.myConfig.mode)) ; - var ifrm = document.createElement("IFRAME") ; - ifrm.src = 'javascript:void(0)' ; - ifrm.width = "100%" ; - ifrm.style.height = settings["height"] || this.myConfig.height ; - ifrm.frameBorder = 0 ; - ifrm.scrolling = "auto" ; - ifrm.onmouseover = this.onMouseOverEvt ; - editorObj.appendChild(ifrm) ; - - txtAreaObj.style.display = 'none' ; - txtAreaObj.parentNode.appendChild(editorObj) ; - editorObj.appendChild(txtAreaObj) ; - txtAreaObj.style.width = "100%" ; - - var inst = new Instance(ifrm) ; - inst.instId = instId ; - this.instances[instId] = inst ; - inst.writeContent(txtAreaObj.value) ; - this.setEventHandlers(inst) ; - }; - - ExoEditor.prototype.onMouseOverEvt = function() { - try { - this.contentDocument.designMode = 'on'; - } catch (ex) {} - } - - ExoEditor.prototype.execCommand = function(instId, cmd, user, value) { - if(!user) user = false; - if(!value) value = null ; - switch(cmd) { - case "Source": - this.switchMode(instId) ; - return false ; - } - var doc = this.instances[instId].getDoc() ; - doc.execCommand(cmd, user, value) ; - return false; - }; - - ExoEditor.prototype.setEventHandlers = function(inst) { - var doc = inst.getDoc(), evts, i, f = this.addEvent; - - if (this.isIE) { - evts = ['keypress', 'keyup', 'keydown', 'click', 'mouseup', 'mousedown', 'controlselect', 'dblclick']; - for (i=0; i") txtArea.value = "" ; - else txtArea.value = inst.getContent() ; - }; - - ExoEditor.prototype.switchMode = function(instId) { - var inst = this.instances[instId] ; - var ifrm = inst.getWin().frameElement ; - var textArea = document.getElementById(instId) ; - if(inst.isWYSIWYG) { - textArea.value = inst.getContent() ; - ifrm.style.display = 'none' ; - textArea.style.display = 'block' ; - } else { - inst.setContent(textArea.value) ; - textArea.style.display = 'none' ; - ifrm.style.display = 'block' ; - } - inst.isWYSIWYG = !inst.isWYSIWYG; - }; - - ExoEditor.prototype.removeInstance = function(instId) { - var inst = tinyMCE.getInstanceById(editor_id), h, re, ot, tn; - - if (inst) { - inst.switchSettings(); - - editor_id = inst.editorId; - h = tinyMCE.getContent(editor_id); - - this.removeInstance(inst); - - tinyMCE.selectedElement = null; - tinyMCE.selectedInstance = null; - - // Remove element - re = document.getElementById(editor_id + "_parent"); - ot = inst.oldTargetElement; - tn = ot.nodeName.toLowerCase(); - - if (tn == "textarea" || tn == "input") { - re.parentNode.removeChild(re); - ot.style.display = "inline"; - ot.value = h; - } else { - ot.innerHTML = h; - ot.style.display = 'block'; - re.parentNode.insertBefore(ot, re); - re.parentNode.removeChild(re); - } - } - }; - - ExoEditor.prototype.encodeHTML = function(text) { - if ( typeof( text ) != "string" ) - text = text.toString() ; - - text = text.replace(/&/g, "&").replace(/"/g, """) - .replace(//g, ">") ; - - return text ; - }; - - ExoEditor.prototype.insertHtmlBefore = function(html, element) { - if ( element.insertAdjacentHTML ) // IE - element.insertAdjacentHTML( 'beforeBegin', html ) ; - else { // Gecko - var oRange = document.createRange() ; - oRange.setStartBefore( element ) ; - var oFragment = oRange.createContextualFragment( html ); - element.parentNode.insertBefore( oFragment, element ) ; - } - }; - - ExoEditor.prototype.addEvent = function(o, n, h) { - if (o.attachEvent) o.attachEvent("on" + n, h); - else o.addEventListener(n, h, false); - }; - - ExoEditor.prototype.removeEvent = function(o, n, h) { - if (o.detachEvent) o.detachEvent("on" + n, h); - else o.removeEventListener(n, h, false); - }; - - ExoEditor.prototype.cancelEvent = function(e) { - if (!e) return false; - if (this.isIE) { - e.returnValue = false; - e.cancelBubble = true; - } else { - e.preventDefault(); - e.stopPropagation && e.stopPropagation(); - } - - return false; - }; - - eXo.ecm.ExoEditor = new ExoEditor() ; - - function DMSBrowser(){ - } - - DMSBrowser.prototype.managerResize = function() { - if(eXo.core.Browser.currheight != document.documentElement.clientHeight || - eXo.core.Browser.currwidth != document.documentElement.clientWidth) { - clearTimeout(eXo.core.Browser.breakStream) ; - eXo.core.Browser.breakStream = setTimeout(eXo.core.Browser.onResize, 100) ; - } - eXo.core.Browser.currheight = document.documentElement.clientHeight; - eXo.core.Browser.currwidth = document.documentElement.clientWidth; - } - - DMSBrowser.prototype.findPosX = function(obj, isRTL) { - var curleft = 0; - var tmpObj = obj ; - while (tmpObj) { - curleft += tmpObj.offsetLeft ; - tmpObj = tmpObj.offsetParent ; - } - // if RTL return right position of obj - if(isRTL) return curleft + obj.offsetWidth ; - return curleft ; - } ; - - DMSBrowser.prototype.findMouseRelativeX = function(object, e) { - var posx = -1 ; - var posXObject = eXo.ecm.DMSBrowser.findPosX(object) ; - if (!e) e = window.event ; - if (e.pageX || e.pageY) { - posx = e.pageX - posXObject ; - } else if (e.clientX || e.clientY) { - posx = e.clientX + document.body.scrollLeft - posXObject ; - } - return posx ; - } ; - - eXo.ecm.DMSBrowser = new DMSBrowser(); - window.onresize = eXo.ecm.DMSBrowser.managerResize; - - return { - ExoEditor : eXo.ecm.ExoEditor, - ECMUtils : eXo.ecm.ECMUtils, - DMSBrowser : eXo.ecm.DMSBrowser - }; -})(gj, ecm_bootstrap, webuiExt); diff --git a/apps/resources-wcm/src/main/webapp/javascript/eXo/ecm/document-preview.js b/apps/resources-wcm/src/main/webapp/javascript/eXo/ecm/document-preview.js deleted file mode 100644 index 4d64b34dea5..00000000000 --- a/apps/resources-wcm/src/main/webapp/javascript/eXo/ecm/document-preview.js +++ /dev/null @@ -1,1372 +0,0 @@ -(function ($, XSSUtils, editorbuttons) { - MAX_LENGTH = 2000, - documentPreview = { - defaultSettings: { - doc: { - id: null, - repository: null, - workspace: null, - path: null, - title: null, - fileType: null, - downloadUrl: null, - remoteEditURL: null, - remoteEditTitle: null, - remoteEditClass: null, - openUrl: null, - size: null, - cssIcon : null, - isWebContent: false, - isCloudDrive: false - }, - showComments: true, - showOpenInFolderButton: true, - user: { - username: null, - fullname: null, - avatarUrl: null, - profileUrl: null - }, - author: { - username: null, - fullname: null, - avatarUrl: null, - profileUrl: null - }, - activity: { - id: null, - postTime: "", - status: "", - liked: null, - likes: null, - comments: null, - previous: null, - next: null - }, - comments: null - }, - settings: {}, - isDownloadStatusActivated: true, - - init: function (docPreviewSettings) { - $('.spaceButtomNavigation').addClass('hidden'); - if($('.commentsLoaded').length) { - $("#documentPreviewContent").html('
' + - '' + - '
'); - } - - this.settings = $.extend(this.defaultSettings, docPreviewSettings); - - var promises = []; - if(this.settings.showComments) { - - // if we miss author information, let's fetch them - if(this.settings.author.username != null - && (this.settings.author.fullname == null || this.settings.author.avatarUrl == null || this.settings.author.profileUrl == null)) { - promises.push(this.fetchAuthorInformation()); - } - // if we miss current user information, let's fetch them - if(this.settings.user.fullname == null || this.settings.user.avatarUrl == null || this.settings.user.profileUrl == null) { - promises.push(this.fetchUserInformation()); - } - // if we don't have the number of likes, let's fetch it - if(this.settings.activity.id != null && this.settings.activity.likes == null) { - promises.push(this.fetchLikes()); - } - // if we don't know if an activity is liked or not, let's fetch it - if(this.settings.activity.id != null && this.settings.activity.liked == null) { - promises.push(this.fetchLiked()); - } - // if we don't have the activity information, let's fetch it - if(this.settings.activity.id != null && (this.settings.activity.postTime == null || this.settings.activity.status == null)) { - promises.push(this.fetchActivity()); - } - } - - var self = this; - promises.push(this.checkDownloadDocumentStatus()); - - // wait for all users info fetches to be complete before rendering the component - Promise.all(promises).then(function() { - self.render(); - self.show(); - if(!$('.commentsLoaded').length && self.settings.showComments) { - self.loadComments(); - } - }, function(err) { - console.error('An error occurred when trying to load document preview details: ',err); - }); - }, - - checkDevice : function() { - var body = $('body:first').removeClass('phoneDisplay').removeClass('tabletDisplay').removeClass('tabletLDisplay'); - var isMobile = body.find('.visible-phone:first').css('display') !== 'none'; - var isTablet = body.find('.visible-tablet:first').css('display') !== 'none'; - var isTabletL = body.find('.visible-tabletL:first').css('display') !== 'none'; - if (isMobile) { - body.addClass('phoneDisplay'); - } - if (isTablet) { - body.addClass('tabletDisplay'); - } - if (isTabletL) { - body.addClass('tabletLDisplay'); - } - return {'isMobile' : isMobile, 'isTablet' : isTablet, 'isTabletL' : isTabletL}; - }, - - fetchUserInformation: function(callback) { - var self = this; - return $.ajax({ - url: "/portal/rest/v1/social/users/" + eXo.env.portal.userName, - cache: false - }).done(function (data) { - if (data.fullname != null) { - self.settings.user.fullname = data.fullname; - } - if (data.avatar != null) { - self.settings.user.avatarUrl = data.avatar; - } else { - self.settings.user.avatarUrl = "/eXoSkin/skin/images/system/SpaceAvtDefault.png"; - } - self.settings.user.profileUrl = "/" + eXo.env.portal.containerName + "/" + eXo.env.portal.portalName + "/" + eXo.env.portal.userName; - }).fail(function () { - console.log("Can not fetch user information!"); - }).always(function () { - if(typeof callback === 'function') { - callback(); - } - }); - }, - - - checkDownloadDocumentStatus: function(callback) { - var self = this; - return $.ajax({ - type: 'GET', - url: '/portal/rest/transferRules/getTransfertRulesDocumentStatus' - }).done(function (data) { - self.isDownloadStatusActivated = data.downloadDocumentStatus == 'true'; - self.clearErrorMessage(); - }).fail(function () { - self.showErrorMessage("Error when getting documents transfer rules status"); - }); - }, - - fetchAuthorInformation: function(callback) { - var self = this; - return $.ajax({ - url: "/portal/rest/v1/social/users/" + self.settings.author.username, - cache: false - }).done(function (data) { - if (data.fullname != null) { - self.settings.author.fullname = data.fullname; - } - if (data.avatar != null) { - self.settings.author.avatarUrl = data.avatar; - } else { - self.settings.author.avatarUrl = "/eXoSkin/skin/images/system/SpaceAvtDefault.png"; - } - self.settings.author.profileUrl = "/" + eXo.env.portal.containerName + "/" + eXo.env.portal.portalName + "/" + self.settings.author.username; - }).fail(function () { - console.log("Can not fetch author information!"); - }).always(function () { - if(typeof callback === 'function') { - callback(); - } - }); - }, - - fetchLikes: function() { - var self = this; - return $.ajax({ - url: '/portal/rest/v1/social/activities/' + this.settings.activity.id + '/likes' - }).done(function (data) { - if (data.likes != null) { - self.settings.activity.likes = data.likes.length; - } - self.clearErrorMessage(); - }).fail(function () { - self.settings.activity.likes = 0; - self.showErrorMessage("${UIActivity.comment.canNotLoadLikes}"); - }); - }, - - like: function(liked) { - var self = this; - if(!liked) { - return $.post('/portal/rest/v1/social/activities/' + this.settings.activity.id + '/likes', {liker: eXo.env.portal.userName}) - .done(function (data) { - self.settings.activity.liked = true; - self.settings.activity.likes++; - $('#documentPreviewContainer .nbOfLikes').html(self.settings.activity.likes); - self.refreshLikeLink('clickEvent'); - self.clearErrorMessage(); - }).fail(function () { - self.showErrorMessage("${UIActivity.comment.canNotLike}"); - console.log("Can not like document!"); - }); - } else { - return $.ajax({ - type: 'DELETE', - url: '/portal/rest/v1/social/activities/' + this.settings.activity.id + '/likes' - }).done(function (data) { - self.settings.activity.liked = false; - self.settings.activity.likes--; - $('#documentPreviewContainer .nbOfLikes').html(self.settings.activity.likes); - self.refreshLikeLink('clickEvent'); - self.clearErrorMessage(); - }).fail(function () { - self.showErrorMessage("${UIActivity.comment.canNotUnLike}"); - console.log("Can not delete like of document!"); - }); - } - }, - - refreshLikeLink: function(event) { - var likeLink = $('#documentPreviewContainer #previewLikeLink'); - var likeIcon = likeLink.find('.uiIconThumbUp'); - if(this.settings.activity.liked == true) { - likeLink.attr("data-original-title", "${UIActivity.label.Unlike}"); - likeIcon.addClass('uiIconBlue'); - likeIcon.removeClass('uiIconLightGray'); - } else { - likeLink.attr("data-original-title", "${UIActivity.label.Like}"); - likeIcon.removeClass('uiIconBlue'); - likeIcon.addClass('uiIconLightGray'); - } - if (event) { - likeLink.tooltip('show'); - } - }, - fetchLiked: function() { - var self = this; - return $.ajax({ - type:'GET', - url: '/portal/rest/v1/social/activities/' + this.settings.activity.id + '/likes/' + eXo.env.portal.userName - }).done(function (data) { - if (data.likes != null) { - self.settings.activity.liked = true; - } - self.clearErrorMessage(); - }).fail(function () { - self.settings.activity.liked = false; - }); - }, - - fetchActivity: function() { - var self = this; - return $.ajax({ - type:'GET', - url: '/portal/rest/v1/social/activities/' + this.settings.activity.id - }).done(function (data) { - if (data != null) { - self.settings.activity.postTime = self.convertDate(data.createDate); - self.settings.activity.status = data.title; - } - self.clearErrorMessage(); - }).fail(function () { - }); - }, - - toggleLikeComment: function(commentId) { - var self = this; - - var comment = this.findComment(commentId); - - if(!comment.liked) { - return $.post('/portal/rest/v1/social/comments/' + commentId + '/likes', {liker: eXo.env.portal.userName}) - .done(function (data) { - comment.liked = true; - comment.nbOfLikes++; - - // update tooltip on likes count - var likeCommentCount = $('#documentPreviewContainer #likeCommentCount_' + commentId); - if(likeCommentCount.attr('title')) { - likeCommentCount.attr('title', self.settings.user.fullname + '\n' + likeCommentCount.attr('title')); - } else { - likeCommentCount.attr('title', self.settings.user.fullname); - } - // update nb of likes - likeCommentCount.css('display', 'inline'); - likeCommentCount.html('(' + comment.nbOfLikes + ')'); - - likeCommentCount.addClass('commentLiked'); - - var likeCommentLink = $('#documentPreviewContainer #likeCommentLink_' + commentId); - likeCommentLink.find('i').addClass('commentLiked'); - likeCommentLink.attr('title', "${UIActivity.msg.UnlikeComment}"); - - self.clearErrorMessage(); - }).fail(function () { - self.showErrorMessage("${UIActivity.comment.canNotLike}"); - }); - } else { - return $.ajax({ - type: 'DELETE', - url: '/portal/rest/v1/social/comments/' + commentId + '/likes/' + eXo.env.portal.userName - }).done(function (data) { - comment.liked = false; - comment.nbOfLikes--; - - var likeCommentCount = $('#documentPreviewContainer #likeCommentCount_' + commentId); - if(comment.nbOfLikes > 0) { - // refresh tooltip on likes count - comment.likes.reverse(); - likeCommentCount.attr('title', comment.likes.filter(function(like) { - return like.username != eXo.env.portal.userName; - }).map(function(like) { - return like.fullname; - }).join('\n')); - // update nb of likes - likeCommentCount.html('(' + comment.nbOfLikes + ')'); - } else { - likeCommentCount.css('display', 'none'); - likeCommentCount.empty(); - likeCommentCount.attr('title', ''); - } - - likeCommentCount.removeClass('commentLiked'); - - var likeCommentLink = $('#documentPreviewContainer #likeCommentLink_' + commentId); - likeCommentLink.find('i').removeClass('commentLiked'); - likeCommentLink.attr('title', "${UIActivity.msg.LikeComment}"); - - self.clearErrorMessage(); - }).fail(function () { - self.showErrorMessage("${UIActivity.comment.canNotUnLike}"); - }); - } - }, - - findComment: function(commentId) { - for(i = 0; i < this.settings.activity.comments.length; i++) { - if(this.settings.activity.comments[i].id == commentId) { - return this.settings.activity.comments[i]; - } - } - }, - - showLikersPopup: function(commentId) { - UIActivity.showLikersPopup(commentId); - }, - - createSkeleton: function () { - var docPreviewContainer = $("#documentPreviewContainer"); - - if(docPreviewContainer.length == 0) { - docPreviewContainer = $("
", { - "id": "documentPreviewContainer", - "class": "maskLayer z-index-modal position-absolute" - }).appendTo('body'); - } - docPreviewContainer.hide(); - - var cssClasses = ''; - if (this.settings.doc.fileType) { - cssClasses = $.map(this.settings.doc.fileType.split(/\s+/g), function(type){return "uiIcon16x16" + type}).join(" "); - } - - if($('.commentsLoaded').length) { - let html = ''; - if(this.settings.showComments) { - html += ''; - } - if (eXo.env.portal.userName !== '') { - html +='
' + - ' ' + - ' ' + - '
'; - } - else { - html += '
' + - ' '; - } - if (this.settings.showComments) { - html += ''; - }; - if(documentPreview.settings.doc && documentPreview.settings.doc.breadCrumb) { - var breadCrumbContent = '
'; - var folderIndex = 0; - var breadCrumbContentTooltip = ""; - for (var folderName in documentPreview.settings.doc.breadCrumb) { - if (documentPreview.settings.doc.breadCrumb.hasOwnProperty(folderName)) { - var folderPath = documentPreview.settings.doc.breadCrumb[folderName]; - if(folderIndex > 0) { - breadCrumbContent += '  '; - breadCrumbContentTooltip += " > "; - } - breadCrumbContent += '' + XSSUtils.escapeHtml(folderName) + ''; - breadCrumbContentTooltip += folderName; - folderIndex++; - } - } - breadCrumbContent += '
'; - } - if(breadCrumbContent) { - html += ''; - } - docPreviewContainer.find(".previewBtn").html(html); - - } else { - var authorFullName = XSSUtils.sanitizeString(this.settings.author?.fullname != null ? this.settings.author.fullname : ''); - let html = '
' + - '
' + - '' + - '
' + - '
'; - - if(this.settings.showComments) { - html += '' + - '
' + - '
' + - '
' + - '' + this.settings.doc.title + ''; - if (typeof this.settings.doc.fileInfo != "undefined") { - html += ((documentPreview.settings.version && documentPreview.settings.version.number) ? ('
V' + documentPreview.settings.version.number + '
') : '') + - '
' + this.settings.doc.fileInfo + '
'; - } - html += '
' + - '
' + - '' + - '
' + - '
' + - '
' + - '
' + - '
' + - '' + authorFullName + '' + - '
' + - '' + authorFullName + '' + - '

' + this.settings.activity.postTime + '

' + - '

' + (this.settings.activity.status != null ? this.settings.activity.status : '') + '

' + - '
' + - '
' + - '
' + - '
' + - '' + - '
' + - '
' + - '' + - 'Your email address is incorrect. Please try again!' + - '
' + - '
' + - '
    ' + - '
' + - '
' + - '
' + - '' + - '' + XSSUtils.sanitizeString(this.settings.user.fullname) + '' + - '
' + - '
' + - '' + - '
' + - '' + - '' + - '
' + - '
' + - '' + - '
' + - '
'; - } - - html += '
' + - '
' + - '' + - '
' + - '
' + - '' ; - if (this.settings.showComments) { - html += '
' + - '
' + documentPreview.settings.doc.title + '
' + - ((documentPreview.settings.version && documentPreview.settings.version.number) ? ('
V' + documentPreview.settings.version.number + '
') : '') + - '
'; - } - - if (!this.settings.showComments) { - let documentTitle = documentPreview.settings.doc.title; - try { - documentTitle = decodeURI(documentPreview.settings.doc.title); - } catch (error) { - // No problem, we can use the title as is, it does not need to be decoded and it contains a % character - } - html += '
' + - '
' + documentTitle + '
'; - if (documentPreview.settings.version && (documentPreview.settings.version.number != 0)) { - html +='
V' + documentPreview.settings.version.number + '
'; - } - html +='
'; - } - '' - html += '
'; - if(!documentPreview.defaultSettings.doc.isCloudDrive){ - const downloadUrl = this.settings.doc.downloadUrl.replaceAll('%', '%25').replaceAll('+', '%2B'); - if (eXo.env.portal.userName !== '') { - html += '
' + - ' ' + - ' ' + - '
'; - } - else { - html += '
' + - ' '; - } - } - if (this.settings.showComments) { - html += ''; - } - if(documentPreview.settings.doc && documentPreview.settings.doc.breadCrumb) { - var breadCrumbContent = '
'; - var folderIndex = 0; - var breadCrumbContentTooltip = ""; - for (var folderName in documentPreview.settings.doc.breadCrumb) { - if (documentPreview.settings.doc.breadCrumb.hasOwnProperty(folderName)) { - var folderPath = documentPreview.settings.doc.breadCrumb[folderName]; - var baseurl = folderPath.slice(0,folderPath.indexOf('?')); - var path = decodeURIComponent(folderPath.slice(folderPath.indexOf('?'), folderPath.indexOf('&'))); - if (eXo.env.portal.spaceName){ - if(path.includes('/Documents')){ - const index = path.indexOf('/Documents'); - folderPath= baseurl.concat(path.substring(index+10)); - } - } else { - if (path.includes('/Private')){ - const index = path.indexOf('/Private'); - folderPath= baseurl.concat(path.substring(index)); - } - if (path.includes('/Public')){ - const index = path.indexOf('/Public'); - folderPath= baseurl.concat(path.substring(index)); - } - } - if(folderIndex > 0) { - breadCrumbContent += '  '; - breadCrumbContentTooltip += " > "; - } - breadCrumbContent += '' + folderName + ''; - breadCrumbContentTooltip += folderName; - folderIndex++; - } - } - breadCrumbContent += '
'; - } - if(breadCrumbContent) { - html += ''; - } - html += '
' + - '
' + - '
'; - docPreviewContainer.html(html); - } - - if(this.settings.doc.remoteEditURL) { - $(".previewBtn").append( - '' - ); - } - if(!this.isDownloadStatusActivated && !documentPreview.defaultSettings.doc.isCloudDrive) { - var editorButtonsLoader = editorbuttons.initPreviewButtons(this.settings.doc.id, this.settings.doc.workspace, 'dropup'); - editorButtonsLoader.done(function ($buttonsContainer) { - if ($(".previewBtn").find('.editorButtonContainer').length === 0){ - $(".previewBtn").append($buttonsContainer); - } - }); - } - - $('#documentPreviewContainer #previewLikeLink').tooltip(); - - $("#uiPreviewErrorMessage").hide(); - $("#uiPreviewErrorMessageIcon").click(function() { - $("#uiPreviewErrorMessage").hide(); - }); - $("#previewPopupCloseIcon, #previewPopupCloseButton").click(function() { - $("#previewPopup").hide(); - }); - }, - showErrorMessage: function(message) { - $("#uiPreviewErrorMessageContent").html(message); - $("#uiPreviewErrorMessage").show(); - }, - clearErrorMessage: function() { - $("#uiPreviewErrorMessageContent").html(""); - $("#uiPreviewErrorMessage").hide(); - }, - loadComments: function(commentActivityParentId, scrollToCommentId) { - var self = this; - if(this.settings.activity.id != null) { - // load comments activity - $.ajax({ - url: '/portal/rest/v1/social/activities/' + this.settings.activity.id + '/comments?expand=identity,likes,subComments', - cache: false - }).done(function(data) { - self.clearErrorMessage(); - self.settings.activity.comments = data.comments; - for(i = 0; i < self.settings.activity.comments.length; i++) { - self.settings.activity.comments[i].liked = self.settings.activity.comments[i].likes.some(function(like) { - return like.username == eXo.env.portal.userName; - }); - self.settings.activity.comments[i].nbOfLikes = self.settings.activity.comments[i].likes.length; - } - self.renderComments(self.settings.activity.comments, commentActivityParentId, scrollToCommentId); - resizeEventHandler(); - self.clearErrorMessage(); - }).fail(function () { - self.showErrorMessage("${UIActivity.comment.canNotLoadComments}"); - console.log("Can not load comments!"); - }); - } - }, - - renderComments: function(comments, commentActivityParentId, scrollToCommentId) { - var self = this; - - var commentsHtml = ''; - if(comments != null && comments.length > 0) { - $('#documentPreviewContainer .nbOfComments').html(comments.length); - commentsHtml = '
    '; - var subCommentIndex = 0; - var subCommentSize = 0; - var subCommentSize = 0; - var hideSubComments = false; - $.each(comments, function (index, comment) { - var commenterProfileUrl = "/" + eXo.env.portal.containerName + "/" + eXo.env.portal.portalName + "/" + comment.identity.profile.username; - var commenterAvatar = comment.identity.profile.avatar; - if (commenterAvatar == null) { - commenterAvatar = '/eXoSkin/skin/images/system/UserAvtDefault.png'; - } - var commentClass = ""; - var parentCommentIdString = comment.parentCommentId ? comment.parentCommentId : ""; - if(comment.parentCommentId) { - subCommentIndex ++; - commentClass = "subCommentBlock"; - if(hideSubComments) { - commentClass += " hidden"; - if(subCommentIndex == subCommentSize) { - commentsHtml += - '
  • ' + - '

    ' + - '' + - "${UIActivity.label.ViewAllReplies}".replace("{0}", subCommentSize) + - '' + - '

    ' + - '
  • '; - } - } - } else { - subCommentIndex = 0; - subCommentSize = self.getSubCommentsSize(comments, comment.id); - hideSubComments = subCommentSize > 2 & comment.id !== commentActivityParentId; - } - - commentsHtml += '
  • ' + - '' + - '
    ' + - '
    ' + - '' + XSSUtils.sanitizeString(comment.identity.profile.fullname) + '' + - '' + self.convertDate(comment.updateDate) + '' + - '
    ' + - '

    ' + comment.body + '

    '; - - // add like comment if the document is linked to an activity - if(self.settings.activity.id != null) { - var maxNbLikersInTooltip = 10; - comment.likes.reverse(); - var moreThan10Likers = comment.likes.length > maxNbLikersInTooltip; - var commentLikers = ''; - for(var i=0; i < comment.likes.length; i++) { - commentLikers += comment.likes[i].fullname + '\n'; - if(moreThan10Likers && i == (maxNbLikersInTooltip - 2)) { - commentLikers += "${UIActivity.msg.MoreLikers}".replace("{0}", comment.likes.length - (maxNbLikersInTooltip - 1)); - break; - } - } - - var likeTooltip = comment.liked ? "${UIActivity.msg.UnlikeComment}" : "${UIActivity.msg.LikeComment}"; - - commentsHtml += ''; - } - - commentsHtml += '
    ' + - '
  • '; - }) - commentsHtml += '
'; - } else { - $('#documentPreviewContainer .nbOfComments').html('0'); - commentsHtml = '
' + - '
${UIActivity.comment.noComment}
' + - '
'; - } - var commentsContainer = $('#documentPreviewContainer .commentArea .comments'); - commentsContainer.html(commentsHtml); - commentsContainer.addClass('commentsLoaded'); - - $("#documentPreviewContainer .subCommentShowAllLink").on("click", function() { - var parentCommentId = $(this).attr('data-parent-comment'); - - $('#documentPreviewContainer #SubCommentShowAll_' + parentCommentId).hide(); - $('#documentPreviewContainer [data-parent-comment=' + parentCommentId + ']').removeClass('hidden'); - }); - - $(".replyCommentLink").on("click", function() { - var parentCommentId = $(this).attr("data-parent-comment"); - var commentId = $(this).attr("data-comment"); - parentCommentId = parentCommentId ? parentCommentId : commentId; - var commentInput = $('#documentPreviewContainer #commentInput'); - commentInput.attr("data-parent-comment", parentCommentId); - - $("#documentPreviewContainer .parentCommentBlock").removeClass("hidden"); - var $commentList = $('#documentPreviewContainer .commentList'); - - var $inputContainer = $("#documentPreviewContainer .commentInputBox"); - $('#documentPreviewContainer #commentInput').ckeditorGet().destroy(true); - - $inputContainer.addClass("subCommentBlock"); - $inputContainer.insertAfter($("#documentPreviewContainer .commentItem[data-comment=" + parentCommentId + "], #documentPreviewContainer .commentItem[data-parent-comment=" + parentCommentId + "]").last()); - $inputContainer.find("#documentPreviewContainer .commentBox .commentTextInput").html($('
').append($inputContainer.find('textarea').clone()).html()); - - $("#documentPreviewContainer .commentItem").removeClass("focus"); - $("#documentPreviewContainer .commentItem[data-comment=" + commentId + "]").addClass("focus"); - - var ele = $("#documentPreviewContainer .commentInputBox"); - var elementToScroll = "#documentPreviewContainer .comments .commentList"; - if (this.checkDevice().isMobile === true) { - ele = $("#documentPreviewContainer [data-comment=" + commentId + "]"); - elementToScroll = "#documentPreviewContainer .commentArea"; - } - if(ele.length > 0 && ele.offset() && ele.parent().offset()) { - var nTop = ele.offset().top - ele.parent().offset().top + ele.parent().scrollTop(); - $(elementToScroll).animate({ - scrollTop: nTop - },1000); - } - - self.initCKEditor(); - self.clearErrorMessage(); - self.showCommentLink(true, true, false); - }); - - if(scrollToCommentId && this.checkDevice().isMobile === true) { - var ele = $("#documentPreviewContainer [data-comment=" + scrollToCommentId + "]"); - - if(ele.length > 0 && ele.offset() && ele.parent().offset()) { - var nTop = ele.offset().top - ele.parent().offset().top + ele.parent().scrollTop(); - $("#documentPreviewContainer .commentArea").animate({ - scrollTop: nTop - },1000); - } - } - self.showCommentLink(this.checkDevice().isMobile, false, true); - }, - - showCommentBlockForActivity: function(comments, parentCommentId) { - $("#documentPreviewContainer .commentItem").removeClass("focus"); - this.moveCKEditorInOriginalLocation(); - this.initCKEditor(); - this.clearErrorMessage(); - this.showCommentLink(false, true, true); - resizeEventHandler(); - }, - - getSubCommentsSize: function(comments, parentCommentId) { - var count = 0; - comments.forEach(function(comment) { - if(comment.parentCommentId == parentCommentId) { - count++; - } - }) - return count; - }, - - convertDate: function(dateStr) { - var postedTime = Date.parse(dateStr); - - var time = (new Date().getTime() - postedTime) / 1000; - var value; - if (time < 60) { - return eXo.ecm.WCMUtils.getBundle("TimeConvert.label.Less_Than_A_Minute",eXo.env.portal.language); - } else { - if (time < 120) { - return eXo.ecm.WCMUtils.getBundle("TimeConvert.label.About_A_Minute",eXo.env.portal.language); - } else { - if (time < 3600) { - value = Math.round(time / 60); - return eXo.ecm.WCMUtils.getBundle("TimeConvert.type.MINUTES",eXo.env.portal.language).replace("{0}", value); - } else { - if (time < 7200) { - return eXo.ecm.WCMUtils.getBundle("TimeConvert.label.About_An_Hour",eXo.env.portal.language); - } else { - if (time < 86400) { - value = Math.round(time / 3600); - return eXo.ecm.WCMUtils.getBundle("TimeConvert.type.HOURS",eXo.env.portal.language).replace("{0}", value); - } else { - if (time < 172800) { - return eXo.ecm.WCMUtils.getBundle("TimeConvert.label.About_A_Day",eXo.env.portal.language); - } else { - if (time < 2592000) { - value = Math.round(time / 86400); - return eXo.ecm.WCMUtils.getBundle("TimeConvert.type.DAYS",eXo.env.portal.language).replace("{0}", value); - } else { - if (time < 5184000) { - return eXo.ecm.WCMUtils.getBundle("TimeConvert.label.About_A_Month",eXo.env.portal.language); - } else { - value = Math.round(time / 2592000); - return eXo.ecm.WCMUtils.getBundle("TimeConvert.type.MONTHS",eXo.env.portal.language).replace("{0}", value); - } - } - } - } - } - } - } - } - }, - - postComment: function () { - var self = this; - var commentInput = $('#documentPreviewContainer #commentInput'); - if(commentInput != null && $.trim(commentInput.val())) { - var commentContent = commentInput.val(); - var commentActivityParentId = commentInput.attr("data-parent-comment"); - if(this.settings.activity.id != null) { - var postData = { poster : eXo.env.portal.userName , title : commentContent, parentCommentId : commentActivityParentId }; - // post comment on the activity - return $.ajax({ - type: 'POST', - url: '/portal/rest/v1/social/activities/' + this.settings.activity.id + '/comments', - data: JSON.stringify(postData), - contentType: 'application/json' - }).done(function (data) { - self.loadComments(commentActivityParentId, data.id); - self.moveCKEditorInOriginalLocation(); - self.initCKEditor(); - self.clearErrorMessage(); - }).fail(function () { - self.showErrorMessage("${UIActivity.comment.canNotAddComment}"); - console.log("Can not post comment!"); - }); - } - } - }, - - deleteComment: function(commentId) { - var self = this; - - if(this.settings.activity.id != null) { - return $.ajax({ - type: 'DELETE', - url: '/portal/rest/v1/social/comments/' + commentId - }).done(function (data) { - self.loadComments(); - self.clearErrorMessage(); - }).fail(function () { - self.showErrorMessage("${UIActivity.comment.canNotDeleteComment}"); - console.log("Can not delete comment!"); - }); - } - }, - - render: function () { - var self = this; - - this.createSkeleton(); - - var docContentContainer = $('#documentPreviewContent'); - - if(!$('.commentsLoaded').length) { - $(window).on('resize', resizeEventHandler); - $(document).on('keyup', closeEventHandler); - if(!window.previewDocumentEventsSet) { - $(document).keyup(function(event) { - if(event && event.keyCode && (event.keyCode == 37 || event.keyCode == 39) && $("#NavCommands").length && $("#NavCommands").is(":visible")) { - event.stopPropagation(); - event.preventDefault(); - if(event.keyCode == 37) { - self.goToPrevious(); - } else if(event.keyCode == 39) { - self.goToNext(); - } - } - }) - $(document).on("swipe", function(event) { - if(window.innerWidth < 767 && $("#NavCommands").length && $("#NavCommands").is(":visible")) { - if(event.direction === 'left') { - self.goToNext(); - } else if(event.direction === 'right') { - self.goToPrevious(); - } - } - }) - } - window.previewDocumentEventsSet = true; - - // Bind close event. Return body scroll, turn off keyup - $(".exitWindow > .uiIconClose", $('#uiDocumentPreview')).click(function() { - $('.spaceButtomNavigation').removeClass('hidden'); - $('body').removeClass('modal-open'); - $("#documentPreviewContainer").remove(); - setTimeout(function() { - $('body').css('overflow', 'visible'); - $(document).off('keyup', closeEventHandler); - $(window).off('resize', resizeEventHandler); - }, 500); - }); - - $(".closeIcon > .uiIconClose", $('#uiDocumentPreview')).click(function() { - $('body').removeClass('modal-open'); - $("#documentPreviewContainer").remove(); - setTimeout(function() { - $('body').css('overflow', 'visible'); - $(document).off('keyup', closeEventHandler); - $(window).off('resize', resizeEventHandler); - }, 500); - }); - - if(this.settings.showComments) { - if(this.settings.activity.id != null) { - // render like link and nb of likes - this.refreshLikeLink(); - $('#documentPreviewContainer .nbOfLikes').html(this.settings.activity.likes); - } else { - // hide like link since there is no linked activity - $('#documentPreviewContainer #previewLikeLink').hide(); - } - - this.initCKEditor(); - - if($('#CommentButton [data-action-initialized]').length == 0) { - $('#CommentButton').on('click', function(event) { - self.postComment(); - self.showCommentLink(this.checkDevice().isMobile, false, true); - }); - $('#CommentButton').attr("data-action-initialized", "true"); - } - - if($('#CancelButton [data-action-initialized]').length == 0) { - $('#CancelButton').on('click', function(event) { - $('#documentPreviewContainer .commentArea')[0].style.display = "none"; - $('#documentPreviewContent')[0].style.display = "block"; - $('.previewBtn')[0].style.display = "block" - resizeEventHandler(); - }); - $('#CancelButton').attr("data-action-initialized", "true"); - } - - if ($('.showComments [data-action-initialized]').length == 0) { - $('.showComments').on('click', function (event) { - var $uiDocumentPreview = $('#uiDocumentPreview'); - var $commentArea = $('.commentArea', $uiDocumentPreview); - var $commentList = $('.commentList', $commentArea); - if ($('#cke_commentInput .cke_contents').length > 0) { - $('#cke_commentInput .cke_contents')[0].style.height = "100px"; - } - if ($('#documentPreviewContent')[0].style.display === "none") { - $('#documentPreviewContainer .commentArea')[0].style.display = "none"; - $('#documentPreviewContent')[0].style.display = "block"; - $("#documentPreviewContainer .parentCommentBlock").removeClass("hidden"); - $("#documentPreviewContainer .uiIconComment").removeClass("hiddenComment"); - } else { - $('#documentPreviewContainer .commentArea')[0].style.display = "block"; - $('#documentPreviewContent')[0].style.display = "none"; - $("#documentPreviewContainer .parentCommentBlock").addClass("hidden"); - $("#documentPreviewContainer .uiIconComment").addClass("hiddenComment"); - - self.moveCKEditorInOriginalLocation(); - self.initCKEditor(); - self.clearErrorMessage(); - self.showCommentLink(this.checkDevice().isMobile, false, false); - } - }); - $('.showComments').attr("data-action-initialized", "true"); - } - } - - $('.loading', docContentContainer).show(); - this.show(); - } - - docContentContainer.load(eXo.env.portal.context + '/' + eXo.env.portal.rest + '/contentviewer/' + this.settings.doc.repository + '/' + this.settings.doc.workspace + '/' + this.settings.doc.id, function() { - $('.loading', docContentContainer).hide(); - resizeEventHandler(); - }); - }, - showCommentLink: function(showComment, showCKEditor, isCKEditorInBottom) { - if(showComment) { - $('#documentPreviewContainer .parentCommentBlock').removeClass("hidden"); - } else { - $('#documentPreviewContainer .parentCommentBlock').addClass("hidden"); - } - - if (this.checkDevice().isMobile === true) { - var commentLinkRelative = showComment && showCKEditor; - if(commentLinkRelative) { - $('#documentPreviewContainer .parentCommentBlock').removeClass("FixedBlock"); - } else { - $('#documentPreviewContainer .parentCommentBlock').addClass("FixedBlock"); - } - if(showCKEditor) { - $("#documentPreviewContainer .commentArea").addClass("commentBoxOpen"); - $('#documentPreviewContainer .commentInputBox').removeClass("hidden"); - } else { - $("#documentPreviewContainer .commentArea").removeClass("commentBoxOpen"); - $('#documentPreviewContainer .commentInputBox').addClass("hidden"); - } - } - - if(isCKEditorInBottom) { - $("#documentPreviewContainer .commentList").addClass("commentBoxOpen"); - } else { - $("#documentPreviewContainer .commentList").removeClass("commentBoxOpen"); - } - }, - moveCKEditorInOriginalLocation: function() { - $('#documentPreviewContainer #commentInput').attr("data-parent-comment", null) - try { - $('#documentPreviewContainer #commentInput').ckeditorGet().destroy(true); - } catch(e) { - } - - var $inputContainer = $("#documentPreviewContainer .commentInputBox"); - $inputContainer.insertAfter($("#documentPreviewContainer .comments")); - $inputContainer.removeClass("subCommentBlock"); - $inputContainer.find("#documentPreviewContainer .commentBox .commentTextInput").html($('
').append($inputContainer.find('textarea').clone()).html()); - }, - initCKEditor: async function() { - await new Promise(resolve => window.require(["SHARED/commons-editor"], resolve)); - var commentInput = $('#documentPreviewContainer #commentInput'); - var extraPlugins = 'simpleLink,selectImage,suggester'; - - // TODO this line is mandatory when a custom skin is defined, it should not be mandatory - CKEDITOR.basePath = '/commons-extension/ckeditor/'; - var toolbarHeight = 39; - commentInput.ckeditor({ - customConfig: eXo.env.portal.context + '/' + eXo.env.portal.rest + '/richeditor/configuration?type=document-preview&v=' + eXo.env.client.assetsVersion, - extraPlugins: extraPlugins, - typeOfRelation: 'mention_comment', - spaceURL: this.settings.activity.spaceURL, - on : { - instanceReady : function ( evt ) { - // Hide the editor toolbar - $("#CommentButton").prop("disabled", true); - $('#' + evt.editor.id + '_bottom').removeClass('cke_bottom_visible'); - - }, - focus : function ( evt ) { - // Show the editor toolbar, except for smartphones in landscape mode - if ($(window).width() > 767 || $(window).width() < $(window).height()) { - //$('#' + evt.editor.id + '_bottom').css('display', 'block'); - evt.editor.execCommand('autogrow'); - var $content = $('#' + evt.editor.id + '_contents'); - var contentHeight = $content.height(); - var $ckeBottom = $('#' + evt.editor.id + '_bottom'); - $ckeBottom[0].style.display = "block"; - var originalHeight = $ckeBottom.css('height', 'auto').outerHeight(); - toolbarHeight = $ckeBottom.addClass('cke_bottom_visible').outerHeight(); - var heightToAddVisibleClass = toolbarHeight - originalHeight; - $ckeBottom.removeClass('cke_bottom_visible').css('height', '0px'); - $ckeBottom.animate({ - height: "" + toolbarHeight - }, { - step: function(number, tween) { - $content.height(contentHeight - number); - if (number >= heightToAddVisibleClass) { - $ckeBottom.addClass('cke_bottom_visible'); - } - } - }); - } else { - $('#' + evt.editor.id + '_bottom').removeClass('cke_bottom_visible'); - $('#' + evt.editor.id + '_bottom')[0].style.display = "none"; - } - }, - blur : function ( evt ) { - // Hide the editor toolbar - if ($(window).width() > 767 || $(window).width() < $(window).height()) { - $('#' + evt.editor.id + '_contents').css('height', $('#' + evt.editor.id + '_contents').height() + toolbarHeight); - $('#' + evt.editor.id + '_bottom').css('height', '0px'); - $('#' + evt.editor.id + '_bottom').removeClass('cke_bottom_visible'); - } - }, - change: function( evt) { - var newData = evt.editor.getData(); - var pureText = newData? newData.replace(/<[^>]*>/g, "").replace(/ /g,"").trim() : ""; - - if (pureText.length > 0 && pureText.length <= MAX_LENGTH) { - $("#CommentButton").removeAttr("disabled"); - } else { - $("#CommentButton").prop("disabled", true); - } - - if (pureText.length <= MAX_LENGTH) { - evt.editor.getCommand('selectImage').enable(); - } else { - evt.editor.getCommand('selectImage').disable(); - } - }, - key: function( evt) { - var newData = evt.editor.getData(); - var pureText = newData? newData.replace(/<[^>]*>/g, "").replace(/ /g,"").trim() : ""; - if (pureText.length > MAX_LENGTH) { - if ([8, 46, 33, 34, 35, 36, 37,38,39,40].indexOf(evt.data.keyCode) < 0) { - evt.cancel(); - } - } - } - } - }); - }, - show: function () { - $('#documentPreviewContainer').show(); - $('body').css('overflow', 'hidden'); - }, - - hide: function () { - $('#documentPreviewContainer').hide(); - $('body').css('overflow', ''); - }, - - goToNext: function () { - if(this.settings && this.settings.activity && this.settings.activity.next) { - $(this.settings.activity.next).click(); - } - }, - - goToPrevious: function () { - if(this.settings && this.settings.activity && this.settings.activity.previous) { - $(this.settings.activity.previous).click(); - } - } - }; - - // Bind Esc key - var closeEventHandler = function(e) { - $('#presentationMode').blur(); - if (e.keyCode == 27 && ("presentationMode" != e.target.id || $.browser.mozilla)) { - $(".exitWindow > .uiIconClose", $('#uiDocumentPreview')).trigger("click"); - } - } - - var applyReverseEllipsis = function($parent) { - $parent.find('.ellipsis-reverse').each(function() { - var $ellipsisContent = $(this).find(".ellipsis-reverse-content"); - var $ellipsisApply = $(this).find(".ellipsis-reverse-apply"); - var $ellipsisApplyContent = $(this).find(".ellipsis-reverse-apply-content"); - var $ellipsisFirstChild = $ellipsisApplyContent.find(' :first-child'); - if(!$ellipsisApplyContent.length - || !$ellipsisContent.length - || !$(this).offset() - || !$ellipsisFirstChild - || !$ellipsisFirstChild.offset() - || !$ellipsisFirstChild.length) { - return; - } - var applyEllipsisReverse = $ellipsisFirstChild.offset().left - $(this).offset().left -15; - if(applyEllipsisReverse > 0) { - $ellipsisContent.addClass("hidden"); - } else { - $ellipsisContent.removeClass("hidden"); - } - }) - }; - - // Resize Event - var resizeEventHandler = function() { - var pdfDisplayAreaHeight = window.innerHeight - 125; - var $uiDocumentPreview = $('#uiDocumentPreview'); - - // Show empty preview message - var $blockToAppendTo = $uiDocumentPreview.find(".UIResizableBlock"); - if($blockToAppendTo.length == 0 && !documentPreview.settings.doc.isWebContent) { - $blockToAppendTo = $("#documentPreviewContent"); - if($blockToAppendTo.find(".EmptyDocumentPreview").length == 0) { - $blockToAppendTo.append("

${UIActivity.comment.noPreviewOfDocument}
"); - } - } - // Show Next & previous buttons inside resizable div - if($uiDocumentPreview.find("#NavCommands").length == 0) { - if(documentPreview.settings.activity.next || documentPreview.settings.activity.previous) { - $blockToAppendTo.find(".fileContent").before('