Dotclear

source: admin/js/_blog_theme.js @ 3706:170617361020

Revision 3706:170617361020, 2.4 KB checked in by franck <carnet.franck.paul@…>, 7 years ago (diff)

use strict and no more linter warnings/errors as far as possible

Line 
1/*global $, dotclear */
2'use strict';
3
4$(function() {
5  // expend theme info
6  $('.module-sshot').not('.current-theme .module-sshot').each(function() {
7    var bar = $('<div>').addClass('bloc-toggler');
8    $(this).after(
9      $(bar).toggleWithLegend($(this).parent().children('.toggle-bloc'), {
10        img_on_src: dotclear.img_plus_theme_src,
11        img_on_alt: dotclear.img_plus_theme_alt,
12        img_off_src: dotclear.img_minus_theme_src,
13        img_off_alt: dotclear.img_minus_theme_alt,
14        legend_click: true
15      }));
16    $(this).children('img').click(function() {
17      $(this).parent().parent().children('.bloc-toggler').click();
18    });
19  });
20
21  // dirty short search blocker
22  $('div.modules-search form input[type=submit]').click(function() {
23    var mlen = $('input[name=m_search]', $(this).parent()).val();
24    if (mlen.length > 2) {
25      return true;
26    } else {
27      return false;
28    }
29  });
30
31  // checkboxes selection
32  $('.checkboxes-helpers').each(function() {
33    dotclear.checkboxesHelpers(this);
34  });
35
36  // actions tests
37  $('.modules-form-actions').each(function() {
38    var rxActionType = /^[^\[]+/;
39    var rxActionValue = /([^\[]+)\]$/;
40    var checkboxes = $(this).find('input[type=checkbox]');
41
42    // check if submit is a global action or one line action
43    $('input[type=submit]', this).click(function() {
44      var keyword = $(this).attr('name');
45      var maction = keyword.match(rxActionType);
46      var action = maction[0];
47      var mvalues = keyword.match(rxActionValue);
48
49      // action on multiple modules
50      if (!mvalues) {
51        var checked = false;
52
53        // check if there is checkboxes in form
54        if (checkboxes.length > 0) {
55          // check if there is at least one checkbox checked
56          $(checkboxes).each(function() {
57            if (this.checked) {
58              checked = true;
59            }
60          });
61          if (!checked) {
62            //alert(dotclear.msg.no_selection);
63            return false;
64          }
65        }
66
67        // confirm delete
68        if (action == 'delete') {
69          return window.confirm(dotclear.msg.confirm_delete_themes);
70        }
71
72        // action on one module
73      } else {
74        var module = mvalues[1];
75
76        // confirm delete
77        if (action == 'delete') {
78          return window.confirm(dotclear.msg.confirm_delete_theme.replace('%s', module));
79        }
80      }
81
82      return true;
83    });
84  });
85});
Note: See TracBrowser for help on using the repository browser.

Sites map