Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
<%--
/**
* Copyright (c) 2000-present Liferay, Inc. All rights reserved.
*
* This library is free software; you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License as published by the Free
* Software Foundation; either version 2.1 of the License, or (at your option)
* any later version.
*
* This library is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*/
--%>
<%
boolean changeableDefaultLanguage = journalEditDDMStructuresDisplayContext.changeableDefaultLanguage();
String defaultLanguageId = LocaleUtil.toLanguageId(LocaleUtil.getSiteDefault());
if ((ddmForm != null) && (ddmForm.getDefaultLocale() != null)) {
String ddmFormDefaultLanguageId = LocaleUtil.toLanguageId(ddmForm.getDefaultLocale());
if (!Objects.equals(defaultLanguageId, ddmFormDefaultLanguageId)) {
changeableDefaultLanguage = true;
}
defaultLanguageId = ddmFormDefaultLanguageId;
}
%>
var Lang = A.Lang;
var STR_VALUE = 'value';
var displayWarning = function (message) {
Liferay.Util.openToast({
message: message,
type: 'warning',
});
};
var formEditor;
var getContentValue = function () {
var content;
if (formEditor && !checkViewTabActive()) {
content = formEditor.get(STR_VALUE);
}
else {
content = formBuilder.getContent();
}
return content;
};
var getFormEditor = function () {
if (!formEditor) {
formEditor = new A.AceEditor({
boundingBox: '#formBuilderEditor',
height: 600,
mode: 'xml',
tabSize: 4,
width: 600,
}).render();
}
return formEditor;
};
var checkViewTabActive = function () {
var formBuilderTab = A.one('#formBuilderTab');
var viewTabActive = false;
if (formBuilderTab) {
var ancestor = formBuilderTab.ancestor();
viewTabActive = !ancestor.hasClass('hide');
}
return viewTabActive;
};
var reloadFormBuilderData = function (content) {
if (!Lang.isValue(content)) {
content = window.getContentDefinition();
}
content = content.replace(/nestedFields/g, 'fields');
if (
content.indexOf('availableLanguageIds') === -1 ||
content.indexOf('defaultLanguageId') === -1 ||
content.indexOf('fields') === -1
) {
displayWarning(
''
);
}
else {
try {
content = JSON.parse(content);
}
catch (e) {
displayWarning(
''
);
return;
}
formBuilder.translationManager.set(
'availableLocales',
content.availableLanguageIds
);
content = formBuilder.deserializeDefinitionFields(content);
formBuilder.set('fields', content);
}
};
var setEditorSize = function () {
if (!checkViewTabActive()) {
getFormEditor().set(
'width',
A.one('#formBuilderSourceWrapper').get(
'clientWidth'
)
);
}
};
var switchToSource = function () {
setEditorSize();
var content = formBuilder.getContent();
getFormEditor().set(STR_VALUE, content);
};
var switchToView = function () {
if (formEditor) {
reloadFormBuilderData(formEditor.get(STR_VALUE));
}
else if (formBuilder) {
reloadFormBuilderData(formBuilder.getContent());
}
};
var availableFields = A.Object.getValue(
window,
'<%= HtmlUtil.escapeJS(journalEditDDMStructuresDisplayContext.getAvailableFields()) %>'.split(
'.'
)
);
if (A.Lang.isFunction(availableFields)) {
availableFields = availableFields(A, Liferay.FormBuilder);
}
var formBuilder = new Liferay.FormBuilder({
allowRemoveRequiredFields: true,
availableFields: availableFields,
boundingBox: '#formBuilder',
enableEditing: false,
fieldNameEditionDisabled: <%= (ddmStructure != null) && (DDMStorageLinkLocalServiceUtil.getStructureStorageLinksCount(ddmStructure.getStructureId()) > 0) %>,
fields: <%= journalEditDDMStructuresDisplayContext.getFields() %>,
portletNamespace: '',
portletResourceNamespace: '',
readOnly: <%= ParamUtil.getBoolean(request, "formBuilderReadOnly") %>,
srcNode: '#formBuilderContent',
translationManager: {
availableLocales: <%= journalEditDDMStructuresDisplayContext.getAvailableLocalesJSONArrayString() %>,
boundingBox: '#translationManager',
changeableDefaultLanguage: <%= changeableDefaultLanguage %>,
defaultLocale: '<%= HtmlUtil.escapeJS(defaultLanguageId) %>',
localesMap: <%= journalEditDDMStructuresDisplayContext.getLocalesMap() %>,
srcNode:
'#translationManager .lfr-translation-manager-content',
},
}).render();
var dialog = Liferay.Util.getWindow();
if (dialog) {
dialog.after('widthChange', setEditorSize);
}
var afterShowTab = function (event) {
if (checkViewTabActive()) {
switchToView();
}
else {
switchToSource();
}
};
Liferay.after('showTab', afterShowTab);
var onDestroyPortlet = function (event) {
if (event.portletId === '<%= portletDisplay.getRootPortletId() %>') {
Liferay.detach('showTab', afterShowTab);
Liferay.detach('destroyPortlet', onDestroyPortlet);
var propertyList = formBuilder.propertyList;
if (propertyList) {
propertyList.get('data').each(function (model) {
var editor = model.get('editor');
if (editor) {
editor.destroy();
}
});
}
formBuilder.destroy();
}
};
Liferay.on('destroyPortlet', onDestroyPortlet);
window.formBuilder = formBuilder;
window.getContentValue = getContentValue;
Liferay.on('saveTemplate', function (event) {
A.one('#scriptContent').val(getContentValue());
});
Liferay.fire('formBuilderLoaded', {
formBuilder: formBuilder,
});