Skip to content

Commit

Permalink
Remove Title
Browse files Browse the repository at this point in the history
change title to aria-label
cache jquery
  • Loading branch information
Tiago Porto committed Aug 22, 2014
1 parent 41c402f commit cd6f9f9
Show file tree
Hide file tree
Showing 11 changed files with 135 additions and 111 deletions.
60 changes: 37 additions & 23 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,62 +1,76 @@
# Accessibility Buttons

Accessibility functions
Version: 2.0.0

* Contrast
**Accessibility functions**

* Contrast
* Font Size


[Example Page](http://tiagoporto.github.io/accessibility-buttons/)

## Usage

* Requires [Jquery](http://jquery.com/download/).

* Include `main.js` or `main.min.js` and `styles.css`.
* Include `accessibility-buttons.js` or `accessibility-buttons.min.js` and `accessibility-buttons.css`.

* Insert the buttons in HTML

```html
<button title="" id="accessibility-font" class="js-acessibility"></button>
<button title="" id="accessibility-contrast" class="js-acessibility"></button>
<button aria-label="" id="accessibility-font" class="js-acessibility"></button>
<button aria-label="" id="accessibility-contrast" class="js-acessibility"></button>
```

To `font-size` works it's necessary work with `em` unit.
**Note:** To `font-size` works, it's necessary work with `em` unit.

##Configure

To setup names and buttons titles, change the variables in the `main.js` or `main.min.js` at the initial lines.
To setup names and buttons aria-labels, change the variables in the `accessibility-buttons.js` or `accessibility-buttons.min.js` at the initial lines.

```javascript
//Font Button
var nameButtonIncreaseFont = "+A";
var nameTitleButtonIncreaseFont = "Increase Font";

var nameButtonDecreaseFont = "-A";
var nameTitleButtonDecreaseFont = "Decrease Font";

var nameButtonIncreaseFont = "+A",
ariaLabelButtonIncreaseFont = "Increase Font",
nameButtonDecreaseFont = "-A",
ariaLabelButtonDecreaseFont = "Decrease Font",
//Contrast Button
var nameButtonAddContrast = "Add Contrast";
var nameTitleButtonAddContrast = "Add Contrast";

var nameButtonRemoveContrast = "Remove Contrast";
var nameTitleButtonRemoveContrast = "Remove Contrast";
nameButtonAddContrast = "Add Contrast",
ariaLabelButtonAddContrast = "Add Contrast",
nameButtonRemoveContrast = "Remove Contrast",
ariaLabelButtonRemoveContrast = "Remove Contrast",
```

To change font-size and contrast colors change the values in the `styles.css`.
To change font-size and contrast colors change the values in the `accessibility-buttons.css`.

```css
/* Accessibility */
.accessibility-font {
font-size: 1.125em;
font-size: 1.125em;
}

.accessibility-contrast {
color: white;
background: black;
color: white;
background: black;
}
```

##Bower

To download with [Bower](http://bower.io/)

```sh
$ bower install accessibility-buttons --save
```

##Credit

Accessibility `arial-label` tip - [brunopulis](https://github.com/brunopulis)

##License
[MIT License](http://opensource.org/licenses/MIT)





3 changes: 2 additions & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
{
"name": "accessibility-buttons",
"version": "1.0.0",
"version": "2.0.0",
"main": "public/accessibility-buttons.js",
"license": "MIT",
"ignore": [
"**/.*",
"src",
"bower.json",
"config.rb",
"gulpfile.js",
"package.json"
Expand Down
22 changes: 11 additions & 11 deletions public/css/accessibility-buttons.css
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
/*
Accessibility Buttons
Version: 2.0.0
Author: Tiago Porto - http://www.tiagoporto.com
https://github.com/tiagoporto
Contact: [email protected]
*/

/* Typography */
body {
font: normal normal 1em/1.1875em Helvetica, Arial, sans-serif;
text-rendering: optimizeLegibility;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
-moz-font-feature-settings: "frac", "liga";
-moz-font-feature-settings: "frac=1, liga=1";
-ms-font-feature-settings: "frac", "liga";
-o-font-feature-settings: "frac", "liga";
-webkit-font-feature-settings: "frac", "liga";
font-feature-settings: "frac", "liga";
font-size: 1em;
line-height: 1.1875em;
}

/* Main */
/* Transition */
body {
-webkit-transition: all 1s ease-in;
-moz-transition: all 1s ease-in;
Expand Down
4 changes: 2 additions & 2 deletions public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ <h1>Accessibility</h1>
</a>

<p>
<button title="" id="accessibility-font" class="js-acessibility"></button>
<button title="" id="accessibility-contrast" class="js-acessibility"></button>
<button aria-label="" id="accessibility-font" class="js-acessibility"></button>
<button aria-label="" id="accessibility-contrast" class="js-acessibility"></button>
</p>

<script src="http://code.jquery.com/jquery-1.11.0.min.js"></script>
Expand Down
76 changes: 41 additions & 35 deletions public/js/accessibility-buttons.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,29 @@
//Main Scripts
/*
Accessibility Buttons
Version: 2.0.0
Author: Tiago Porto - http://www.tiagoporto.com
https://github.com/tiagoporto
Contact: [email protected]
*/

$(document).ready(function(){
//Font Button
var nameButtonIncreaseFont = "+A";
var nameTitleButtonIncreaseFont = "Increase Font";

var nameButtonDecreaseFont = "-A";
var nameTitleButtonDecreaseFont = "Decrease Font";

var nameButtonIncreaseFont = "+A",
ariaLabelButtonIncreaseFont = "Increase Font",
nameButtonDecreaseFont = "-A",
ariaLabelButtonDecreaseFont = "Decrease Font",
//Contrast Button
var nameButtonAddContrast = "Add Contrast";
var nameTitleButtonAddContrast = "Add Contrast";

var nameButtonRemoveContrast = "Remove Contrast";
var nameTitleButtonRemoveContrast = "Remove Contrast";
nameButtonAddContrast = "Add Contrast",
ariaLabelButtonAddContrast = "Add Contrast",
nameButtonRemoveContrast = "Remove Contrast",
ariaLabelButtonRemoveContrast = "Remove Contrast",
//Cache jQuery Elements
$_body = $('body'),
$_fontButton = $("#accessibility-font"),
$_contrastButton = $("#accessibility-contrast"),
//Cookies
cookieFont = getCookie("accessibility_font"),
cookieContrast = getCookie("accessibility_contrast");


function getCookie(cname){
Expand All @@ -25,62 +36,57 @@ $(document).ready(function(){
return "";
}

var body = $('body');

var cookieFont = getCookie("accessibility_font");

var cookieContrast = getCookie("accessibility_contrast");


if (cookieFont) {
body.addClass('accessibility-font');
$_body.addClass('accessibility-font');

$("#accessibility-font").html(nameButtonDecreaseFont).attr('title', nameTitleButtonDecreaseFont);
$_fontButton.html(nameButtonDecreaseFont).attr('aria-label', ariaLabelButtonDecreaseFont);
}else{
$("#accessibility-font").html(nameButtonIncreaseFont).attr('title', nameTitleButtonIncreaseFont);
$_fontButton.html(nameButtonIncreaseFont).attr('aria-label', ariaLabelButtonIncreaseFont);
};

if (cookieContrast) {
body.addClass('accessibility-contrast');
$_body.addClass('accessibility-contrast');

$("#accessibility-contrast").html(nameButtonRemoveContrast).attr('title', nameTitleButtonRemoveContrast);
$_contrastButton.html(nameButtonRemoveContrast).attr('aria-label', ariaLabelButtonRemoveContrast);
}else{
$("#accessibility-contrast").html(nameButtonAddContrast).attr('title', nameTitleButtonAddContrast);
$_contrastButton.html(nameButtonAddContrast).attr('aria-label', ariaLabelButtonAddContrast);
};

$('.js-acessibility').click(function(event) {
if(body.hasClass($(this).attr('id'))){
var $_this = $(this);

body.removeClass($(this).attr('id'));
if($_body.hasClass($_this.attr('id'))){

if ($(this).attr('id') == 'accessibility-font') {
$_body.removeClass($_this.attr('id'));

$(this).html(nameButtonIncreaseFont).attr('title', nameTitleButtonIncreaseFont);
if ($_this.attr('id') == 'accessibility-font') {

document.cookie = "accessibility_font=True; expires=Thu, 01 Jan 1970 00:00:00 GMT; path=/";
$_this.html(nameButtonIncreaseFont).attr('aria-label', ariaLabelButtonIncreaseFont);

document.cookie = "accessibility_font=True; expires=Thu, 01 Jan 1970 00:00:00 GMT; path=/";
}else{
$(this).html(nameButtonAddContrast).attr('title', nameTitleButtonAddContrast);
$_this.html(nameButtonAddContrast).attr('aria-label', ariaLabelButtonAddContrast);

document.cookie = "accessibility_contrast=True; expires=Thu, 01 Jan 1970 00:00:00 GMT; path=/";
};

}else{
body.addClass($(this).attr('id'));
$_body.addClass($_this.attr('id'));

if ($(this).attr('id') == 'accessibility-font') {
if ($_this.attr('id') == 'accessibility-font') {
if (!cookieFont) {
document.cookie = "accessibility_font=True; path=/";
};
$(this).html(nameButtonDecreaseFont).attr('title', nameTitleButtonDecreaseFont);
$_this.html(nameButtonDecreaseFont).attr('aria-label', ariaLabelButtonDecreaseFont);

}else{
if (!cookieContrast) {
document.cookie = "accessibility_contrast=True; path=/";
};

$(this).html(nameButtonRemoveContrast).attr('title', nameTitleButtonRemoveContrast);
$_this.html(nameButtonRemoveContrast).attr('aria-label', ariaLabelButtonRemoveContrast);
};
}
});

});
2 changes: 1 addition & 1 deletion public/js/accessibility-buttons.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

52 changes: 24 additions & 28 deletions src/scripts/acessibility.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,20 @@
//Font Button
var nameButtonIncreaseFont = "+A";
var nameTitleButtonIncreaseFont = "Increase Font";

var nameButtonDecreaseFont = "-A";
var nameTitleButtonDecreaseFont = "Decrease Font";

var nameButtonIncreaseFont = "+A",
ariaLabelButtonIncreaseFont = "Increase Font",
nameButtonDecreaseFont = "-A",
ariaLabelButtonDecreaseFont = "Decrease Font",
//Contrast Button
var nameButtonAddContrast = "Add Contrast";
var nameTitleButtonAddContrast = "Add Contrast";

var nameButtonRemoveContrast = "Remove Contrast";
var nameTitleButtonRemoveContrast = "Remove Contrast";
nameButtonAddContrast = "Add Contrast",
ariaLabelButtonAddContrast = "Add Contrast",
nameButtonRemoveContrast = "Remove Contrast",
ariaLabelButtonRemoveContrast = "Remove Contrast",
//Cache jQuery Elements
$_body = $('body'),
$_fontButton = $("#accessibility-font"),
$_contrastButton = $("#accessibility-contrast"),
//Cookies
cookieFont = getCookie("accessibility_font"),
cookieContrast = getCookie("accessibility_contrast");


function getCookie(cname){
Expand All @@ -23,44 +27,36 @@
return "";
}

var $_body = $('body');

var cookieFont = getCookie("accessibility_font");

var cookieContrast = getCookie("accessibility_contrast");


if (cookieFont) {
$_body.addClass('accessibility-font');

$("#accessibility-font").html(nameButtonDecreaseFont).attr('title', nameTitleButtonDecreaseFont);
$_fontButton.html(nameButtonDecreaseFont).attr('aria-label', ariaLabelButtonDecreaseFont);
}else{
$("#accessibility-font").html(nameButtonIncreaseFont).attr('title', nameTitleButtonIncreaseFont);
$_fontButton.html(nameButtonIncreaseFont).attr('aria-label', ariaLabelButtonIncreaseFont);
};

if (cookieContrast) {
$_body.addClass('accessibility-contrast');

$("#accessibility-contrast").html(nameButtonRemoveContrast).attr('title', nameTitleButtonRemoveContrast);
$_contrastButton.html(nameButtonRemoveContrast).attr('aria-label', ariaLabelButtonRemoveContrast);
}else{
$("#accessibility-contrast").html(nameButtonAddContrast).attr('title', nameTitleButtonAddContrast);
$_contrastButton.html(nameButtonAddContrast).attr('aria-label', ariaLabelButtonAddContrast);
};

$('.js-acessibility').click(function(event) {
var $_this = $(this);

if($_body.hasClass($_this.attr('id'))){

$_body.removeClass($_this.attr('id'));

if ($_this.attr('id') == 'accessibility-font') {

$_this.html(nameButtonIncreaseFont).attr('title', nameTitleButtonIncreaseFont);
$_this.html(nameButtonIncreaseFont).attr('aria-label', ariaLabelButtonIncreaseFont);

document.cookie = "accessibility_font=True; expires=Thu, 01 Jan 1970 00:00:00 GMT; path=/";

}else{
$_this.html(nameButtonAddContrast).attr('title', nameTitleButtonAddContrast);
$_this.html(nameButtonAddContrast).attr('aria-label', ariaLabelButtonAddContrast);

document.cookie = "accessibility_contrast=True; expires=Thu, 01 Jan 1970 00:00:00 GMT; path=/";
};
Expand All @@ -72,14 +68,14 @@
if (!cookieFont) {
document.cookie = "accessibility_font=True; path=/";
};
$_this.html(nameButtonDecreaseFont).attr('title', nameTitleButtonDecreaseFont);
$_this.html(nameButtonDecreaseFont).attr('aria-label', ariaLabelButtonDecreaseFont);

}else{
if (!cookieContrast) {
document.cookie = "accessibility_contrast=True; path=/";
};

$_this.html(nameButtonRemoveContrast).attr('title', nameTitleButtonRemoveContrast);
$_this.html(nameButtonRemoveContrast).attr('aria-label', ariaLabelButtonRemoveContrast);
};
}
});
9 changes: 8 additions & 1 deletion src/scripts/onread/open_onread.js
Original file line number Diff line number Diff line change
@@ -1,2 +1,9 @@
//Main Scripts
/*
Accessibility Buttons
Version: 2.0.0
Author: Tiago Porto - http://www.tiagoporto.com
https://github.com/tiagoporto
Contact: [email protected]
*/

$(document).ready(function(){
Loading

0 comments on commit cd6f9f9

Please sign in to comment.