mirror of
https://github.com/tenrok/vue-tribute.git
synced 2026-06-17 14:10:34 +03:00
Fix constructor params, add eslint, fix all current linting issues
This commit is contained in:
@@ -0,0 +1,7 @@
|
||||
{
|
||||
"extends": "standard",
|
||||
"rules": {
|
||||
"arrow-parens": [2, "as-needed"],
|
||||
"quotes": [2, "double"]
|
||||
}
|
||||
}
|
||||
@@ -30,10 +30,9 @@ exports.install = function (Vue, options) {
|
||||
collection: this.params.values
|
||||
});
|
||||
} else {
|
||||
this.tribute = new Tribute({
|
||||
values: this.params.values,
|
||||
options: options
|
||||
});
|
||||
this.tribute = new Tribute(Object.assign({
|
||||
values: this.params.values
|
||||
}, options));
|
||||
}
|
||||
|
||||
this.tribute.attach(this.el);
|
||||
|
||||
+3
-4
@@ -32,10 +32,9 @@
|
||||
collection: this.params.values
|
||||
});
|
||||
} else {
|
||||
this.tribute = new Tribute({
|
||||
values: this.params.values,
|
||||
options: options
|
||||
});
|
||||
this.tribute = new Tribute(Object.assign({
|
||||
values: this.params.values
|
||||
}, options));
|
||||
}
|
||||
|
||||
this.tribute.attach(this.el);
|
||||
|
||||
+6
-1
@@ -19,7 +19,8 @@
|
||||
"example": "vbuild --dev",
|
||||
"example:build": "vbuild -t VueTribute",
|
||||
"test": "karma start karma.conf.js --single-run true --auto-watch false",
|
||||
"watch-test": "karma start karma.conf.js --single-run false --auto-watch true"
|
||||
"watch-test": "karma start karma.conf.js --single-run false --auto-watch true",
|
||||
"lint": "eslint src"
|
||||
},
|
||||
"main": "index.js",
|
||||
"files": [
|
||||
@@ -42,6 +43,10 @@
|
||||
"babel-runtime": "^6.9.2",
|
||||
"babelify": "^7.3.0",
|
||||
"browserify": "^13.0.1",
|
||||
"eslint": "^3.1.1",
|
||||
"eslint-config-standard": "^5.3.5",
|
||||
"eslint-plugin-promise": "^2.0.0",
|
||||
"eslint-plugin-standard": "^2.0.0",
|
||||
"jasmine-core": "^2.4.1",
|
||||
"karma": "^1.1.1",
|
||||
"karma-browserify": "^5.1.0",
|
||||
|
||||
+26
-30
@@ -1,51 +1,47 @@
|
||||
import Tribute from "tributejs";
|
||||
import Tribute from "tributejs"
|
||||
|
||||
if(!Tribute){
|
||||
if (!Tribute) {
|
||||
throw new Error("[vue-tribute] cannot locate tributejs")
|
||||
}
|
||||
|
||||
exports.install = function(Vue, options){
|
||||
exports.install = function (Vue, options) {
|
||||
Vue.directive("tribute", {
|
||||
params: ["values"],
|
||||
tribute: null,
|
||||
paramWatchers: {
|
||||
values(val, oldVal){
|
||||
values (val, oldVal) {
|
||||
setTimeout(() => {
|
||||
this.setValues(val);
|
||||
this.setValues(val)
|
||||
}, 0)
|
||||
}
|
||||
},
|
||||
bind(){
|
||||
bind () {
|
||||
// If it has a "values" property, it's actually a collection
|
||||
if( this.params.values.hasOwnProperty("values") ){
|
||||
if (this.params.values.hasOwnProperty("values")) {
|
||||
this.tribute = new Tribute({
|
||||
collection: this.params.values,
|
||||
});
|
||||
}
|
||||
else {
|
||||
this.tribute = new Tribute({
|
||||
values: this.params.values,
|
||||
options
|
||||
});
|
||||
collection: this.params.values
|
||||
})
|
||||
} else {
|
||||
this.tribute = new Tribute(Object.assign({
|
||||
values: this.params.values
|
||||
}, options))
|
||||
}
|
||||
|
||||
this.tribute.attach(this.el);
|
||||
this.el.addEventListener("tribute-replaced", (e) => {
|
||||
this.vm.$emit("tribute-replaced");
|
||||
});
|
||||
this.el.addEventListener("tribute-no-match", (e) => {
|
||||
this.vm.$emit("tribute-no-match");
|
||||
});
|
||||
this.tribute.attach(this.el)
|
||||
this.el.addEventListener("tribute-replaced", e => {
|
||||
this.vm.$emit("tribute-replaced")
|
||||
})
|
||||
this.el.addEventListener("tribute-no-match", e => {
|
||||
this.vm.$emit("tribute-no-match")
|
||||
})
|
||||
},
|
||||
setValues(values){
|
||||
setValues (values) {
|
||||
// If it has a "values" property, it's actually a collection
|
||||
if( values.hasOwnProperty("values") ){
|
||||
this.tribute.collection = values;
|
||||
}
|
||||
else {
|
||||
this.tribute.collection[0].values = values;
|
||||
if (values.hasOwnProperty("values")) {
|
||||
this.tribute.collection = values
|
||||
} else {
|
||||
this.tribute.collection[0].values = values
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user