PageSourceSearch

https://www.hirosaki-u.ac.jp/wp-content/themes/hirosaki-univ/js/jquery.accessible.js

js hirosaki-u.ac.jp collected 2026-09-24 09:03:10 UTC 3,275 bytes, 95 lines download raw bytes

1/**
2 * jquery.accessible
3 * Description: フォントサイズ変更機能、色反転機能を実装
4 * Version: 1.0.0
5 * Author: Takashi Kitajima
6 * Autho URI: http://2inc.org
7 * created : February 8, 2014
8 * modified:
9 * License: GPL2
10 *
11 * Copyright 2014 Takashi Kitajima (email : [email protected])
12 *
13 * This program is free software; you can redistribute it and/or modify
14 * it under the terms of the GNU General Public License, version 2, as
15 * published by the Free Software Foundation.
16 *
17 * This program is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
20 * GNU General Public License for more details.
21 *
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, write to the Free Software
24 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
25 */
26( function( $ ) {
27	$.fn.accessible_fontsize = function( config ) {
28		var defaults = {
29			base_font_size: 13, // 標準文字サイズ
30			normal_btn_id : '#fontsize-normal', // 標準ボタンのID名
31			enlarge_btn_id: '#fontsize-enlarge' // 拡大ボタンのID名
32		};
33		var config = $.extend( defaults, config );
34
35		var saved_font_size = $.cookie( 'fontsize' );
36		var now_font_size =  ( saved_font_size ) ? saved_font_size : config.base_font_size;
37		$( 'body' ).css( 'fontSize', now_font_size + 'px' );
38
39		var methods = {
40			change_body_font_size: function( _fontsize ) {
41				$( 'body' ).css( 'fontSize', _fontsize + 'px' );
42				$.cookie( 'fontsize', _fontsize, { expires: 1, path: '/' } );
43			}
44		};
45
46		return this.each( function( i, e ) {
47			$( e ).find( config.normal_btn_id ).click( function() {
48				now_font_size = config.base_font_size;
49				methods.change_body_font_size( now_font_size );
50			} );
51			$( e ).find( config.enlarge_btn_id ).click( function() {
52				now_font_size = parseInt( now_font_size ) + 1;
53				methods.change_body_font_size( now_font_size );
54			} );
55		} );
56	};
57
58	$.fn.accessible_inverse = function( config ) {
59		var defaults = {
60			inverse_class: 'default', // 反転を判別するclass名 ( inverse-default )
61			target : 'body *' // 反転する対象 ( eg: div, a, #contents )
62		};
63		var config = $.extend( defaults, config );
64
65		var methods = {
66			invert_color: function() {
67				var is_inverted_color = $.cookie( 'is_inverted_color' );
68				if ( is_inverted_color === config.inverse_class ) {
69					methods.remove_inverse_class();
70					$( config.target ).addClass( 'inverse-' + config.inverse_class );
71				}
72			},
73			remove_inverse_class: function() {
74				$( config.target ).removeClass( function ( index, css ) {
75					return ( css.match (/\binverse-\S+/g) || [] ).join( ' ' );
76				} );
77			}
78		};
79
80		methods.invert_color();
81
82		return this.each( function( i, e ) {
83			$( e ).click( function() {
84				var is_inverted_color = $.cookie( 'is_inverted_color' );
85				if ( is_inverted_color !== config.inverse_class ) {
86					$.cookie( 'is_inverted_color', config.inverse_class, { expires: 1, path: '/' } );
87				} else {
88					$.cookie( 'is_inverted_color', 'false', { expires: 1, path: '/' } );
89					methods.remove_inverse_class();
90				}
91				methods.invert_color();
92			} );
93		} );
94	};
95} )( jQuery );

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.