CharPicker.js (4105B)
1 Ext.define('PartKeepr.picker.Char', { 2 extend: 'Ext.picker.Color', 3 alias: 'widget.charpicker', 4 5 /** 6 * @cfg {String} [componentCls='x-char-picker'] 7 * The CSS class to apply to the containing element. 8 */ 9 componentCls : Ext.baseCSSPrefix + 'char-picker', 10 11 /** 12 * @cfg {String} [selectedCls='x-char-picker-selected'] 13 * The CSS class to apply to the selected element 14 */ 15 selectedCls: Ext.baseCSSPrefix + 'char-picker-selected', 16 17 /** 18 * @cfg {String} value 19 * The initial char to highlight. 20 */ 21 value : null, 22 23 /** 24 * @cfg {String} clickEvent 25 * The DOM event that will cause a char to be selected. This can be any valid event name (dblclick, contextmenu). 26 */ 27 clickEvent :'click', 28 29 /** 30 * @cfg {Boolean} allowReselect 31 * If set to true then reselecting a char that is already selected fires the {@link #select} event 32 */ 33 allowReselect : true, 34 35 /** 36 * @property {String[]} chars 37 */ 38 chars : [ 39 ' ', '&', '"', '¢', '€', '£', '¥', '©', '®', '™', '‰', 'µ', '·', '•', '…', '′', '″', '§', '¶', 'ß', 40 '‹', '›', '«', '»', '‘', '’', '“', '”', '‚', '„', '<', '>', '≤', '≥', '–', '—', '¯', '‾', '¤', '¦', 41 '¨', '¡', '¿', 'ˆ', '˜', '°', '−', '±', '÷', '⁄', '×', '¹', '²', '³', '¼', '½', '¾', 'ƒ', '∫', '∑', 42 '∞', '√', '≈', '≠', '≡', '∏', '¬', '∩', '∂', '´', '¸', 'ª', 'º', '†', '‡', 'À', 'Á', 'Â', 'Ã', 'Ä', 43 'Å', 'Æ', 'Ç', 'È', 'É', 'Ê', 'Ë', 'Ì', 'Í', 'Î', 'Ï', 'Ð', 'Ñ', 'Ò', 'Ó', 'Ô', 'Õ', 'Ö', 'Ø', 'Œ', 44 'Š', 'Ù', 'Ú', 'Û', 'Ü', 'Ý', 'Ÿ', 'Þ', 'à', 'á', 'â', 'ã', 'ä', 'å', 'æ', 'ç', 'è', 'é', 'ê', 'ë', 45 'ì', 'í', 'î', 'ï', 'ð', 'ñ', 'ò', 'ó', 'ô', 'õ', 'ö', 'ø', 'œ', 'š', 'ù', 'ú', 'û', 'ü', 'ý', 'þ', 46 'ÿ', 'Α', 'Β', 'Γ', 'Δ', 'Ε', 'Ζ', 'Η', 'Θ', 'Ι', 'Κ', 'Λ', 'Μ', 'Ν', 'Ξ', 'Ο', 'Π', 'Ρ', 'Σ', 'Τ', 47 'Υ', 'Φ', 'Χ', 'Ψ', 'Ω', 'α', 'β', 'γ', 'δ', 'ε', 'ζ', 'η', 'θ', 'ι', 'κ', 'λ', 'μ', 'ν', 'ξ', 'ο', 48 'π', 'ρ', 'ς', 'σ', 'τ', 'υ', 'φ', 'χ', 'ψ', 'ω', '←', '↑', '→', '↓', '↔', '◊', '♠', '♣', '♥', '♦', 49 '⌀', '∅' 50 ], 51 52 /** 53 * @cfg {Function} handler 54 * A function that will handle the select event of this picker. The handler is passed the following parameters: 55 * 56 * - `picker` : CharPicker 57 * 58 * - `char` : String 59 */ 60 61 /** 62 * @cfg {Object} scope 63 * The scope (`this` reference) in which the `{@link #handler}` function will be called. Defaults to this 64 * Char picker instance. 65 */ 66 67 renderTpl: [ 68 '<tpl for="chars">', 69 '<a href="#" hidefocus="on">', 70 '<em><span unselectable="on">{.}</span></em>', 71 '</a>', 72 '</tpl>' 73 ], 74 75 // private 76 initRenderData : function(){ 77 var me = this; 78 return Ext.apply(me.callParent(), { 79 iitemCls: me.itemCls, 80 chars: me.chars 81 }); 82 }, 83 84 // private 85 handleClick : function(event, target){ 86 var me = this; 87 88 event.stopEvent(); 89 if (!me.disabled) { 90 var el = Ext.get(target); 91 me.select(el.down("span").dom.textContent); 92 } 93 }, 94 95 /** 96 * Selects the specified char in the picker (fires the {@link #select} event) 97 * @param {String} char The char 98 * @param {Boolean} suppressEvent (optional) True to stop the select event from firing. Defaults to false. 99 */ 100 select : function(chr, suppressEvent){ 101 102 var me = this, 103 selectedCls = me.selectedCls, 104 value = me.value, 105 el; 106 107 if (!me.rendered) { 108 me.value = chr; 109 return; 110 } 111 112 113 if (chr != value || me.allowReselect) { 114 me.value = chr; 115 if (suppressEvent !== true) { 116 me.fireEvent('select', me, chr); 117 } 118 } 119 } 120 });