From d1301b74e2197c0ec491ab614bd34585ff1eb887 Mon Sep 17 00:00:00 2001 From: Euan Kemp Date: Fri, 18 Sep 2020 20:00:15 -0700 Subject: [PATCH 1/6] decaffeinate the coffeescript This commit is the result of just running https://decaffeinate-project.org/ and making no additional changes. --- app/assets/javascripts/_initialization.coffee | 29 ---- app/assets/javascripts/_initialization.js | 34 +++++ app/assets/javascripts/collaboration.coffee | 8 -- app/assets/javascripts/collaboration.js | 12 ++ app/assets/javascripts/document_editor.coffee | 117 --------------- app/assets/javascripts/document_editor.js | 135 ++++++++++++++++++ app/assets/javascripts/generators.js.coffee | 31 ---- app/assets/javascripts/generators.js.js | 46 ++++++ app/assets/javascripts/help.coffee | 3 - app/assets/javascripts/help.js | 3 + app/assets/javascripts/image_uploads.coffee | 6 - app/assets/javascripts/image_uploads.js | 10 ++ app/assets/javascripts/pickers.js.coffee | 4 - app/assets/javascripts/pickers.js.js | 9 ++ app/assets/javascripts/stripe.coffee | 36 ----- app/assets/javascripts/stripe.js | 44 ++++++ app/assets/javascripts/thredded_proxy.coffee | 3 - app/assets/javascripts/thredded_proxy.js | 3 + 18 files changed, 296 insertions(+), 237 deletions(-) delete mode 100644 app/assets/javascripts/_initialization.coffee create mode 100644 app/assets/javascripts/_initialization.js delete mode 100644 app/assets/javascripts/collaboration.coffee create mode 100644 app/assets/javascripts/collaboration.js delete mode 100644 app/assets/javascripts/document_editor.coffee create mode 100644 app/assets/javascripts/document_editor.js delete mode 100644 app/assets/javascripts/generators.js.coffee create mode 100644 app/assets/javascripts/generators.js.js delete mode 100644 app/assets/javascripts/help.coffee create mode 100644 app/assets/javascripts/help.js delete mode 100644 app/assets/javascripts/image_uploads.coffee create mode 100644 app/assets/javascripts/image_uploads.js delete mode 100644 app/assets/javascripts/pickers.js.coffee create mode 100644 app/assets/javascripts/pickers.js.js delete mode 100644 app/assets/javascripts/stripe.coffee create mode 100644 app/assets/javascripts/stripe.js delete mode 100644 app/assets/javascripts/thredded_proxy.coffee create mode 100644 app/assets/javascripts/thredded_proxy.js diff --git a/app/assets/javascripts/_initialization.coffee b/app/assets/javascripts/_initialization.coffee deleted file mode 100644 index 83da2147..00000000 --- a/app/assets/javascripts/_initialization.coffee +++ /dev/null @@ -1,29 +0,0 @@ -## This file is prepended with an underscore to ensure it comes alphabetically-first -## when application.js includes all JS files in the directory with require_tree. -## Here be dragons. - -window.Notebook ||= {} -Notebook.init = -> - # Initialize MaterializeCSS stuff - M.AutoInit() - $('.sidenav').sidenav() - $('.quick-reference-sidenav').sidenav { - closeOnClick: true, - edge: 'right', - draggable: false - } - $('#recent-edits-sidenav').sidenav { - closeOnClick: true, - edge: 'right', - draggable: false - } - $('.slider').slider { height: 200, indicators: false } - $('.dropdown-trigger').dropdown { coverTrigger: false } - $('.tooltipped').tooltip { enterDelay: 50 } - $('.with-character-counter').characterCounter(); - $('.materialboxed').materialbox(); - -# We're using $ -> here for document readiness, but if we ever use Turbolinks we'd want: -# $(document).on "turbolinks:load", -> -$ -> - Notebook.init() \ No newline at end of file diff --git a/app/assets/javascripts/_initialization.js b/app/assets/javascripts/_initialization.js new file mode 100644 index 00000000..fae41656 --- /dev/null +++ b/app/assets/javascripts/_initialization.js @@ -0,0 +1,34 @@ +/* + * decaffeinate suggestions: + * DS102: Remove unnecessary code created because of implicit returns + * Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md + */ +//# This file is prepended with an underscore to ensure it comes alphabetically-first +//# when application.js includes all JS files in the directory with require_tree. +//# Here be dragons. + +if (!window.Notebook) { window.Notebook = {}; } +Notebook.init = function() { + // Initialize MaterializeCSS stuff + M.AutoInit(); + $('.sidenav').sidenav(); + $('.quick-reference-sidenav').sidenav({ + closeOnClick: true, + edge: 'right', + draggable: false + }); + $('#recent-edits-sidenav').sidenav({ + closeOnClick: true, + edge: 'right', + draggable: false + }); + $('.slider').slider({ height: 200, indicators: false }); + $('.dropdown-trigger').dropdown({ coverTrigger: false }); + $('.tooltipped').tooltip({ enterDelay: 50 }); + $('.with-character-counter').characterCounter(); + return $('.materialboxed').materialbox(); +}; + +// We're using $ -> here for document readiness, but if we ever use Turbolinks we'd want: +// $(document).on "turbolinks:load", -> +$(() => Notebook.init()); \ No newline at end of file diff --git a/app/assets/javascripts/collaboration.coffee b/app/assets/javascripts/collaboration.coffee deleted file mode 100644 index fcec61f4..00000000 --- a/app/assets/javascripts/collaboration.coffee +++ /dev/null @@ -1,8 +0,0 @@ -$ -> - # When a user clicks to remove a collaborator, we should remove them from the list of collaborators after the remote request finishes - $('a.js-remove-contributor[data-remote]').on 'ajax:success', (e, data, status, xhr) -> - - # Remove the image from the UI - $(this).closest('.collection-item').fadeOut().remove() # todo use animate.css for something more fun - - return \ No newline at end of file diff --git a/app/assets/javascripts/collaboration.js b/app/assets/javascripts/collaboration.js new file mode 100644 index 00000000..615be883 --- /dev/null +++ b/app/assets/javascripts/collaboration.js @@ -0,0 +1,12 @@ +/* + * decaffeinate suggestions: + * DS102: Remove unnecessary code created because of implicit returns + * Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md + */ +$(() => // When a user clicks to remove a collaborator, we should remove them from the list of collaborators after the remote request finishes +$('a.js-remove-contributor[data-remote]').on('ajax:success', function(e, data, status, xhr) { + + // Remove the image from the UI + $(this).closest('.collection-item').fadeOut().remove(); // todo use animate.css for something more fun + +})); \ No newline at end of file diff --git a/app/assets/javascripts/document_editor.coffee b/app/assets/javascripts/document_editor.coffee deleted file mode 100644 index 2c9ac9f0..00000000 --- a/app/assets/javascripts/document_editor.coffee +++ /dev/null @@ -1,117 +0,0 @@ -class Notebook.DocumentEditor - constructor: (@el) -> - return unless @el.length > 0 - - window.editor = new MediumEditor('#editor', - targetBlank: true - autoLink: false - buttonLabels: 'fontawesome' - toolbar: buttons: [ - 'bold' - 'italic' - 'underline' - 'strikethrough' - { - name: 'h1' - action: 'append-h2' - aria: 'header type 1' - tagNames: [ 'h2' ] - contentDefault: 'H1' - classList: [ 'custom-class-h1' ] - attrs: 'data-custom-attr': 'attr-value-h1' - } - { - name: 'h2' - action: 'append-h3' - aria: 'header type 2' - tagNames: [ 'h3' ] - contentDefault: 'H2' - classList: [ 'custom-class-h2' ] - attrs: 'data-custom-attr': 'attr-value-h2' - } - { - name: 'h3' - action: 'append-h4' - aria: 'header type 3' - tagNames: [ 'h4' ] - contentDefault: 'H3' - classList: [ 'custom-class-h3' ] - attrs: 'data-custom-attr': 'attr-value-h3' - } - 'justifyLeft' - 'justifyCenter' - 'justifyRight' - 'justifyFull' - 'orderedlist' - 'unorderedlist' - 'quote' - 'anchor' - 'removeFormat' - ] - anchorPreview: hideDelay: 0 - placeholder: text: 'Write as little or as much as you want!' - paste: forcePlainText: false) - - # Autosave - autosave_event = null - last_autosave = null - - autosave = -> - if autosave_event == null - - console.log 'Queueing autosave' - $('.js-autosave-icon').addClass 'grey-text' - $('.js-autosave-icon').removeClass 'black-text' - $('.js-autosave-icon').removeClass 'red-text' - $('.js-autosave-status').text 'Saving changes...' - - autosave_event = setTimeout((-> - console.log 'Autosaving...' - $('.js-autosave-status').text 'Saving...' - autosave_event = null - - # Do the autosave - last_autosave = $.ajax( - type: 'PATCH' - url: $('#editor').data('save-url'), - data: document: - title: $('#document_title').val() - body: $('#editor').html() - ) - - last_autosave.fail (jqXHR, textStatus) -> - $('.js-autosave-status').text 'There was a problem saving! We will try to save again, but please make sure you back up any changes.' - $('.js-autosave-status').addClass 'red-text' - $('.js-autosave-status').removeClass 'grey-text' - $('.js-autosave-status').removeClass 'black-text' - return - - # Done! - $('.js-autosave-icon').addClass 'black-text' - $('.js-autosave-icon').removeClass 'grey-text' - $('.js-autosave-icon').removeClass 'red-text' - $('.js-autosave-status').text 'Saved!' - - return - ), 2500) - - else - console.log 'Waiting for existing autosave' - - return - - editor.subscribe 'editableInput', autosave - $('#document_title').on 'change', autosave - $('#document_title').on 'keydown', autosave - $('.js-autosave-status').on 'click', autosave - - # Allow entering `tab` into the editor - $(document).delegate '#editor', 'keydown', (e) -> - keyCode = e.keyCode or e.which - if keyCode == 9 - e.preventDefault() - - return - -$ -> - new Notebook.DocumentEditor $("body.documents.edit") \ No newline at end of file diff --git a/app/assets/javascripts/document_editor.js b/app/assets/javascripts/document_editor.js new file mode 100644 index 00000000..15300ad8 --- /dev/null +++ b/app/assets/javascripts/document_editor.js @@ -0,0 +1,135 @@ +/* + * decaffeinate suggestions: + * DS102: Remove unnecessary code created because of implicit returns + * Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md + */ +Notebook.DocumentEditor = class DocumentEditor { + constructor(el) { + this.el = el; + if (!(this.el.length > 0)) { return; } + + window.editor = new MediumEditor('#editor', { + targetBlank: true, + autoLink: false, + buttonLabels: 'fontawesome', + toolbar: { buttons: [ + 'bold', + 'italic', + 'underline', + 'strikethrough', + { + name: 'h1', + action: 'append-h2', + aria: 'header type 1', + tagNames: [ 'h2' ], + contentDefault: 'H1', + classList: [ 'custom-class-h1' ], + attrs: { 'data-custom-attr': 'attr-value-h1' + } + }, + { + name: 'h2', + action: 'append-h3', + aria: 'header type 2', + tagNames: [ 'h3' ], + contentDefault: 'H2', + classList: [ 'custom-class-h2' ], + attrs: { 'data-custom-attr': 'attr-value-h2' + } + }, + { + name: 'h3', + action: 'append-h4', + aria: 'header type 3', + tagNames: [ 'h4' ], + contentDefault: 'H3', + classList: [ 'custom-class-h3' ], + attrs: { 'data-custom-attr': 'attr-value-h3' + } + }, + 'justifyLeft', + 'justifyCenter', + 'justifyRight', + 'justifyFull', + 'orderedlist', + 'unorderedlist', + 'quote', + 'anchor', + 'removeFormat' + ] + }, + anchorPreview: { hideDelay: 0 + }, + placeholder: { text: 'Write as little or as much as you want!' + }, + paste: { forcePlainText: false + } + }); + + // Autosave + let autosave_event = null; + let last_autosave = null; + + const autosave = function() { + if (autosave_event === null) { + + console.log('Queueing autosave'); + $('.js-autosave-icon').addClass('grey-text'); + $('.js-autosave-icon').removeClass('black-text'); + $('.js-autosave-icon').removeClass('red-text'); + $('.js-autosave-status').text('Saving changes...'); + + autosave_event = setTimeout((function() { + console.log('Autosaving...'); + $('.js-autosave-status').text('Saving...'); + autosave_event = null; + + // Do the autosave + last_autosave = $.ajax({ + type: 'PATCH', + url: $('#editor').data('save-url'), + data: { document: { + title: $('#document_title').val(), + body: $('#editor').html() + } + } + }); + + last_autosave.fail(function(jqXHR, textStatus) { + $('.js-autosave-status').text('There was a problem saving! We will try to save again, but please make sure you back up any changes.'); + $('.js-autosave-status').addClass('red-text'); + $('.js-autosave-status').removeClass('grey-text'); + $('.js-autosave-status').removeClass('black-text'); + }); + + // Done! + $('.js-autosave-icon').addClass('black-text'); + $('.js-autosave-icon').removeClass('grey-text'); + $('.js-autosave-icon').removeClass('red-text'); + $('.js-autosave-status').text('Saved!'); + + }), 2500); + + } else { + console.log('Waiting for existing autosave'); + } + + }; + + editor.subscribe('editableInput', autosave); + $('#document_title').on('change', autosave); + $('#document_title').on('keydown', autosave); + $('.js-autosave-status').on('click', autosave); + + // Allow entering `tab` into the editor + $(document).delegate('#editor', 'keydown', function(e) { + const keyCode = e.keyCode || e.which; + if (keyCode === 9) { + e.preventDefault(); + } + + }); + } +}; + +$(() => new Notebook.DocumentEditor($("body.documents.edit"))); \ No newline at end of file diff --git a/app/assets/javascripts/generators.js.coffee b/app/assets/javascripts/generators.js.coffee deleted file mode 100644 index 94b745f3..00000000 --- a/app/assets/javascripts/generators.js.coffee +++ /dev/null @@ -1,31 +0,0 @@ -$(document).ready -> - - # Character name generator - $('.character_name_generator').click -> - target = $(this).closest('.row').find('input[type=text]') - $.ajax - dataType: 'text' - url: '/generate/character/name' - success: (data) -> - target.val data - 0 - - # Character age generator - $('.character_age_generator').click -> - target = $(this).closest('.row').find('input[type=text]') - $.ajax - dataType: 'text' - url: '/generate/character/age' - success: (data) -> - target.val data - 0 - - # Location name generator - $('.location_name_generator').click -> - target = $(this).closest('.row').find('input[type=text]') - $.ajax - dataType: 'text' - url: '/generate/location/name' - success: (data) -> - target.val data - 0 diff --git a/app/assets/javascripts/generators.js.js b/app/assets/javascripts/generators.js.js new file mode 100644 index 00000000..119214c8 --- /dev/null +++ b/app/assets/javascripts/generators.js.js @@ -0,0 +1,46 @@ +/* + * decaffeinate suggestions: + * DS102: Remove unnecessary code created because of implicit returns + * Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md + */ +$(document).ready(function() { + + // Character name generator + $('.character_name_generator').click(function() { + const target = $(this).closest('.row').find('input[type=text]'); + $.ajax({ + dataType: 'text', + url: '/generate/character/name', + success(data) { + return target.val(data); + } + }); + return 0; + }); + + // Character age generator + $('.character_age_generator').click(function() { + const target = $(this).closest('.row').find('input[type=text]'); + $.ajax({ + dataType: 'text', + url: '/generate/character/age', + success(data) { + return target.val(data); + } + }); + return 0; + }); + + // Location name generator + return $('.location_name_generator').click(function() { + const target = $(this).closest('.row').find('input[type=text]'); + $.ajax({ + dataType: 'text', + url: '/generate/location/name', + success(data) { + return target.val(data); + } + }); + return 0; + }); +}); diff --git a/app/assets/javascripts/help.coffee b/app/assets/javascripts/help.coffee deleted file mode 100644 index 24f83d18..00000000 --- a/app/assets/javascripts/help.coffee +++ /dev/null @@ -1,3 +0,0 @@ -# Place all the behaviors and hooks related to the matching controller here. -# All this logic will automatically be available in application.js. -# You can use CoffeeScript in this file: http://coffeescript.org/ diff --git a/app/assets/javascripts/help.js b/app/assets/javascripts/help.js new file mode 100644 index 00000000..4532725d --- /dev/null +++ b/app/assets/javascripts/help.js @@ -0,0 +1,3 @@ +// Place all the behaviors and hooks related to the matching controller here. +// All this logic will automatically be available in application.js. +// You can use CoffeeScript in this file: http://coffeescript.org/ diff --git a/app/assets/javascripts/image_uploads.coffee b/app/assets/javascripts/image_uploads.coffee deleted file mode 100644 index fb1db7e8..00000000 --- a/app/assets/javascripts/image_uploads.coffee +++ /dev/null @@ -1,6 +0,0 @@ -$ -> - # When a user clicks to delete an image, we should remove it from the list of images after the remote request finishes - $('a.js-remove-image[data-remote]').on 'ajax:success', (e, data, status, xhr) -> - # Remove the image from the UI - $(this).closest('.row').fadeOut().remove() # todo use animate.css for something more fun - return diff --git a/app/assets/javascripts/image_uploads.js b/app/assets/javascripts/image_uploads.js new file mode 100644 index 00000000..b68546fd --- /dev/null +++ b/app/assets/javascripts/image_uploads.js @@ -0,0 +1,10 @@ +/* + * decaffeinate suggestions: + * DS102: Remove unnecessary code created because of implicit returns + * Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md + */ +$(() => // When a user clicks to delete an image, we should remove it from the list of images after the remote request finishes +$('a.js-remove-image[data-remote]').on('ajax:success', function(e, data, status, xhr) { + // Remove the image from the UI + $(this).closest('.row').fadeOut().remove(); // todo use animate.css for something more fun +})); diff --git a/app/assets/javascripts/pickers.js.coffee b/app/assets/javascripts/pickers.js.coffee deleted file mode 100644 index 2268a4a5..00000000 --- a/app/assets/javascripts/pickers.js.coffee +++ /dev/null @@ -1,4 +0,0 @@ -$(document).ready -> - $('.dropdown-picker li a').click -> - val = $(this).text() - $(this).closest('.row').find('input[type=text]').val(val) diff --git a/app/assets/javascripts/pickers.js.js b/app/assets/javascripts/pickers.js.js new file mode 100644 index 00000000..be280ad7 --- /dev/null +++ b/app/assets/javascripts/pickers.js.js @@ -0,0 +1,9 @@ +/* + * decaffeinate suggestions: + * DS102: Remove unnecessary code created because of implicit returns + * Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md + */ +$(document).ready(() => $('.dropdown-picker li a').click(function() { + const val = $(this).text(); + return $(this).closest('.row').find('input[type=text]').val(val); +})); diff --git a/app/assets/javascripts/stripe.coffee b/app/assets/javascripts/stripe.coffee deleted file mode 100644 index c321be5b..00000000 --- a/app/assets/javascripts/stripe.coffee +++ /dev/null @@ -1,36 +0,0 @@ -class Notebook.StripeHandler - constructor: (@el) -> - return unless @el.length > 0 - - $form = $('#payment-form') - stripeResponseHandler = (status, response) -> - $form = $('#payment-form') - if response.error - # Show the errors on the form: - $form.find('.payment-errors').text response.error.message - $form.find('.submit').prop 'disabled', false - - else - # Insert the created token ID into the form so it gets submitted to the server: - token = response.id - $form.append $('').val(token) - - # Submit the form: - $form.get(0).submit() - - return - - $form.submit (event) -> - # Disable the submit button to prevent repeated clicks: - $form.find('.submit').prop 'disabled', true - - # Request a token from Stripe: - Stripe.card.createToken $form, stripeResponseHandler - - # Prevent the form from being submitted: - false - - return - -$ -> - new Notebook.StripeHandler $("body.subscriptions.information") \ No newline at end of file diff --git a/app/assets/javascripts/stripe.js b/app/assets/javascripts/stripe.js new file mode 100644 index 00000000..8f2556ff --- /dev/null +++ b/app/assets/javascripts/stripe.js @@ -0,0 +1,44 @@ +/* + * decaffeinate suggestions: + * DS102: Remove unnecessary code created because of implicit returns + * Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md + */ +Notebook.StripeHandler = class StripeHandler { + constructor(el) { + this.el = el; + if (!(this.el.length > 0)) { return; } + + let $form = $('#payment-form'); + const stripeResponseHandler = function(status, response) { + $form = $('#payment-form'); + if (response.error) { + // Show the errors on the form: + $form.find('.payment-errors').text(response.error.message); + $form.find('.submit').prop('disabled', false); + + } else { + // Insert the created token ID into the form so it gets submitted to the server: + const token = response.id; + $form.append($('').val(token)); + + // Submit the form: + $form.get(0).submit(); + } + + }; + + $form.submit(function(event) { + // Disable the submit button to prevent repeated clicks: + $form.find('.submit').prop('disabled', true); + + // Request a token from Stripe: + Stripe.card.createToken($form, stripeResponseHandler); + + // Prevent the form from being submitted: + return false; + }); + + } +}; + +$(() => new Notebook.StripeHandler($("body.subscriptions.information"))); \ No newline at end of file diff --git a/app/assets/javascripts/thredded_proxy.coffee b/app/assets/javascripts/thredded_proxy.coffee deleted file mode 100644 index 24f83d18..00000000 --- a/app/assets/javascripts/thredded_proxy.coffee +++ /dev/null @@ -1,3 +0,0 @@ -# Place all the behaviors and hooks related to the matching controller here. -# All this logic will automatically be available in application.js. -# You can use CoffeeScript in this file: http://coffeescript.org/ diff --git a/app/assets/javascripts/thredded_proxy.js b/app/assets/javascripts/thredded_proxy.js new file mode 100644 index 00000000..4532725d --- /dev/null +++ b/app/assets/javascripts/thredded_proxy.js @@ -0,0 +1,3 @@ +// Place all the behaviors and hooks related to the matching controller here. +// All this logic will automatically be available in application.js. +// You can use CoffeeScript in this file: http://coffeescript.org/ From 673a5d2e4489ff9db27c3eccaeeeaa2928bdf615 Mon Sep 17 00:00:00 2001 From: Euan Kemp Date: Fri, 18 Sep 2020 20:08:08 -0700 Subject: [PATCH 2/6] decaffeinate: fix + remove suggestions --- app/assets/javascripts/_initialization.js | 9 ++------- app/assets/javascripts/collaboration.js | 11 ++--------- app/assets/javascripts/document_editor.js | 9 +-------- app/assets/javascripts/generators.js.js | 13 ++++--------- app/assets/javascripts/image_uploads.js | 9 ++------- app/assets/javascripts/pickers.js.js | 7 +------ app/assets/javascripts/stripe.js | 7 +------ 7 files changed, 13 insertions(+), 52 deletions(-) diff --git a/app/assets/javascripts/_initialization.js b/app/assets/javascripts/_initialization.js index fae41656..b0c617aa 100644 --- a/app/assets/javascripts/_initialization.js +++ b/app/assets/javascripts/_initialization.js @@ -1,8 +1,3 @@ -/* - * decaffeinate suggestions: - * DS102: Remove unnecessary code created because of implicit returns - * Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md - */ //# This file is prepended with an underscore to ensure it comes alphabetically-first //# when application.js includes all JS files in the directory with require_tree. //# Here be dragons. @@ -26,9 +21,9 @@ Notebook.init = function() { $('.dropdown-trigger').dropdown({ coverTrigger: false }); $('.tooltipped').tooltip({ enterDelay: 50 }); $('.with-character-counter').characterCounter(); - return $('.materialboxed').materialbox(); + $('.materialboxed').materialbox(); }; // We're using $ -> here for document readiness, but if we ever use Turbolinks we'd want: // $(document).on "turbolinks:load", -> -$(() => Notebook.init()); \ No newline at end of file +$(() => Notebook.init()); diff --git a/app/assets/javascripts/collaboration.js b/app/assets/javascripts/collaboration.js index 615be883..8183bf3e 100644 --- a/app/assets/javascripts/collaboration.js +++ b/app/assets/javascripts/collaboration.js @@ -1,12 +1,5 @@ -/* - * decaffeinate suggestions: - * DS102: Remove unnecessary code created because of implicit returns - * Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md - */ -$(() => // When a user clicks to remove a collaborator, we should remove them from the list of collaborators after the remote request finishes +// When a user clicks to remove a collaborator, we should remove them from the list of collaborators after the remote request finishes $('a.js-remove-contributor[data-remote]').on('ajax:success', function(e, data, status, xhr) { - // Remove the image from the UI $(this).closest('.collection-item').fadeOut().remove(); // todo use animate.css for something more fun - -})); \ No newline at end of file +}); diff --git a/app/assets/javascripts/document_editor.js b/app/assets/javascripts/document_editor.js index 15300ad8..8e4e2a2b 100644 --- a/app/assets/javascripts/document_editor.js +++ b/app/assets/javascripts/document_editor.js @@ -1,8 +1,3 @@ -/* - * decaffeinate suggestions: - * DS102: Remove unnecessary code created because of implicit returns - * Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md - */ Notebook.DocumentEditor = class DocumentEditor { constructor(el) { this.el = el; @@ -113,7 +108,6 @@ Notebook.DocumentEditor = class DocumentEditor { } else { console.log('Waiting for existing autosave'); } - }; editor.subscribe('editableInput', autosave); @@ -127,9 +121,8 @@ Notebook.DocumentEditor = class DocumentEditor { if (keyCode === 9) { e.preventDefault(); } - }); } }; -$(() => new Notebook.DocumentEditor($("body.documents.edit"))); \ No newline at end of file +$(() => new Notebook.DocumentEditor($("body.documents.edit"))); diff --git a/app/assets/javascripts/generators.js.js b/app/assets/javascripts/generators.js.js index 119214c8..2fe9da4c 100644 --- a/app/assets/javascripts/generators.js.js +++ b/app/assets/javascripts/generators.js.js @@ -1,8 +1,3 @@ -/* - * decaffeinate suggestions: - * DS102: Remove unnecessary code created because of implicit returns - * Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md - */ $(document).ready(function() { // Character name generator @@ -12,7 +7,7 @@ $(document).ready(function() { dataType: 'text', url: '/generate/character/name', success(data) { - return target.val(data); + target.val(data); } }); return 0; @@ -25,20 +20,20 @@ $(document).ready(function() { dataType: 'text', url: '/generate/character/age', success(data) { - return target.val(data); + target.val(data); } }); return 0; }); // Location name generator - return $('.location_name_generator').click(function() { + $('.location_name_generator').click(function() { const target = $(this).closest('.row').find('input[type=text]'); $.ajax({ dataType: 'text', url: '/generate/location/name', success(data) { - return target.val(data); + target.val(data); } }); return 0; diff --git a/app/assets/javascripts/image_uploads.js b/app/assets/javascripts/image_uploads.js index b68546fd..7fb373f0 100644 --- a/app/assets/javascripts/image_uploads.js +++ b/app/assets/javascripts/image_uploads.js @@ -1,10 +1,5 @@ -/* - * decaffeinate suggestions: - * DS102: Remove unnecessary code created because of implicit returns - * Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md - */ -$(() => // When a user clicks to delete an image, we should remove it from the list of images after the remote request finishes +// When a user clicks to delete an image, we should remove it from the list of images after the remote request finishes $('a.js-remove-image[data-remote]').on('ajax:success', function(e, data, status, xhr) { // Remove the image from the UI $(this).closest('.row').fadeOut().remove(); // todo use animate.css for something more fun -})); +}); diff --git a/app/assets/javascripts/pickers.js.js b/app/assets/javascripts/pickers.js.js index be280ad7..d96602f1 100644 --- a/app/assets/javascripts/pickers.js.js +++ b/app/assets/javascripts/pickers.js.js @@ -1,9 +1,4 @@ -/* - * decaffeinate suggestions: - * DS102: Remove unnecessary code created because of implicit returns - * Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md - */ $(document).ready(() => $('.dropdown-picker li a').click(function() { const val = $(this).text(); - return $(this).closest('.row').find('input[type=text]').val(val); + $(this).closest('.row').find('input[type=text]').val(val); })); diff --git a/app/assets/javascripts/stripe.js b/app/assets/javascripts/stripe.js index 8f2556ff..ed844853 100644 --- a/app/assets/javascripts/stripe.js +++ b/app/assets/javascripts/stripe.js @@ -1,8 +1,3 @@ -/* - * decaffeinate suggestions: - * DS102: Remove unnecessary code created because of implicit returns - * Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md - */ Notebook.StripeHandler = class StripeHandler { constructor(el) { this.el = el; @@ -41,4 +36,4 @@ Notebook.StripeHandler = class StripeHandler { } }; -$(() => new Notebook.StripeHandler($("body.subscriptions.information"))); \ No newline at end of file +$(() => new Notebook.StripeHandler($("body.subscriptions.information"))); From ef480f22d2f38f0c388eba94e6b4aa60c4659f0e Mon Sep 17 00:00:00 2001 From: Euan Kemp Date: Fri, 18 Sep 2020 20:09:42 -0700 Subject: [PATCH 3/6] move .js.js files -> .js .js.coffee made more sense I guess; simplify down the extension to the expected one. --- app/assets/javascripts/{generators.js.js => generators.js} | 0 app/assets/javascripts/{pickers.js.js => pickers.js} | 0 2 files changed, 0 insertions(+), 0 deletions(-) rename app/assets/javascripts/{generators.js.js => generators.js} (100%) rename app/assets/javascripts/{pickers.js.js => pickers.js} (100%) diff --git a/app/assets/javascripts/generators.js.js b/app/assets/javascripts/generators.js similarity index 100% rename from app/assets/javascripts/generators.js.js rename to app/assets/javascripts/generators.js diff --git a/app/assets/javascripts/pickers.js.js b/app/assets/javascripts/pickers.js similarity index 100% rename from app/assets/javascripts/pickers.js.js rename to app/assets/javascripts/pickers.js From 56f49a2494a0434446e5fccba09223a536d9a5e4 Mon Sep 17 00:00:00 2001 From: Euan Kemp Date: Fri, 18 Sep 2020 20:18:29 -0700 Subject: [PATCH 4/6] Delete some stale js files These empty files haven't been used in years; might as well delete em --- app/assets/javascripts/help.js | 3 --- app/assets/javascripts/thredded_proxy.js | 3 --- 2 files changed, 6 deletions(-) delete mode 100644 app/assets/javascripts/help.js delete mode 100644 app/assets/javascripts/thredded_proxy.js diff --git a/app/assets/javascripts/help.js b/app/assets/javascripts/help.js deleted file mode 100644 index 4532725d..00000000 --- a/app/assets/javascripts/help.js +++ /dev/null @@ -1,3 +0,0 @@ -// Place all the behaviors and hooks related to the matching controller here. -// All this logic will automatically be available in application.js. -// You can use CoffeeScript in this file: http://coffeescript.org/ diff --git a/app/assets/javascripts/thredded_proxy.js b/app/assets/javascripts/thredded_proxy.js deleted file mode 100644 index 4532725d..00000000 --- a/app/assets/javascripts/thredded_proxy.js +++ /dev/null @@ -1,3 +0,0 @@ -// Place all the behaviors and hooks related to the matching controller here. -// All this logic will automatically be available in application.js. -// You can use CoffeeScript in this file: http://coffeescript.org/ From a48aa7945583d505bfda8c5dc4a9d0046418cc21 Mon Sep 17 00:00:00 2001 From: Euan Kemp Date: Fri, 18 Sep 2020 20:19:32 -0700 Subject: [PATCH 5/6] Remove stale comment --- app/assets/javascripts/_initialization.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/app/assets/javascripts/_initialization.js b/app/assets/javascripts/_initialization.js index b0c617aa..47bf8d7c 100644 --- a/app/assets/javascripts/_initialization.js +++ b/app/assets/javascripts/_initialization.js @@ -24,6 +24,4 @@ Notebook.init = function() { $('.materialboxed').materialbox(); }; -// We're using $ -> here for document readiness, but if we ever use Turbolinks we'd want: -// $(document).on "turbolinks:load", -> $(() => Notebook.init()); From 6314a052a050ab11f606938d67091338c90a4d00 Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Tue, 13 Oct 2020 21:27:23 +0000 Subject: [PATCH 6/6] Bump better_errors from 2.7.1 to 2.8.3 Bumps [better_errors](https://github.com/BetterErrors/better_errors) from 2.7.1 to 2.8.3. - [Release notes](https://github.com/BetterErrors/better_errors/releases) - [Commits](https://github.com/BetterErrors/better_errors/compare/v2.7.1...v2.8.3) Signed-off-by: dependabot-preview[bot] --- Gemfile.lock | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index 4b18c531..bbaa7460 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1013,7 +1013,7 @@ GEM multi_json (~> 1) statsd-ruby (~> 1.1) bcrypt (3.1.16) - better_errors (2.7.1) + better_errors (2.8.3) coderay (>= 1.0.0) erubi (>= 1.0.0) rack (>= 0.9.0) @@ -1041,7 +1041,7 @@ GEM cocoon (1.2.15) codeclimate-test-reporter (1.0.9) simplecov (<= 0.13) - coderay (1.1.2) + coderay (1.1.3) coffee-rails (5.0.0) coffee-script (>= 2.2.0) railties (>= 5.2.0)