Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
mikekscholz authored Jan 9, 2020
1 parent 51e1508 commit bfa7fec
Show file tree
Hide file tree
Showing 2 changed files with 184 additions and 171 deletions.
348 changes: 177 additions & 171 deletions source/js/components/keyboard.js
Original file line number Diff line number Diff line change
@@ -1,171 +1,177 @@
TouchUI.prototype.components.keyboard = {

isActive: ko.observable(false),
config: {

default: {

display: {
'accept' : 'Save',
'bksp' : ' ',
'default': 'ABC',
'meta1' : '.?123',
'meta2' : '#+='
},

layout: 'custom',
customLayout: {
'default': [
'q w e r t y u i o p',
'a s d f g h j k l',
'{bksp} {s} z x c v b n m',
'{accept} {c} {left} {right} {meta1} {space}'
],
'shift': [
'Q W E R T Y U I O P',
'A S D F G H J K L',
'{bksp} {s} Z X C V B N M',
'{accept} {c} {left} {right} {meta1} {space}'
],
'meta1': [
'1 2 3 4 5 6 7 8 9 0',
'- / : ; ( ) \u20ac & @',
'{bksp} {meta2} . , ? ! \' "',
'{accept} {c} {left} {right} {default} {space}'
],
'meta2': [
'[ ] { } # % ^ * + =',
'_ \\ | ~ < > $ \u00a3 \u00a5',
'{bksp} {meta1} . , ? ! \' "',
'{accept} {c} {left} {right} {default} {space}'
]
}

},
terminal: {
display: {
'bksp' : ' ',
'accept' : 'Save',
'default': 'ABC',
'meta1' : '.?123',
'meta2' : '#+='
},

layout: 'custom',
customLayout: {
'default': [
'Q W E R T Y U I O P',
'A S D F G H J K L',
'{bksp} {s} Z X C V B N M',
'{accept} {c} {left} {right} {meta1} {space}'
],
'meta1': [
'1 2 3 4 5 6 7 8 9 0',
'- / : ; ( ) \u20ac & @',
'{bksp} {meta2} . , ? ! \' "',
'{accept} {c} {left} {right} {default} {space}'
],
'meta2': [
'[ ] { } # % ^ * + =',
'_ \\ | ~ < > $ \u00a3 \u00a5',
'{bksp} {meta1} . , ? ! \' "',
'{accept} {c} {left} {right} {default} {space}'
]
}

},
number: {
display: {
'bksp' : ' ',
'a' : 'Save',
'c' : 'Cancel'
},

layout: 'custom',
customLayout: {
'default' : [
'{bksp} 1 2 3 4 5 6 7 ',
'{accept} {c} {left} {right} 8 9 0 - , . '
]
},
}


},

init: function() {
var self = this;

// Add virtual keyboard
var obj = {
visible: self.components.keyboard.onShow,
beforeClose: self.components.keyboard.onClose
};

var notThis = ['[type="file"]','[type="checkbox"]','[type="radio"]'];
$(document).on("mousedown", 'input:not('+notThis+'), textarea', function(e) {
var $elm = $(e.target);

if(!self.components.keyboard.isActive()) {

if($elm.data("keyboard")) {
$elm.data("keyboard").close().destroy();
}

} else {

if(!self.settings.hasTouch) {

// Force iScroll to stop following the mouse (bug)
self.scroll.currentActive._end(e);
setTimeout(function() {
self.scroll.currentActive.scrollToElement($elm[0], 200, 0, -30);
}, 0);

}

// $elm already has a keyboard
if($elm.data("keyboard")) {
$elm.data('keyboard').reveal();
return;
}

if($elm.attr("type") === "number") {
$elm.keyboard($.extend(self.components.keyboard.config.number, obj));
} else if($elm.attr("id") === "terminal-command") {
$elm.keyboard($.extend(self.components.keyboard.config.terminal, obj));
} else {
$elm.keyboard($.extend(self.components.keyboard.config.default, obj));
}
}

});
},

onShow: function(event, keyboard, el) {
// Set the input cursor to the end of the input field
setTimeout(function() {
var prev = keyboard.$preview.get(0);
if (prev) {
prev.selectionStart = prev.selectionEnd = prev.value.length;
}
}, 10);

keyboard.$keyboard.find("button").on("mousedown", function(e) {
$(e.target).addClass("touch-focus");

if(typeof $(e.target).data("timeout") !== "function") {
clearTimeout($(e.target).data("timeout"));
}
var timeout = setTimeout(function() {
$(e.target).removeClass("touch-focus").data("timeout", "");
}, 600);
$(e.target).data("timeout", timeout);
});
},

onClose: function(event, keyboard, el) {
keyboard.$keyboard.find("button").off("mousedown");
}

}
TouchUI.prototype.components.keyboard = {

isActive: ko.observable(false),
config: {

default: {
usePreview : false,
autoAccept : true,

display: {
'accept' : 'Save',
'bksp' : ' ',
'default': 'ABC',
'meta1' : '.?123',
'meta2' : '#+='
},

layout: 'custom',
customLayout: {
'default': [
'q w e r t y u i o p',
'a s d f g h j k l',
'{bksp} {s} z x c v b n m',
'{accept} {c} {left} {right} {meta1} {space}'
],
'shift': [
'Q W E R T Y U I O P',
'A S D F G H J K L',
'{bksp} {s} Z X C V B N M',
'{accept} {c} {left} {right} {meta1} {space}'
],
'meta1': [
'1 2 3 4 5 6 7 8 9 0',
'- / : ; ( ) \u20ac & @',
'{bksp} {meta2} . , ? ! \' "',
'{accept} {c} {left} {right} {default} {space}'
],
'meta2': [
'[ ] { } # % ^ * + =',
'_ \\ | ~ < > $ \u00a3 \u00a5',
'{bksp} {meta1} . , ? ! \' "',
'{accept} {c} {left} {right} {default} {space}'
]
}

},
terminal: {
usePreview : false,
autoAccept : true,
display: {
'bksp' : ' ',
'accept' : 'Save',
'default': 'ABC',
'meta1' : '.?123',
'meta2' : '#+='
},

layout: 'custom',
customLayout: {
'default': [
'Q W E R T Y U I O P',
'A S D F G H J K L',
'{bksp} {s} Z X C V B N M',
'{accept} {c} {left} {right} {meta1} {space}'
],
'meta1': [
'1 2 3 4 5 6 7 8 9 0',
'- / : ; ( ) \u20ac & @',
'{bksp} {meta2} . , ? ! \' "',
'{accept} {c} {left} {right} {default} {space}'
],
'meta2': [
'[ ] { } # % ^ * + =',
'_ \\ | ~ < > $ \u00a3 \u00a5',
'{bksp} {meta1} . , ? ! \' "',
'{accept} {c} {left} {right} {default} {space}'
]
}

},
number: {
usePreview : false,
autoAccept : true,
display: {
'bksp' : ' ',
'a' : 'Save',
'c' : 'Cancel'
},

layout: 'custom',
customLayout: {
'default' : [
'{bksp} 1 2 3 4 5 6 7 ',
'{accept} {c} {left} {right} 8 9 0 - , . '
]
},
}


},

init: function() {
var self = this;

// Add virtual keyboard
var obj = {
visible: self.components.keyboard.onShow,
beforeClose: self.components.keyboard.onClose
};

var notThis = ['[type="file"]','[type="checkbox"]','[type="radio"]'];
$(document).on("mousedown", 'input:not('+notThis+'), textarea', function(e) {
var $elm = $(e.target);

if(!self.components.keyboard.isActive()) {

if($elm.data("keyboard")) {
$elm.data("keyboard").close().destroy();
}

} else {

if(!self.settings.hasTouch) {

// Force iScroll to stop following the mouse (bug)
self.scroll.currentActive._end(e);
setTimeout(function() {
self.scroll.currentActive.scrollToElement($elm[0], 200, 0, -30);
}, 0);

}

// $elm already has a keyboard
if($elm.data("keyboard")) {
$elm.data('keyboard').reveal();
return;
}

if($elm.attr("type") === "number") {
$elm.keyboard($.extend(self.components.keyboard.config.number, obj));
} else if($elm.attr("id") === "terminal-command") {
$elm.keyboard($.extend(self.components.keyboard.config.terminal, obj));
} else {
$elm.keyboard($.extend(self.components.keyboard.config.default, obj));
}
}

});
},

onShow: function(event, keyboard, el) {
// Set the input cursor to the end of the input field
setTimeout(function() {
var prev = keyboard.$preview.get(0);
if (prev) {
prev.selectionStart = prev.selectionEnd = prev.value.length;
}
}, 10);

keyboard.$keyboard.find("button").on("mousedown", function(e) {
$(e.target).addClass("touch-focus");

if(typeof $(e.target).data("timeout") !== "function") {
clearTimeout($(e.target).data("timeout"));
}
var timeout = setTimeout(function() {
$(e.target).removeClass("touch-focus").data("timeout", "");
}, 600);
$(e.target).data("timeout", timeout);
});
},

onClose: function(event, keyboard, el) {
keyboard.$keyboard.find("button").off("mousedown");
}

}
7 changes: 7 additions & 0 deletions source/less/layout/tabbar.less
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,13 @@
}
}

#tab_plugin_bedlevelvisualizer_link,
#tab_plugin_bedlevelvisualizer_link2 {
a:before {
content: "\f21d";
}
}

#tab_plugin_astroprint_link,
#tab_plugin_astroprint_link2 {
a:before {
Expand Down

0 comments on commit bfa7fec

Please sign in to comment.