Skip to content

Commit ef532b7

Browse files
author
Philippe Assis
committed
all
1 parent f861bf1 commit ef532b7

File tree

16 files changed

+295
-157
lines changed

16 files changed

+295
-157
lines changed

README.md

Lines changed: 30 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#custom-alert.js
22
![custom-alert.js](https://raw.githubusercontent.com/PhilippeAssis/custom-alert/master/customAlert2.jpg)
33

4-
Override the alert () and confirm () functions of JavaScript, allowing you to customize them. This application does not use jQuery or another framework, just JavaScript and CSS. Responsive design.
4+
Override the alert() and confirm() functions of JavaScript, allowing you to customize them. This application does not use jQuery or another framework, just JavaScript and CSS. Responsive design.
55

66
## Demo
77
[demo page](https://philippeassis.github.io/custom-alert)
@@ -31,7 +31,7 @@ Default bootstrap style
3131

3232
and script
3333
```html
34-
<script src="YOU/PATH/dist/js/custom-alert.min.js">
34+
<!--<script src="YOU/PATH/dist/js/custom-alert.min.js">-->
3535
```
3636

3737
## Use
@@ -99,9 +99,12 @@ Setting Title and Text of Buttons.
9999
//..
100100
}, {
101101
"title" : "Wellcome",
102-
"buttons": {
103-
"done" : ":)",
104-
"cancel" : ":("
102+
"done": {
103+
"text": ":)",
104+
},
105+
"cancel": {
106+
"text" : ":(",
107+
"default": true
105108
}
106109
})
107110
```
@@ -115,13 +118,30 @@ Setting Title and Text of Buttons.
115118

116119
#### Confirm
117120
##### options
118-
- **title:** The title.
119-
- **buttons.done:** The done text.
120-
- **buttons.cancel:** The cancel text.
121+
- **title.text** The title.
122+
- **title.default** If true, set the default as default.
123+
- **title.bold** Add bold text.
124+
- **done.text** The done text.
125+
- **done.default** If true, set the default as default.
126+
- **done.bold** Add bold text.
127+
- **cancel:** The cancel text.
121128

122129
##### callback
123-
- **buttons.success:** if button done press.
124-
- **buttons.cancel:** if button calcel press.
130+
- **success:** if button done press.
131+
- **cancel:** if button calcel press.
125132
- **only function:** Gets an attribute with true or false.
126133

134+
## Keyboard events
135+
The ENTER key performs the default button.
136+
137+
```javascript
138+
{
139+
"cancel": {
140+
"default" : true
141+
}
142+
}
143+
```
144+
In this example, the default button will be "Cancel", so by clicking ENTER on the keyboard, this button will be executed.
145+
**By default the "default button" is done.**
146+
127147
I see an example on the [demo page](https://philippeassis.github.io/custom-alert)

demo/assets/js/demo.js

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,16 @@ function demo1() {
88
confirm("Ok?", function(done) {
99
if (!done) {
1010
confirm("No?", function(done) {
11+
console.log('NO!')
1112
if (!done) {
1213
alert("Cry... :/")
1314
}
1415
else {
1516
alert("Good!")
1617
}
1718
}, {
18-
"buttons": {
19-
"done": "No, no... Good!",
20-
"cancel": "No."
21-
}
19+
"done": "No, no... Good!",
20+
"cancel": "No."
2221
})
2322
}
2423
else {
@@ -27,10 +26,15 @@ function demo1() {
2726

2827
}, {
2928
"title": "Demo Confirm",
30-
"buttons": {
31-
"done": ":)",
32-
"cancel": ":("
29+
30+
"done": {
31+
"text": ":)",
32+
},
33+
"cancel": {
34+
"text" : ":(",
35+
"default": true
3336
}
37+
3438
})
3539
})
3640
}

demo/assets/styl/demo.styl

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
.demo
2+
padding 0% 20%
3+
text-align center
4+
font-family: 'Roboto', sans-serif;
5+
h1
6+
margin-bottom 40px
7+
a
8+
background-color #3e619b
9+
color #fff
10+
padding 5px 10px
11+
text-decoration none
12+
border-radius 5px
13+
14+
pre
15+
margin-top 40px
16+
padding: 20px
17+
border-radius 5px
18+
text-align left
19+
font-family: 'Ubuntu', sans-serif;
20+
background-color #20252d
21+
color: #fff
22+
width 100%
23+
float left
24+
box-sizing: border-box;
25+
code
26+
width 100%
27+
float left
28+

demo/assets/views/index.pug

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,14 @@ html
44
meta(charset='utf-8')
55
title custom-alert.js :: Demo
66
link(rel="stylesheet", href="dist/css/custom-alert.css")
7+
link(href="https://fonts.googleapis.com/css?family=Roboto|Ubuntu" rel="stylesheet")
8+
link(rel="stylesheet", href="demo/public/css/demo.css")
79
body
8-
h1 custom-alert.js
9-
pre
10-
code
11-
a(href="#", onclick="demo1()") Click to demo.
12-
script(src="dist/js/custom-alert.min.js")
10+
.demo
11+
h1 custom-alert.js
12+
a(href="#", onclick="demo1()") Click to demo
13+
pre
14+
code
15+
script(src="dist/js/custom-alert-debug.js")
1316
script(src="demo/public/js/demo.js")
1417

demo/public/css/demo.css

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

demo/public/js/demo-min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

demo/public/js/demo.js

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,16 @@ function demo1() {
88
confirm("Ok?", function(done) {
99
if (!done) {
1010
confirm("No?", function(done) {
11+
console.log('NO!')
1112
if (!done) {
1213
alert("Cry... :/")
1314
}
1415
else {
1516
alert("Good!")
1617
}
1718
}, {
18-
"buttons": {
19-
"done": "No, no... Good!",
20-
"cancel": "No."
21-
}
19+
"done": "No, no... Good!",
20+
"cancel": "No."
2221
})
2322
}
2423
else {
@@ -27,10 +26,15 @@ function demo1() {
2726

2827
}, {
2928
"title": "Demo Confirm",
30-
"buttons": {
31-
"done": ":)",
32-
"cancel": ":("
29+
30+
"done": {
31+
"text": ":)",
32+
},
33+
"cancel": {
34+
"text" : ":(",
35+
"default": true
3336
}
37+
3438
})
3539
})
3640
}

dist/css/custom-alert-bootstrap.css

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/css/custom-alert.css

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)