diff --git a/apps/documenteditor/embed/js/ApplicationController.js b/apps/documenteditor/embed/js/ApplicationController.js
index 5a306ed6a..eedd90822 100644
--- a/apps/documenteditor/embed/js/ApplicationController.js
+++ b/apps/documenteditor/embed/js/ApplicationController.js
@@ -43,7 +43,8 @@ DE.ApplicationController = new(function(){
labelDocName,
appOptions = {},
btnSubmit,
- _submitFail, $submitedTooltip, $requiredTooltip;
+ _submitFail, $submitedTooltip, $requiredTooltip,
+ $listControlMenu, listControlItems = [], listObj;
var LoadingDocument = -256;
@@ -273,6 +274,97 @@ DE.ApplicationController = new(function(){
}
}
+ function onShowContentControlsActions(obj, x, y) {
+ switch (obj.type) {
+ case Asc.c_oAscContentControlSpecificType.Picture:
+ if (obj.pr && obj.pr.get_Lock) {
+ var lock = obj.pr.get_Lock();
+ if (lock == Asc.c_oAscSdtLockType.SdtContentLocked || lock==Asc.c_oAscSdtLockType.ContentLocked)
+ return;
+ }
+ api.asc_addImage(obj);
+ setTimeout(function(){
+ api.asc_UncheckContentControlButtons();
+ }, 500);
+ break;
+ case Asc.c_oAscContentControlSpecificType.DropDownList:
+ case Asc.c_oAscContentControlSpecificType.ComboBox:
+ onShowListActions(obj, x, y);
+ break;
+ }
+ }
+
+ function onHideContentControlsActions() {
+ $listControlMenu && $listControlMenu.hide();
+ api.asc_UncheckContentControlButtons();
+ }
+
+ function onShowListActions(obj, x, y) {
+ var type = obj.type,
+ props = obj.pr,
+ specProps = (type == Asc.c_oAscContentControlSpecificType.ComboBox) ? props.get_ComboBoxPr() : props.get_DropDownListPr(),
+ isForm = !!props.get_FormPr();
+
+ var menuContainer = DE.ApplicationView.getMenuForm();
+
+ if (!$listControlMenu) {
+ $listControlMenu = menuContainer.find('ul');
+ $listControlMenu.on('click', 'li', function(e) {
+ var value = $(e.target).attr('value');
+ if (value) {
+ value = parseInt(value);
+ setTimeout(function(){
+ (value!==-1) && api.asc_SelectContentControlListItem(listControlItems[value], listObj.get_InternalId());
+ }, 1);
+ }
+ });
+ $('#editor_sdk').on('click', function(e){
+ if (e.target.localName == 'canvas') {
+ if (me._preventClick)
+ me._preventClick = false;
+ else {
+ $listControlMenu && $listControlMenu.hide();
+ api.asc_UncheckContentControlButtons();
+ }
+ }
+ });
+ }
+ $listControlMenu.find('li').remove();
+ listControlItems = [];
+ listObj = props;
+
+ if (specProps) {
+ var k = 0;
+ if (isForm){ // for dropdown and combobox form control always add placeholder item
+ var text = props.get_PlaceholderText();
+ $listControlMenu.append('
' +
+ ((text.trim()!=='') ? text : me.txtEmpty) +
+ '');
+ listControlItems.push('');
+ }
+ var count = specProps.get_ItemsCount();
+ k = listControlItems.length;
+ for (var i=0; i' +
+ common.utils.htmlEncode(specProps.get_ItemDisplayText(i)) +
+ '');
+ listControlItems.push(specProps.get_ItemValue(i));
+ }
+ }
+ if (!isForm && listControlItems.length<1) {
+ $listControlMenu.append('' +
+ me.txtEmpty +
+ '');
+ listControlItems.push(-1);
+ }
+ }
+
+ menuContainer.css({left: x, top : y});
+ me._preventClick = true;
+ $listControlMenu.show();
+ }
+
function hidePreloader() {
$('#loading-mask').fadeOut('slow');
}
@@ -350,6 +442,10 @@ DE.ApplicationController = new(function(){
api.asc_registerCallback('asc_onPrint', onPrint);
api.asc_registerCallback('asc_onPrintUrl', onPrintUrl);
api.asc_registerCallback('sync_onAllRequiredFormsFilled', onFillRequiredFields);
+ if (appOptions.canFillForms) {
+ api.asc_registerCallback('asc_onShowContentControlsActions', onShowContentControlsActions);
+ api.asc_registerCallback('asc_onHideContentControlsActions', onHideContentControlsActions);
+ }
Common.Gateway.on('processmouse', onProcessMouse);
Common.Gateway.on('downloadas', onDownloadAs);
@@ -812,6 +908,7 @@ DE.ApplicationController = new(function(){
textAnonymous: 'Anonymous',
textRequired: 'Fill all required fields to send form.',
textGotIt: 'Got it',
- errorForceSave: "An error occurred while saving the file. Please use the 'Download as' option to save the file to your computer hard drive or try again later."
+ errorForceSave: "An error occurred while saving the file. Please use the 'Download as' option to save the file to your computer hard drive or try again later.",
+ txtEmpty: '(Empty)'
}
})();
\ No newline at end of file
diff --git a/apps/documenteditor/embed/js/ApplicationView.js b/apps/documenteditor/embed/js/ApplicationView.js
index 75a8adb04..0f74bdaf0 100644
--- a/apps/documenteditor/embed/js/ApplicationView.js
+++ b/apps/documenteditor/embed/js/ApplicationView.js
@@ -36,6 +36,7 @@ if (DE === undefined) {
DE.ApplicationView = new(function(){
var $btnTools;
+ var $menuForm;
// Initialize view
@@ -63,11 +64,23 @@ DE.ApplicationView = new(function(){
return $btnTools.parent().find(name);
}
+ function getMenuForm() {
+ if (!$menuForm) {
+ $menuForm = $('');
+ $('#editor_sdk').append($menuForm);
+ }
+ return $menuForm;
+ }
+
return {
create: createView
, tools: {
get: getTools
},
+ getMenuForm: getMenuForm,
txtDownload: 'Download',
txtPrint: 'Print',
diff --git a/apps/documenteditor/embed/locale/en.json b/apps/documenteditor/embed/locale/en.json
index de0c0c291..18212d966 100644
--- a/apps/documenteditor/embed/locale/en.json
+++ b/apps/documenteditor/embed/locale/en.json
@@ -34,6 +34,7 @@
"DE.ApplicationController.unknownErrorText": "Unknown error.",
"DE.ApplicationController.unsupportedBrowserErrorText": "Your browser is not supported.",
"DE.ApplicationController.waitText": "Please, wait...",
+ "DE.ApplicationController.txtEmpty": "(Empty)",
"DE.ApplicationView.txtDownload": "Download",
"DE.ApplicationView.txtDownloadDocx": "Download as docx",
"DE.ApplicationView.txtDownloadPdf": "Download as pdf",