You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by bo...@apache.org on 2009/02/18 04:10:21 UTC

svn commit: r745369 - in /myfaces/tobago/branches/tobago-1.0.x: ./ theme/standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/script/tobago.js

Author: bommel
Date: Wed Feb 18 03:10:20 2009
New Revision: 745369

URL: http://svn.apache.org/viewvc?rev=745369&view=rev
Log:
Merged revisions 744771,744909,744926 via svnmerge from 
https://svn.eu.apache.org/repos/asf/myfaces/tobago/trunk

........
  r744771 | bommel | 2009-02-15 23:16:31 +0100 (So, 15 Feb 2009) | 4 lines
  
  (TOBAGO-626) Input length restriction for tc:textarea
  
  Maybe the keypress event is a better choice.
  Can't really test and debug the paste event.
........
  r744909 | bommel | 2009-02-16 14:20:30 +0100 (Mo, 16 Feb 2009) | 1 line
  
  (TOBAGO-626) Input length restriction for tc:textarea Can't really test and debug the paste event on ie (ubuntu).
........
  r744926 | idus | 2009-02-16 15:50:24 +0100 (Mo, 16 Feb 2009) | 1 line
  
  TOBAGO-626: small hack for event bubbling
........

Modified:
    myfaces/tobago/branches/tobago-1.0.x/   (props changed)
    myfaces/tobago/branches/tobago-1.0.x/theme/standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/script/tobago.js

Propchange: myfaces/tobago/branches/tobago-1.0.x/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Wed Feb 18 03:10:20 2009
@@ -1 +1 @@
-/myfaces/tobago/trunk:699460,699891-700092,743495-743708
+/myfaces/tobago/trunk:699460,699891-700092,743495-743708,744771-744909,744926

Propchange: myfaces/tobago/branches/tobago-1.0.x/
------------------------------------------------------------------------------
Binary property 'svnmerge-integrated' - no diff available.

Modified: myfaces/tobago/branches/tobago-1.0.x/theme/standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/script/tobago.js
URL: http://svn.apache.org/viewvc/myfaces/tobago/branches/tobago-1.0.x/theme/standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/script/tobago.js?rev=745369&r1=745368&r2=745369&view=diff
==============================================================================
--- myfaces/tobago/branches/tobago-1.0.x/theme/standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/script/tobago.js (original)
+++ myfaces/tobago/branches/tobago-1.0.x/theme/standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/script/tobago.js Wed Feb 18 03:10:20 2009
@@ -1732,8 +1732,9 @@
 };
 
 Tobago.In.prototype.setup = function() {
+  var ctrl;
   if (this.required) {
-    var ctrl = Tobago.element(this.id);
+    ctrl = Tobago.element(this.id);
     if (ctrl.value && ctrl.value.length > 0) {
       Tobago.removeCssClass(this.id, this.cssPrefix + "-required" );
     }
@@ -1741,9 +1742,27 @@
     Tobago.addBindEventListener(ctrl, "blur", this, "leaveRequired");
   }
   if (this.maxLength && this.maxLength > 0) {
-    var ctrl = Tobago.element(this.id);
+    ctrl = Tobago.element(this.id);
     Tobago.addBindEventListener(ctrl, "change", this, "checkMaxLength");
-    Tobago.addBindEventListener(ctrl, "keyup", this, "checkMaxLength");
+    Tobago.addBindEventListener(ctrl, "keypress", this, "checkMaxLength");
+    if (Tobago.getBrowser().type == "msie") {
+      Tobago.addBindEventListener(ctrl, "paste", this, "checkMaxLengthOnPaste");
+    }
+  }
+};
+
+// XXX IE only
+Tobago.In.prototype.checkMaxLengthOnPaste = function(event) {
+  if (!event) {
+    event = window.event;
+  }
+  var input = Tobago.element(event);
+  var pasteText = window.clipboardData.getData("Text");
+  var range = document.selection.createRange();
+  if (input.value.length - range.text.length + pasteText.length > this.maxLength) {
+    pasteText = pasteText.substring(0, this.maxLength - input.value.length + range.text.length);
+    range.text = pasteText;
+    event.returnValue = false;
   }
 };
 
@@ -1751,7 +1770,7 @@
   if (!event) {
     event = window.event;
   }
-  var ctrl = Tobago.element(this.id);
+  var ctrl = Tobago.element(event);
   var elementLength = ctrl.value.length;
   if (elementLength > this.maxLength) {
     // Input is longer than max, truncate and return false.