1// Generated by CoffeeScript 1.10.0 2 3/* 4jQuery Growl 5Copyright 2015 Kevin Sylvestre 61.3.2 7 */ 8 9(function() { 10 "use strict"; 11 var $, Animation, Growl, 12 bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; }; 13 14 $ = jQuery; 15 16 Animation = (function() { 17 function Animation() {} 18 19 Animation.transitions = { 20 "webkitTransition": "webkitTransitionEnd", 21 "mozTransition": "mozTransitionEnd", 22 "oTransition": "oTransitionEnd", 23 "transition": "transitionend" 24 }; 25 26 Animation.transition = function($el) { 27 var el, ref, result, type; 28 el = $el[0]; 29 ref = this.transitions; 30 for (type in ref) { 31 result = ref[type]; 32 if (el.style[type] != null) { 33 return result; 34 } 35 } 36 }; 37 38 return Animation; 39 40 })(); 41 42 Growl = (function() { 43 Growl.settings = { 44 namespace: 'growl', 45 duration: 3200, 46 close: "×", 47 location: "default", 48 style: "default", 49 size: "medium", 50 delayOnHover: true 51 }; 52 53 Growl.growl = function(settings) { 54 if (settings == null) { 55 settings = {}; 56 } 57 this.initialize(); 58 return new Growl(settings); 59 }; 60 61 Growl.initialize = function() { 62 return $("body:not(:has(#growls))").append('<div id="growls" />'); 63 }; 64 65 function Growl(settings) { 66 if (settings == null) { 67 settings = {}; 68 } 69 this.container = bind(this.container, this); 70 this.content = bind(this.content, this); 71 this.html = bind(this.html, this); 72 this.$growl = bind(this.$growl, this); 73 this.$growls = bind(this.$growls, this); 74 this.animate = bind(this.animate, this); 75 this.remove = bind(this.remove, this); 76 this.dismiss = bind(this.dismiss, this); 77 this.present = bind(this.present, this); 78 this.waitAndDismiss = bind(this.waitAndDismiss, this); 79 this.cycle = bind(this.cycle, this); 80 this.close = bind(this.close, this); 81 this.click = bind(this.click, this); 82 this.mouseLeave = bind(this.mouseLeave, this); 83 this.mouseEnter = bind(this.mouseEnter, this); 84 this.unbind = bind(this.unbind, this); 85 this.bind = bind(this.bind, this); 86 this.render = bind(this.render, this); 87 this.settings = $.extend({}, Growl.settings, settings); 88 this.$growls().attr('class', this.settings.location); 89 this.render(); 90 } 91 92 Growl.prototype.render = function() { 93 var $growl; 94 $growl = this.$growl(); 95 this.$growls().append($growl); 96 if (this.settings.fixed) { 97 this.present(); 98 } else { 99 this.cycle(); 100 } 101 }; 102 103 Growl.prototype.bind = function($growl) { 104 if ($growl == null) { 105 $growl = this.$growl(); 106 } 107 $growl.on("click", this.click); 108 if (this.settings.delayOnHover) { 109 $growl.on("mouseenter", this.mouseEnter); 110 $growl.on("mouseleave", this.mouseLeave); 111 } 112 return $growl.on("contextmenu", this.close).find("." + this.settings.namespace + "-close").on("click", this.close); 113 }; 114 115 Growl.prototype.unbind = function($growl) { 116 if ($growl == null) { 117 $growl = this.$growl(); 118 } 119 $growl.off("click", this.click); 120 if (this.settings.delayOnHover) { 121 $growl.off("mouseenter", this.mouseEnter); 122 $growl.off("mouseleave", this.mouseLeave); 123 } 124 return $growl.off("contextmenu", this.close).find("." + this.settings.namespace + "-close").off("click", this.close); 125 }; 126 127 Growl.prototype.mouseEnter = function(event) { 128 var $growl; 129 $growl = this.$growl(); 130 return $growl.stop(true, true); 131 }; 132 133 Growl.prototype.mouseLeave = function(event) { 134 return this.waitAndDismiss(); 135 }; 136 137 Growl.prototype.click = function(event) { 138 if (this.settings.url != null) { 139 event.preventDefault(); 140 event.stopPropagation(); 141 return window.open(this.settings.url); 142 } 143 }; 144 145 Growl.prototype.close = function(event) { 146 var $growl; 147 event.preventDefault(); 148 event.stopPropagation(); 149 $growl = this.$growl(); 150 return $growl.stop().queue(this.dismiss).queue(this.remove); 151 }; 152 153 Growl.prototype.cycle = function() { 154 var $growl; 155 $growl = this.$growl(); 156 return $growl.queue(this.present).queue(this.waitAndDismiss()); 157 }; 158 159 Growl.prototype.waitAndDismiss = function() { 160 var $growl; 161 $growl = this.$growl(); 162 return $growl.delay(this.settings.duration).queue(this.dismiss).queue(this.remove); 163 }; 164 165 Growl.prototype.present = function(callback) { 166 var $growl; 167 $growl = this.$growl(); 168 this.bind($growl); 169 return this.animate($growl, this.settings.namespace + "-incoming", 'out',
169callback); 170 }; 171 172 Growl.prototype.dismiss = function(callback) { 173 var $growl; 174 $growl = this.$growl(); 175 this.unbind($growl); 176 return this.animate($growl, this.settings.namespace + "-outgoing", 'in', callback); 177 }; 178 179 Growl.prototype.remove = function(callback) { 180 this.$growl().remove(); 181 return typeof callback === "function" ? callback() : void 0; 182 }; 183 184 Growl.prototype.animate = function($element, name, direction, callback) { 185 var transition; 186 if (direction == null) { 187 direction = 'in'; 188 } 189 transition = Animation.transition($element); 190 $element[direction === 'in' ? 'removeClass' : 'addClass'](name); 191 $element.offset().position; 192 $element[direction === 'in' ? 'addClass' : 'removeClass'](name); 193 if (callback == null) { 194 return; 195 } 196 if (transition != null) { 197 $element.one(transition, callback); 198 } else { 199 callback(); 200 } 201 }; 202 203 Growl.prototype.$growls = function() { 204 return this.$_growls != null ? this.$_growls : this.$_growls = $('#growls'); 205 }; 206 207 Growl.prototype.$growl = function() { 208 return this.$_growl != null ? this.$_growl : this.$_growl = $(this.html()); 209 }; 210 211 Growl.prototype.html = function() { 212 return this.container(this.content()); 213 }; 214 215 Growl.prototype.content = function() { 216 return "<div class='" + this.settings.namespace + "-close'>" + this.settings.close + "</div>\n<div class='" + this.settings.namespace + "-title'>" + this.settings.title + "</div>\n<div class='" + this.settings.namespace + "-message'>" + this.settings.message + "</div>"; 217 }; 218 219 Growl.prototype.container = function(content) { 220 return "<div class='" + this.settings.namespace + " " + this.settings.namespace + "-" + this.settings.style + " " + this.settings.namespace + "-" + this.settings.size + "'>\n " + content + "\n</div>"; 221 }; 222 223 return Growl; 224 225 })(); 226 227 this.Growl = Growl; 228 229 $.growl = function(options) { 230 if (options == null) { 231 options = {}; 232 } 233 return Growl.growl(options); 234 }; 235 236 $.growl.error = function(options) { 237 var settings; 238 if (options == null) { 239 options = {}; 240 } 241 settings = { 242 title: "Error!", 243 style: "error" 244 }; 245 return $.growl($.extend(settings, options)); 246 }; 247 248 $.growl.notice = function(options) { 249 var settings; 250 if (options == null) { 251 options = {}; 252 } 253 settings = { 254 title: "Notice!", 255 style: "notice" 256 }; 257 return $.growl($.extend(settings, options)); 258 }; 259 260 $.growl.warning = function(options) { 261 var settings; 262 if (options == null) { 263 options = {}; 264 } 265 settings = { 266 title: "Warning!", 267 style: "warning" 268 }; 269 return $.growl($.extend(settings, options)); 270 }; 271 272}).call(this);
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.