Skip to content

Commit 7750365

Browse files
committed
added alert module - closes #11
1 parent 9327133 commit 7750365

File tree

15 files changed

+1138
-63
lines changed

15 files changed

+1138
-63
lines changed

demo/dist/assets/logo-80.png

1.38 KB
Loading

demo/dist/assets/logo.png

645 Bytes
Loading

demo/dist/assets/sweetalert.css

Lines changed: 932 additions & 0 deletions
Large diffs are not rendered by default.

demo/src/demo/alert/index.html

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<div>
2+
<ui-button @click="sample1">A basic message</ui-button><p/>
3+
<ui-button @click="sample2">A title with a text under</ui-button><p/>
4+
<ui-button @click="sample3">A success message!</ui-button><p/>
5+
<ui-button @click="sample4">A warning message, with a function attached to the "Confirm"-button...</ui-button><p/>
6+
<ui-button @click="sample5">... and by passing a parameter, you can execute something else for "Cancel".</ui-button><p/>
7+
<ui-button @click="sample6">A message with a custom icon</ui-button><p/>
8+
<ui-button @click="sample7">An HTML message</ui-button><p/>
9+
<ui-button @click="sample8">A message with auto close timer</ui-button><p/>
10+
<ui-button @click="sample9">A replacement for the "prompt" function</ui-button><p/>
11+
<ui-button @click="sample10">With a loader (for AJAX request for example)</ui-button>
12+
</div>

demo/src/demo/alert/index.ts

Lines changed: 124 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,124 @@
1+
import { Component, Prop } from 'vue-typed';
2+
import { Base } from '../base'
3+
import * as Vue from 'vue'
4+
5+
@Component({
6+
template: require('./index.html')
7+
})
8+
export class Alert extends Base {
9+
10+
sample1() {
11+
this.$ui.alert("Here's a message!")
12+
}
13+
14+
sample2() {
15+
this.$ui.alert("Here's a message!", "It's pretty, isn't it?")
16+
}
17+
18+
sample3() {
19+
this.$ui.alert("Good job!", "You clicked the button!", "success")
20+
}
21+
22+
sample4() {
23+
this.$ui.alert({
24+
title: "Are you sure?",
25+
text: "You will not be able to recover this imaginary file!",
26+
type: "warning",
27+
showCancelButton: true,
28+
confirmButtonColor: "#DD6B55",
29+
confirmButtonText: "Yes, delete it!",
30+
closeOnConfirm: false
31+
},
32+
function () {
33+
swal("Deleted!", "Your imaginary file has been deleted.", "success");
34+
})
35+
}
36+
37+
sample5() {
38+
this.$ui.alert({
39+
title: "Are you sure?",
40+
text: "You will not be able to recover this imaginary file!",
41+
type: "warning",
42+
showCancelButton: true,
43+
confirmButtonColor: "#DD6B55",
44+
confirmButtonText: "Yes, delete it!",
45+
cancelButtonText: "No, cancel plx!",
46+
closeOnConfirm: false,
47+
closeOnCancel: false
48+
},
49+
function (isConfirm) {
50+
if (isConfirm) {
51+
swal("Deleted!", "Your imaginary file has been deleted.", "success");
52+
} else {
53+
swal("Cancelled", "Your imaginary file is safe :)", "error");
54+
}
55+
})
56+
}
57+
58+
sample6() {
59+
this.$ui.alert({
60+
title: "Sweet!",
61+
text: "Here's a custom image.",
62+
imageUrl: "assets/logo-80.png"
63+
})
64+
}
65+
66+
sample7() {
67+
this.$ui.alert({
68+
title: "HTML <small>Title</small>!",
69+
text: "A custom <span style=\"color: #F8BB86\">html<span> message.",
70+
html: true
71+
})
72+
}
73+
74+
sample8() {
75+
this.$ui.alert({
76+
title: "Auto close alert!",
77+
text: "I will close in 2 seconds.",
78+
timer: 2000,
79+
showConfirmButton: false
80+
})
81+
}
82+
83+
84+
sample9() {
85+
this.$ui.alert({
86+
title: "An input!",
87+
text: "Write something interesting:",
88+
type: "input",
89+
showCancelButton: true,
90+
closeOnConfirm: false,
91+
animation: "slide-from-top",
92+
inputPlaceholder: "Write something"
93+
},
94+
function (inputValue) {
95+
if (inputValue === false) return false;
96+
97+
if (inputValue === "") {
98+
swal.showInputError("You need to write something!");
99+
return false
100+
}
101+
102+
swal("Nice!", "You wrote: " + inputValue, "success");
103+
})
104+
}
105+
106+
sample10() {
107+
this.$ui.alert({
108+
title: "Ajax request example",
109+
text: "Submit to run ajax request",
110+
type: "info",
111+
showCancelButton: true,
112+
closeOnConfirm: false,
113+
showLoaderOnConfirm: true,
114+
},
115+
function () {
116+
setTimeout(function () {
117+
swal("Ajax request finished!");
118+
}, 2000);
119+
})
120+
}
121+
122+
123+
124+
}

demo/src/demo/routes.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import { Modal } from './modal';
1616
import { Tree } from './tree';
1717
import { Menu } from './menu';
1818
import { Message } from './message';
19+
import { Alert } from './alert';
1920

2021

2122
// Main routes builder
@@ -37,7 +38,8 @@ const m = [
3738
{ text: 'Modal', path: 'modal', component: Modal },
3839
{ text: 'Tree', path: 'tree', component: Tree },
3940
{ text: 'Menu', path: 'menu', component: Menu },
40-
{ text: 'Message', path: 'message', component: Message }
41+
{ text: 'Message', path: 'message', component: Message },
42+
{ text: 'Alert', path: 'alert', component: Alert }
4143
]
4244

4345
// Build router routes

demo/webpack.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ var config = {
2626
{ test: /\.html$/, loader: 'html-loader' },
2727
{ test: /\.json$/, loader: 'json-loader' },
2828
{ test: /\.less$/, loader: 'style-loader!css-loader!less-loader' },
29-
{ test: /\.css$/, loader: 'style-loader/url!file-loader' },
29+
{ test: /\.css$/, loader: 'style-loader/url!file-loader?name=assets/[name].[ext]' },
3030
{ test: /\.(jpe?g|png|gif|svg)$/i, loader: 'file-loader?name=assets/[name].[ext]' }
3131
]
3232
},

dist/vue-typed-ui.d.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,22 @@ import * as sets from '../lib/settings'
44
import * as formOpt from '../lib/form-options'
55
// import { Modal } from '../lib/methods/modal'
66
import {VueTypedUIMethods} from '../lib/methods'
7+
import * as modules from '../lib/modules'
78

89
declare namespace VueTypedUI {
910
export type Options = opts.Options
1011
export type Settings = sets.Settings
1112
export type FormOptions = formOpt.FormOptions
1213
export function FormComponent(options: FormOptions): ClassDecorator
13-
export function Validate(options): PropertyDecorator
14+
export function Validate(options): PropertyDecorator
1415
}
1516

1617
declare class VueTypedUI extends VueTypedUIMethods {
1718
static install: Vue.PluginFunction<VueTypedUI.Options>
1819
$settings: VueTypedUI.Settings
1920

2021
createValidationRule(name: string, rule: Function)
22+
alert: modules.Alert
2123
}
2224

2325
declare module "vue/types/vue" {

dist/vue-typed-ui.js

Lines changed: 38 additions & 57 deletions
Large diffs are not rendered by default.

lib/modules.d.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import * as swal from 'sweetalert'
2+
3+
export type Alert = typeof swal

0 commit comments

Comments
 (0)