Skip to content

Commit

Permalink
🎁 🧹 add missing file and format with semicolons
Browse files Browse the repository at this point in the history
The previous build revealed that admin_color_select.js was missing. It also complained about missing semicolons.
  • Loading branch information
ShanaLMoore committed Sep 25, 2023
1 parent 1899175 commit 2ac4625
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 25 deletions.
20 changes: 20 additions & 0 deletions app/assets/javascripts/admin_color_select.js
Original file line number Diff line number Diff line change
@@ -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"));
});
});
});
54 changes: 29 additions & 25 deletions app/assets/javascripts/admin_font_select.js
Original file line number Diff line number Diff line change
@@ -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);
});
});

0 comments on commit 2ac4625

Please sign in to comment.