PageSourceSearch

https://networkdepo.com/Scripts/js/wl_Alert.js

js networkdepo.com collected 2026-10-06 22:51:48 UTC 3,206 bytes, 118 lines download raw bytes

1/*----------------------------------------------------------------------*/
2/* wl_Alert
3/* description: Handles alert boxes
4/* dependency: jquery UI Slider, fadeOutSlide plugin
5/*----------------------------------------------------------------------*/
6
7
8$.fn.wl_Alert = function (method) {
9	var args = arguments;
10	return this.each(function () {
11
12		var $this = $(this);
13
14
15		if ($.fn.wl_Alert.methods[method]) {
16			return $.fn.wl_Alert.methods[method].apply(this, Array.prototype.slice.call(args, 1));
17		} else if (typeof method === 'object' || !method) {
18			if ($this.data('wl_Alert')) {
19				var opts = $.extend({}, $this.data('wl_Alert'), method);
20			} else {
21
22				var opts = $.extend({}, $.fn.wl_Alert.defaults, method, $this.data());
23			}
24		} else {
25			$.error('Method "' + method + '" does not exist');
26		}
27
28
29		if (!$this.data('wl_Alert')) {
30
31			$this.data('wl_Alert', {});
32
33			//bind click events to hide alert box
34			$this.bind('click.wl_Alert', function (event) {
35				event.preventDefault();
36
37				//Don't hide if it is sticky
38				if (!$this.data('wl_Alert').sticky) {
39					$.fn.wl_Alert.methods.close.call($this[0]);
40				}
41
42				//prevent hiding the box if an inline link is clicked
43			}).find('a').bind('click.wl_Alert', function (event) {
44				event.stopPropagation();
45			});
46		} else {
47
48		}
49		//show it if it is hidden
50		if ($this.is(':hidden')) {
51			$this.slideDown(opts.speed / 2);
52		}
53
54		if (opts) $.extend($this.data('wl_Alert'), opts);
55	});
56
57};
58
59$.fn.wl_Alert.defaults = {
60	speed: 500,
61	sticky: false,
62	onBeforeClose: function (element) {},
63	onClose: function (element) {}
64};
65$.fn.wl_Alert.version = '1.0';
66
67
68$.fn.wl_Alert.methods = {
69	close: function () {
70		var $this = $(this),
71			opts = $this.data('wl_Alert');
72		//call callback and stop if it returns false
73		if (opts.onBeforeClose.call(this, $this) === false) {
74			return false;
75		};
76		//fadeout and call an callback
77		$this.fadeOutSlide(opts.speed, function () {
78			opts.onClose.call($this[0], $this);
79		});
80	},
81	set: function () {
82		var $this = $(this),
83			options = {};
84		if (typeof arguments[0] === 'object') {
85			options = arguments[0];
86		} else if (arguments[0] && arguments[1] !== undefined) {
87			options[arguments[0]] = arguments[1];
88		}
89		$.each(options, function (key, value) {
90			if ($.fn.wl_Alert.defaults[key] !== undefined || $.fn.wl_Alert.defaults[key] == null) {
91				$this.data('wl_Alert')[key] = value;
92			} else {
93				$.error('Key "' + key + '" is not defined');
94			}
95		});
96
97	}
98};
99
100//to create an alert box on the fly
101$.wl_Alert = function (text, cssclass, insert, after, options) {
102    //go thru all
103    
104    $('div.alert').each(function () {
105        var _this = $(this);
106        //...and hide if one with the same text is allready set
107        if (_this.text() == text) {
108            _this.slideUp($.fn.wl_Alert.defaults.speed);
109        }
110    });
111
112    //create a new DOM element and inject it
113    var al = $('<div class="alert ' + cssclass + '">
113' + text + '</div>').hide();
114    (after) ? al.appendTo(insert).wl_Alert() : al.prependTo(insert).wl_Alert(options);
115
116    //return the element
117    return al;
118};

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.