Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions _locales/en/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@
"options_hotkeys_link": {
"message": "Edit shortcut keys"
},
"options_css_link": {
"message": "Edit custom CSS"
},
"options_save_button": {
"message": "Save"
},
Expand Down
3 changes: 2 additions & 1 deletion css/options.css
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,8 @@ input[type=checkbox], input[type=radio] {
display: none;
}

#hotkeys-link {
#hotkeys-link,
#css-link {
color: gray;
cursor: pointer;
text-decoration: underline;
Expand Down
45 changes: 45 additions & 0 deletions custom-css.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" type="text/css" href="css/common.css">
<link rel="stylesheet" type="text/css" href="css/bootstrap.min.css">
<style>
.card {
margin-top: 30px;
}
.card-body {
padding-bottom: .25rem;
}
#custom-css-code {
height: 20em;
}
</style>

<script src="js/jquery-3.1.1.min.js"></script>
<script src="js/bootstrap.min.js"></script>
<script src="js/defaults.js"></script>
<script src="js/custom-css.js"></script>
</head>
<body>
<div class="container">
<h2>Edit Custom CSS</h2>

<div class="card">
<div class="card-header">
Custom CSS in popup
</div>
<div class="card-body">
<form>
<div class="form-group">
<textarea class="form-control" id="custom-css-code" placeholder="Custom CSS code"></textarea>
</div>
<div class="form-group">
<button type="button" class="btn btn-primary" id="css-save-button">Save</button>
</div>
</form>
</div>
</div>

</div>
</body>
</html>
20 changes: 20 additions & 0 deletions js/custom-css.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@

$(function() {
getSettings(["customCss"])
.then(function(items) {
let css = items.customCss || ''
const $element = $("#custom-css-code")
function update () {
$("#css-save-button").get(0).disabled = $element.val() === css;
}
$("#css-save-button").click(function () {
updateSettings({ customCss: (css = $element.val()) });
update();
});
$element.val(css);
$element.keyup(function () {
update();
});
update();
})
})
5 changes: 5 additions & 0 deletions js/options.js
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,11 @@ function initialize(allVoices, settings) {
$("#hotkeys-link").click(function() {
brapi.tabs.create({url: getHotkeySettingsUrl()});
});

//edit css link
$("#css-link").click(function() {
brapi.tabs.create({url: 'custom-css.html'});
});
}


Expand Down
9 changes: 9 additions & 0 deletions js/popup.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ $(function() {

refreshSize();
checkAnnouncements();
applyCustomCSS();
});

function handleError(err) {
Expand Down Expand Up @@ -247,3 +248,11 @@ function showAnnouncement(ann) {
updateSettings({announcement: ann});
})
}

function applyCustomCSS() {
getSettings(["customCss"])
.then(function(items) {
let css = items.customCss || ''
$("#custom-css").text(css)
})
}
2 changes: 2 additions & 0 deletions options.html
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ <h2 data-i18n="options_heading"></h2>

<div class="form-group">
<span id="hotkeys-link" data-i18n="options_hotkeys_link"></span>
&middot;
<span id="css-link" data-i18n="options_css_link"></span>
</div>

<div class="layout">
Expand Down
1 change: 1 addition & 0 deletions popup.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
<script src="js/jquery-3.1.1.min.js"></script>
<script src="js/defaults.js"></script>
<script src="js/popup.js"></script>
<style id="custom-css"></style>
</head>
<body>
<div id="status">
Expand Down