manifold-core deprecated, keep its -leftovers for further ref
[unfold.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             console.log(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) { console.log(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     return out;
26     },
27
28     get_value: function (value) {
29     //if(typeof(jQuery(value).attr('value'))!="undefined"){
30     if (/<span value=['"].*['"]>.*<\/span>/i.test(value)) {
31         return jQuery(value).attr('value');
32     } else {
33         return value;
34     }
35 }
36
37 } // global unfold
38
39 // xxx tmp - until all plugins are ported
40 errorDisplay    = unfold.errorDisplay;
41 get_value       = unfold.get_value;