forked from IT61/it61.info
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
971 additions
and
370 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
{ | ||
"env": { "browser": true }, | ||
"extends": ["airbnb"], | ||
"plugins": ["@typescript-eslint"], | ||
"parser": "@typescript-eslint/parser", | ||
"parserOptions": { "project": ["./tsconfig.json"] }, | ||
"rules": { | ||
"import/no-unresolved": 0, | ||
"react/jsx-filename-extension": [1, { "extensions": [".jsx", ".tsx"] }] | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,28 @@ | ||
import * as Turbolinks from 'turbolinks' | ||
import railsUjs from 'rails-ujs' | ||
import * as Turbolinks from 'turbolinks'; | ||
import railsUjs from '@rails/ujs'; | ||
|
||
import { ForeignLinkSwitcher } from './helpers/foreign-link-switcher' | ||
import { MdcInit } from './mdc/mdc-init' | ||
import { YandexInit } from './yandex/yandex-init' | ||
import { ForeignLinkSwitcher } from './helpers/foreign-link-switcher'; | ||
import { MdcInit } from './mdc/mdc-init'; | ||
import { YandexInit } from './yandex/yandex-init'; | ||
|
||
Turbolinks.start() | ||
railsUjs.start() | ||
Turbolinks.start(); | ||
railsUjs.start(); | ||
|
||
function init(): void { | ||
const foreignLinkCheckbox = document.getElementById('has_foreign_link') | ||
if (!!foreignLinkCheckbox) ForeignLinkSwitcher.init() | ||
MdcInit.init() | ||
YandexInit.init() | ||
const foreignLinkCheckbox = document.getElementById('has_foreign_link'); | ||
if (foreignLinkCheckbox) ForeignLinkSwitcher.init(); | ||
MdcInit.init(); | ||
YandexInit.init(); | ||
|
||
let uuid = null | ||
const uuidEl = document.getElementById('uuid') | ||
if (uuidEl) uuid = uuidEl.dataset.userId | ||
let uuid = null; | ||
const uuidEl = document.getElementById('uuid'); | ||
if (uuidEl) uuid = uuidEl.dataset.userId; | ||
if (typeof ga === 'function') { | ||
ga('set', '&uid', uuid) | ||
ga('set', 'location', location.href) | ||
ga('send', 'pageview') | ||
ga('set', '&uid', uuid); | ||
ga('set', 'location', location.href); | ||
ga('send', 'pageview'); | ||
} | ||
} | ||
|
||
document.addEventListener('turbolinks:load', init) | ||
init() | ||
document.addEventListener('turbolinks:load', init); | ||
init(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,40 +1,43 @@ | ||
export class ForeignLinkSwitcher { | ||
private static instance: ForeignLinkSwitcher | ||
private static initPage = location.href | ||
private static instance: ForeignLinkSwitcher; | ||
|
||
foreignLinkCheckbox = document.getElementById('has_foreign_link') as HTMLInputElement | ||
foreignLinkSwitchedEl = document.getElementById('event_foreign_link_box') as HTMLDivElement | ||
foreignLinkInput = document.getElementById('event_foreign_link') as HTMLInputElement | ||
private static initPage = location.href; | ||
|
||
foreignLinkCheckbox = document.getElementById('has_foreign_link') as HTMLInputElement; | ||
|
||
foreignLinkSwitchedEl = document.getElementById('event_foreign_link_box') as HTMLDivElement; | ||
|
||
foreignLinkInput = document.getElementById('event_foreign_link') as HTMLInputElement; | ||
|
||
static init() { | ||
if (!ForeignLinkSwitcher.instance || ForeignLinkSwitcher.initPage !== location.href) { | ||
ForeignLinkSwitcher.initPage = location.href | ||
ForeignLinkSwitcher.instance = new ForeignLinkSwitcher() | ||
ForeignLinkSwitcher.initPage = location.href; | ||
ForeignLinkSwitcher.instance = new ForeignLinkSwitcher(); | ||
document.addEventListener('turbolinks:request-start', (_: Event) => { | ||
ForeignLinkSwitcher.initPage = null | ||
}) | ||
ForeignLinkSwitcher.initPage = null; | ||
}); | ||
} | ||
return ForeignLinkSwitcher.instance | ||
return ForeignLinkSwitcher.instance; | ||
} | ||
|
||
private get isChecked(): boolean { | ||
return this.foreignLinkCheckbox.checked | ||
return this.foreignLinkCheckbox.checked; | ||
} | ||
|
||
private constructor() { | ||
if (this.isChecked) this.foreignLinkSwitchedEl.classList.remove('hidden') | ||
this.bindEvents() | ||
if (this.isChecked) this.foreignLinkSwitchedEl.classList.remove('hidden'); | ||
this.bindEvents(); | ||
} | ||
|
||
bindEvents() { | ||
this.foreignLinkCheckbox.addEventListener('change', (_: Event) => { | ||
this.foreignLinkSwitchedEl.classList.toggle('hidden') | ||
this.foreignLinkSwitchedEl.classList.toggle('hidden'); | ||
if (!this.isChecked) { | ||
this.foreignLinkInput.value = '' | ||
this.foreignLinkInput.setAttribute('disable', 'disabled') | ||
this.foreignLinkInput.value = ''; | ||
this.foreignLinkInput.setAttribute('disable', 'disabled'); | ||
} else { | ||
this.foreignLinkInput.removeAttribute('disabled') | ||
this.foreignLinkInput.removeAttribute('disabled'); | ||
} | ||
}) | ||
}); | ||
} | ||
} |
Oops, something went wrong.