Changeset 3429998
- Timestamp:
- 12/31/2025 09:03:23 AM (8 weeks ago)
- Location:
- adjust-accessibility/trunk
- Files:
-
- 4 edited
-
adjust-accessibility.php (modified) (31 diffs)
-
assets/css/accessibility.tailwind.css (modified) (1 diff)
-
assets/js/accessibility.js (modified) (2 diffs)
-
readme.txt (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
adjust-accessibility/trunk/adjust-accessibility.php
r3426598 r3429998 15 15 } 16 16 17 // Run activation to set up defaults.18 17 register_activation_hook( __FILE__, [ 'Adjst_Acsiblty', 'activate' ] ); 19 18 20 19 class Adjst_Acsiblty { 20 21 private static $rendered = false; 21 22 22 23 public function __construct() { … … 24 25 add_action( 'wp_enqueue_scripts', [ $this, 'adjst_acsiblty_enqueue_styles' ] ); 25 26 add_action( 'wp_enqueue_scripts', [ $this, 'adjst_acsiblty_enqueue_assets' ] ); 27 28 // Render in footer (most themes) + body open (some builders/themes) 29 add_action( 'wp_body_open', [ $this, 'adjst_acsiblty_render_panel' ] ); 26 30 add_action( 'wp_footer', [ $this, 'adjst_acsiblty_render_panel' ] ); 31 27 32 add_action( 'admin_menu', [ $this, 'add_admin_menu' ] ); 28 33 add_action( 'admin_init', [ $this, 'adjst_acsiblty_register_settings' ] ); … … 31 36 } 32 37 33 /**34 * On plugin activation, ensure defaults.35 */36 38 public static function activate() { 37 39 if ( get_option( 'adjst_acsiblty_primary_color' ) === false ) { 38 40 add_option( 'adjst_acsiblty_primary_color', '#0073aa' ); 39 41 } 40 41 42 if ( get_option( 'adjst_acsiblty_enabled_features' ) === false ) { 42 43 add_option( 'adjst_acsiblty_enabled_features', [ 'brightness' ] ); 43 44 } 44 }45 46 /**47 * Load text domain for translations.48 */ 45 if ( get_option( 'adjst_acsiblty_settings' ) === false ) { 46 add_option( 'adjst_acsiblty_settings', [ 'desktop_enabled' => 1, 'mobile_enabled' => 1 ] ); 47 } 48 } 49 49 50 public function load_textdomain() { 50 51 load_plugin_textdomain( … … 55 56 } 56 57 57 /**58 * Enqueue color picker assets on correct admin page.59 */60 58 public function enqueue_color_picker_assets( $hook_suffix ) { 61 59 if ( $hook_suffix !== 'toplevel_page_adjst_acsiblty_settings' ) { 62 60 return; 63 61 } 64 65 62 wp_enqueue_style( 'wp-color-picker' ); 66 63 wp_enqueue_script( 'wp-color-picker' ); 67 68 64 wp_enqueue_script( 69 65 'adjst_acsiblty_color_picker_init', … … 75 71 } 76 72 77 /**78 * Enqueue admin CSS on every admin page.79 */80 73 public function adjst_acsiblty_enqueue_admin_styles() { 81 74 wp_enqueue_style( … … 87 80 } 88 81 89 /**90 * Front-end main CSS (Tailwind compiled).91 */92 93 94 // public function adjst_acsiblty_enqueue_styles() {95 // $css_file = plugin_dir_path( __FILE__ ) . 'assets/css/accessibility.tailwind.css';96 97 // wp_enqueue_style(98 // 'adjst_acsiblty_front',99 // plugin_dir_url( __FILE__ ) . 'assets/css/accessibility.tailwind.css',100 // [],101 // file_exists( $css_file ) ? filemtime( $css_file ) : '1.0.0'102 // );103 // }104 105 106 82 public function adjst_acsiblty_enqueue_styles() { 107 $css_file = plugin_dir_path(__FILE__) . 'assets/css/accessibility.tailwind.css'; 108 109 wp_enqueue_style( 110 'adjst_acsiblty_front', 111 plugin_dir_url(__FILE__) . 'assets/css/accessibility.tailwind.css', 112 [], 113 filemtime( $css_file ) 114 ); 115 116 // ✅ INLINE CSS MUST BE HERE 117 $primary = get_option( 'adjst_acsiblty_primary_color', '#0073aa' ); 118 wp_add_inline_style( 119 'adjst_acsiblty_front', 120 ":root { --aa-primary-color: " . esc_attr( $primary ) . "; }" 121 ); 122 } 123 124 125 /** 126 * Front-end JS + Font Awesome + inline CSS vars. 127 */ 83 $css_file = plugin_dir_path(__FILE__) . 'assets/css/accessibility.tailwind.css'; 84 85 wp_enqueue_style( 86 'adjst_acsiblty_front', 87 plugin_dir_url(__FILE__) . 'assets/css/accessibility.tailwind.css', 88 [], 89 file_exists( $css_file ) ? filemtime( $css_file ) : '1.0.0' 90 ); 91 92 $primary = get_option( 'adjst_acsiblty_primary_color', '#0073aa' ); 93 wp_add_inline_style( 94 'adjst_acsiblty_front', 95 ":root { --aa-primary-color: " . esc_attr( $primary ) . "; }" 96 ); 97 } 98 128 99 public function adjst_acsiblty_enqueue_assets() { 129 // Local Font Awesome CSS (no CDN).130 100 wp_enqueue_style( 131 101 'adjst_acsiblty_fontawesome', … … 135 105 ); 136 106 137 // Plugin JS.138 107 wp_enqueue_script( 139 108 'adjst_acsiblty_script', … … 144 113 ); 145 114 146 // Inject primary color as a CSS variable onto the main front stylesheet.147 $primary = get_option( 'adjst_acsiblty_primary_color', '#0073aa' );148 149 // wp_add_inline_style(150 // 'adjst_acsiblty_front',151 // ':root { --aa-primary-color: ' . esc_attr( $primary ) . '; }'152 // );153 154 // Pass enabled features & device flags to JS; defaults if none saved.155 115 $enabled = get_option( 'adjst_acsiblty_enabled_features', [ 'brightness' ] ); 156 116 $opts = get_option( 157 117 'adjst_acsiblty_settings', 158 [ 159 'desktop_enabled' => 1, 160 'mobile_enabled' => 1, 161 ] 118 [ 'desktop_enabled' => 1, 'mobile_enabled' => 1 ] 162 119 ); 163 120 … … 173 130 } 174 131 175 /**176 * Render the front-end accessibility panel.177 */178 132 public function adjst_acsiblty_render_panel() { 133 134 // Prevent double output (because we hook wp_body_open + wp_footer) 135 if ( self::$rendered ) { 136 return; 137 } 138 self::$rendered = true; 139 179 140 $opts = get_option( 180 141 'adjst_acsiblty_settings', 181 [ 182 'desktop_enabled' => 1, 183 'mobile_enabled' => 1, 184 ] 185 ); 186 187 // Device visibility checks. 188 if ( wp_is_mobile() && empty( $opts['mobile_enabled'] ) ) { 189 return; 190 } 191 192 if ( ! wp_is_mobile() && empty( $opts['desktop_enabled'] ) ) { 193 return; 194 } 195 196 // Features to output; default to ['brightness']. 142 [ 'desktop_enabled' => 1, 'mobile_enabled' => 1 ] 143 ); 144 145 if ( wp_is_mobile() && empty( $opts['mobile_enabled'] ) ) return; 146 if ( ! wp_is_mobile() && empty( $opts['desktop_enabled'] ) ) return; 147 197 148 $enabled = get_option( 'adjst_acsiblty_enabled_features', [ 'brightness' ] ); 198 149 … … 203 154 <div class="aa-wrap"> 204 155 <div id="aa-panel" class="aa-panel aa-pos-<?php echo esc_attr( $pos ); ?>"> 205 <button id="aa-toggle" class="aa-toggle" >156 <button id="aa-toggle" class="aa-toggle" type="button" aria-label="Accessibility"> 206 157 <img src="<?php echo esc_url( plugin_dir_url( __FILE__ ) . 'assets/img/accessibility.png' ); ?>" alt=""> 207 158 </button> 208 159 </div> 160 209 161 <div id="aa-panel-main" class="aa-panel-main aa-pos-<?php echo esc_attr( $pos ); ?>"> 210 162 <div class="aa-header"> … … 213 165 </div> 214 166 <div class="aa-header-rt"> 215 <button id="aa-clear" class="aa-clear" aria-label="<?php esc_attr_e( 'Clear', 'adjust-accessibility' ); ?>">↻</button>216 <button id="aa-close" class="aa-close" aria-label="<?php esc_attr_e( 'Close', 'adjust-accessibility' ); ?>">⨯</button>167 <button id="aa-clear" class="aa-clear" type="button" aria-label="<?php esc_attr_e( 'Clear', 'adjust-accessibility' ); ?>">↻</button> 168 <button id="aa-close" class="aa-close" type="button" aria-label="<?php esc_attr_e( 'Close', 'adjust-accessibility' ); ?>">⨯</button> 217 169 </div> 218 170 </div> 171 219 172 <div id="aa-controls" class="aa-controls"> 220 173 <?php if ( in_array( 'brightness', $enabled, true ) ) : ?> … … 224 177 <input type="range" id="aa-brightness" min="50" max="150" value="100"> 225 178 </label> 179 226 180 <label> 227 181 <i class="fa-solid fa-droplet"></i> … … 229 183 <input type="range" id="aa-saturation" min="0" max="200" value="100"> 230 184 </label> 185 231 186 <label> 232 187 <i class="fa-solid fa-sun"></i> … … 261 216 262 217 <?php if ( in_array( 'dark_light_mode', $enabled, true ) ) : ?> 263 <button id="aa-darkmode" class="aa-btn" >218 <button id="aa-darkmode" class="aa-btn" type="button"> 264 219 <i class="fa-solid fa-moon"></i> 265 220 <?php esc_html_e( 'Dark Mode', 'adjust-accessibility' ); ?> 266 221 </button> 267 <button id="aa-lightmode" class="aa-btn"> 222 223 <button id="aa-lightmode" class="aa-btn" type="button"> 268 224 <i class="fa-solid fa-sun"></i> 269 225 <?php esc_html_e( 'Light Mode', 'adjust-accessibility' ); ?> … … 272 228 273 229 <?php if ( in_array( 'highlight_links', $enabled, true ) ) : ?> 274 <button id="aa-highlight-links" class="aa-btn" >230 <button id="aa-highlight-links" class="aa-btn" type="button"> 275 231 <i class="fa-solid fa-link"></i> 276 232 <?php esc_html_e( 'Highlight Links', 'adjust-accessibility' ); ?> … … 279 235 280 236 <?php if ( in_array( 'highlight_titles', $enabled, true ) ) : ?> 281 <button id="aa-highlight-titles" class="aa-btn" >237 <button id="aa-highlight-titles" class="aa-btn" type="button"> 282 238 <i class="fa-solid fa-wand-magic-sparkles"></i> 283 239 <?php esc_html_e( 'Highlight Titles', 'adjust-accessibility' ); ?> … … 290 246 } 291 247 292 /**293 * Add admin menu page.294 */295 248 public function add_admin_menu() { 296 249 add_menu_page( … … 300 253 'adjst_acsiblty_settings', 301 254 [ $this, 'settings_page' ], 302 plugins_url( 'assets/img/wp-image s.png', __FILE__ ),255 plugins_url( 'assets/img/wp-image.png', __FILE__ ), // (your zip has wp-image.png) 303 256 80 304 257 ); 305 258 } 306 259 307 /**308 * Register plugin settings and fields.309 */310 260 public function adjst_acsiblty_register_settings() { 311 // Device visibility.312 261 register_setting( 313 262 'adjst_acsiblty_settings_group', … … 341 290 ); 342 291 343 // Primary color picker.344 292 register_setting( 345 293 'adjst_acsiblty_settings_group', 346 294 'adjst_acsiblty_primary_color', 347 [ 348 'sanitize_callback' => 'sanitize_hex_color', 349 'default' => '#0073aa', 350 ] 295 [ 'sanitize_callback' => 'sanitize_hex_color', 'default' => '#0073aa' ] 351 296 ); 352 297 … … 369 314 ); 370 315 371 // Feature toggles.372 316 register_setting( 373 317 'adjst_acsiblty_settings_group', 374 318 'adjst_acsiblty_enabled_features', 375 [ 376 'sanitize_callback' => [ $this, 'adjst_acsiblty_sanitize_features' ], 377 'default' => [ 'brightness' ], 378 ] 319 [ 'sanitize_callback' => [ $this, 'adjst_acsiblty_sanitize_features' ], 'default' => [ 'brightness' ] ] 379 320 ); 380 321 … … 388 329 ); 389 330 390 // Panel position options.391 331 register_setting( 392 332 'adjst_acsiblty_settings_group', 393 333 'adjst_acsiblty_panel_position', 394 [ 395 'sanitize_callback' => [ $this, 'adjst_acsiblty_sanitize_panel_position' ], 396 'default' => 'bottom-right', 397 ] 334 [ 'sanitize_callback' => [ $this, 'adjst_acsiblty_sanitize_panel_position' ], 'default' => 'bottom-right' ] 398 335 ); 399 336 … … 410 347 'adjst_acsiblty_settings_group', 411 348 'adjst_acsiblty_mobile_panel_position', 412 [ 413 'sanitize_callback' => [ $this, 'adjst_acsiblty_sanitize_panel_position' ], 414 'default' => 'bottom-left', 415 ] 349 [ 'sanitize_callback' => [ $this, 'adjst_acsiblty_sanitize_panel_position' ], 'default' => 'bottom-left' ] 416 350 ); 417 351 … … 425 359 ); 426 360 427 // Feature list.428 361 $features = [ 429 362 'brightness' => 'Brightness / Saturation / Contrast', … … 448 381 } 449 382 450 /**451 * Color picker field callback.452 */453 383 public function adjst_acsiblty_color_picker_field_cb( $args ) { 454 384 $color = get_option( 'adjst_acsiblty_primary_color', '#0073aa' ); 455 456 385 printf( 457 386 '<input type="text" id="%1$s" name="adjst_acsiblty_primary_color" value="%2$s" class="wp-color-picker-field" data-default-color="#0073aa" />', … … 461 390 } 462 391 463 /**464 * Sanitize settings for device visibility.465 */466 392 public function adjst_acsiblty_sanitize_settings( $input ) { 467 393 return [ … … 471 397 } 472 398 473 /**474 * Sanitize panel position.475 */476 399 public function adjst_acsiblty_sanitize_panel_position( $input ) { 477 400 $allowed = [ 'center-right', 'center-left', 'bottom-right', 'bottom-left' ]; … … 479 402 } 480 403 481 /**482 * Checkbox field for device visibility.483 */484 404 public function field_checkbox_cb( $args ) { 485 $opts = get_option( 486 'adjst_acsiblty_settings', 487 [ 488 'desktop_enabled' => 1, 489 'mobile_enabled' => 1, 490 ] 491 ); 492 $id = $args['label_for']; 405 $opts = get_option( 'adjst_acsiblty_settings', [ 'desktop_enabled' => 1, 'mobile_enabled' => 1 ] ); 406 $id = $args['label_for']; 493 407 $checked = ! empty( $opts[ $id ] ) ? 'checked' : ''; 494 495 408 printf( 496 409 '<input type="checkbox" id="%1$s" name="adjst_acsiblty_settings[%1$s]" value="1" %2$s />', … … 500 413 } 501 414 502 /**503 * Sanitize enabled features.504 */505 415 public function adjst_acsiblty_sanitize_features( $input ) { 506 $allowed = [ 507 'brightness', 508 'font_size', 509 'line_height', 510 'letter_spacing', 511 'dark_light_mode', 512 'highlight_links', 513 'highlight_titles', 514 ]; 515 416 $allowed = [ 'brightness','font_size','line_height','letter_spacing','dark_light_mode','highlight_links','highlight_titles' ]; 516 417 $vals = array_intersect( $allowed, (array) $input ); 517 518 if ( empty( $vals ) ) { 519 $vals = [ 'brightness' ]; 520 } 521 418 if ( empty( $vals ) ) $vals = [ 'brightness' ]; 522 419 return array_values( $vals ); 523 420 } 524 421 525 /**526 * Feature checkbox callbacks.527 */528 422 public function feature_checkbox_cb( $args ) { 529 $opts = get_option( 'adjst_acsiblty_enabled_features', [ 'brightness' ] );530 $key = $args['feature_key'];531 $id = 'adjst_acsiblty_feat_' . $key;423 $opts = get_option( 'adjst_acsiblty_enabled_features', [ 'brightness' ] ); 424 $key = $args['feature_key']; 425 $id = 'adjst_acsiblty_feat_' . $key; 532 426 $checked = in_array( $key, $opts, true ) ? 'checked="checked"' : ''; 533 534 427 printf( 535 428 '<input type="checkbox" id="%1$s" name="adjst_acsiblty_enabled_features[]" value="%2$s" %3$s />', … … 540 433 } 541 434 542 /**543 * Panel position select field (desktop & mobile).544 */545 435 public function adjst_acsiblty_panel_position_field_cb( $args ) { 546 436 $option_key = $args['label_for']; 547 $current = get_option( $option_key, 'bottom-right' );437 $current = get_option( $option_key, 'bottom-right' ); 548 438 549 439 $options = [ … … 554 444 ]; 555 445 556 printf( 557 '<select id="%1$s" name="%1$s">', 558 esc_attr( $option_key ) 559 ); 560 446 printf( '<select id="%1$s" name="%1$s">', esc_attr( $option_key ) ); 561 447 foreach ( $options as $value => $label ) { 562 448 printf( … … 567 453 ); 568 454 } 569 570 455 echo '</select>'; 571 456 } 572 457 573 /**574 * Settings page output.575 */576 458 public function settings_page() { 577 459 ?> -
adjust-accessibility/trunk/assets/css/accessibility.tailwind.css
r3426200 r3429998 240 240 transform: none !important; 241 241 } 242 243 244 245 246 247 248 /* ========================================= 249 REQUIRED: PANEL POSITION CLASSES 250 (Your PHP uses aa-pos-*, but CSS had none) 251 ========================================= */ 252 .aa-panel.aa-pos-bottom-right { right: 20px; bottom: 20px; } 253 .aa-panel.aa-pos-bottom-left { left: 20px; bottom: 20px; } 254 .aa-panel.aa-pos-center-right { right: 20px; top: 50%; transform: translateY(-50%); } 255 .aa-panel.aa-pos-center-left { left: 20px; top: 50%; transform: translateY(-50%); } 256 257 /* main panel appears above icon in bottom positions */ 258 .aa-panel-main.aa-pos-bottom-right { right: 20px; bottom: 85px; } 259 .aa-panel-main.aa-pos-bottom-left { left: 20px; bottom: 85px; } 260 .aa-panel-main.aa-pos-center-right { right: 20px; top: 50%; transform: translateY(-50%); } 261 .aa-panel-main.aa-pos-center-left { left: 20px; top: 50%; transform: translateY(-50%); } 262 263 264 265 266 /* =============================== 267 2 COLUMN GRID FOR CONTROLS 268 =============================== */ 269 270 #aa-controls{ 271 display: grid !important; 272 grid-template-columns: repeat(2, 1fr); 273 gap: 8px; 274 } 275 276 /* Make labels & buttons consistent */ 277 #aa-controls label, 278 #aa-controls .aa-btn{ 279 width: 100% !important; 280 margin: 0 !important; 281 box-sizing: border-box; 282 } 283 284 /* Sliders inside labels */ 285 #aa-controls label input[type=range]{ 286 margin-top: 6px; 287 } 288 289 /* Full width header row spacing fix */ 290 .aa-header{ 291 margin-bottom: 6px; 292 } 293 294 295 296 .aa-btn.active{ 297 background: var(--aa-primary-color) !important; 298 color: #fff !important; 299 border-color: var(--aa-primary-color) !important; 300 } 301 302 303 304 305 /* ===================================== 306 FIX RIGHT-SIDE OVERFLOW & RESPONSIVE 307 ===================================== */ 308 309 /* Ensure box sizing everywhere */ 310 .aa-wrap, 311 .aa-wrap * { 312 box-sizing: border-box; 313 } 314 315 /* Main panel padding fix */ 316 #aa-panel-main { 317 padding: 0 !important; 318 max-width: 95vw; 319 } 320 321 /* Controls grid spacing */ 322 #aa-controls { 323 display: grid !important; 324 grid-template-columns: repeat(2, 1fr); 325 gap: 10px; 326 padding: 10px; 327 } 328 329 /* Label & button boxes */ 330 #aa-controls label, 331 #aa-controls .aa-btn { 332 width: 100% !important; 333 padding: 10px !important; 334 margin: 0 !important; 335 overflow: hidden; 336 } 337 338 /* Slider width fix */ 339 #aa-controls input[type="range"] { 340 width: 100% !important; 341 max-width: 100%; 342 } 343 344 /* Icons + text alignment */ 345 #aa-controls label i, 346 .aa-controls .aa-btn i { 347 display: block; 348 margin-bottom: 4px; 349 } 350 351 /* Header padding alignment */ 352 .aa-header { 353 padding: 10px 12px !important; 354 } 355 356 /* Buttons (dark/light/highlight) height consistency */ 357 .aa-btn { 358 min-height: 64px; 359 display: flex; 360 flex-direction: column; 361 align-items: center; 362 justify-content: center; 363 } 364 365 /* ========================= 366 MOBILE RESPONSIVE FIX 367 ========================= */ 368 @media (max-width: 480px) { 369 370 #aa-panel-main { 371 width: 94vw !important; 372 right: 3vw !important; 373 left: auto !important; 374 } 375 376 #aa-controls { 377 gap: 8px; 378 padding: 8px; 379 } 380 381 .aa-controls label, 382 .aa-controls .aa-btn { 383 padding: 8px !important; 384 font-size: 13px !important; 385 } 386 } -
adjust-accessibility/trunk/assets/js/accessibility.js
r3425784 r3429998 1 1 (function($){ 2 $(document).ready(function(){3 4 if ( /iP(hone|od|ad)/.test(navigator.userAgent)) {5 $('html').addClass('aa-ios');2 $(document).ready(function(){ 3 4 if (/iP(hone|od|ad)/.test(navigator.userAgent)) { 5 $('html').addClass('aa-ios'); 6 6 } 7 8 var $body = $('body'),9 $texts = $('h1,h2,h3,h4,h5,h6,p,li,span,a,button,label'),10 $sliderFS = $('#aa-font-size'),11 $displayFS = $('#aa-font-size-value'),12 $sliderLH = $('#aa-line-height'),13 $displayLH = $('#aa-line-height-value'),14 $letterSlider = $('#aa-letter-spacing'),15 $letterValue = $('#aa-letter-spacing-value');16 17 $texts.each(function(){18 var $el = $(this);19 $el.data('aaOriginalFontSize', parseFloat($el.css('font-size')));20 // $el.data('aaOriginalLineHeight', parseFloat($el.css('line-height')));21 $el.data('aaOriginalLetterSpacing', parseFloat($el.css('letter-spacing')) || 0 );22 });23 7 24 // 1) Cache the *computed* line-height in px for each element 25 $texts.each(function(){ 26 var compLH = window.getComputedStyle(this).lineHeight; // e.g. "19.2px" 27 $(this).data('aaOriginalLineHeight', parseFloat(compLH)); 28 }); 8 // ✅ IMPORTANT: exclude plugin UI from resizing 9 var $texts = $('h1,h2,h3,h4,h5,h6,p,li,span,a,button,label') 10 .not('.aa-wrap, .aa-wrap *'); 29 11 12 var $sliderFS = $('#aa-font-size'); 13 var $sliderLH = $('#aa-line-height'); 14 var $letterSlider = $('#aa-letter-spacing'); 30 15 31 $('#aa-toggle').on('click', function(){ 32 $('#aa-panel-main').toggle(); 33 }); 34 // Close panel 35 $('#aa-close').on('click', function(){ 36 $('#aa-panel-main').hide(); 37 }); 16 // Cache originals 17 $texts.each(function(){ 18 var $el = $(this); 19 $el.data('aaOriginalFontSize', parseFloat($el.css('font-size')) || 16); 20 $el.data('aaOriginalLetterSpacing', parseFloat($el.css('letter-spacing')) || 0); 38 21 39 function applyFilters() { 40 var b = $('#aa-brightness').val(); 41 var s = $('#aa-saturation').val(); 42 var p = $('#aa-contrast').val(); 43 $('html').css('filter', 'brightness('+ b +'%) saturate('+ s +'%) contrast('+ p +'%)'); 44 } 45 $('#aa-brightness, #aa-saturation, #aa-contrast').on('input', applyFilters); 22 var lh = window.getComputedStyle(this).lineHeight; 23 $el.data('aaOriginalLineHeight', parseFloat(lh) || 16); 24 }); 46 25 47 // Dark mode toggle 48 $('#aa-darkmode').on('click', function(){ 49 $('body, div, span') 50 .not('#aa-panel-main, #aa-panel, .aa-wrap, .aa-wrap *, #aa-panel-main *') 51 .toggleClass('aa-darkmode') 52 .removeClass('aa-lightmode'); 53 $(this).toggleClass('active'); 54 $('#aa-lightmode').removeClass('active'); 55 }); 56 57 // Light mode toggle 58 $('#aa-lightmode').on('click', function(){ 59 $('body, div, span') 60 .not('#aa-panel-main, #aa-panel, .aa-wrap, .aa-wrap *, #aa-panel-main *') 61 .toggleClass('aa-lightmode') 62 .removeClass('aa-darkmode'); 63 $(this).toggleClass('active'); 64 $('#aa-darkmode').removeClass('active'); 65 }); 26 $('#aa-toggle').on('click', function(){ 27 $('#aa-panel-main').toggle(); 28 }); 66 29 67 $('#aa-highlight-links').on('click', function(){ 68 $('a, button').toggleClass('aa-highlight-link'); 69 $(this).toggleClass('active'); 70 }); 30 $('#aa-close').on('click', function(){ 31 $('#aa-panel-main').hide(); 32 }); 71 33 72 $('#aa-highlight-titles').on('click', function(){ 73 $('h1, h2, h3, h4, h5, h6').toggleClass('aa-highlight-title'); 74 $(this).toggleClass('active'); 75 }); 34 function applyFilters() { 35 var b = $('#aa-brightness').val(); 36 var s = $('#aa-saturation').val(); 37 var c = $('#aa-contrast').val(); 38 $('html').css('filter', 'brightness('+ b +'%) saturate('+ s +'%) contrast('+ c +'%)'); 39 } 40 $('#aa-brightness, #aa-saturation, #aa-contrast').on('input', applyFilters); 76 41 77 // Font-size slider 42 // Dark / Light 43 // $('#aa-darkmode').on('click', function(){ 44 // $('body').addClass('aa-darkmode').removeClass('aa-lightmode'); 45 // $(this).addClass('active'); 46 // $('#aa-lightmode').removeClass('active'); 47 // }); 48 49 $('#aa-darkmode').on('click', function(){ 50 51 if ($('body').hasClass('aa-darkmode')) { 52 // turn OFF 53 $('body').removeClass('aa-darkmode'); 54 $(this).removeClass('active'); 55 } else { 56 // turn ON 57 $('body').addClass('aa-darkmode').removeClass('aa-lightmode'); 58 $(this).addClass('active'); 59 $('#aa-lightmode').removeClass('active'); 60 } 61 }); 62 //light 63 // $('#aa-lightmode').on('click', function(){ 64 // $('body').addClass('aa-lightmode').removeClass('aa-darkmode'); 65 // $(this).addClass('active'); 66 // $('#aa-darkmode').removeClass('active'); 67 // }); 68 69 $('#aa-lightmode').on('click', function(){ 70 71 if ($('body').hasClass('aa-lightmode')) { 72 // turn OFF 73 $('body').removeClass('aa-lightmode'); 74 $(this).removeClass('active'); 75 } else { 76 // turn ON 77 $('body').addClass('aa-lightmode').removeClass('aa-darkmode'); 78 $(this).addClass('active'); 79 $('#aa-darkmode').removeClass('active'); 80 } 81 }); 82 83 $('#aa-highlight-links').on('click', function(){ 84 $('a, button').toggleClass('aa-highlight-link'); 85 $(this).toggleClass('active'); 86 }); 87 88 $('#aa-highlight-titles').on('click', function(){ 89 $('h1, h2, h3, h4, h5, h6').toggleClass('aa-highlight-title'); 90 $(this).toggleClass('active'); 91 }); 92 93 // Font size 78 94 $sliderFS.on('input change', function(){ 79 95 var pct = +this.value; 80 $displayFS.text(pct + '%');81 96 $texts.each(function(){ 82 97 var orig = $(this).data('aaOriginalFontSize'); 83 if (orig) $(this).css('font-size', orig * pct/100+ 'px');98 $(this).css('font-size', (orig * pct/100) + 'px'); 84 99 }); 85 100 }); 86 101 87 // Line -height slider102 // Line height 88 103 $sliderLH.on('input change', function(){ 89 var pct = +this.value; // 50–200 90 $displayLH.text(pct + '%'); 91 104 var pct = +this.value; 92 105 $texts.each(function(){ 93 106 var origLH = $(this).data('aaOriginalLineHeight'); 94 if (!isNaN(origLH)) { 95 $(this).css('line-height', (origLH * pct/100) + 'px'); 96 } 107 $(this).css('line-height', (origLH * pct/100) + 'px'); 97 108 }); 98 109 }); 99 100 // Letter -spacing slider110 111 // Letter spacing 101 112 $letterSlider.on('input change', function(){ 102 113 var extra = +this.value; 103 $letterValue.text(extra + 'px');104 114 $texts.each(function(){ 105 115 var origLS = $(this).data('aaOriginalLetterSpacing'); … … 108 118 }); 109 119 110 // Clear button (resets *all* controls) 111 $('#aa-clear').on('click', function(){ 112 // 1) reset filters 113 $('#aa-brightness, #aa-saturation, #aa-contrast').val(100).trigger('input'); 114 115 // 2) reset font-size 116 $sliderFS.val(100).trigger('input'); 117 118 // 3) reset line-height 119 // $sliderLH.val(100); 120 // $displayLH.text('100%'); 121 // $texts.each(function(){ 122 // var origLH = $(this).data('aaOriginalLineHeight'); 123 // if (!isNaN(origLH)) { 124 // $(this).css('line-height', origLH + 'px'); 125 // } 126 // }); 127 $sliderLH.val(100).trigger('input'); 128 129 // 4) reset letter-spacing slider *and* all elements 130 $letterSlider.val(0).trigger('input'); // fires your slider handler 131 $letterValue.text('0px'); // update the label 132 $texts.each(function(){ 133 var origLS = $(this).data('aaOriginalLetterSpacing') || 0; 134 $(this).css('letter-spacing', origLS + 'px'); 135 }); 136 137 // 5) reset dark/light modes & highlights 138 $('body, div, span').removeClass('aa-darkmode aa-lightmode'); 139 $('.aa-btn').removeClass('active'); 140 $('a').removeClass('aa-highlight-link'); 141 $('h1, h2, h3, h4, h5, h6').removeClass('aa-highlight-title'); 142 }); 143 144 145 // input type range style 120 // Clear 121 $('#aa-clear').on('click', function(){ 122 $('#aa-brightness, #aa-saturation, #aa-contrast').val(100).trigger('input'); 123 $sliderFS.val(100).trigger('input'); 124 $sliderLH.val(100).trigger('input'); 125 $letterSlider.val(0).trigger('input'); 126 127 $('html').css('filter', ''); 128 $('body').removeClass('aa-darkmode aa-lightmode'); 129 $('.aa-btn').removeClass('active'); 130 $('a,button').removeClass('aa-highlight-link'); 131 $('h1,h2,h3,h4,h5,h6').removeClass('aa-highlight-title'); 132 }); 133 134 // Range background fill 146 135 $('input[type=range]').on('input', function(e){ 147 var min = e.target.min, 148 max = e.target.max, 149 val = e.target.value; 150 151 $(e.target).css({ 152 'backgroundSize': (val - min) * 100 / (max - min) + '% 100%' 153 }); 136 var min = e.target.min, max = e.target.max, val = e.target.value; 137 $(e.target).css({ 'backgroundSize': (val - min) * 100 / (max - min) + '% 100%' }); 154 138 }).trigger('input'); 155 139 156 140 }); 157 141 })(jQuery); 158 159 160 -
adjust-accessibility/trunk/readme.txt
r3426598 r3429998 4 4 Requires at least: 4.5 5 5 Tested up to: 6.9 6 Stable tag: 1.0. 46 Stable tag: 1.0.5 7 7 License: GPLv2 or later 8 8 License URI: https://www.gnu.org/licenses/gpl-2.0.html
Note: See TracChangeset
for help on using the changeset viewer.