@oxyshop/admin 1.3.46 → 1.3.49
Sign up to get free protection for your applications and to get access to all the features.
- package/images/50x50.png +0 -0
- package/lib/index.js +21 -253
- package/lib/style.css +0 -0
- package/package.json +1 -1
- package/src/components/customerGroupClientAssigner.js +20 -23
- package/src/index.js +1 -3
- package/src/plugins/ckeditor/index.js +0 -29
- package/src/components/article-slug.js +0 -65
- package/src/components/blog-category-slug.js +0 -71
- package/src/components/blog-slug.js +0 -65
package/images/50x50.png
ADDED
Binary file
|
package/lib/index.js
CHANGED
@@ -30,6 +30,7 @@ import '@oxyshop/admin/scss/main.scss';
|
|
30
30
|
import '@oxyshop/admin/lib/style.css';
|
31
31
|
import '@oxyshop/admin/images/logo.png';
|
32
32
|
import '@oxyshop/admin/images/admin-logo.svg';
|
33
|
+
import '@oxyshop/admin/images/50x50.png';
|
33
34
|
import { axios } from '@oxyshop/shop/lib/plugins/Axios';
|
34
35
|
|
35
36
|
window.$ = $$1;
|
@@ -2038,207 +2039,6 @@ class CustomerGroupingRuleConfiguration {
|
|
2038
2039
|
}
|
2039
2040
|
}
|
2040
2041
|
|
2041
|
-
(function ($) {
|
2042
|
-
|
2043
|
-
$.fn.extend({
|
2044
|
-
blogSlugGenerator: function () {
|
2045
|
-
let timeout;
|
2046
|
-
|
2047
|
-
$('[name*="nextgen_cms_bundle_blog[translations]"][name*="[name]"]').on('input', function () {
|
2048
|
-
clearTimeout(timeout);
|
2049
|
-
let element = $(this);
|
2050
|
-
|
2051
|
-
timeout = setTimeout(function () {
|
2052
|
-
updateSlug(element);
|
2053
|
-
}, 1000);
|
2054
|
-
});
|
2055
|
-
|
2056
|
-
$('.toggle-blog-slug-modification').on('click', function (e) {
|
2057
|
-
e.preventDefault();
|
2058
|
-
toggleSlugModification($(this), $(this).siblings('input'));
|
2059
|
-
});
|
2060
|
-
|
2061
|
-
function updateSlug(element) {
|
2062
|
-
let slugInput = element.parents('.content').find('[name*="[slug]"]');
|
2063
|
-
let loadableParent = slugInput.parents('.field.loadable');
|
2064
|
-
|
2065
|
-
if ('readonly' === slugInput.attr('readonly')) {
|
2066
|
-
return
|
2067
|
-
}
|
2068
|
-
|
2069
|
-
loadableParent.addClass('loading');
|
2070
|
-
|
2071
|
-
$.ajax({
|
2072
|
-
type: 'GET',
|
2073
|
-
url: slugInput.attr('data-url'),
|
2074
|
-
data: { name: element.val() },
|
2075
|
-
dataType: 'json',
|
2076
|
-
accept: 'application/json',
|
2077
|
-
success: function (data) {
|
2078
|
-
slugInput.val(data.slug);
|
2079
|
-
if (slugInput.parents('.field').hasClass('error')) {
|
2080
|
-
slugInput.parents('.field').removeClass('error');
|
2081
|
-
slugInput.parents('.field').find('.sylius-validation-error').remove();
|
2082
|
-
}
|
2083
|
-
loadableParent.removeClass('loading');
|
2084
|
-
},
|
2085
|
-
});
|
2086
|
-
}
|
2087
|
-
|
2088
|
-
function toggleSlugModification(button, slugInput) {
|
2089
|
-
if (slugInput.attr('readonly')) {
|
2090
|
-
slugInput.removeAttr('readonly');
|
2091
|
-
button.html('<i class="unlock icon"></i>');
|
2092
|
-
} else {
|
2093
|
-
slugInput.attr('readonly', 'readonly');
|
2094
|
-
button.html('<i class="lock icon"></i>');
|
2095
|
-
}
|
2096
|
-
}
|
2097
|
-
},
|
2098
|
-
});
|
2099
|
-
})(jQuery)
|
2100
|
-
;(function ($) {
|
2101
|
-
$(document).ready(function () {
|
2102
|
-
$(this).blogSlugGenerator();
|
2103
|
-
});
|
2104
|
-
})(jQuery);
|
2105
|
-
|
2106
|
-
(function ($) {
|
2107
|
-
|
2108
|
-
$.fn.extend({
|
2109
|
-
articleSlugGenerator: function () {
|
2110
|
-
let timeout;
|
2111
|
-
|
2112
|
-
$('[name*="nextgen_cms_bundle_article[translations]"][name*="[name]"]').on('input', function () {
|
2113
|
-
clearTimeout(timeout);
|
2114
|
-
let element = $(this);
|
2115
|
-
|
2116
|
-
timeout = setTimeout(function () {
|
2117
|
-
updateSlug(element);
|
2118
|
-
}, 1000);
|
2119
|
-
});
|
2120
|
-
|
2121
|
-
$('.toggle-article-slug-modification').on('click', function (e) {
|
2122
|
-
e.preventDefault();
|
2123
|
-
toggleSlugModification($(this), $(this).siblings('input'));
|
2124
|
-
});
|
2125
|
-
|
2126
|
-
function updateSlug(element) {
|
2127
|
-
let slugInput = element.parents('.content').find('[name*="[slug]"]');
|
2128
|
-
let loadableParent = slugInput.parents('.field.loadable');
|
2129
|
-
|
2130
|
-
if ('readonly' === slugInput.attr('readonly')) {
|
2131
|
-
return
|
2132
|
-
}
|
2133
|
-
|
2134
|
-
loadableParent.addClass('loading');
|
2135
|
-
|
2136
|
-
$.ajax({
|
2137
|
-
type: 'GET',
|
2138
|
-
url: slugInput.attr('data-url'),
|
2139
|
-
data: { name: element.val() },
|
2140
|
-
dataType: 'json',
|
2141
|
-
accept: 'application/json',
|
2142
|
-
success: function (data) {
|
2143
|
-
slugInput.val(data.slug);
|
2144
|
-
if (slugInput.parents('.field').hasClass('error')) {
|
2145
|
-
slugInput.parents('.field').removeClass('error');
|
2146
|
-
slugInput.parents('.field').find('.sylius-validation-error').remove();
|
2147
|
-
}
|
2148
|
-
loadableParent.removeClass('loading');
|
2149
|
-
},
|
2150
|
-
});
|
2151
|
-
}
|
2152
|
-
|
2153
|
-
function toggleSlugModification(button, slugInput) {
|
2154
|
-
if (slugInput.attr('readonly')) {
|
2155
|
-
slugInput.removeAttr('readonly');
|
2156
|
-
button.html('<i class="unlock icon"></i>');
|
2157
|
-
} else {
|
2158
|
-
slugInput.attr('readonly', 'readonly');
|
2159
|
-
button.html('<i class="lock icon"></i>');
|
2160
|
-
}
|
2161
|
-
}
|
2162
|
-
},
|
2163
|
-
});
|
2164
|
-
})(jQuery)
|
2165
|
-
;(function ($) {
|
2166
|
-
$(document).ready(function () {
|
2167
|
-
$(this).articleSlugGenerator();
|
2168
|
-
});
|
2169
|
-
})(jQuery);
|
2170
|
-
|
2171
|
-
(function ($) {
|
2172
|
-
|
2173
|
-
$.fn.extend({
|
2174
|
-
blogCategorySlugGenerator: function () {
|
2175
|
-
let timeout;
|
2176
|
-
|
2177
|
-
$('[name*="nextgen_cms_bundle_blog_category[translations]"][name*="[name]"]').on('input', function () {
|
2178
|
-
clearTimeout(timeout);
|
2179
|
-
let element = $(this);
|
2180
|
-
|
2181
|
-
timeout = setTimeout(function () {
|
2182
|
-
updateSlug(element);
|
2183
|
-
}, 1000);
|
2184
|
-
});
|
2185
|
-
|
2186
|
-
$('.toggle-blog-category-slug-modification').on('click', function (e) {
|
2187
|
-
e.preventDefault();
|
2188
|
-
toggleSlugModification($(this), $(this).siblings('input'));
|
2189
|
-
});
|
2190
|
-
|
2191
|
-
function updateSlug(element) {
|
2192
|
-
let slugInput = element.parents('.content').find('[name*="[slug]"]');
|
2193
|
-
let loadableParent = slugInput.parents('.field.loadable');
|
2194
|
-
|
2195
|
-
if ('readonly' === slugInput.attr('readonly')) {
|
2196
|
-
return
|
2197
|
-
}
|
2198
|
-
|
2199
|
-
loadableParent.addClass('loading');
|
2200
|
-
|
2201
|
-
let data;
|
2202
|
-
data = {
|
2203
|
-
name: element.val(),
|
2204
|
-
locale: element.closest('[data-locale]').data('locale'),
|
2205
|
-
};
|
2206
|
-
|
2207
|
-
$.ajax({
|
2208
|
-
type: 'GET',
|
2209
|
-
url: slugInput.attr('data-url'),
|
2210
|
-
data: data,
|
2211
|
-
dataType: 'json',
|
2212
|
-
accept: 'application/json',
|
2213
|
-
success: function (data) {
|
2214
|
-
slugInput.val(data.slug);
|
2215
|
-
if (slugInput.parents('.field').hasClass('error')) {
|
2216
|
-
slugInput.parents('.field').removeClass('error');
|
2217
|
-
slugInput.parents('.field').find('.sylius-validation-error').remove();
|
2218
|
-
}
|
2219
|
-
loadableParent.removeClass('loading');
|
2220
|
-
},
|
2221
|
-
});
|
2222
|
-
}
|
2223
|
-
|
2224
|
-
function toggleSlugModification(button, slugInput) {
|
2225
|
-
if (slugInput.attr('readonly')) {
|
2226
|
-
slugInput.removeAttr('readonly');
|
2227
|
-
button.html('<i class="unlock icon"></i>');
|
2228
|
-
} else {
|
2229
|
-
slugInput.attr('readonly', 'readonly');
|
2230
|
-
button.html('<i class="lock icon"></i>');
|
2231
|
-
}
|
2232
|
-
}
|
2233
|
-
},
|
2234
|
-
});
|
2235
|
-
})(jQuery)
|
2236
|
-
;(function ($) {
|
2237
|
-
$(document).ready(function () {
|
2238
|
-
$(this).blogCategorySlugGenerator();
|
2239
|
-
});
|
2240
|
-
})(jQuery);
|
2241
|
-
|
2242
2042
|
/**
|
2243
2043
|
* CKEditor config
|
2244
2044
|
*/
|
@@ -2332,35 +2132,6 @@ vendorDescriptionElements.forEach((element) => {
|
|
2332
2132
|
CKEDITOR.replace(element.name, ckEditorOptions);
|
2333
2133
|
});
|
2334
2134
|
|
2335
|
-
/**
|
2336
|
-
* Blog article
|
2337
|
-
*/
|
2338
|
-
const articleAnnotationElements = document.querySelectorAll(
|
2339
|
-
'form[name="nextgen_cms_bundle_article"] textarea[name$="[annotation]"]'
|
2340
|
-
);
|
2341
|
-
articleAnnotationElements.forEach((element) => {
|
2342
|
-
// eslint-disable-next-line no-undef
|
2343
|
-
CKEDITOR.replace(element.name, ckEditorOptions);
|
2344
|
-
});
|
2345
|
-
const articleContentElements = document.querySelectorAll(
|
2346
|
-
'form[name="nextgen_cms_bundle_article"] textarea[name$="[content]"]'
|
2347
|
-
);
|
2348
|
-
articleContentElements.forEach((element) => {
|
2349
|
-
// eslint-disable-next-line no-undef
|
2350
|
-
CKEDITOR.replace(element.name, ckEditorOptions);
|
2351
|
-
});
|
2352
|
-
|
2353
|
-
/**
|
2354
|
-
* Blog category
|
2355
|
-
*/
|
2356
|
-
const categoryDescriptionElements = document.querySelectorAll(
|
2357
|
-
'form[name="nextgen_cms_bundle_blog_category"] textarea[name$="[description]"]'
|
2358
|
-
);
|
2359
|
-
categoryDescriptionElements.forEach((element) => {
|
2360
|
-
// eslint-disable-next-line no-undef
|
2361
|
-
CKEDITOR.replace(element.name, ckEditorOptions);
|
2362
|
-
});
|
2363
|
-
|
2364
2135
|
(function ($) {
|
2365
2136
|
$(document).ready(function () {
|
2366
2137
|
$('#sylius_payment_method_calculator').handlePrototypes({
|
@@ -2566,33 +2337,30 @@ class CustomerGroupClientAssigner {
|
|
2566
2337
|
this.selector = selector;
|
2567
2338
|
this.searchSelector = searchSelector;
|
2568
2339
|
this.submitSelector = submitSelector;
|
2569
|
-
|
2570
|
-
this.containerElement = null;
|
2571
|
-
this.searchElement = null;
|
2572
|
-
this.submitElement = null;
|
2573
2340
|
}
|
2574
2341
|
|
2575
2342
|
init() {
|
2576
|
-
|
2577
|
-
|
2578
|
-
|
2343
|
+
document.querySelectorAll(this.selector).forEach((containerElement) => {
|
2344
|
+
const submitApiEndpoint = containerElement.getAttribute('data-assign-customers-url');
|
2345
|
+
const redirectAfterUrl = containerElement.getAttribute('data-redirect-after-url');
|
2579
2346
|
|
2580
|
-
|
2581
|
-
|
2347
|
+
const searchElement = containerElement.querySelector(this.searchSelector);
|
2348
|
+
const searchApiEndpoint = searchElement.getAttribute('data-customer-search-url');
|
2582
2349
|
|
2583
|
-
|
2584
|
-
|
2585
|
-
|
2586
|
-
|
2587
|
-
|
2350
|
+
$(searchElement).dropdown({
|
2351
|
+
apiSettings: {
|
2352
|
+
url: `${searchApiEndpoint}/{query}`,
|
2353
|
+
cache: false,
|
2354
|
+
},
|
2588
2355
|
|
2589
|
-
|
2590
|
-
|
2356
|
+
minCharacters: 2,
|
2357
|
+
});
|
2591
2358
|
|
2592
|
-
|
2593
|
-
|
2594
|
-
|
2595
|
-
|
2359
|
+
const submitElement = containerElement.querySelector(this.submitSelector);
|
2360
|
+
submitElement.addEventListener('click', () => {
|
2361
|
+
const selectedCustomersIds = this.getSelectValues(searchElement);
|
2362
|
+
this.submitCustomers(submitElement, submitApiEndpoint, selectedCustomersIds, redirectAfterUrl);
|
2363
|
+
});
|
2596
2364
|
});
|
2597
2365
|
}
|
2598
2366
|
|
@@ -2601,8 +2369,8 @@ class CustomerGroupClientAssigner {
|
|
2601
2369
|
return Array.from(selected).map((optionElement) => optionElement.value)
|
2602
2370
|
}
|
2603
2371
|
|
2604
|
-
submitCustomers(apiEndpoint, selectedIds, redirectTo) {
|
2605
|
-
|
2372
|
+
submitCustomers(submitElement, apiEndpoint, selectedIds, redirectTo) {
|
2373
|
+
submitElement.disabled = true;
|
2606
2374
|
|
2607
2375
|
axios
|
2608
2376
|
.post(apiEndpoint, { customers: selectedIds })
|
@@ -2613,7 +2381,7 @@ class CustomerGroupClientAssigner {
|
|
2613
2381
|
console.error(error);
|
2614
2382
|
})
|
2615
2383
|
.finally(() => {
|
2616
|
-
|
2384
|
+
submitElement.disabled = false;
|
2617
2385
|
});
|
2618
2386
|
}
|
2619
2387
|
}
|
package/lib/style.css
CHANGED
File without changes
|
package/package.json
CHANGED
@@ -5,33 +5,30 @@ export default class CustomerGroupClientAssigner {
|
|
5
5
|
this.selector = selector
|
6
6
|
this.searchSelector = searchSelector
|
7
7
|
this.submitSelector = submitSelector
|
8
|
-
|
9
|
-
this.containerElement = null
|
10
|
-
this.searchElement = null
|
11
|
-
this.submitElement = null
|
12
8
|
}
|
13
9
|
|
14
10
|
init() {
|
15
|
-
|
16
|
-
|
17
|
-
|
11
|
+
document.querySelectorAll(this.selector).forEach((containerElement) => {
|
12
|
+
const submitApiEndpoint = containerElement.getAttribute('data-assign-customers-url')
|
13
|
+
const redirectAfterUrl = containerElement.getAttribute('data-redirect-after-url')
|
18
14
|
|
19
|
-
|
20
|
-
|
15
|
+
const searchElement = containerElement.querySelector(this.searchSelector)
|
16
|
+
const searchApiEndpoint = searchElement.getAttribute('data-customer-search-url')
|
21
17
|
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
18
|
+
$(searchElement).dropdown({
|
19
|
+
apiSettings: {
|
20
|
+
url: `${searchApiEndpoint}/{query}`,
|
21
|
+
cache: false,
|
22
|
+
},
|
27
23
|
|
28
|
-
|
29
|
-
|
24
|
+
minCharacters: 2,
|
25
|
+
})
|
30
26
|
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
27
|
+
const submitElement = containerElement.querySelector(this.submitSelector)
|
28
|
+
submitElement.addEventListener('click', () => {
|
29
|
+
const selectedCustomersIds = this.getSelectValues(searchElement)
|
30
|
+
this.submitCustomers(submitElement, submitApiEndpoint, selectedCustomersIds, redirectAfterUrl)
|
31
|
+
})
|
35
32
|
})
|
36
33
|
}
|
37
34
|
|
@@ -40,8 +37,8 @@ export default class CustomerGroupClientAssigner {
|
|
40
37
|
return Array.from(selected).map((optionElement) => optionElement.value)
|
41
38
|
}
|
42
39
|
|
43
|
-
submitCustomers(apiEndpoint, selectedIds, redirectTo) {
|
44
|
-
|
40
|
+
submitCustomers(submitElement, apiEndpoint, selectedIds, redirectTo) {
|
41
|
+
submitElement.disabled = true
|
45
42
|
|
46
43
|
axios
|
47
44
|
.post(apiEndpoint, { customers: selectedIds })
|
@@ -52,7 +49,7 @@ export default class CustomerGroupClientAssigner {
|
|
52
49
|
console.error(error)
|
53
50
|
})
|
54
51
|
.finally(() => {
|
55
|
-
|
52
|
+
submitElement.disabled = false
|
56
53
|
})
|
57
54
|
}
|
58
55
|
}
|
package/src/index.js
CHANGED
@@ -10,9 +10,6 @@ import FeedCategorySelect from './components/feedCategorySelect'
|
|
10
10
|
import TooltipHelpers from './components/tooltipHelpers'
|
11
11
|
import AdminSidebarScroller from './components/adminSidebarScroller'
|
12
12
|
import CustomerGroupingRuleConfiguration from './components/customerGroupingRuleConfiguration'
|
13
|
-
import './components/blog-slug.js'
|
14
|
-
import './components/article-slug.js'
|
15
|
-
import './components/blog-category-slug.js'
|
16
13
|
|
17
14
|
// Scripts - plugin
|
18
15
|
import './plugins/ckeditor/index'
|
@@ -32,6 +29,7 @@ import '@oxyshop/admin/lib/style.css'
|
|
32
29
|
// Images
|
33
30
|
import '@oxyshop/admin/images/logo.png'
|
34
31
|
import '@oxyshop/admin/images/admin-logo.svg'
|
32
|
+
import '@oxyshop/admin/images/50x50.png'
|
35
33
|
import CustomerGroupClientAssigner from './components/customerGroupClientAssigner'
|
36
34
|
|
37
35
|
// Components initializations
|
@@ -90,32 +90,3 @@ vendorDescriptionElements.forEach((element) => {
|
|
90
90
|
// eslint-disable-next-line no-undef
|
91
91
|
CKEDITOR.replace(element.name, ckEditorOptions)
|
92
92
|
})
|
93
|
-
|
94
|
-
/**
|
95
|
-
* Blog article
|
96
|
-
*/
|
97
|
-
const articleAnnotationElements = document.querySelectorAll(
|
98
|
-
'form[name="nextgen_cms_bundle_article"] textarea[name$="[annotation]"]'
|
99
|
-
)
|
100
|
-
articleAnnotationElements.forEach((element) => {
|
101
|
-
// eslint-disable-next-line no-undef
|
102
|
-
CKEDITOR.replace(element.name, ckEditorOptions)
|
103
|
-
})
|
104
|
-
const articleContentElements = document.querySelectorAll(
|
105
|
-
'form[name="nextgen_cms_bundle_article"] textarea[name$="[content]"]'
|
106
|
-
)
|
107
|
-
articleContentElements.forEach((element) => {
|
108
|
-
// eslint-disable-next-line no-undef
|
109
|
-
CKEDITOR.replace(element.name, ckEditorOptions)
|
110
|
-
})
|
111
|
-
|
112
|
-
/**
|
113
|
-
* Blog category
|
114
|
-
*/
|
115
|
-
const categoryDescriptionElements = document.querySelectorAll(
|
116
|
-
'form[name="nextgen_cms_bundle_blog_category"] textarea[name$="[description]"]'
|
117
|
-
)
|
118
|
-
categoryDescriptionElements.forEach((element) => {
|
119
|
-
// eslint-disable-next-line no-undef
|
120
|
-
CKEDITOR.replace(element.name, ckEditorOptions)
|
121
|
-
})
|
@@ -1,65 +0,0 @@
|
|
1
|
-
;(function ($) {
|
2
|
-
'use strict'
|
3
|
-
|
4
|
-
$.fn.extend({
|
5
|
-
articleSlugGenerator: function () {
|
6
|
-
let timeout
|
7
|
-
|
8
|
-
$('[name*="nextgen_cms_bundle_article[translations]"][name*="[name]"]').on('input', function () {
|
9
|
-
clearTimeout(timeout)
|
10
|
-
let element = $(this)
|
11
|
-
|
12
|
-
timeout = setTimeout(function () {
|
13
|
-
updateSlug(element)
|
14
|
-
}, 1000)
|
15
|
-
})
|
16
|
-
|
17
|
-
$('.toggle-article-slug-modification').on('click', function (e) {
|
18
|
-
e.preventDefault()
|
19
|
-
toggleSlugModification($(this), $(this).siblings('input'))
|
20
|
-
})
|
21
|
-
|
22
|
-
function updateSlug(element) {
|
23
|
-
let slugInput = element.parents('.content').find('[name*="[slug]"]')
|
24
|
-
let loadableParent = slugInput.parents('.field.loadable')
|
25
|
-
|
26
|
-
if ('readonly' === slugInput.attr('readonly')) {
|
27
|
-
return
|
28
|
-
}
|
29
|
-
|
30
|
-
loadableParent.addClass('loading')
|
31
|
-
|
32
|
-
$.ajax({
|
33
|
-
type: 'GET',
|
34
|
-
url: slugInput.attr('data-url'),
|
35
|
-
data: { name: element.val() },
|
36
|
-
dataType: 'json',
|
37
|
-
accept: 'application/json',
|
38
|
-
success: function (data) {
|
39
|
-
slugInput.val(data.slug)
|
40
|
-
if (slugInput.parents('.field').hasClass('error')) {
|
41
|
-
slugInput.parents('.field').removeClass('error')
|
42
|
-
slugInput.parents('.field').find('.sylius-validation-error').remove()
|
43
|
-
}
|
44
|
-
loadableParent.removeClass('loading')
|
45
|
-
},
|
46
|
-
})
|
47
|
-
}
|
48
|
-
|
49
|
-
function toggleSlugModification(button, slugInput) {
|
50
|
-
if (slugInput.attr('readonly')) {
|
51
|
-
slugInput.removeAttr('readonly')
|
52
|
-
button.html('<i class="unlock icon"></i>')
|
53
|
-
} else {
|
54
|
-
slugInput.attr('readonly', 'readonly')
|
55
|
-
button.html('<i class="lock icon"></i>')
|
56
|
-
}
|
57
|
-
}
|
58
|
-
},
|
59
|
-
})
|
60
|
-
})(jQuery)
|
61
|
-
;(function ($) {
|
62
|
-
$(document).ready(function () {
|
63
|
-
$(this).articleSlugGenerator()
|
64
|
-
})
|
65
|
-
})(jQuery)
|
@@ -1,71 +0,0 @@
|
|
1
|
-
;(function ($) {
|
2
|
-
'use strict'
|
3
|
-
|
4
|
-
$.fn.extend({
|
5
|
-
blogCategorySlugGenerator: function () {
|
6
|
-
let timeout
|
7
|
-
|
8
|
-
$('[name*="nextgen_cms_bundle_blog_category[translations]"][name*="[name]"]').on('input', function () {
|
9
|
-
clearTimeout(timeout)
|
10
|
-
let element = $(this)
|
11
|
-
|
12
|
-
timeout = setTimeout(function () {
|
13
|
-
updateSlug(element)
|
14
|
-
}, 1000)
|
15
|
-
})
|
16
|
-
|
17
|
-
$('.toggle-blog-category-slug-modification').on('click', function (e) {
|
18
|
-
e.preventDefault()
|
19
|
-
toggleSlugModification($(this), $(this).siblings('input'))
|
20
|
-
})
|
21
|
-
|
22
|
-
function updateSlug(element) {
|
23
|
-
let slugInput = element.parents('.content').find('[name*="[slug]"]')
|
24
|
-
let loadableParent = slugInput.parents('.field.loadable')
|
25
|
-
|
26
|
-
if ('readonly' === slugInput.attr('readonly')) {
|
27
|
-
return
|
28
|
-
}
|
29
|
-
|
30
|
-
loadableParent.addClass('loading')
|
31
|
-
|
32
|
-
let data
|
33
|
-
data = {
|
34
|
-
name: element.val(),
|
35
|
-
locale: element.closest('[data-locale]').data('locale'),
|
36
|
-
}
|
37
|
-
|
38
|
-
$.ajax({
|
39
|
-
type: 'GET',
|
40
|
-
url: slugInput.attr('data-url'),
|
41
|
-
data: data,
|
42
|
-
dataType: 'json',
|
43
|
-
accept: 'application/json',
|
44
|
-
success: function (data) {
|
45
|
-
slugInput.val(data.slug)
|
46
|
-
if (slugInput.parents('.field').hasClass('error')) {
|
47
|
-
slugInput.parents('.field').removeClass('error')
|
48
|
-
slugInput.parents('.field').find('.sylius-validation-error').remove()
|
49
|
-
}
|
50
|
-
loadableParent.removeClass('loading')
|
51
|
-
},
|
52
|
-
})
|
53
|
-
}
|
54
|
-
|
55
|
-
function toggleSlugModification(button, slugInput) {
|
56
|
-
if (slugInput.attr('readonly')) {
|
57
|
-
slugInput.removeAttr('readonly')
|
58
|
-
button.html('<i class="unlock icon"></i>')
|
59
|
-
} else {
|
60
|
-
slugInput.attr('readonly', 'readonly')
|
61
|
-
button.html('<i class="lock icon"></i>')
|
62
|
-
}
|
63
|
-
}
|
64
|
-
},
|
65
|
-
})
|
66
|
-
})(jQuery)
|
67
|
-
;(function ($) {
|
68
|
-
$(document).ready(function () {
|
69
|
-
$(this).blogCategorySlugGenerator()
|
70
|
-
})
|
71
|
-
})(jQuery)
|
@@ -1,65 +0,0 @@
|
|
1
|
-
;(function ($) {
|
2
|
-
'use strict'
|
3
|
-
|
4
|
-
$.fn.extend({
|
5
|
-
blogSlugGenerator: function () {
|
6
|
-
let timeout
|
7
|
-
|
8
|
-
$('[name*="nextgen_cms_bundle_blog[translations]"][name*="[name]"]').on('input', function () {
|
9
|
-
clearTimeout(timeout)
|
10
|
-
let element = $(this)
|
11
|
-
|
12
|
-
timeout = setTimeout(function () {
|
13
|
-
updateSlug(element)
|
14
|
-
}, 1000)
|
15
|
-
})
|
16
|
-
|
17
|
-
$('.toggle-blog-slug-modification').on('click', function (e) {
|
18
|
-
e.preventDefault()
|
19
|
-
toggleSlugModification($(this), $(this).siblings('input'))
|
20
|
-
})
|
21
|
-
|
22
|
-
function updateSlug(element) {
|
23
|
-
let slugInput = element.parents('.content').find('[name*="[slug]"]')
|
24
|
-
let loadableParent = slugInput.parents('.field.loadable')
|
25
|
-
|
26
|
-
if ('readonly' === slugInput.attr('readonly')) {
|
27
|
-
return
|
28
|
-
}
|
29
|
-
|
30
|
-
loadableParent.addClass('loading')
|
31
|
-
|
32
|
-
$.ajax({
|
33
|
-
type: 'GET',
|
34
|
-
url: slugInput.attr('data-url'),
|
35
|
-
data: { name: element.val() },
|
36
|
-
dataType: 'json',
|
37
|
-
accept: 'application/json',
|
38
|
-
success: function (data) {
|
39
|
-
slugInput.val(data.slug)
|
40
|
-
if (slugInput.parents('.field').hasClass('error')) {
|
41
|
-
slugInput.parents('.field').removeClass('error')
|
42
|
-
slugInput.parents('.field').find('.sylius-validation-error').remove()
|
43
|
-
}
|
44
|
-
loadableParent.removeClass('loading')
|
45
|
-
},
|
46
|
-
})
|
47
|
-
}
|
48
|
-
|
49
|
-
function toggleSlugModification(button, slugInput) {
|
50
|
-
if (slugInput.attr('readonly')) {
|
51
|
-
slugInput.removeAttr('readonly')
|
52
|
-
button.html('<i class="unlock icon"></i>')
|
53
|
-
} else {
|
54
|
-
slugInput.attr('readonly', 'readonly')
|
55
|
-
button.html('<i class="lock icon"></i>')
|
56
|
-
}
|
57
|
-
}
|
58
|
-
},
|
59
|
-
})
|
60
|
-
})(jQuery)
|
61
|
-
;(function ($) {
|
62
|
-
$(document).ready(function () {
|
63
|
-
$(this).blogSlugGenerator()
|
64
|
-
})
|
65
|
-
})(jQuery)
|