myfaces-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mat...@apache.org
Subject svn commit: r562028 - in /myfaces/trinidad/trunk/trinidad/trinidad-impl/src/main: java/org/apache/myfaces/trinidadinternal/resource/ javascript/META-INF/adf/jsLibs/
Date Thu, 02 Aug 2007 07:02:25 GMT
Author: matzew
Date: Thu Aug  2 00:02:22 2007
New Revision: 562028

URL: http://svn.apache.org/viewvc?view=rev&rev=562028
Log:
small js refactoring.
added TrCollections.js, which contains (will contain) functions to
work with collections

Added:
    myfaces/trinidad/trunk/trinidad/trinidad-impl/src/main/javascript/META-INF/adf/jsLibs/TrCollections.js
Modified:
    myfaces/trinidad/trunk/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/resource/CoreCommonScriptsResourceLoader.java
    myfaces/trinidad/trunk/trinidad/trinidad-impl/src/main/javascript/META-INF/adf/jsLibs/CoreFormat.js

Modified: myfaces/trinidad/trunk/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/resource/CoreCommonScriptsResourceLoader.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/trunk/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/resource/CoreCommonScriptsResourceLoader.java?view=diff&rev=562028&r1=562027&r2=562028
==============================================================================
--- myfaces/trinidad/trunk/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/resource/CoreCommonScriptsResourceLoader.java
(original)
+++ myfaces/trinidad/trunk/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/resource/CoreCommonScriptsResourceLoader.java
Thu Aug  2 00:02:22 2007
@@ -56,6 +56,7 @@
     "META-INF/adf/jsLibs/CharSets.js",
     "META-INF/adf/jsLibs/NumberFormat.js",
     "META-INF/adf/jsLibs/CoreFormat.js",
+    "META-INF/adf/jsLibs/TrCollections.js",
     "META-INF/adf/jsLibs/DateField.js",
     "META-INF/adf/jsLibs/DateFieldFormat.js",
     "META-INF/adf/jsLibs/DateFormat.js",
@@ -87,6 +88,7 @@
   {
     "META-INF/adf/jsLibsDebug/CharSets.js",
     "META-INF/adf/jsLibsDebug/NumberFormat.js",
+    "META-INF/adf/jsLibsDebug/TrCollections.js",
     "META-INF/adf/jsLibsDebug/CoreFormat.js",
     "META-INF/adf/jsLibsDebug/DateField.js",
     "META-INF/adf/jsLibsDebug/DateFieldFormat.js",

Modified: myfaces/trinidad/trunk/trinidad/trinidad-impl/src/main/javascript/META-INF/adf/jsLibs/CoreFormat.js
URL: http://svn.apache.org/viewvc/myfaces/trinidad/trunk/trinidad/trinidad-impl/src/main/javascript/META-INF/adf/jsLibs/CoreFormat.js?view=diff&rev=562028&r1=562027&r2=562028
==============================================================================
--- myfaces/trinidad/trunk/trinidad/trinidad-impl/src/main/javascript/META-INF/adf/jsLibs/CoreFormat.js
(original)
+++ myfaces/trinidad/trunk/trinidad/trinidad-impl/src/main/javascript/META-INF/adf/jsLibs/CoreFormat.js
Thu Aug  2 00:02:22 2007
@@ -912,8 +912,8 @@
   var allMonth = ['jan','feb','mar','apr','may','jun','jul','aug','sep','oct','nov','dec'];
   
   //remove the submitted values, which are invalid, to display only the valid ones
-  this._removeInvalidValues(this._weekdaysValue, allWeekdays);
-  this._removeInvalidValues(this._monthValue, allMonth);
+  TrCollections.removeValuesFromArray(this._weekdaysValue, allWeekdays);
+  TrCollections.removeValuesFromArray(this._monthValue, allMonth);
   
   return _returnHints(
     this._messages,
@@ -926,31 +926,6 @@
   );
 }
 
-/**
- * Removes invalidValues from the allValues array
- * TODO matzew: move this to a "CollectionUtil.js" ?
- */
-TrDateRestrictionValidator.prototype._removeInvalidValues = function(
-  invalidValues,
-  allValues
-  )
-{
-  if(invalidValues)
-  {
-    for(i=0; i<invalidValues.length; i++)
-    {
-      var value = invalidValues[i];
-      for(j=0;j<allValues.length; j++)
-      {
-        if(allValues[j].toLowerCase() == value.toLowerCase())
-        {
-          allValues.splice(j,1);
-        }
-      }
-    }
-  }
-}
-
 TrDateRestrictionValidator.prototype._translate = function(
   values,
   map,
@@ -988,7 +963,7 @@
       if(weekDaysArray[i].toLowerCase() == dayString)
       {
         var allWeekdays = ['mon','tue','wed','thu','fri','sat','sun'];
-        this._removeInvalidValues(this._weekdaysValue, allWeekdays);
+        TrCollections.removeValuesFromArray(this._weekdaysValue, allWeekdays);
         var days = this._translate(allWeekdays, this._translatedWeekdaysMap, converter.getLocaleSymbols().getWeekdays());
 
         var facesMessage;
@@ -1023,7 +998,7 @@
       if(monthArray[i].toLowerCase() == monthString)
       {
         var allMonth = ['jan','feb','mar','apr','may','jun','jul','aug','sep','oct','nov','dec'];
-        this._removeInvalidValues(this._monthValue, allMonth);
+        TrCollections.removeValuesFromArray(this._monthValue, allMonth);
         var month = this._translate(allMonth, this._translatedMonthMap, converter.getLocaleSymbols().getMonths());
         
         var facesMessage;

Added: myfaces/trinidad/trunk/trinidad/trinidad-impl/src/main/javascript/META-INF/adf/jsLibs/TrCollections.js
URL: http://svn.apache.org/viewvc/myfaces/trinidad/trunk/trinidad/trinidad-impl/src/main/javascript/META-INF/adf/jsLibs/TrCollections.js?view=auto&rev=562028
==============================================================================
--- myfaces/trinidad/trunk/trinidad/trinidad-impl/src/main/javascript/META-INF/adf/jsLibs/TrCollections.js
(added)
+++ myfaces/trinidad/trunk/trinidad/trinidad-impl/src/main/javascript/META-INF/adf/jsLibs/TrCollections.js
Thu Aug  2 00:02:22 2007
@@ -0,0 +1,51 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ * 
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+
+/**
+ * Utilities for working with collections
+ */
+var TrCollections = new Object();
+
+/**
+ * A static util function that removes an array of values
+ * from another array.
+ * @param {Array} toRemove Array that contains the values to remove
+ * @param {Array} allValues Array from that the values will be removed
+ */
+TrCollections.removeValuesFromArray = function(
+  toRemove,
+  allValues
+  )
+{
+  if(toRemove && allValues)
+  {
+    for(i=0; i<toRemove.length; i++)
+    {
+      var value = toRemove[i];
+      for(j=0;j<allValues.length; j++)
+      {
+        if(allValues[j].toLowerCase() == value.toLowerCase())
+        {
+          allValues.splice(j,1);
+        }
+      }
+    }
+  }
+}
+



Mime
View raw message