1/* 2 * notifIt! by @naoxink 3 */ 4function notif(config) { 5 var to = null; 6 var defaults = { 7 type: "info", 8 width: 320, 9 height: 60, 10 position: "right", 11 autohide: 1, 12 msg: "This is my default message", 13 opacity: 1, 14 multiline: 1, 15 fade: 0, 16 bgcolor: "", 17 color: "", 18 timeout: 15000 19 }; 20 $.extend(defaults, config); 21 22 position = defaults.position; 23 24 if (defaults.width > 0) { 25 defaults.width = defaults.width; 26 } else if (defaults.width === "all") { 27 defaults.width = screen.width - 60; 28 } 29 30 if (defaults.height < 100 && defaults.height > 0) { 31 height = defaults.height; 32 } 33 34 var div = "<div id='ui_notifIt'><p>" + defaults.msg + "</p></div>"; 35 $("#ui_notifIt").remove(); 36 clearInterval(to); 37 $("body").append(div); 38 39 40 if (defaults.multiline) { 41 $("#ui_notifIt").css("padding", 15); 42 } else { 43 $("#ui_notifIt").css("height", height); 44 $("#ui_notifIt p").css("line-height", height + "px"); 45 } 46 47 $("#ui_notifIt").css("width", defaults.width); 48 49 $("#ui_notifIt").css("opacity", defaults.opacity); 50 51 switch (defaults.type) { 52 case "error": 53 $("#ui_notifIt").addClass("error"); 54 break; 55 case "success": 56 $("#ui_notifIt").addClass("success"); 57 break; 58 case "info": 59 $("#ui_notifIt").addClass("info"); 60 break; 61 case "warning": 62 $("#ui_notifIt").addClass("warning"); 63 break; 64 default: 65 $("#ui_notifIt").addClass("default"); 66 break; 67 } 68 69 $("#ui_notifIt").css("background-color", defaults.bgcolor); 70 71 $("#ui_notifIt").css("color", defaults.color); 72 73 switch (defaults.position) { 74 case "left": 75 $("#ui_notifIt").css("left", parseInt(0 - (defaults.width + 10))); 76 $("#ui_notifIt").css("left", parseInt(0 - (defaults.width * 2))); 77 $("#ui_notifIt").animate({left: 10}); 78 break; 79 case "right": 80 $("#ui_notifIt").css("right", parseInt(0 - (defaults.width + 10))); 81 $("#ui_notifIt").css("right", parseInt(0 - (defaults.width * 2))); 82 $("#ui_notifIt").animate({right: 10}); 83 break; 84 case "center": 85 var mid = window.innerWidth / 2; 86 $("#ui_notifIt").css("top", parseInt(0 - (defaults.height + 10))); 87 $("#ui_notifIt").css("left", mid - parseInt(defaults.width / 2)); 88 $("#ui_notifIt").animate({top: 10}); 89 break; 90 default: 91 var mid = window.innerWidth / 2; 92 $("#ui_notifIt").css("right", parseInt(0 - (defaults.width + 10))); 93 $("#ui_notifIt").css("left", mid - parseInt(defaults.width / 2)); 94 $("#ui_notifIt").animate({right: 10}); 95 break; 96 } 97 98 $("#ui_notifIt").click(function() { 99 notifit_dismiss(to, defaults); 100 }); 101 102 if (defaults.autohide) { 103 if (!isNaN(defaults.timeout)) { // Take the timeout if is a number 104 to = setTimeout(function() { 105 $("#ui_notifIt").click(); 106 }, defaults.timeout); 107 } 108 109 } 110} 111 112function notifit_dismiss(to, config) { 113 clearInterval(to); 114 if (!config.fade) { 115 switch(config.position){ 116 case "center": 117 $("#ui_notifIt").animate({ 118 top: parseInt(config.height - (config.height / 2)) 119 }, 100, function() { 120 $("#ui_notifIt").animate({ 121 top: parseInt(0 - (config.height * 2)) 122 }, 100, function() { 123 $("#ui_notifIt").remove(); 124 }); 125 }); 126 break; 127 case "right": 128 $("#ui_notifIt").animate({ 129 right: parseFloat(config.width - (config.width * 0.9)) 130 }, 100, function() { 131 $("#ui_notifIt").animate({ 132 right: parseInt(0 - (config.width * 2)) 133 }, 100, function() { 134 $("#ui_notifIt").remove(); 135 }); 136 }); 137 break;
138 case "left": 139 $("#ui_notifIt").animate({ 140 left: parseFloat(config.width - (config.width * 0.9)) 141 }, 100, function() { 142 $("#ui_notifIt").animate({ 143 left: parseInt(0 - (config.width * 2)) 144 }, 100, function() { 145 $("#ui_notifIt").remove(); 146 }); 147 }); 148 break; 149 } 150 } else { 151 $("#ui_notifIt").fadeOut("slow", function() { 152 $("#ui_notifIt").remove(); 153 }); 154 } 155}
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.