includes/clientside/static/comments.js
changeset 748 e39454295bbb
parent 582 a38876c0793c
child 754 75decd836c94
equal deleted inserted replaced
747:cffe13960330 748:e39454295bbb
   152     html += '  </table>';
   152     html += '  </table>';
   153     html += '</div>';
   153     html += '</div>';
   154   }
   154   }
   155     
   155     
   156   document.getElementById('ajaxEditContainer').innerHTML = html;
   156   document.getElementById('ajaxEditContainer').innerHTML = html;
       
   157   if ( document.getElementById('commentform_message') )
       
   158   {
       
   159     document.getElementById('commentform_message').allow_wysiwyg = data.auth_edit_wysiwyg
       
   160   }
   157   
   161   
   158   for ( i = 0; i < data.comments.length; i++ )
   162   for ( i = 0; i < data.comments.length; i++ )
   159   {
   163   {
   160     document.getElementById('comment_source_'+i).value = data.comments[i].comment_source;
   164     document.getElementById('comment_source_'+i).value = data.comments[i].comment_source;
   161   }
   165   }
   259 
   263 
   260 window.displayCommentForm = function()
   264 window.displayCommentForm = function()
   261 {
   265 {
   262   document.getElementById('leave_comment_button').style.display = 'none';
   266   document.getElementById('leave_comment_button').style.display = 'none';
   263   document.getElementById('comment_form').style.display = 'block';
   267   document.getElementById('comment_form').style.display = 'block';
       
   268   if ( $dynano('commentform_message').object.allow_wysiwyg )
       
   269     $dynano('commentform_message').makeSwitchable();
   264 }
   270 }
   265 
   271 
   266 window.hideCommentForm = function()
   272 window.hideCommentForm = function()
   267 {
   273 {
   268   document.getElementById('leave_comment_button').style.display = 'inline';
   274   document.getElementById('leave_comment_button').style.display = 'inline';
   287   ta.cols = '40';
   293   ta.cols = '40';
   288   ta.style.width = '98%';
   294   ta.style.width = '98%';
   289   ta.value = src;
   295   ta.value = src;
   290   ta.id = 'comment_edit_'+id;
   296   ta.id = 'comment_edit_'+id;
   291   cmt.appendChild(ta);
   297   cmt.appendChild(ta);
       
   298   $dynano(ta).makeSwitchable();
   292   
   299   
   293   link.style.fontWeight = 'bold';
   300   link.style.fontWeight = 'bold';
   294   link.innerHTML = $lang.get('comment_btn_save');
   301   link.innerHTML = $lang.get('comment_btn_save');
   295   link.onclick = function() { var id = this.id.substr(this.id.indexOf('_')+1); saveComment(id, this); return false; };
   302   link.onclick = function() { var id = this.id.substr(this.id.indexOf('_')+1); saveComment(id, this); return false; };
   296 }
   303 }
   334 
   341 
   335 window.submitComment = function()
   342 window.submitComment = function()
   336 {
   343 {
   337   var name = document.getElementById('commentform_name').value;
   344   var name = document.getElementById('commentform_name').value;
   338   var subj = document.getElementById('commentform_subject').value;
   345   var subj = document.getElementById('commentform_subject').value;
   339   var text = document.getElementById('commentform_message').value;
   346   var text = $dynano('commentform_message').getContent();
   340   if ( document.getElementById('commentform_captcha') )
   347   if ( document.getElementById('commentform_captcha') )
   341   {
   348   {
   342     var captcha_code = document.getElementById('commentform_captcha').value;
   349     var captcha_code = document.getElementById('commentform_captcha').value;
   343     var captcha_id   = document.getElementById('commentform_captcha_id').value;
   350     var captcha_id   = document.getElementById('commentform_captcha_id').value;
   344   }
   351   }
   347     var captcha_code = '';
   354     var captcha_code = '';
   348     var captcha_id   = '';
   355     var captcha_id   = '';
   349   }
   356   }
   350   if ( subj == '' )
   357   if ( subj == '' )
   351   {
   358   {
       
   359     load_component('messagebox');
       
   360     load_component('fadefilter');
   352     new MessageBox(MB_OK|MB_ICONSTOP, 'Input validation failed', 'Please enter a subject for your comment.');
   361     new MessageBox(MB_OK|MB_ICONSTOP, 'Input validation failed', 'Please enter a subject for your comment.');
   353     return false;
   362     return false;
   354   }
   363   }
   355   if ( text == '' )
   364   if ( text == '' )
   356   {
   365   {
       
   366     load_component('messagebox');
       
   367     load_component('fadefilter');
   357     new MessageBox(MB_OK|MB_ICONSTOP, 'Input validation failed', 'Please enter some text for the body of your comment .');
   368     new MessageBox(MB_OK|MB_ICONSTOP, 'Input validation failed', 'Please enter some text for the body of your comment .');
   358     return false;
   369     return false;
   359   }
   370   }
   360   var req = {
   371   var req = {
   361     'mode' : 'submit',
   372     'mode' : 'submit',