diff options
Diffstat (limited to 'core/src/OCP')
-rw-r--r-- | core/src/OCP/accessibility.js | 28 | ||||
-rw-r--r-- | core/src/OCP/appconfig.js | 64 | ||||
-rw-r--r-- | core/src/OCP/collaboration.js | 30 | ||||
-rw-r--r-- | core/src/OCP/comments.js | 26 | ||||
-rw-r--r-- | core/src/OCP/index.js | 21 | ||||
-rw-r--r-- | core/src/OCP/loader.js | 31 | ||||
-rw-r--r-- | core/src/OCP/toast.js | 35 | ||||
-rw-r--r-- | core/src/OCP/whatsnew.js | 39 |
8 files changed, 140 insertions, 134 deletions
diff --git a/core/src/OCP/accessibility.js b/core/src/OCP/accessibility.js new file mode 100644 index 00000000000..4a1399f3f96 --- /dev/null +++ b/core/src/OCP/accessibility.js @@ -0,0 +1,28 @@ +/** + * SPDX-FileCopyrightText: 2022 Nextcloud GmbH and Nextcloud contributors + * SPDX-License-Identifier: AGPL-3.0-or-later + */ + +import { loadState } from '@nextcloud/initial-state' + +/** + * Set the page heading + * + * @param {string} heading page title from the history api + * @since 27.0.0 + */ +export function setPageHeading(heading) { + const headingEl = document.getElementById('page-heading-level-1') + if (headingEl) { + headingEl.textContent = heading + } +} +export default { + /** + * @return {boolean} Whether the user opted-out of shortcuts so that they should not be registered + */ + disableKeyboardShortcuts() { + return loadState('theming', 'shortcutsDisabled', false) + }, + setPageHeading, +} diff --git a/core/src/OCP/appconfig.js b/core/src/OCP/appconfig.js index 78ee1643878..78f94922d53 100644 --- a/core/src/OCP/appconfig.js +++ b/core/src/OCP/appconfig.js @@ -1,35 +1,21 @@ /** - * @copyright Copyright (c) 2016 Joas Schilling <coding@schilljs.com> - * - * @license GNU AGPL version 3 or any later version - * - * 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 program. If not, see <http://www.gnu.org/licenses/>. - * + * SPDX-FileCopyrightText: 2016 Nextcloud GmbH and Nextcloud contributors + * SPDX-FileCopyrightText: 2016 ownCloud, Inc. + * SPDX-License-Identifier: AGPL-3.0-or-later */ import $ from 'jquery' +import { generateOcsUrl } from '@nextcloud/router' -import OC from '../OC/index' +import OC from '../OC/index.js' /** * @param {string} method 'post' or 'delete' * @param {string} endpoint endpoint - * @param {Object} [options] destructuring object - * @param {Object} [options.data] option data - * @param {function} [options.success] success callback - * @param {function} [options.error] error callback - * @internal + * @param {object} [options] destructuring object + * @param {object} [options.data] option data + * @param {Function} [options.success] success callback + * @param {Function} [options.error] error callback */ function call(method, endpoint, options) { if ((method === 'post' || method === 'delete') && OC.PasswordConfirmation.requiresPasswordConfirmation()) { @@ -40,7 +26,7 @@ function call(method, endpoint, options) { options = options || {} $.ajax({ type: method.toUpperCase(), - url: OC.linkToOCS('apps/provisioning_api/api/v1', 2) + 'config/apps' + endpoint, + url: generateOcsUrl('apps/provisioning_api/api/v1/config/apps') + endpoint, data: options.data || {}, success: options.success, error: options.error, @@ -48,8 +34,8 @@ function call(method, endpoint, options) { } /** - * @param {Object} [options] destructuring object - * @param {function} [options.success] success callback + * @param {object} [options] destructuring object + * @param {Function} [options.success] success callback * @since 11.0.0 */ export function getApps(options) { @@ -58,9 +44,9 @@ export function getApps(options) { /** * @param {string} app app id - * @param {Object} [options] destructuring object - * @param {function} [options.success] success callback - * @param {function} [options.error] error callback + * @param {object} [options] destructuring object + * @param {Function} [options.success] success callback + * @param {Function} [options.error] error callback * @since 11.0.0 */ export function getKeys(app, options) { @@ -70,10 +56,10 @@ export function getKeys(app, options) { /** * @param {string} app app id * @param {string} key key - * @param {string|function} defaultValue default value - * @param {Object} [options] destructuring object - * @param {function} [options.success] success callback - * @param {function} [options.error] error callback + * @param {string | Function} defaultValue default value + * @param {object} [options] destructuring object + * @param {Function} [options.success] success callback + * @param {Function} [options.error] error callback * @since 11.0.0 */ export function getValue(app, key, defaultValue, options) { @@ -89,9 +75,9 @@ export function getValue(app, key, defaultValue, options) { * @param {string} app app id * @param {string} key key * @param {string} value value - * @param {Object} [options] destructuring object - * @param {function} [options.success] success callback - * @param {function} [options.error] error callback + * @param {object} [options] destructuring object + * @param {Function} [options.success] success callback + * @param {Function} [options.error] error callback * @since 11.0.0 */ export function setValue(app, key, value, options) { @@ -106,9 +92,9 @@ export function setValue(app, key, value, options) { /** * @param {string} app app id * @param {string} key key - * @param {Object} [options] destructuring object - * @param {function} [options.success] success callback - * @param {function} [options.error] error callback + * @param {object} [options] destructuring object + * @param {Function} [options.success] success callback + * @param {Function} [options.error] error callback * @since 11.0.0 */ export function deleteKey(app, key, options) { diff --git a/core/src/OCP/collaboration.js b/core/src/OCP/collaboration.js index 73573b3f1f7..82ff34392cf 100644 --- a/core/src/OCP/collaboration.js +++ b/core/src/OCP/collaboration.js @@ -1,43 +1,27 @@ /** - * @copyright Copyright (c) 2018 Julius Härtl <jus@bitgrid.net> - * - * @author Julius Härtl <jus@bitgrid.net> - * - * @license GNU AGPL version 3 or any later version - * - * 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 program. If not, see <http://www.gnu.org/licenses/>. - * + * SPDX-FileCopyrightText: 2018 Nextcloud GmbH and Nextcloud contributors + * SPDX-License-Identifier: AGPL-3.0-or-later */ import escapeHTML from 'escape-html' /** * @typedef TypeDefinition - * @method {callback} action This action is executed to let the user select a resource + * @function action This action is executed to let the user select a resource * @param {string} icon Contains the icon css class for the type - * @constructor + * @function Object() { [native code] } */ /** * @type {TypeDefinition[]} - **/ + */ const types = {} /** * Those translations will be used by the vue component but they should be shipped with the server * FIXME: Those translations should be added to the library - * @returns {Array} + * + * @return {Array} */ export const l10nProjects = () => { return [ diff --git a/core/src/OCP/comments.js b/core/src/OCP/comments.js index 2e12accddce..34699a477d1 100644 --- a/core/src/OCP/comments.js +++ b/core/src/OCP/comments.js @@ -1,10 +1,6 @@ /** - * @copyright (c) 2017 Arthur Schiwon <blizzz@arthur-schiwon.de> - * - * @author Arthur Schiwon <blizzz@arthur-schiwon.de> - * - * This file is licensed under the Affero General Public License version 3 or - * later. See the COPYING file. + * SPDX-FileCopyrightText: 2017 Nextcloud GmbH and Nextcloud contributors + * SPDX-License-Identifier: AGPL-3.0-or-later */ import $ from 'jquery' @@ -12,22 +8,33 @@ import $ from 'jquery' /* * Detects links: * Either the http(s) protocol is given or two strings, basically limited to ascii with the last - * word being at least one digit long, + * word being at least one digit long, * followed by at least another character * * The downside: anything not ascii is excluded. Not sure how common it is in areas using different * alphabets… the upside: fake domains with similar looking characters won't be formatted as links + * + * This is a copy of the backend regex in IURLGenerator, make sure to adjust both when changing */ -const urlRegex = /(\s|^)(https?:\/\/)?((?:[-A-Z0-9+_]+\.)+[-A-Z]+(?:\/[-A-Z0-9+&@#%?=~_|!:,.;()]*)*)(\s|$)/ig +const urlRegex = /(\s|^)(https?:\/\/)([-A-Z0-9+_.]+(?::[0-9]+)?(?:\/[-A-Z0-9+&@#%?=~_|!:,.;()]*)*)(\s|$)/ig +/** + * @param {any} content - + */ export function plainToRich(content) { return this.formatLinksRich(content) } +/** + * @param {any} content - + */ export function richToPlain(content) { return this.formatLinksPlain(content) } +/** + * @param {any} content - + */ export function formatLinksRich(content) { return content.replace(urlRegex, function(_, leadingSpace, protocol, url, trailingSpace) { let linkText = url @@ -41,6 +48,9 @@ export function formatLinksRich(content) { }) } +/** + * @param {any} content - + */ export function formatLinksPlain(content) { const $content = $('<div></div>').html(content) $content.find('a').each(function() { diff --git a/core/src/OCP/index.js b/core/src/OCP/index.js index 4f2c47f1fa4..94f4e8e5eb3 100644 --- a/core/src/OCP/index.js +++ b/core/src/OCP/index.js @@ -1,13 +1,22 @@ -import * as AppConfig from './appconfig' -import * as Comments from './comments' -import Loader from './loader' +/** + * SPDX-FileCopyrightText: 2016 Nextcloud GmbH and Nextcloud contributors + * SPDX-License-Identifier: AGPL-3.0-or-later + */ + import { loadState } from '@nextcloud/initial-state' -import Collaboration from './collaboration' -import * as WhatsNew from './whatsnew' -import Toast from './toast' + +import * as AppConfig from './appconfig.js' +import * as Comments from './comments.js' +import * as WhatsNew from './whatsnew.js' + +import Accessibility from './accessibility.js' +import Collaboration from './collaboration.js' +import Loader from './loader.js' +import Toast from './toast.js' /** @namespace OCP */ export default { + Accessibility, AppConfig, Collaboration, Comments, diff --git a/core/src/OCP/loader.js b/core/src/OCP/loader.js index 26beaffca33..d307eb27996 100644 --- a/core/src/OCP/loader.js +++ b/core/src/OCP/loader.js @@ -1,25 +1,10 @@ /** - * @copyright Copyright (c) 2018 Julius Härtl <jus@bitgrid.net> - * - * @author Julius Härtl <jus@bitgrid.net> - * - * @license GNU AGPL version 3 or any later version - * - * 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 program. If not, see <http://www.gnu.org/licenses/>. - * + * SPDX-FileCopyrightText: 2018 Nextcloud GmbH and Nextcloud contributors + * SPDX-License-Identifier: AGPL-3.0-or-later */ +import { generateFilePath } from '@nextcloud/router' + const loadedScripts = {} const loadedStylesheets = {} /** @@ -33,7 +18,7 @@ export default { * * @param {string} app the app name * @param {string} file the script file name - * @returns {Promise} + * @return {Promise} */ loadScript(app, file) { const key = app + file @@ -42,7 +27,7 @@ export default { } loadedScripts[key] = true return new Promise(function(resolve, reject) { - const scriptPath = OC.filePath(app, 'js', file) + const scriptPath = generateFilePath(app, 'js', file) const script = document.createElement('script') script.src = scriptPath script.setAttribute('nonce', btoa(OC.requestToken)) @@ -57,7 +42,7 @@ export default { * * @param {string} app the app name * @param {string} file the script file name - * @returns {Promise} + * @return {Promise} */ loadStylesheet(app, file) { const key = app + file @@ -66,7 +51,7 @@ export default { } loadedStylesheets[key] = true return new Promise(function(resolve, reject) { - const stylePath = OC.filePath(app, 'css', file) + const stylePath = generateFilePath(app, 'css', file) const link = document.createElement('link') link.href = stylePath link.type = 'text/css' diff --git a/core/src/OCP/toast.js b/core/src/OCP/toast.js index e5331377dc9..f93344bbc8e 100644 --- a/core/src/OCP/toast.js +++ b/core/src/OCP/toast.js @@ -1,23 +1,6 @@ -/* - * @copyright Copyright (c) 2019 Julius Härtl <jus@bitgrid.net> - * - * @author Julius Härtl <jus@bitgrid.net> - * - * @license GNU AGPL version 3 or any later version - * - * 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 program. If not, see <http://www.gnu.org/licenses/>. - * +/** + * SPDX-FileCopyrightText: 2019 Nextcloud GmbH and Nextcloud contributors + * SPDX-License-Identifier: AGPL-3.0-or-later */ import { @@ -27,13 +10,15 @@ import { showWarning, } from '@nextcloud/dialogs' +/** @typedef {import('toastify-js')} Toast */ + export default { /** * @deprecated 19.0.0 use `showSuccess` from the `@nextcloud/dialogs` package instead * * @param {string} text the toast text * @param {object} options options - * @returns {Toast} + * @return {Toast} */ success(text, options) { return showSuccess(text, options) @@ -43,7 +28,7 @@ export default { * * @param {string} text the toast text * @param {object} options options - * @returns {Toast} + * @return {Toast} */ warning(text, options) { return showWarning(text, options) @@ -53,7 +38,7 @@ export default { * * @param {string} text the toast text * @param {object} options options - * @returns {Toast} + * @return {Toast} */ error(text, options) { return showError(text, options) @@ -63,7 +48,7 @@ export default { * * @param {string} text the toast text * @param {object} options options - * @returns {Toast} + * @return {Toast} */ info(text, options) { return showInfo(text, options) @@ -73,7 +58,7 @@ export default { * * @param {string} text the toast text * @param {object} options options - * @returns {Toast} + * @return {Toast} */ message(text, options) { return showMessage(text, options) diff --git a/core/src/OCP/whatsnew.js b/core/src/OCP/whatsnew.js index 17c9eeabce2..acada6a8383 100644 --- a/core/src/OCP/whatsnew.js +++ b/core/src/OCP/whatsnew.js @@ -1,23 +1,21 @@ /** - * @copyright (c) 2017 Arthur Schiwon <blizzz@arthur-schiwon.de> - * - * @author Arthur Schiwon <blizzz@arthur-schiwon.de> - * - * This file is licensed under the Affero General Public License version 3 or - * later. See the COPYING file. + * SPDX-FileCopyrightText: 2017 Nextcloud GmbH and Nextcloud contributors + * SPDX-License-Identifier: AGPL-3.0-or-later */ import _ from 'underscore' import $ from 'jquery' +import { generateOcsUrl } from '@nextcloud/router' -import OC from '../OC/index' - +/** + * @param {any} options - + */ export function query(options) { options = options || {} const dismissOptions = options.dismiss || {} $.ajax({ type: 'GET', - url: options.url || OC.linkToOCS('core', 2) + 'whatsnew?format=json', + url: options.url || generateOcsUrl('core/whatsnew?format=json'), success: options.success || function(data, statusText, xhr) { onQuerySuccess(data, statusText, xhr, dismissOptions) }, @@ -25,11 +23,15 @@ export function query(options) { }) } +/** + * @param {any} version - + * @param {any} options - + */ export function dismiss(version, options) { options = options || {} $.ajax({ type: 'POST', - url: options.url || OC.linkToOCS('core', 2) + 'whatsnew', + url: options.url || generateOcsUrl('core/whatsnew'), data: { version: encodeURIComponent(version) }, success: options.success || onDismissSuccess, error: options.error || onDismissError, @@ -38,6 +40,12 @@ export function dismiss(version, options) { $('.whatsNewPopover').remove() } +/** + * @param {any} data - + * @param {any} statusText - + * @param {any} xhr - + * @param {any} dismissOptions - + */ function onQuerySuccess(data, statusText, xhr, dismissOptions) { console.debug('querying Whats New data was successful: ' + statusText) console.debug(data) @@ -118,15 +126,26 @@ function onQuerySuccess(data, statusText, xhr, dismissOptions) { document.body.appendChild(div) } +/** + * @param {any} x - + * @param {any} t - + * @param {any} e - + */ function onQueryError(x, t, e) { console.debug('querying Whats New Data resulted in an error: ' + t + e) console.debug(x) } +/** + * @param {any} data - + */ function onDismissSuccess(data) { // noop } +/** + * @param {any} data - + */ function onDismissError(data) { console.debug('dismissing Whats New data resulted in an error: ' + data) } |