Permalink
Browse files

added portuguese layout & updated demo

  • Loading branch information...
Mottie committed Jan 15, 2013
1 parent 8a47665 commit 84e9c1d827640b37c21f944e0f0d2737ef0b3bd9
Showing with 148 additions and 50 deletions.
  1. +55 −50 layouts.html
  2. +93 −0 layouts/portuguese.js
View
@@ -15,7 +15,7 @@
<!-- keyboard widget css & script (required) -->
<link href="css/keyboard.css" rel="stylesheet">
- <script src="js/jquery.keyboard.min.js"></script>
+ <script src="js/jquery.keyboard.js"></script>
<!-- keyboard extensions (optional) -->
<script src="js/jquery.mousewheel.js"></script>
@@ -75,16 +75,61 @@
$(function(){
- // Theme switcher
- // $('#switcher').themeswitcher();
-
- $('#lang').change(function(){
+ var layouts = [
+ "albanian-qwerty:Albanian (qwerty)",
+ "albanian-qwertz:Albanian (qwertz)",
+ "arabic-azerty:Arabic (azerty)",
+ "arabic-qwerty-1:Arabic (qwerty-1)",
+ "arabic-qwerty-2:Arabic (qwerty-2)",
+ "arabic-qwerty-3:Arabic (qwerty-3)",
+ "arabic-qwerty-4:Arabic (qwerty-4)",
+ "belarusian-qwerty:Belarusian (Belarus)",
+ "bengali-qwerty-1:Bengali (qwerty-1)",
+ "bengali-qwerty-2:Bengali (qwerty-2)",
+ "bulgarian-qwerty:Bulgarian (qwerty)",
+ "catalan-qwerty:Catalan (qwerty)",
+ "danish-qwerty:Danish (qwerty)",
+ "french-azerty-1:French (azerty-1)",
+ "french-azerty-2:French (azerty-2)",
+ "german-qwertz-1:German (qwertz-1)",
+ "german-qwertz-2:German (qwertz-2)",
+ "hebrew-qwerty:Hebrew (qwerty)",
+ "hungarian-qwertz-1:Magyar (qwertz-1) utf8",
+ "hungarian-qwertz-2:Magyar (qwertz-2) utf8",
+ "hungarianansi-qwertz-1:Magyar (qwertz-1) ansi",
+ "hungarianansi-qwertz-2:Magyar (qwertz-2) ansi",
+ "japanese-kana:Japanese (kana)",
+ "japanese-qwerty:Japanese (qwerty)",
+ "latvian-qwerty:Latvian (qwerty)",
+ "polish-qwerty:Polish (qwerty)",
+ "portuguese-qwerty:Portuguese (qwerty)",
+ "russian-qwerty:Russian (qwerty)",
+ "spanish-qwerty:Spanish (qwerty)",
+ "spanish-qwerty-sp:Spanish (qwerty) special",
+ "swedish-qwerty:Swedish (qwerty)",
+ "swedish-dvorak:Swedish (dvorak)",
+ "thai-qwerty:Thai (qwerty)",
+ "turkish-q:Turkish (q)",
+ "turkish-f:Turkish (f)"
+ ],
+
+ t, o = '';
+
+ $.each(layouts.sort(), function(i, l){
+ t = l.split(':');
+ o += '<option value="' + t[0] + '">' + t[1] + '</option>';
+ });
+
+ $('#lang')
+ .html(o)
+ .change(function(){
var kb = $('#multi'),
- opt = $(this).find('option:selected'),
- layout = opt.attr('class'),
- file = $(this).val();
- $('h2').text(opt.text());
+ layout = $(this).val(),
+ file = layout.split('-')[0];
+ $('h2').text(file);
+ // make language RTL, hebrew does it automatically
$('#multi')[file.match('arabic') ? 'addClass' : 'removeClass']('rtl');
+
if (kb.data('keyboard')) { kb.getkeyboard().destroy(); }
if (!language.hasOwnProperty(file)) {
$.getScript('layouts/' + file + '.js', function(){
@@ -135,47 +180,7 @@ <h4>This is a work in progress.</h4>
<div id="switcher"></div>
<br>
<div class="block2">
- <select id="lang">
- <!-- value="file name", class="layout name", Title -->
- <option value="albanian" class="albanian-qwerty">Albanian (qwerty)</option>
- <option value="albanian" class="albanian-qwertz">Albanian (qwertz)</option>
- <option value="arabic" class="arabic-azerty">Arabic (azerty)</option>
- <option value="arabic" class="arabic-qwerty-1">Arabic (qwerty-1)</option>
- <option value="arabic" class="arabic-qwerty-2">Arabic (qwerty-2)</option>
- <option value="arabic" class="arabic-qwerty-3">Arabic (qwerty-3)</option>
- <option value="arabic" class="arabic-qwerty-4">Arabic (qwerty-4)</option>
- <option value="belarusian" class="belarusian-qwerty">Belarusian (Belarus)</option>
- <option value="bengali" class="bengali-qwerty-1">Bengali (qwerty-1)</option>
- <option value="bengali" class="bengali-qwerty-2">Bengali (qwerty-2)</option>
- <option value="bulgarian" class="bulgarian-qwerty">Bulgarian (qwerty)</option>
- <option value="catalan" class="catalan-qwerty">Catalan (qwerty)</option>
- <option value="danish" class="danish-qwerty">Danish (qwerty)</option>
- <option value="french" class="french-azerty-1">French (azerty-1)</option>
- <option value="french" class="french-azerty-2">French (azerty-2)</option>
- <option value="german" class="german-qwertz-1">German (qwertz-1)</option>
- <option value="german" class="german-qwertz-2">German (qwertz-2)</option>
- <option value="hebrew" class="hebrew-qwerty">Hebrew (qwerty)</option>
- <option value="hungarian" class="hungarian-qwertz-1">Magyar (qwertz-1) utf8</option>
- <option value="hungarian" class="hungarian-qwertz-2">Magyar (qwertz-2) utf8</option>
- <option value="hungarianansi" class="hungarianansi-qwertz-1">Magyar (qwertz-1) ansi</option>
- <option value="hungarianansi" class="hungarianansi-qwertz-2">Magyar (qwertz-2) ansi</option>
- <option value="japanese" class="japanese-kana">Japanese (kana)</option>
- <option value="japanese" class="japanese-qwerty">Japanese (qwerty)</option>
- <option value="latvian" class="latvian-qwerty">Latvian (qwerty)</option>
- <option value="polish" class="polish-qwerty">Polish (qwerty)</option>
- <option value="russian" class="russian-qwerty">Russian (qwerty)</option>
- <option value="spanish" class="spanish-qwerty">Spanish (qwerty)</option>
- <option value="spanish" class="spanish-qwerty-sp">Spanish (qwerty) special</option>
- <option value="swedish" class="swedish-qwerty">Swedish (qwerty)</option>
- <option value="swedish" class="swedish-dvorak">Swedish (dvorak)</option>
- <option value="thai" class="thai-qwerty">Thai (qwerty)</option>
- <option value="turkish" class="turkish-q">Turkish (q)</option>
- <option value="turkish" class="turkish-f">Turkish (f)</option>
-
-<!--
- <option value="" class=""></option>
--->
- </select>
+ <select id="lang"></select>
<div style="height: 50px;"></div>
<h2></h2>
View
@@ -0,0 +1,93 @@
+/* Portuguese (pt) keyboard layout
+ * contains layout: 'portuguese-qwerty'
+ *
+ * To use:
+ * Point to this js file into your page header: <script src="layouts/portuguese-pt.js" type="text/javascript"></script>
+ * Initialize the keyboard using: $('input').keyboard({ layout: 'portuguese-pt' });
+ *
+ * license for this file: WTFPL, unless the source layout site has a problem with me using them as a reference
+
+ * Portuguese-pt layout by Luiz Castelo-Branco ( translations at Castelo-Branco . org ), based on:
+ * http://ascii-table.com/keyboard.php/163 and/with
+ * Unicode 6.2 from http://www.unicode.org/Public/6.2.0/charts/CodeCharts.pdf
+
+*/
+
+// portuguese-pt
+$.keyboard.layouts['portuguese-qwerty'] = {
+ 'default' : [
+ "\u005C 1 2 3 4 5 6 7 8 9 0 \u0027 \u00ab {bksp}",
+ "{tab} q w e r t y u i o p \u002b \u00b4",
+ "a s d f g h j k l \u00e7 \u00ba \u007e {enter}",
+ "{shift} \u003c z x c v b n m \u002c \u002e \u002d {shift}",
+ "{cancel} {space} {alt} {combo} {accept}"
+ ],
+ 'shift' : [
+ "\u007c \u0021 \u0022 \u0023 \u0024 \u0025 \u0026 \u002f \u0028 \u0029 \u003d \u003F \u00bb {bksp}",
+ "{tab} Q W E R T Y U I O P \u002a \u0060",
+ "A S D F G H J K L \u00c7 \u00aa \u005e {enter}",
+ "{shift} \u003e Z X C V B N M \u003b \u003a \u005f {shift}",
+ "{cancel} {space} {alt} {combo} {accept}"
+ ],
+// AltGr
+ 'alt' : [
+ "\u005C 1 \u0040 \u00a3 \u00a7 \u20ac 6 \u007b \u005b \u005d \u007d \u0027 \u00ab {bksp}",
+ "{tab} q w \u20ac r t y u i o p \u0308 \u00b4",
+ "a s d f g h j k l \u00e7 \u00ba \u007e {enter}",
+ "{shift} \u003c z x c v b n m \u002c \u002e \u002d {shift}",
+ "{cancel} {space} {alt} {combo} {accept}"
+ ],
+ 'alt-shift' : [
+ "\u007c \u0021 \u0022 \u0023 \u0024 \u0025 \u0026 \u002f \u0028 \u0029 \u003d \u003F \u00bb {bksp}",
+ "{tab} Q W \u20ac R T Y U I O P \u0308 \u0060",
+ "A S D F G H J K L \u00c7 \u00aa \u005e {enter}",
+ "{shift} \u003e Z X C V B N M \u003b \u003a \u005f {shift}",
+ "{cancel} {space} {alt} {combo} {accept}"
+ ]
+
+};
+
+// New combos using specific accents
+$.extend(true, $.keyboard.defaultOptions.combos, {
+ "\u00b4" : { a:"\u00e1", A:"\u00c1", e:"\u00e9", E:"\u00c9", i:"\u00ed", I:"\u00cd", o:"\u00f3", O:"\u00d3", u:"\u00fa", U:"\u00da", y:"\u00fd", Y:"\u00dd" } // acute & cedilla
+});
+
+// remove apostrophe combo
+$.keyboard.defaultOptions.combos["'"] = {};
+
+// Update regex for the combos above
+$.keyboard.comboRegex = /([`\'~\^\"ao\u00b4])([a-z])/mig;
+
+// Keyboard Language
+// please update this section to match this language and email me with corrections!
+// ***********************
+// "{a} {accept} {alt} {b} {bksp} {c} {cancel} {clear} {combo} {dec} {e} {enter} {lock} {s} {shift} {sign} {space} {t} {tab}"
+if (typeof(language) === 'undefined') { var language = {}; };
+language.portuguese = {
+ display : {
+ 'a' : '\u2714:Aceitar (Shift-Enter)', // ALTERNATE accept button - unicode for check mark symbol
+ 'accept' : 'Aceitar\:Concluir (Shift-Enter)', // Accept button text
+ 'alt' :'AltGr:Carateres Adicionais/CTRL+ALT', // Alt button text (AltGr is for international key sets)
+ 'b' : '\u2190:Retroceder', // ALTERNATE backspace button - unicode for left arrow. Same as ← ( &larr; ) - Left arrow
+ 'bksp' : '\u2190 Bksp:Retroceder', // Backspace button text
+ 'c' : '\u2716:Cancelar/Escape (Esc)', // ALTERNATE cancel button - unicode for big X
+ 'cancel' : 'Cancel:Cancelar/Escape(Esc)', // Cancel button text
+ 'clear' : 'C:Limpar', // Clear window content (used in num pad)
+ 'combo' : '\u00f6:Acentua\ç\ão Automtica', // (Toggle combo (diacritic) key
+ 'dec' : '.:Decimal', // Decimal point for num pad (optional), change '.' to ',' for European format
+ 'e' : '\u21b5:Introduzir/Mudar de Linha', // ALTERNATE enter button - unicode for down, then left arrow (enter symbol)
+ 'enter' : 'Enter\u21b5:Introduzir/Mudar de Linha', // Enter button text
+ 'lock' : '\u21ea Lock:CapsLock/Maisculas', // Caps lock button - unicode for double lined up arrow
+ 's' : '\u21e7:Shift/Maisculas', // ALTERNATE shift button - unicode for a thick up arrow
+ 'shift' : '\u21ea Shift:Maisculas-Minsculas', // Shift button text
+ 'sign' : '\u00b1:Mudar Sinal', // Change sign (used in num pad) - unicode for a +- symbol
+ 'space' : '&nbsp;:Espao', // Space button text
+ 't' : '\u21e5:Tab/Tabela/Avanar', // ALTERNATE tab button - unicode for right arrow to bar (used since only one directional tabs available)
+ 'tab' : '\u21e5 Tab:Tabela/Avanar' // Tab button text (Note: \u21b9 is the true tab symbol (left & right arrows) but not used here)
+ },
+ wheelMessage : 'Use a roda do rato/navegador para ver mais teclas',
+};
+
+// This will replace all default language options with these language options.
+// it is separated out here so the layout demo will work properly.
+$.extend(true, $.keyboard.defaultOptions, language.portuguese);

0 comments on commit 84e9c1d

Please sign in to comment.