-
Notifications
You must be signed in to change notification settings - Fork 19
/
Copy pathgevent_test.html
82 lines (66 loc) · 2.46 KB
/
gevent_test.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
<!doctype html>
<html>
<head>
<!-- ie9+ rendering support for latest standards -->
<meta http-equiv="Content-Type" content="text/html;
charset=ISO-8859-1">
<meta http-equiv="X-UA-Compatible" content="IE=edge"/>
<title>jQuery global custom event plugin tests</title>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script src="jquery.event.gevent.js"></script>
<script>
/*jslint browser : true, continue : true,
devel : true, indent : 2, maxerr : 50,
newcap : true, nomen : true, plusplus : true,
regexp : true, sloppy : true, vars : false,
white : true
*/
/*global $ */
var showEvent1, showEvent2, showEvent3, showEvent4;
showEvent1 = function ( event ){
console.log( 'e1 event published', arguments );
};
showEvent2 = function ( event ){
console.log( 'e2 event published', arguments );
};
showEvent3 = function ( event ){
console.log( 'e3 event published', arguments );
};
showEvent4 = function ( event ){
console.log( 'e4 event published', arguments );
};
$( document ).ready( function(){
$.gevent.subscribe( $( '#div1' ), 'e1', showEvent1 );
$.gevent.subscribe( $( '#div2' ), 'e2', showEvent2 );
$.gevent.subscribe( $( '#div3' ), 'e3', showEvent3 );
$.gevent.subscribe( $( '#div4a' ), 'e4', showEvent4 );
$.gevent.subscribe( $( '#div4b' ), 'e4', showEvent4 );
$.gevent.subscribe( $( '#div4c' ), 'e4', showEvent4 );
$.gevent.publish( 'e1' );
$.gevent.publish( 'e2', [ 'fred' ] );
$.gevent.publish( 'e3', [ 'barney', { barney : 'male' } ] );
console.log( '\n>>> should show 3' );
$.gevent.publish( 'e4', [ 'wilma', { wilma : 'female' } ] );
$.gevent.unsubscribe( $( '#div4a' ), 'e4' );
console.log( '\n>>> should show 2' );
$.gevent.publish( 'e4', [ 'should show 2', { wilma : 'female' } ] );
$.gevent.unsubscribe( $( '#div4b' ), 'e4' );
console.log( '\n>>> should show 1' );
$.gevent.publish( 'e4', [ 'should show 1', { wilma : 'female' } ] );
$.gevent.unsubscribe( $( '#div4c' ), 'e4' );
console.log( '\n>>> should show 0' );
$.gevent.publish( 'e4', [ 'should not show', { wilma : 'female' } ] );
});
</script>
</head>
<body>
<div id="spa">
<div id="div1"></div>
<div id="div2"></div>
<div id="div3"></div>
<div id="div4a"></div>
<div id="div4b"></div>
<div id="div4c"></div>
</div>
</body>
</html>