File: show_and_hide.js

package info (click to toggle)
tdiary-contrib 5.0.2-2
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 2,576 kB
  • ctags: 1,957
  • sloc: ruby: 16,900; lisp: 514; xml: 451; php: 61; sql: 40; sh: 35; makefile: 33
file content (39 lines) | stat: -rw-r--r-- 1,076 bytes parent folder | download | duplicates (2)
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
/*
 * show_and_hide.js : javascript for show_and_hide.rb plugin of tDiary
 *
 * Copyright (C) 2011 by tamoot <tamoot+tdiary@gmail.com>
 * You can distribute it under GPL.
 */

$( function() {
	
	function show_and_hide(target) {
		$('.show_and_hide_toggle', target).each( function() {
			$(this).click( function() {
				$('.show_and_hide#'+$(this).attr('data-showandhideid')).slideToggle(400);
			});
		});
	};
	
	// for AutoPagerize
	$(window).bind('AutoPagerize_DOMNodeInserted', function(event) {
		show_and_hide(event.target);
	});
	
	// for AuthPatchWork
	// NOTE: jQuery.bind() cannot handle an event that include a dot charactor.
	// see http://todayspython.blogspot.com/2011/06/autopager-autopagerize.html
	if(window.addEventListener) {
		window.addEventListener('AutoPatchWork.DOMNodeInserted', function(event) {
			show_and_hide(event.target);
		}, false);
	} else if(window.attachEvent) {
		window.attachEvent('onAutoPatchWork.DOMNodeInserted', function(event) {
			show_and_hide(event.target);
		});
	};
	
	show_and_hide(document)
	$('.show_and_hide').hide();
});