PageSourceSearch

https://www.cau.ac.kr/cau/js/jquery.font-accessibility.dev.js

js cau.ac.kr collected 2026-09-24 08:43:14 UTC 6,682 bytes, 213 lines download raw bytes

1(function($){
2	$.fn.easyView = function(option, value){
3		var selector = $(this.selector);
4
5		if(typeof selector.data('easyView') == 'undefined'){
6			/* First execution */
7			if(typeof option == 'string'){
8				option = {};
9			}
10
11			var plugin = {
12				selector: selector,
13				currentRatio: 100,
14				normalContrast: true,
15				defaults: {
16					container: 'body',
17					tags: ['h1','h2','h3','h4','h5','h6', 'div', 'p', 'a', 'span', 'strong', 'em', 'ul', 'ol', 'li', 'dt', 'dd'],
18					step: 10,
19					bootstrap: true,
20					defaultMarkup: '<a href="#decrease" class="decrease-text">Decrease font size</a><a href="#normal" class="reset-text">Normal font size</a><a href="#increase" class="increase-text">Increase font size</a><a href="#contrast" class="contrast-text">Change contrast</a>',
21					increaseSelector: '.increase-text',
22					decreaseSelector: '.decrease-text',
23					normalSelector: '.reset-text',
24					contrastSelector: '.contrast-text'
25				},
26				options: {},
27				affectedTags: new Array(),
28				mergeOptions: function(option){
29					$.extend(this.options, this.defaults, option)
30				},
31				storeDefaults: function(){
32					/* Store default values for each elements */
33					$.each(this.affectedTags, function(elIndex, elValue){
34						$(elValue).each(function(){
35							var current_tag = $(this);
36							var font_size = current_tag.css('font-size');
37
38							if(font_size.indexOf('%') > -1){
39								/* Percentage */
40								current_tag.data('originalSize', parseInt(font_size.replace('%','')));
41								current_tag.data('originalUnit', '%');
42							} else {
43								/* Other units */
44								current_tag.data('originalSize', parseInt(font_size.replace(font_size.substr(-2),'')));
45								current_tag.data('originalUnit', font_size.substr(-2));
46							}
47
48							current_tag.data('originalBackground', current_tag.css('background-color'));
49							current_tag.data('originalColor', current_tag.css('color'));
50						});
51					});
52
53					/* Container default values */
54					$(this.options.container).data('originalBackground', $(this.options.container).css('background-color'));
55					$(this.options.container).data('originalColor', $(this.options.container).css('color'));
56				},
57				createDefaultMarkup: function(){
58					/* Create a default markup */
59					if(selector.html() == ''){
60						selector.html(this.options.defaultMarkup);
61					}
62				},
63				setActions: function(){
64					var self = this;
65
66					/* Decrease font size */
67					selector.find(this.options.decreaseSelector).click(function(ev){
68						ev.preventDefault();
69						self.decreaseFont();
70					});
71
72					/* Reset font size */
73					selector.find(this.options.normalSelector).click(function(ev){
74						ev.preventDefault();
75						self.resetFont();
76					});
77
78					/* Increase font size */
79					selector.find(this.options.increaseSelector).click(function(ev){
80						ev.preventDefault();
81						self.increaseFont();
82					});
83
84					/* Change text contrast */
85					selector.find(this.options.contrastSelector).click(function(ev){
86						ev.preventDefault();
87						self.changeContrast();
88					});
89				},
90				fetchTags: function(){
91					/* Fetching all tags to work */
92					var affectedTags = this.affectedTags;
93					var options = this.options;
94					$.each(this.options.tags, function(i, v){
95						affectedTags.push(options.container+" "+v);
96					});
97				},
98				decreaseFont: function(){
99					if((this.currentRatio - this.options.step) >= 10){
100						this.currentRatio = this.currentRatio - this.options.step;
101					}
102					this.changeFontSize();
103				},
104				resetFont: function(){
105					/* Set default ratio */
106					this.currentRatio = 100;
107					this.changeFontSize();
108				},
109				increaseFont: function(){
110					this.currentRatio = this.currentRatio + this.options.step;
111					this.changeFontSize();
112				},
113				changeFontSize: function(ratio){
114					if(typeof ratio != 'undefined' && parseInt(ratio) > 10){
115						this.currentRatio = ratio;
116					}
117
118					var current_ratio = this.currentRatio;
119
120					$.each(this.affectedTags, function(elIndex, elValue){
121						$(elValue).each(function(){
122							var current_tag = $(this);
123							current_tag.css('font-size', (current_tag.data('originalSize')*(current_ratio/100))+current_tag.data('originalUnit'));
124						});
125					});
126				},
127				changeContrast: function(){
128
129				    //const normalContrast = this.normalContrast;
130					$(this.affectedTags.join(',')).each(function(){
131						//const current_tag = $(this);
132
133						normalContrast ? current_tag.css('color', '#fff') : current_tag.css('color', current_tag.data('originalColor'));
134					});
135
136					$(this.options.container).css('color', this.normalContrast ? '#fff' : $(this.options.container).data('originalColor'));
137					$(this.options.container).css('background-color', this.normalContrast ? '#000' : $(this.options.container).data('originalBackground'));
138
139                    this.normalContrast = !this.normalContrast;
140				},
141				startPlugin: function(option){
142					this.mergeOptions(option);
143					this.fetchTags();
144					this.storeDefaults();
145					this.createDefaultMarkup();
146					this.setActions();
147				},
148				executeFunction: function(function_name, value){
149					switch(function_name){
150						case 'decrease':
151								this.decreaseFont();
152							break;
153						case 'reset':
154								this.resetFont();
155							break;
156						case 'increase':
157								this.increaseFont();
158							break;
159						case 'contrast':
160								if(typeof value != 'undefined'){
161									/* Change to specified value - true or false */
162									if(value){
163										/* Setting true, contrast will be applied */
164										this.normalContrast = true;
165									} else {
166										/* Setting false, will remove contrast */
167										this.normalContrast = false;
168									}
169								}
170
171								this.changeContrast();
172							break;
173						case 'setRatio':
174								this.changeFontSize(ratio);
175							break;
176						default:
177								alert("Called function does not exist!");
178							break;
179					}
180				},
181				destroy: function(){
182					/* Back all fonts to default size */
183					this.resetFont();
184
185					/* Remove contrast change */
186					this.normalContrast = false;
187					this.changeContrast();
188
189					/* Remove plugin data */
190					selector.removeData('easyView');
191				}
192			};
193
194			plugin.startPlugin(option);
195
196			/* Store plugin instance */
197			selector.data('easyView', plugin);
198		} else {
199			/* Plugin is already initialized, execute existing function */
200			var plugin = selector.data('easyView');
201			if(typeof option == 'object'){
202				/* Restart plugin */
203				plugin.destroy();
204				plugin.startPlugin(option);
205			} else if(typeof option == 'string') {
206				/* Execute specific function */
207				plugin.executeFunction(option, value);
208			} else {
209				alert("Invalid params to start");
210			}
211		}
212	}
213}(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.