/* GZIP on the fly by Raccoon Framework http://www.wt.com.mx/ */ /** * @version 0.1 * @author Alejandro -aztkgeek- Galindo * @copyright Copyright (C) 2006 Web Technologies Networks S.A. de C.V. * @package Raccoon.RUI * @license http://www.gnu.org/copyleft/gpl.html GNU/GPL, see LICENSE.php * Raccoon is free software. This version may have been modified pursuant * to the GNU General Public License, and as distributed it includes or * is derivative of works licensed under the GNU General Public License or * other free or open source software licenses. * See COPYRIGHT.php for copyright notices and details. */ // Namespaces, index RACCOON.namespace("RACCOON.html.input"); RACCOON.namespace("RACCOON.html.input.acceptOnly"); RACCOON.namespace("RACCOON.html.input.serviceAcceptOnly"); RACCOON.namespace("RACCOON.html.input.incrementDecrement"); RACCOON.html.input.serviceAcceptOnly = function(element, patron) { if (typeof element == "string") { element = document.getElementById(element); } element.onkeyup = function() { if (patron == 'phone') { patron = '0123456789-()'; } else if (patron == 'numbers') { patron = '0123456789'; } else if (patron == 'email') { patron = '0123456789._@abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'; } for (var i = 0; i < this.value.length; i++) { if (patron.indexOf(this.value[i]) == -1) { this.value = this.value.replace(this.value[i], ""); } } } } /** * @copyright 1999 Idocs, Inc. http://www.idocs.com/ * @author Miko O'Sullivan, * @author Modified by Alejandro -aztkgeek- Galindo, Web Technologies Networks S.A. de C.V. www.wt.com.mx * @license Open Content License, Distribute this * script freely but keep this notice in place * @usage telephone: onkeypress="return RACCOON.html.input.acceptOnly('phone', this, event)" * zip: onkeypress="return RACCOON.html.input.acceptOnly('numbers', this, event)" * email: onkeypress="return RACCOON.html.input.acceptOnly('email', this, event)" */ RACCOON.html.input.acceptOnly = function(that, field_pointer, e, dec) { if (that == 'phone') { that = '0123456789-()'; } else if (that == 'numbers') { that = '0123456789'; } else if (that == 'email') { that = '0123456789._@abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'; } var key; var keychar; if (window.event) { key = window.event.keyCode; } else if (e) { key = e.which; } else { return true; } keychar = String.fromCharCode(key); // control keys if ((key==null) || (key==0) || (key==8) || (key==9) || (key==13) || (key==27) ) { return true; } // "that" patron else if (((that).indexOf(keychar) > -1)) { return true; } } /** * @author http://gatsu.ftp.free.fr/ * @author Alejandro -aztkgeek- Galindo, Web Technologies Networks S.A. de C.V. www.wt.com.mx * @usage * var incDec = new RACCOON.html.input.incrementDecrement(); * incDec.plusButtonId = "my_plus_button_id"; * incDec.lessButtonId = "my_less_button_id"; * incDec.elementId = "my_element_id"; * incDec.min = 1; // optional, my less value * incDec.max = 50; // optional, my big value * incDec.init(); */ RACCOON.html.input.incrementDecrement = function() { this.delay = 150; this.interval = null; this.plusButtonId = null; this.lessButtonId = null; this.elementId = null; this.min = 0; this.max = null; } RACCOON.html.input.incrementDecrement.prototype.changeValue = function(typeAction, value) { var _this = this; switch(typeAction) { case 0: //Stop the function clearInterval(this.interval); break; case 1: //Just 1 click document.getElementById(this.elementId).value = parseInt(document.getElementById(this.elementId).value) + value; if (parseInt(document.getElementById(this.elementId).value) < this.min) { document.getElementById(this.elementId).value = this.min; } else if (parseInt(document.getElementById(this.elementId).value) > this.max) { document.getElementById(this.elementId).value = this.max; } break; case 2: //Play the function a regular interval this.interval = setInterval(function() { _this.changeValue(1, value); }, _this.delay); break; default: break; } } RACCOON.html.input.incrementDecrement.prototype.init = function() { var _this = this; if (this.elementId != null && this.min != null) { document.getElementById(this.elementId).value = this.min; } if (this.plusButtonId != null) { var plusButton = document.getElementById(this.plusButtonId); plusButton.onclick = function() { _this.changeValue(1, 1); } plusButton.onmousedown = function() { _this.changeValue(2, 1); } plusButton.onmouseup = function() { _this.changeValue(0, 0); } } if (this.lessButtonId != null) { var lessButton = document.getElementById(this.lessButtonId); lessButton.onclick = function() { _this.changeValue(1, -1); } lessButton.onmousedown = function() { _this.changeValue(2, -1); } lessButton.onmouseup = function() { _this.changeValue(0, 0); } } }