Refactoring custom window buttons

This commit is contained in:
Julia Radzhabova
2023-10-25 11:08:05 +03:00
parent 65ccb45c84
commit b3ae32e477
7 changed files with 12 additions and 17 deletions

View File

@ -179,7 +179,7 @@ define([
'<% if (typeof (buttons) !== "undefined" && _.size(buttons) > 0) { %>' +
'<div class="footer">' +
'<% for(var bt in buttons) { %>' +
'<button class="btn normal dlg-btn <%= buttons[bt].cls %>" result="<%= bt %>"><%= buttons[bt].text %></button>'+
'<button class="btn normal dlg-btn <%= buttons[bt].cls %>" result="<%= bt %>" <% if (buttons[bt].id) { %>id="<%=buttons[bt].id%>" <% } %> ><%= buttons[bt].text %></button>'+
'<% } %>' +
'</div>' +
'<% } %>' +
@ -629,12 +629,12 @@ define([
var newBtns = {};
_.each(options.buttons, function(b){
if (typeof(b) == 'object') {
if (b.value !== undefined)
newBtns[b.value] = {text: b.caption, cls: 'custom' + ((b.primary || options.primary==b.value) ? ' primary' : '')};
if (b.value !== undefined) {
newBtns[b.value] = {text: b.caption, cls: 'auto' + ((b.primary || options.primary==b.value) ? ' primary' : '')};
b.id && (newBtns[b.value].id = b.id);
}
} else if (b!==undefined) {
newBtns[b] = {text: (b=='custom') ? options.customButtonText : arrBtns[b], cls: (options.primary==b || _.indexOf(options.primary, b)>-1) ? 'primary' : ''};
if (b=='custom')
newBtns[b].cls += ' custom';
newBtns[b] = {text: arrBtns[b], cls: (options.primary==b || _.indexOf(options.primary, b)>-1) ? 'primary' : ''};
}
});

View File

@ -1327,7 +1327,7 @@
opacity: @component-disabled-opacity;
}
&.custom {
&.auto {
width: auto;
min-width: 86px;
}

View File

@ -2640,9 +2640,8 @@ define([
width: 500,
msg: this.appOptions.canChangeCoAuthoring ? this.textTryUndoRedo : this.textTryUndoRedoWarn,
iconCls: 'info',
buttons: this.appOptions.canChangeCoAuthoring ? ['custom', 'cancel'] : ['ok'],
buttons: this.appOptions.canChangeCoAuthoring ? [{value: 'custom', caption: this.textStrict}, 'cancel'] : ['ok'],
primary: this.appOptions.canChangeCoAuthoring ? 'custom' : 'ok',
customButtonText: this.textStrict,
dontshow: true,
callback: _.bind(function(btn, dontshow){
if (dontshow) Common.localStorage.setItem("de-hide-try-undoredo", 1);

View File

@ -639,9 +639,8 @@ define([
title: this.notcriticalErrorTitle,
msg: opts.data.error,
iconCls: 'warn',
buttons: _.isEmpty(opts.data.createEmailAccountUrl) ? ['ok'] : ['custom', 'cancel'],
buttons: _.isEmpty(opts.data.createEmailAccountUrl) ? ['ok'] : [{value: 'custom', caption: this.textGoToMail}, 'cancel'],
primary: _.isEmpty(opts.data.createEmailAccountUrl) ? ['ok'] : 'custom',
customButtonText: this.textGoToMail,
callback: _.bind(function(btn){
if (btn == 'custom') {
window.open(opts.data.createEmailAccountUrl, "_blank");

View File

@ -2034,9 +2034,8 @@ define([
width: 500,
msg: this.appOptions.canChangeCoAuthoring ? this.textTryUndoRedo : this.textTryUndoRedoWarn,
iconCls: 'info',
buttons: this.appOptions.canChangeCoAuthoring ? ['custom', 'cancel'] : ['ok'],
buttons: this.appOptions.canChangeCoAuthoring ? [{value: 'custom', caption: this.textStrict}, 'cancel'] : ['ok'],
primary: this.appOptions.canChangeCoAuthoring ? 'custom' : 'ok',
customButtonText: this.textStrict,
dontshow: true,
callback: _.bind(function(btn, dontshow){
if (dontshow) Common.localStorage.setItem("pdfe-hide-try-undoredo", 1);

View File

@ -2198,9 +2198,8 @@ define([
width: 500,
msg: this.appOptions.canChangeCoAuthoring ? this.textTryUndoRedo : this.textTryUndoRedoWarn,
iconCls: 'info',
buttons: this.appOptions.canChangeCoAuthoring ? ['custom', 'cancel'] : ['ok'],
buttons: this.appOptions.canChangeCoAuthoring ? [{value: 'custom', caption: this.textStrict}, 'cancel'] : ['ok'],
primary: this.appOptions.canChangeCoAuthoring ? 'custom' : 'ok',
customButtonText: this.textStrict,
dontshow: true,
callback: _.bind(function(btn, dontshow){
if (dontshow) window.localStorage.setItem("pe-hide-try-undoredo", 1);

View File

@ -2933,9 +2933,8 @@ define([
width: 500,
msg: this.appOptions.canChangeCoAuthoring ? this.textTryUndoRedo : this.textTryUndoRedoWarn,
iconCls: 'info',
buttons: this.appOptions.canChangeCoAuthoring ? ['custom', 'cancel'] : ['ok'],
buttons: this.appOptions.canChangeCoAuthoring ? [{value: 'custom', caption: this.textStrict}, 'cancel'] : ['ok'],
primary: this.appOptions.canChangeCoAuthoring ? 'custom' : 'ok',
customButtonText: this.textStrict,
dontshow: true,
callback: _.bind(function(btn, dontshow){
if (dontshow) window.localStorage.setItem("sse-hide-try-undoredo", 1);