summaryrefslogtreecommitdiff
path: root/print/resources/inkstitch.js
diff options
context:
space:
mode:
authorLex Neva <github.com@lexneva.name>2018-04-13 21:23:00 -0400
committerLex Neva <github.com@lexneva.name>2018-04-15 19:46:22 -0400
commit85a8b6b1cfe008eed49c678bc0af9e2bea931f3c (patch)
treec227246a4c1186b9b6b9e69bd5d37430238422b1 /print/resources/inkstitch.js
parentd323059b9db610ac0dda23475729cde5f5c0a619 (diff)
inkstitch metadata framework
Diffstat (limited to 'print/resources/inkstitch.js')
-rw-r--r--print/resources/inkstitch.js31
1 files changed, 15 insertions, 16 deletions
diff --git a/print/resources/inkstitch.js b/print/resources/inkstitch.js
index 454c9ae2..ed26d367 100644
--- a/print/resources/inkstitch.js
+++ b/print/resources/inkstitch.js
@@ -40,19 +40,18 @@ $(function() {
setTimeout(ping, 1000);
setPageNumbers();
scaleInksimulation();
-
+
/* Contendeditable Fields */
-
+
// When we focus out from a contenteditable field, we want to
// set the same content to all fields with the same classname
- document.querySelectorAll('[contenteditable="true"]').forEach(function(elem) {
- elem.addEventListener('focusout', function() {
- var content = $(this).html();
- var field_name = $(this).attr('data-field-name');
- $('[data-field-name="' + field_name + '"]').html(content);
- });
+ $('[contenteditable="true"]').on('focusout', function() {
+ var content = $(this).html();
+ var field_name = $(this).attr('data-field-name');
+ $('[data-field-name="' + field_name + '"]').html(content);
+ $.post('/metadata/' + field_name + '/set', {value: content});
});
-
+
$('[contenteditable="true"]').keypress(function(e) {
if (e.which == 13) {
// pressing enter defocuses the element
@@ -64,10 +63,10 @@ $(function() {
return true;
}
});
-
-
+
+
/* Settings Bar */
-
+
$('button.close').click(function() {
$.post('/shutdown', {})
.done(function(data) {
@@ -92,20 +91,20 @@ $(function() {
$('#close-settings').click(function(){
$('#settings-ui').hide();
});
-
+
/* Settings */
-
+
// Paper Size
$('select#printing-size').change(function(){
$('.page').toggleClass('a4');
});
-
+
//Checkbox
$(':checkbox').change(function() {
$('.' + this.id).toggle();
setPageNumbers();
scaleInksimulation();
});
-
+
});