diff options
author | John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com> | 2019-09-25 18:19:42 +0200 |
---|---|---|
committer | John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com> | 2019-10-01 17:16:09 +0200 |
commit | b9bc2417e7a8dc81feb0abe20359bedaf864f790 (patch) | |
tree | 61b47fbf37c1d168da8625224debde9e6a985348 /core/src/jquery | |
parent | 7fb651235128dcbca8a6683b5cdafdf835f46300 (diff) | |
download | nextcloud-server-b9bc2417e7a8dc81feb0abe20359bedaf864f790.tar.gz nextcloud-server-b9bc2417e7a8dc81feb0abe20359bedaf864f790.zip |
Comply to eslint
Signed-off-by: John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>
Diffstat (limited to 'core/src/jquery')
-rw-r--r-- | core/src/jquery/avatar.js | 78 | ||||
-rw-r--r-- | core/src/jquery/contactsmenu.js | 94 | ||||
-rw-r--r-- | core/src/jquery/exists.js | 9 | ||||
-rw-r--r-- | core/src/jquery/filterattr.js | 16 | ||||
-rw-r--r-- | core/src/jquery/index.js | 4 | ||||
-rw-r--r-- | core/src/jquery/ocdialog.js | 306 | ||||
-rw-r--r-- | core/src/jquery/octemplate.js | 44 | ||||
-rw-r--r-- | core/src/jquery/placeholder.js | 131 | ||||
-rw-r--r-- | core/src/jquery/requesttoken.js | 12 | ||||
-rw-r--r-- | core/src/jquery/selectrange.js | 29 | ||||
-rw-r--r-- | core/src/jquery/showpassword.js | 99 | ||||
-rw-r--r-- | core/src/jquery/tipsy.js | 66 | ||||
-rw-r--r-- | core/src/jquery/ui-fixes.js | 8 |
13 files changed, 450 insertions, 446 deletions
diff --git a/core/src/jquery/avatar.js b/core/src/jquery/avatar.js index 75aef6d958f..eaedce1461b 100644 --- a/core/src/jquery/avatar.js +++ b/core/src/jquery/avatar.js @@ -64,46 +64,46 @@ import OC from '../OC' * */ -$.fn.avatar = function (user, size, ie8fix, hidedefault, callback, displayname) { - var setAvatarForUnknownUser = function (target) { - target.imageplaceholder('?'); - target.css('background-color', '#b9b9b9'); - }; +$.fn.avatar = function(user, size, ie8fix, hidedefault, callback, displayname) { + var setAvatarForUnknownUser = function(target) { + target.imageplaceholder('?') + target.css('background-color', '#b9b9b9') + } if (typeof (user) !== 'undefined') { - user = String(user); + user = String(user) } if (typeof (displayname) !== 'undefined') { - displayname = String(displayname); + displayname = String(displayname) } if (typeof (size) === 'undefined') { if (this.height() > 0) { - size = this.height(); + size = this.height() } else if (this.data('size') > 0) { - size = this.data('size'); + size = this.data('size') } else { - size = 64; + size = 64 } } - this.height(size); - this.width(size); + this.height(size) + this.width(size) if (typeof (user) === 'undefined') { if (typeof (this.data('user')) !== 'undefined') { - user = this.data('user'); + user = this.data('user') } else { - setAvatarForUnknownUser(this); - return; + setAvatarForUnknownUser(this) + return } } // sanitize - user = String(user).replace(/\//g, ''); + user = String(user).replace(/\//g, '') - var $div = this; - var url; + var $div = this + var url // If this is our own avatar we have to use the version attribute if (user === OC.getCurrentUser().uid) { @@ -113,50 +113,50 @@ $.fn.avatar = function (user, size, ie8fix, hidedefault, callback, displayname) user: user, size: Math.ceil(size * window.devicePixelRatio), version: oc_userconfig.avatar.version - }); + }) } else { url = OC.generateUrl( '/avatar/{user}/{size}', { user: user, size: Math.ceil(size * window.devicePixelRatio) - }); + }) } - var img = new Image(); + var img = new Image() // If the new image loads successfully set it. - img.onload = function () { - $div.clearimageplaceholder(); - $div.append(img); + img.onload = function() { + $div.clearimageplaceholder() + $div.append(img) if (typeof callback === 'function') { - callback(); + callback() } - }; + } // Fallback when avatar loading fails: // Use old placeholder when a displayname attribute is defined, // otherwise show the unknown user placeholder. - img.onerror = function () { - $div.clearimageplaceholder(); + img.onerror = function() { + $div.clearimageplaceholder() if (typeof (displayname) !== 'undefined') { - $div.imageplaceholder(user, displayname); + $div.imageplaceholder(user, displayname) } else { - setAvatarForUnknownUser($div); + setAvatarForUnknownUser($div) } if (typeof callback === 'function') { - callback(); + callback() } - }; + } if (size < 32) { - $div.addClass('icon-loading-small'); + $div.addClass('icon-loading-small') } else { - $div.addClass('icon-loading'); + $div.addClass('icon-loading') } - img.width = size; - img.height = size; - img.src = url; - img.alt = ''; -}; + img.width = size + img.height = size + img.src = url + img.alt = '' +} diff --git a/core/src/jquery/contactsmenu.js b/core/src/jquery/contactsmenu.js index 4f90640eda0..389c8809be0 100644 --- a/core/src/jquery/contactsmenu.js +++ b/core/src/jquery/contactsmenu.js @@ -32,96 +32,92 @@ const LIST = '' + ' </a>' + ' </li>' + ' </ul>' - + '</div>'; + + '</div>' -const entryTemplate = require('./contactsmenu/jquery_entry.handlebars'); +const entryTemplate = require('./contactsmenu/jquery_entry.handlebars') -$.fn.contactsMenu = function (shareWith, shareType, appendTo) { +$.fn.contactsMenu = function(shareWith, shareType, appendTo) { // 0 - user, 4 - email, 6 - remote - var allowedTypes = [0, 4, 6]; + var allowedTypes = [0, 4, 6] if (allowedTypes.indexOf(shareType) === -1) { - return; + return } - var $div = this; - appendTo.append(LIST); - var $list = appendTo.find('div.contactsmenu-popover'); + var $div = this + appendTo.append(LIST) + var $list = appendTo.find('div.contactsmenu-popover') - $div.click(function () { + $div.click(function() { if (!$list.hasClass('hidden')) { - $list.addClass('hidden'); - $list.hide(); - return; + $list.addClass('hidden') + $list.hide() + return } - $list.removeClass('hidden'); - $list.show(); + $list.removeClass('hidden') + $list.show() if ($list.hasClass('loaded')) { - return; + return } - $list.addClass('loaded'); + $list.addClass('loaded') $.ajax(OC.generateUrl('/contactsmenu/findOne'), { method: 'POST', data: { shareType: shareType, shareWith: shareWith } - }).then(function (data) { - $list.find('ul').find('li').addClass('hidden'); + }).then(function(data) { + $list.find('ul').find('li').addClass('hidden') - var actions; + var actions if (!data.topAction) { actions = [{ hyperlink: '#', title: t('core', 'No action available') - }]; + }] } else { - actions = [data.topAction].concat(data.actions); + actions = [data.topAction].concat(data.actions) } - actions.forEach(function (action) { - var template = entryTemplate; - $list.find('ul').append(template(action)); - }); + actions.forEach(function(action) { + var template = entryTemplate + $list.find('ul').append(template(action)) + }) + }, function(jqXHR) { + $list.find('ul').find('li').addClass('hidden') - if (actions.length === 0) { - - } - }, function (jqXHR) { - $list.find('ul').find('li').addClass('hidden'); - - var title; + var title if (jqXHR.status === 404) { - title = t('core', 'No action available'); + title = t('core', 'No action available') } else { - title = t('core', 'Error fetching contact actions'); + title = t('core', 'Error fetching contact actions') } - var template = entryTemplate; + var template = entryTemplate $list.find('ul').append(template({ hyperlink: '#', title: title - })); - }); - }); + })) + }) + }) - $(document).click(function (event) { - var clickedList = ($list.has(event.target).length > 0); - var clickedTarget = ($div.has(event.target).length > 0); + $(document).click(function(event) { + var clickedList = ($list.has(event.target).length > 0) + var clickedTarget = ($div.has(event.target).length > 0) - $div.each(function () { + $div.each(function() { if ($(this).is(event.target)) { - clickedTarget = true; + clickedTarget = true } - }); + }) if (clickedList || clickedTarget) { - return; + return } - $list.addClass('hidden'); - $list.hide(); - }); -}; + $list.addClass('hidden') + $list.hide() + }) +} diff --git a/core/src/jquery/exists.js b/core/src/jquery/exists.js index bdf62ab7d4b..3481faeb6cd 100644 --- a/core/src/jquery/exists.js +++ b/core/src/jquery/exists.js @@ -1,4 +1,4 @@ -/* +/** * @copyright 2019 Christoph Wurst <christoph@winzerhof-wurst.at> * * @author 2019 Christoph Wurst <christoph@winzerhof-wurst.at> @@ -25,7 +25,8 @@ import $ from 'jquery' * check if an element exists. * allows you to write if ($('#myid').exists()) to increase readability * @link http://stackoverflow.com/questions/31044/is-there-an-exists-function-for-jquery + * @returns {boolean} */ -$.fn.exists = function () { - return this.length > 0; -}; +$.fn.exists = function() { + return this.length > 0 +} diff --git a/core/src/jquery/filterattr.js b/core/src/jquery/filterattr.js index 7675eaa1e2d..204d04b46a0 100644 --- a/core/src/jquery/filterattr.js +++ b/core/src/jquery/filterattr.js @@ -1,4 +1,4 @@ -/* +/** * @copyright 2018 Christoph Wurst <christoph@winzerhof-wurst.at> * * @author 2018 Christoph Wurst <christoph@winzerhof-wurst.at> @@ -23,9 +23,13 @@ import $ from 'jquery' /** * Filter jQuery selector by attribute value + * + * @param {string} attrName attribute name + * @param {string} attrValue attribute value + * @returns {Void} */ -$.fn.filterAttr = function (attrName, attrValue) { - return this.filter(function () { - return $(this).attr(attrName) === attrValue; - }); -}; +$.fn.filterAttr = function(attrName, attrValue) { + return this.filter(function() { + return $(this).attr(attrName) === attrValue + }) +} diff --git a/core/src/jquery/index.js b/core/src/jquery/index.js index e2efc76bdf1..d131ae5245a 100644 --- a/core/src/jquery/index.js +++ b/core/src/jquery/index.js @@ -1,4 +1,4 @@ -/* +/** * @copyright 2019 Christoph Wurst <christoph@winzerhof-wurst.at> * * @author 2019 Christoph Wurst <christoph@winzerhof-wurst.at> @@ -59,5 +59,5 @@ $.ajaxSetup({ * * This thus mitigates some unexpected XSS vectors. */ -$.globalEval = function () { +$.globalEval = function() { } diff --git a/core/src/jquery/ocdialog.js b/core/src/jquery/ocdialog.js index 8899d9433d1..68384311531 100644 --- a/core/src/jquery/ocdialog.js +++ b/core/src/jquery/ocdialog.js @@ -29,17 +29,17 @@ $.widget('oc.ocdialog', { closeOnEscape: true, modal: false }, - _create: function () { - var self = this; + _create: function() { + var self = this this.originalCss = { display: this.element[0].style.display, width: this.element[0].style.width, height: this.element[0].style.height - }; + } - this.originalTitle = this.element.attr('title'); - this.options.title = this.options.title || this.originalTitle; + this.originalTitle = this.element.attr('title') + this.options.title = this.options.title || this.originalTitle this.$dialog = $('<div class="oc-dialog" />') .attr({ @@ -47,224 +47,224 @@ $.widget('oc.ocdialog', { tabIndex: -1, role: 'dialog' }) - .insertBefore(this.element); - this.$dialog.append(this.element.detach()); - this.element.removeAttr('title').addClass('oc-dialog-content').appendTo(this.$dialog); + .insertBefore(this.element) + this.$dialog.append(this.element.detach()) + this.element.removeAttr('title').addClass('oc-dialog-content').appendTo(this.$dialog) this.$dialog.css({ display: 'inline-block', position: 'fixed' - }); + }) - this.enterCallback = null; + this.enterCallback = null - $(document).on('keydown keyup', function (event) { + $(document).on('keydown keyup', function(event) { if ( - event.target !== self.$dialog.get(0) && - self.$dialog.find($(event.target)).length === 0 + event.target !== self.$dialog.get(0) + && self.$dialog.find($(event.target)).length === 0 ) { - return; + return } // Escape if ( - event.keyCode === 27 && - event.type === 'keydown' && - self.options.closeOnEscape + event.keyCode === 27 + && event.type === 'keydown' + && self.options.closeOnEscape ) { - event.stopImmediatePropagation(); - self.close(); - return false; + event.stopImmediatePropagation() + self.close() + return false } // Enter if (event.keyCode === 13) { - event.stopImmediatePropagation(); + event.stopImmediatePropagation() if (self.enterCallback !== null) { - self.enterCallback(); - event.preventDefault(); - return false; + self.enterCallback() + event.preventDefault() + return false } if (event.type === 'keyup') { - event.preventDefault(); - return false; + event.preventDefault() + return false } // If no button is selected we trigger the primary if ( - self.$buttonrow && - self.$buttonrow.find($(event.target)).length === 0 + self.$buttonrow + && self.$buttonrow.find($(event.target)).length === 0 ) { - var $button = self.$buttonrow.find('button.primary'); + var $button = self.$buttonrow.find('button.primary') if ($button && !$button.prop('disabled')) { - $button.trigger('click'); + $button.trigger('click') } } else if (self.$buttonrow) { - $(event.target).trigger('click'); + $(event.target).trigger('click') } - return false; + return false } - }); + }) - this._setOptions(this.options); - this._createOverlay(); + this._setOptions(this.options) + this._createOverlay() }, - _init: function () { - this.$dialog.focus(); - this._trigger('open'); + _init: function() { + this.$dialog.focus() + this._trigger('open') }, - _setOption: function (key, value) { - var self = this; + _setOption: function(key, value) { + var self = this switch (key) { - case 'title': - if (this.$title) { - this.$title.text(value); - } else { - var $title = $('<h2 class="oc-dialog-title">' + case 'title': + if (this.$title) { + this.$title.text(value) + } else { + var $title = $('<h2 class="oc-dialog-title">' + value - + '</h2>'); - this.$title = $title.prependTo(this.$dialog); - } - this._setSizes(); - break; - case 'buttons': - if (this.$buttonrow) { - this.$buttonrow.empty(); - } else { - var $buttonrow = $('<div class="oc-dialog-buttonrow" />'); - this.$buttonrow = $buttonrow.appendTo(this.$dialog); - } - if (value.length === 1) { - this.$buttonrow.addClass('onebutton'); - } else if (value.length === 2) { - this.$buttonrow.addClass('twobuttons'); - } else if (value.length === 3) { - this.$buttonrow.addClass('threebuttons'); - } - $.each(value, function (idx, val) { - var $button = $('<button>').text(val.text); - if (val.classes) { - $button.addClass(val.classes); - } - if (val.defaultButton) { - $button.addClass('primary'); - self.$defaultButton = $button; - } - self.$buttonrow.append($button); - $button.click(function () { - val.click.apply(self.element[0], arguments); - }); - }); - this.$buttonrow.find('button') - .on('focus', function (event) { - self.$buttonrow.find('button').removeClass('primary'); - $(this).addClass('primary'); - }); - this._setSizes(); - break; - case 'style': - if (value.buttons !== undefined) { - this.$buttonrow.addClass(value.buttons); + + '</h2>') + this.$title = $title.prependTo(this.$dialog) + } + this._setSizes() + break + case 'buttons': + if (this.$buttonrow) { + this.$buttonrow.empty() + } else { + var $buttonrow = $('<div class="oc-dialog-buttonrow" />') + this.$buttonrow = $buttonrow.appendTo(this.$dialog) + } + if (value.length === 1) { + this.$buttonrow.addClass('onebutton') + } else if (value.length === 2) { + this.$buttonrow.addClass('twobuttons') + } else if (value.length === 3) { + this.$buttonrow.addClass('threebuttons') + } + $.each(value, function(idx, val) { + var $button = $('<button>').text(val.text) + if (val.classes) { + $button.addClass(val.classes) } - break; - case 'closeButton': - if (value) { - var $closeButton = $('<a class="oc-dialog-close"></a>'); - this.$dialog.prepend($closeButton); - $closeButton.on('click', function () { - self.close(); - }); - } else { - this.$dialog.find('.oc-dialog-close').remove(); + if (val.defaultButton) { + $button.addClass('primary') + self.$defaultButton = $button } - break; - case 'width': - this.$dialog.css('width', value); - break; - case 'height': - this.$dialog.css('height', value); - break; - case 'close': - this.closeCB = value; - break; + self.$buttonrow.append($button) + $button.click(function() { + val.click.apply(self.element[0], arguments) + }) + }) + this.$buttonrow.find('button') + .on('focus', function(event) { + self.$buttonrow.find('button').removeClass('primary') + $(this).addClass('primary') + }) + this._setSizes() + break + case 'style': + if (value.buttons !== undefined) { + this.$buttonrow.addClass(value.buttons) + } + break + case 'closeButton': + if (value) { + var $closeButton = $('<a class="oc-dialog-close"></a>') + this.$dialog.prepend($closeButton) + $closeButton.on('click', function() { + self.close() + }) + } else { + this.$dialog.find('.oc-dialog-close').remove() + } + break + case 'width': + this.$dialog.css('width', value) + break + case 'height': + this.$dialog.css('height', value) + break + case 'close': + this.closeCB = value + break } - //this._super(key, value); - $.Widget.prototype._setOption.apply(this, arguments); + // this._super(key, value); + $.Widget.prototype._setOption.apply(this, arguments) }, - _setOptions: function (options) { - //this._super(options); - $.Widget.prototype._setOptions.apply(this, arguments); + _setOptions: function(options) { + // this._super(options); + $.Widget.prototype._setOptions.apply(this, arguments) }, - _setSizes: function () { - var lessHeight = 0; + _setSizes: function() { + var lessHeight = 0 if (this.$title) { - lessHeight += this.$title.outerHeight(true); + lessHeight += this.$title.outerHeight(true) } if (this.$buttonrow) { - lessHeight += this.$buttonrow.outerHeight(true); + lessHeight += this.$buttonrow.outerHeight(true) } this.element.css({ 'height': 'calc(100% - ' + lessHeight + 'px)' - }); + }) }, - _createOverlay: function () { + _createOverlay: function() { if (!this.options.modal) { - return; + return } - var self = this; + var self = this this.overlay = $('<div>') .addClass('oc-dialog-dim') - .appendTo($('#content')); - this.overlay.on('click keydown keyup', function (event) { + .appendTo($('#content')) + this.overlay.on('click keydown keyup', function(event) { if (event.target !== self.$dialog.get(0) && self.$dialog.find($(event.target)).length === 0) { - event.preventDefault(); - event.stopPropagation(); - return; + event.preventDefault() + event.stopPropagation() + } - }); + }) }, - _destroyOverlay: function () { + _destroyOverlay: function() { if (!this.options.modal) { - return; + return } if (this.overlay) { - this.overlay.off('click keydown keyup'); - this.overlay.remove(); - this.overlay = null; + this.overlay.off('click keydown keyup') + this.overlay.remove() + this.overlay = null } }, - widget: function () { - return this.$dialog; + widget: function() { + return this.$dialog }, - setEnterCallback: function (callback) { - this.enterCallback = callback; + setEnterCallback: function(callback) { + this.enterCallback = callback }, - unsetEnterCallback: function () { - this.enterCallback = null; + unsetEnterCallback: function() { + this.enterCallback = null }, - close: function () { - this._destroyOverlay(); - var self = this; + close: function() { + this._destroyOverlay() + var self = this // Ugly hack to catch remaining keyup events. - setTimeout(function () { - self._trigger('close', self); - }, 200); + setTimeout(function() { + self._trigger('close', self) + }, 200) - self.$dialog.remove(); - this.destroy(); + self.$dialog.remove() + this.destroy() }, - destroy: function () { + destroy: function() { if (this.$title) { - this.$title.remove(); + this.$title.remove() } if (this.$buttonrow) { - this.$buttonrow.remove(); + this.$buttonrow.remove() } if (this.originalTitle) { - this.element.attr('title', this.originalTitle); + this.element.attr('title', this.originalTitle) } this.element.removeClass('oc-dialog-content') - .css(this.originalCss).detach().insertBefore(this.$dialog); - this.$dialog.remove(); + .css(this.originalCss).detach().insertBefore(this.$dialog) + this.$dialog.remove() } -}); +}) diff --git a/core/src/jquery/octemplate.js b/core/src/jquery/octemplate.js index 61fbea2af5f..24df6739225 100644 --- a/core/src/jquery/octemplate.js +++ b/core/src/jquery/octemplate.js @@ -56,49 +56,49 @@ import escapeHTML from '../Util/escapeHTML' * Inspired by micro templating done by e.g. underscore.js */ const Template = { - init: function (vars, options, elem) { + init: function(vars, options, elem) { // Mix in the passed in options with the default options - this.vars = vars; - this.options = $.extend({}, this.options, options); + this.vars = vars + this.options = $.extend({}, this.options, options) - this.elem = elem; - var self = this; + this.elem = elem + var self = this if (typeof this.options.escapeFunction === 'function') { - var keys = Object.keys(this.vars); + var keys = Object.keys(this.vars) for (var key = 0; key < keys.length; key++) { if (typeof this.vars[keys[key]] === 'string') { - this.vars[keys[key]] = self.options.escapeFunction(this.vars[keys[key]]); + this.vars[keys[key]] = self.options.escapeFunction(this.vars[keys[key]]) } } } - var _html = this._build(this.vars); - return $(_html); + var _html = this._build(this.vars) + return $(_html) }, // From stackoverflow.com/questions/1408289/best-way-to-do-variable-interpolation-in-javascript - _build: function (o) { - var data = this.elem.attr('type') === 'text/template' ? this.elem.html() : this.elem.get(0).outerHTML; + _build: function(o) { + var data = this.elem.attr('type') === 'text/template' ? this.elem.html() : this.elem.get(0).outerHTML try { return data.replace(/{([^{}]*)}/g, - function (a, b) { - var r = o[b]; - return typeof r === 'string' || typeof r === 'number' ? r : a; + function(a, b) { + var r = o[b] + return typeof r === 'string' || typeof r === 'number' ? r : a } - ); + ) } catch (e) { - console.error(e, 'data:', data); + console.error(e, 'data:', data) } }, options: { escapeFunction: escapeHTML } -}; +} -$.fn.octemplate = function (vars, options) { - vars = vars || {}; +$.fn.octemplate = function(vars, options) { + vars = vars || {} if (this.length) { - var _template = Object.create(Template); - return _template.init(vars, options, this); + var _template = Object.create(Template) + return _template.init(vars, options, this) } -}; +} diff --git a/core/src/jquery/placeholder.js b/core/src/jquery/placeholder.js index 074ad5029b5..029071c4d99 100644 --- a/core/src/jquery/placeholder.js +++ b/core/src/jquery/placeholder.js @@ -1,3 +1,4 @@ +/* eslint-disable */ /** * ownCloud * @@ -61,114 +62,114 @@ import $ from 'jquery' * */ -String.prototype.toRgb = function () { +String.prototype.toRgb = function() { // Normalize hash - var hash = this.toLowerCase(); + var hash = this.toLowerCase() // Already a md5 hash? if (hash.match(/^([0-9a-f]{4}-?){8}$/) === null) { - hash = md5(hash); + hash = md5(hash) } - hash = hash.replace(/[^0-9a-f]/g, ''); + hash = hash.replace(/[^0-9a-f]/g, '') - function Color (r, g, b) { - this.r = r; - this.g = g; - this.b = b; + function Color(r, g, b) { + this.r = r + this.g = g + this.b = b } - function stepCalc (steps, ends) { - var step = new Array(3); - step[0] = (ends[1].r - ends[0].r) / steps; - step[1] = (ends[1].g - ends[0].g) / steps; - step[2] = (ends[1].b - ends[0].b) / steps; - return step; + function stepCalc(steps, ends) { + var step = new Array(3) + step[0] = (ends[1].r - ends[0].r) / steps + step[1] = (ends[1].g - ends[0].g) / steps + step[2] = (ends[1].b - ends[0].b) / steps + return step } - function mixPalette (steps, color1, color2) { - var count = steps + 1; - var palette = new Array(); - palette.push(color1); + function mixPalette(steps, color1, color2) { + var count = steps + 1 + var palette = new Array() + palette.push(color1) var step = stepCalc(steps, [color1, color2]) for (var i = 1; i < steps; i++) { - var r = parseInt(color1.r + (step[0] * i)); - var g = parseInt(color1.g + (step[1] * i)); - var b = parseInt(color1.b + (step[2] * i)); - palette.push(new Color(r, g, b)); + var r = parseInt(color1.r + (step[0] * i)) + var g = parseInt(color1.g + (step[1] * i)) + var b = parseInt(color1.b + (step[2] * i)) + palette.push(new Color(r, g, b)) } - return palette; + return palette } - var red = new Color(182, 70, 157); - var yellow = new Color(221, 203, 85); - var blue = new Color(0, 130, 201); // Nextcloud blue + var red = new Color(182, 70, 157) + var yellow = new Color(221, 203, 85) + var blue = new Color(0, 130, 201) // Nextcloud blue // Number of steps to go from a color to another // 3 colors * 6 will result in 18 generated colors - var steps = 6; + var steps = 6 - var palette1 = mixPalette(steps, red, yellow); - var palette2 = mixPalette(steps, yellow, blue); - var palette3 = mixPalette(steps, blue, red); + var palette1 = mixPalette(steps, red, yellow) + var palette2 = mixPalette(steps, yellow, blue) + var palette3 = mixPalette(steps, blue, red) - var finalPalette = palette1.concat(palette2).concat(palette3); + var finalPalette = palette1.concat(palette2).concat(palette3) // Convert a string to an integer evenly - function hashToInt (hash, maximum) { - var finalInt = 0; - var result = Array(); + function hashToInt(hash, maximum) { + var finalInt = 0 + var result = Array() // Splitting evenly the string for (var i = 0; i < hash.length; i++) { // chars in md5 goes up to f, hex:16 - result.push(parseInt(hash.charAt(i), 16) % 16); + result.push(parseInt(hash.charAt(i), 16) % 16) } // Adds up all results for (var j in result) { - finalInt += result[j]; + finalInt += result[j] } // chars in md5 goes up to f, hex:16 // make sure we're always using int in our operation - return parseInt(parseInt(finalInt) % maximum); + return parseInt(parseInt(finalInt) % maximum) } - return finalPalette[hashToInt(hash, steps * 3)]; -}; + return finalPalette[hashToInt(hash, steps * 3)] +} -$.fn.imageplaceholder = function (seed, text, size) { - text = text || seed; +$.fn.imageplaceholder = function(seed, text, size) { + text = text || seed // Compute the hash - var rgb = seed.toRgb(); - this.css('background-color', 'rgb(' + rgb.r + ', ' + rgb.g + ', ' + rgb.b + ')'); + var rgb = seed.toRgb() + this.css('background-color', 'rgb(' + rgb.r + ', ' + rgb.g + ', ' + rgb.b + ')') // Placeholders are square - var height = this.height() || size || 32; - this.height(height); - this.width(height); + var height = this.height() || size || 32 + this.height(height) + this.width(height) // CSS rules - this.css('color', '#fff'); - this.css('font-weight', 'normal'); - this.css('text-align', 'center'); + this.css('color', '#fff') + this.css('font-weight', 'normal') + this.css('text-align', 'center') // calculate the height - this.css('line-height', height + 'px'); - this.css('font-size', (height * 0.55) + 'px'); + this.css('line-height', height + 'px') + this.css('font-size', (height * 0.55) + 'px') if (seed !== null && seed.length) { - this.html(text[0].toUpperCase()); + this.html(text[0].toUpperCase()) } -}; - -$.fn.clearimageplaceholder = function () { - this.css('background-color', ''); - this.css('color', ''); - this.css('font-weight', ''); - this.css('text-align', ''); - this.css('line-height', ''); - this.css('font-size', ''); - this.html(''); - this.removeClass('icon-loading'); - this.removeClass('icon-loading-small'); -}; +} + +$.fn.clearimageplaceholder = function() { + this.css('background-color', '') + this.css('color', '') + this.css('font-weight', '') + this.css('text-align', '') + this.css('line-height', '') + this.css('font-size', '') + this.html('') + this.removeClass('icon-loading') + this.removeClass('icon-loading-small') +} diff --git a/core/src/jquery/requesttoken.js b/core/src/jquery/requesttoken.js index a8fb024d04a..5f15d43aa17 100644 --- a/core/src/jquery/requesttoken.js +++ b/core/src/jquery/requesttoken.js @@ -21,11 +21,11 @@ import $ from 'jquery' -import {getToken} from '../OC/requesttoken' +import { getToken } from '../OC/requesttoken' -$(document).on('ajaxSend',function(elm, xhr, settings) { - if(settings.crossDomain === false) { - xhr.setRequestHeader('requesttoken', getToken()); - xhr.setRequestHeader('OCS-APIREQUEST', 'true'); +$(document).on('ajaxSend', function(elm, xhr, settings) { + if (settings.crossDomain === false) { + xhr.setRequestHeader('requesttoken', getToken()) + xhr.setRequestHeader('OCS-APIREQUEST', 'true') } -}); +}) diff --git a/core/src/jquery/selectrange.js b/core/src/jquery/selectrange.js index b7e20361805..b53bac4fc02 100644 --- a/core/src/jquery/selectrange.js +++ b/core/src/jquery/selectrange.js @@ -1,4 +1,4 @@ -/* +/** * @copyright 2019 Christoph Wurst <christoph@winzerhof-wurst.at> * * @author 2019 Christoph Wurst <christoph@winzerhof-wurst.at> @@ -24,20 +24,21 @@ import $ from 'jquery' /** * select a range in an input field * @link http://stackoverflow.com/questions/499126/jquery-set-cursor-position-in-text-area - * @param {type} start - * @param {type} end + * @param {int} start start selection from + * @param {int} end number of char from start + * @returns {Void} */ -$.fn.selectRange = function (start, end) { - return this.each(function () { +$.fn.selectRange = function(start, end) { + return this.each(function() { if (this.setSelectionRange) { - this.focus(); - this.setSelectionRange(start, end); + this.focus() + this.setSelectionRange(start, end) } else if (this.createTextRange) { - var range = this.createTextRange(); - range.collapse(true); - range.moveEnd('character', end); - range.moveStart('character', start); - range.select(); + var range = this.createTextRange() + range.collapse(true) + range.moveEnd('character', end) + range.moveStart('character', start) + range.select() } - }); -}; + }) +} diff --git a/core/src/jquery/showpassword.js b/core/src/jquery/showpassword.js index 4dc39340e76..a9857f4d6d4 100644 --- a/core/src/jquery/showpassword.js +++ b/core/src/jquery/showpassword.js @@ -36,18 +36,18 @@ import $ from 'jquery' * @licens MIT License - http://www.opensource.org/licenses/mit-license.php */ $.fn.extend({ - showPassword: function (c) { + showPassword: function(c) { // Setup callback object - var callback = {'fn': null, 'args': {}}; - callback.fn = c; + var callback = { 'fn': null, 'args': {} } + callback.fn = c // Clones passwords and turn the clones into text inputs - var cloneElement = function (element) { + var cloneElement = function(element) { - var $element = $(element); + var $element = $(element) - var $clone = $("<input />"); + var $clone = $('<input />') // Name added for JQuery Validation compatibility // Element name is required to avoid script warning. @@ -59,91 +59,90 @@ $.fn.extend({ 'name': $element.attr('name') + '-clone', 'tabindex': $element.attr('tabindex'), 'autocomplete': 'off' - }); + }) if ($element.attr('placeholder') !== undefined) { - $clone.attr('placeholder', $element.attr('placeholder')); + $clone.attr('placeholder', $element.attr('placeholder')) } - return $clone; + return $clone - }; + } // Transfers values between two elements - var update = function (a, b) { - b.val(a.val()); - }; + var update = function(a, b) { + b.val(a.val()) + } // Shows a or b depending on checkbox - var setState = function (checkbox, a, b) { + var setState = function(checkbox, a, b) { if (checkbox.is(':checked')) { - update(a, b); - b.show(); - a.hide(); + update(a, b) + b.show() + a.hide() } else { - update(b, a); - b.hide(); - a.show(); + update(b, a) + b.hide() + a.show() } - }; + } - return this.each(function () { + return this.each(function() { - var $input = $(this), - $checkbox = $($input.data('typetoggle')); + var $input = $(this) + var $checkbox = $($input.data('typetoggle')) // Create clone - var $clone = cloneElement($input); - $clone.insertAfter($input); + var $clone = cloneElement($input) + $clone.insertAfter($input) // Set callback arguments if (callback.fn) { - callback.args.input = $input; - callback.args.checkbox = $checkbox; - callback.args.clone = $clone; + callback.args.input = $input + callback.args.checkbox = $checkbox + callback.args.clone = $clone } + $checkbox.bind('click', function() { + setState($checkbox, $input, $clone) + }) - $checkbox.bind('click', function () { - setState($checkbox, $input, $clone); - }); + $input.bind('keyup', function() { + update($input, $clone) + }) - $input.bind('keyup', function () { - update($input, $clone); - }); - - $clone.bind('keyup', function () { - update($clone, $input); + $clone.bind('keyup', function() { + update($clone, $input) // Added for JQuery Validation compatibility // This will trigger validation if it's ON for keyup event - $input.trigger('keyup'); + $input.trigger('keyup') - }); + }) // Added for JQuery Validation compatibility // This will trigger validation if it's ON for blur event - $clone.bind('blur', function () { - $input.trigger('focusout'); - }); + $clone.bind('blur', function() { + $input.trigger('focusout') + }) - setState($checkbox, $input, $clone); + setState($checkbox, $input, $clone) // set type of password field clone (type=text) to password right on submit // to prevent browser save the value of this field - $clone.closest('form').submit(function (e) { + $clone.closest('form').submit(function(e) { // .prop has to be used, because .attr throws // an error while changing a type of an input // element - $clone.prop('type', 'password'); - }); + $clone.prop('type', 'password') + }) if (callback.fn) { - callback.fn(callback.args); + callback.fn(callback.args) } - }); + }) } -}); +}) diff --git a/core/src/jquery/tipsy.js b/core/src/jquery/tipsy.js index 816a93fb9a9..75e90b1c060 100644 --- a/core/src/jquery/tipsy.js +++ b/core/src/jquery/tipsy.js @@ -1,4 +1,4 @@ -/* +/** * @copyright 2019 Christoph Wurst <christoph@winzerhof-wurst.at> * * @author 2019 Christoph Wurst <christoph@winzerhof-wurst.at> @@ -23,61 +23,63 @@ import $ from 'jquery' /** * $ tipsy shim for the bootstrap tooltip + * @param {Object} argument options + * @returns {Object} this * @deprecated */ -$.fn.tipsy = function (argument) { - console.warn('Deprecation warning: tipsy is deprecated. Use tooltip instead.'); +$.fn.tipsy = function(argument) { + console.warn('Deprecation warning: tipsy is deprecated. Use tooltip instead.') if (typeof argument === 'object' && argument !== null) { // tipsy defaults var options = { placement: 'bottom', - delay: {'show': 0, 'hide': 0}, + delay: { 'show': 0, 'hide': 0 }, trigger: 'hover', html: false, container: 'body' - }; + } if (argument.gravity) { switch (argument.gravity) { - case 'n': - case 'nw': - case 'ne': - options.placement = 'bottom'; - break; - case 's': - case 'sw': - case 'se': - options.placement = 'top'; - break; - case 'w': - options.placement = 'right'; - break; - case 'e': - options.placement = 'left'; - break; + case 'n': + case 'nw': + case 'ne': + options.placement = 'bottom' + break + case 's': + case 'sw': + case 'se': + options.placement = 'top' + break + case 'w': + options.placement = 'right' + break + case 'e': + options.placement = 'left' + break } } if (argument.trigger) { - options.trigger = argument.trigger; + options.trigger = argument.trigger } if (argument.delayIn) { - options.delay.show = argument.delayIn; + options.delay.show = argument.delayIn } if (argument.delayOut) { - options.delay.hide = argument.delayOut; + options.delay.hide = argument.delayOut } if (argument.html) { - options.html = true; + options.html = true } if (argument.fallback) { - options.title = argument.fallback; + options.title = argument.fallback } // destroy old tooltip in case the title has changed - $.fn.tooltip.call(this, 'destroy'); - $.fn.tooltip.call(this, options); + $.fn.tooltip.call(this, 'destroy') + $.fn.tooltip.call(this, options) } else { - this.tooltip(argument); - $.fn.tooltip.call(this, argument); + this.tooltip(argument) + $.fn.tooltip.call(this, argument) } - return this; -};
\ No newline at end of file + return this +} diff --git a/core/src/jquery/ui-fixes.js b/core/src/jquery/ui-fixes.js index d3cebfc346e..fb5ce4d7ba8 100644 --- a/core/src/jquery/ui-fixes.js +++ b/core/src/jquery/ui-fixes.js @@ -2,7 +2,7 @@ import $ from 'jquery' // Set autocomplete width the same as the related input // See http://stackoverflow.com/a/11845718 -$.ui.autocomplete.prototype._resizeMenu = function () { - var ul = this.menu.element; - ul.outerWidth(this.element.outerWidth()); -}; +$.ui.autocomplete.prototype._resizeMenu = function() { + var ul = this.menu.element + ul.outerWidth(this.element.outerWidth()) +} |