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