|
|
|
@ -1,31 +1,36 @@ |
|
|
|
/** |
|
|
|
* ownCloud |
|
|
|
/* global alert */ |
|
|
|
|
|
|
|
/* |
|
|
|
* @copyright 2019 Christoph Wurst <christoph@winzerhof-wurst.at> |
|
|
|
* |
|
|
|
* @author Bartek Przybylski, Christopher Schäpers, Thomas Tanghus |
|
|
|
* @copyright 2012 Bartek Przybylski bartek@alefzero.eu |
|
|
|
* @author 2019 Christoph Wurst <christoph@winzerhof-wurst.at> |
|
|
|
* |
|
|
|
* This library is free software; you can redistribute it and/or |
|
|
|
* modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE |
|
|
|
* License as published by the Free Software Foundation; either |
|
|
|
* version 3 of the License, or any later version. |
|
|
|
* @license GNU AGPL version 3 or any later version |
|
|
|
* |
|
|
|
* This library is distributed in the hope that it will be useful, |
|
|
|
* This program is free software: you can redistribute it and/or modify |
|
|
|
* it under the terms of the GNU Affero General Public License as |
|
|
|
* published by the Free Software Foundation, either version 3 of the |
|
|
|
* License, or (at your option) any later version. |
|
|
|
* |
|
|
|
* This program 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 AFFERO GENERAL PUBLIC LICENSE for more details. |
|
|
|
* |
|
|
|
* You should have received a copy of the GNU Affero General Public |
|
|
|
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
* GNU Affero General Public License for more details. |
|
|
|
* |
|
|
|
* You should have received a copy of the GNU Affero General Public License |
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/ |
|
|
|
|
|
|
|
/* global alert */ |
|
|
|
import _ from 'underscore' |
|
|
|
import $ from 'jquery' |
|
|
|
|
|
|
|
import OC from './index' |
|
|
|
import OCA from '../OCA/index' |
|
|
|
|
|
|
|
/** |
|
|
|
* this class to ease the usage of jquery dialogs |
|
|
|
* @lends OC.dialogs |
|
|
|
*/ |
|
|
|
var OCdialogs = { |
|
|
|
const Dialogs = { |
|
|
|
// dialog button types
|
|
|
|
YES_NO_BUTTONS: 70, |
|
|
|
OK_BUTTONS: 71, |
|
|
|
@ -49,7 +54,7 @@ var OCdialogs = { |
|
|
|
text, |
|
|
|
title, |
|
|
|
'alert', |
|
|
|
OCdialogs.OK_BUTTON, |
|
|
|
Dialogs.OK_BUTTON, |
|
|
|
callback, |
|
|
|
modal |
|
|
|
); |
|
|
|
@ -62,7 +67,7 @@ var OCdialogs = { |
|
|
|
* @param modal make the dialog modal |
|
|
|
*/ |
|
|
|
info: function (text, title, callback, modal) { |
|
|
|
this.message(text, title, 'info', OCdialogs.OK_BUTTON, callback, modal); |
|
|
|
this.message(text, title, 'info', Dialogs.OK_BUTTON, callback, modal); |
|
|
|
}, |
|
|
|
/** |
|
|
|
* displays confirmation dialog |
|
|
|
@ -77,7 +82,7 @@ var OCdialogs = { |
|
|
|
text, |
|
|
|
title, |
|
|
|
'notice', |
|
|
|
OCdialogs.YES_NO_BUTTONS, |
|
|
|
Dialogs.YES_NO_BUTTONS, |
|
|
|
callback, |
|
|
|
modal |
|
|
|
); |
|
|
|
@ -95,7 +100,7 @@ var OCdialogs = { |
|
|
|
text, |
|
|
|
title, |
|
|
|
'notice', |
|
|
|
OCdialogs.YES_NO_BUTTONS, |
|
|
|
Dialogs.YES_NO_BUTTONS, |
|
|
|
callback, |
|
|
|
modal, |
|
|
|
true |
|
|
|
@ -113,7 +118,7 @@ var OCdialogs = { |
|
|
|
*/ |
|
|
|
prompt: function (text, title, callback, modal, name, password) { |
|
|
|
return $.when(this._getMessageTemplate()).then(function ($tmpl) { |
|
|
|
var dialogName = 'oc-dialog-' + OCdialogs.dialogsCounter + '-content'; |
|
|
|
var dialogName = 'oc-dialog-' + Dialogs.dialogsCounter + '-content'; |
|
|
|
var dialogId = '#' + dialogName; |
|
|
|
var $dlg = $tmpl.octemplate({ |
|
|
|
dialog_name: dialogName, |
|
|
|
@ -170,7 +175,7 @@ var OCdialogs = { |
|
|
|
} |
|
|
|
}); |
|
|
|
input.focus(); |
|
|
|
OCdialogs.dialogsCounter++; |
|
|
|
Dialogs.dialogsCounter++; |
|
|
|
}); |
|
|
|
}, |
|
|
|
/** |
|
|
|
@ -306,7 +311,9 @@ var OCdialogs = { |
|
|
|
try { |
|
|
|
if (!Files.isFileNameValid(filename)) { |
|
|
|
// Files.isFileNameValid(filename) throws an exception itself
|
|
|
|
} else if (self.filelist.find(function(file){return file.name === this;},filename)) { |
|
|
|
} else if (self.filelist.find(function (file) { |
|
|
|
return file.name === this; |
|
|
|
}, filename)) { |
|
|
|
throw t('files', '{newName} already exists', {newName: filename}, undefined, { |
|
|
|
escape: false |
|
|
|
}); |
|
|
|
@ -315,7 +322,11 @@ var OCdialogs = { |
|
|
|
} |
|
|
|
} catch (error) { |
|
|
|
$input.attr('title', error); |
|
|
|
$input.tooltip({placement: 'right', trigger: 'manual', 'container': '.newFolderMenu'}); |
|
|
|
$input.tooltip({ |
|
|
|
placement: 'right', |
|
|
|
trigger: 'manual', |
|
|
|
'container': '.newFolderMenu' |
|
|
|
}); |
|
|
|
$input.tooltip('fixTitle'); |
|
|
|
$input.tooltip('show'); |
|
|
|
$input.addClass('error'); |
|
|
|
@ -388,33 +399,33 @@ var OCdialogs = { |
|
|
|
}; |
|
|
|
|
|
|
|
var chooseCallback = function () { |
|
|
|
functionToCall(OCdialogs.FILEPICKER_TYPE_CHOOSE); |
|
|
|
functionToCall(Dialogs.FILEPICKER_TYPE_CHOOSE); |
|
|
|
}; |
|
|
|
|
|
|
|
var copyCallback = function () { |
|
|
|
functionToCall(OCdialogs.FILEPICKER_TYPE_COPY); |
|
|
|
functionToCall(Dialogs.FILEPICKER_TYPE_COPY); |
|
|
|
}; |
|
|
|
|
|
|
|
var moveCallback = function () { |
|
|
|
functionToCall(OCdialogs.FILEPICKER_TYPE_MOVE); |
|
|
|
functionToCall(Dialogs.FILEPICKER_TYPE_MOVE); |
|
|
|
}; |
|
|
|
|
|
|
|
var buttonlist = []; |
|
|
|
if (type === OCdialogs.FILEPICKER_TYPE_CHOOSE) { |
|
|
|
if (type === Dialogs.FILEPICKER_TYPE_CHOOSE) { |
|
|
|
buttonlist.push({ |
|
|
|
text: t('core', 'Choose'), |
|
|
|
click: chooseCallback, |
|
|
|
defaultButton: true |
|
|
|
}); |
|
|
|
} else { |
|
|
|
if (type === OCdialogs.FILEPICKER_TYPE_COPY || type === OCdialogs.FILEPICKER_TYPE_COPY_MOVE) { |
|
|
|
if (type === Dialogs.FILEPICKER_TYPE_COPY || type === Dialogs.FILEPICKER_TYPE_COPY_MOVE) { |
|
|
|
buttonlist.push({ |
|
|
|
text: t('core', 'Copy'), |
|
|
|
click: copyCallback, |
|
|
|
defaultButton: false |
|
|
|
}); |
|
|
|
} |
|
|
|
if (type === OCdialogs.FILEPICKER_TYPE_MOVE || type === OCdialogs.FILEPICKER_TYPE_COPY_MOVE) { |
|
|
|
if (type === Dialogs.FILEPICKER_TYPE_MOVE || type === Dialogs.FILEPICKER_TYPE_COPY_MOVE) { |
|
|
|
buttonlist.push({ |
|
|
|
text: t('core', 'Move'), |
|
|
|
click: moveCallback, |
|
|
|
@ -436,7 +447,8 @@ var OCdialogs = { |
|
|
|
close: function () { |
|
|
|
try { |
|
|
|
$(this).ocdialog('destroy').remove(); |
|
|
|
} catch(e) {} |
|
|
|
} catch (e) { |
|
|
|
} |
|
|
|
self.$filePicker = null; |
|
|
|
} |
|
|
|
}); |
|
|
|
@ -466,7 +478,7 @@ var OCdialogs = { |
|
|
|
*/ |
|
|
|
message: function (content, title, dialogType, buttons, callback, modal, allowHtml) { |
|
|
|
return $.when(this._getMessageTemplate()).then(function ($tmpl) { |
|
|
|
var dialogName = 'oc-dialog-' + OCdialogs.dialogsCounter + '-content'; |
|
|
|
var dialogName = 'oc-dialog-' + Dialogs.dialogsCounter + '-content'; |
|
|
|
var dialogId = '#' + dialogName; |
|
|
|
var $dlg = $tmpl.octemplate({ |
|
|
|
dialog_name: dialogName, |
|
|
|
@ -480,7 +492,7 @@ var OCdialogs = { |
|
|
|
$('body').append($dlg); |
|
|
|
var buttonlist = []; |
|
|
|
switch (buttons) { |
|
|
|
case OCdialogs.YES_NO_BUTTONS: |
|
|
|
case Dialogs.YES_NO_BUTTONS: |
|
|
|
buttonlist = [{ |
|
|
|
text: t('core', 'No'), |
|
|
|
click: function () { |
|
|
|
@ -501,7 +513,7 @@ var OCdialogs = { |
|
|
|
defaultButton: true |
|
|
|
}]; |
|
|
|
break; |
|
|
|
case OCdialogs.OK_BUTTON: |
|
|
|
case Dialogs.OK_BUTTON: |
|
|
|
var functionToCall = function () { |
|
|
|
$(dialogId).ocdialog('close'); |
|
|
|
if (callback !== undefined) { |
|
|
|
@ -521,7 +533,7 @@ var OCdialogs = { |
|
|
|
modal: modal, |
|
|
|
buttons: buttonlist |
|
|
|
}); |
|
|
|
OCdialogs.dialogsCounter++; |
|
|
|
Dialogs.dialogsCounter++; |
|
|
|
}) |
|
|
|
.fail(function (status, error) { |
|
|
|
// If the method is called while navigating away from
|
|
|
|
@ -1199,4 +1211,6 @@ var OCdialogs = { |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
}; |
|
|
|
} |
|
|
|
|
|
|
|
export default Dialogs |