dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #12394
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 3805: moved more functionality from ajaxSelect -> dhis2.*
------------------------------------------------------------
revno: 3805
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Tue 2011-05-31 11:30:22 +0200
message:
moved more functionality from ajaxSelect -> dhis2.*
modified:
dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/dhis2/dhis2.array.js
dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/dhis2/dhis2.comparator.js
dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/dhis2/dhis2.select.js
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/jQuery/jquery.dhisAjaxSelect.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.array.js'
--- dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/dhis2/dhis2.array.js 2011-05-31 08:21:47 +0000
+++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/dhis2/dhis2.array.js 2011-05-31 09:30:22 +0000
@@ -26,3 +26,19 @@
*/
dhis2.util.namespace( 'dhis2.array' );
+
+/**
+ * Remove part of an array.
+ *
+ * @param array {array} Array to remove from
+ * @param from {Number} Start index
+ * @param to {Number} End index
+ */
+dhis2.array.remove = function( array, from, to )
+{
+ // Array Remove - By John Resig (MIT Licensed)
+ var rest = array.slice( (to || from) + 1 || array.length );
+ array.length = from < 0 ? array.length + from : from;
+
+ return array.push.apply( array, rest );
+};
=== modified file 'dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/dhis2/dhis2.comparator.js'
--- dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/dhis2/dhis2.comparator.js 2011-05-31 08:21:47 +0000
+++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/dhis2/dhis2.comparator.js 2011-05-31 09:30:22 +0000
@@ -67,24 +67,11 @@
*/
dhis2.comparator.htmlNoCaseComparator = function( a, b )
{
- if( !! a) {
- a = a.html();
-
- if(!! a) {
- a = a.toLowerCase();
- }
- }
-
- if( !! b) {
- b = b.html();
-
- if(!! b) {
- b = b.toLowerCase();
- }
- }
-
-// a = !! a ? a.html().toLowerCase() : a.html();
-// b = !! b ? b.html().toLowerCase() : b.html();
+ a = !!a ? a.html() : a;
+ b = !!b ? b.html() : b;
+
+ a = !!a ? a.toLowerCase() : a;
+ b = !!b ? b.toLowerCase() : b;
return dhis2.comparator.defaultComparator( a, b );
}
=== modified file 'dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/dhis2/dhis2.select.js'
--- dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/dhis2/dhis2.select.js 2011-05-31 08:21:47 +0000
+++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/dhis2/dhis2.select.js 2011-05-31 09:30:22 +0000
@@ -26,3 +26,24 @@
*/
dhis2.util.namespace( 'dhis2.select' );
+
+/**
+ * Return a hidden select with id $select + '_ghost'. This is usually used for temporary hiding options, since these
+ * can't be hidden using 'display: none' or other similar techniques.
+ *
+ * @param $select A jQuery wrapped selector
+ * @returns The ghost for a given select
+ */
+dhis2.select.getGhost = function( $select )
+{
+ var select_ghost_id = $select.attr( 'id' ) + '_ghost';
+ var $select_ghost = $( '#' + select_ghost_id );
+
+ if ($select_ghost.size() === 0) {
+ $select_ghost = $( '<select id="' + select_ghost_id + '" multiple="multiple"></select>' );
+ $select_ghost.hide();
+ $select_ghost.appendTo( 'body' );
+ }
+
+ return $select_ghost;
+}
=== 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-05-31 08:21:47 +0000
+++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/dhis2/dhis2.util.js 2011-05-31 09:30:22 +0000
@@ -48,3 +48,17 @@
return parent;
}
+
+/**
+ * adds ':containsNoCase' to filtering. $(sel).find(':containsNC(key)').doSomething();
+ */
+$.expr[":"].containsNC = function( el, i, m )
+{
+ // http://www.west-wind.com/weblog/posts/2008/Oct/24/Using-jQuery-to-search-Content-and-creating-custom-Selector-Filters
+ var search = m[3];
+
+ if (!search)
+ return false;
+
+ return eval( '/' + search + '/i' ).test( $( el ).text() );
+};
=== modified file 'dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/jQuery/jquery.dhisAjaxSelect.js'
--- dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/jQuery/jquery.dhisAjaxSelect.js 2011-05-31 08:21:47 +0000
+++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/jQuery/jquery.dhisAjaxSelect.js 2011-05-31 09:30:22 +0000
@@ -32,23 +32,6 @@
// -----------------------------------------------
// Support functions
// -----------------------------------------------
-// Array Remove - By John Resig (MIT Licensed)
-Array.remove = function(array, from, to)
-{
- var rest = array.slice((to || from) + 1 || array.length);
- array.length = from < 0 ? array.length + from : from;
- return array.push.apply(array, rest);
-};
-
-// http://www.west-wind.com/weblog/posts/2008/Oct/24/Using-jQuery-to-search-Content-and-creating-custom-Selector-Filters
-// adds :containsNoCase to filtering. $(sel).find(":containsNC(key)").do();
-$.expr[":"].containsNC = function(el, i, m)
-{
- var search = m[3];
- if (!search)
- return false;
- return eval("/" + search + "/i").test($(el).text());
-};
/* perform dblclick action on the sourceId */
function dhisAjaxSelect_moveAllSelected(sourceId)
@@ -97,29 +80,10 @@
}
}
-/**
- * Return ghost for a select. Creates it if necessary.
- *
- * @param $target jQuery object to work on
- */
-function get_ghost_for_select($target)
-{
- var ghost_target_id = $target.attr("id") + '_ghost';
- var $ghost_target = $("#" + ghost_target_id);
-
- if ($ghost_target.size() === 0) {
- $ghost_target = $('<select id="' + ghost_target_id + '" multiple="multiple"></select>');
- $ghost_target.hide();
- $ghost_target.appendTo('body');
- }
-
- return $ghost_target;
-}
-
/* filter a select-target with a given key */
function dhisAjaxSelect_filter($target, key)
{
- $ghost_target = get_ghost_for_select($target);
+ $ghost_target = dhis2.select.getGhost($target);
key = key.toLowerCase();
if (key.length === 0) {
@@ -141,7 +105,7 @@
*/
function dhisAjaxSelect_filter_on_kv($target, key, value)
{
- $ghost_target = get_ghost_for_select($target);
+ $ghost_target = dhis2.select.getGhost($target);
if (key.length === 0) {
dhisAjaxSelect_moveSorted($target, $ghost_target.children());