js helper function 'get_value' not defined globally anymore, use unfold.get_velue...
[myslice.git] / unfold / static / js / unfold-helper.js
1 // various UI oriented utilities
2 var unfold = {
3     debug_dom: function (msg,dom,maxdepth) {
4         if (maxdepth===undefined) maxdepth=5;
5         var up=null, counter=0;
6         while (true) {
7             messages.debug(counter+" "+msg+" id='"+dom.id+"' ["+dom.classList+"]");
8             up=dom.parentNode;
9             counter += 1;
10             if ( (up == null) || (up === dom)) break;
11             if (counter >= maxdepth) { messages.debug(counter+" "+msg+" -> ..."); break; }
12             dom=up;
13         }
14     },
15
16     warning:function(text){ 
17         return "<button class='unfold-warning btn btn-warning'>"+text+"</button>"; 
18     },
19     error : function(text){ 
20         return "<button class='unfold-error btn btn-danger'>"+text+"</button>"; 
21     },
22
23     get_value: function (value) {
24         //if(typeof(jQuery(value).attr('value'))!="undefined"){
25         if (/<span value=['"].*['"]>.*<\/span>/i.test(value)) {
26             return jQuery(value).attr('value');
27         } else {
28             return value;
29         }
30     }
31
32 } // global unfold
33