2019-03-15 00:34:35 +03:00
|
|
|
/**
|
|
|
|
* @copyright 2019 Christoph Wurst <christoph@winzerhof-wurst.at>
|
2018-12-11 22:56:46 +03:00
|
|
|
*
|
2019-03-15 00:34:35 +03:00
|
|
|
* @author 2019 Christoph Wurst <christoph@winzerhof-wurst.at>
|
2018-12-11 22:56:46 +03:00
|
|
|
*
|
|
|
|
* @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/>.
|
|
|
|
*/
|
|
|
|
|
2019-03-15 00:34:35 +03:00
|
|
|
/**
|
2019-04-29 19:16:15 +03:00
|
|
|
*
|
2019-03-15 00:34:35 +03:00
|
|
|
* @param {Function} func the library to deprecate
|
|
|
|
* @param {String} funcName the name of the library
|
|
|
|
*/
|
|
|
|
const deprecate = (func, funcName) => {
|
|
|
|
const oldFunc = func
|
|
|
|
const newFunc = function() {
|
|
|
|
console.warn(`The ${funcName} library is deprecated! It will be removed in nextcloud 19.`)
|
|
|
|
return oldFunc.apply(this, arguments)
|
|
|
|
}
|
|
|
|
Object.assign(newFunc, oldFunc)
|
|
|
|
return newFunc
|
|
|
|
}
|
|
|
|
|
2019-04-29 19:04:45 +03:00
|
|
|
const setDeprecatedProp = (global, val, msg) => {
|
|
|
|
if (window[global] !== undefined) {
|
|
|
|
delete window[global]
|
|
|
|
}
|
2019-04-29 19:16:15 +03:00
|
|
|
Object.defineProperty(window, global, {
|
|
|
|
get: () => {
|
|
|
|
if (msg) {
|
|
|
|
console.warn(`${global} is deprecated: ${msg}`)
|
|
|
|
} else {
|
|
|
|
console.warn(`${global} is deprecated`)
|
|
|
|
}
|
|
|
|
return val
|
|
|
|
}
|
|
|
|
})
|
2019-04-29 19:04:45 +03:00
|
|
|
}
|
2019-04-29 19:16:15 +03:00
|
|
|
|
2018-12-11 22:56:46 +03:00
|
|
|
import _ from 'underscore'
|
|
|
|
import $ from 'jquery'
|
|
|
|
import 'jquery-migrate/dist/jquery-migrate.min'
|
2018-12-21 15:30:33 +03:00
|
|
|
// TODO: switch to `jquery-ui` package and import widgets and effects individually
|
|
|
|
// `jquery-ui-dist` is used as a workaround for the issue of missing effects
|
|
|
|
import 'jquery-ui-dist/jquery-ui'
|
|
|
|
import 'jquery-ui-dist/jquery-ui.css'
|
|
|
|
import 'jquery-ui-dist/jquery-ui.theme.css'
|
|
|
|
// END TODO
|
2018-12-11 22:56:46 +03:00
|
|
|
import autosize from 'autosize'
|
|
|
|
import Backbone from 'backbone'
|
2019-03-01 16:48:08 +03:00
|
|
|
import 'bootstrap/js/dist/tooltip'
|
2019-03-06 21:47:12 +03:00
|
|
|
import './Polyfill/tooltip'
|
2019-01-14 14:01:04 +03:00
|
|
|
import ClipboardJS from 'clipboard'
|
2018-12-20 19:59:55 +03:00
|
|
|
import cssVars from 'css-vars-ponyfill'
|
2018-12-11 22:56:46 +03:00
|
|
|
import dav from 'davclient.js'
|
|
|
|
import DOMPurify from 'dompurify'
|
|
|
|
import Handlebars from 'handlebars'
|
|
|
|
import 'jcrop/js/jquery.Jcrop'
|
|
|
|
import 'jcrop/css/jquery.Jcrop.css'
|
|
|
|
import jstimezonedetect from 'jstimezonedetect'
|
|
|
|
import marked from 'marked'
|
|
|
|
import md5 from 'blueimp-md5'
|
|
|
|
import moment from 'moment'
|
2019-01-09 18:57:08 +03:00
|
|
|
import 'Select2'
|
|
|
|
import 'Select2/select2.css'
|
2018-12-11 22:56:46 +03:00
|
|
|
import 'snap.js/dist/snap'
|
|
|
|
import 'strengthify'
|
|
|
|
import 'strengthify/strengthify.css'
|
|
|
|
|
2019-01-28 13:24:08 +03:00
|
|
|
import OC from './OC/index'
|
|
|
|
import OCP from './OCP/index'
|
|
|
|
import OCA from './OCA/index'
|
2019-01-29 12:15:46 +03:00
|
|
|
import escapeHTML from './Util/escapeHTML'
|
2019-01-31 21:19:47 +03:00
|
|
|
import formatDate from './Util/format-date'
|
2019-02-05 14:48:31 +03:00
|
|
|
import getURLParameter from './Util/get-url-parameter'
|
2019-01-31 20:50:59 +03:00
|
|
|
import humanFileSize from './Util/human-file-size'
|
2019-01-31 21:19:47 +03:00
|
|
|
import relative_modified_date from './Util/relative-modified-date'
|
2019-01-28 13:24:08 +03:00
|
|
|
|
2018-12-11 22:56:46 +03:00
|
|
|
window['_'] = _
|
|
|
|
window['$'] = $
|
|
|
|
window['autosize'] = autosize
|
|
|
|
window['Backbone'] = Backbone
|
2019-01-14 14:01:04 +03:00
|
|
|
window['Clipboard'] = ClipboardJS
|
|
|
|
window['ClipboardJS'] = ClipboardJS
|
2018-12-20 19:59:55 +03:00
|
|
|
window['cssVars'] = cssVars
|
2018-12-11 22:56:46 +03:00
|
|
|
window['dav'] = dav
|
|
|
|
window['DOMPurify'] = DOMPurify
|
|
|
|
window['Handlebars'] = Handlebars
|
|
|
|
window['jstimezonedetect'] = jstimezonedetect
|
|
|
|
window['jstz'] = jstimezonedetect
|
|
|
|
window['jQuery'] = $
|
2019-03-15 00:34:35 +03:00
|
|
|
window['marked'] = deprecate(marked, 'marked')
|
2018-12-11 22:56:46 +03:00
|
|
|
window['md5'] = md5
|
|
|
|
window['moment'] = moment
|
2019-01-28 13:24:08 +03:00
|
|
|
|
|
|
|
window['OC'] = OC
|
2019-04-29 19:04:45 +03:00
|
|
|
setDeprecatedProp('oc_config', OC.config, 'use OC.config instead')
|
2019-05-03 10:07:31 +03:00
|
|
|
setDeprecatedProp('oc_isadmin', OC.isUserAdmin(), 'use OC.isUserAdmin() instead')
|
2019-04-29 19:04:45 +03:00
|
|
|
setDeprecatedProp('OCDialogs', OC.dialogs, 'use OC.dialogs instead')
|
2019-01-28 13:24:08 +03:00
|
|
|
window['OCP'] = OCP
|
|
|
|
window['OCA'] = OCA
|
2019-03-15 00:34:35 +03:00
|
|
|
window['escapeHTML'] = deprecate(escapeHTML, 'escapeHTML')
|
|
|
|
window['formatDate'] = deprecate(formatDate, 'formatDate')
|
|
|
|
window['getURLParameter'] = deprecate(getURLParameter, 'getURLParameter')
|
|
|
|
window['humanFileSize'] = deprecate(humanFileSize, 'humanFileSize')
|
|
|
|
window['relative_modified_date'] = deprecate(relative_modified_date, 'relative_modified_date')
|
|
|
|
$.fn.select2 = deprecate($.fn.select2, 'select2')
|
2019-01-29 11:28:45 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* translate a string
|
|
|
|
* @param {string} app the id of the app for which to translate the string
|
|
|
|
* @param {string} text the string to translate
|
|
|
|
* @param [vars] map of placeholder key to value
|
|
|
|
* @param {number} [count] number to replace %n with
|
|
|
|
* @return {string}
|
|
|
|
*/
|
|
|
|
window.t = _.bind(OC.L10N.translate, OC.L10N);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* translate a string
|
|
|
|
* @param {string} app the id of the app for which to translate the string
|
|
|
|
* @param {string} text_singular the string to translate for exactly one object
|
|
|
|
* @param {string} text_plural the string to translate for n objects
|
|
|
|
* @param {number} count number to determine whether to use singular or plural
|
|
|
|
* @param [vars] map of placeholder key to value
|
|
|
|
* @return {string} Translated string
|
|
|
|
*/
|
|
|
|
window.n = _.bind(OC.L10N.translatePlural, OC.L10N);
|