renusify 2.1.1 → 2.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -4,7 +4,7 @@ export * as rCalendarYearTab from './year.vue'
|
|
|
4
4
|
export * as l_container from '../container/index.js'
|
|
5
5
|
export * as l_row from '../container/row.js'
|
|
6
6
|
export * as l_col from '../container/col.js'
|
|
7
|
-
export * as l_btn from '
|
|
7
|
+
export * as l_btn from '../button/index.js'
|
|
8
8
|
export * as l_icon from '../icon/index.js'
|
|
9
9
|
export * as l_card from '../card/index.js'
|
|
10
10
|
export * as l_modal from '../modal/index.js'
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export * as
|
|
1
|
+
export * as rChartMap from './worldMap.vue'
|
|
2
2
|
export * as l_float from '../float/index.js'
|
package/components/index.js
CHANGED
package/components/meta/index.js
CHANGED
|
@@ -1,155 +1 @@
|
|
|
1
|
-
|
|
2
|
-
export const rMeta= {
|
|
3
|
-
name: "r-meta",
|
|
4
|
-
created(){
|
|
5
|
-
this.build()
|
|
6
|
-
},
|
|
7
|
-
watch: {
|
|
8
|
-
'$attrs': {
|
|
9
|
-
handler() {
|
|
10
|
-
this.build()
|
|
11
|
-
},
|
|
12
|
-
deep: true
|
|
13
|
-
},
|
|
14
|
-
},
|
|
15
|
-
activated() {
|
|
16
|
-
this.build()
|
|
17
|
-
},
|
|
18
|
-
deactivated() {
|
|
19
|
-
this.removeAll()
|
|
20
|
-
},
|
|
21
|
-
methods: {
|
|
22
|
-
build() {
|
|
23
|
-
for (let i in this.$attrs) {
|
|
24
|
-
if (this.$helper.hasKey(this.$attrs, i)) {
|
|
25
|
-
this[i](this.$attrs[i]);
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
},
|
|
29
|
-
html(obj) {
|
|
30
|
-
/*
|
|
31
|
-
:html="{
|
|
32
|
-
body: {id: 'aPageId'},
|
|
33
|
-
h1: {'data-foo': 'bar'},
|
|
34
|
-
}"
|
|
35
|
-
*/
|
|
36
|
-
Object.keys(obj).forEach(selector =>
|
|
37
|
-
this.setRootElementAttributes(selector, obj[selector])
|
|
38
|
-
);
|
|
39
|
-
},
|
|
40
|
-
head(obj) {
|
|
41
|
-
/*
|
|
42
|
-
:head="{
|
|
43
|
-
'meta[charset]': {charset: 'utf-8'},
|
|
44
|
-
}"
|
|
45
|
-
*/
|
|
46
|
-
Object.keys(obj).forEach(selector =>
|
|
47
|
-
this.setHeadElementAttributes(selector, obj[selector])
|
|
48
|
-
);
|
|
49
|
-
},
|
|
50
|
-
title(val) {
|
|
51
|
-
document.title = this.isRemoveValue(val) ? "" : val;
|
|
52
|
-
this.setMetaContent('itemprop="name"', val);
|
|
53
|
-
this.setMetaContent('property="og:title"', val);
|
|
54
|
-
this.setMetaContent('name="twitter:title"', val);
|
|
55
|
-
},
|
|
56
|
-
description(val) {
|
|
57
|
-
this.setMetaContent('name="description"', val);
|
|
58
|
-
this.setMetaContent('itemprop="description"', val);
|
|
59
|
-
this.setMetaContent('property="og:description"', val);
|
|
60
|
-
this.setMetaContent('name="twitter:description"', val);
|
|
61
|
-
},
|
|
62
|
-
keywords(val) {
|
|
63
|
-
this.setMetaContent('name="keywords"',val);
|
|
64
|
-
},
|
|
65
|
-
image(val) {
|
|
66
|
-
this.setMetaContent('itemprop="image"', val);
|
|
67
|
-
this.setMetaContent('property="og:image"', val);
|
|
68
|
-
this.setMetaContent('name="twitter:image"', val);
|
|
69
|
-
},
|
|
70
|
-
lang(val) {
|
|
71
|
-
this.setRootElementAttributes("html", {lang: val});
|
|
72
|
-
this.ogLocaleTag && this.setOgLocaleIfValid(val);
|
|
73
|
-
},
|
|
74
|
-
ogLocale(val) {
|
|
75
|
-
this.setMetaContent('property="og:locale"', val);
|
|
76
|
-
},
|
|
77
|
-
url(val) {
|
|
78
|
-
this.setHeadElementAttributes('link[rel="canonical"]', {href: val});
|
|
79
|
-
this.setMetaContent('property="og:url"', val);
|
|
80
|
-
this.setMetaContent('name="twitter:url"', val);
|
|
81
|
-
},
|
|
82
|
-
createChild(parent, selector) {
|
|
83
|
-
if (!this.getElement(parent, selector)) {
|
|
84
|
-
let property = selector;
|
|
85
|
-
property = property.split("[");
|
|
86
|
-
const name = property[0];
|
|
87
|
-
property = this.$helper.replacer(property[1], "]", "");
|
|
88
|
-
property = this.$helper.replacer(property, '"', "");
|
|
89
|
-
property = this.$helper.replacer(property, "'", "");
|
|
90
|
-
property = property.trim(" ");
|
|
91
|
-
property = property.split("=");
|
|
92
|
-
let meta = document.createElement(name);
|
|
93
|
-
meta.setAttribute("c", "renusify");
|
|
94
|
-
meta.setAttribute(property[0], property[1]);
|
|
95
|
-
parent.appendChild(meta);
|
|
96
|
-
}
|
|
97
|
-
},
|
|
98
|
-
setMetaContent(attr, val) {
|
|
99
|
-
this.createChild(document.head, `meta[${attr}]`);
|
|
100
|
-
this.setHeadElementAttributes(`meta[${attr}]`, {content: val});
|
|
101
|
-
},
|
|
102
|
-
setRootElementAttributes(selector, attributes) {
|
|
103
|
-
this.createChild(document, selector);
|
|
104
|
-
this.setElementAttributes(
|
|
105
|
-
this.getElement(document, selector),
|
|
106
|
-
attributes
|
|
107
|
-
);
|
|
108
|
-
},
|
|
109
|
-
setHeadElementAttributes(selector, attributes) {
|
|
110
|
-
this.createChild(document.head, selector);
|
|
111
|
-
this.setElementAttributes(
|
|
112
|
-
this.getElement(document.head, selector),
|
|
113
|
-
attributes
|
|
114
|
-
);
|
|
115
|
-
},
|
|
116
|
-
setElementAttributes(element, attributes) {
|
|
117
|
-
if (element) {
|
|
118
|
-
Object.keys(attributes).forEach(attrName => {
|
|
119
|
-
if (this.isRemoveValue(attributes[attrName])) {
|
|
120
|
-
element.removeAttribute(attrName);
|
|
121
|
-
} else {
|
|
122
|
-
element.setAttribute(attrName, attributes[attrName]);
|
|
123
|
-
}
|
|
124
|
-
});
|
|
125
|
-
}
|
|
126
|
-
},
|
|
127
|
-
getElement(parent, selector) {
|
|
128
|
-
return parent.querySelector(selector);
|
|
129
|
-
},
|
|
130
|
-
setOgLocaleIfValid(locale) {
|
|
131
|
-
if (this.isRemoveValue(locale)) {
|
|
132
|
-
this.ogLocale(locale);
|
|
133
|
-
} else if (locale.match(/^[a-z]{2}-[a-z]{2}$/i)) {
|
|
134
|
-
const [language, region] = locale.split("-");
|
|
135
|
-
const ogLocale = `${language}_${region.toUpperCase()}`;
|
|
136
|
-
this.ogLocale(ogLocale);
|
|
137
|
-
}
|
|
138
|
-
},
|
|
139
|
-
isRemoveValue(val) {
|
|
140
|
-
return val === undefined || val === null;
|
|
141
|
-
},
|
|
142
|
-
removeAll() {
|
|
143
|
-
let children = document.querySelectorAll("[c='renusify']");
|
|
144
|
-
if (children) {
|
|
145
|
-
let childArray = Array.prototype.slice.call(children);
|
|
146
|
-
|
|
147
|
-
childArray.forEach(function (child) {
|
|
148
|
-
child.parentNode.removeChild(child);
|
|
149
|
-
});
|
|
150
|
-
}
|
|
151
|
-
}
|
|
152
|
-
},
|
|
153
|
-
render() {
|
|
154
|
-
}
|
|
155
|
-
};
|
|
1
|
+
export * as rMeta from './index.js'
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
//https://github.com/troxler/headful/blob/master/src/headful.js
|
|
2
|
+
export default {
|
|
3
|
+
name: "r-meta",
|
|
4
|
+
created(){
|
|
5
|
+
this.build()
|
|
6
|
+
},
|
|
7
|
+
watch: {
|
|
8
|
+
'$attrs': {
|
|
9
|
+
handler() {
|
|
10
|
+
this.build()
|
|
11
|
+
},
|
|
12
|
+
deep: true
|
|
13
|
+
},
|
|
14
|
+
},
|
|
15
|
+
activated() {
|
|
16
|
+
this.build()
|
|
17
|
+
},
|
|
18
|
+
deactivated() {
|
|
19
|
+
this.removeAll()
|
|
20
|
+
},
|
|
21
|
+
methods: {
|
|
22
|
+
build() {
|
|
23
|
+
for (let i in this.$attrs) {
|
|
24
|
+
if (this.$helper.hasKey(this.$attrs, i)) {
|
|
25
|
+
this[i](this.$attrs[i]);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
},
|
|
29
|
+
html(obj) {
|
|
30
|
+
/*
|
|
31
|
+
:html="{
|
|
32
|
+
body: {id: 'aPageId'},
|
|
33
|
+
h1: {'data-foo': 'bar'},
|
|
34
|
+
}"
|
|
35
|
+
*/
|
|
36
|
+
Object.keys(obj).forEach(selector =>
|
|
37
|
+
this.setRootElementAttributes(selector, obj[selector])
|
|
38
|
+
);
|
|
39
|
+
},
|
|
40
|
+
head(obj) {
|
|
41
|
+
/*
|
|
42
|
+
:head="{
|
|
43
|
+
'meta[charset]': {charset: 'utf-8'},
|
|
44
|
+
}"
|
|
45
|
+
*/
|
|
46
|
+
Object.keys(obj).forEach(selector =>
|
|
47
|
+
this.setHeadElementAttributes(selector, obj[selector])
|
|
48
|
+
);
|
|
49
|
+
},
|
|
50
|
+
title(val) {
|
|
51
|
+
document.title = this.isRemoveValue(val) ? "" : val;
|
|
52
|
+
this.setMetaContent('itemprop="name"', val);
|
|
53
|
+
this.setMetaContent('property="og:title"', val);
|
|
54
|
+
this.setMetaContent('name="twitter:title"', val);
|
|
55
|
+
},
|
|
56
|
+
description(val) {
|
|
57
|
+
this.setMetaContent('name="description"', val);
|
|
58
|
+
this.setMetaContent('itemprop="description"', val);
|
|
59
|
+
this.setMetaContent('property="og:description"', val);
|
|
60
|
+
this.setMetaContent('name="twitter:description"', val);
|
|
61
|
+
},
|
|
62
|
+
keywords(val) {
|
|
63
|
+
this.setMetaContent('name="keywords"',val);
|
|
64
|
+
},
|
|
65
|
+
image(val) {
|
|
66
|
+
this.setMetaContent('itemprop="image"', val);
|
|
67
|
+
this.setMetaContent('property="og:image"', val);
|
|
68
|
+
this.setMetaContent('name="twitter:image"', val);
|
|
69
|
+
},
|
|
70
|
+
lang(val) {
|
|
71
|
+
this.setRootElementAttributes("html", {lang: val});
|
|
72
|
+
this.ogLocaleTag && this.setOgLocaleIfValid(val);
|
|
73
|
+
},
|
|
74
|
+
ogLocale(val) {
|
|
75
|
+
this.setMetaContent('property="og:locale"', val);
|
|
76
|
+
},
|
|
77
|
+
url(val) {
|
|
78
|
+
this.setHeadElementAttributes('link[rel="canonical"]', {href: val});
|
|
79
|
+
this.setMetaContent('property="og:url"', val);
|
|
80
|
+
this.setMetaContent('name="twitter:url"', val);
|
|
81
|
+
},
|
|
82
|
+
createChild(parent, selector) {
|
|
83
|
+
if (!this.getElement(parent, selector)) {
|
|
84
|
+
let property = selector;
|
|
85
|
+
property = property.split("[");
|
|
86
|
+
const name = property[0];
|
|
87
|
+
property = this.$helper.replacer(property[1], "]", "");
|
|
88
|
+
property = this.$helper.replacer(property, '"', "");
|
|
89
|
+
property = this.$helper.replacer(property, "'", "");
|
|
90
|
+
property = property.trim(" ");
|
|
91
|
+
property = property.split("=");
|
|
92
|
+
let meta = document.createElement(name);
|
|
93
|
+
meta.setAttribute("c", "renusify");
|
|
94
|
+
meta.setAttribute(property[0], property[1]);
|
|
95
|
+
parent.appendChild(meta);
|
|
96
|
+
}
|
|
97
|
+
},
|
|
98
|
+
setMetaContent(attr, val) {
|
|
99
|
+
this.createChild(document.head, `meta[${attr}]`);
|
|
100
|
+
this.setHeadElementAttributes(`meta[${attr}]`, {content: val});
|
|
101
|
+
},
|
|
102
|
+
setRootElementAttributes(selector, attributes) {
|
|
103
|
+
this.createChild(document, selector);
|
|
104
|
+
this.setElementAttributes(
|
|
105
|
+
this.getElement(document, selector),
|
|
106
|
+
attributes
|
|
107
|
+
);
|
|
108
|
+
},
|
|
109
|
+
setHeadElementAttributes(selector, attributes) {
|
|
110
|
+
this.createChild(document.head, selector);
|
|
111
|
+
this.setElementAttributes(
|
|
112
|
+
this.getElement(document.head, selector),
|
|
113
|
+
attributes
|
|
114
|
+
);
|
|
115
|
+
},
|
|
116
|
+
setElementAttributes(element, attributes) {
|
|
117
|
+
if (element) {
|
|
118
|
+
Object.keys(attributes).forEach(attrName => {
|
|
119
|
+
if (this.isRemoveValue(attributes[attrName])) {
|
|
120
|
+
element.removeAttribute(attrName);
|
|
121
|
+
} else {
|
|
122
|
+
element.setAttribute(attrName, attributes[attrName]);
|
|
123
|
+
}
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
},
|
|
127
|
+
getElement(parent, selector) {
|
|
128
|
+
return parent.querySelector(selector);
|
|
129
|
+
},
|
|
130
|
+
setOgLocaleIfValid(locale) {
|
|
131
|
+
if (this.isRemoveValue(locale)) {
|
|
132
|
+
this.ogLocale(locale);
|
|
133
|
+
} else if (locale.match(/^[a-z]{2}-[a-z]{2}$/i)) {
|
|
134
|
+
const [language, region] = locale.split("-");
|
|
135
|
+
const ogLocale = `${language}_${region.toUpperCase()}`;
|
|
136
|
+
this.ogLocale(ogLocale);
|
|
137
|
+
}
|
|
138
|
+
},
|
|
139
|
+
isRemoveValue(val) {
|
|
140
|
+
return val === undefined || val === null;
|
|
141
|
+
},
|
|
142
|
+
removeAll() {
|
|
143
|
+
let children = document.querySelectorAll("[c='renusify']");
|
|
144
|
+
if (children) {
|
|
145
|
+
let childArray = Array.prototype.slice.call(children);
|
|
146
|
+
|
|
147
|
+
childArray.forEach(function (child) {
|
|
148
|
+
child.parentNode.removeChild(child);
|
|
149
|
+
});
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
},
|
|
153
|
+
render() {
|
|
154
|
+
}
|
|
155
|
+
};
|