mirror of
https://github.com/tenrok/vue-tribute.git
synced 2026-06-24 19:01:41 +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
|
collection: this.params.values
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
this.tribute = new Tribute({
|
this.tribute = new Tribute(Object.assign({
|
||||||
values: this.params.values,
|
values: this.params.values
|
||||||
options: options
|
}, options));
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
this.tribute.attach(this.el);
|
this.tribute.attach(this.el);
|
||||||
|
|||||||
+3
-4
@@ -32,10 +32,9 @@
|
|||||||
collection: this.params.values
|
collection: this.params.values
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
this.tribute = new Tribute({
|
this.tribute = new Tribute(Object.assign({
|
||||||
values: this.params.values,
|
values: this.params.values
|
||||||
options: options
|
}, options));
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
this.tribute.attach(this.el);
|
this.tribute.attach(this.el);
|
||||||
|
|||||||
+6
-1
@@ -19,7 +19,8 @@
|
|||||||
"example": "vbuild --dev",
|
"example": "vbuild --dev",
|
||||||
"example:build": "vbuild -t VueTribute",
|
"example:build": "vbuild -t VueTribute",
|
||||||
"test": "karma start karma.conf.js --single-run true --auto-watch false",
|
"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",
|
"main": "index.js",
|
||||||
"files": [
|
"files": [
|
||||||
@@ -42,6 +43,10 @@
|
|||||||
"babel-runtime": "^6.9.2",
|
"babel-runtime": "^6.9.2",
|
||||||
"babelify": "^7.3.0",
|
"babelify": "^7.3.0",
|
||||||
"browserify": "^13.0.1",
|
"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",
|
"jasmine-core": "^2.4.1",
|
||||||
"karma": "^1.1.1",
|
"karma": "^1.1.1",
|
||||||
"karma-browserify": "^5.1.0",
|
"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")
|
throw new Error("[vue-tribute] cannot locate tributejs")
|
||||||
}
|
}
|
||||||
|
|
||||||
exports.install = function(Vue, options){
|
exports.install = function (Vue, options) {
|
||||||
Vue.directive("tribute", {
|
Vue.directive("tribute", {
|
||||||
params: ["values"],
|
params: ["values"],
|
||||||
tribute: null,
|
tribute: null,
|
||||||
paramWatchers: {
|
paramWatchers: {
|
||||||
values(val, oldVal){
|
values (val, oldVal) {
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
this.setValues(val);
|
this.setValues(val)
|
||||||
}, 0)
|
}, 0)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
bind(){
|
bind () {
|
||||||
// If it has a "values" property, it's actually a collection
|
// 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({
|
this.tribute = new Tribute({
|
||||||
collection: this.params.values,
|
collection: this.params.values
|
||||||
});
|
})
|
||||||
}
|
} else {
|
||||||
else {
|
this.tribute = new Tribute(Object.assign({
|
||||||
this.tribute = new Tribute({
|
values: this.params.values
|
||||||
values: this.params.values,
|
}, options))
|
||||||
options
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
this.tribute.attach(this.el);
|
this.tribute.attach(this.el)
|
||||||
this.el.addEventListener("tribute-replaced", (e) => {
|
this.el.addEventListener("tribute-replaced", e => {
|
||||||
this.vm.$emit("tribute-replaced");
|
this.vm.$emit("tribute-replaced")
|
||||||
});
|
})
|
||||||
this.el.addEventListener("tribute-no-match", (e) => {
|
this.el.addEventListener("tribute-no-match", e => {
|
||||||
this.vm.$emit("tribute-no-match");
|
this.vm.$emit("tribute-no-match")
|
||||||
});
|
})
|
||||||
},
|
},
|
||||||
setValues(values){
|
setValues (values) {
|
||||||
// If it has a "values" property, it's actually a collection
|
// If it has a "values" property, it's actually a collection
|
||||||
if( values.hasOwnProperty("values") ){
|
if (values.hasOwnProperty("values")) {
|
||||||
this.tribute.collection = values;
|
this.tribute.collection = values
|
||||||
}
|
} else {
|
||||||
else {
|
this.tribute.collection[0].values = values
|
||||||
this.tribute.collection[0].values = values;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
})
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user