diff --git a/apps/spreadsheeteditor/mobile/app/controller/Statusbar.js b/apps/spreadsheeteditor/mobile/app/controller/Statusbar.js index af7700a4c..5f99f5742 100644 --- a/apps/spreadsheeteditor/mobile/app/controller/Statusbar.js +++ b/apps/spreadsheeteditor/mobile/app/controller/Statusbar.js @@ -336,6 +336,63 @@ define([ } }, + renameWorksheet: function() { + var me = this; + if (me.api.asc_getWorksheetsCount() > 0) { + var sindex = me.api.asc_getActiveWorksheetIndex(); + if (me.api.asc_isWorksheetLockedOrDeleted(sindex)) { + return; + } + var current = me.api.asc_getWorksheetName(me.api.asc_getActiveWorksheetIndex()); + + var renameDlg = uiApp.modal({ + title: me.strRenameSheet, + afterText: '
', + buttons: [ + { + text: 'OK', + bold: true, + onClick: function () { + var s = $(renameDlg).find('.modal-text-input[name="modal-sheet-name"]').val(), + wc = me.api.asc_getWorksheetsCount(), items = [], + err = _.isEmpty(s) ? me.errNotEmpty : ((s.length > 2 && s[0]=='"' && s[s.length-1]=='"' || !/[:\\\/\*\?\[\]\']/.test(s)) ? null : me.errNameWrongChar); + if (!err) { + while (wc--) { + if (sindex !== wc) { + items.push(me.api.asc_getWorksheetName(wc).toLowerCase()); + } + } + if (items) { + var testval = s.toLowerCase(); + for (var i = items.length - 1; i >= 0; --i) { + if (items[i] === testval) { + err = me.errNameExists; + } + } + } + } + if (err) { + uiApp.alert( + err, + me.notcriticalErrorTitle, + function () { + _.defer(function() { + me.renameWorksheet(); + }); + } + ); + } else if (s != current) + me.api.asc_renameWorksheet(s); + } + }, + { + text: me.cancelButtonText + } + ] + }); + } + }, + // colors onApiUpdateTabColor: function (index) { @@ -463,6 +520,7 @@ define([ me.statusbar.showTabContextMenu(items, model); }); break; + case 'ren': me.renameWorksheet(); break; default: var _re = /reveal\:(\d+)/.exec(event); if ( _re && !!_re[1] ) { @@ -484,6 +542,10 @@ define([ caption: this.menuDelete, event: 'del', locked: wbLocked || shLocked + },{ + caption: this.menuRename, + event: 'ren', + locked: wbLocked || shLocked },{ caption: this.menuHide, event: 'hide', @@ -508,6 +570,15 @@ define([ errorLastSheet : 'Workbook must have at least one visible worksheet.', errorRemoveSheet: 'Can\'t delete the worksheet.', warnDeleteSheet : 'The worksheet maybe has data. Proceed operation?', - strSheet : 'Sheet' + strSheet : 'Sheet', + menuRename : 'Rename', + errNameExists : 'Worksheet with such name already exist.', + errNameWrongChar: 'A sheet name cannot contains characters: \\, \/, *, ?, [, ], :', + errNotEmpty: 'Sheet name must not be empty', + strRenameSheet: 'Rename Sheet', + strSheetName : 'Sheet Name', + cancelButtonText: 'Cancel', + notcriticalErrorTitle: 'Warning' + }, SSE.Controllers.Statusbar || {})); }); \ No newline at end of file diff --git a/apps/spreadsheeteditor/mobile/locale/en.json b/apps/spreadsheeteditor/mobile/locale/en.json index 5229e0afb..c24293dca 100644 --- a/apps/spreadsheeteditor/mobile/locale/en.json +++ b/apps/spreadsheeteditor/mobile/locale/en.json @@ -274,6 +274,14 @@ "SSE.Controllers.Statusbar.strSheet": "Sheet", "SSE.Controllers.Statusbar.textExternalLink": "External Link", "SSE.Controllers.Statusbar.warnDeleteSheet": "The worksheet maybe has data. Proceed operation?", + "SSE.Controllers.Statusbar.menuRename": "Rename", + "SSE.Controllers.Statusbar.errNameExists": "Worksheet with such name already exist.", + "SSE.Controllers.Statusbar.errNameWrongChar": "A sheet name cannot contains characters: \\, \/, *, ?, [, ], :", + "SSE.Controllers.Statusbar.errNotEmpty": "Sheet name must not be empty", + "SSE.Controllers.Statusbar.strRenameSheet": "Rename Sheet", + "SSE.Controllers.Statusbar.strSheetName": "Sheet Name", + "SSE.Controllers.Statusbar.cancelButtonText": "Cancel", + "SSE.Controllers.Statusbar.notcriticalErrorTitle": "Warning", "SSE.Controllers.Toolbar.dlgLeaveMsgText": "You have unsaved changes in this document. Click 'Stay on this Page' to await the autosave of the document. Click 'Leave this Page' to discard all the unsaved changes.", "SSE.Controllers.Toolbar.dlgLeaveTitleText": "You leave the application", "SSE.Controllers.Toolbar.leaveButtonText": "Leave this Page",