Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mise à jour des dépendances front #6261

Merged
merged 4 commits into from
Mar 25, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
assets/js/editor-old.js
27 changes: 17 additions & 10 deletions Gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ const autoprefixer = require('autoprefixer')
const concat = require('gulp-concat')
const cssnano = require('cssnano')
const del = require('del')
const eslint = require('gulp-eslint')
const { ESLint } = require('eslint')
const gulp = require('gulp')
const gulpif = require('gulp-if')
const imagemin = require('gulp-imagemin')
Expand Down Expand Up @@ -94,20 +94,27 @@ function errors() {
/* JS tasks */

// ESLint options
var eslintOptions = {}
let eslintOptions = {}
const fix = options.has('fix')
if (fix) {
eslintOptions = { fix: true }
}

// Lints the JS source files

function jsLint() {
return gulp.src(['assets/js/*.js', 'Gulpfile.js', '!assets/js/editor-old.js'], { base: '.' })
.pipe(eslint(eslintOptions))
.pipe(eslint.format())
.pipe(gulp.dest('.'))
.pipe(eslint.failAfterError())
async function jsLint() {
const eslint = new ESLint(eslintOptions)

const results = await eslint.lintFiles(['assets/js/*.js', 'Gulpfile.js'])

if (fix) {
await ESLint.outputFixes(results)
}

const formatter = await eslint.loadFormatter('stylish')
const resultText = formatter.format(results)

console.log(resultText)
}

// Get JS minified files from packages
Expand Down Expand Up @@ -148,7 +155,7 @@ function js() {

// Optimizes the images
function images() {
var plugins = [
const plugins = [
imagemin.gifsicle(),
imagemin.mozjpeg(),
imagemin.optipng(),
Expand Down Expand Up @@ -202,7 +209,7 @@ function watch() {
}

// Build the front
var build = gulp.parallel(prepareZmd, prepareEasyMde, jsPackages, js, images, gulp.series(spriteCss, gulp.parallel(css, spriteImages)))
const build = gulp.parallel(prepareZmd, prepareEasyMde, jsPackages, js, images, gulp.series(spriteCss, gulp.parallel(css, spriteImages)))

exports.build = build
exports.watch = gulp.series(build, watch)
Expand Down
86 changes: 43 additions & 43 deletions assets/js/ajax-actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,23 +11,23 @@
* @param {string} dataAttribute
*/
$.fn.toggleText = function(dataAttribute) {
var textContainer = this.find('.a11y')
let textContainer = this.find('.a11y')
if (textContainer.length === 0) {
textContainer = this
} else {
textContainer = $(textContainer[0])
}

var text = textContainer.text()
var textToPut = this.data(dataAttribute)
const text = textContainer.text()
const textToPut = this.data(dataAttribute)

textContainer.text(textToPut)
this.data(dataAttribute, text)
}

function synchText() {
$('#mobile-menu [data-ajax-input]').each(function() {
var dataAjaxInput = $(this).data('ajax-input')
const dataAjaxInput = $(this).data('ajax-input')
$(this).text($('.sidebar').find("button[data-ajax-input='" + dataAjaxInput + "']").text())
})
}
Expand All @@ -36,24 +36,24 @@
* Follow a topic
*/
$('.sidebar, .flexpage-title-tool .actions').on('click', "[data-ajax-input='follow-topic']", function(e) {
var $act = $(this)
var $form = $(this).parents('form:first')
var $email = $(this).parents('li:first').next().find("[data-ajax-input='follow-topic-by-email']")
var $followText = $act.find('span#follow_text')
var $count = $form.find('span#subscriber_count')
var $plural = $act.find('span#subscriber_plural')
var $otherSubscriberCount = $($act.attr('data-raw-subscriber-count'))
const $act = $(this)
const $form = $(this).parents('form:first')
let $email = $(this).parents('li:first').next().find("[data-ajax-input='follow-topic-by-email']")
const $followText = $act.find('span#follow_text')
const $count = $form.find('span#subscriber_count')
const $plural = $act.find('span#subscriber_plural')
const $otherSubscriberCount = $($act.attr('data-raw-subscriber-count'))

if ($email.length === 0) {
$email = $(this).parents('.buttons-combined').find("[data-ajax-input='follow-topic-by-email']")
}

$email.prop('disabled', true)

var csrfmiddlewaretoken = $form.find('input[name=csrfmiddlewaretoken]').val()
var topic = $form.find('input[name=topic]').val()
var follow = $form.find('input[name=follow]').val()
var page = $form.find('input[name=page]').val()
const csrfmiddlewaretoken = $form.find('input[name=csrfmiddlewaretoken]').val()
const topic = $form.find('input[name=topic]').val()
const follow = $form.find('input[name=follow]').val()
const page = $form.find('input[name=page]').val()

$.ajax({
url: $form.attr('action'),
Expand Down Expand Up @@ -105,20 +105,20 @@
* Be notified by email
*/
$('.sidebar, .flexpage-title-tool .actions').on('click', "[data-ajax-input='follow-topic-by-email']", function(e) {
var $act = $(this)
var $follow = $(this).parents('li:first').prev().find("[data-ajax-input='follow-topic']")
var $form = $(this).parents('form:first')
const $act = $(this)
let $follow = $(this).parents('li:first').prev().find("[data-ajax-input='follow-topic']")
const $form = $(this).parents('form:first')

if ($follow.length === 0) {
$follow = $(this).parents('.buttons-combined').find("[data-ajax-input='follow-topic']")
}

$follow.prop('disabled', true)

var csrfmiddlewaretoken = $form.find('input[name=csrfmiddlewaretoken]').val()
var topic = $form.find('input[name=topic]').val()
var email = $form.find('input[name=email]').val()
var page = $form.find('input[name=page]').val()
const csrfmiddlewaretoken = $form.find('input[name=csrfmiddlewaretoken]').val()
const topic = $form.find('input[name=topic]').val()
const email = $form.find('input[name=email]').val()
const page = $form.find('input[name=page]').val()

$.ajax({
url: $form.attr('action'),
Expand Down Expand Up @@ -163,14 +163,14 @@
* Featured request
*/
$('.sidebar').on('click', "[data-ajax-input='request-featured']", function(e) {
var $act = $(this)
var $form = $(this).parents('form:first')
var $requestText = $act.find('#request_text')
var $count = $form.find('#featured_request_count')
var $plural = $act.find('#featured_request_plural')
const $act = $(this)
const $form = $(this).parents('form:first')
const $requestText = $act.find('#request_text')
const $count = $form.find('#featured_request_count')
const $plural = $act.find('#featured_request_plural')

var csrfmiddlewaretoken = $form.find('input[name=csrfmiddlewaretoken]').val()
var requestFeatured = $form.find('input[name=request_featured]').val()
const csrfmiddlewaretoken = $form.find('input[name=csrfmiddlewaretoken]').val()
const requestFeatured = $form.find('input[name=request_featured]').val()

$.ajax({
url: $form.attr('action'),
Expand Down Expand Up @@ -198,13 +198,13 @@
* Mark a topic solved
*/
$('.sidebar').on('click', "[data-ajax-input='solve-topic']", function(e) {
var $act = $(this)
var $form = $(this).parents('form:first')
const $act = $(this)
const $form = $(this).parents('form:first')

var csrfmiddlewaretoken = $form.find('input[name=csrfmiddlewaretoken]').val()
var topic = $form.find('input[name=topic]').val()
var solved = $form.find('input[name=solved]').val()
var page = $form.find('input[name=page]').val()
const csrfmiddlewaretoken = $form.find('input[name=csrfmiddlewaretoken]').val()
const topic = $form.find('input[name=topic]').val()
const solved = $form.find('input[name=solved]').val()
const page = $form.find('input[name=page]').val()

$.ajax({
url: $form.attr('action'),
Expand Down Expand Up @@ -239,8 +239,8 @@
* Mobile action
*/
$('#mobile-menu').on('click', '[data-ajax-input]', function(e) {
var dataAjaxInput = $(this).data('ajax-input')
var $button = $('.sidebar').find("button[data-ajax-input='" + dataAjaxInput + "']")
const dataAjaxInput = $(this).data('ajax-input')
const $button = $('.sidebar').find("button[data-ajax-input='" + dataAjaxInput + "']")

if ($button[0]) {
$(this).toggleText('content-on-click')
Expand All @@ -252,8 +252,8 @@
})

function getLineAt(string, index) {
var before = string.slice(0, index).split('\n').slice(-1)[0] || ''
var after = string.slice(index).split('\n')[0] || ''
const before = string.slice(0, index).split('\n').slice(-1)[0] || ''
const after = string.slice(index).split('\n')[0] || ''
return before + after
}

Expand All @@ -268,8 +268,8 @@
return
}

var before = editor.value.slice(0, editor.selectionStart)
var after = editor.value.slice(editor.selectionEnd)
const before = editor.value.slice(0, editor.selectionStart)
const after = editor.value.slice(editor.selectionEnd)
editor.value = before + '\n' + citation + '\n' + after
}

Expand Down Expand Up @@ -297,8 +297,8 @@
e.stopPropagation()
e.preventDefault()

var $act = $(this)
var editor = document.querySelector('.md-editor')
const $act = $(this)
const editor = document.querySelector('.md-editor')

$.ajax({
url: $act.attr('href'),
Expand Down
Loading