[3706] | 1 | /*global $, dotclear */ |
---|
| 2 | 'use strict'; |
---|
| 3 | |
---|
[0] | 4 | $(function() { |
---|
[3706] | 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'), { |
---|
[3768] | 10 | img_on_txt: dotclear.img_plus_theme_txt, |
---|
[3706] | 11 | img_on_alt: dotclear.img_plus_theme_alt, |
---|
[3768] | 12 | img_off_txt: dotclear.img_minus_theme_txt, |
---|
[3706] | 13 | img_off_alt: dotclear.img_minus_theme_alt, |
---|
| 14 | legend_click: true |
---|
| 15 | })); |
---|
| 16 | $(this).children('img').click(function() { |
---|
[3768] | 17 | // Click on theme thumbnail |
---|
[3706] | 18 | $(this).parent().parent().children('.bloc-toggler').click(); |
---|
| 19 | }); |
---|
| 20 | }); |
---|
[2287] | 21 | |
---|
[3706] | 22 | // dirty short search blocker |
---|
| 23 | $('div.modules-search form input[type=submit]').click(function() { |
---|
| 24 | var mlen = $('input[name=m_search]', $(this).parent()).val(); |
---|
| 25 | if (mlen.length > 2) { |
---|
| 26 | return true; |
---|
| 27 | } else { |
---|
| 28 | return false; |
---|
| 29 | } |
---|
| 30 | }); |
---|
[2487] | 31 | |
---|
[3706] | 32 | // checkboxes selection |
---|
| 33 | $('.checkboxes-helpers').each(function() { |
---|
| 34 | dotclear.checkboxesHelpers(this); |
---|
| 35 | }); |
---|
[2487] | 36 | |
---|
[3706] | 37 | // actions tests |
---|
| 38 | $('.modules-form-actions').each(function() { |
---|
| 39 | var rxActionType = /^[^\[]+/; |
---|
| 40 | var rxActionValue = /([^\[]+)\]$/; |
---|
| 41 | var checkboxes = $(this).find('input[type=checkbox]'); |
---|
[2487] | 42 | |
---|
[3706] | 43 | // check if submit is a global action or one line action |
---|
| 44 | $('input[type=submit]', this).click(function() { |
---|
| 45 | var keyword = $(this).attr('name'); |
---|
[3768] | 46 | if (!keyword) { |
---|
| 47 | return true; |
---|
| 48 | } |
---|
[3706] | 49 | var maction = keyword.match(rxActionType); |
---|
| 50 | var action = maction[0]; |
---|
| 51 | var mvalues = keyword.match(rxActionValue); |
---|
[2487] | 52 | |
---|
[3706] | 53 | // action on multiple modules |
---|
| 54 | if (!mvalues) { |
---|
| 55 | var checked = false; |
---|
[2487] | 56 | |
---|
[3706] | 57 | // check if there is checkboxes in form |
---|
| 58 | if (checkboxes.length > 0) { |
---|
| 59 | // check if there is at least one checkbox checked |
---|
| 60 | $(checkboxes).each(function() { |
---|
| 61 | if (this.checked) { |
---|
| 62 | checked = true; |
---|
| 63 | } |
---|
| 64 | }); |
---|
| 65 | if (!checked) { |
---|
| 66 | //alert(dotclear.msg.no_selection); |
---|
| 67 | return false; |
---|
| 68 | } |
---|
| 69 | } |
---|
[2487] | 70 | |
---|
[3706] | 71 | // confirm delete |
---|
| 72 | if (action == 'delete') { |
---|
| 73 | return window.confirm(dotclear.msg.confirm_delete_themes); |
---|
| 74 | } |
---|
[2487] | 75 | |
---|
[3706] | 76 | // action on one module |
---|
| 77 | } else { |
---|
| 78 | var module = mvalues[1]; |
---|
[2487] | 79 | |
---|
[3706] | 80 | // confirm delete |
---|
| 81 | if (action == 'delete') { |
---|
| 82 | return window.confirm(dotclear.msg.confirm_delete_theme.replace('%s', module)); |
---|
| 83 | } |
---|
| 84 | } |
---|
[2487] | 85 | |
---|
[3706] | 86 | return true; |
---|
| 87 | }); |
---|
| 88 | }); |
---|
[2566] | 89 | }); |
---|