Changeset 347 in t29-www for shared/js-v6
- Timestamp:
- Mar 6, 2013, 3:58:15 AM (11 years ago)
- Location:
- shared/js-v6/modules
- Files:
-
- 1 added
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
shared/js-v6/modules/log.js
r260 r347 1 1 /** 2 * Logging functions, basics provided by HTML5 Boilerplate 2 * t29v6 Logging subsystem 3 * 4 * Logging on client side is splitted in two parts: 5 * 1. Javascript console.log calls which won't offend the user 6 * 2. the t29.log class to notify the user. 7 * 8 * Considering console.log, the code is borrowed by HTML5 Boilerplate 9 * 3 10 * 4 11 **/ … … 20 27 {console.log();return window.console;}catch(err){return window.console={};}})()); 21 28 29 30 if(!t29) window.t29 = {}; // the t29 namespace 31 t29.log = {}; // the t29.log namespace 32 33 t29.log.setup = function() { 34 // setup our spaces 35 t29.log.$panel = $(".messages.panel"); 36 t29.log.$end = $(".messages.footer"); 37 38 // find end messages and push them to the first 39 if((end_li = t29.log.$end.find("li")).length) { 40 end_li.appendTo(t29.log.$panel); 41 t29.log.$end.hide(); // hide bottom panel 42 t29.log.$panel.removeClass("empty"); // show top panel 43 } 44 45 // setup some functions 46 levels = ["emerg", "alert", "crit", "error", "warn", "notice", "info"]; 47 $.each(levels, function() { 48 level = this; 49 t29.log[level] = function(msg) { t29.log.append(level, msg) } 50 }); 51 } 52 53 t29.log.append = function(level, msg) { 54 // tell the panel that it's now not empty (thus it will become CSS visible) 55 t29.log.$panel.removeClass("empty"); 56 57 if(jQuery.type(msg) == "string") 58 s = msg; 59 else { 60 s = ""; 61 if(msg.dismissable) s += "<button class='close'>×</button>"; 62 if(msg.heading) s += "<h5>"+msg.heading+"</h5>"; 63 if(msg.text) s += "<p>"+msg.text+"</p>"; 64 } 65 infoelement = $("<li>", {"class": level}).html(s).hide().appendTo(t29.log.$panel).slideDown(); 66 67 // fill eventual close button with action 68 $(infoelement).find("button.close").click(function(){ 69 $(this).closest("li").slideUp(); 70 }); 71 } -
shared/js-v6/modules/startup.js
r306 r347 20 20 'img_license', 21 21 'lightbox', 22 'log', 22 23 23 24 // ganz am anfang 24 25 'prefs', 26 27 // needs log, t29msg 28 'interlang', 25 29 26 30 // needs prefs
Note: See TracChangeset
for help on using the changeset viewer.