diff --git a/core/js/dist/login.js b/core/js/dist/login.js index 41fa6875853e1c83a22a9f638d6de488a03bb8a0..11e072559094fb1b2f4297bb407d5837b6be302f 100644 Binary files a/core/js/dist/login.js and b/core/js/dist/login.js differ diff --git a/core/js/dist/login.js.map b/core/js/dist/login.js.map index af3a89264da3078850ec6f4fbd6df7478d3fcc56..cb24b022c57775437536099020c3d8d89f5f4d55 100644 Binary files a/core/js/dist/login.js.map and b/core/js/dist/login.js.map differ diff --git a/core/js/dist/main.js b/core/js/dist/main.js index 5befe512f499e265fd04c153a527bad6fdac64a8..25ac4026d75b699b112d3e8af304119b2e49ce60 100644 Binary files a/core/js/dist/main.js and b/core/js/dist/main.js differ diff --git a/core/js/dist/main.js.map b/core/js/dist/main.js.map index c7f422c15532e5143e4c20b8d506856b271d6f37..0ff9c2c091d248ea1080f8fdbfdb4fd8b9d27f3c 100644 Binary files a/core/js/dist/main.js.map and b/core/js/dist/main.js.map differ diff --git a/core/js/js.js b/core/js/js.js index 1002e751548f4a135af84c226951bf27811ac570..8b9fae0a9217746e7c0a5c79552759ad23c94c55 100644 --- a/core/js/js.js +++ b/core/js/js.js @@ -4,63 +4,6 @@ Object.assign(window.OC, { /* jshint camelcase: false */ - /** - * Opens a popup with the setting for an app. - * @param {string} appid The ID of the app e.g. 'calendar', 'contacts' or 'files'. - * @param {boolean|string}Â loadJS If true 'js/settings.js' is loaded. If it's a string - * it will attempt to load a script by that name in the 'js' directory. - * @param {boolean} [cache] If true the javascript file won't be forced refreshed. Defaults to true. - * @param {string} [scriptName] The name of the PHP file to load. Defaults to 'settings.php' in - * the root of the app directory hierarchy. - */ - appSettings:function(args) { - if(typeof args === 'undefined' || typeof args.appid === 'undefined') { - throw { name: 'MissingParameter', message: 'The parameter appid is missing' }; - } - var props = {scriptName:'settings.php', cache:true}; - $.extend(props, args); - var settings = $('#appsettings'); - if(settings.length === 0) { - throw { name: 'MissingDOMElement', message: 'There has be be an element with id "appsettings" for the popup to show.' }; - } - var popup = $('#appsettings_popup'); - if(popup.length === 0) { - $('body').prepend('<div class="popup hidden" id="appsettings_popup"></div>'); - popup = $('#appsettings_popup'); - popup.addClass(settings.hasClass('topright') ? 'topright' : 'bottomleft'); - } - if(popup.is(':visible')) { - popup.hide().remove(); - } else { - var arrowclass = settings.hasClass('topright') ? 'up' : 'left'; - var jqxhr = $.get(OC.filePath(props.appid, '', props.scriptName), function(data) { - popup.html(data).ready(function() { - popup.prepend('<span class="arrow '+arrowclass+'"></span><h2>'+t('core', 'Settings')+'</h2><a class="close"></a>').show(); - popup.find('.close').bind('click', function() { - popup.remove(); - }); - if(typeof props.loadJS !== 'undefined') { - var scriptname; - if(props.loadJS === true) { - scriptname = 'settings.js'; - } else if(typeof props.loadJS === 'string') { - scriptname = props.loadJS; - } else { - throw { name: 'InvalidParameter', message: 'The "loadJS" parameter must be either boolean or a string.' }; - } - if(props.cache) { - $.ajaxSetup({cache: true}); - } - $.getScript(OC.filePath(props.appid, 'js', scriptname)) - .fail(function(jqxhr, settings, e) { - throw e; - }); - } - }).show(); - }, 'html'); - } - }, - /** * Warn users that the connection to the server was lost temporarily * diff --git a/core/src/OC/appsettings.js b/core/src/OC/appsettings.js new file mode 100644 index 0000000000000000000000000000000000000000..b62af5c592a1221a6fd95e5f699bdb8aa5fc1397 --- /dev/null +++ b/core/src/OC/appsettings.js @@ -0,0 +1,93 @@ +/* + * @copyright 2019 Christoph Wurst <christoph@winzerhof-wurst.at> + * + * @author 2019 Christoph Wurst <christoph@winzerhof-wurst.at> + * + * @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/>. + */ + +import $ from 'jquery' +import {filePath} from './routing' + +/** + * Opens a popup with the setting for an app. + * @param {string} appid The ID of the app e.g. 'calendar', 'contacts' or 'files'. + * @param {boolean|string}Â loadJS If true 'js/settings.js' is loaded. If it's a string + * it will attempt to load a script by that name in the 'js' directory. + * @param {boolean} [cache] If true the javascript file won't be forced refreshed. Defaults to true. + * @param {string} [scriptName] The name of the PHP file to load. Defaults to 'settings.php' in + * the root of the app directory hierarchy. + * + * @deprecated 17.0.0 this method is unused and will be removed with Nextcloud 18 + */ +export const appSettings = args => { + console.warn('OC.appSettings is deprecated and will be removed with Nextcloud 18') + + if (typeof args === 'undefined' || typeof args.appid === 'undefined') { + throw { + name: 'MissingParameter', + message: 'The parameter appid is missing' + } + } + var props = {scriptName: 'settings.php', cache: true} + $.extend(props, args) + var settings = $('#appsettings') + if (settings.length === 0) { + throw { + name: 'MissingDOMElement', + message: 'There has be be an element with id "appsettings" for the popup to show.' + } + } + var popup = $('#appsettings_popup') + if (popup.length === 0) { + $('body').prepend('<div class="popup hidden" id="appsettings_popup"></div>') + popup = $('#appsettings_popup') + popup.addClass(settings.hasClass('topright') ? 'topright' : 'bottomleft') + } + if (popup.is(':visible')) { + popup.hide().remove() + } else { + const arrowclass = settings.hasClass('topright') ? 'up' : 'left' + $.get(filePath(props.appid, '', props.scriptName), function (data) { + popup.html(data).ready(function () { + popup.prepend('<span class="arrow ' + arrowclass + '"></span><h2>' + t('core', 'Settings') + '</h2><a class="close"></a>').show() + popup.find('.close').bind('click', function () { + popup.remove() + }) + if (typeof props.loadJS !== 'undefined') { + var scriptname + if (props.loadJS === true) { + scriptname = 'settings.js' + } else if (typeof props.loadJS === 'string') { + scriptname = props.loadJS + } else { + throw { + name: 'InvalidParameter', + message: 'The "loadJS" parameter must be either boolean or a string.' + } + } + if (props.cache) { + $.ajaxSetup({cache: true}) + } + $.getScript(filePath(props.appid, 'js', scriptname)) + .fail(function (jqxhr, settings, e) { + throw e + }) + } + }).show() + }, 'html') + } +} diff --git a/core/src/OC/index.js b/core/src/OC/index.js index 4a2f2c3d803ef7915fb2177f44876cff8c20b160..7fd718e17c4b5bd590f310a578a6a0ff5067308c 100644 --- a/core/src/OC/index.js +++ b/core/src/OC/index.js @@ -22,6 +22,7 @@ import {addScript, addStyle} from './legacy-loader' import Apps from './apps' import {AppConfig, appConfig} from './appconfig' +import {appSettings} from './appsettings' import appswebroots from './appswebroots' import Backbone from './backbone' import { @@ -129,6 +130,7 @@ export default { Apps, AppConfig, appConfig, + appSettings, appswebroots, Backbone, ContactsMenu,