1// Generated by CoffeeScript 1.8.0 2 3/* 4jQuery Growl 5Copyright 2015 Kevin Sylvestre 61.2.5 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, result, type, _ref; 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: 20000, 46 close: "<span class=\"fa fa-times-thin\"></span>", 47 location: "tc", 48 style: "default", 49 size: "large" 50 }; 51 52 Growl.growl = function(settings) { 53 if (settings == null) { 54 settings = {}; 55 } 56 this.initialize(); 57 return new Growl(settings); 58 }; 59 60 Growl.initialize = function() { 61 return $("body:not(:has(#growls))").append('<div id="growls" />'); 62 }; 63 64 function Growl(settings) { 65 if (settings == null) { 66 settings = {}; 67 } 68 this.html = __bind(this.html, this); 69 this.$growl = __bind(this.$growl, this); 70 this.$growls = __bind(this.$growls, this); 71 this.animate = __bind(this.animate, this); 72 this.remove = __bind(this.remove, this); 73 this.dismiss = __bind(this.dismiss, this); 74 this.present = __bind(this.present, this); 75 this.cycle = __bind(this.cycle, this); 76 this.close = __bind(this.close, this); 77 this.unbind = __bind(this.unbind, this); 78 this.bind = __bind(this.bind, this); 79 this.render = __bind(this.render, this); 80 this.settings = $.extend({}, Growl.settings, settings); 81 this.$growls().attr('class', this.settings.location); 82 this.render(); 83 } 84 85 Growl.prototype.render = function() { 86 var $growl; 87 $growl = this.$growl(); 88 this.$growls().append($growl); 89 if (this.settings["static"] != null) { 90 this.present(); 91 } else { 92 this.cycle(); 93 } 94 }; 95 96 Growl.prototype.bind = function($growl) { 97 if ($growl == null) { 98 $growl = this.$growl(); 99 } 100 return $growl.on("contextmenu", this.close).find("." + this.settings.namespace + "-close").on("click", this.close); 101 }; 102 103 Growl.prototype.unbind = function($growl) { 104 if ($growl == null) { 105 $growl = this.$growl(); 106 } 107 return $growl.off("contextmenu", this.close).find("." + this.settings.namespace + "-close").off("click", this.close); 108 }; 109 110 Growl.prototype.close = function(event) { 111 var $growl; 112 event.preventDefault(); 113 event.stopPropagation(); 114 $growl = this.$growl(); 115 return $growl.stop().queue(this.dismiss).queue(this.remove); 116 }; 117 118 Growl.prototype.cycle = function() { 119 var $growl; 120 $growl = this.$growl(); 121 return $growl.queue(this.present).delay(this.settings.duration).queue(this.dismiss).queue(this.remove); 122 }; 123 124 Growl.prototype.present = function(callback) { 125 var $growl; 126 $growl = this.$growl(); 127 this.bind($growl); 128 return this.animate($growl, "" + this.settings.namespace + "-incoming", 'out', callback); 129 }; 130 131 Growl.prototype.dismiss = function(callback) { 132 var $growl; 133 $growl = this.$growl(); 134 this.unbind($growl); 135 return this.animate($growl, "" + this.settings.namespace + "-outgoing", 'in', callback); 136 }; 137 138 Growl.prototype.remove = function(callback) { 139 this.$growl().remove(); 140 return callback(); 141 }; 142 143 Growl.prototype.animate = function($element, name, direction, callback) { 144 var transition; 145 if (direction == null) { 146 direction = 'in'; 147 } 148 transition = Animation.transition($element);
149 $element[direction === 'in' ? 'removeClass' : 'addClass'](name); 150 $element.offset().position; 151 $element[direction === 'in' ? 'addClass' : 'removeClass'](name); 152 if (callback == null) { 153 return; 154 } 155 if (transition != null) { 156 $element.one(transition, callback); 157 } else { 158 callback(); 159 } 160 }; 161 162 Growl.prototype.$growls = function() { 163 return this.$_growls != null ? this.$_growls : this.$_growls = $('#growls'); 164 }; 165 166 Growl.prototype.$growl = function() { 167 return this.$_growl != null ? this.$_growl : this.$_growl = $(this.html()); 168 }; 169 170 Growl.prototype.html = function() { 171 return "<div class='" + this.settings.namespace + " " + this.settings.namespace + "-" + this.settings.style + " " + this.settings.namespace + "-" + this.settings.size + "'>\n <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>\n</div>"; 172 }; 173 174 return Growl; 175 176 })(); 177 178 $.growl = function(options) { 179 if (options == null) { 180 options = {}; 181 } 182 return Growl.growl(options); 183 }; 184 185 $.growl.error = function(options) { 186 var settings; 187 if (options == null) { 188 options = {}; 189 } 190 settings = { 191 title: "Error!", 192 style: "error" 193 }; 194 return $.growl($.extend(settings, options)); 195 }; 196 197 $.growl.notice = function(options) { 198 var settings; 199 if (options == null) { 200 options = {}; 201 } 202 settings = { 203 title: "Notice!", 204 style: "notice" 205 }; 206 return $.growl($.extend(settings, options)); 207 }; 208 209 $.growl.warning = function(options) { 210 var settings; 211 if (options == null) { 212 options = {}; 213 } 214 settings = { 215 title: "Warning!", 216 style: "warning" 217 }; 218 return $.growl($.extend(settings, options)); 219 }; 220 221}).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.