diff --git a/core/js/dist/login.js b/core/js/dist/login.js index 88ca4b25cb04fcb1e121997367e27737474eff6e..9ae0db355b25bc6625378cf9c418d4135b79ebdc 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 dd80984718e632146533870ba798224814995112..d9d5d6481fa32d72f4c670a994c38b7dd1a6b563 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 8fbf6ed93c4a01f1fda44d4d8c002217b78c4710..2e65de5b5982aae456d5d570b9806825af83605e 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 29e3f12429772971b4cb9d1e93cae769f22260ab..bdbfd65d41d3a9693d4a7c748e57115269ac14d0 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 55bc4ffb963e6e44d2128d067957c6f5bc5222b7..13e0e11b0fbb34f5b0f1080d274629738146cbc4 100644 --- a/core/js/js.js +++ b/core/js/js.js @@ -117,48 +117,6 @@ Object.assign(window.OC, { return result.join('/'); }, - /** - * Load a script for the server and load it. If the script is already loaded, - * the event handler will be called directly - * @param {string} app the app id to which the script belongs - * @param {string} script the filename of the script - * @param ready event handler to be called when the script is loaded - * @deprecated 16.0.0 Use OCP.Loader.loadScript - */ - addScript:function(app,script,ready){ - var deferred, path=OC.filePath(app,'js',script+'.js'); - if(!OC.addScript.loaded[path]) { - deferred = $.Deferred(); - $.getScript(path, function() { - deferred.resolve(); - }); - OC.addScript.loaded[path] = deferred; - } else { - if (ready) { - ready(); - } - } - return OC.addScript.loaded[path]; - }, - /** - * Loads a CSS file - * @param {string} app the app id to which the css style belongs - * @param {string} style the filename of the css file - * @deprecated 16.0.0 Use OCP.Loader.loadStylesheet - */ - addStyle:function(app,style){ - var path=OC.filePath(app,'css',style+'.css'); - if(OC.addStyle.loaded.indexOf(path)===-1){ - OC.addStyle.loaded.push(path); - if (document.createStyleSheet) { - document.createStyleSheet(path); - } else { - style=$('<link rel="stylesheet" type="text/css" href="'+path+'"/>'); - $('head').append(style); - } - } - }, - /** * Loads translations for the given app asynchronously. * @@ -511,9 +469,6 @@ Object.assign(window.OC, { } }); -OC.addStyle.loaded=[]; -OC.addScript.loaded=[]; - /** * Initializes core */ diff --git a/core/src/OC/index.js b/core/src/OC/index.js index a27695d8edafbaaa28ad239b5c382498b391439f..81cf002e47ffe1761e953936eeb55ab1a61e0f08 100644 --- a/core/src/OC/index.js +++ b/core/src/OC/index.js @@ -19,6 +19,7 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ +import {addScript, addStyle} from './legacy-loader' import Apps from './apps' import {AppConfig, appConfig} from './appconfig' import appswebroots from './appswebroots' @@ -84,6 +85,8 @@ export default { PERMISSION_UPDATE, TAG_FAVORITE, + addScript, + addStyle, Apps, AppConfig, appConfig, diff --git a/core/src/OC/legacy-loader.js b/core/src/OC/legacy-loader.js new file mode 100644 index 0000000000000000000000000000000000000000..a2c76c2e3ab9f66071817a8027f1721903f47309 --- /dev/null +++ b/core/src/OC/legacy-loader.js @@ -0,0 +1,71 @@ +/* + * @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' + +const loadedScripts = {} +const loadedStyles = [] + +/** + * Load a script for the server and load it. If the script is already loaded, + * the event handler will be called directly + * @param {string} app the app id to which the script belongs + * @param {string} script the filename of the script + * @param ready event handler to be called when the script is loaded + * @deprecated 16.0.0 Use OCP.Loader.loadScript + */ +export const addScript = (app, script, ready) => { + console.warn('OC.addScript is deprecated, use OCP.Loader.loadScript instead') + + let deferred + const path = OC.filePath(app, 'js', script + '.js') + if (!loadedScripts[path]) { + deferred = $.Deferred() + $.getScript(path, () => deferred.resolve()) + loadedScripts[path] = deferred + } else { + if (ready) { + ready() + } + } + return loadedScripts[path] +} + +/** + * Loads a CSS file + * @param {string} app the app id to which the css style belongs + * @param {string} style the filename of the css file + * @deprecated 16.0.0 Use OCP.Loader.loadStylesheet + */ +export const addStyle = (app, style) => { + console.warn('OC.addStyle is deprecated, use OCP.Loader.loadStylesheet instead') + + const path = OC.filePath(app, 'css', style + '.css') + if (loadedStyles.indexOf(path) === -1) { + loadedStyles.push(path) + if (document.createStyleSheet) { + document.createStyleSheet(path) + } else { + style = $('<link rel="stylesheet" type="text/css" href="' + path + '"/>') + $('head').append(style) + } + } +}