1/** 2 * Copyright ETS Software Technology Co., Ltd 3 * 4 * NOTICE OF LICENSE 5 * 6 * This file is not open source! Each license that you purchased is only available for 1 website only. 7 * If you want to use this file on more websites (or projects), you need to purchase additional licenses. 8 * You are not allowed to redistribute, resell, lease, license, sub-license or offer our resources to any third party. 9 * 10 * DISCLAIMER 11 * 12 * Do not edit or add to this file if you wish to upgrade PrestaShop to newer 13 * versions in the future. 14 * 15 * @author ETS Software Technology Co., Ltd 16 * @copyright ETS Software Technology Co., Ltd 17 * @license Valid for 1 website (or project) for each purchase of license 18 */ 19 20(function() { 21 "use strict"; 22 var $, Animation, Growl, 23 __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; }; 24 25 $ = jQuery; 26 27 Animation = (function() { 28 function Animation() {} 29 30 Animation.transitions = { 31 "webkitTransition": "webkitTransitionEnd", 32 "mozTransition": "mozTransitionEnd", 33 "oTransition": "oTransitionEnd", 34 "transition": "transitionend" 35 }; 36 37 Animation.transition = function($el) { 38 var el, result, type, _ref; 39 el = $el[0]; 40 _ref = this.transitions; 41 for (type in _ref) { 42 result = _ref[type]; 43 if (el.style[type] != null) { 44 return result; 45 } 46 } 47 }; 48 49 return Animation; 50 51 })(); 52 53 Growl = (function() { 54 Growl.settings = { 55 namespace: 'growl', 56 duration: 3200, 57 close: "×", 58 location: "default", 59 style: "default", 60 size: "medium" 61 }; 62 63 Growl.growl = function(settings) { 64 if (settings == null) { 65 settings = {}; 66 } 67 this.initialize(); 68 return new Growl(settings); 69 }; 70 71 Growl.initialize = function() { 72 return $("body:not(:has(#growls))").append('<div id="growls" />'); 73 }; 74 75 function Growl(settings) { 76 if (settings == null) { 77 settings = {}; 78 } 79 this.html = __bind(this.html, this); 80 this.$growl = __bind(this.$growl, this); 81 this.$growls = __bind(this.$growls, this); 82 this.animate = __bind(this.animate, this); 83 this.remove = __bind(this.remove, this); 84 this.dismiss = __bind(this.dismiss, this); 85 this.present = __bind(this.present, this); 86 this.close = __bind(this.close, this); 87 this.cycle = __bind(this.cycle, this); 88 this.unbind = __bind(this.unbind, this); 89 this.bind = __bind(this.bind, this); 90 this.render = __bind(this.render, this); 91 this.settings = $.extend({}, Growl.settings, settings); 92 this.$growls().attr('class', this.settings.location); 93 this.render(); 94 } 95 96 Growl.prototype.render = function() { 97 var $growl; 98 $growl = this.$growl(); 99 this.$growls().append($growl); 100 this.cycle($growl); 101 }; 102 103 Growl.prototype.bind = function($growl) { 104 if ($growl == null) { 105 $growl = this.$growl(); 106 } 107 return $growl.find("." + this.settings.namespace + "-close").on("click", this.close); 108 }; 109 110 Growl.prototype.unbind = function($growl) { 111 if ($growl == null) { 112 $growl = this.$growl(); 113 } 114 return $growl.find("." + (this.settings.namespace - close)).off("click", this.close); 115 }; 116 117 Growl.prototype.cycle = function($growl) { 118 if ($growl == null) { 119 $growl = this.$growl(); 120 } 121 return $growl.queue(this.present).delay(this.settings.duration).queue(this.dismiss).queue(this.remove); 122 }; 123 124 Growl.prototype.close = function(event) { 125 var $growl; 126 event.preventDefault(); 127 event.stopPropagation(); 128 $growl = this.$growl(); 129 return $growl.stop().queue(this.dismiss).queue(this.remove); 130 }; 131 132 Growl.prototype.present = function(callback) { 133 var $growl; 134 $growl = this.$growl(); 135 this.bind($growl); 136 return this.animate($growl, "" + this.settings.namespace + "-incoming", 'out', callback); 137 }; 138 139 Growl.prototype.dismiss = function(callback) { 140 var $growl; 141 $growl = this.$growl(); 142 this.unbind($growl); 143 return this.animate($growl, "" + this.settings.namespace + "-outgoing", 'in', callback); 144 }; 145 146 Growl.prototype.remove = function(callback) { 147 this.$growl().remove(); 148 return callback(); 149 }; 150 151 Growl.prototype.animate = function($element, name, direction, callback) { 152 var transition; 153 if (direction == null) { 154 direction = 'in'; 155 } 156 transition = Animation.transition($element);
157 $element[direction === 'in' ? 'removeClass' : 'addClass'](name); 158 $element.offset().position; 159 $element[direction === 'in' ? 'addClass' : 'removeClass'](name); 160 if (callback == null) { 161 return; 162 } 163 if (transition != null) { 164 $element.one(transition, callback); 165 } else { 166 callback(); 167 } 168 }; 169 170 Growl.prototype.$growls = function() { 171 return this.$_growls != null ? this.$_growls : this.$_growls = $('#growls'); 172 }; 173 174 Growl.prototype.$growl = function() { 175 return this.$_growl != null ? this.$_growl : this.$_growl = $(this.html()); 176 }; 177 178 Growl.prototype.html = function() { 179 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>"; 180 }; 181 182 return Growl; 183 184 })(); 185 186 $.growl = function(options) { 187 if (options == null) { 188 options = {}; 189 } 190 return Growl.growl(options); 191 }; 192 193 $.growl.error = function(options) { 194 var settings; 195 if (options == null) { 196 options = {}; 197 } 198 settings = { 199 title: "Error!", 200 style: "error" 201 }; 202 return $.growl($.extend(settings, options)); 203 }; 204 205 $.growl.notice = function(options) { 206 var settings; 207 if (options == null) { 208 options = {}; 209 } 210 settings = { 211 title: "Notice!", 212 style: "notice" 213 }; 214 return $.growl($.extend(settings, options)); 215 }; 216 217 $.growl.warning = function(options) { 218 var settings; 219 if (options == null) { 220 options = {}; 221 } 222 settings = { 223 title: "Warning!", 224 style: "warning" 225 }; 226 return $.growl($.extend(settings, options)); 227 }; 228 229}).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.