Dotclear

Changeset 1525:c30081595436 for admin/js


Ignore:
Timestamp:
08/22/13 20:14:09 (12 years ago)
Author:
Nicolas <nikrou77@…>
Branch:
default
Message:

Fix issue #1541 : improve and simplify categories page.

Location:
admin/js
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • admin/js/_categories.js

    r0 r1525  
    11/* TODO: Some nice drag and drop on categories */ 
    22$(function() { 
    3      $('form#delete-category').submit(function() { 
    4           var c_id = $('#del_cat').val(); 
    5           var c_name = $('#del_cat option[value='+c_id+']').text(); 
    6           return window.confirm(dotclear.msg.confirm_delete_category.replace('%s',c_name)); 
     3     $('.checkboxes-helpers').each(function() { 
     4          dotclear.checkboxesHelpers(this); 
    75     }); 
    8 }); 
    96 
    10 $(function() { 
     7     dotclear.categoriesActionsHelper(); 
     8 
     9 
    1110     $('form#reset-order').submit(function() { 
    1211          return window.confirm(dotclear.msg.confirm_reorder_categories); 
  • admin/js/_post.js

    r1518 r1525  
    11dotclear.commentExpander = function(line) { 
    22     var td = line.firstChild; 
    3       
     3 
    44     var img = document.createElement('img'); 
    55     img.src = dotclear.img_plus_src; 
     
    99     img.line = line; 
    1010     img.onclick = function() { dotclear.viewCommentContent(this,this.line); }; 
    11       
     11 
    1212     td.insertBefore(img,td.firstChild); 
    1313}; 
     
    1515dotclear.viewCommentContent = function(img,line) { 
    1616     var commentId = line.id.substr(1); 
    17       
     17 
    1818     var tr = document.getElementById('ce'+commentId); 
    19       
     19 
    2020     if (!tr) { 
    2121          tr = document.createElement('tr'); 
     
    2525          td.className = 'expand'; 
    2626          tr.appendChild(td); 
    27            
     27 
    2828          img.src = dotclear.img_minus_src; 
    2929          img.alt = dotclear.img_minus_alt; 
    30            
     30 
    3131          // Get comment content 
    3232          $.get('services.php',{f:'getCommentById',id: commentId},function(data) { 
    3333               var rsp = $(data).children('rsp')[0]; 
    34                 
     34 
    3535               if (rsp.attributes[0].value == 'ok') { 
    3636                    var comment = $(rsp).find('comment_display_content').text(); 
    37                      
     37 
    3838                    if (comment) { 
    3939                         $(td).append(comment); 
     
    4242                         var comment_ip = $(rsp).find('comment_ip').text(); 
    4343                         var comment_spam_disp = $(rsp).find('comment_spam_disp').text(); 
    44                           
     44 
    4545                         $(td).append('<p><strong>' + dotclear.msg.website + 
    4646                         '</strong> ' + comment_site + '<br />' + 
     
    5252               } 
    5353          }); 
    54            
     54 
    5555          $(line).toggleClass('expand'); 
    5656          line.parentNode.insertBefore(tr,line.nextSibling); 
     
    7474$(function() { 
    7575     if (!document.getElementById) { return; } 
    76       
     76 
    7777     if (document.getElementById('edit-entry')) 
    7878     { 
     
    8383               contentTb.switchMode(this.value); 
    8484          }); 
    85            
     85 
    8686          var excerptTb = new jsToolBar(document.getElementById('post_excerpt')); 
    8787          var contentTb = new jsToolBar(document.getElementById('post_content')); 
    8888          excerptTb.context = contentTb.context = 'post'; 
    8989     } 
    90       
     90 
    9191     if (document.getElementById('comment_content')) { 
    9292          var commentTb = new jsToolBar(document.getElementById('comment_content')); 
    9393     } 
    94       
     94 
    9595     // Post preview 
    9696     $('#post-preview').modalWeb($(window).width()-40,$(window).height()-40); 
    97       
     97 
    9898     // Tabs events 
    9999     $('#edit-entry').onetabload(function() { 
    100100          dotclear.hideLockable(); 
    101            
     101 
    102102          // Add date picker 
    103103          var post_dtPick = new datePicker($('#post_dt').get(0)); 
    104104          post_dtPick.img_top = '1.5em'; 
    105105          post_dtPick.draw(); 
    106            
     106 
    107107          // Confirm post deletion 
    108108          $('input[name="delete"]').click(function() { 
    109                     return window.confirm(dotclear.msg.confirm_delete_post); 
    110           }); 
    111            
     109               return window.confirm(dotclear.msg.confirm_delete_post); 
     110          }); 
     111 
    112112          // Hide some fields 
    113113          $('#notes-area label').toggleWithLegend($('#notes-area').children().not('label'),{ 
    114114               cookie: 'dcx_post_notes', 
    115                hide: $('#post_notes').val() == '' 
     115                  hide: $('#post_notes').val() == '', 
     116                  legend_click: true 
    116117          }); 
    117118          $('#new_cat').toggleWithLegend( 
    118119               $('#new_cat').parent().children().not('#new_cat'), 
    119                {} // no cookie on new category as we don't use this every day 
     120               {legend_click: true} // no cookie on new category as we don't use this every day 
    120121          ); 
    121122          $('#post_lang').parent().toggleWithLegend($('#post_lang'),{ 
    122                cookie: 'dcx_post_lang' 
     123              cookie: 'dcx_post_lang', 
     124              legend_click: true 
    123125          }); 
    124126          $('#post_password').parent().toggleWithLegend($('#post_password'),{ 
    125127               cookie: 'dcx_post_password', 
    126                hide: $('#post_password').val() == '' 
     128              hide: $('#post_password').val() == '', 
     129              legend_click: true 
    127130          }); 
    128131          $('#post_status').parent().toggleWithLegend($('#post_status'),{ 
    129                cookie: 'dcx_post_status' 
     132                  cookie: 'dcx_post_status', 
     133              legend_click: true 
    130134          }); 
    131135          $('#post_dt').parent().toggleWithLegend($('#post_dt').parent().children().not('label'),{ 
    132                cookie: 'dcx_post_dt' 
     136              cookie: 'dcx_post_dt', 
     137              legend_click: true 
    133138          }); 
    134139          $('#post_format').parent().toggleWithLegend($('#post_format').parent().children().not('label').add($('#post_format').parents('p').next()),{ 
    135                cookie: 'dcx_post_format' 
     140              cookie: 'dcx_post_format', 
     141              legend_click: true 
    136142          }); 
    137143          $('#cat_id').parent().toggleWithLegend($('#cat_id'),{ 
    138                cookie: 'cat_id' 
     144              cookie: 'cat_id', 
     145              legend_click: true 
    139146          }); 
    140147          $('#post_url').parent().toggleWithLegend($('#post_url').parent().children().not('label'),{ 
    141                cookie: 'post_url' 
     148              cookie: 'post_url', 
     149              legend_click: true 
    142150          }); 
    143151          // We load toolbar on excerpt only when it's ready 
     
    147155               hide: $('#post_excerpt').val() == '' 
    148156          }); 
    149            
     157 
    150158          // Load toolbars 
    151159          contentTb.switchMode(formatField.value); 
    152            
     160 
    153161          // Replace attachment remove links by a POST form submit 
    154162          $('a.attachment-remove').click(function() { 
     
    162170               return false; 
    163171          }); 
    164            
     172 
    165173          // Markup validator 
    166174          var h = document.createElement('h4'); 
     
    177185                    lang: $('#post_lang').get(0).value 
    178186               }; 
    179                 
     187 
    180188               $.post('services.php',params,function(data) { 
    181189                    if ($(data).find('rsp').attr('status') != 'ok') { 
     
    183191                         return false; 
    184192                    } 
    185                      
     193 
    186194                    if ($(data).find('valid').text() == 1) { 
    187195                         var p = document.createElement('p'); 
    188196                         p.id = 'markup-validator'; 
    189                           
     197 
    190198                         if ($('#markup-validator').length > 0) { 
    191199                              $('#markup-validator').remove(); 
    192200                         } 
    193                           
     201 
    194202                         $(p).addClass('message'); 
    195203                         $(p).text(dotclear.msg.xhtml_valid); 
     
    201209                         var div = document.createElement('div'); 
    202210                         div.id = 'markup-validator'; 
    203                           
     211 
    204212                         if ($('#markup-validator').length > 0) { 
    205213                              $('#markup-validator').remove(); 
    206214                         } 
    207                           
     215 
    208216                         $(div).addClass('error'); 
    209217                         $(div).html('<p><strong>' + dotclear.msg.xhtml_not_valid + '</strong></p>' + $(data).find('errors').text()); 
     
    213221                         }); 
    214222                    } 
    215                      
     223 
    216224                    return false; 
    217225               }); 
    218                 
     226 
    219227               return false; 
    220228          }); 
    221            
     229 
    222230          a.appendChild(document.createTextNode(dotclear.msg.xhtml_validator)); 
    223231          h.appendChild(a); 
    224232          $(h).appendTo('#entry-content'); 
    225            
     233 
    226234          // Check unsaved changes before XHTML conversion 
    227235          var excerpt = $('#post_excerpt').val(); 
     
    230238               if (excerpt != $('#post_excerpt').val() || content != $('#post_content').val()) { 
    231239                    return window.confirm(dotclear.msg.confirm_change_post_format); 
    232                }     
     240               } 
    233241          }); 
    234242     }); 
    235       
     243 
    236244     $('#comments').onetabload(function() { 
    237245          $('.comments-list tr.line').each(function() { 
     
    241249               dotclear.checkboxesHelpers(this); 
    242250          }); 
    243            
     251 
    244252          dotclear.commentsActionsHelper(); 
    245253     }); 
    246       
     254 
    247255     $('#add-comment').onetabload(function() { 
    248256          commentTb.draw('xhtml'); 
  • admin/js/common.js

    r1516 r1525  
    121121 
    122122          $(ctarget).css('cursor','pointer'); 
     123          if (p.legend_click) { 
     124               $(ctarget).find('label').css('cursor','pointer'); 
     125          } 
    123126          $(ctarget).click(function() { 
    124127               toggle(i,p.speed); 
     
    290293               if (action == 'delete') { 
    291294                    return window.confirm(dotclear.msg.confirm_delete_posts.replace('%s',$('input[name="entries[]"]:checked').size())); 
     295               } 
     296 
     297               return true; 
     298          }); 
     299     }, 
     300 
     301     categoriesActionsHelper: function() { 
     302          $('#form-categories').submit(function() { 
     303               var action = $(this).find('select[name="action"]').val(); 
     304               var checked = false; 
     305 
     306               $(this).find('input[name="categories[]"]').each(function() { 
     307                    if (this.checked) { 
     308                         checked = true; 
     309                    } 
     310               }); 
     311 
     312               if (!checked) { return false; } 
     313 
     314               if (action == 'delete') { 
     315                    return window.confirm(dotclear.msg.confirm_delete_categories.replace('%s',$('input[name="categories[]"]:checked').size())); 
    292316               } 
    293317 
Note: See TracChangeset for help on using the changeset viewer.

Sites map