Mercurial > kallithea
diff rhodecode/public/js/rhodecode.js @ 3695:45df84d36b44 beta
Implemented preview for comments
author | Marcin Kuzminski <marcin@python-works.com> |
---|---|
date | Sat, 06 Apr 2013 02:49:42 +0200 |
parents | 690a955ba785 |
children | e07b07ac9fbe |
line wrap: on
line diff
--- a/rhodecode/public/js/rhodecode.js Fri Apr 05 23:16:21 2013 +0200 +++ b/rhodecode/public/js/rhodecode.js Sat Apr 06 02:49:42 2013 +0200 @@ -865,6 +865,29 @@ ajaxPOST(submit_url, postData, success); }); + + YUE.on('preview-btn_'+lineno, 'click', function(e){ + var _text = YUD.get('text_'+lineno).value; + if(!_text){ + return + } + var post_data = {'text': _text}; + YUD.addClass('preview-box_'+lineno, 'unloaded'); + YUD.get('preview-box_'+lineno).innerHTML = _TM['Loading ...']; + YUD.setStyle('edit-container_'+lineno, 'display', 'none'); + YUD.setStyle('preview-container_'+lineno, 'display', ''); + + var url = pyroutes.url('changeset_comment_preview', {'repo_name': REPO_NAME}); + ajaxPOST(url,post_data,function(o){ + YUD.get('preview-box_'+lineno).innerHTML = o.responseText; + YUD.removeClass('preview-box_'+lineno, 'unloaded'); + }) + }) + YUE.on('edit-btn_'+lineno, 'click', function(e){ + YUD.setStyle('edit-container_'+lineno, 'display', ''); + YUD.setStyle('preview-container_'+lineno, 'display', 'none'); + }) + setTimeout(function(){ // callbacks @@ -886,8 +909,11 @@ var root = prevElementSibling(prevElementSibling(n)); n.parentNode.removeChild(n); - // scann nodes, and attach add button to last one - placeAddButton(root); + // scann nodes, and attach add button to last one only for TR + // which are the inline comments + if(root && root.tagName == 'TR'){ + placeAddButton(root); + } } ajaxPOST(url,postData,success); }