changeset 3419:efc00d363d1e beta

collapsable diff container in changeset, makes quick review easier
author Marcin Kuzminski <marcin@python-works.com>
date Fri, 01 Mar 2013 15:25:36 +0100
parents 9fe4543b6823
children a6bef3e8a361
files rhodecode/public/css/style.css rhodecode/public/js/rhodecode.js rhodecode/templates/base/root.html rhodecode/templates/changeset/diff_block.html
diffstat 4 files changed, 47 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/rhodecode/public/css/style.css	Thu Feb 28 16:13:38 2013 +0100
+++ b/rhodecode/public/css/style.css	Fri Mar 01 15:25:36 2013 +0100
@@ -244,7 +244,6 @@
 
 #header {
 }
-
 #header ul#logged-user {
     margin-bottom: 5px !important;
     -webkit-border-radius: 0px 0px 8px 8px;
@@ -4639,6 +4638,23 @@
 /*****************************************************************************
                                   DIFFS CSS
 ******************************************************************************/
+.diff-collapse{
+	text-align: center;
+}
+.diff-collapse-button{
+	cursor: pointer;
+	color: #666;
+	font-size: 16px;
+}
+.diff-container {
+	margin-bottom: -15px;
+}
+
+.diff-container.hidden{
+	display: none;
+	overflow: hidden;
+}
+
 
 div.diffblock {
     overflow: auto;
--- a/rhodecode/public/js/rhodecode.js	Thu Feb 28 16:13:38 2013 +0100
+++ b/rhodecode/public/js/rhodecode.js	Fri Mar 01 15:25:36 2013 +0100
@@ -2161,3 +2161,26 @@
 		});
 	}
 }
+
+
+// global hooks after DOM is loaded
+
+YUE.onDOMReady(function(){
+	YUE.on(YUQ('.diff-collapse-button'), 'click', function(e){
+		var button = e.currentTarget;
+		var t = YUD.get(button).getAttribute('target');
+	    console.log(t);
+		if(YUD.hasClass(t, 'hidden')){
+			YUD.removeClass(t, 'hidden');
+			YUD.get(button).innerHTML = "&uarr; {0} &uarr;".format(_TM['collapse diff']);
+		}
+		else if(!YUD.hasClass(t, 'hidden')){
+			YUD.addClass(t, 'hidden');
+			YUD.get(button).innerHTML = "&darr; {0} &darr;".format(_TM['expand diff']);
+		}
+	});
+	
+	
+	
+});
+
--- a/rhodecode/templates/base/root.html	Thu Feb 28 16:13:38 2013 +0100
+++ b/rhodecode/templates/base/root.html	Fri Mar 01 15:25:36 2013 +0100
@@ -51,6 +51,8 @@
                 'Open new pull request for selected changesets':  "${_('Open new pull request for selected changesets')}",
                 'Show selected changes __S -> __E': "${_('Show selected changes __S -> __E')}",
                 'Selection link': "${_('Selection link')}",
+                'collapse diff': "${_('collapse diff')}",
+                'expand diff': "${_('expand diff')}",
             };
             var _TM = TRANSLATION_MAP;
 
--- a/rhodecode/templates/changeset/diff_block.html	Thu Feb 28 16:13:38 2013 +0100
+++ b/rhodecode/templates/changeset/diff_block.html	Fri Mar 01 15:25:36 2013 +0100
@@ -4,7 +4,10 @@
 ## ${diff_block.diff_block(change)}
 ##
 <%def name="diff_block(change)">
-
+<div class="diff-collapse">
+    <span target="${'diff-container-%s' % (id(change))}" class="diff-collapse-button">&uarr; ${_('collapse diff')} &uarr;</span>
+</div>
+<div class="diff-container" id="${'diff-container-%s' % (id(change))}">
 %for FID,(cs1, cs2, change, path, diff, stats) in change.iteritems():
     ##%if op !='removed':
     <div id="${FID}_target" style="clear:both;margin-top:25px"></div>
@@ -37,7 +40,7 @@
     </div>
     ##%endif
 %endfor
-
+</div>
 </%def>
 
 <%def name="diff_block_simple(change)">