[update] New line added icon
This commit is contained in:
@@ -28,11 +28,19 @@ application.factory(
|
||||
_version.lines = [];
|
||||
var length = _version.content.split(/\r\n|\r|\n/).length;
|
||||
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
|
||||
var count = 0,
|
||||
modified = 0;
|
||||
modified = 0,
|
||||
line_index = 0;
|
||||
|
||||
if( !_version.diff )
|
||||
{
|
||||
@@ -45,10 +53,32 @@ application.factory(
|
||||
for( var _diff_key in _version.diff )
|
||||
{
|
||||
var _diff = _version.diff[ _diff_key ];
|
||||
|
||||
count += _diff.count;
|
||||
|
||||
if( _diff.added /*|| _diff.removed*/ )
|
||||
{
|
||||
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_percent = Math.round( _version.diff_ratio * 100 ) + '%';
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -483,8 +483,36 @@ body.project
|
||||
left 0
|
||||
width 38px
|
||||
padding 0.5em
|
||||
|
||||
.line
|
||||
position relative
|
||||
|
||||
.index
|
||||
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
|
||||
pre
|
||||
code
|
||||
@@ -495,31 +523,6 @@ body.project
|
||||
margin-left 38px
|
||||
background none
|
||||
outline none
|
||||
|
||||
.differences
|
||||
position absolute
|
||||
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)
|
||||
.state-show-differences
|
||||
section.main section.file section.code .lines .line.added .added-icon
|
||||
display block
|
||||
|
||||
@@ -18,7 +18,7 @@ script(type="text/ng-template",id="folder_template.html")
|
||||
span.notif.new-version(ng-if="_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
|
||||
header.aside-header
|
||||
@@ -114,15 +114,12 @@ div(ng-controller="ProjectController as controller",ng-init="init('" + project_s
|
||||
.lines
|
||||
pre
|
||||
code
|
||||
.line(ng-repeat="_line in version.lines")
|
||||
| {{ _line }}
|
||||
.line(ng-repeat="_line in version.lines",ng-class="_line.added ? 'added' : ''")
|
||||
.added-icon
|
||||
.bar.bar-1
|
||||
.bar.bar-2
|
||||
.index
|
||||
| {{ _line.index }}
|
||||
.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
|
||||
|
||||
Reference in New Issue
Block a user