Dotclear

Changeset 2313:ef1db3d7c388 for admin/js


Ignore:
Timestamp:
10/08/13 15:27:39 (12 years ago)
Author:
Dsls
Branch:
twig
Parents:
1524:913f5a36bbb0 (diff), 2312:d01c85eaa37d (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Twig merge - lots of things to adapt yet

File:
1 edited

Legend:

Unmodified
Added
Removed
  • admin/js/_post.js

    r1492 r2313  
    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     { 
    7979          // Get document format and prepare toolbars 
    8080          var formatField = $('#post_format').get(0); 
     81          var last_post_format = $(formatField).val(); 
    8182          $(formatField).change(function() { 
    82                excerptTb.switchMode(this.value); 
    83                contentTb.switchMode(this.value); 
    84           }); 
    85            
     83               // Confirm post format change 
     84               if(window.confirm(dotclear.msg.confirm_change_post_format_noconvert)){ 
     85                    excerptTb.switchMode(this.value); 
     86                    contentTb.switchMode(this.value); 
     87                    last_post_format = $(this).val(); 
     88               }else{ 
     89                    // Restore last format if change cancelled 
     90                    $(this).val(last_post_format); 
     91               } 
     92                
     93               $('.format_control > *').addClass('hide'); 
     94               $('.format_control:not(.control_no_'+$(this).val()+') > *').removeClass('hide'); 
     95          }); 
     96 
    8697          var excerptTb = new jsToolBar(document.getElementById('post_excerpt')); 
    8798          var contentTb = new jsToolBar(document.getElementById('post_content')); 
    8899          excerptTb.context = contentTb.context = 'post'; 
    89100     } 
    90       
     101 
    91102     if (document.getElementById('comment_content')) { 
    92103          var commentTb = new jsToolBar(document.getElementById('comment_content')); 
    93104     } 
    94       
     105 
    95106     // Post preview 
    96107     $('#post-preview').modalWeb($(window).width()-40,$(window).height()-40); 
    97       
     108 
    98109     // Tabs events 
    99110     $('#edit-entry').onetabload(function() { 
    100111          dotclear.hideLockable(); 
    101            
     112 
    102113          // Add date picker 
    103114          var post_dtPick = new datePicker($('#post_dt').get(0)); 
    104115          post_dtPick.img_top = '1.5em'; 
    105116          post_dtPick.draw(); 
    106            
     117 
    107118          // Confirm post deletion 
    108119          $('input[name="delete"]').click(function() { 
    109                     return window.confirm(dotclear.msg.confirm_delete_post); 
    110           }); 
     120               return window.confirm(dotclear.msg.confirm_delete_post); 
     121          }); 
     122 
     123          // Markup validator 
     124          var v = $('<div class="format_control"><p><a id="a-validator"></a></p><div/>').get(0); 
     125          $('.format_control').before(v); 
     126          var a = $('#a-validator').get(0); 
     127          a.href = '#'; 
     128          a.className = 'button '; 
     129          $(a).click(function() { 
     130                
     131               excerpt_content = $('#post_excerpt').css('display') != 'none' ? $('#post_excerpt').val() : $('#excerpt-area iframe').contents().find('body').html(); 
     132               post_content    = $('#post_content').css('display') != 'none' ? $('#post_content').val() : $('#content-area iframe').contents().find('body').html(); 
     133                
     134               var params = { 
     135                    xd_check: dotclear.nonce, 
     136                    f: 'validatePostMarkup', 
     137                    excerpt: excerpt_content, 
     138                    content: post_content, 
     139                    format: $('#post_format').get(0).value, 
     140                    lang: $('#post_lang').get(0).value 
     141               }; 
     142 
     143               $.post('services.php',params,function(data) { 
     144                    if ($(data).find('rsp').attr('status') != 'ok') { 
     145                         alert($(data).find('rsp message').text()); 
     146                         return false; 
     147                    } 
     148                          
     149                    $('.message, .success, .error, .warning-msg').remove(); 
     150 
     151                    if ($(data).find('valid').text() == 1) { 
     152                         var p = document.createElement('p'); 
     153                         p.id = 'markup-validator'; 
     154                          
     155                         $(p).addClass('success'); 
     156                         $(p).text(dotclear.msg.xhtml_valid); 
     157                         $('#entry-content h3').after(p); 
     158                         $(p).backgroundFade({sColor: dotclear.fadeColor.beginValidatorMsg, eColor: dotclear.fadeColor.endValidatorMsg, steps: 50},function() { 
     159                                   $(this).backgroundFade({sColor: dotclear.fadeColor.endValidatorMsg, eColor: dotclear.fadeColor.beginValidatorMsg}); 
     160                         }); 
     161                    } else { 
     162                         var div = document.createElement('div'); 
     163                         div.id = 'markup-validator'; 
     164                          
     165                         $(div).addClass('error'); 
     166                         $(div).html('<p><strong>' + dotclear.msg.xhtml_not_valid + '</strong></p>' + $(data).find('errors').text()); 
     167                         $('#entry-content h3').after(div); 
     168                         $(div).backgroundFade({sColor: dotclear.fadeColor.beginValidatorErr,eColor: dotclear.fadeColor.endValidatorErr, steps: 50},function() { 
     169                                   $(this).backgroundFade({sColor: dotclear.fadeColor.endValidatorErr, eColor: dotclear.fadeColor.beginValidatorErr}); 
     170                         }); 
     171                    } 
     172 
     173                    if ( $('#post_excerpt').text() != excerpt_content || $('#post_content').text() != post_content ) { 
     174                         var pn = document.createElement('p'); 
     175                         $(pn).addClass('warning-msg'); 
     176                         $(pn).text(dotclear.msg.warning_validate_no_save_content); 
     177                         $('#entry-content h3').after(pn); 
     178                    } 
     179 
     180                    return false; 
     181               }); 
     182 
     183               return false; 
     184          }); 
     185 
     186          a.appendChild(document.createTextNode(dotclear.msg.xhtml_validator)); 
    111187           
     188          $('.format_control > *').addClass('hide'); 
     189          $('.format_control:not(.control_no_'+last_post_format+') > *').removeClass('hide'); 
     190 
    112191          // Hide some fields 
    113192          $('#notes-area label').toggleWithLegend($('#notes-area').children().not('label'),{ 
    114                cookie: 'dcx_post_notes', 
     193               user_pref: 'dcx_post_notes', 
     194               legend_click:true, 
    115195               hide: $('#post_notes').val() == '' 
    116196          }); 
    117           $('#new_cat').toggleWithLegend( 
    118                $('#new_cat').parent().children().not('#new_cat'), 
    119                {} // no cookie on new category as we don't use this every day 
    120           ); 
    121           $('#post_lang').parent().toggleWithLegend($('#post_lang'),{ 
    122                cookie: 'dcx_post_lang' 
    123           }); 
    124           $('#post_password').parent().toggleWithLegend($('#post_password'),{ 
    125                cookie: 'dcx_post_password', 
     197          $('#post_lang').parent().children('label').toggleWithLegend($('#post_lang'),{ 
     198               user_pref: 'dcx_post_lang', 
     199               legend_click: true 
     200          }); 
     201          $('#post_password').parent().children('label').toggleWithLegend($('#post_password'),{ 
     202               user_pref: 'dcx_post_password', 
     203               legend_click: true, 
    126204               hide: $('#post_password').val() == '' 
    127205          }); 
    128           $('#post_status').parent().toggleWithLegend($('#post_status'),{ 
    129                cookie: 'dcx_post_status' 
    130           }); 
    131           $('#post_dt').parent().toggleWithLegend($('#post_dt').parent().children().not('label'),{ 
    132                cookie: 'dcx_post_dt' 
    133           }); 
    134           $('#post_format').parent().toggleWithLegend($('#post_format').parent().children().not('label').add($('#post_format').parents('p').next()),{ 
    135                cookie: 'dcx_post_format' 
    136           }); 
    137           $('#cat_id').parent().toggleWithLegend($('#cat_id'),{ 
    138                cookie: 'cat_id' 
    139           }); 
    140           $('#post_url').parent().toggleWithLegend($('#post_url').parent().children().not('label'),{ 
    141                cookie: 'post_url' 
     206          $('#post_status').parent().children('label').toggleWithLegend($('#post_status'),{ 
     207               user_pref: 'dcx_post_status', 
     208               legend_click: true 
     209          }); 
     210          $('#post_dt').parent().children('label').toggleWithLegend($('#post_dt').parent().children().not('label'),{ 
     211               user_pref: 'dcx_post_dt', 
     212               legend_click: true 
     213          }); 
     214          $('#label_format').toggleWithLegend($('#label_format').parent().children().not('#label_format'),{ 
     215               user_pref: 'dcx_post_format', 
     216               legend_click: true 
     217          }); 
     218          $('#label_cat_id').toggleWithLegend($('#label_cat_id').parent().children().not('#label_cat_id'),{ 
     219               user_pref: 'dcx_cat_id', 
     220               legend_click: true 
     221          }); 
     222          $('#create_cat').toggleWithLegend($('#create_cat').parent().children().not('#create_cat'),{ 
     223               // no cookie on new category as we don't use this every day 
     224               legend_click: true 
     225          }); 
     226          $('#label_comment_tb').toggleWithLegend($('#label_comment_tb').parent().children().not('#label_comment_tb'),{ 
     227               user_pref: 'dcx_comment_tb', 
     228               legend_click: true 
     229          }); 
     230          $('#post_url').parent().children('label').toggleWithLegend($('#post_url').parent().children().not('label'),{ 
     231               user_pref: 'post_url', 
     232               legend_click: true 
    142233          }); 
    143234          // We load toolbar on excerpt only when it's ready 
    144235          $('#excerpt-area label').toggleWithLegend($('#excerpt-area').children().not('label'),{ 
    145                fn: function() { excerptTb.switchMode(formatField.value); }, 
    146                cookie: 'dcx_post_excerpt', 
     236               user_pref: 'dcx_post_excerpt', 
     237               legend_click: true, 
    147238               hide: $('#post_excerpt').val() == '' 
    148239          }); 
    149            
     240 
    150241          // Load toolbars 
    151242          contentTb.switchMode(formatField.value); 
    152            
     243          excerptTb.switchMode(formatField.value); 
     244 
    153245          // Replace attachment remove links by a POST form submit 
    154246          $('a.attachment-remove').click(function() { 
     
    162254               return false; 
    163255          }); 
    164            
    165           // Markup validator 
    166           var h = document.createElement('h4'); 
    167           var a = document.createElement('a'); 
    168           a.href = '#'; 
    169           a.className = 'button'; 
    170           $(a).click(function() { 
    171                var params = { 
    172                     xd_check: dotclear.nonce, 
    173                     f: 'validatePostMarkup', 
    174                     excerpt: $('#post_excerpt').text(), 
    175                     content: $('#post_content').text(), 
    176                     format: $('#post_format').get(0).value, 
    177                     lang: $('#post_lang').get(0).value 
    178                }; 
    179                 
    180                $.post('services.php',params,function(data) { 
    181                     if ($(data).find('rsp').attr('status') != 'ok') { 
    182                          alert($(data).find('rsp message').text()); 
    183                          return false; 
    184                     } 
    185                      
    186                     if ($(data).find('valid').text() == 1) { 
    187                          var p = document.createElement('p'); 
    188                          p.id = 'markup-validator'; 
    189                           
    190                          if ($('#markup-validator').length > 0) { 
    191                               $('#markup-validator').remove(); 
    192                          } 
    193                           
    194                          $(p).addClass('message'); 
    195                          $(p).text(dotclear.msg.xhtml_valid); 
    196                          $(p).insertAfter(h); 
    197                          $(p).backgroundFade({sColor:'#666666',eColor:'#ffcc00',steps:50},function() { 
    198                                    $(this).backgroundFade({sColor:'#ffcc00',eColor:'#666666'}); 
    199                          }); 
    200                     } else { 
    201                          var div = document.createElement('div'); 
    202                          div.id = 'markup-validator'; 
    203                           
    204                          if ($('#markup-validator').length > 0) { 
    205                               $('#markup-validator').remove(); 
    206                          } 
    207                           
    208                          $(div).addClass('error'); 
    209                          $(div).html('<p><strong>' + dotclear.msg.xhtml_not_valid + '</strong></p>' + $(data).find('errors').text()); 
    210                          $(div).insertAfter(h); 
    211                          $(div).backgroundFade({sColor:'#ffffff',eColor:'#ff9999',steps:50},function() { 
    212                                    $(this).backgroundFade({sColor:'#ff9999',eColor:'#ffffff'}); 
    213                          }); 
    214                     } 
    215                      
    216                     return false; 
    217                }); 
    218                 
    219                return false; 
    220           }); 
    221            
    222           a.appendChild(document.createTextNode(dotclear.msg.xhtml_validator)); 
    223           h.appendChild(a); 
    224           $(h).appendTo('#entry-content'); 
    225            
     256 
    226257          // Check unsaved changes before XHTML conversion 
    227258          var excerpt = $('#post_excerpt').val(); 
     
    230261               if (excerpt != $('#post_excerpt').val() || content != $('#post_content').val()) { 
    231262                    return window.confirm(dotclear.msg.confirm_change_post_format); 
    232                }     
    233           }); 
    234      }); 
    235       
     263               } 
     264          }); 
     265     }); 
     266 
    236267     $('#comments').onetabload(function() { 
    237           $('.comments-list tr.line').each(function() { 
     268          $('#form-comments .comments-list tr.line').each(function() { 
    238269               dotclear.commentExpander(this); 
    239270          }); 
    240           $('.checkboxes-helpers').each(function() { 
     271          $('#form-comments .checkboxes-helpers').each(function() { 
    241272               dotclear.checkboxesHelpers(this); 
    242273          }); 
    243            
     274 
    244275          dotclear.commentsActionsHelper(); 
    245276     }); 
    246       
     277 
     278     $('#trackbacks').onetabload(function() { 
     279          $('#form-trackbacks .comments-list tr.line').each(function() { 
     280               dotclear.commentExpander(this); 
     281          }); 
     282          $('#form-trackbacks .checkboxes-helpers').each(function() { 
     283               dotclear.checkboxesHelpers(this); 
     284          }); 
     285 
     286          dotclear.commentsActionsHelper(); 
     287     }); 
     288 
    247289     $('#add-comment').onetabload(function() { 
    248290          commentTb.draw('xhtml'); 
Note: See TracChangeset for help on using the changeset viewer.

Sites map