From 2ac46251a4b01b2fc6a11e628c0e7721757d6b79 Mon Sep 17 00:00:00 2001 From: Shana Moore Date: Mon, 25 Sep 2023 12:49:21 -0700 Subject: [PATCH] :gift: :broom: add missing file and format with semicolons The previous build revealed that admin_color_select.js was missing. It also complained about missing semicolons. --- app/assets/javascripts/admin_color_select.js | 20 ++++++++ app/assets/javascripts/admin_font_select.js | 54 +++++++++++--------- 2 files changed, 49 insertions(+), 25 deletions(-) create mode 100644 app/assets/javascripts/admin_color_select.js diff --git a/app/assets/javascripts/admin_color_select.js b/app/assets/javascripts/admin_color_select.js new file mode 100644 index 000000000..5bff8eb25 --- /dev/null +++ b/app/assets/javascripts/admin_color_select.js @@ -0,0 +1,20 @@ +$(document).on("turbolinks:load", function () { + $("div.defaultable-colors a.restore-default-color").click(function (e) { + e.preventDefault(); + + var defaultTarget = $(e.target).data("default-target"); + var input = $("input[name='admin_appearance[" + defaultTarget + "]']"); + + input.val(input.data("default-value")); + }); + + $(".panel-footer a.restore-all-default-colors").click(function (e) { + e.preventDefault(); + + var allColorInputs = $("input[name*='color']"); + + allColorInputs.each(function () { + $(this).val($(this).data("default-value")); + }); + }); +}); diff --git a/app/assets/javascripts/admin_font_select.js b/app/assets/javascripts/admin_font_select.js index e2c3e89cb..26abe89fa 100644 --- a/app/assets/javascripts/admin_font_select.js +++ b/app/assets/javascripts/admin_font_select.js @@ -1,34 +1,38 @@ -Blacklight.onLoad(function() { - if($("#admin_appearance_body_font").length > 0){ - $("#admin_appearance_body_font").fontselect({lookahead: 20}) - $("#admin_appearance_headline_font").fontselect({lookahead: 20}) +Blacklight.onLoad(function () { + if ($("#admin_appearance_body_font").length > 0) { + $("#admin_appearance_body_font").fontselect({ lookahead: 20 }); + $("#admin_appearance_headline_font").fontselect({ lookahead: 20 }); } }); -$('div.defaultable-fonts a.restore-default-font').click(function(e) { - e.preventDefault() - var defaultTarget = $(e.target).data('default-target') - var input = $("input[name='admin_appearance["+ defaultTarget +"]']") - var defaultValue = input.data('default-value').replace(';', '') - var inputDisplay = $("div[class$='"+ defaultTarget +"']").find('div.font-select span') +$("div.defaultable-fonts a.restore-default-font").click(function (e) { + e.preventDefault(); + var defaultTarget = $(e.target).data("default-target"); + var input = $("input[name='admin_appearance[" + defaultTarget + "]']"); + var defaultValue = input.data("default-value").replace(";", ""); + var inputDisplay = $("div[class$='" + defaultTarget + "']").find( + "div.font-select span" + ); - input.val(defaultValue) - inputDisplay.css("font-family", defaultValue) - inputDisplay.text(defaultValue) -}) + input.val(defaultValue); + inputDisplay.css("font-family", defaultValue); + inputDisplay.text(defaultValue); +}); -$('.panel-footer a.restore-all-default-fonts').click(function(e) { - e.preventDefault() +$(".panel-footer a.restore-all-default-fonts").click(function (e) { + e.preventDefault(); - var allFontInputs = $("input[name*='font']") + var allFontInputs = $("input[name*='font']"); - allFontInputs.each(function() { - var thisTarget = $(this).attr('id').replace('admin_appearance_', '') - var defaultValue = $(this).data('default-value').replace(';', '') - var inputDisplay = $("div[class$='"+ thisTarget +"']").find('div.font-select span') + allFontInputs.each(function () { + var thisTarget = $(this).attr("id").replace("admin_appearance_", ""); + var defaultValue = $(this).data("default-value").replace(";", ""); + var inputDisplay = $("div[class$='" + thisTarget + "']").find( + "div.font-select span" + ); - $(this).val(defaultValue) - inputDisplay.css("font-family", defaultValue) - inputDisplay.text(defaultValue) - }) + $(this).val(defaultValue); + inputDisplay.css("font-family", defaultValue); + inputDisplay.text(defaultValue); + }); });