|
1
|
|
|
/** |
|
2
|
|
|
* SEOmatic plugin for Craft CMS 3.x |
|
3
|
|
|
* |
|
4
|
|
|
* A turnkey SEO implementation for Craft CMS that is comprehensive, powerful, |
|
5
|
|
|
* and flexible |
|
6
|
|
|
* |
|
7
|
|
|
* @link https://nystudio107.com |
|
8
|
|
|
* @copyright Copyright (c) 2017 nystudio107 |
|
9
|
|
|
*/ |
|
10
|
|
|
|
|
11
|
|
|
import SchemaTypeList from "../vue/SchemaTypeList.vue"; |
|
12
|
|
|
|
|
13
|
|
|
/** |
|
14
|
|
|
* @author nystudio107 |
|
15
|
|
|
* @package SEOmatic |
|
16
|
|
|
* @since 3.0.0 |
|
17
|
|
|
*/ |
|
18
|
|
|
|
|
19
|
|
|
if (window.schemaSelectId !== undefined) { |
|
|
|
|
|
|
20
|
|
|
// Create our vue instance |
|
21
|
|
|
const vm = new Vue({ |
|
|
|
|
|
|
22
|
|
|
el: '#' + window.schemaSelectId, |
|
|
|
|
|
|
23
|
|
|
components: { |
|
|
|
|
|
|
24
|
|
|
'schema-type-list': SchemaTypeList, |
|
|
|
|
|
|
25
|
|
|
}, |
|
|
|
|
|
|
26
|
|
|
data: {}, |
|
|
|
|
|
|
27
|
|
|
methods: {}, |
|
|
|
|
|
|
28
|
|
|
mounted() { |
|
29
|
|
|
}, |
|
|
|
|
|
|
30
|
|
|
}); |
|
31
|
|
|
} |
|
|
|
|
|
|
32
|
|
|
|
|
33
|
|
|
// Accept HMR as per: https://webpack.js.org/api/hot-module-replacement#accept |
|
34
|
|
|
if (module.hot) { |
|
35
|
|
|
module.hot.accept(); |
|
36
|
|
|
} |
|
37
|
|
|
|
|
38
|
|
|
function seomaticTabChangeHandler() { |
|
|
|
|
|
|
39
|
|
|
// Tab handler |
|
40
|
|
|
$('.seomatic-tab-links').on('click', function(e) { |
|
|
|
|
|
|
41
|
|
|
e.preventDefault(); |
|
42
|
|
|
$('.seomatic-tab-links').removeClass('sel'); |
|
43
|
|
|
$(this).addClass('sel'); |
|
44
|
|
|
$('.seomatic-tab-content').addClass('hidden'); |
|
45
|
|
|
var selector = $(this).attr('href'); |
|
46
|
|
|
$(selector).removeClass('hidden'); |
|
47
|
|
|
}); |
|
48
|
|
|
} |
|
49
|
|
|
|
|
50
|
|
|
window.seomaticTabChangeHandler = seomaticTabChangeHandler; |
|
51
|
|
|
window.seomaticTabChangeHandler(); |
|
52
|
|
|
|
|
53
|
|
|
$(function() { |
|
|
|
|
|
|
54
|
|
|
// Show/hide the script settings containers |
|
55
|
|
|
var selector = $('.seomatic-script-lightswitch').find('.lightswitch'); |
|
56
|
|
|
$(selector).each(function(index, value) { |
|
|
|
|
|
|
57
|
|
|
var value = $(this).find('input').first().val(); |
|
58
|
|
|
if (value) { |
|
59
|
|
|
$(this).closest('.seomatic-script-wrapper').find('.seomatic-script-container').show(); |
|
60
|
|
|
} else { |
|
61
|
|
|
$(this).closest('.seomatic-script-wrapper').find('.seomatic-script-container').hide(); |
|
62
|
|
|
} |
|
63
|
|
|
}); |
|
64
|
|
|
$(selector).on('click', function(e) { |
|
|
|
|
|
|
65
|
|
|
var value = $(this).find('input').first().val(); |
|
66
|
|
|
if (value) { |
|
67
|
|
|
$(this).closest('.seomatic-script-wrapper').find('.seomatic-script-container').slideDown(); |
|
68
|
|
|
} else { |
|
69
|
|
|
$(this).closest('.seomatic-script-wrapper').find('.seomatic-script-container').slideUp(); |
|
70
|
|
|
} |
|
71
|
|
|
}); |
|
72
|
|
|
|
|
73
|
|
|
// Show/hide the image source fields initially |
|
74
|
|
|
$('.seomatic-imageSourceSelect > select').each(function(index, value) { |
|
|
|
|
|
|
75
|
|
|
var popupValue = $(this).val(); |
|
76
|
|
|
switch (popupValue) { |
|
77
|
|
|
case 'sameAsSeo': |
|
|
|
|
|
|
78
|
|
|
$(this).closest('.seomatic-imageSourceWrapper').children('.seomatic-imageSourceNotFromUrl').show(); |
|
79
|
|
|
$(this).closest('.seomatic-imageSourceWrapper').children('.seomatic-imageSourceFromField').hide(); |
|
80
|
|
|
$(this).closest('.seomatic-imageSourceWrapper').children('.seomatic-imageSourceFromAsset').hide(); |
|
81
|
|
|
$(this).closest('.seomatic-imageSourceWrapper').children('.seomatic-imageSourceFromUrl').hide(); |
|
82
|
|
|
break; |
|
83
|
|
|
|
|
84
|
|
|
case 'fromField': |
|
|
|
|
|
|
85
|
|
|
$(this).closest('.seomatic-imageSourceWrapper').children('.seomatic-imageSourceNotFromUrl').show(); |
|
86
|
|
|
$(this).closest('.seomatic-imageSourceWrapper').children('.seomatic-imageSourceFromField').show(); |
|
87
|
|
|
$(this).closest('.seomatic-imageSourceWrapper').children('.seomatic-imageSourceFromAsset').hide(); |
|
88
|
|
|
$(this).closest('.seomatic-imageSourceWrapper').children('.seomatic-imageSourceFromUrl').hide(); |
|
89
|
|
|
break; |
|
90
|
|
|
|
|
91
|
|
|
case 'fromAsset': |
|
|
|
|
|
|
92
|
|
|
$(this).closest('.seomatic-imageSourceWrapper').children('.seomatic-imageSourceNotFromUrl').show(); |
|
93
|
|
|
$(this).closest('.seomatic-imageSourceWrapper').children('.seomatic-imageSourceFromField').hide(); |
|
94
|
|
|
$(this).closest('.seomatic-imageSourceWrapper').children('.seomatic-imageSourceFromAsset').show(); |
|
95
|
|
|
$(this).closest('.seomatic-imageSourceWrapper').children('.seomatic-imageSourceFromUrl').hide(); |
|
96
|
|
|
break; |
|
97
|
|
|
|
|
98
|
|
|
case 'fromUrl': |
|
|
|
|
|
|
99
|
|
|
$(this).closest('.seomatic-imageSourceWrapper').children('.seomatic-imageSourceNotFromUrl').hide(); |
|
100
|
|
|
$(this).closest('.seomatic-imageSourceWrapper').children('.seomatic-imageSourceFromField').hide(); |
|
101
|
|
|
$(this).closest('.seomatic-imageSourceWrapper').children('.seomatic-imageSourceFromAsset').hide(); |
|
102
|
|
|
$(this).closest('.seomatic-imageSourceWrapper').children('.seomatic-imageSourceFromUrl').show(); |
|
103
|
|
|
break; |
|
104
|
|
|
} |
|
105
|
|
|
}); |
|
106
|
|
|
// Handle hiding/showing the image source fields based on the selection |
|
107
|
|
|
$('.seomatic-imageSourceSelect > select').on('change', function(e) { |
|
|
|
|
|
|
108
|
|
|
switch (this.value) { |
|
109
|
|
|
case 'sameAsSeo': |
|
|
|
|
|
|
110
|
|
|
$(this).closest('.seomatic-imageSourceWrapper').children('.seomatic-imageSourceNotFromUrl').slideDown(); |
|
111
|
|
|
$(this).closest('.seomatic-imageSourceWrapper').children('.seomatic-imageSourceFromField').slideUp(); |
|
112
|
|
|
$(this).closest('.seomatic-imageSourceWrapper').children('.seomatic-imageSourceFromAsset').slideUp(); |
|
113
|
|
|
$(this).closest('.seomatic-imageSourceWrapper').children('.seomatic-imageSourceFromUrl').slideUp(); |
|
114
|
|
|
break; |
|
115
|
|
|
|
|
116
|
|
|
case 'fromField': |
|
|
|
|
|
|
117
|
|
|
$(this).closest('.seomatic-imageSourceWrapper').children('.seomatic-imageSourceNotFromUrl').slideDown(); |
|
118
|
|
|
$(this).closest('.seomatic-imageSourceWrapper').children('.seomatic-imageSourceFromField').slideDown(); |
|
119
|
|
|
$(this).closest('.seomatic-imageSourceWrapper').children('.seomatic-imageSourceFromAsset').slideUp(); |
|
120
|
|
|
$(this).closest('.seomatic-imageSourceWrapper').children('.seomatic-imageSourceFromUrl').slideUp(); |
|
121
|
|
|
break; |
|
122
|
|
|
|
|
123
|
|
|
case 'fromAsset': |
|
|
|
|
|
|
124
|
|
|
$(this).closest('.seomatic-imageSourceWrapper').children('.seomatic-imageSourceNotFromUrl').slideDown(); |
|
125
|
|
|
$(this).closest('.seomatic-imageSourceWrapper').children('.seomatic-imageSourceFromField').slideUp(); |
|
126
|
|
|
$(this).closest('.seomatic-imageSourceWrapper').children('.seomatic-imageSourceFromAsset').slideDown(); |
|
127
|
|
|
$(this).closest('.seomatic-imageSourceWrapper').children('.seomatic-imageSourceFromUrl').slideUp(); |
|
128
|
|
|
break; |
|
129
|
|
|
|
|
130
|
|
|
case 'fromUrl': |
|
|
|
|
|
|
131
|
|
|
$(this).closest('.seomatic-imageSourceWrapper').children('.seomatic-imageSourceNotFromUrl').slideUp(); |
|
132
|
|
|
$(this).closest('.seomatic-imageSourceWrapper').children('.seomatic-imageSourceFromField').slideUp(); |
|
133
|
|
|
$(this).closest('.seomatic-imageSourceWrapper').children('.seomatic-imageSourceFromAsset').slideUp(); |
|
134
|
|
|
$(this).closest('.seomatic-imageSourceWrapper').children('.seomatic-imageSourceFromUrl').slideDown(); |
|
135
|
|
|
break; |
|
136
|
|
|
} |
|
137
|
|
|
}); |
|
138
|
|
|
|
|
139
|
|
|
// Show/hide the text source fields initially |
|
140
|
|
|
$('.seomatic-textSourceSelect > select').each(function(index, value) { |
|
|
|
|
|
|
141
|
|
|
var popupValue = $(this).val(); |
|
142
|
|
|
switch (popupValue) { |
|
143
|
|
|
case 'sameAsSeo': |
|
|
|
|
|
|
144
|
|
|
case 'sameAsGlobal': |
|
|
|
|
|
|
145
|
|
|
case 'sameAsSiteTwitter': |
|
|
|
|
|
|
146
|
|
|
$(this).closest('.seomatic-textSourceWrapper').children('.seomatic-textSourceFromField').hide(); |
|
147
|
|
|
$(this).closest('.seomatic-textSourceWrapper').children('.seomatic-textSourceFromUrl').hide(); |
|
148
|
|
|
break; |
|
149
|
|
|
|
|
150
|
|
|
case 'fromField': |
|
|
|
|
|
|
151
|
|
|
case 'summaryFromField': |
|
|
|
|
|
|
152
|
|
|
case 'keywordsFromField': |
|
|
|
|
|
|
153
|
|
|
case 'fromUserField': |
|
|
|
|
|
|
154
|
|
|
$(this).closest('.seomatic-textSourceWrapper').children('.seomatic-textSourceFromField').show(); |
|
155
|
|
|
$(this).closest('.seomatic-textSourceWrapper').children('.seomatic-textSourceFromUrl').hide(); |
|
156
|
|
|
break; |
|
157
|
|
|
|
|
158
|
|
|
case 'fromCustom': |
|
|
|
|
|
|
159
|
|
|
$(this).closest('.seomatic-textSourceWrapper').children('.seomatic-textSourceFromField').hide(); |
|
160
|
|
|
$(this).closest('.seomatic-textSourceWrapper').children('.seomatic-textSourceFromUrl').show(); |
|
161
|
|
|
break; |
|
162
|
|
|
} |
|
163
|
|
|
}); |
|
164
|
|
|
// Handle hiding/showing the image source fields based on the selection |
|
165
|
|
|
$('.seomatic-textSourceSelect > select').on('change', function(e) { |
|
|
|
|
|
|
166
|
|
|
switch (this.value) { |
|
167
|
|
|
case 'sameAsSeo': |
|
|
|
|
|
|
168
|
|
|
case 'sameAsGlobal': |
|
|
|
|
|
|
169
|
|
|
case 'sameAsSiteTwitter': |
|
|
|
|
|
|
170
|
|
|
$(this).closest('.seomatic-textSourceWrapper').children('.seomatic-textSourceFromField').hide(); |
|
171
|
|
|
$(this).closest('.seomatic-textSourceWrapper').children('.seomatic-textSourceFromUrl').hide(); |
|
172
|
|
|
break; |
|
173
|
|
|
|
|
174
|
|
|
case 'fromField': |
|
|
|
|
|
|
175
|
|
|
case 'summaryFromField': |
|
|
|
|
|
|
176
|
|
|
case 'keywordsFromField': |
|
|
|
|
|
|
177
|
|
|
case 'fromUserField': |
|
|
|
|
|
|
178
|
|
|
$(this).closest('.seomatic-textSourceWrapper').children('.seomatic-textSourceFromField').show(); |
|
179
|
|
|
$(this).closest('.seomatic-textSourceWrapper').children('.seomatic-textSourceFromUrl').hide(); |
|
180
|
|
|
break; |
|
181
|
|
|
|
|
182
|
|
|
case 'fromCustom': |
|
|
|
|
|
|
183
|
|
|
$(this).closest('.seomatic-textSourceWrapper').children('.seomatic-textSourceFromField').hide(); |
|
184
|
|
|
$(this).closest('.seomatic-textSourceWrapper').children('.seomatic-textSourceFromUrl').show(); |
|
185
|
|
|
break; |
|
186
|
|
|
} |
|
187
|
|
|
}); |
|
188
|
|
|
}); |
|
189
|
|
|
|