Skip to content
This repository has been archived by the owner on Dec 16, 2021. It is now read-only.

Commit

Permalink
v0.8.0
Browse files Browse the repository at this point in the history
Added option closeOnBgClick. See readme for more infos.
  • Loading branch information
DavideTriso committed May 19, 2017
1 parent ad184bd commit 91db8ee
Show file tree
Hide file tree
Showing 11 changed files with 45 additions and 33 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ dialogContainerClass | dialog__container | string | Class of a dialog container.
dialogHeadingClass | dialog__heading | string | Class of a dialog heading. | optional
dialogType | modal | token | Set type of dialog: modal or alert. For more informations see [https://www.w3.org/TR/wai-aria-practices-1.1/#alertdialog](https://www.w3.org/TR/wai-aria-practices-1.1/#alertdialog) and [https://www.w3.org/TR/wai-aria-practices-1.1/#dialog_modal](https://www.w3.org/TR/wai-aria-practices-1.1/#dialog_modal). (Support for non-modal dialog is planned for future verions of the plugin). | optional
closeWithEsc | false | bool | Close dialog when esc key is pressed. | optional (recommended value: true)
closeOnBgClick | false | bool | Close dialog if user clicks on dialog background | optional
dialogContainerRole | document | token | Role of dialog content. Accepted values: document, application. For more information see [https://www.w3.org/TR/wai-aria-1.1/](https://www.w3.org/TR/wai-aria-1.1/). | optional
zIndex | 100 | int | Z-index assigned to dialog. | optional
fadeSpeed | 100 | int (>= 0) | Duration of fade-in and fade-out animations. | optional
Expand Down
14 changes: 12 additions & 2 deletions aria-dialog.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@
dialogType: 'modal', // modal, alert (alertdialog)
dialogContainerRole: 'document',
closeWithEsc: false,
closeOnBgClick: false,
zIndex: 100,
fadeSpeed: 100,
preventScroll: true
Expand Down Expand Up @@ -95,11 +96,11 @@
elements.wrapper.css({
opacity: 0
});

//Set needed attributes to dialog elements
switch (settings.dialogType) {
case 'modal':
//case 'non-modal':
//case 'non-modal':
elements.wrapper.attr(a.r, 'dialog');
break;
case 'alert':
Expand Down Expand Up @@ -173,6 +174,15 @@
}
});
}
//close dialog if user clicks on bg
if (dialogsArray[index][2].closeOnBgClick) {
dialog.on('click', function (event) {
methods.close(dialog);
});
wrapper.on('click', function (event) {
event.stopPropagation();
});
}
};


Expand Down
2 changes: 1 addition & 1 deletion aria-dialog.min.js

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

17 changes: 14 additions & 3 deletions demo/aria-dialog.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@
dialogType: 'modal', // modal, alert (alertdialog)
dialogContainerRole: 'document',
closeWithEsc: false,
closeOnBgClick: false,
zIndex: 100,
fadeSpeed: 100,
preventScroll: true
Expand Down Expand Up @@ -95,11 +96,11 @@
elements.wrapper.css({
opacity: 0
});

//Set needed attributes to dialog elements
switch (settings.dialogType) {
case 'modal':
//case 'non-modal':
//case 'non-modal':
elements.wrapper.attr(a.r, 'dialog');
break;
case 'alert':
Expand Down Expand Up @@ -173,6 +174,15 @@
}
});
}
//close dialog if user clicks on bg
if (dialogsArray[index][2].closeOnBgClick) {
dialog.on('click', function (event) {
methods.close(dialog);
});
wrapper.on('click', function (event) {
event.stopPropagation();
});
}
};


Expand Down Expand Up @@ -269,7 +279,8 @@ $(document).ready(function () {
'use strict';
$('#dialog-1').ariaDialog({
fadeSpeed: 200,
closeWithEsc: true
closeWithEsc: true,
closeOnBgClick: true
});

$('#dialog-2').ariaDialog({
Expand Down
1 change: 1 addition & 0 deletions demo/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

<head>
<title>Dialog demo</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta charset="utf-8">
<link rel="stylesheet" href="aria-dialog.css" />
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
Expand Down
3 changes: 3 additions & 0 deletions scss/01_placeholders/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# PLACEHOLDERS

## ABOUT
3 changes: 3 additions & 0 deletions scss/01_placeholders/_placeholders-all.scss
Original file line number Diff line number Diff line change
Expand Up @@ -900,6 +900,9 @@
%height-0 {
height: 0;
}
%height-100 {
height: 100%;
}
%justify-content-flex-start {
-webkit-justify-content: flex-start;
justify-content: flex-start;
Expand Down
3 changes: 3 additions & 0 deletions scss/01_placeholders/_placeholders-desktop.scss
Original file line number Diff line number Diff line change
Expand Up @@ -901,6 +901,9 @@
%desktop-height-0 {
height: 0;
}
%desktop-height-100 {
height: 100%;
}
%desktop-justify-content-flex-start {
-webkit-justify-content: flex-start;
justify-content: flex-start;
Expand Down
3 changes: 3 additions & 0 deletions scss/01_placeholders/_placeholders-tablet.scss
Original file line number Diff line number Diff line change
Expand Up @@ -901,6 +901,9 @@
%tablet-height-0 {
height: 0;
}
%tablet-height-100 {
height: 100%;
}
%tablet-justify-content-flex-start {
-webkit-justify-content: flex-start;
justify-content: flex-start;
Expand Down
4 changes: 4 additions & 0 deletions scss/02_css-mixins/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# CSS MIXINS

## ABOUT

27 changes: 0 additions & 27 deletions scss/_variables.scss

This file was deleted.

0 comments on commit 91db8ee

Please sign in to comment.