From 7d27d36860395c140557f415bcde52679fab9e2a Mon Sep 17 00:00:00 2001 From: xue <> Date: Mon, 3 Sep 2007 19:02:11 +0000 Subject: rearranged js location. --- framework/Web/Javascripts/source/packages.php | 10 + .../Javascripts/source/prado/controls/controls.js | 221 --------------------- .../Javascripts/source/prado/controls/keyboard.js | 168 ++++++++++++++++ .../Javascripts/source/prado/controls/tabpanel.js | 50 +++++ framework/Web/UI/WebControls/TKeyboard.php | 2 +- framework/Web/UI/WebControls/TTabPanel.php | 2 +- 6 files changed, 230 insertions(+), 223 deletions(-) create mode 100644 framework/Web/Javascripts/source/prado/controls/keyboard.js create mode 100644 framework/Web/Javascripts/source/prado/controls/tabpanel.js (limited to 'framework') diff --git a/framework/Web/Javascripts/source/packages.php b/framework/Web/Javascripts/source/packages.php index 85fbb612..66b63966 100644 --- a/framework/Web/Javascripts/source/packages.php +++ b/framework/Web/Javascripts/source/packages.php @@ -49,6 +49,14 @@ $packages = array( 'slider'=>array( 'scriptaculous/slider.js' ), + + 'keyboard'=>array( + 'prado/controls/keyboard.js' + ), + + 'tabpanel'=>array( + 'prado/controls/tabpanel.js' + ), ); @@ -63,6 +71,8 @@ $dependencies = array( 'ajax' => array('prado', 'effects', 'ajax'), 'dragdrop' => array('prado', 'effects', 'dragdrop'), 'slider' => array('prado', 'slider'), + 'keyboard' => array('prado', 'keyboard'), + 'tabpanel' => array('prado', 'tabpanel'), ); return array($packages, $dependencies); diff --git a/framework/Web/Javascripts/source/prado/controls/controls.js b/framework/Web/Javascripts/source/prado/controls/controls.js index c4dcf562..ba472b70 100644 --- a/framework/Web/Javascripts/source/prado/controls/controls.js +++ b/framework/Web/Javascripts/source/prado/controls/controls.js @@ -288,224 +288,3 @@ Prado.WebUI.TRadioButtonList = Base.extend( } } }); - -Prado.WebUI.TTabPanel = Class.create(); -Prado.WebUI.TTabPanel.prototype = -{ - initialize : function(options) - { - this.element = $(options.ID); - this.onInit(options); - }, - - onInit : function(options) - { - this.views = options.Views; - this.hiddenField = $(options.ID+'_1'); - this.activeCssClass = options.ActiveCssClass; - this.normalCssClass = options.NormalCssClass; - var length = options.Views.length; - for(var i = 0; i'); key = key.replace(/</, '<'); key = key.replace(/&/, '&'); - this.insert(input, key); - } - - if (command != 'exit') input.focus(); - }, - - saveSelection : function() - { - if (this.keyboard.forControl.createTextRange) - { - this.keyboard.selection = document.selection.createRange().duplicate(); - return; - } - }, - - insert : function(field, value) - { - if (this.forControl.createTextRange && this.selection) - { - if (value == 'bksp') {this.selection.moveStart("character", -1); this.selection.text = '';} - else if (value == 'del') {this.selection.moveEnd("character", 1); this.selection.text = '';} - else {this.selection.text = value;} - this.selection.select(); - } - else - { - var selectStart = this.forControl.selectionStart; - var selectEnd = this.forControl.selectionEnd; - var start = (this.forControl.value).substring(0, selectStart); - var end = (this.forControl.value).substring(selectEnd, this.forControl.textLength); - - if (value == 'bksp') {start = start.substring(0, start.length - 1); selectStart -= 1; value = '';} - if (value == 'del') {end = end.substring(1, end.length); value = '';} - - this.forControl.value = start + value + end; - this.forControl.selectionStart = selectEnd + value.length; - this.forControl.selectionEnd = selectStart + value.length; - } - } -} \ No newline at end of file diff --git a/framework/Web/Javascripts/source/prado/controls/keyboard.js b/framework/Web/Javascripts/source/prado/controls/keyboard.js new file mode 100644 index 00000000..978aedb9 --- /dev/null +++ b/framework/Web/Javascripts/source/prado/controls/keyboard.js @@ -0,0 +1,168 @@ +Prado.WebUI.TKeyboard = Class.create(); +Prado.WebUI.TKeyboard.prototype = +{ + initialize : function(options) + { + this.element = $(options.ID); + this.onInit(options); + }, + + onInit : function(options) + { + this.cssClass = options['CssClass']; + this.forControl = document.getElementById(options['ForControl']); + this.autoHide = options['AutoHide']; + + this.flagShift = false; + this.flagCaps = false; + this.flagHover = false; + this.flagFocus = false; + + this.keys = new Array + ( + new Array('` ~ D', '1 ! D', '2 @ D', '3 # D', '4 $ D', '5 % D', '6 ^ D', '7 & D', '8 * D', '9 ( D', '0 ) D', '- _ D', '= + D', 'Bksp Bksp Bksp'), + new Array('Del Del Del', 'q Q L', 'w W L', 'e E L', 'r R L', 't T L', 'y Y L', 'u U L', 'i I L', 'o O L', 'p P L', '[ { D', '] } D', '\\ | \\'), + new Array('Caps Caps Caps', 'a A L', 's S L', 'd D L', 'f F L', 'g G L', 'h H L', 'j J L', 'k K L', 'l L L', '; : D', '\' " D', 'Exit Exit Exit'), + new Array('Shift Shift Shift', 'z Z L', 'x X L', 'c C L', 'v V L', 'b B L', 'n N L', 'm M L', ', < D', '. > D', '/ ? D', 'Shift Shift Shift') + ); + + if (this.isObject(this.forControl)) + { + this.forControl.keyboard = this; + this.forControl.onfocus = function() {this.keyboard.show(); }; + this.forControl.onblur = function() {if (this.keyboard.flagHover == false) this.keyboard.hide();}; + this.forControl.onkeydown = function(e) {if (!e) e = window.event; var key = (e.keyCode)?e.keyCode:e.which; if(key == 9) this.keyboard.hide();;}; + this.forControl.onselect = this.saveSelection; + this.forControl.onclick = this.saveSelection; + this.forControl.onkeyup = this.saveSelection; + } + + this.render(); + + this.tagKeyboard.onmouseover = function() {this.keyboard.flagHover = true;}; + this.tagKeyboard.onmouseout = function() {this.keyboard.flagHover = false;}; + + if (!this.autoHide) this.show(); + }, + + isObject : function(a) + { + return (typeof a == 'object' && !!a) || typeof a == 'function'; + }, + + createElement : function(tagName, attributes, parent) + { + var tagElement = document.createElement(tagName); + if (this.isObject(attributes)) for (attribute in attributes) tagElement[attribute] = attributes[attribute]; + if (this.isObject(parent)) parent.appendChild(tagElement); + return tagElement; + }, + + onmouseover : function() + { + this.className += ' Hover'; + }, + + onmouseout : function() + { + this.className = this.className.replace(/( Hover| Active)/ig, ''); + }, + + onmousedown : function() + { + this.className += ' Active'; + }, + + onmouseup : function() + { + this.className = this.className.replace(/( Active)/ig, ''); + this.keyboard.type(this.innerHTML); + }, + + render : function() + { + this.tagKeyboard = this.createElement('div', {className: this.cssClass, onselectstart: function() {return false;}}, this.element); + this.tagKeyboard.keyboard = this; + + for (var line = 0; line < this.keys.length; line++) + { + var tagLine = this.createElement('div', {className: 'Line'}, this.tagKeyboard); + for (var key = 0; key < this.keys[line].length; key++) + { + var split = this.keys[line][key].split(' '); + var tagKey = this.createElement('div', {className: 'Key ' + split[2]}, tagLine); + var tagKey1 = this.createElement('div', {className: 'Key1', innerHTML: split[0], keyboard: this, onmouseover: this.onmouseover, onmouseout: this.onmouseout, onmousedown: this.onmousedown, onmouseup: this.onmouseup}, tagKey); + var tagKey2 = this.createElement('div', {className: 'Key2', innerHTML: split[1], keyboard: this, onmouseover: this.onmouseover, onmouseout: this.onmouseout, onmousedown: this.onmousedown, onmouseup: this.onmouseup}, tagKey); + } + } + }, + + isShown : function() + { + return (this.tagKeyboard.style.visibility.toLowerCase() == 'visible'); + }, + + show : function() + { + if (this.isShown() == false) this.tagKeyboard.style.visibility = 'visible'; + }, + + hide : function() + { + if (this.isShown() == true && this.autoHide) {this.tagKeyboard.style.visibility = 'hidden'; } + }, + + type : function(key) + { + var input = this.forControl; + var command = key.toLowerCase(); + + if (command == 'exit') {this.hide();} + else if (input != 'undefined' && input != null && command == 'bksp') {this.insert(input, 'bksp');} + else if (input != 'undefined' && input != null && command == 'del') {this.insert(input, 'del');} + else if (command == 'shift') {this.tagKeyboard.className = this.flagShift?'Keyboard Off':'Keyboard Shift';this.flagShift = this.flagShift?false:true;} + else if (command == 'caps') {this.tagKeyboard.className = this.caps?'Keyboard Off':'Keyboard Caps';this.caps = this.caps?false:true;} + else if (input != 'undefined' && input != null) + { + if (this.flagShift == true) {this.flagShift = false; this.tagKeyboard.className = 'Keyboard Off';} + key = key.replace(/>/, '>'); key = key.replace(/</, '<'); key = key.replace(/&/, '&'); + this.insert(input, key); + } + + if (command != 'exit') input.focus(); + }, + + saveSelection : function() + { + if (this.keyboard.forControl.createTextRange) + { + this.keyboard.selection = document.selection.createRange().duplicate(); + return; + } + }, + + insert : function(field, value) + { + if (this.forControl.createTextRange && this.selection) + { + if (value == 'bksp') {this.selection.moveStart("character", -1); this.selection.text = '';} + else if (value == 'del') {this.selection.moveEnd("character", 1); this.selection.text = '';} + else {this.selection.text = value;} + this.selection.select(); + } + else + { + var selectStart = this.forControl.selectionStart; + var selectEnd = this.forControl.selectionEnd; + var start = (this.forControl.value).substring(0, selectStart); + var end = (this.forControl.value).substring(selectEnd, this.forControl.textLength); + + if (value == 'bksp') {start = start.substring(0, start.length - 1); selectStart -= 1; value = '';} + if (value == 'del') {end = end.substring(1, end.length); value = '';} + + this.forControl.value = start + value + end; + this.forControl.selectionStart = selectEnd + value.length; + this.forControl.selectionEnd = selectStart + value.length; + } + } +}; \ No newline at end of file diff --git a/framework/Web/Javascripts/source/prado/controls/tabpanel.js b/framework/Web/Javascripts/source/prado/controls/tabpanel.js new file mode 100644 index 00000000..8033a2ee --- /dev/null +++ b/framework/Web/Javascripts/source/prado/controls/tabpanel.js @@ -0,0 +1,50 @@ +Prado.WebUI.TTabPanel = Class.create(); +Prado.WebUI.TTabPanel.prototype = +{ + initialize : function(options) + { + this.element = $(options.ID); + this.onInit(options); + }, + + onInit : function(options) + { + this.views = options.Views; + this.hiddenField = $(options.ID+'_1'); + this.activeCssClass = options.ActiveCssClass; + this.normalCssClass = options.NormalCssClass; + var length = options.Views.length; + for(var i = 0; igetClientOptions()); $className=$this->getClientClassName(); $cs=$this->getPage()->getClientScript(); - $cs->registerPradoScript('prado'); + $cs->registerPradoScript('keyboard'); $cs->registerEndScript('prado:'.$this->getClientID(), "new $className($options);"); } diff --git a/framework/Web/UI/WebControls/TTabPanel.php b/framework/Web/UI/WebControls/TTabPanel.php index d4524534..c6beae3c 100644 --- a/framework/Web/UI/WebControls/TTabPanel.php +++ b/framework/Web/UI/WebControls/TTabPanel.php @@ -398,7 +398,7 @@ class TTabPanel extends TWebControl implements IPostBackDataHandler $className=$this->getClientClassName(); $page=$this->getPage(); $cs=$page->getClientScript(); - $cs->registerPradoScript('prado'); + $cs->registerPradoScript('tabpanel'); $code="new $className($options);"; $cs->registerEndScript("prado:$id", $code); $cs->registerHiddenField($id.'_1',$this->getActiveViewIndex()); -- cgit v1.2.3