Move OC.dialogs to the main bundle
Signed-off-by: Christoph Wurst <christoph@winzerhof-wurst.at>
This commit is contained in:
parent
2e0199a04a
commit
35d8e7a4e0
|
@ -2,7 +2,6 @@
|
||||||
"libraries": [
|
"libraries": [
|
||||||
],
|
],
|
||||||
"modules": [
|
"modules": [
|
||||||
"oc-dialogs.js",
|
|
||||||
"js.js",
|
"js.js",
|
||||||
"share.js",
|
"share.js",
|
||||||
"sharetemplates.js",
|
"sharetemplates.js",
|
||||||
|
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -477,12 +477,6 @@ Object.assign(window.OC, {
|
||||||
return path;
|
return path;
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
|
||||||
* Dialog helper for jquery dialogs.
|
|
||||||
*
|
|
||||||
* @namespace OC.dialogs
|
|
||||||
*/
|
|
||||||
dialogs:OCdialogs,
|
|
||||||
/**
|
/**
|
||||||
* Parses a URL query string into a JS map
|
* Parses a URL query string into a JS map
|
||||||
* @param {string} queryString query string in the format param1=1234¶m2=abcde¶m3=xyz
|
* @param {string} queryString query string in the format param1=1234¶m2=abcde¶m3=xyz
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
[
|
[
|
||||||
"oc-dialogs.js",
|
|
||||||
"js.js",
|
"js.js",
|
||||||
"oc-requesttoken.js",
|
"oc-requesttoken.js",
|
||||||
"mimetype.js",
|
"mimetype.js",
|
||||||
|
|
|
@ -1,31 +1,36 @@
|
||||||
/**
|
/* global alert */
|
||||||
* ownCloud
|
|
||||||
|
/*
|
||||||
|
* @copyright 2019 Christoph Wurst <christoph@winzerhof-wurst.at>
|
||||||
*
|
*
|
||||||
* @author Bartek Przybylski, Christopher Schäpers, Thomas Tanghus
|
* @author 2019 Christoph Wurst <christoph@winzerhof-wurst.at>
|
||||||
* @copyright 2012 Bartek Przybylski bartek@alefzero.eu
|
|
||||||
*
|
*
|
||||||
* This library is free software; you can redistribute it and/or
|
* @license GNU AGPL version 3 or any later version
|
||||||
* 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.
|
|
||||||
*
|
*
|
||||||
* 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
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU AFFERO GENERAL PUBLIC LICENSE for more details.
|
* 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/>.
|
|
||||||
*
|
*
|
||||||
|
* 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
|
* this class to ease the usage of jquery dialogs
|
||||||
* @lends OC.dialogs
|
|
||||||
*/
|
*/
|
||||||
var OCdialogs = {
|
const Dialogs = {
|
||||||
// dialog button types
|
// dialog button types
|
||||||
YES_NO_BUTTONS: 70,
|
YES_NO_BUTTONS: 70,
|
||||||
OK_BUTTONS: 71,
|
OK_BUTTONS: 71,
|
||||||
|
@ -49,7 +54,7 @@ var OCdialogs = {
|
||||||
text,
|
text,
|
||||||
title,
|
title,
|
||||||
'alert',
|
'alert',
|
||||||
OCdialogs.OK_BUTTON,
|
Dialogs.OK_BUTTON,
|
||||||
callback,
|
callback,
|
||||||
modal
|
modal
|
||||||
);
|
);
|
||||||
|
@ -62,7 +67,7 @@ var OCdialogs = {
|
||||||
* @param modal make the dialog modal
|
* @param modal make the dialog modal
|
||||||
*/
|
*/
|
||||||
info: function (text, title, callback, 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
|
* displays confirmation dialog
|
||||||
|
@ -77,7 +82,7 @@ var OCdialogs = {
|
||||||
text,
|
text,
|
||||||
title,
|
title,
|
||||||
'notice',
|
'notice',
|
||||||
OCdialogs.YES_NO_BUTTONS,
|
Dialogs.YES_NO_BUTTONS,
|
||||||
callback,
|
callback,
|
||||||
modal
|
modal
|
||||||
);
|
);
|
||||||
|
@ -95,7 +100,7 @@ var OCdialogs = {
|
||||||
text,
|
text,
|
||||||
title,
|
title,
|
||||||
'notice',
|
'notice',
|
||||||
OCdialogs.YES_NO_BUTTONS,
|
Dialogs.YES_NO_BUTTONS,
|
||||||
callback,
|
callback,
|
||||||
modal,
|
modal,
|
||||||
true
|
true
|
||||||
|
@ -113,7 +118,7 @@ var OCdialogs = {
|
||||||
*/
|
*/
|
||||||
prompt: function (text, title, callback, modal, name, password) {
|
prompt: function (text, title, callback, modal, name, password) {
|
||||||
return $.when(this._getMessageTemplate()).then(function ($tmpl) {
|
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 dialogId = '#' + dialogName;
|
||||||
var $dlg = $tmpl.octemplate({
|
var $dlg = $tmpl.octemplate({
|
||||||
dialog_name: dialogName,
|
dialog_name: dialogName,
|
||||||
|
@ -170,7 +175,7 @@ var OCdialogs = {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
input.focus();
|
input.focus();
|
||||||
OCdialogs.dialogsCounter++;
|
Dialogs.dialogsCounter++;
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
/**
|
/**
|
||||||
|
@ -306,7 +311,9 @@ var OCdialogs = {
|
||||||
try {
|
try {
|
||||||
if (!Files.isFileNameValid(filename)) {
|
if (!Files.isFileNameValid(filename)) {
|
||||||
// Files.isFileNameValid(filename) throws an exception itself
|
// 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, {
|
throw t('files', '{newName} already exists', {newName: filename}, undefined, {
|
||||||
escape: false
|
escape: false
|
||||||
});
|
});
|
||||||
|
@ -315,7 +322,11 @@ var OCdialogs = {
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
$input.attr('title', 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('fixTitle');
|
||||||
$input.tooltip('show');
|
$input.tooltip('show');
|
||||||
$input.addClass('error');
|
$input.addClass('error');
|
||||||
|
@ -388,33 +399,33 @@ var OCdialogs = {
|
||||||
};
|
};
|
||||||
|
|
||||||
var chooseCallback = function () {
|
var chooseCallback = function () {
|
||||||
functionToCall(OCdialogs.FILEPICKER_TYPE_CHOOSE);
|
functionToCall(Dialogs.FILEPICKER_TYPE_CHOOSE);
|
||||||
};
|
};
|
||||||
|
|
||||||
var copyCallback = function () {
|
var copyCallback = function () {
|
||||||
functionToCall(OCdialogs.FILEPICKER_TYPE_COPY);
|
functionToCall(Dialogs.FILEPICKER_TYPE_COPY);
|
||||||
};
|
};
|
||||||
|
|
||||||
var moveCallback = function () {
|
var moveCallback = function () {
|
||||||
functionToCall(OCdialogs.FILEPICKER_TYPE_MOVE);
|
functionToCall(Dialogs.FILEPICKER_TYPE_MOVE);
|
||||||
};
|
};
|
||||||
|
|
||||||
var buttonlist = [];
|
var buttonlist = [];
|
||||||
if (type === OCdialogs.FILEPICKER_TYPE_CHOOSE) {
|
if (type === Dialogs.FILEPICKER_TYPE_CHOOSE) {
|
||||||
buttonlist.push({
|
buttonlist.push({
|
||||||
text: t('core', 'Choose'),
|
text: t('core', 'Choose'),
|
||||||
click: chooseCallback,
|
click: chooseCallback,
|
||||||
defaultButton: true
|
defaultButton: true
|
||||||
});
|
});
|
||||||
} else {
|
} 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({
|
buttonlist.push({
|
||||||
text: t('core', 'Copy'),
|
text: t('core', 'Copy'),
|
||||||
click: copyCallback,
|
click: copyCallback,
|
||||||
defaultButton: false
|
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({
|
buttonlist.push({
|
||||||
text: t('core', 'Move'),
|
text: t('core', 'Move'),
|
||||||
click: moveCallback,
|
click: moveCallback,
|
||||||
|
@ -436,7 +447,8 @@ var OCdialogs = {
|
||||||
close: function () {
|
close: function () {
|
||||||
try {
|
try {
|
||||||
$(this).ocdialog('destroy').remove();
|
$(this).ocdialog('destroy').remove();
|
||||||
} catch(e) {}
|
} catch (e) {
|
||||||
|
}
|
||||||
self.$filePicker = null;
|
self.$filePicker = null;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -466,7 +478,7 @@ var OCdialogs = {
|
||||||
*/
|
*/
|
||||||
message: function (content, title, dialogType, buttons, callback, modal, allowHtml) {
|
message: function (content, title, dialogType, buttons, callback, modal, allowHtml) {
|
||||||
return $.when(this._getMessageTemplate()).then(function ($tmpl) {
|
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 dialogId = '#' + dialogName;
|
||||||
var $dlg = $tmpl.octemplate({
|
var $dlg = $tmpl.octemplate({
|
||||||
dialog_name: dialogName,
|
dialog_name: dialogName,
|
||||||
|
@ -480,7 +492,7 @@ var OCdialogs = {
|
||||||
$('body').append($dlg);
|
$('body').append($dlg);
|
||||||
var buttonlist = [];
|
var buttonlist = [];
|
||||||
switch (buttons) {
|
switch (buttons) {
|
||||||
case OCdialogs.YES_NO_BUTTONS:
|
case Dialogs.YES_NO_BUTTONS:
|
||||||
buttonlist = [{
|
buttonlist = [{
|
||||||
text: t('core', 'No'),
|
text: t('core', 'No'),
|
||||||
click: function () {
|
click: function () {
|
||||||
|
@ -501,7 +513,7 @@ var OCdialogs = {
|
||||||
defaultButton: true
|
defaultButton: true
|
||||||
}];
|
}];
|
||||||
break;
|
break;
|
||||||
case OCdialogs.OK_BUTTON:
|
case Dialogs.OK_BUTTON:
|
||||||
var functionToCall = function () {
|
var functionToCall = function () {
|
||||||
$(dialogId).ocdialog('close');
|
$(dialogId).ocdialog('close');
|
||||||
if (callback !== undefined) {
|
if (callback !== undefined) {
|
||||||
|
@ -521,7 +533,7 @@ var OCdialogs = {
|
||||||
modal: modal,
|
modal: modal,
|
||||||
buttons: buttonlist
|
buttons: buttonlist
|
||||||
});
|
});
|
||||||
OCdialogs.dialogsCounter++;
|
Dialogs.dialogsCounter++;
|
||||||
})
|
})
|
||||||
.fail(function (status, error) {
|
.fail(function (status, error) {
|
||||||
// If the method is called while navigating away from
|
// If the method is called while navigating away from
|
||||||
|
@ -1199,4 +1211,6 @@ var OCdialogs = {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
|
|
||||||
|
export default Dialogs
|
|
@ -23,6 +23,7 @@ import Apps from './apps'
|
||||||
import AppConfig from './appconfig'
|
import AppConfig from './appconfig'
|
||||||
import Backbone from './backbone'
|
import Backbone from './backbone'
|
||||||
import ContactsMenu from './contactsmenu'
|
import ContactsMenu from './contactsmenu'
|
||||||
|
import Dialogs from './dialogs'
|
||||||
import EventSource from './eventsource'
|
import EventSource from './eventsource'
|
||||||
import L10N from './l10n'
|
import L10N from './l10n'
|
||||||
import msg from './msg'
|
import msg from './msg'
|
||||||
|
@ -39,6 +40,7 @@ export default {
|
||||||
AppConfig,
|
AppConfig,
|
||||||
Backbone,
|
Backbone,
|
||||||
ContactsMenu,
|
ContactsMenu,
|
||||||
|
dialogs: Dialogs,
|
||||||
EventSource,
|
EventSource,
|
||||||
L10N,
|
L10N,
|
||||||
msg,
|
msg,
|
||||||
|
|
|
@ -34,6 +34,18 @@ const deprecate = (func, funcName) => {
|
||||||
return newFunc
|
return newFunc
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const setDeprecatedProp = (global, val, msg) =>
|
||||||
|
Object.defineProperty(window, global, {
|
||||||
|
get: () => {
|
||||||
|
if (msg) {
|
||||||
|
console.warn(`${global} is deprecated: ${msg}`)
|
||||||
|
} else {
|
||||||
|
console.warn(`${global} is deprecated`)
|
||||||
|
}
|
||||||
|
return val
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
import _ from 'underscore'
|
import _ from 'underscore'
|
||||||
import $ from 'jquery'
|
import $ from 'jquery'
|
||||||
import 'jquery-migrate/dist/jquery-migrate.min'
|
import 'jquery-migrate/dist/jquery-migrate.min'
|
||||||
|
@ -91,6 +103,7 @@ window['md5'] = md5
|
||||||
window['moment'] = moment
|
window['moment'] = moment
|
||||||
|
|
||||||
window['OC'] = OC
|
window['OC'] = OC
|
||||||
|
setDeprecatedProp('OCDialogs', OC.dialogs, 'use OC.dialogs')
|
||||||
window['OCP'] = OCP
|
window['OCP'] = OCP
|
||||||
window['OCA'] = OCA
|
window['OCA'] = OCA
|
||||||
window['escapeHTML'] = deprecate(escapeHTML, 'escapeHTML')
|
window['escapeHTML'] = deprecate(escapeHTML, 'escapeHTML')
|
||||||
|
|
Loading…
Reference in New Issue