diff --git a/source/js/components/keyboard.js b/source/js/components/keyboard.js index 49d7b102..64a134ee 100644 --- a/source/js/components/keyboard.js +++ b/source/js/components/keyboard.js @@ -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"); + } + +} diff --git a/source/less/layout/tabbar.less b/source/less/layout/tabbar.less index 261ddf7e..f8c1a9e0 100644 --- a/source/less/layout/tabbar.less +++ b/source/less/layout/tabbar.less @@ -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 {