Skip to content

Commit 4a55edd

Browse files
committed
Optimize scripts.
1 parent 8054d10 commit 4a55edd

File tree

7 files changed

+27
-20
lines changed

7 files changed

+27
-20
lines changed

README.md

+2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
> A lightweight, promise based alert, prompt and confirm dialog.
44
5+
[![Build Status](https://scrutinizer-ci.com/g/Godofbrowser/vuejs-dialog/badges/build.png?b=master)](https://scrutinizer-ci.com/g/Godofbrowser/vuejs-dialog/build-status/master)
6+
[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/Godofbrowser/vuejs-dialog/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/Godofbrowser/vuejs-dialog/?branch=master)
57

68
![Vuejs Dialog Plugin](./src/docs/img/html-enabled.png?raw=true "Vuejs Dialog Plugin example")
79
![Vuejs Dialog Plugin](./src/docs/img/demo.gif?raw=true "Vuejs Dialog Plugin usage demo")

dist/vuejs-dialog.min.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/vuejs-dialog.min.js.map

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/app.main.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/index.html

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<meta charset="UTF-8">
55
<title>VueJs Plugin usage example</title>
66
<meta name="viewport" content="width=device-width, initial-scale=1.0">
7-
<link href="app.main.css?4c2bab1f9ccdd0470ea4" rel="stylesheet"></head>
7+
<link href="app.main.css?952aa728a6180ea6b2b1" rel="stylesheet"></head>
88
<body>
99
<div id="app"></div>
1010

@@ -21,5 +21,5 @@
2121
ga('send', 'pageview');
2222

2323
</script>
24-
<script type="text/javascript" src="app.main.js?4c2bab1f9ccdd0470ea4"></script></body>
24+
<script type="text/javascript" src="app.main.js?952aa728a6180ea6b2b1"></script></body>
2525
</html>

src/docs/js/translations.js

+10-9
Original file line numberDiff line numberDiff line change
@@ -3,29 +3,30 @@
33
import en from './translations/en'
44

55

6-
const Translator = function(translations, separator = '.'){
6+
const Translator = function (translations, separator = '.') {
77
let lang = window.navigator.languages[1] || window.navigator.userLanguage[1]
88
this.lang = typeof translations[lang] !== 'undefined' ? lang : 'en'
9-
this.separator = '.'
9+
this.separator = separator
1010
this.translations = translations
1111
}
1212

1313
Translator.prototype.get = function (route) {
1414
let parts = route.split(this.separator)
1515
let translation = this.translations[this.lang]
16-
parts.forEach(key => {
17-
translation = translation[key]
18-
if (translation === undefined){
16+
17+
for (let i = 0; i < parts.length; i++) {
18+
translation = translation[parts[i]]
19+
if (translation === undefined) {
1920
translation = 'No Translation'
20-
return
21+
break
2122
}
22-
})
23-
return translation
23+
}
2424

25+
return translation
2526
}
2627

2728
let T = new Translator({en})
2829

29-
export default function(n){
30+
export default function (n) {
3031
return T.get(n)
3132
}

src/plugin/js/directives.js

+10-6
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,17 @@
33
import {noop} from './utilities'
44

55
export default function (Vue) {
6-
let Directives = function (Vue) {
6+
let Directives = function () {}
7+
8+
Directives.prototype.init = function (Vue) {
79
this.Vue = Vue
810
this.registerConfirm()
911
}
1012

1113
Directives.prototype.registerConfirm = function () {
1214
const _this = this
1315

14-
const clickHandler = function (event, el, binding, vnode) {
16+
const clickHandler = function (event, el, binding) {
1517
event.preventDefault()
1618
event.stopImmediatePropagation()
1719

@@ -59,12 +61,13 @@ export default function (Vue) {
5961
}
6062

6163
this.Vue.directive('confirm', {
62-
bind (el, binding, vnode) {
63-
if (el.VuejsDialog === undefined)
64+
bind (el, binding) {
65+
if (el.VuejsDialog === undefined) {
6466
el.VuejsDialog = {}
67+
}
6568

6669
el.VuejsDialog.confirmHandler = function clickEventHandler(event) {
67-
clickHandler(event, el, binding, vnode)
70+
clickHandler(event, el, binding)
6871
}
6972

7073
el.addEventListener('click', el.VuejsDialog.confirmHandler, true)
@@ -77,5 +80,6 @@ export default function (Vue) {
7780

7881
}
7982

80-
new Directives(Vue)
83+
let D = new Directives()
84+
D.init(Vue)
8185
}

0 commit comments

Comments
 (0)