refactoring of javascripts
This commit is contained in:
parent
a6a30078bb
commit
7d81521c8c
|
@ -1,17 +1,19 @@
|
||||||
const App = function (components) {
|
class App {
|
||||||
this.components = components || []
|
constructor(components) {
|
||||||
}
|
this.components = components || []
|
||||||
|
}
|
||||||
|
|
||||||
App.prototype.add = function (c) {
|
add(c) {
|
||||||
this.components.push(c)
|
this.components.push(c)
|
||||||
|
|
||||||
return this
|
return this
|
||||||
}
|
}
|
||||||
|
|
||||||
App.prototype.init = function () {
|
init() {
|
||||||
for (let u = 0, x = this.components.length; u < x; u++) {
|
for (let u = 0, x = this.components.length; u < x; u++) {
|
||||||
this.components[u].init()
|
this.components[u].init()
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = App
|
module.exports = App
|
||||||
|
|
|
@ -23,76 +23,78 @@ require('prismjs/plugins/keep-markup/prism-keep-markup')
|
||||||
require('prismjs/plugins/line-highlight/prism-line-highlight')
|
require('prismjs/plugins/line-highlight/prism-line-highlight')
|
||||||
require('prismjs/plugins/line-numbers/prism-line-numbers')
|
require('prismjs/plugins/line-numbers/prism-line-numbers')
|
||||||
|
|
||||||
const Code = function (w) {
|
class Code {
|
||||||
this.window = w
|
constructor(w) {
|
||||||
|
this.window = w
|
||||||
|
}
|
||||||
|
|
||||||
|
init() {
|
||||||
|
Prism.highlightAllUnder(document)
|
||||||
|
let elements = this.window.document.querySelectorAll('code[data-title], div[data-title]')
|
||||||
|
|
||||||
|
for (let i = 0, len = elements.length; i < len; i++) {
|
||||||
|
const element = elements[i]
|
||||||
|
|
||||||
|
if (element.tagName === 'CODE') {
|
||||||
|
var code = element
|
||||||
|
var pre = code.parentNode
|
||||||
|
var post = pre.parentNode
|
||||||
|
} else {
|
||||||
|
var code = element.querySelector('code')
|
||||||
|
|
||||||
|
if (!code) {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
var pre = code.parentNode
|
||||||
|
var post = pre.parentNode
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!pre || !post) {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
pre.classList.add('with-title')
|
||||||
|
|
||||||
|
const title = this.window.document.createElement('div')
|
||||||
|
title.classList.add('code-title')
|
||||||
|
title.textContent = element.getAttribute('data-title')
|
||||||
|
|
||||||
|
post.insertBefore(title, pre)
|
||||||
|
}
|
||||||
|
|
||||||
|
elements = this.window.document.querySelectorAll('code.window')
|
||||||
|
|
||||||
|
for (let i = 0, len = elements.length; i < len; i++) {
|
||||||
|
const element = elements[i]
|
||||||
|
|
||||||
|
if (element.tagName === 'CODE') {
|
||||||
|
var code = element
|
||||||
|
var pre = code.parentNode
|
||||||
|
var post = pre.parentNode
|
||||||
|
} else {
|
||||||
|
var code = element.querySelector('code')
|
||||||
|
|
||||||
|
if (!code) {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
var pre = code.parentNode
|
||||||
|
var post = pre.parentNode
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!pre || !post) {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
pre.classList.add('with-title')
|
||||||
|
const win = this.window.document.createElement('div')
|
||||||
|
win.classList.add('code-window')
|
||||||
|
win.textContent = 'Console'
|
||||||
|
|
||||||
|
post.insertBefore(win, pre)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Code.prototype.init = function () {
|
module.exports = Code
|
||||||
Prism.highlightAllUnder(document)
|
|
||||||
let elements = this.window.document.querySelectorAll('code[data-title], div[data-title]')
|
|
||||||
|
|
||||||
for (let i = 0, len = elements.length; i < len; i++) {
|
|
||||||
const element = elements[i]
|
|
||||||
|
|
||||||
if (element.tagName === 'CODE') {
|
|
||||||
var code = element
|
|
||||||
var pre = code.parentNode
|
|
||||||
var post = pre.parentNode
|
|
||||||
} else {
|
|
||||||
var code = element.querySelector('code')
|
|
||||||
|
|
||||||
if (!code) {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
|
|
||||||
var pre = code.parentNode
|
|
||||||
var post = pre.parentNode
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!pre || !post) {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
|
|
||||||
pre.classList.add('with-title')
|
|
||||||
|
|
||||||
const title = this.window.document.createElement('div')
|
|
||||||
title.classList.add('code-title')
|
|
||||||
title.textContent = element.getAttribute('data-title')
|
|
||||||
|
|
||||||
post.insertBefore(title, pre)
|
|
||||||
}
|
|
||||||
|
|
||||||
elements = this.window.document.querySelectorAll('code.window')
|
|
||||||
|
|
||||||
for (let i = 0, len = elements.length; i < len; i++) {
|
|
||||||
const element = elements[i]
|
|
||||||
|
|
||||||
if (element.tagName === 'CODE') {
|
|
||||||
var code = element
|
|
||||||
var pre = code.parentNode
|
|
||||||
var post = pre.parentNode
|
|
||||||
} else {
|
|
||||||
var code = element.querySelector('code')
|
|
||||||
|
|
||||||
if (!code) {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
|
|
||||||
var pre = code.parentNode
|
|
||||||
var post = pre.parentNode
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!pre || !post) {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
|
|
||||||
pre.classList.add('with-title')
|
|
||||||
const win = this.window.document.createElement('div')
|
|
||||||
win.classList.add('code-window')
|
|
||||||
win.textContent = 'Console'
|
|
||||||
|
|
||||||
post.insertBefore(win, pre)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
module.exports = Code
|
|
|
@ -1,30 +1,32 @@
|
||||||
const Routing = require('./routing')
|
const Routing = require('./routing')
|
||||||
|
|
||||||
const FormPnw = function (w) {
|
class FormPnw {
|
||||||
this.window = w
|
constructor(w) {
|
||||||
}
|
this.window = w
|
||||||
|
}
|
||||||
FormPnw.prototype.init = function () {
|
|
||||||
const doc = this.window.document
|
init() {
|
||||||
|
const doc = this.window.document
|
||||||
doc.addEventListener('mousemove', function () {
|
|
||||||
const forms = doc.querySelectorAll('form[data-form-bot]')
|
doc.addEventListener('mousemove', function() {
|
||||||
|
const forms = doc.querySelectorAll('form[data-form-bot]')
|
||||||
for (let i = 0, len = forms.length; i < len; i++) {
|
|
||||||
const form = forms[i]
|
for (let i = 0, len = forms.length; i < len; i++) {
|
||||||
let action = form.getAttribute('action')
|
const form = forms[i]
|
||||||
action = action.replace(
|
let action = form.getAttribute('action')
|
||||||
Routing.generate('blog_tech_form_without_javascript', {
|
action = action.replace(
|
||||||
_domain: window.location.hostname
|
Routing.generate('blog_tech_form_without_javascript', {
|
||||||
}, false) + '?page=', ''
|
_domain: window.location.hostname
|
||||||
)
|
}, false) + '?page=', ''
|
||||||
|
)
|
||||||
action = decodeURIComponent(action)
|
|
||||||
|
action = decodeURIComponent(action)
|
||||||
form.setAttribute('action', action)
|
|
||||||
form.removeAttribute('data-form-bot')
|
form.setAttribute('action', action)
|
||||||
|
form.removeAttribute('data-form-bot')
|
||||||
|
}
|
||||||
|
})
|
||||||
}
|
}
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = FormPnw
|
module.exports = FormPnw
|
||||||
|
|
|
@ -1,34 +1,36 @@
|
||||||
const Mario = require('../../images/mario.gif')
|
const Mario = require('../../images/mario.gif')
|
||||||
|
|
||||||
const Knmc = function (w) {
|
class Knmc {
|
||||||
this.window = w
|
constructor(w) {
|
||||||
}
|
this.window = w
|
||||||
|
}
|
||||||
Knmc.prototype.init = function () {
|
|
||||||
let chars = ''
|
init() {
|
||||||
const seq = '38384040373937396665'
|
let chars = ''
|
||||||
const body = this.window.document.querySelector('body')
|
const seq = '38384040373937396665'
|
||||||
|
const body = this.window.document.querySelector('body')
|
||||||
body.addEventListener('keyup', function (e) {
|
|
||||||
chars += e.keyCode.toString()
|
body.addEventListener('keyup', function(e) {
|
||||||
|
chars += e.keyCode.toString()
|
||||||
if (chars.indexOf(seq) !== -1) {
|
|
||||||
chars = ''
|
if (chars.indexOf(seq) !== -1) {
|
||||||
const url = Mario
|
chars = ''
|
||||||
const image = new Image()
|
const url = Mario
|
||||||
image.classList.add('fixed')
|
const image = new Image()
|
||||||
image.style.position = 'fixed'
|
image.classList.add('fixed')
|
||||||
image.style.bottom = '-11px'
|
image.style.position = 'fixed'
|
||||||
image.style.left = '-256px'
|
image.style.bottom = '-11px'
|
||||||
|
image.style.left = '-256px'
|
||||||
image.onload = function () {
|
|
||||||
image.classList.add('knmc')
|
image.onload = function() {
|
||||||
body.appendChild(image)
|
image.classList.add('knmc')
|
||||||
}
|
body.appendChild(image)
|
||||||
|
}
|
||||||
image.src = url
|
|
||||||
|
image.src = url
|
||||||
|
}
|
||||||
|
})
|
||||||
}
|
}
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = Knmc
|
module.exports = Knmc
|
||||||
|
|
|
@ -1,11 +1,10 @@
|
||||||
const lozad = require('lozad')
|
const lozad = require('lozad')
|
||||||
|
|
||||||
const LazyLoad = function () {
|
class LazyLoad {
|
||||||
}
|
init() {
|
||||||
|
const observer = lozad('.lazy-img')
|
||||||
LazyLoad.prototype.init = function () {
|
observer.observe()
|
||||||
const observer = lozad('.lazy-img')
|
}
|
||||||
observer.observe()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = LazyLoad
|
module.exports = LazyLoad
|
||||||
|
|
|
@ -1,34 +1,36 @@
|
||||||
const tingle = require('tingle.js/src/tingle.js')
|
const tingle = require('tingle.js/src/tingle.js')
|
||||||
|
|
||||||
const MeshViewer = function (w) {
|
class MeshViewer {
|
||||||
this.window = w
|
constructor(w) {
|
||||||
}
|
this.window = w
|
||||||
|
}
|
||||||
|
|
||||||
MeshViewer.prototype.init = function () {
|
init() {
|
||||||
const openers = this.window.document.querySelectorAll('*[data-modal]')
|
const openers = this.window.document.querySelectorAll('*[data-modal]')
|
||||||
|
|
||||||
for (let i = 0, len = openers.length; i < len; i++) {
|
for (let i = 0, len = openers.length; i < len; i++) {
|
||||||
openers[i].addEventListener('click', (e) => {
|
openers[i].addEventListener('click', (e) => {
|
||||||
e.preventDefault()
|
e.preventDefault()
|
||||||
|
|
||||||
let target = e.target
|
let target = e.target
|
||||||
|
|
||||||
if (target.tagName != 'A') {
|
if (target.tagName != 'A') {
|
||||||
target = target.parentNode
|
target = target.parentNode
|
||||||
}
|
}
|
||||||
|
|
||||||
const modal = new tingle.modal({
|
const modal = new tingle.modal({
|
||||||
footer: false,
|
footer: false,
|
||||||
stickyFooter: false,
|
stickyFooter: false,
|
||||||
closeMethods: ['overlay', 'button', 'escape'],
|
closeMethods: ['overlay', 'button', 'escape'],
|
||||||
closeLabel: 'Close',
|
closeLabel: 'Close',
|
||||||
cssClass: ['tingle-modal-box--mesh']
|
cssClass: ['tingle-modal-box--mesh']
|
||||||
})
|
})
|
||||||
|
|
||||||
modal.setContent('<iframe src="' + target.getAttribute('href') + '"></iframe>')
|
modal.setContent('<iframe src="' + target.getAttribute('href') + '"></iframe>')
|
||||||
modal.open()
|
modal.open()
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = MeshViewer
|
module.exports = MeshViewer
|
||||||
|
|
|
@ -1,46 +1,48 @@
|
||||||
require('particles.js')
|
require('particles.js')
|
||||||
|
|
||||||
const Particles = function (w) {
|
class Particles {
|
||||||
this.window = w
|
constructor(w) {
|
||||||
|
this.window = w
|
||||||
|
}
|
||||||
|
|
||||||
|
start() {
|
||||||
|
if (this.window.innerWidth < 708) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
const height = this.header.offsetHeight
|
||||||
|
const width = this.header.offsetWidth
|
||||||
|
let canvas
|
||||||
|
|
||||||
|
this.particles.style.maxHeight = height + 'px'
|
||||||
|
this.particles.style.maxWidth = width + 'px'
|
||||||
|
|
||||||
|
particlesJS.load('particles', '/js/particles.json?v=3')
|
||||||
|
}
|
||||||
|
|
||||||
|
clean() {
|
||||||
|
this.particles.innerHTML = ''
|
||||||
|
}
|
||||||
|
|
||||||
|
init() {
|
||||||
|
this.particles = this.window.document.getElementById('particles')
|
||||||
|
|
||||||
|
if (!this.particles) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
this.header = this.particles.parentNode
|
||||||
|
|
||||||
|
this.clean()
|
||||||
|
this.start()
|
||||||
|
|
||||||
|
const that = this
|
||||||
|
|
||||||
|
this.window.addEventListener('resize', function() {
|
||||||
|
that.clean()
|
||||||
|
that.start()
|
||||||
|
}, false)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Particles.prototype.start = function () {
|
module.exports = Particles
|
||||||
if (this.window.innerWidth < 708) {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
const height = this.header.offsetHeight
|
|
||||||
const width = this.header.offsetWidth
|
|
||||||
let canvas
|
|
||||||
|
|
||||||
this.particles.style.maxHeight = height + 'px'
|
|
||||||
this.particles.style.maxWidth = width + 'px'
|
|
||||||
|
|
||||||
particlesJS.load('particles', '/js/particles.json?v=3')
|
|
||||||
}
|
|
||||||
|
|
||||||
Particles.prototype.clean = function () {
|
|
||||||
this.particles.innerHTML = ''
|
|
||||||
}
|
|
||||||
|
|
||||||
Particles.prototype.init = function () {
|
|
||||||
this.particles = this.window.document.getElementById('particles')
|
|
||||||
|
|
||||||
if (!this.particles) {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
this.header = this.particles.parentNode
|
|
||||||
|
|
||||||
this.clean()
|
|
||||||
this.start()
|
|
||||||
|
|
||||||
const that = this
|
|
||||||
|
|
||||||
this.window.addEventListener('resize', function () {
|
|
||||||
that.clean()
|
|
||||||
that.start()
|
|
||||||
}, false)
|
|
||||||
}
|
|
||||||
|
|
||||||
module.exports = Particles
|
|
|
@ -1,120 +1,122 @@
|
||||||
const Routing = require('./routing')
|
const Routing = require('./routing')
|
||||||
|
|
||||||
const Post = function (w) {
|
class Post {
|
||||||
this.window = w
|
constructor(w) {
|
||||||
}
|
this.window = w
|
||||||
|
|
||||||
Post.prototype.commentsEvents = function () {
|
|
||||||
const document = this.window.document
|
|
||||||
|
|
||||||
const parentCommentIdField = document.getElementById('user_comment_parentCommentId')
|
|
||||||
|
|
||||||
if (!parentCommentIdField) {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
const isAnswerAlert = document.getElementById('answer-alert')
|
|
||||||
const cancelAnswerButton = document.getElementById('cancel-answer')
|
|
||||||
|
|
||||||
const toogleAnswerAlert = function () {
|
|
||||||
if (parentCommentIdField.value) {
|
|
||||||
isAnswerAlert.classList.remove('hidden')
|
|
||||||
} else {
|
|
||||||
isAnswerAlert.classList.add('hidden')
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
toogleAnswerAlert()
|
|
||||||
|
|
||||||
const answerButtons = document.querySelectorAll('a[data-answer]')
|
|
||||||
|
|
||||||
for (let i = 0, len = answerButtons.length; i < len; i++) {
|
|
||||||
answerButtons[i].addEventListener('click', function (e) {
|
|
||||||
parentCommentIdField.value = e.target.getAttribute('data-answer')
|
|
||||||
toogleAnswerAlert()
|
|
||||||
}, false)
|
|
||||||
}
|
|
||||||
|
|
||||||
cancelAnswerButton.addEventListener('click', function (e) {
|
|
||||||
e.preventDefault()
|
|
||||||
|
|
||||||
parentCommentIdField.value = null
|
|
||||||
toogleAnswerAlert()
|
|
||||||
}, false)
|
|
||||||
|
|
||||||
const previewButton = document.querySelector('.preview-button')
|
|
||||||
const previewRender = document.querySelector('#preview')
|
|
||||||
|
|
||||||
previewButton.addEventListener('click', function () {
|
|
||||||
if (previewRender.innerHTML === '') {
|
|
||||||
previewRender.innerHTML = '<p>Chargement en cours…</p>'
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const content = document.querySelector('#user_comment_content').value
|
commentsEvents() {
|
||||||
const httpRequest = new XMLHttpRequest()
|
const document = this.window.document
|
||||||
|
|
||||||
httpRequest.onreadystatechange = function (data) {
|
const parentCommentIdField = document.getElementById('user_comment_parentCommentId')
|
||||||
if (httpRequest.readyState === 4 && httpRequest.status === 200) {
|
|
||||||
const json = JSON.parse(httpRequest.response)
|
if (!parentCommentIdField) {
|
||||||
previewRender.innerHTML = json.render
|
return
|
||||||
document.location.href = '#preview'
|
}
|
||||||
}
|
|
||||||
|
const isAnswerAlert = document.getElementById('answer-alert')
|
||||||
|
const cancelAnswerButton = document.getElementById('cancel-answer')
|
||||||
|
|
||||||
|
const toogleAnswerAlert = function() {
|
||||||
|
if (parentCommentIdField.value) {
|
||||||
|
isAnswerAlert.classList.remove('hidden')
|
||||||
|
} else {
|
||||||
|
isAnswerAlert.classList.add('hidden')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
toogleAnswerAlert()
|
||||||
|
|
||||||
|
const answerButtons = document.querySelectorAll('a[data-answer]')
|
||||||
|
|
||||||
|
for (let i = 0, len = answerButtons.length; i < len; i++) {
|
||||||
|
answerButtons[i].addEventListener('click', function(e) {
|
||||||
|
parentCommentIdField.value = e.target.getAttribute('data-answer')
|
||||||
|
toogleAnswerAlert()
|
||||||
|
}, false)
|
||||||
|
}
|
||||||
|
|
||||||
|
cancelAnswerButton.addEventListener('click', function(e) {
|
||||||
|
e.preventDefault()
|
||||||
|
|
||||||
|
parentCommentIdField.value = null
|
||||||
|
toogleAnswerAlert()
|
||||||
|
}, false)
|
||||||
|
|
||||||
|
const previewButton = document.querySelector('.preview-button')
|
||||||
|
const previewRender = document.querySelector('#preview')
|
||||||
|
|
||||||
|
previewButton.addEventListener('click', function() {
|
||||||
|
if (previewRender.innerHTML === '') {
|
||||||
|
previewRender.innerHTML = '<p>Chargement en cours…</p>'
|
||||||
|
}
|
||||||
|
|
||||||
|
const content = document.querySelector('#user_comment_content').value
|
||||||
|
const httpRequest = new XMLHttpRequest()
|
||||||
|
|
||||||
|
httpRequest.onreadystatechange = function(data) {
|
||||||
|
if (httpRequest.readyState === 4 && httpRequest.status === 200) {
|
||||||
|
const json = JSON.parse(httpRequest.response)
|
||||||
|
previewRender.innerHTML = json.render
|
||||||
|
document.location.href = '#preview'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
httpRequest.open('POST', Routing.generate('api_blog_comment_preview'))
|
||||||
|
httpRequest.setRequestHeader(
|
||||||
|
'Content-Type',
|
||||||
|
'application/x-www-form-urlencoded'
|
||||||
|
)
|
||||||
|
httpRequest.send('content=' + encodeURIComponent(content))
|
||||||
|
}, false)
|
||||||
}
|
}
|
||||||
|
|
||||||
httpRequest.open('POST', Routing.generate('api_blog_comment_preview'))
|
imagesEvents() {
|
||||||
httpRequest.setRequestHeader(
|
const document = this.window.document
|
||||||
'Content-Type',
|
let isFullscreen = false
|
||||||
'application/x-www-form-urlencoded'
|
const images = document.querySelectorAll('.body img')
|
||||||
)
|
|
||||||
httpRequest.send('content=' + encodeURIComponent(content))
|
|
||||||
}, false)
|
|
||||||
}
|
|
||||||
|
|
||||||
Post.prototype.imagesEvents = function () {
|
const handleClick = function(image) {
|
||||||
const document = this.window.document
|
if (isFullscreen) {
|
||||||
let isFullscreen = false
|
if (document.exitFullscreen) {
|
||||||
const images = document.querySelectorAll('.body img')
|
document.exitFullscreen()
|
||||||
|
} else if (document.webkitExitFullscreen) {
|
||||||
|
document.webkitExitFullscreen()
|
||||||
|
} else if (document.mozCancelFullScreen) {
|
||||||
|
document.mozCancelFullScreen()
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (image.requestFullscreen) {
|
||||||
|
image.requestFullscreen()
|
||||||
|
} else if (image.webkitRequestFullscreen) {
|
||||||
|
image.webkitRequestFullscreen()
|
||||||
|
} else if (image.mozRequestFullScreen) {
|
||||||
|
image.mozRequestFullScreen()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const handleClick = function (image) {
|
isFullscreen = !isFullscreen
|
||||||
if (isFullscreen) {
|
}
|
||||||
if (document.exitFullscreen) {
|
|
||||||
document.exitFullscreen()
|
for (let i = 0, len = images.length; i < len; i++) {
|
||||||
} else if (document.webkitExitFullscreen) {
|
const image = images[i]
|
||||||
document.webkitExitFullscreen()
|
|
||||||
} else if (document.mozCancelFullScreen) {
|
if (image.parentNode.tagName === 'A') {
|
||||||
document.mozCancelFullScreen()
|
continue
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
if (image.requestFullscreen) {
|
(function(i) {
|
||||||
image.requestFullscreen()
|
i.addEventListener('click', function() {
|
||||||
} else if (image.webkitRequestFullscreen) {
|
handleClick(i)
|
||||||
image.webkitRequestFullscreen()
|
}, false)
|
||||||
} else if (image.mozRequestFullScreen) {
|
})(image)
|
||||||
image.mozRequestFullScreen()
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
isFullscreen = !isFullscreen
|
init() {
|
||||||
}
|
this.commentsEvents()
|
||||||
|
this.imagesEvents()
|
||||||
for (let i = 0, len = images.length; i < len; i++) {
|
|
||||||
const image = images[i]
|
|
||||||
|
|
||||||
if (image.parentNode.tagName === 'A') {
|
|
||||||
continue
|
|
||||||
}
|
}
|
||||||
|
|
||||||
(function (i) {
|
|
||||||
i.addEventListener('click', function () {
|
|
||||||
handleClick(i)
|
|
||||||
}, false)
|
|
||||||
})(image)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Post.prototype.init = function () {
|
|
||||||
this.commentsEvents()
|
|
||||||
this.imagesEvents()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = Post
|
module.exports = Post
|
||||||
|
|
|
@ -1,25 +1,27 @@
|
||||||
const QuickPost = function (w) {
|
class QuickPost {
|
||||||
this.window = w
|
constructor(w) {
|
||||||
}
|
this.window = w
|
||||||
|
}
|
||||||
|
|
||||||
QuickPost.prototype.init = function () {
|
init() {
|
||||||
const doc = this.window.document
|
const doc = this.window.document
|
||||||
|
|
||||||
const images = doc.querySelectorAll('.quick-image img')
|
const images = doc.querySelectorAll('.quick-image img')
|
||||||
|
|
||||||
for (let i = 0, len = images.length; i < len; i++) {
|
for (let i = 0, len = images.length; i < len; i++) {
|
||||||
(function (image) {
|
(function(image) {
|
||||||
const source = image.getAttribute('data-src')
|
const source = image.getAttribute('data-src')
|
||||||
const loader = new Image()
|
const loader = new Image()
|
||||||
|
|
||||||
loader.onload = function () {
|
loader.onload = function() {
|
||||||
image.style.backgroundImage = 'url(' + source + ')'
|
image.style.backgroundImage = 'url(' + source + ')'
|
||||||
image.style.backgroundSize = 'cover'
|
image.style.backgroundSize = 'cover'
|
||||||
}
|
}
|
||||||
|
|
||||||
loader.src = source
|
loader.src = source
|
||||||
})(images[i])
|
})(images[i])
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = QuickPost
|
module.exports = QuickPost
|
||||||
|
|
|
@ -1,22 +1,24 @@
|
||||||
const Routing = require('./routing')
|
const Routing = require('./routing')
|
||||||
|
|
||||||
const SmallMenu = function (w) {
|
class SmallMenu {
|
||||||
this.window = w
|
constructor(w) {
|
||||||
}
|
this.window = w
|
||||||
|
}
|
||||||
|
|
||||||
SmallMenu.prototype.addEvent = function () {
|
addEvent() {
|
||||||
const document = this.window.document
|
const document = this.window.document
|
||||||
const menu = document.querySelector('.small-menu')
|
const menu = document.querySelector('.small-menu')
|
||||||
const opener = document.querySelector('.menu-opener')
|
const opener = document.querySelector('.menu-opener')
|
||||||
|
|
||||||
opener.addEventListener('click', () => {
|
opener.addEventListener('click', () => {
|
||||||
menu.classList.toggle('is-open')
|
menu.classList.toggle('is-open')
|
||||||
opener.classList.toggle('is-open')
|
opener.classList.toggle('is-open')
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
SmallMenu.prototype.init = function () {
|
init() {
|
||||||
this.addEvent()
|
this.addEvent()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = SmallMenu
|
module.exports = SmallMenu
|
||||||
|
|
|
@ -1,38 +1,19 @@
|
||||||
const Stats = function () {
|
class Stats {
|
||||||
}
|
init() {
|
||||||
|
(function(f, a, t, h, o, m) {
|
||||||
Stats.prototype.init = function () {
|
a[h] = a[h] || function() {
|
||||||
(function (f, a, t, h, o, m) {
|
(a[h].q = a[h].q || []).push(arguments)
|
||||||
a[h] = a[h] || function () {
|
}
|
||||||
(a[h].q = a[h].q || []).push(arguments)
|
o = f.createElement('script'),
|
||||||
|
m = f.getElementsByTagName('script')[0]
|
||||||
|
o.async = 1;
|
||||||
|
o.src = t;
|
||||||
|
o.id = 'fathom-script'
|
||||||
|
m.parentNode.insertBefore(o, m)
|
||||||
|
})(document, window, '//ftm.deblan.org/tracker.js', 'fathom')
|
||||||
|
fathom('set', 'siteId', 'HQAWS')
|
||||||
|
fathom('trackPageview')
|
||||||
}
|
}
|
||||||
o = f.createElement('script'),
|
|
||||||
m = f.getElementsByTagName('script')[0]
|
|
||||||
o.async = 1; o.src = t; o.id = 'fathom-script'
|
|
||||||
m.parentNode.insertBefore(o, m)
|
|
||||||
})(document, window, '//ftm.deblan.org/tracker.js', 'fathom')
|
|
||||||
fathom('set', 'siteId', 'HQAWS')
|
|
||||||
fathom('trackPageview')
|
|
||||||
|
|
||||||
/*
|
|
||||||
var _paq = _paq || [];
|
|
||||||
_paq.push(['trackPageView']);
|
|
||||||
_paq.push(['enableLinkTracking']);
|
|
||||||
|
|
||||||
var u="//piwik.deblan.org/";
|
|
||||||
_paq.push(['setTrackerUrl', u+'piwik.php']);
|
|
||||||
_paq.push(['setSiteId', '1']);
|
|
||||||
|
|
||||||
var d= document;
|
|
||||||
var g= d.createElement('script');
|
|
||||||
var s= d.getElementsByTagName('script')[0];
|
|
||||||
|
|
||||||
g.type='text/javascript';
|
|
||||||
g.async=true;
|
|
||||||
g.defer=true;
|
|
||||||
g.src=u+'piwik.js';
|
|
||||||
s.parentNode.insertBefore(g,s);
|
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = Stats
|
module.exports = Stats
|
||||||
|
|
|
@ -1,13 +1,15 @@
|
||||||
const VideoRatio = function (w) {
|
class VideoRatio {
|
||||||
this.window = w
|
constructor(w) {
|
||||||
}
|
this.window = w
|
||||||
|
}
|
||||||
|
|
||||||
VideoRatio.prototype.init = function () {
|
init() {
|
||||||
const videos = this.window.document.querySelectorAll('.video-ratio')
|
const videos = this.window.document.querySelectorAll('.video-ratio')
|
||||||
|
|
||||||
for (let i = 0, len = videos.length; i < len; i++) {
|
for (let i = 0, len = videos.length; i < len; i++) {
|
||||||
videos[i].style.paddingBottom = videos[i].getAttribute('data-ratio')
|
videos[i].style.paddingBottom = videos[i].getAttribute('data-ratio')
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = VideoRatio
|
module.exports = VideoRatio
|
||||||
|
|
Loading…
Reference in a new issue