get_text counterpart of set_text. abstracts away the widget type involved
authorphasefx <phasefx@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Thu, 24 Sep 2009 01:34:37 +0000 (01:34 +0000)
committerphasefx <phasefx@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Thu, 24 Sep 2009 01:34:37 +0000 (01:34 +0000)
git-svn-id: svn://svn.open-ils.org/ILS/trunk@14136 dcc99617-32d9-48b4-a31d-7c20da2025e4

Open-ILS/xul/staff_client/chrome/content/util/widgets.js

index 259add0..74681cf 100644 (file)
@@ -318,6 +318,30 @@ util.widgets.set_text = function(n,t) {
        }
 }
 
+util.widgets.get_text = function(n) {
+       n = util.widgets.get(n);
+       switch(n.nodeName) {
+               case 'button' :
+               case 'caption' :
+                       return n.getAttribute('label');
+               break;
+               case 'label' : 
+                       return n.getAttribute('value'); 
+               break;
+               case 'description' : 
+               case 'H1': case 'H2': case 'H3': case 'H4': case 'SPAN': case 'P': case 'BLOCKQUOTE':
+                       return n.textContent;
+               break;
+               case 'textbox' :
+                       return n.value;
+               break;
+               default:
+                       alert("FIXME: util.widgets.get_text doesn't know how to handle " + n.nodeName);
+            return null;
+               break;
+       }
+}
+
 util.widgets.save_attributes = function (file,ids_attrs) {
        try {
                var blob = {};