| | 9 | |
| | 10 | /** simple version of $X |
| | 11 | * $X(exp); |
| | 12 | * $X(exp, context); |
| | 13 | * @source http://gist.github.com/3242.txt |
| | 14 | */ |
| | 15 | var $X = function (exp, context) { |
| | 16 | context || (context = document); |
| | 17 | var expr = (context.ownerDocument || context).createExpression(exp, function (prefix) { |
| | 18 | return document.createNSResolver(context.documentElement || context).lookupNamespaceURI(prefix) || |
| | 19 | context.namespaceURI || document.documentElement.namespaceURI || ""; |
| | 20 | }); |
| | 21 | var result = expr.evaluate(context, XPathResult.ANY_TYPE, null); |
| | 22 | switch (result.resultType) { |
| | 23 | case XPathResult.STRING_TYPE : return result.stringValue; |
| | 24 | case XPathResult.NUMBER_TYPE : return result.numberValue; |
| | 25 | case XPathResult.BOOLEAN_TYPE: return result.booleanValue; |
| | 26 | case XPathResult.UNORDERED_NODE_ITERATOR_TYPE: |
| | 27 | // not ensure the order. |
| | 28 | var ret = [], i = null; |
| | 29 | while (i = result.iterateNext()) ret.push(i); |
| | 30 | return ret; |
| | 31 | } |
| | 32 | return null; |
| | 33 | } |
| | 34 | |
| | 35 | |
| 87 | | var t = e.target; |
| 88 | | if( t.nodeType == 1 ){ |
| 89 | | var tn = t.tagName.toLowerCase(); |
| 90 | | if( tn == 'input' || tn == 'textarea' ){ |
| 91 | | return; |
| 92 | | } |
| 93 | | var pressKey = String.fromCharCode(e.which); |
| 94 | | if( typeof handler[pressKey] == "function" ){ |
| 95 | | e.preventDefault(); //Stop Default Event |
| 96 | | handler[pressKey].apply(); |
| 97 | | } |
| 98 | | } |
| | 114 | if( e.target.tagName == 'INPUT' || e.target.tagName == 'TEXTAREA' ) return; |
| | 115 | var pressKey= (e.ctrlKey?'C-':'') + String.fromCharCode(e.which) |
| | 116 | if( typeof handler[pressKey] != "function" ) return; |
| | 117 | try{ |
| | 118 | e.preventDefault(); //Stop Default Event |
| | 119 | handler[pressKey].apply(); |
| | 120 | }catch(d){} |