Skip to content

Commit

Permalink
Refactor JS. (Follow eslint)
Browse files Browse the repository at this point in the history
  • Loading branch information
akiko-pusu committed Jul 4, 2020
1 parent 14f03fb commit 8a80c43
Showing 1 changed file with 11 additions and 13 deletions.
24 changes: 11 additions & 13 deletions assets/javascripts/issue_templates.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,10 @@
*
* Use '==' operator to evaluate null or undefined.
*/

// For namespace setting.
// var ISSUE_TEMPLATE = ISSUE_TEMPLATE || function () {}
/* global CKEDITOR, Element, Event */
'use strict'

function ISSUE_TEMPLATE(config) {
function ISSUE_TEMPLATE (config) {
this.pulldownUrl = config.pulldownUrl
this.loadUrl = config.loadUrl
this.confirmMsg = config.confirmMessage
Expand Down Expand Up @@ -41,7 +39,7 @@ ISSUE_TEMPLATE.prototype = {
},
openDialog: function (url, title) {
// Open dialog (modal window) to display selectable templates list.
fetch(url)
window.fetch(url)
.then((response) => {
return response.text()
})
Expand Down Expand Up @@ -95,7 +93,7 @@ ISSUE_TEMPLATE.prototype = {
templateType = 'global'
}

fetch(ns.loadUrl,
window.fetch(ns.loadUrl,
{
method: 'POST',
credentials: 'same-origin',
Expand Down Expand Up @@ -264,7 +262,7 @@ ISSUE_TEMPLATE.prototype = {
params.issue_project_id = pullDownProject.value
}

fetch(ns.pulldownUrl,
window.fetch(ns.pulldownUrl,
{
method: 'POST',
credentials: 'same-origin',
Expand Down Expand Up @@ -529,7 +527,7 @@ document.onreadystatechange = () => {
if (orphanedTemplateLink) {
orphanedTemplateLink.addEventListener('click', (event) => {
const url = orphanedTemplateLink.getAttribute('data-url')
fetch(url)
window.fetch(url)
.then((response) => {
return response.text()
})
Expand Down Expand Up @@ -561,7 +559,7 @@ document.onreadystatechange = () => {

// ------- fot NoteTemplate

function NOTE_TEMPLATE(config) {
function NOTE_TEMPLATE (config) {
this.baseElementId = config.baseElementId
this.baseTemplateListUrl = config.baseTemplateListUrl
this.baseTrackerId = config.baseTrackerId
Expand Down Expand Up @@ -608,8 +606,8 @@ NOTE_TEMPLATE.prototype = {
}

let token = document.querySelector('#issue-form input[name="authenticity_token"]')
let req = new XMLHttpRequest()
req.onreadystatechange = function() {
let req = new window.XMLHttpRequest()
req.onreadystatechange = function () {
let container = targetElement.closest('div.overlay')
let target = container.id.replace('template_', '')
target = target.replace('_dialog', '')
Expand Down Expand Up @@ -641,8 +639,8 @@ NOTE_TEMPLATE.prototype = {
templateListUrl += '?tracker_id=' + ns.baseTrackerId + '&project_id=' + ns.baseProjectId
}

let req = new XMLHttpRequest();
req.onreadystatechange = function() {
let req = new window.XMLHttpRequest()
req.onreadystatechange = function () {
if (req.readyState === 4) {
if (req.status === 200 || req.status === 304) {
let value = req.responseText
Expand Down

0 comments on commit 8a80c43

Please sign in to comment.