From 3647577b2b58d30b9e0cc1d46e7a70282c4e0415 Mon Sep 17 00:00:00 2001 From: Bruno Basto Date: Tue, 4 Dec 2012 11:53:36 -0800 Subject: [PATCH] LPS-30963 onSubmit event should be triggered when saving an article --- .../html/portlet/journal/article/content.jsp | 2 +- .../html/portlet/journal/edit_article.jsp | 35 ++++++++++++++++--- .../docroot/html/portlet/journal/js/main.js | 33 ----------------- 3 files changed, 32 insertions(+), 38 deletions(-) diff --git a/portal-web/docroot/html/portlet/journal/article/content.jsp b/portal-web/docroot/html/portlet/journal/article/content.jsp index c71ab639eb08af..7fb04ead8de0d2 100644 --- a/portal-web/docroot/html/portlet/journal/article/content.jsp +++ b/portal-web/docroot/html/portlet/journal/article/content.jsp @@ -776,7 +776,7 @@ if (Validator.isNotNull(content)) { Liferay.Portlet.Journal.PROXY.pathThemeCss = '<%= HttpUtil.encodeURL(themeDisplay.getPathThemeCss()) %>'; Liferay.Portlet.Journal.PROXY.portletNamespace = ''; - new Liferay.Portlet.Journal(Liferay.Portlet.Journal.PROXY.portletNamespace, '<%= (article != null) ? HtmlUtil.escape(articleId) : StringPool.BLANK %>'); + window.journalPortlet = new Liferay.Portlet.Journal(Liferay.Portlet.Journal.PROXY.portletNamespace, '<%= (article != null) ? HtmlUtil.escape(articleId) : StringPool.BLANK %>'); var defaultLocaleSelector = A.one('#defaultLocale'); diff --git a/portal-web/docroot/html/portlet/journal/edit_article.jsp b/portal-web/docroot/html/portlet/journal/edit_article.jsp index 3498ff87cb2967..e2e03118cb3633 100644 --- a/portal-web/docroot/html/portlet/journal/edit_article.jsp +++ b/portal-web/docroot/html/portlet/journal/edit_article.jsp @@ -155,7 +155,7 @@ request.setAttribute("edit_article.jsp-toLanguageId", toLanguageId); - + @@ -266,14 +266,14 @@ request.setAttribute("edit_article.jsp-toLanguageId", toLanguageId); - + - + - + <% String[] translations = article.getAvailableLocales(); @@ -345,6 +345,10 @@ request.setAttribute("edit_article.jsp-toLanguageId", toLanguageId); submitForm(document.fm1); } + function publishArticle() { + document.fm1.<%= Constants.CMD %>.value = "<%= Constants.PUBLISH %>"; + } + function removeArticleLocale() { if (confirm("<%= UnicodeLanguageUtil.get(pageContext, "are-you-sure-you-want-to-deactivate-this-language") %>")) { document.fm1.<%= Constants.CMD %>.value = "<%= Constants.DELETE_TRANSLATION %>"; @@ -353,6 +357,10 @@ request.setAttribute("edit_article.jsp-toLanguageId", toLanguageId); } } + function saveArticle() { + document.fm1.<%= Constants.CMD %>.value = "<%= Constants.SAVE %>"; + } + function selectDocumentLibrary(url) { document.getElementById(documentLibraryInput).value = url; } @@ -387,6 +395,25 @@ request.setAttribute("edit_article.jsp-toLanguageId", toLanguageId); } } + function submitForm(event) { + event.preventDefault(); + + if (window.journalPortlet) { + var cmd = document.fm1.<%= Constants.CMD %>.value; + + if (cmd === '<%= Constants.TRANSLATE %>') { + window.journalPortlet.translateArticle(); + } + else { + window.journalPortlet.saveArticle(cmd); + } + } + } + + function translateArticle() { + document.fm1.<%= Constants.CMD %>.value = "<%= Constants.TRANSLATE %>"; + } + diff --git a/portal-web/docroot/html/portlet/journal/js/main.js b/portal-web/docroot/html/portlet/journal/js/main.js index e4c79a697dc5e7..6621a4598a6f5f 100644 --- a/portal-web/docroot/html/portlet/journal/js/main.js +++ b/portal-web/docroot/html/portlet/journal/js/main.js @@ -2396,39 +2396,6 @@ AUI.add( } ); } - - if (publishButton) { - publishButton.detach('click'); - - publishButton.on( - 'click', - function() { - instance.saveArticle('publish'); - } - ); - } - - if (saveButton) { - saveButton.detach('click'); - - saveButton.on( - 'click', - function() { - instance.saveArticle(); - } - ); - } - - if (translateButton) { - translateButton.detach('click'); - - translateButton.on( - 'click', - function() { - instance.translateArticle(); - } - ); - } }, _createDynamicNode: function(nodeName, attributeMap) {