1 | /*global $, dotclear, jsToolBar, getData */ |
---|
2 | 'use strict'; |
---|
3 | |
---|
4 | Object.assign(dotclear.msg, getData('blog_pref')); |
---|
5 | |
---|
6 | $(function() { |
---|
7 | const blog_url = $('#blog_url'); |
---|
8 | if (blog_url.length > 0 && !blog_url.is(':hidden')) { |
---|
9 | const checkQueryString = function() { |
---|
10 | const url = blog_url[0].value; |
---|
11 | const scan = $('#url_scan')[0].value; |
---|
12 | let msg = ''; |
---|
13 | if (/.*[^\/]$/.exec(url) && scan == 'path_info') { |
---|
14 | msg = dotclear.msg.warning_path_info; |
---|
15 | } else if (/.*[^\?]$/.exec(url) && scan == 'query_string') { |
---|
16 | msg = dotclear.msg.warning_query_string; |
---|
17 | } |
---|
18 | $('p#urlwarning').remove(); |
---|
19 | if (msg != '') { |
---|
20 | blog_url.parents('p').after(`<p id="urlwarning" class="warning">${msg}</p>`); |
---|
21 | } |
---|
22 | }; |
---|
23 | checkQueryString(); |
---|
24 | blog_url.focusout(checkQueryString); |
---|
25 | $('body').on('change', '#url_scan', checkQueryString); |
---|
26 | } |
---|
27 | |
---|
28 | $('#date_format_select,#time_format_select').change(function() { |
---|
29 | if ($(this).prop('value') == '') { |
---|
30 | return; |
---|
31 | } |
---|
32 | $('#' + $(this).attr('id').replace('_select', '')).prop('value', $(this).prop('value')); |
---|
33 | $(this).parent().next('.chosen').html($(this).find(':selected').prop('label')); |
---|
34 | }); |
---|
35 | |
---|
36 | // HTML text editor |
---|
37 | if (typeof jsToolBar !== 'undefined' && $.isFunction(jsToolBar)) { |
---|
38 | $('#blog_desc').each(function() { |
---|
39 | let tbWidgetText = new jsToolBar(this); |
---|
40 | tbWidgetText.context = 'blog_desc'; |
---|
41 | tbWidgetText.draw('xhtml'); |
---|
42 | }); |
---|
43 | } |
---|
44 | |
---|
45 | // Hide advanced and plugins prefs sections |
---|
46 | $('#standard-pref h3').toggleWithLegend($('#standard-pref').children().not('h3'), { |
---|
47 | legend_click: true, |
---|
48 | hide: false |
---|
49 | }); |
---|
50 | $('#advanced-pref h3').toggleWithLegend($('#advanced-pref').children().not('h3'), { |
---|
51 | legend_click: true, |
---|
52 | user_pref: 'dcx_blog_pref_adv', |
---|
53 | }); |
---|
54 | $('#plugins-pref h3').toggleWithLegend($('#plugins-pref').children().not('h3'), { |
---|
55 | legend_click: true, |
---|
56 | user_pref: 'dcx_blog_pref_plg', |
---|
57 | }); |
---|
58 | }); |
---|