[update] New line added icon

This commit is contained in:
brunosimon
2016-10-24 00:32:23 +02:00
parent e44ca988fb
commit 5d716b1093
4 changed files with 73 additions and 43 deletions
+32 -2
View File
@@ -28,11 +28,19 @@ application.factory(
_version.lines = []; _version.lines = [];
var length = _version.content.split(/\r\n|\r|\n/).length; var length = _version.content.split(/\r\n|\r|\n/).length;
for( var i = 1; i < length + 1; i++ ) for( var i = 1; i < length + 1; i++ )
_version.lines.push( i ); {
var line = {};
line.index = i;
line.added = false;
line.removed = false;
_version.lines.push( line );
}
// Differences // Differences
var count = 0, var count = 0,
modified = 0; modified = 0,
line_index = 0;
if( !_version.diff ) if( !_version.diff )
{ {
@@ -45,10 +53,32 @@ application.factory(
for( var _diff_key in _version.diff ) for( var _diff_key in _version.diff )
{ {
var _diff = _version.diff[ _diff_key ]; var _diff = _version.diff[ _diff_key ];
count += _diff.count; count += _diff.count;
if( _diff.added /*|| _diff.removed*/ ) if( _diff.added /*|| _diff.removed*/ )
{
modified += _diff.count; modified += _diff.count;
} }
// Add info to line
if( typeof _diff.removed === 'undefined' )
{
var lines_breaks = _diff.value.match(/\r\n|\r|\n/g),
lines_count = lines_breaks ? lines_breaks.length : 0;
if( _diff.added )
{
for( var j = line_index; j < line_index + lines_count; j++ )
{
var line = _version.lines[ j ];
line.added = true;
}
}
line_index += lines_count;
}
}
_version.diff_ratio = modified / count; _version.diff_ratio = modified / count;
} }
_version.diff_percent = Math.round( _version.diff_ratio * 100 ) + '%'; _version.diff_percent = Math.round( _version.diff_ratio * 100 ) + '%';
File diff suppressed because one or more lines are too long
+31 -28
View File
@@ -483,8 +483,36 @@ body.project
left 0 left 0
width 38px width 38px
padding 0.5em padding 0.5em
.line
position relative
.index
opacity 0.2 opacity 0.2
.added-icon
display none
position absolute
top 50%
right -2px
width 6px
height 6px
margin-top -3px
.bar
display block
position absolute
background #17f861
&.bar-1
left 2px
width 2px
height 100%
&.bar-2
top 2px
width 100%
height 2px
.current .current
pre pre
code code
@@ -495,31 +523,6 @@ body.project
margin-left 38px margin-left 38px
background none background none
outline none outline none
.state-show-differences
.differences section.main section.file section.code .lines .line.added .added-icon
position absolute display block
top 0
left 38px
padding 0.5em
pointer-events none
pre
code
.value
visibility hidden
&.inactive
display none
span
&.removed
display none
border 1px solid red
.value
display none
&.added
border 1px solid #b0ea23
background rgba(176, 234, 35, 0.1)
+7 -10
View File
@@ -18,7 +18,7 @@ script(type="text/ng-template",id="folder_template.html")
span.notif.new-version(ng-if="_file.data.notif") span.notif.new-version(ng-if="_file.data.notif")
| {{_file.data.notif}} | {{_file.data.notif}}
div(ng-controller="ProjectController as controller",ng-init="init('" + project_slug + "')") div(ng-controller="ProjectController as controller",ng-init="init('" + project_slug + "')",ng-class="show_differences ? 'state-show-differences' : ''")
aside.aside aside.aside
header.aside-header header.aside-header
@@ -114,15 +114,12 @@ div(ng-controller="ProjectController as controller",ng-init="init('" + project_s
.lines .lines
pre pre
code code
.line(ng-repeat="_line in version.lines") .line(ng-repeat="_line in version.lines",ng-class="_line.added ? 'added' : ''")
| {{ _line }} .added-icon
.bar.bar-1
.bar.bar-2
.index
| {{ _line.index }}
.current(hljs,hljs-source="version.content") .current(hljs,hljs-source="version.content")
.differences
pre
code(ng-if="version.diff",ng-class="show_differences ? 'active' : 'inactive'")
span(ng-repeat="_difference in version.diff",ng-class="{removed: _difference.removed, added: _difference.added}")
span.value
| {{ _difference.value }}
include ../../partials/footer.pug include ../../partials/footer.pug