1/** 2 * @author WingedFox 3 */ 4 5/** 6 * Keyboard constructor 7 * 8 * @class DraggableVirtualKeyboard 9 * @constructor 10 */ 11 12PopupVirtualKeyboard = new function() { 13 var self = this; 14 /** 15 * popup window handler 16 * 17 * @type {Window} 18 * @scope private 19 */ 20 var hWnd = null; 21 /** 22 * path to this file 23 * 24 * @type {String} 25 */ 26 var p = (function (sname){var sc = document.getElementsByTagName('script'),sr = new RegExp('^(.*/|)('+sname+')([#?]|$)');for (var i=0,scL=sc.length; i<scL; i++) {var m = String(sc[i].src).match(sr);if (m) {if (m[1].match(/^((https?|file)\:\/{2,}|\w:[\\])/)) return m[1];if (m[1].indexOf("/")==0) return m[1];b = document.getElementsByTagName('base');if (b[0] && b[0].href) return b[0].href+m[1];return (document.location.href.match(/(.*[\/\\])/)[0]+m[1]).replace(/^\/+(?=\w:)/,"");}}return null;})('vk_popup.js'); 27 /** 28 * Tells, if the keyboard is open 29 * 30 * @return {Boolean} 31 * @scope public 32 */ 33 this.isOpen = function () { 34 return null!=hWnd && !hWnd.closed; 35 } 36 /** 37 * Target input 38 * 39 * @type {String} 40 * @scope private 41 */ 42 var tgt = null; 43 /** 44 * Shows keyboard 45 * 46 * @param {HTMLElement, String} input element or it to bind keyboard to 47 * @return {Boolean} operation state 48 * @scope public 49 */ 50 this.show = function (target) { 51 if (!hWnd || hWnd.closed) { 52 hWnd = (window.showModelessDialog||window.open)(p+"vk_popup.html",window.showModelessDialog?window:"_blank","status=0,title=0,dependent=yes,resizable=no,scrollbars=no,width=500,height=500"); 53 tgt = target; 54 return true; 55 } 56 return false; 57 } 58 /** 59 * Hides keyboard 60 * 61 * @scope public 62 */ 63 this.close = function (target) { 64 if (!hWnd) return false; 65 if (!hWnd.VirtualKeyboard.isOpen()) hWnd.VirtualKeyboard.hide(); 66 hWnd.close(); 67 hWnd = null; 68 } 69 this.onload = function () { 70 hWnd.VirtualKeyboard.show( document.getElementById(tgt) 71 ,hWnd.document.body 72 ,hWnd.document.body 73 ); 74 hWnd.dialogHeight = parseInt(hWnd.dialogHeight)-hWnd.getClientHeight()+hWnd.document.body.firstChild.offsetHeight+'px'; 75 hWnd.dialogWidth = parseInt(hWnd.dialogWidth)-hWnd.getClientWidth()+hWnd.document.body.firstChild.offsetWidth+'px'; 76 if (hWnd.sizeToContent) hWnd.sizeToContent(); 77 hWnd.onunload = self.close; 78 } 79 if (window.attachEvent) window.attachEvent('onunload', self.close); 80 else if (window.addEventListener) window.addEventListener('unload', self.close, false); 81 82 var p = (function (sname){var sc = document.getElementsByTagName('script'),sr = new RegExp('^(.*/|)('+sname+')([#?]|$)');for (var i=0,scL=sc.length; i<scL; i++) {var m = String(sc[i].src).match(sr);if (m) {if (m[1].match(/^((https?|file)\:\/{2,}|\w:[\\])/)) return m[1];if (m[1].indexOf("/")==0) return m[1];b = document.getElementsByTagName('base');if (b[0] && b[0].href) return b[0].href+m[1];return (document.location.pathname.match(/(.*[\/\\])/)[0]+m[1]).replace(/^\/+(?=\w:)/,"");}}return null;})('vk_popup.js'); 83 var dpd = ['/extensions/documentselection.js']; 84 for (var i=0,dL=dpd.length;i<dL;i++) { 85 document.write('<scr'+'ipt defer="false" type="text/javascript" src="'+p+dpd[i]+'"></scr'+'ipt>'); 86 } 87} 88