From 40c80270b3fa2a2ef15d65b2c5ee72b56bd502f2 Mon Sep 17 00:00:00 2001 From: Vishal Kharche Date: Thu, 11 Jul 2024 00:10:30 +0530 Subject: [PATCH] Created the Zoom Level settings in the WP admin panel, fetched the zoom level on the front end, integrated it with app.dev.js, and then minified app.dev.js to app.min.js. --- assets/js/app.dev.js | 2 +- assets/js/app.min.js | 6 ++++-- includes/pojo-a11y-frontend.php | 1 + includes/pojo-a11y-settings.php | 18 ++++++++++++++++++ 4 files changed, 24 insertions(+), 3 deletions(-) diff --git a/assets/js/app.dev.js b/assets/js/app.dev.js index dc2b967..62bc6eb 100644 --- a/assets/js/app.dev.js +++ b/assets/js/app.dev.js @@ -23,7 +23,7 @@ settings: { minFontSize: 120, - maxFontSize: 200, + maxFontSize: PojoA11yOptions.maximum_zoom_level, buttonsClassPrefix: 'pojo-a11y-btn-', bodyClassPrefix: 'pojo-a11y-', bodyFontClassPrefix: 'pojo-a11y-resize-font-', diff --git a/assets/js/app.min.js b/assets/js/app.min.js index a0d2181..9cc4d07 100644 --- a/assets/js/app.min.js +++ b/assets/js/app.min.js @@ -1,2 +1,4 @@ -/*! pojo-accessibility - v2.1.0 - 18-12-2022 */ -!function(){var t=-1 a"),this.cache.$skipToContent=n("#pojo-a11y-skip-content"),this.cache.$body=n("body")},settings:{minFontSize:120,maxFontSize:200,buttonsClassPrefix:"pojo-a11y-btn-",bodyClassPrefix:"pojo-a11y-",bodyFontClassPrefix:"pojo-a11y-resize-font-",storageKey:"pojo-a11y",expires:PojoA11yOptions.save_expiration?36e5*PojoA11yOptions.save_expiration:432e5},variables:{currentFontSize:120,currentSchema:null},activeActions:{},buildElements:function(){this.cache.$body.prepend(this.cache.$toolbar),this.cache.$body.prepend(this.cache.$skipToContent)},bindEvents:function(){var e=this;e.cache.$btnToolbarToggle.on("click",function(t){t.preventDefault(),e.cache.$toolbar.toggleClass("pojo-a11y-toolbar-open"),e.cache.$toolbar.hasClass("pojo-a11y-toolbar-open")?e.cache.$toolbarLinks.attr("tabindex","0"):e.cache.$toolbarLinks.attr("tabindex","-1")}),n(o).on("keyup",function(t){9===t.which&&e.cache.$btnToolbarToggle.is(":focus")&&(e.cache.$toolbar.addClass("pojo-a11y-toolbar-open"),e.cache.$toolbarLinks.attr("tabindex","0"))}),e.bindToolbarButtons()},bindToolbarButtons:function(){var s=this;s.cache.$toolbarToolsLinks.on("click",function(t){t.preventDefault();var e=n(this),o=e.data("action"),i=e.data("action-group"),a=!1;"reset"!==o?(-1!==["toggle","schema"].indexOf(i)&&(a=e.hasClass("active")),s.activateButton(o,a)):s.reset()})},activateButton:function(t,e){var o=this.getButtonByAction(t).data("action-group");this.activeActions[t]=!e,this.actions[o].call(this,t,e),this.saveToLocalStorage()},getActiveButtons:function(){return this.cache.$toolbarToolsLinks.filter(".active")},getButtonByAction:function(t){return this.cache.$toolbarToolsLinks.filter("."+this.settings.buttonsClassPrefix+t)},actions:{toggle:function(t,e){var o=this.getButtonByAction(t),i=e?"removeClass":"addClass";e?o.removeClass("active"):o.addClass("active"),this.cache.$body[i](this.settings.bodyClassPrefix+t)},resize:function(t,e){var o=this.variables.currentFontSize;"resize-plus"===t&&this.settings.maxFontSize>o&&(this.variables.currentFontSize+=10),"resize-minus"===t&&this.settings.minFontSize a"),this.cache.$skipToContent=$("#pojo-a11y-skip-content"),this.cache.$body=$("body")},settings:{minFontSize:120,maxFontSize:PojoA11yOptions.maximum_zoom_level,buttonsClassPrefix:"pojo-a11y-btn-",bodyClassPrefix:"pojo-a11y-",bodyFontClassPrefix:"pojo-a11y-resize-font-",storageKey:"pojo-a11y",expires:PojoA11yOptions.save_expiration?36e5*PojoA11yOptions.save_expiration:432e5},variables:{currentFontSize:120,currentSchema:null},activeActions:{},buildElements:function(){this.cache.$body.prepend(this.cache.$toolbar),this.cache.$body.prepend(this.cache.$skipToContent)},bindEvents:function(){var $self=this;$self.cache.$btnToolbarToggle.on("click",(function(event){event.preventDefault(),$self.cache.$toolbar.toggleClass("pojo-a11y-toolbar-open"),$self.cache.$toolbar.hasClass("pojo-a11y-toolbar-open")?$self.cache.$toolbarLinks.attr("tabindex","0"):$self.cache.$toolbarLinks.attr("tabindex","-1")})),$(document).on("keyup",(function(event){var TAB_KEY=9;9===event.which&&$self.cache.$btnToolbarToggle.is(":focus")&&($self.cache.$toolbar.addClass("pojo-a11y-toolbar-open"),$self.cache.$toolbarLinks.attr("tabindex","0"))})),$self.bindToolbarButtons()},bindToolbarButtons:function(){var self=this;self.cache.$toolbarToolsLinks.on("click",(function(event){event.preventDefault();var $this=$(this),action=$this.data("action"),actionGroup=$this.data("action-group"),deactivate=!1;"reset"!==action?(-1!==["toggle","schema"].indexOf(actionGroup)&&(deactivate=$this.hasClass("active")),self.activateButton(action,deactivate)):self.reset()}))},activateButton:function(action,deactivate){var $button,actionGroup=this.getButtonByAction(action).data("action-group");this.activeActions[action]=!deactivate,this.actions[actionGroup].call(this,action,deactivate),this.saveToLocalStorage()},getActiveButtons:function(){return this.cache.$toolbarToolsLinks.filter(".active")},getButtonByAction:function(action){return this.cache.$toolbarToolsLinks.filter("."+this.settings.buttonsClassPrefix+action)},actions:{toggle:function(action,deactivate){var $button=this.getButtonByAction(action),fn=deactivate?"removeClass":"addClass";deactivate?$button.removeClass("active"):$button.addClass("active"),this.cache.$body[fn](this.settings.bodyClassPrefix+action)},resize:function(action,deactivate){var oldFontSize=this.variables.currentFontSize;"resize-plus"===action&&this.settings.maxFontSize>oldFontSize&&(this.variables.currentFontSize+=10),"resize-minus"===action&&this.settings.minFontSizelocalData.variables.expires)localStorage.removeItem(this.settings.storageKey);else{var actions=localData.actions;for(var action in localData.variables.currentFontSize>120&&(localData.variables.currentFontSize-=10),$.extend(this.variables,localData.variables),actions)actions.hasOwnProperty(action)&&actions[action]&&this.activateButton(action,!1)}}},handleGlobalOptions:function(){"1"===PojoA11yOptions.focusable&&this.cache.$body.addClass("pojo-a11y-focusable"),"1"===PojoA11yOptions.remove_link_target&&$('a[target="_blank"]').attr("target",""),"1"===PojoA11yOptions.add_role_links&&$("a").attr("role","link")},init:function(){this.cacheElements(),this.buildElements(),this.bindEvents(),this.handleGlobalOptions()}};$(document).ready((function($){Pojo_Accessibility_App.init(),Pojo_Accessibility_App.setFromLocalStorage()}))}(jQuery,window,document); \ No newline at end of file diff --git a/includes/pojo-a11y-frontend.php b/includes/pojo-a11y-frontend.php index 05a5659..561e5ef 100644 --- a/includes/pojo-a11y-frontend.php +++ b/includes/pojo-a11y-frontend.php @@ -52,6 +52,7 @@ public function enqueue_scripts() { 'add_role_links' => ( 'enable' === get_option( 'pojo_a11y_add_role_links' ) ), 'enable_save' => ( 'enable' === get_option( 'pojo_a11y_save' ) ), 'save_expiration' => get_option( 'pojo_a11y_save_expiration' ), + 'maximum_zoom_level' => get_option( 'pojo_a11y_maximum_zoom_level' ), ) ); } diff --git a/includes/pojo-a11y-settings.php b/includes/pojo-a11y-settings.php index f2e43c2..41e9031 100644 --- a/includes/pojo-a11y-settings.php +++ b/includes/pojo-a11y-settings.php @@ -367,6 +367,24 @@ public function section_a11y_settings( $sections ) { 'std' => '12', ); + $fields[] = array( + 'id' => 'pojo_a11y_maximum_zoom_level', + 'title' => __( 'Maximum Levels of Zoom', 'pojo-accessibility' ), + 'type' => self::FIELD_SELECT, + 'desc' => __( 'Define Maximum zoom level settings', 'pojo-accessibility' ), + 'options' => array( + '120' => __( '0', 'pojo-accessibility' ), + '130' => __( '1', 'pojo-accessibility' ), + '140' => __( '2', 'pojo-accessibility' ), + '150' => __( '3', 'pojo-accessibility' ), + '160' => __( '4', 'pojo-accessibility' ), + '170' => __( '5', 'pojo-accessibility' ), + '180' => __( '6', 'pojo-accessibility' ), + '200' => __( '7', 'pojo-accessibility' ), + ), + 'std' => '0', + ); + $sections[] = array( 'id' => 'section-a11y-settings', 'page' => self::SETTINGS_PAGE,