Dotclear

source: admin/js/_blog_theme.js @ 3:cf375f1e7b0f

Revision 3:cf375f1e7b0f, 2.3 KB checked in by Dsls <dsls@…>, 14 years ago (diff)

Ported Franck & Kozlika updates for user prefs, dedicated branch

Line 
1$(function() {
2     $('#themes-actions').hide();
3     var submit_s = $('#themes-actions input[name=select]');
4     var submit_r = $('#themes-actions input[name=remove]');
5     
6     var details = $('#themes div.theme-details');
7     $('div.theme-actions',details).hide();
8     $('input:radio',details).hide();
9     $('div.theme-info span, div.theme-info a',details).hide();
10     details.removeClass('theme-details').addClass('theme-details-js');
11     
12     var themes_wrapper = $('<div id="themes-wrapper"></div>');
13     var theme_box = $('<div id="theme-box"><div</div>');
14     $('#themes').wrap(themes_wrapper).before(theme_box);
15     
16     details.each(function() {
17          var box = this;
18          var a = $(document.createElement('a'));
19          a.attr('href','#');
20          a.attr('title',$('>div h3>label',this).text());
21          $(box).wrap(a);
22          $(box).parent().click(function(event) {
23               update_box(box);
24               event.preventDefault();
25               return false;
26          });
27     });
28     
29     function update_box(e) {
30          theme_box.empty();
31          var img = $('div.theme-shot',e).clone();
32          var info = $('div.theme-info',e).clone();
33         
34          if ($(e).hasClass('current-theme')) {
35               var actions = $('div.theme-actions',e).clone();
36               actions.show();
37          } else {
38               var actions = $('<div class="theme-actions"></div>');
39               if (submit_s.length > 0  && !$('input:radio',info).attr('disabled')) {
40                    var select = $('<a href="#" class="button">' + dotclear.msg.use_this_theme + '</a>');
41                    select.css('font-weight','bold').click(function() {
42                         submit_s.click();
43                         return false;
44                    });
45                    actions.append(select).append('&nbsp;&nbsp;');
46               }
47               if (submit_r.length > 0 && $('input:radio',info).attr('id') != 'theme_default') {
48                    var remove = $('<a href="#" class="button delete">' + dotclear.msg.remove_this_theme + '</a>');
49                    remove.click(function() {
50                         var t_name = $(this).parents('#theme-box').find('div.theme-info h3:first').text();
51                         t_name = $.trim(t_name);
52                         if (window.confirm(dotclear.msg.confirm_delete_theme.replace('%s',t_name))) {
53                              submit_r.click();
54                         }
55                         return false;
56                    });
57                    actions.append(remove);
58               }
59          }
60         
61          $('input:radio',info).remove();
62          $('span, a',info).show();
63         
64          theme_box.append(img).append(info).append(actions);
65          details.removeClass('theme-selected');
66          $(e).addClass('theme-selected');
67          $('input:radio',e).attr('checked','checked');
68     }
69     
70     update_box(details[0]);
71});
Note: See TracBrowser for help on using the repository browser.

Sites map