Version 5.1 - All the GraphQL #32

Closed
timw4mail wants to merge 1160 commits from develop into master
4 changed files with 32 additions and 26 deletions
Showing only changes of commit 664a9ec14a - Show all commits

View File

@ -18,8 +18,8 @@ const search = (query) => {
};
if (_.hasElement('.anime #search')) {
_.on('#search', 'keyup', _.throttle(250, function () {
const query = encodeURIComponent(this.value);
_.on('#search', 'keyup', _.throttle(250, (e) => {
const query = encodeURIComponent(e.target.value);
if (query === '') {
return;
}
@ -82,7 +82,7 @@ _.on('body.anime.list', 'click', '.plus_one', (e) => {
_.$('.completed_number', parentSel)[ 0 ].textContent = ++watchedCount;
_.scrollToTop();
},
error: (xhr, errorType, error) => {
error: () => {
_.hide(_.$('#loading-shadow')[ 0 ]);
_.showMessage('error', `Failed to update ${title}. `);
_.scrollToTop();

View File

@ -193,8 +193,8 @@ function delegateEvent(sel, target, event, listener) {
* @param {function} [listener] - event listener callback
* @return {void}
*/
AnimeClient.on = function (sel, event, target, listener) {
if (arguments.length === 3) {
AnimeClient.on = (sel, event, target, listener) => {
if (listener === undefined) {
listener = target;
AnimeClient.$(sel).forEach((el) => {
addEvent(el, event, listener);
@ -246,15 +246,21 @@ function ajaxSerialize(data) {
* @param {Object} config - the configuration object
* @return {void}
*/
AnimeClient.ajax = function(url, config) {
AnimeClient.ajax = (url, config) => {
// Set some sane defaults
config = config || {};
config.data = config.data || {};
config.type = config.type || 'GET';
config.dataType = config.dataType || '';
config.success = config.success || AnimeClient.noop;
config.mimeType = config.mimeType || 'application/x-www-form-urlencoded';
config.error = config.error || AnimeClient.noop;
const defaultConfig = {
data: {},
type: 'GET',
dataType: '',
success: AnimeClient.noop,
mimeType: 'application/x-www-form-urlencoded',
error: AnimeClient.noop
}
config = {
...defaultConfig,
...config,
}
let request = new XMLHttpRequest();
let method = String(config.type).toUpperCase();
@ -312,7 +318,7 @@ AnimeClient.ajax = function(url, config) {
* @param {object|function} data
* @param {function} [callback]
*/
AnimeClient.get = function(url, data, callback = null) {
AnimeClient.get = (url, data, callback = null) => {
if (callback === null) {
callback = data;
data = {};

View File

@ -3,8 +3,8 @@ import _ from './AnimeClient.js';
* Event handlers
*/
// Close event for messages
_.on('header', 'click', '.message', function () {
_.hide(this);
_.on('header', 'click', '.message', (e) => {
_.hide(e.target);
});
// Confirm deleting of list or library items

View File

@ -11,8 +11,8 @@ const search = (query) => {
};
if (_.hasElement('.manga #search')) {
_.on('#search', 'keyup', _.throttle(250, function (e) {
let query = encodeURIComponent(this.value);
_.on('#search', 'keyup', _.throttle(250, (e) => {
let query = encodeURIComponent(e.target.value);
if (query === '') {
return;
}