diff --git a/.gitignore b/.gitignore index 762bf42..ae9cc1e 100644 --- a/.gitignore +++ b/.gitignore @@ -4,3 +4,7 @@ bin .settings .idea *.iml +package-lock.json +node_modules +.classpath +.project diff --git a/bnd.bnd b/bnd.bnd index 4f4e64b..cff728c 100644 --- a/bnd.bnd +++ b/bnd.bnd @@ -1,6 +1,6 @@ Bundle-Name: Liferay Dummy Factory Portlet Bundle-SymbolicName: liferay.dummy.factory -Bundle-Version: 7.3.1 +Bundle-Version: 7.4.0 Web-ContextPath: /liferay-dummy-factory -dsannotations-options: inherit -sources: true diff --git a/build.gradle b/build.gradle index d027bdc..27a88d2 100644 --- a/build.gradle +++ b/build.gradle @@ -85,7 +85,6 @@ dependencies { compile "com.liferay:com.liferay.blogs.api" compile "com.liferay:com.liferay.portal.settings.api" - compile "com.liferay:com.liferay.portal.settings.lang" compile "com.liferay:com.liferay.journal.api" compile "com.liferay:com.liferay.journal.service" diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index d77c131..870db93 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,5 @@ #Wed Apr 08 16:42:57 JST 2020 -distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.4-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-6.6.1-all.zip distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStorePath=wrapper/dists diff --git a/latest/liferay.dummy.factory-7.3.1.jar b/latest/liferay.dummy.factory-7.4.0.jar similarity index 79% rename from latest/liferay.dummy.factory-7.3.1.jar rename to latest/liferay.dummy.factory-7.4.0.jar index 0b15c8b..1c12a73 100644 Binary files a/latest/liferay.dummy.factory-7.3.1.jar and b/latest/liferay.dummy.factory-7.4.0.jar differ diff --git a/package.json b/package.json index b798dbf..c424f46 100644 --- a/package.json +++ b/package.json @@ -2,12 +2,12 @@ "name": "liferay-dummy-factory", "version": "1.0.0", "dependencies": { - "jquery": "^3.5.1", - "lodash": "^4.17.20" + "jquery": "^3.6.0", + "lodash": "^4.17.21" }, "devDependencies": { - "@liferay/npm-scripts": "^34.0.1", - "liferay-npm-bundler": "^2.20.0" + "@liferay/npm-scripts": "^45.0.0", + "liferay-npm-bundler": "^2.24.3" }, "scripts": { "build": "liferay-npm-bundler" diff --git a/src/main/java/com/liferay/support/tools/company/CompanyDefaultDummyGenerator.java b/src/main/java/com/liferay/support/tools/company/CompanyDefaultDummyGenerator.java index 0070b83..70bdc74 100644 --- a/src/main/java/com/liferay/support/tools/company/CompanyDefaultDummyGenerator.java +++ b/src/main/java/com/liferay/support/tools/company/CompanyDefaultDummyGenerator.java @@ -80,7 +80,8 @@ protected void exec(ActionRequest request, CompanyContext paramContext) paramContext.isActive()); _portalInstancesLocalService.initializePortalInstance( - paramContext.getServletContext(), company.getWebId()); + company.getCompanyId(), company.getWebId(), + paramContext.getServletContext()); } catch (Exception e) { //Finish progress diff --git a/src/main/java/com/liferay/support/tools/journal/JournalUtils.java b/src/main/java/com/liferay/support/tools/journal/JournalUtils.java index 9dc33e5..71fcc79 100644 --- a/src/main/java/com/liferay/support/tools/journal/JournalUtils.java +++ b/src/main/java/com/liferay/support/tools/journal/JournalUtils.java @@ -53,7 +53,7 @@ public String buildFields(long groupId, String[] locales, String baseArticle) th locales, LocaleUtil.getDefault()); - return _journalConverter.getContent(ddmStructure, fields); + return _journalConverter.getContent(ddmStructure, fields, groupId); } /** @@ -79,7 +79,7 @@ public String buildFields(long groupId, DDMStructure ddmStructure, String[] loca locales, LocaleUtil.getDefault()); - return _journalConverter.getContent(ddmStructure, fields); + return _journalConverter.getContent(ddmStructure, fields, groupId); } @Reference diff --git a/src/main/java/com/liferay/support/tools/utils/JqueryResolver.java b/src/main/java/com/liferay/support/tools/utils/JqueryResolver.java new file mode 100644 index 0000000..8c9fd1d --- /dev/null +++ b/src/main/java/com/liferay/support/tools/utils/JqueryResolver.java @@ -0,0 +1,13 @@ +package com.liferay.support.tools.utils; + +import com.liferay.frontend.js.loader.modules.extender.npm.JSPackage; +import com.liferay.frontend.js.loader.modules.extender.npm.NPMResolver; + +import javax.portlet.RenderRequest; + +public class JqueryResolver { + static public void exec(RenderRequest renderRequest, NPMResolver npmResolver) { + JSPackage jsPackage = npmResolver.getDependencyJSPackage("jquery"); + renderRequest.setAttribute("jqueryResolver", jsPackage.getResolvedId()); + } +} diff --git a/src/main/resources/META-INF/resources/blogs.jsp b/src/main/resources/META-INF/resources/blogs.jsp index 5d243d0..5b1cae7 100644 --- a/src/main/resources/META-INF/resources/blogs.jsp +++ b/src/main/resources/META-INF/resources/blogs.jsp @@ -1,131 +1,152 @@ - -<%@ include file="/init.jsp"%> +<%@ include file="/init.jsp" %>
- - - - - <%@ include file="/command_select.jspf"%> - - - - - -
-

Create Blog posts   - -

+ + + + + <%@ include file="/command_select.jspf" %> + + + + + + + - - - function execCommand() { - <%= progressId %>.startProgress(); - submitForm(document.fm); - } + function execCommand() { + <%= progressId %>.startProgress(); + submitForm(document.fm); + } \ No newline at end of file diff --git a/src/main/resources/META-INF/resources/category.jsp b/src/main/resources/META-INF/resources/category.jsp index 6f958f9..192431f 100644 --- a/src/main/resources/META-INF/resources/category.jsp +++ b/src/main/resources/META-INF/resources/category.jsp @@ -1,323 +1,324 @@ -<%@ include file="/init.jsp"%> +<%@ include file="/init.jsp" %>
- - - - - <%@ include file="/command_select.jspf"%> - - - - - - -
-

Create Category / Vocabulary   - -

-
- - - - <% - String numberOfCategoriesLabel = "Enter the number of categories / vocabralies you would like to create"; - String baseCategoryNameLabel= "Enter the base Category / Vocabulary name"; - List groups = GroupLocalServiceUtil.getGroups(QueryUtil.ALL_POS, QueryUtil.ALL_POS); - final String groupName = GroupConstants.GUEST; - final long companyId = PortalUtil.getDefaultCompanyId(); - final long guestGroupId = GroupLocalServiceUtil.getGroup(companyId, groupName).getGroupId(); - - String defaultOption = "(None)"; - - String scopeGroupdId = String.valueOf(themeDisplay.getScopeGroupId()); - String groupLabel = "Select a site to assign the pages to"; - String pageLabel = "Select a parent page"; - String createContentsTypeLabel = "Select create type"; - String parentCategoryIdLabel = "Enter the parent category ID"; - String privateLayoutLabel = "Make pages private"; - String hiddenLabel = "Hide from Navigation Menu"; - String vocabularyIdLabel = "Vocabulary ID"; - %> - - - - - - - - - - - - - - <% - for (Group group : groups) { - if (group.isSite()) { - %> - - <% - } - } - %> - + + + + + <%@ include file="/command_select.jspf" %> + + + + + + + + + + + <% + String numberOfCategoriesLabel = "Enter the number of categories / vocabralies you would like to create"; + String baseCategoryNameLabel = "Enter the base Category / Vocabulary name"; + List groups = GroupLocalServiceUtil.getGroups(QueryUtil.ALL_POS, QueryUtil.ALL_POS); + final String groupName = GroupConstants.GUEST; + final long companyId = PortalUtil.getDefaultCompanyId(); + final long guestGroupId = GroupLocalServiceUtil.getGroup(companyId, groupName).getGroupId(); - + String defaultOption = "(None)"; + + String groupLabel = "Select a site to assign the pages to"; + String createContentsTypeLabel = "Select create type"; + String parentCategoryIdLabel = "Enter the parent category ID"; + String vocabularyIdLabel = "Vocabulary ID"; + %> + + + + + + + + + + + + + + <% + for (Group group : groups) { + if (group.isSite()) { + %> + + <% + } + } + %> + + + <% - List assetVocabularies = AssetVocabularyServiceUtil.getGroupVocabularies( - guestGroupId, true); + List assetVocabularies = AssetVocabularyServiceUtil.getGroupVocabularies( + guestGroupId, true); - %> + %> - - <% - for (AssetVocabulary assetVocabulary : assetVocabularies) { - %> - - <% - } - %> - - - - (None) - + + <% + for (AssetVocabulary assetVocabulary : assetVocabularies) { + %> + + <% + } + %> + + + + (None) + - - - 1 - - function() { - return (<%= String.valueOf(LDFPortletKeys.C_CATEGORY_CREATE) %> == $('#createContentsType').val()); - } - - - - - - function() { - return (<%= String.valueOf(LDFPortletKeys.C_CATEGORY_CREATE) %> == $('#createContentsType').val()); - } - - + + + 1 + + function() { + return (<%= String.valueOf(LDFPortletKeys.C_CATEGORY_CREATE) %> == document.getElementById('createContentsType').value); + } + + + + + + function() { + return (<%= String.valueOf(LDFPortletKeys.C_CATEGORY_CREATE) %> == document.getElementById('createContentsType').value); + } + + - <% - String numberOfVocabularyLabel = "Number of vocabulary"; - String baseVocabularyNameLabel = "Base Vocabulary Name"; - %> - -<% -// Because of bug of lifeary-ui:upload-progress, you need to add the following parameter in the request. -String progressSessionKey = ProgressTracker.PERCENT + progressId; -request.setAttribute("liferay-ui:progress:sessionKey", progressSessionKey); -%> - - - + + + + + <% + // Because of bug of lifeary-ui:upload-progress, you need to add the following parameter in the request. + String progressSessionKey = ProgressTracker.PERCENT + progressId; + request.setAttribute("liferay-ui:progress:sessionKey", progressSessionKey); + %> + +
+
- function execCommand() { - <%= progressId %>.startProgress(); - submitForm(document.fm); - } + function execCommand() { + <%= progressId %>.startProgress(); + submitForm(document.fm); + } - + // Manage GroupID list display - var createContentsType = A.one('#createContentsType'); - $('#createContentsType').on( - 'change load', - function() { - //-------------------------------- - // Contents Creation fields switch - //-------------------------------- - var cmp_str = "contentsType" + createContentsType.val(); - - $('.contentsTypeGroup').each(function(index){ - $(this).toggle((cmp_str === $(this).attr("id"))); - }); - } - ); + var createContentsType = document.getElementById('createContentsType'); + createContentsType.addEventListener("change load", function() { + //-------------------------------- + // Contents Creation fields switch + //-------------------------------- + var cmp_str = "contentsType" + createContentsType.value; + var ctg = document.getElementsByClassName("contentsTypeGroup"); + for (var i = 0; i < ctg.length; i++) { + ctg[i].style.display = (cmp_str === document.getElementById(this).getAttribute("id")) ? "block" : "none"; + } + }); <%-- Thread List Update --%> - + - - // Update category list - function categoryListUpdate() { - var defer = $.Deferred(); - - Liferay.Service( - '/assetcategory/get-vocabulary-categories', - { - vocabularyId:$('#vocabularyId').val() , - start: -1 , - end: -1, - "+obc":"com.liferay.portlet.asset.util.comparator.AssetCategoryCreateDateComparator" - }, - function(dataIn) { - var data = dataIn; - - Liferay.Loader.require("<%=lodashResolver %>", function(_lodash) { - (function() { - var _ = _lodash; - - //Load Template - var tmpl = _.template($('#category_options').html()); - var listAll = tmpl({ - categoryId:"<%= String.valueOf(AssetCategoryConstants.DEFAULT_PARENT_CATEGORY_ID) %>", - categoryName:"(None)", - selected:"true" - }); - - _.map(data,function(n) { - listAll += - tmpl( - { - categoryId:(n.categoryId) ? _.escape(n.categoryId) : "", - categoryName:(n.titleCurrentValue) ? _.escape(n.titleCurrentValue) : "", - selected:"false" - } - ); - }); - var catObj = $('#parentCategoryId'); - catObj.empty(); - catObj.append(listAll); - defer.resolve(); - - })() - }, function(error) { - console.error(error) - }); - - } - ); - return defer.promise(); - } - - // Vocabulary ID - $('#vocabularyId').on( - 'change load', - function(event) { - //Update thread list - categoryListUpdate(); - } - ); - - // Group (Site) - $('#group').on( - 'change load', - function(event) { - - //Update thread list - vocabularyUpdate() - .then(function() { - categoryListUpdate(); - }); - } - ); - - // Update vocabulary list - function vocabularyUpdate() { - var defer = $.Deferred(); - - $('#group').on( - 'change load', - function(event) { - Liferay.Service( - '/assetvocabulary/get-group-vocabularies', - { - groupId: $('#group').val() - }, - function(dataIn) { - var data = dataIn; - - Liferay.Loader.require("<%=lodashResolver %>", function(_lodash) { - (function() { - var _ = _lodash; - - //Load Template - var tmpl = _.template($('#vocabulary_options').html()); - var listAll = ""; - _.map(data,function(n) { - listAll += - tmpl({ - vocabularyId:(n.vocabularyId) ? _.escape(n.vocabularyId) : "", - vocabularyName:(n.titleCurrentValue) ? _.escape(n.titleCurrentValue) : "" - }); - }); - var catObj = $('#vocabularyId'); - catObj.empty(); - catObj.append(listAll); - defer.resolve(); - - })() - }, function(error) { - console.error(error) - }); - } - ); - } - ); - return defer.promise(); - } - \ No newline at end of file + // Update category list + function categoryListUpdate() { + var defer = $.Deferred(); + + Liferay.Service( + '/assetcategory/get-vocabulary-categories', + { + vocabularyId:document.getElementById('vocabularyId').value , + start: -1 , + end: -1, + "+obc":"com.liferay.portlet.asset.util.comparator.AssetCategoryCreateDateComparator" + }, + function(dataIn) { + var data = dataIn; + + Liferay.Loader.require("<%=lodashResolver %>", function(_lodash) { + (function() { + var _ = _lodash; + + //Load Template + var tmpl = _.template(document.getElementById('category_options').innerHTML); + var listAll = tmpl({ + categoryId:"<%= String.valueOf(AssetCategoryConstants.DEFAULT_PARENT_CATEGORY_ID) %>", + categoryName:"(None)", + selected:"true" + }); + + _.map(data,function(n) { + listAll += + tmpl( + { + categoryId:(n.categoryId) ? _.escape(n.categoryId) : "", + categoryName:(n.titleCurrentValue) ? _.escape(n.titleCurrentValue) : "", + selected:"false" + } + ); + }); + var catObj = document.getElementById('parentCategoryId'); + catObj.empty(); + catObj.append(listAll); + defer.resolve(); + + })() + }, function(error) { + console.error(error) + }); + + } + ); + return defer.promise(); + } + + // Vocabulary ID + document.getElementById('vocabularyId') + .addEventListener("change load", function(event) { + //Update thread list + categoryListUpdate(); + }) + + // Group (Site) + document.getElementById('group') + .addEventListener("change load", function(event) { + //Update thread list + vocabularyUpdate() + .then(function() { + categoryListUpdate(); + }); + }) + + function Deferred (){ + let res,rej,p = new Promise((a,b)=>(res = a, rej = b)); + p.resolve = res; + p.reject = rej; + return p; + } + + // Update vocabulary list + function vocabularyUpdate() { + var defer = Deferred(); + document.getElementById('group') + .addEventListener("change load", function(event) { + Liferay.Service( + '/assetvocabulary/get-group-vocabularies', + { + groupId: document.getElementById('group').value + }, + function(dataIn) { + var data = dataIn; + + Liferay.Loader.require("<%=lodashResolver %>", function(_lodash) { + (function() { + var _ = _lodash; + + //Load Template + var tmpl = _.template(document.getElementById('vocabulary_options').innerHTML); + var listAll = ""; + _.map(data,function(n) { + listAll += + tmpl({ + vocabularyId:(n.vocabularyId) ? _.escape(n.vocabularyId) : "", + vocabularyName:(n.titleCurrentValue) ? _.escape(n.titleCurrentValue) : "" + }); + }); + var catObj = document.getElementById('vocabularyId'); + catObj.empty(); + catObj.append(listAll); + defer.resolve(); + + })() + }, function(error) { + console.error(error) + }); + } + ); + }) + + return defer.resolve(); + } + diff --git a/src/main/resources/META-INF/resources/company.jsp b/src/main/resources/META-INF/resources/company.jsp index fbfaecf..34da30e 100644 --- a/src/main/resources/META-INF/resources/company.jsp +++ b/src/main/resources/META-INF/resources/company.jsp @@ -16,25 +16,28 @@ - -
-

Create Companies   - -

-
- - <% String numberOfCompaniesLabel= "Enter the number of companies you would like to create"; diff --git a/src/main/resources/META-INF/resources/documents.jsp b/src/main/resources/META-INF/resources/documents.jsp index e60fed4..08634d7 100644 --- a/src/main/resources/META-INF/resources/documents.jsp +++ b/src/main/resources/META-INF/resources/documents.jsp @@ -1,248 +1,286 @@ -<%@ include file="/init.jsp"%> +<%@ include file="/init.jsp" %>
- - - - - <%@ include file="/command_select.jspf"%> - - - - - + + + + + <%@ include file="/command_select.jspf" %> + + + + +

Create Documents   -

- - function execCommand() { - <%= progressId %>.startProgress(); - submitForm(document.fm); - } + function execCommand() { + <%= progressId %>.startProgress(); + submitForm(document.fm); + } + var handleClick = function (event) { + Liferay.Service( + '/dlfolder/get-folders', + { + groupId: document.getElementById('groupId').value, + parentFolderId: "<%= String.valueOf(DLFolderConstants.DEFAULT_PARENT_FOLDER_ID) %>", + start: -1, + end: -1, + "+obc": "com.liferay.document.library.kernel.util.comparator.FolderIdComparator" + }, + function (dataIn) { + var data = dataIn; - $('#groupId').on( - 'change load', - function(event) { - - Liferay.Service( - '/dlfolder/get-folders', - { - groupId: $('#groupId').val(), - parentFolderId: "<%= String.valueOf(DLFolderConstants.DEFAULT_PARENT_FOLDER_ID) %>", - start: -1, - end: -1, - "+obc":"com.liferay.document.library.kernel.util.comparator.FolderIdComparator" - }, - function(dataIn) { - var data = dataIn; - //Load Template - Liferay.Loader.require("<%=lodashResolver %>", function(_lodash) { - (function() { - var _ = _lodash; - - var tmpl = _.template($('#journal_folder_options').html()); - var listAll = tmpl({ - folderId:"<%= String.valueOf(DLFolderConstants.DEFAULT_PARENT_FOLDER_ID) %>", - name:"(None)", - selected:"true" - }); - - _.map(data,function(n) { - listAll += - tmpl( - { - folderId:(n.folderId) ? _.escape(n.folderId) : "", - name:(n.name) ? _.escape(n.name) : "", - selected:"false" - } - ); - }); - var catObj = $('#folderId'); - catObj.empty(); - catObj.append(listAll); - - })() - }, function(error) { - console.error(error) - }); - - } - ); - } - ); + Liferay.Loader.require("<%=lodashResolver %>", function (_lodash) { + (function () { + var _ = _lodash; + + var tmpl = _.template(document.getElementById('journal_folder_options').innerHTML); + var listAll = tmpl({ + folderId: "<%= String.valueOf(DLFolderConstants.DEFAULT_PARENT_FOLDER_ID) %>", + name: "(None)", + selected: "true" + }); + + _.map(data, function (n) { + listAll += + tmpl( + { + folderId: (n.folderId) ? _.escape(n.folderId) : "", + name: (n.name) ? _.escape(n.name) : "", + selected: "false" + } + ); + }); + var catObj = document.getElementById('folderId'); + catObj.empty(); + catObj.append(listAll); + + })() + }, function (error) { + console.error(error) + }); + + } + ); + } + + // Register listeners to the dom + var elm = document.createElement("groupId"); + elm.addEventListener("change load", handleClick); diff --git a/src/main/resources/META-INF/resources/mb.jsp b/src/main/resources/META-INF/resources/mb.jsp index 87818af..7e53d2b 100644 --- a/src/main/resources/META-INF/resources/mb.jsp +++ b/src/main/resources/META-INF/resources/mb.jsp @@ -17,29 +17,30 @@ - -
-

Create Message Board   - -

-
- - <% String numberOfMBLabel= "Enter the number of threads / categories you would like to create"; - String baseTitleLabel= "Enter the base title"; - String baseArticleLabel = "Enter the contents"; String defaultOption = "(None)"; String groupIdLabel = "Select a site to assign the threads / categories to"; String createContentsTypeLabel = "Select create type"; @@ -60,7 +61,8 @@ final long guestGroupId = GroupLocalServiceUtil.getGroup(companyId, groupName).getGroupId(); %> - + @@ -119,14 +121,14 @@ function() { - return (<%= String.valueOf(LDFPortletKeys.MB_THREAD_CREATE) %> == AUI.$('#createContentsType').val()); + return (<%= String.valueOf(LDFPortletKeys.MB_THREAD_CREATE) %> == document.getElementById('createContentsType').value); } function() { - return (<%= String.valueOf(LDFPortletKeys.MB_THREAD_CREATE) %> == AUI.$('#createContentsType').val()); + return (<%= String.valueOf(LDFPortletKeys.MB_THREAD_CREATE) %> == document.getElementById('createContentsType').value); } @@ -151,14 +153,14 @@ function() { - return (<%= String.valueOf(LDFPortletKeys.MB_CATEGORY_CREATE) %> == AUI.$('#createContentsType').val()); + return (<%= String.valueOf(LDFPortletKeys.MB_CATEGORY_CREATE) %> == document.getElementById('createContentsType').value); } function() { - return (<%= String.valueOf(LDFPortletKeys.MB_CATEGORY_CREATE) %> == AUI.$('#createContentsType').val()); + return (<%= String.valueOf(LDFPortletKeys.MB_CATEGORY_CREATE) %> == document.getElementById('createContentsType').value); } @@ -169,11 +171,11 @@ -<% -// Because of bug of lifeary-ui:upload-progress, you need to add the following parameter in the request. -String progressSessionKey = ProgressTracker.PERCENT + progressId; -request.setAttribute("liferay-ui:progress:sessionKey", progressSessionKey); -%> + <% + // Because of bug of lifeary-ui:upload-progress, you need to add the following parameter in the request. + String progressSessionKey = ProgressTracker.PERCENT + progressId; + request.setAttribute("liferay-ui:progress:sessionKey", progressSessionKey); + %> - // Manage GroupID list display - var createContentsType = A.one('#createContentsType'); - $('#createContentsType').on( - 'change load', - function() { - //-------------------------------- - // Contents Creation fields switch - //-------------------------------- - var cmp_str = "contentsType" + createContentsType.val(); - - $('.contentsTypeGroup').each(function(index){ - $(this).toggle((cmp_str === $(this).attr("id"))); - }); - - //-------------------------------- - // At reply create, remove multiple for select site. - //-------------------------------- - if(<%= String.valueOf(LDFPortletKeys.MB_REPLY_CREATE) %> == createContentsType.val()) { - $("#siteGroupIdWrap").show(); - $("#contentsType<%= String.valueOf(LDFPortletKeys.MB_THREAD_CREATE) %>").show(); - $("#categoryIdWrap").hide(); - $("#groupIdsWrap").hide(); - - //Update thread list - threadListUpdate(); - } else if(<%= String.valueOf(LDFPortletKeys.MB_CATEGORY_CREATE) %> == createContentsType.val()) { - $("#siteGroupIdWrap").show(); - $("#categoryIdWrap").hide(); - $("#groupIdsWrap").hide(); - } else { - $("#siteGroupIdWrap").hide(); - $("#categoryIdWrap").show(); - $("#groupIdsWrap").show(); - } - - } - ); + var createContentsType = document.getElementById('createContentsType'); + var handleClick = function() { + + //-------------------------------- + // Contents Creation fields switch + //-------------------------------- + var cmp_str = "contentsType" + createContentsType.value; + + var ctg = document.getElementsByClassName("contentsTypeGroup"); + for (var i = 0; i < ctg.length; i++) { + ctg[i].style.display = (cmp_str === document.getElementById(this).getAttribute("id")) ? "block" : "none"; + } + + //-------------------------------- + // At reply create, remove multiple for select site. + //-------------------------------- + if(<%= String.valueOf(LDFPortletKeys.MB_REPLY_CREATE) %> == createContentsType.value) { + document.getElementsByClassName("siteGroupIdWrap").style.display = "block"; + document.getElementsByClassName("contentsType<%= String.valueOf(LDFPortletKeys.MB_THREAD_CREATE) %>").style.display = "block"; + document.getElementsByClassName("categoryIdWrap").style.display = "none"; + document.getElementsByClassName("groupIdsWrap").style.display = "none"; + + //Update thread list + threadListUpdate(); + } else if(<%= String.valueOf(LDFPortletKeys.MB_CATEGORY_CREATE) %> == createContentsType.value) { + document.getElementsByClassName("siteGroupIdWrap").style.display = "block"; + document.getElementsByClassName("categoryIdWrap").style.display = "none"; + document.getElementsByClassName("groupIdsWrap").style.display = "none"; + } else { + document.getElementsByClassName("siteGroupIdWrap").style.display = "none"; + document.getElementsByClassName("categoryIdWrap").style.display = "block"; + document.getElementsByClassName("groupIdsWrap").style.display = "block"; + } + + } + // Manage GroupID list display + createContentsType.addEventListener("change load", handleClick); <%-- Thread List Update --%> @@ -244,124 +246,130 @@ request.setAttribute("liferay-ui:progress:sessionKey", progressSessionKey); - + + function ajax(cmd, path, data, handler) { + var xmlhttp = new XMLHttpRequest(); + + xmlhttp.onreadystatechange = function() { + if (xmlhttp.readyState == XMLHttpRequest.DONE) { // XMLHttpRequest.DONE == 4 + if (xmlhttp.status == 200) { + var jsonData = JSON.parse(xmlhttp.response); + handler(jsonData) + } + else { + console.error('status: ' + xmlhttp.status); + } + } + }; + + xmlhttp.open(cmd, path, true); + xmlhttp.send(data); + } + // Update thread list function threadListUpdate() { var data = Liferay.Util.ns( '', { <%=Constants.CMD %>: '<%=MBMVCResourceCommand.CMD_THREAD_LIST%>', - siteGroupId: $('#siteGroupId').val() + siteGroupId: document.getElementById('siteGroupId').value } ); - $.ajax( - '<%= mbListURL.toString() %>', - { - data: data, - success: function(dataIn) { - var data = dataIn; - - Liferay.Loader.require("<%=lodashResolver %>", function(_lodash) { - (function() { - var _ = _lodash; - - //Load Template - var tmpl = _.template($('#message_options').html()); - var listAll = ""; - _.map(data,function(n) { - listAll += - tmpl( - { - rootMessageSubject:(n.rootMessageSubject) ? _.escape(n.rootMessageSubject) : "", - threadId:(n.threadId) ? _.escape(n.threadId) : "", - rootMessageId:(n.rootMessageId) ? _.escape(n.rootMessageId) : "" - } - ); - }); - var pageObj = $('#threadId'); - pageObj.empty(); - pageObj.append(listAll); - - })() - }, function(error) { - console.error(error) - }); - - } - } - ); + var threadListUpdateHandlerFunc = function(dataIn) { + var data = dataIn; + + Liferay.Loader.require("<%=lodashResolver %>", function(_lodash) { + (function() { + var _ = _lodash; + + //Load Template + var tmpl = _.template(document.getElementsByClassName('message_options').innerHTML); + var listAll = ""; + _.map(data,function(n) { + listAll += + tmpl( + { + rootMessageSubject:(n.rootMessageSubject) ? _.escape(n.rootMessageSubject) : "", + threadId:(n.threadId) ? _.escape(n.threadId) : "", + rootMessageId:(n.rootMessageId) ? _.escape(n.rootMessageId) : "" + } + ); + }); + var pageObj = document.getElementsByClassName('threadId'); + pageObj.empty(); + pageObj.append(listAll); + + })() + }, function(error) { + console.error(error) + }); + + } + ajax("POST", '<%= mbListURL.toString() %>', data, threadListUpdateHandlerFunc ) } - + function categoryListUpdate() { var data = Liferay.Util.ns( '', { <%=Constants.CMD %>: '<%=MBMVCResourceCommand.CMD_CATEGORY_LIST%>', - groupIds: $('#groupIds').val().join(',') + groupIds: document.getElementById('groupIds').value.join(',') } ); - $.ajax( - '<%= mbListURL.toString() %>', - { - data: data, - success: function(dataIn) { - var data = dataIn; - - Liferay.Loader.require("<%=lodashResolver %>", function(_lodash) { - (function() { - var _ = _lodash; - - //Load Template - var tmpl = _.template($('#category_options').html()); - var listAll = tmpl({ - categoryId:"<%= String.valueOf(MBCategoryConstants.DEFAULT_PARENT_CATEGORY_ID) %>", - categoryName:"Default" - }); - _.map(data,function(n) { - listAll += - tmpl( - { - categoryId:(n.categoryId) ? _.escape(n.categoryId) : "", - categoryName:(n.categoryName) ? _.escape(n.categoryName) : "" - } - ); - }); - var pageObj = $('#categoryId'); - pageObj.empty(); - pageObj.append(listAll); - - })() - }, function(error) { - console.error(error) - }); - } - } - ); - } - - $('#siteGroupId').on( - 'change load', - function(event) { - //Update thread list - threadListUpdate(); + var categoryListUpdateHandlerFunc = function(dataIn) { + var data = dataIn; + + Liferay.Loader.require("<%=lodashResolver %>", function(_lodash) { + (function() { + var _ = _lodash; + + //Load Template + var tmpl = _.template(document.getElementsByClassName('category_options').innerHTML); + var listAll = tmpl({ + categoryId:"<%= String.valueOf(MBCategoryConstants.DEFAULT_PARENT_CATEGORY_ID) %>", + categoryName:"Default" + }); + _.map(data,function(n) { + listAll += + tmpl( + { + categoryId:(n.categoryId) ? _.escape(n.categoryId) : "", + categoryName:(n.categoryName) ? _.escape(n.categoryName) : "" + } + ); + }); + var pageObj = document.getElementsByClassName('categoryId'); + pageObj.empty(); + pageObj.append(listAll); + + })() + }, function(error) { + console.error(error) + }); } - ); - - $('#groupIds').on( - 'change load', - function(event) { - var groupIds = $(this).val(); - if(groupIds.length == 1) { - //Update category list - $("#categoryIdWrap").show(); - categoryListUpdate(); - } else { - $("#categoryIdWrap").hide(); - } + + ajax("POST", '<%= mbListURL.toString() %>', data, categoryListUpdateHandlerFunc ) + } + + document.createElement("siteGroupId") + .addEventListener("change load", function(event) { + //Update thread list + threadListUpdate(); + }) + + document.createElement("groupIds") + .addEventListener("change load", function(event) { + var groupIds = document.createElement("groupIds").value; + if(groupIds.length == 1) { + //Update category list + document.getElementById("categoryIdWrap").style.display = "block"; + categoryListUpdate(); + } else { + document.getElementById("categoryIdWrap").style.display = "none"; } - ); + }) diff --git a/src/main/resources/META-INF/resources/pages.jsp b/src/main/resources/META-INF/resources/pages.jsp index fcb789d..fd16aba 100644 --- a/src/main/resources/META-INF/resources/pages.jsp +++ b/src/main/resources/META-INF/resources/pages.jsp @@ -1,184 +1,217 @@ -<%@ include file="/init.jsp"%> +<%@ include file="/init.jsp" %>
- - - - - <%@ include file="/command_select.jspf"%> - - - - - -
-

Create Pages   - -

-
- - - - <% - String numberOfPagesLabel= "Enter the number of pages you would like to create"; - String basePageNameLabel= "Enter the base page name (i.e. newPage, page, testPage)"; - List groups = GroupLocalServiceUtil.getGroups(QueryUtil.ALL_POS, QueryUtil.ALL_POS); - String defaultOption = "(None)"; - - String scopeGroupdId = String.valueOf(themeDisplay.getScopeGroupId()); - String groupLabel = "Select a site to assign the pages to"; - String pageLabel = "Select a parent page"; - %> - - - - - - - 1 - - - - - - - - <% - for (Group group : groups) { - if (group.isSite()) { - %> - - <% - } - } - %> - - - - <% - String parentLayoutIdLabel = "Enter the parent page ID"; - String privateLayoutLabel = "Make pages private"; - String hiddenLabel = "Hide from Navigation Menu"; - %> - - - - - - - -<% -// Because of bug of lifeary-ui:upload-progress, you need to add the following parameter in the request. -String progressSessionKey = ProgressTracker.PERCENT + progressId; -request.setAttribute("liferay-ui:progress:sessionKey", progressSessionKey); -%> - -
-
+ + + + + <%@ include file="/command_select.jspf" %> + + + + + + + + + + + <% + String numberOfPagesLabel = "Enter the number of pages you would like to create"; + String basePageNameLabel = "Enter the base page name (i.e. newPage, page, testPage)"; + List groups = GroupLocalServiceUtil.getGroups(QueryUtil.ALL_POS, QueryUtil.ALL_POS); + String defaultOption = "(None)"; + + String scopeGroupdId = String.valueOf(themeDisplay.getScopeGroupId()); + String groupLabel = "Select a site to assign the pages to"; + String pageLabel = "Select a parent page"; + %> + + + + + + + 1 + + + + + + + + <% + for (Group group : groups) { + if (group.isSite()) { + %> + + <% + } + } + %> + + + + <% + String parentLayoutIdLabel = "Enter the parent page ID"; + String privateLayoutLabel = "Make pages private"; + String hiddenLabel = "Hide from Navigation Menu"; + %> + +
+ +
+ + + + + +
+ <% + // Because of bug of lifeary-ui:upload-progress, you need to add the following parameter in the request. + String progressSessionKey = ProgressTracker.PERCENT + progressId; + request.setAttribute("liferay-ui:progress:sessionKey", progressSessionKey); + %> + +
+
- function execCommand() { - <%= progressId %>.startProgress(); - submitForm(document.fm); - } + function execCommand() { + <%= progressId %>.startProgress(); + submitForm(document.fm); + } - + + // Ajax + function ajax(cmd, path, data, handler) { + var xmlhttp = new XMLHttpRequest(); + + xmlhttp.onreadystatechange = function() { + if (xmlhttp.readyState == XMLHttpRequest.DONE) { // XMLHttpRequest.DONE == 4 + if (xmlhttp.status == 200) { + var jsonData = JSON.parse(xmlhttp.response); + handler(jsonData) + } + else { + console.error('status: ' + xmlhttp.status); + } + } + }; + + xmlhttp.open(cmd, path, true); + xmlhttp.send(data); + } + + document.getElementById("group") + .addEventListener("change", function(event) { + var data = Liferay.Util.ns( + '', + { + <%=Constants.CMD %>: '<%=PageMVCResourceCommand.CMD_PAGELIST%>', + siteGroupId: $('#group').val() + } + ); + + ajax("POST", '<%= pagesForASiteURL.toString() %>', data, function(dataIn) { + var data = dataIn; + + Liferay.Loader.require("<%=lodashResolver %>", function(_lodash) { + (function() { + var _ = _lodash; + + //Load Template + var tmpl = _.template(document.getElementById('page_per_site_options').innerHTML); + var listAll = + tmpl({ + name:'(None)', + parentLayoutId:0 + }); + _.map(data,function(n) { + listAll += + tmpl( + { + name:(n.name) ? _.escape(n.name) : "", + parentLayoutId:(n.parentLayoutId) ? _.escape(n.parentLayoutId) : "" + } + ); + }); + var pageObj = document.getElementById('parentLayoutId'); + pageObj.empty(); + pageObj.append(listAll); - $('#group').on( - 'change', - function(event) { - var data = Liferay.Util.ns( - '', - { - <%=Constants.CMD %>: '<%=PageMVCResourceCommand.CMD_PAGELIST%>', - siteGroupId: $('#group').val() - } - ); - - $.ajax( - '<%= pagesForASiteURL.toString() %>', - { - data: data, - success: function(dataIn) { - var data = dataIn; - - Liferay.Loader.require("<%=lodashResolver %>", function(_lodash) { - (function() { - var _ = _lodash; - - //Load Template - var tmpl = _.template($('#page_per_site_options').html()); - var listAll = - tmpl({ - name:'(None)', - parentLayoutId:0 - }); - _.map(data,function(n) { - listAll += - tmpl( - { - name:(n.name) ? _.escape(n.name) : "", - parentLayoutId:(n.parentLayoutId) ? _.escape(n.parentLayoutId) : "" - } - ); - }); - var pageObj = $('#parentLayoutId'); - pageObj.empty(); - pageObj.append(listAll); - - })() - }, function(error) { - console.error(error) - }); - } - } - ); - } - ); + })() + }, function(error) { + console.error(error) + }); + }); + }); diff --git a/src/main/resources/META-INF/resources/sites.jsp b/src/main/resources/META-INF/resources/sites.jsp index 765ec12..2cdaa7f 100644 --- a/src/main/resources/META-INF/resources/sites.jsp +++ b/src/main/resources/META-INF/resources/sites.jsp @@ -1,144 +1,177 @@ -<%@ include file="/init.jsp"%> +<%@ include file="/init.jsp" %>
- - - - - <%@ include file="/command_select.jspf"%> - - - - - - -
-

Create Sites   - -

-
- - - - <% - String numberOfSitesLabel = "Enter the number of sites you would like to create"; - String baseSiteNameLabel = "Enter the base name for the sites"; - String siteTypeLabel = "Site type"; - %> - - - - - - - - - - - - 1 - - - - - - - <% - String parentGroupIdLabel = "Select the parent site"; - String manualMembershipLabel = "Enable manual membership"; - String inheritContentLabel = "Enable inherit content"; - String activeLabel = "Activate site"; - String publicLayoutSetPrototypeIdLabel = "Site Template"; - - List groups = GroupLocalServiceUtil.getGroups(QueryUtil.ALL_POS, QueryUtil.ALL_POS); - String scopeGroupdId = String.valueOf(themeDisplay.getScopeGroupId()); - String defaultOption = "(None)"; - - List layoutSetPrototypes = LayoutSetPrototypeLocalServiceUtil.search( - themeDisplay.getCompanyId(), true, - QueryUtil.ALL_POS, QueryUtil.ALL_POS, null); - %> - - - - - - - -<% -// Because of bug of lifeary-ui:upload-progress, you need to add the following parameter in the request. -String progressSessionKey = ProgressTracker.PERCENT + progressId; -request.setAttribute("liferay-ui:progress:sessionKey", progressSessionKey); -%> - -
-
+ + + + + <%@ include file="/command_select.jspf" %> + + + + + + + + + + + <% + String numberOfSitesLabel = "Enter the number of sites you would like to create"; + String baseSiteNameLabel = "Enter the base name for the sites"; + String siteTypeLabel = "Site type"; + %> + + + + + + + + + + + + 1 + + + + + + + <% + String parentGroupIdLabel = "Select the parent site"; + String manualMembershipLabel = "Enable manual membership"; + String inheritContentLabel = "Enable inherit content"; + String activeLabel = "Activate site"; + String publicLayoutSetPrototypeIdLabel = "Site Template"; + + List groups = GroupLocalServiceUtil.getGroups(QueryUtil.ALL_POS, QueryUtil.ALL_POS); + String defaultOption = "(None)"; + + List layoutSetPrototypes = LayoutSetPrototypeLocalServiceUtil.search( + themeDisplay.getCompanyId(), true, + QueryUtil.ALL_POS, QueryUtil.ALL_POS, null); + %> + +
+ +
+ + + + + +
+ <% + // Because of bug of lifeary-ui:upload-progress, you need to add the following parameter in the request. + String progressSessionKey = ProgressTracker.PERCENT + progressId; + request.setAttribute("liferay-ui:progress:sessionKey", progressSessionKey); + %> + +
+
- function execCommand() { - <%= progressId %>.startProgress(); - submitForm(document.fm); - } + function execCommand() { + <%= progressId %>.startProgress(); + submitForm(document.fm); + } \ No newline at end of file diff --git a/src/main/resources/META-INF/resources/users.jsp b/src/main/resources/META-INF/resources/users.jsp index fe87256..aab3975 100644 --- a/src/main/resources/META-INF/resources/users.jsp +++ b/src/main/resources/META-INF/resources/users.jsp @@ -1,338 +1,399 @@ -<%@ include file="/init.jsp"%> +<%@ include file="/init.jsp" %>
- - - - - - - <%@ include file="/command_select.jspf"%> - - - - - - -
-

Create Users   - -

-
+ + + + + + + <%@ include file="/command_select.jspf" %> - - function execCommand() { - <%= progressId %>.startProgress(); - submitForm(document.fm); - } + function execCommand() { + <%= progressId %>.startProgress(); + submitForm(document.fm); + } - + + function ajax(cmd, path, data, handler) { + var xmlhttp = new XMLHttpRequest(); + + xmlhttp.onreadystatechange = function () { + if (xmlhttp.readyState == XMLHttpRequest.DONE) { // XMLHttpRequest.DONE == 4 + if (xmlhttp.status == 200) { + var jsonData = JSON.parse(xmlhttp.response); + handler(jsonData) + } else { + console.error('status: ' + xmlhttp.status); + } + } + }; - function updateRoles() { - var data = Liferay.Util.ns( - '', - { - <%=Constants.CMD %>: '<%=RoleMVCResourceCommand.CMD_ROLELIST%>', - isSitesSelected: (null==$('#groups').val())?false:true, - isOrganizationSelected: (null==$('#organizations').val())?false:true - } - ); - - $.ajax( - '<%= roleListURL.toString() %>', - { - data: data, - success: function(dataIn) { - var data = dataIn; - - Liferay.Loader.require("<%=lodashResolver %>", function(_lodash) { - (function() { - var _ = _lodash; - - //Load Template - var tmpl = _.template($('#roles_options').html()); - var listAll = ""; - _.map(data,function(n) { - listAll += - tmpl( - { - name:(n.name) ? _.escape(n.name) : "", - roleId:(n.roleId) ? _.escape(n.roleId) : "", - type:(n.type) ? _.escape(n.type) : "" - } - ); - }); - var pageObj = $('#roles') - pageObj.empty(); - pageObj.append(listAll); - - })() - }, function(error) { - console.error(error) - }); - } - } - ); - } - - $('#organizations, #groups').on( - 'change', - function(event) { - updateRoles(); - } - ); - - $( function() { - //Initialize role options - updateRoles(); - }); - \ No newline at end of file + xmlhttp.open(cmd, path, true); + xmlhttp.send(data); + } + + function updateRoles() { + var data = Liferay.Util.ns( + '', + { + <%=Constants.CMD %>: + '<%=RoleMVCResourceCommand.CMD_ROLELIST%>', + isSitesSelected + : + (null == document.getElementById('groups').value) ? false : true, + isOrganizationSelected + : + (null == document.getElementById('organizations').value) ? false : true + }) + ; + + ajax("POST", '<%= roleListURL.toString() %>', data, function (dataIn) { + var data = dataIn; + + Liferay.Loader.require("<%=lodashResolver %>", function (_lodash) { + (function () { + var _ = _lodash; + + //Load Template + var tmpl = _.template(document.getElementById('roles_options').innerHTML); + var listAll = ""; + _.map(data, function (n) { + listAll += + tmpl( + { + name: (n.name) ? _.escape(n.name) : "", + roleId: (n.roleId) ? _.escape(n.roleId) : "", + type: (n.type) ? _.escape(n.type) : "" + } + ); + }); + var pageObj = document.getElementById('roles') + pageObj.empty(); + pageObj.append(listAll); + + })() + }, function (error) { + console.error(error) + }); + }); + + document.createElement("organizations") + .addEventListener("change", function (event) { + updateRoles(); + }); + + document.createElement("groups") + .addEventListener("change", function (event) { + updateRoles(); + }); + + document.addEventListener('DOMContentLoaded', function () { + //Initialize role options + updateRoles(); + }); + } + diff --git a/src/main/resources/META-INF/resources/view.jsp b/src/main/resources/META-INF/resources/view.jsp index a6eb626..45abda1 100644 --- a/src/main/resources/META-INF/resources/view.jsp +++ b/src/main/resources/META-INF/resources/view.jsp @@ -1,112 +1,139 @@ -<%@ include file="/init.jsp"%> +<%@ include file="/init.jsp" %> - +
- - - - - <%@ include file="/command_select.jspf"%> - - - - - -
-

Create organizations   - -

-
- - - <% - String numberOfOrganizationsLabel = "Enter the number of organizations you would like to create"; - String baseOrganizationNameLabel = "Enter the base name for the organizations"; - String parentOrganizationIdLabel = "Select the parent organization"; - String organizationSiteCreateLabel = "Creating organization site"; - %> - - - - - - - - - 1 - - - - - - - <% - //Organization - List organizations = OrganizationLocalServiceUtil.getOrganizations(QueryUtil.ALL_POS, QueryUtil.ALL_POS); - String defaultOption = "(None)"; - %> - - - - - - - -<% -// Because of bug of lifeary-ui:upload-progress, you need to add the following parameter in the request. -String progressSessionKey = ProgressTracker.PERCENT + progressId; -request.setAttribute("liferay-ui:progress:sessionKey", progressSessionKey); -%> - - -
-
- + + + + + <%@ include file="/command_select.jspf" %> + + + + + + + + + + <% + String numberOfOrganizationsLabel = "Enter the number of organizations you would like to create"; + String baseOrganizationNameLabel = "Enter the base name for the organizations"; + String parentOrganizationIdLabel = "Select the parent organization"; + String organizationSiteCreateLabel = "Creating organization site"; + %> + + + + + + + + + 1 + + + + + + + <% + //Organization + List organizations = OrganizationLocalServiceUtil.getOrganizations(QueryUtil.ALL_POS, QueryUtil.ALL_POS); + String defaultOption = "(None)"; + %> + +
+ + + +
+ + + + +
+ + <% + // Because of bug of lifeary-ui:upload-progress, you need to add the following parameter in the request. + String progressSessionKey = ProgressTracker.PERCENT + progressId; + request.setAttribute("liferay-ui:progress:sessionKey", progressSessionKey); + %> + + +
+
+
- function execCommand() { - <%= progressId %>.startProgress(); - submitForm(document.fm); - } + function execCommand() { + <%= progressId %>.startProgress(); + submitForm(document.fm); + } diff --git a/src/main/resources/META-INF/resources/wcm.jsp b/src/main/resources/META-INF/resources/wcm.jsp index b4cfafb..a472299 100644 --- a/src/main/resources/META-INF/resources/wcm.jsp +++ b/src/main/resources/META-INF/resources/wcm.jsp @@ -1,400 +1,435 @@ - -<%@ include file="/init.jsp"%> +<%@ include file="/init.jsp" %> <% - List ddmTemplates = - DDMTemplateLocalServiceUtil.getTemplates( - themeDisplay.getScopeGroupId(), - PortalUtil.getClassNameId(com.liferay.dynamic.data.mapping.model.DDMStructure.class.getName()) - ); - List ddmStructures = - JournalFolderServiceUtil.getDDMStructures( - PortalUtil.getCurrentAndAncestorSiteGroupIds(themeDisplay.getScopeGroupId()), - JournalFolderConstants.DEFAULT_PARENT_FOLDER_ID, - JournalFolderConstants.RESTRICTION_TYPE_INHERIT - ); + List ddmTemplates = + DDMTemplateLocalServiceUtil.getTemplates( + themeDisplay.getScopeGroupId(), + PortalUtil.getClassNameId(com.liferay.dynamic.data.mapping.model.DDMStructure.class.getName()) + ); + List ddmStructures = + JournalFolderServiceUtil.getDDMStructures( + PortalUtil.getCurrentAndAncestorSiteGroupIds(themeDisplay.getScopeGroupId()), + JournalFolderConstants.DEFAULT_PARENT_FOLDER_ID, + JournalFolderConstants.RESTRICTION_TYPE_INHERIT + ); %>
- - - - - - <%@ include file="/command_select.jspf"%> - - - - - - -
-

Create Web Contents   - -

+ + + + + + <%@ include file="/command_select.jspf" %> + + + + + + + - - - function execCommand() { - <%= progressId %>.startProgress(); - submitForm(document.fm); - } + function execCommand() { + <%= progressId %>.startProgress(); + submitForm(document.fm); + } - -$(function() { - var randomAmount = $('#randomAmount'); - //Initialize - $('#randomLink').hide(); - - $('#randomAmount').on( - 'input load visibility', - function() { - $('#randomLink').toggle((0 < randomAmount.val())); - } - ); - - var createContentsType = $('#createContentsType'); - - $('#createContentsType').on( - 'change load', - function() { - $('.contentsTypeGroup').each(function(index){ - var cmp_str = "contentsType" + createContentsType.val(); - $(this).toggle((cmp_str === $(this).attr("id"))); - }); - } - ); -}); + + document.addEventListener('DOMContentLoaded', function () { + var randomAmount = document.getElementById('randomAmount'); + + // Initialize + document.getElementById('randomLink').style.display = "none"; + + document.createElement("randomAmount") + .addEventListener("input load visibility", function(event) { + document.getElementById('randomLink').classList.toggle((0 < randomAmount.value)); + }); + + var createContentsType = document.getElementById('createContentsType'); + + document.createElement("createContentsType") + .addEventListener("change load", function(event) { + var ctg = document.getElementsByClassName("contentsTypeGroup"); + for (var i = 0; i < ctg.length; i++) { + var cmp_str = "contentsType" + createContentsType.value; + ctg[i].style.display = (cmp_str === document.getElementById(this).getAttribute("id")) ? "block" : "none"; + } + }); + }); - - - // Select Folder - var groupIds = $('#groupIds'); - - $('#groupIds').on( - 'change load', - function() { - - Liferay.Service( - '/journal.journalfolder/get-folders', - { - groupId: groupIds.val()[0] - }, - function(objIn) { - var obj = objIn; - - Liferay.Loader.require("<%=lodashResolver %>", function(_lodash) { - //(function() { - var _ = _lodash; - - //Load Template - var tmpl = _.template($('#journal_folders').html()); - var listAll = tmpl({ - name:"(None)", - folderId:0, - groupId:<%=themeDisplay.getScopeGroupId() %> - }); - _.map(obj,function(data) { - listAll += - tmpl( - { - name:data.name, - folderId:data.folderId, - groupId:data.groupId - } - ); - }); - var folderListObj = $('#folderId') - folderListObj.empty(); - folderListObj.append(listAll); - - //})() - }, function(error) { - console.error(error) - }); - } - ); - } - ); - + + // Select Folder + var groupIds = document.getElementById('groupIds'); + groupIds.addEventListener("change load", function() { + + Liferay.Service( + '/journal.journalfolder/get-folders', + { + groupId: groupIds.value[0] + }, + function(objIn) { + var obj = objIn; + + Liferay.Loader.require("<%=lodashResolver %>", function(_lodash) { + //(function() { + var _ = _lodash; + + //Load Template + var tmpl = _.template(document.getElementById('journal_folders').innerHTML); + var listAll = tmpl({ + name:"(None)", + folderId:0, + groupId:<%=themeDisplay.getScopeGroupId() %> + }); + _.map(obj,function(data) { + listAll += + tmpl( + { + name:data.name, + folderId:data.folderId, + groupId:data.groupId + } + ); + }); + var folderListObj = document.getElementById('#folderId') + folderListObj.empty(); + folderListObj.append(listAll); + }, function(error) { + console.error(error) + }); + } + ); + }); - + - var linkLoader = $('#linkLoader'); - var fetchLinks = $('#fetchLinks'); - var linkLists = $('#linkLists'); - var urlList = $('#urlList'); - var randomAmount = $('#randomAmount') - - fetchLinks.on( - 'click', - function(event) { - event.preventDefault(); - Liferay.Util.toggleDisabled('#fetchLinks', true); - linkLoader.show(); - var data = Liferay.Util.ns( - '', - { - numberOfCrawlers: 15, - maxDepthOfCrawling: 3, - maxPagesToFetch: 100, - randomAmount: randomAmount.val(), - urls: urlList.val() - } - ); + var linkLoader = document.getElementById('linkLoader'); + var fetchLinks = document.getElementById('fetchLinks'); + var linkLists = document.getElementById('linkLists'); + var urlList = document.getElementById('urlList'); + var randomAmount = document.getElementById('randomAmount') + + fetchLinks.addEventListener("click", function(event) { + event.preventDefault(); + Liferay.Util.toggleDisabled('#fetchLinks', true); + linkLoader.show(); + var data = Liferay.Util.ns( + '', + { + numberOfCrawlers: 15, + maxDepthOfCrawling: 3, + maxPagesToFetch: 100, + randomAmount: randomAmount.value, + urls: urlList.value + } + ); + + function ajax(cmd, path, data, handler) { + var xmlhttp = new XMLHttpRequest(); - $.ajax( - '<%= linkListURL.toString() %>', - { - data: data, - success: function(data) { - var currentText = linkLists.val(); - linkLists.val(currentText + data.urlstr); - Liferay.Util.toggleDisabled('#fetchLinks', false); - linkLoader.hide(); + xmlhttp.onreadystatechange = function() { + if (xmlhttp.readyState == XMLHttpRequest.DONE) { // XMLHttpRequest.DONE == 4 + if (xmlhttp.status == 200) { + var jsonData = JSON.parse(xmlhttp.response); + handler(jsonData) + } + else { + console.error('status: ' + xmlhttp.status); } } - ); + }; + xmlhttp.open(cmd, path, true); + xmlhttp.send(data); } - ); + ajax("POST", '<%= linkListURL.toString() %>', data, function(data) { + var currentText = linkLists.value; + linkLists.value = currentText + data.urlstr; + Liferay.Util.toggleDisabled('#fetchLinks', false); + linkLoader.hide(); + }); + }) \ No newline at end of file diff --git a/src/main/resources/META-INF/resources/wiki.jsp b/src/main/resources/META-INF/resources/wiki.jsp index 9aca42a..aaf5618 100644 --- a/src/main/resources/META-INF/resources/wiki.jsp +++ b/src/main/resources/META-INF/resources/wiki.jsp @@ -72,7 +72,7 @@ 1 function() { - return (<%= String.valueOf(LDFPortletKeys.W_NODE) %> == AUI.$('#createContentsType').val()); + return (<%= String.valueOf(LDFPortletKeys.W_NODE) %> == document.getElementById('createContentsType').value); } @@ -80,7 +80,7 @@ function() { - return (<%= String.valueOf(LDFPortletKeys.W_NODE) %> == AUI.$('#createContentsType').val()); + return (<%= String.valueOf(LDFPortletKeys.W_NODE) %> == document.getElementById('createContentsType').value); } @@ -97,7 +97,7 @@ 1 function() { - return (<%= String.valueOf(LDFPortletKeys.W_PAGE) %> == AUI.$('#createContentsType').val()); + return (<%= String.valueOf(LDFPortletKeys.W_PAGE) %> == document.getElementById('createContentsType').value); } @@ -122,7 +122,7 @@ 1 function() { - return (<%= String.valueOf(LDFPortletKeys.W_PAGE) %> == AUI.$('#createContentsType').val()); + return (<%= String.valueOf(LDFPortletKeys.W_PAGE) %> == document.getElementById('createContentsType').value); } @@ -130,7 +130,7 @@ function() { - return (<%= String.valueOf(LDFPortletKeys.W_PAGE) %> == AUI.$('#createContentsType').val()); + return (<%= String.valueOf(LDFPortletKeys.W_PAGE) %> == document.getElementById('createContentsType').value); } @@ -176,160 +176,166 @@ request.setAttribute("liferay-ui:progress:sessionKey", progressSessionKey); -$(function() { - // Manage GroupID list display - var createContentsType = $('#createContentsType'); - - $('#createContentsType').on( - 'change', - function() { - initialUpdate(); - } - ); - - // Initialize - initialUpdate(); - - // Initialize when a page rendered. - function initialUpdate() { - //-------------------------------- - // Contents Creation fields switch - //-------------------------------- - var cmp_str = "contentsType" + createContentsType.val(); - $('.contentsTypeGroup').each(function(index){ - $(this).toggle((cmp_str === $(this).attr("id"))); - }); - - //Update thread list - nodesUpdate() - .then(function() { - pagesUpdate(); - }); - } - - // Group ID - $('#groupId').on( - 'change load', - function() { + + + +