------------------------------------------------------------
revno: 4581
committer: Morten Olav Hansen <[email protected]>
branch nick: dhis2
timestamp: Wed 2011-09-14 10:36:05 +0200
message:
  bugfix, made special characters work correctly with :containsNC (for select 
box filtering)
modified:
  
dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/dhis2/dhis2.util.js


--
lp:dhis2
https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk

Your team DHIS 2 developers is subscribed to branch lp:dhis2.
To unsubscribe from this branch go to 
https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk/+edit-subscription
=== modified file 'dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/dhis2/dhis2.util.js'
--- dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/dhis2/dhis2.util.js	2011-08-26 08:04:48 +0000
+++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/dhis2/dhis2.util.js	2011-09-14 08:36:05 +0000
@@ -52,7 +52,7 @@
 };
 
 /**
- * adds ':containsNoCase' to filtering.
+ * adds ':containsNC' to filtering.
  * $(sel).find(':containsNC(key)').doSomething();
  */
 $.expr[":"].containsNC = function( el, i, m )
@@ -61,7 +61,11 @@
     var search = m[3];
 
     if ( !search )
+    {
         return false;
+    }
+
+    search = dhis2.util.escape( search );
 
     return eval( '/' + search + '/i' ).test( $( el ).text() );
 };
@@ -85,8 +89,8 @@
 }
 
 /**
- * Define a window.log object, and output to console.log if it exists.
- * (this is a fix for IE8 and FF 3.6).
+ * Define a window.log object, and output to console.log if it exists. (this is
+ * a fix for IE8 and FF 3.6).
  */
 window.log = function( str )
 {
@@ -95,3 +99,11 @@
         console.log( str );
     }
 };
+
+/**
+ * Escape function for regular expressions.
+ */
+dhis2.util.escape = function( text )
+{
+    return text.replace( /[-[\]{}()*+?.,\/\\^$|#\s]/g, "\\$&" );
+};

_______________________________________________
Mailing list: https://launchpad.net/~dhis2-devs
Post to     : [email protected]
Unsubscribe : https://launchpad.net/~dhis2-devs
More help   : https://help.launchpad.net/ListHelp

Reply via email to