fixed hazelnut checkbox management
[myslice.git] / unfold / 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     errorDisplay : function (error) {
24         return '<div class="error"><dl id="system-message"><dt class="error">Notice</dt><dd class="error message"><ul><li>' + error + '</li></ul></dd></dl></div>';
25     },
26
27     get_value: function (value) {
28         //if(typeof(jQuery(value).attr('value'))!="undefined"){
29         if (/<span value=['"].*['"]>.*<\/span>/i.test(value)) {
30             return jQuery(value).attr('value');
31         } else {
32             return value;
33         }
34     },
35
36     escape_id: function(id) {
37         return id.replace( /(:|\.|\[|\])/g, "\\$1" );
38     }
39
40 } // global unfold
41
42 // xxx tmp - until all plugins are ported
43 errorDisplay    = unfold.errorDisplay;
44 get_value       = unfold.get_value;