mirror of
https://github.com/wickedest/Mergely.git
synced 2026-02-02 09:38:00 +08:00
Compare commits
6 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c4776b1359 | ||
|
|
9875d58f15 | ||
|
|
ddfe77719e | ||
|
|
24b75d26dd | ||
|
|
21bd63961b | ||
|
|
36eb076648 |
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "Mergely",
|
||||
"version": "3.3.10",
|
||||
"version": "3.4.0",
|
||||
"homepage": "https://github.com/wickedest/Mergely",
|
||||
"description": "Merge and diff documents online",
|
||||
"main": [
|
||||
@@ -29,8 +29,8 @@
|
||||
"url": "git://github.com/wickedest/Mergely"
|
||||
},
|
||||
"dependencies": {
|
||||
"mergely": "https://github.com/wickedest/Mergely.git#3.3.10",
|
||||
"mergely": "https://github.com/wickedest/Mergely.git#3.4.0",
|
||||
"jquery": "<=2.1.3",
|
||||
"codemirror": "<=4.6.0"
|
||||
"codemirror": "<=5.11.0"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -146,7 +146,7 @@ $(document).ready(function() {
|
||||
var color_defaults = {
|
||||
cb: 'cccccc', cg: 'fafafa',
|
||||
ab: 'a3d1ff', ag: 'ddeeff',
|
||||
db: 'ff7f7f', dg: 'edc0c0'
|
||||
db: 'ff7f7f', dg: 'ffe9e9'
|
||||
};
|
||||
applyParameterCss(false);
|
||||
|
||||
|
||||
6
editor/editor.min.js
vendored
6
editor/editor.min.js
vendored
File diff suppressed because one or more lines are too long
@@ -52,7 +52,7 @@ if (isset($_GET['debug'])) {
|
||||
<script type="text/javascript" src="/Mergely/lib/searchcursor.js"></script>
|
||||
|
||||
<script type="text/javascript">
|
||||
var key = '<?php echo $key; ?>';
|
||||
var key = '<?php echo htmlspecialchars($key, ENT_QUOTES, 'UTF-8'); ?>';
|
||||
var isSample = key == 'usaindep';
|
||||
</script>
|
||||
|
||||
|
||||
@@ -4,10 +4,7 @@
|
||||
/* Set height, width, borders, and global font properties here */
|
||||
font-family: monospace;
|
||||
height: 300px;
|
||||
}
|
||||
.CodeMirror-scroll {
|
||||
/* Set scrolling behaviour here */
|
||||
overflow: auto;
|
||||
color: black;
|
||||
}
|
||||
|
||||
/* PADDING */
|
||||
@@ -36,8 +33,7 @@
|
||||
min-width: 20px;
|
||||
text-align: right;
|
||||
color: #999;
|
||||
-moz-box-sizing: content-box;
|
||||
box-sizing: content-box;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.CodeMirror-guttermarker { color: black; }
|
||||
@@ -45,19 +41,21 @@
|
||||
|
||||
/* CURSOR */
|
||||
|
||||
.CodeMirror div.CodeMirror-cursor {
|
||||
.CodeMirror-cursor {
|
||||
border-left: 1px solid black;
|
||||
border-right: none;
|
||||
width: 0;
|
||||
}
|
||||
/* Shown when moving in bi-directional text */
|
||||
.CodeMirror div.CodeMirror-secondarycursor {
|
||||
border-left: 1px solid silver;
|
||||
}
|
||||
.CodeMirror.cm-keymap-fat-cursor div.CodeMirror-cursor {
|
||||
.cm-fat-cursor .CodeMirror-cursor {
|
||||
width: auto;
|
||||
border: 0;
|
||||
background: #7e7;
|
||||
}
|
||||
.CodeMirror.cm-keymap-fat-cursor div.CodeMirror-cursors {
|
||||
.cm-fat-cursor div.CodeMirror-cursors {
|
||||
z-index: 1;
|
||||
}
|
||||
|
||||
@@ -67,27 +65,28 @@
|
||||
-webkit-animation: blink 1.06s steps(1) infinite;
|
||||
-moz-animation: blink 1.06s steps(1) infinite;
|
||||
animation: blink 1.06s steps(1) infinite;
|
||||
background-color: #7e7;
|
||||
}
|
||||
@-moz-keyframes blink {
|
||||
0% { background: #7e7; }
|
||||
50% { background: none; }
|
||||
100% { background: #7e7; }
|
||||
0% {}
|
||||
50% { background-color: transparent; }
|
||||
100% {}
|
||||
}
|
||||
@-webkit-keyframes blink {
|
||||
0% { background: #7e7; }
|
||||
50% { background: none; }
|
||||
100% { background: #7e7; }
|
||||
0% {}
|
||||
50% { background-color: transparent; }
|
||||
100% {}
|
||||
}
|
||||
@keyframes blink {
|
||||
0% { background: #7e7; }
|
||||
50% { background: none; }
|
||||
100% { background: #7e7; }
|
||||
0% {}
|
||||
50% { background-color: transparent; }
|
||||
100% {}
|
||||
}
|
||||
|
||||
/* Can style cursor different in overwrite (non-insert) mode */
|
||||
div.CodeMirror-overwrite div.CodeMirror-cursor {}
|
||||
.CodeMirror-overwrite .CodeMirror-cursor {}
|
||||
|
||||
.cm-tab { display: inline-block; }
|
||||
.cm-tab { display: inline-block; text-decoration: inherit; }
|
||||
|
||||
.CodeMirror-ruler {
|
||||
border-left: 1px solid #ccc;
|
||||
@@ -96,6 +95,15 @@ div.CodeMirror-overwrite div.CodeMirror-cursor {}
|
||||
|
||||
/* DEFAULT THEME */
|
||||
|
||||
.cm-s-default .cm-header {color: blue;}
|
||||
.cm-s-default .cm-quote {color: #090;}
|
||||
.cm-negative {color: #d44;}
|
||||
.cm-positive {color: #292;}
|
||||
.cm-header, .cm-strong {font-weight: bold;}
|
||||
.cm-em {font-style: italic;}
|
||||
.cm-link {text-decoration: underline;}
|
||||
.cm-strikethrough {text-decoration: line-through;}
|
||||
|
||||
.cm-s-default .cm-keyword {color: #708;}
|
||||
.cm-s-default .cm-atom {color: #219;}
|
||||
.cm-s-default .cm-number {color: #164;}
|
||||
@@ -115,20 +123,14 @@ div.CodeMirror-overwrite div.CodeMirror-cursor {}
|
||||
.cm-s-default .cm-bracket {color: #997;}
|
||||
.cm-s-default .cm-tag {color: #170;}
|
||||
.cm-s-default .cm-attribute {color: #00c;}
|
||||
.cm-s-default .cm-header {color: blue;}
|
||||
.cm-s-default .cm-quote {color: #090;}
|
||||
.cm-s-default .cm-hr {color: #999;}
|
||||
.cm-s-default .cm-link {color: #00c;}
|
||||
|
||||
.cm-negative {color: #d44;}
|
||||
.cm-positive {color: #292;}
|
||||
.cm-header, .cm-strong {font-weight: bold;}
|
||||
.cm-em {font-style: italic;}
|
||||
.cm-link {text-decoration: underline;}
|
||||
|
||||
.cm-s-default .cm-error {color: #f00;}
|
||||
.cm-invalidchar {color: #f00;}
|
||||
|
||||
.CodeMirror-composing { border-bottom: 2px solid; }
|
||||
|
||||
/* Default styles for common addons */
|
||||
|
||||
div.CodeMirror span.CodeMirror-matchingbracket {color: #0f0;}
|
||||
@@ -142,14 +144,13 @@ div.CodeMirror span.CodeMirror-nonmatchingbracket {color: #f22;}
|
||||
the editor. You probably shouldn't touch them. */
|
||||
|
||||
.CodeMirror {
|
||||
line-height: 1;
|
||||
position: relative;
|
||||
overflow: hidden;
|
||||
background: white;
|
||||
color: black;
|
||||
}
|
||||
|
||||
.CodeMirror-scroll {
|
||||
overflow: scroll !important; /* Things will break if this is overridden */
|
||||
/* 30px is the magic margin used to hide the element's real scrollbars */
|
||||
/* See overflow: hidden in .CodeMirror */
|
||||
margin-bottom: -30px; margin-right: -30px;
|
||||
@@ -157,18 +158,14 @@ div.CodeMirror span.CodeMirror-nonmatchingbracket {color: #f22;}
|
||||
height: 100%;
|
||||
outline: none; /* Prevent dragging from highlighting the element */
|
||||
position: relative;
|
||||
-moz-box-sizing: content-box;
|
||||
box-sizing: content-box;
|
||||
}
|
||||
.CodeMirror-sizer {
|
||||
position: relative;
|
||||
border-right: 30px solid transparent;
|
||||
-moz-box-sizing: content-box;
|
||||
box-sizing: content-box;
|
||||
}
|
||||
|
||||
/* The fake, visible scrollbars. Used to force redraw during scrolling
|
||||
before actuall scrolling happens, thus preventing shaking and
|
||||
before actual scrolling happens, thus preventing shaking and
|
||||
flickering artifacts. */
|
||||
.CodeMirror-vscrollbar, .CodeMirror-hscrollbar, .CodeMirror-scrollbar-filler, .CodeMirror-gutter-filler {
|
||||
position: absolute;
|
||||
@@ -194,26 +191,38 @@ div.CodeMirror span.CodeMirror-nonmatchingbracket {color: #f22;}
|
||||
|
||||
.CodeMirror-gutters {
|
||||
position: absolute; left: 0; top: 0;
|
||||
padding-bottom: 30px;
|
||||
z-index: 3;
|
||||
}
|
||||
.CodeMirror-gutter {
|
||||
white-space: normal;
|
||||
height: 100%;
|
||||
-moz-box-sizing: content-box;
|
||||
box-sizing: content-box;
|
||||
padding-bottom: 30px;
|
||||
margin-bottom: -32px;
|
||||
display: inline-block;
|
||||
margin-bottom: -30px;
|
||||
/* Hack to make IE7 behave */
|
||||
*zoom:1;
|
||||
*display:inline;
|
||||
}
|
||||
.CodeMirror-gutter-wrapper {
|
||||
position: absolute;
|
||||
z-index: 4;
|
||||
background: none !important;
|
||||
border: none !important;
|
||||
}
|
||||
.CodeMirror-gutter-background {
|
||||
position: absolute;
|
||||
top: 0; bottom: 0;
|
||||
z-index: 4;
|
||||
}
|
||||
.CodeMirror-gutter-elt {
|
||||
position: absolute;
|
||||
cursor: default;
|
||||
z-index: 4;
|
||||
}
|
||||
.CodeMirror-gutter-wrapper {
|
||||
-webkit-user-select: none;
|
||||
-moz-user-select: none;
|
||||
user-select: none;
|
||||
}
|
||||
|
||||
.CodeMirror-lines {
|
||||
cursor: text;
|
||||
@@ -234,6 +243,7 @@ div.CodeMirror span.CodeMirror-nonmatchingbracket {color: #f22;}
|
||||
z-index: 2;
|
||||
position: relative;
|
||||
overflow: visible;
|
||||
-webkit-tap-highlight-color: transparent;
|
||||
}
|
||||
.CodeMirror-wrap pre {
|
||||
word-wrap: break-word;
|
||||
@@ -255,8 +265,18 @@ div.CodeMirror span.CodeMirror-nonmatchingbracket {color: #f22;}
|
||||
|
||||
.CodeMirror-widget {}
|
||||
|
||||
.CodeMirror-wrap .CodeMirror-scroll {
|
||||
overflow-x: hidden;
|
||||
.CodeMirror-code {
|
||||
outline: none;
|
||||
}
|
||||
|
||||
/* Force content-box sizing for the elements where we expect it */
|
||||
.CodeMirror-scroll,
|
||||
.CodeMirror-sizer,
|
||||
.CodeMirror-gutter,
|
||||
.CodeMirror-gutters,
|
||||
.CodeMirror-linenumber {
|
||||
-moz-box-sizing: content-box;
|
||||
box-sizing: content-box;
|
||||
}
|
||||
|
||||
.CodeMirror-measure {
|
||||
@@ -266,19 +286,19 @@ div.CodeMirror span.CodeMirror-nonmatchingbracket {color: #f22;}
|
||||
overflow: hidden;
|
||||
visibility: hidden;
|
||||
}
|
||||
.CodeMirror-measure pre { position: static; }
|
||||
|
||||
.CodeMirror div.CodeMirror-cursor {
|
||||
position: absolute;
|
||||
border-right: none;
|
||||
width: 0;
|
||||
}
|
||||
.CodeMirror-cursor { position: absolute; }
|
||||
.CodeMirror-measure pre { position: static; }
|
||||
|
||||
div.CodeMirror-cursors {
|
||||
visibility: hidden;
|
||||
position: relative;
|
||||
z-index: 3;
|
||||
}
|
||||
div.CodeMirror-dragcursors {
|
||||
visibility: visible;
|
||||
}
|
||||
|
||||
.CodeMirror-focused div.CodeMirror-cursors {
|
||||
visibility: visible;
|
||||
}
|
||||
@@ -286,6 +306,8 @@ div.CodeMirror-cursors {
|
||||
.CodeMirror-selected { background: #d9d9d9; }
|
||||
.CodeMirror-focused .CodeMirror-selected { background: #d7d4f0; }
|
||||
.CodeMirror-crosshair { cursor: crosshair; }
|
||||
.CodeMirror-line::selection, .CodeMirror-line > span::selection, .CodeMirror-line > span > span::selection { background: #d7d4f0; }
|
||||
.CodeMirror-line::-moz-selection, .CodeMirror-line > span::-moz-selection, .CodeMirror-line > span > span::-moz-selection { background: #d7d4f0; }
|
||||
|
||||
.cm-searching {
|
||||
background: #ffa;
|
||||
@@ -305,5 +327,8 @@ div.CodeMirror-cursors {
|
||||
}
|
||||
}
|
||||
|
||||
/* See issue #2901 */
|
||||
.cm-tab-wrap-hack:after { content: ''; }
|
||||
|
||||
/* Help users use markselection to safely style text background */
|
||||
span.CodeMirror-selectedtext { background: none; }
|
||||
|
||||
3095
lib/codemirror.js
3095
lib/codemirror.js
File diff suppressed because it is too large
Load Diff
10
lib/codemirror.min.js
vendored
10
lib/codemirror.min.js
vendored
File diff suppressed because one or more lines are too long
@@ -12,17 +12,19 @@
|
||||
.mergely-column { border: 1px solid #ccc; }
|
||||
.mergely-active { border: 1px solid #a3d1ff; }
|
||||
|
||||
.mergely.a,.mergely.d,.mergely.c { color: #000; }
|
||||
|
||||
.mergely.a.rhs.start { border-top: 1px solid #a3d1ff; }
|
||||
.mergely.a.lhs.start.end,
|
||||
.mergely.a.rhs.end { border-bottom: 1px solid #a3d1ff; }
|
||||
.mergely.a.rhs { background-color: #ddeeff; }
|
||||
.mergely.a.lhs.start.end.first { border-bottom: 0; border-top: 1px solid #a3d1ff; }
|
||||
|
||||
.mergely.d.lhs { background-color: #edc0c0; }
|
||||
.mergely.d.lhs { background-color: #ffe9e9; }
|
||||
.mergely.d.lhs.end,
|
||||
.mergely.d.rhs.start.end { border-bottom: 1px solid #ff7f7f; }
|
||||
.mergely.d.rhs.start.end.first { border-bottom: 0; border-top: 1px solid #ff7f7f; }
|
||||
.mergely.d.lhs.start { border-top: 1px solid #ff7f7f; }
|
||||
.mergely.d.rhs.start.end { border-bottom: 1px solid #f8e8e8; }
|
||||
.mergely.d.rhs.start.end.first { border-bottom: 0; border-top: 1px solid #f8e8e8; }
|
||||
.mergely.d.lhs.start { border-top: 1px solid #f8e8e8; }
|
||||
|
||||
.mergely.c.lhs,
|
||||
.mergely.c.rhs { background-color: #fafafa; }
|
||||
@@ -32,4 +34,12 @@
|
||||
.mergely.c.rhs.end { border-bottom: 1px solid #a3a3a3; }
|
||||
|
||||
.mergely.ch.a.rhs { background-color: #ddeeff; }
|
||||
.mergely.ch.d.lhs { background-color: #edc0c0; text-decoration: line-through; color: #888; }
|
||||
.mergely.ch.d.lhs { background-color: #ffe9e9; text-decoration: line-through; color: red !important; }
|
||||
|
||||
.mergely.current.start { border-top: 1px solid #000 !important; }
|
||||
.mergely.current.end { border-bottom: 1px solid #000 !important; }
|
||||
.mergely.current.lhs.a.start.end,
|
||||
.mergely.current.rhs.d.start.end { border-top: 0 !important; }
|
||||
.mergely.current.CodeMirror-linenumber { color: #F9F9F9; font-weight: bold; background-color: #777; }
|
||||
.CodeMirror-linenumber { cursor: pointer; }
|
||||
.CodeMirror-code { color: #717171; }
|
||||
|
||||
117
lib/mergely.js
117
lib/mergely.js
@@ -496,7 +496,7 @@ jQuery.extend(Mgly.CodeMirrorDiffView.prototype, {
|
||||
if (direction == 'next') {
|
||||
this._current_diff = Math.min(++this._current_diff, this.changes.length - 1);
|
||||
}
|
||||
else {
|
||||
else if (direction == 'prev') {
|
||||
this._current_diff = Math.max(--this._current_diff, 0);
|
||||
}
|
||||
this._scroll_to_change(this.changes[this._current_diff]);
|
||||
@@ -539,10 +539,10 @@ jQuery.extend(Mgly.CodeMirrorDiffView.prototype, {
|
||||
if (this.settings.hasOwnProperty('sidebar')) {
|
||||
// dynamically enable sidebars
|
||||
if (this.settings.sidebar) {
|
||||
jQuery(this.element).find('.mergely-margin').css({display: 'block'});
|
||||
this.element.find('.mergely-margin').css({display: 'block'});
|
||||
}
|
||||
else {
|
||||
jQuery(this.element).find('.mergely-margin').css({display: 'none'});
|
||||
this.element.find('.mergely-margin').css({display: 'none'});
|
||||
}
|
||||
}
|
||||
var le, re;
|
||||
@@ -689,12 +689,12 @@ jQuery.extend(Mgly.CodeMirrorDiffView.prototype, {
|
||||
jQuery('<style type="text/css">' + cmstyle + '</style>').appendTo('head');
|
||||
|
||||
//bind
|
||||
var rhstx = jQuery('#' + this.id + '-rhs').get(0);
|
||||
var rhstx = this.element.find('#' + this.id + '-rhs').get(0);
|
||||
if (!rhstx) {
|
||||
console.error('rhs textarea not defined - Mergely not initialized properly');
|
||||
return;
|
||||
}
|
||||
var lhstx = jQuery('#' + this.id + '-lhs').get(0);
|
||||
var lhstx = this.element.find('#' + this.id + '-lhs').get(0);
|
||||
if (!rhstx) {
|
||||
console.error('lhs textarea not defined - Mergely not initialized properly');
|
||||
return;
|
||||
@@ -727,6 +727,33 @@ jQuery.extend(Mgly.CodeMirrorDiffView.prototype, {
|
||||
);
|
||||
sz(true);
|
||||
}
|
||||
|
||||
this.editor[this.id + '-lhs'].on('gutterClick', function(cm, n) {
|
||||
return $(this.changes).filter(function (i, change) {
|
||||
if (n >= change['lhs-line-from'] && n <= change['lhs-line-to']) {
|
||||
this._current_diff = i;
|
||||
return true;
|
||||
}
|
||||
}.bind(this));
|
||||
// I really don't like this here - something about gutterClick does not
|
||||
// like mutating editor here. Need to trigger the scroll to diff from
|
||||
// a timeout.
|
||||
setTimeout(function() { this.scrollToDiff(); }.bind(this), 10);
|
||||
}.bind(this));
|
||||
|
||||
this.editor[this.id + '-rhs'].on('gutterClick', function(cm, n) {
|
||||
$(this.changes).filter(function (i, change) {
|
||||
if (n >= change['rhs-line-from'] && n <= change['rhs-line-to']) {
|
||||
this._current_diff = i;
|
||||
return true;
|
||||
}
|
||||
}.bind(this));
|
||||
// I really don't like this here - something about gutterClick does not
|
||||
// like mutating editor here. Need to trigger the scroll to diff from
|
||||
// a timeout.
|
||||
setTimeout(function() { this.scrollToDiff(); }.bind(this), 10);
|
||||
}.bind(this));
|
||||
|
||||
//bind
|
||||
var setv;
|
||||
if (this.settings.lhs) {
|
||||
@@ -744,23 +771,10 @@ jQuery.extend(Mgly.CodeMirrorDiffView.prototype, {
|
||||
var self = this;
|
||||
var led = self.editor[self.id+'-lhs'];
|
||||
var red = self.editor[self.id+'-rhs'];
|
||||
|
||||
var yref = led.getScrollerElement().offsetHeight * 0.5; // center between >0 and 1/2
|
||||
|
||||
// set cursors
|
||||
led.setCursor(Math.max(change["lhs-line-from"],0), 0); // use led.getCursor().ch ?
|
||||
red.setCursor(Math.max(change["rhs-line-from"],0), 0);
|
||||
|
||||
// using directly CodeMirror breaks canvas alignment
|
||||
// var ly = led.charCoords({line: Math.max(change["lhs-line-from"],0), ch: 0}, "local").top;
|
||||
|
||||
// calculate scroll offset for current change. Warning: returns relative y position so we scroll to 0 first.
|
||||
led.scrollTo(null, 0);
|
||||
red.scrollTo(null, 0);
|
||||
self._calculate_offsets(self.id+'-lhs', self.id+'-rhs', [change]);
|
||||
led.scrollTo(null, Math.max(change["lhs-y-start"]-yref, 0));
|
||||
red.scrollTo(null, Math.max(change["rhs-y-start"]-yref, 0));
|
||||
// right pane should simply follows
|
||||
led.scrollIntoView({line: change["lhs-line-to"]});
|
||||
},
|
||||
|
||||
_scrolling: function(editor_name) {
|
||||
@@ -921,7 +935,7 @@ jQuery.extend(Mgly.CodeMirrorDiffView.prototype, {
|
||||
this.trace('change', 'diff time', timer.stop());
|
||||
this.changes = Mgly.DiffParser(d.normal_form());
|
||||
this.trace('change', 'parse time', timer.stop());
|
||||
if (this._current_diff === undefined) {
|
||||
if (this._current_diff === undefined && this.changes.length) {
|
||||
// go to first difference on start-up
|
||||
this._current_diff = 0;
|
||||
this._scroll_to_change(this.changes[0]);
|
||||
@@ -989,7 +1003,7 @@ jQuery.extend(Mgly.CodeMirrorDiffView.prototype, {
|
||||
|
||||
// this is the distance from the top of the screen to the top of the
|
||||
// content of the first codemirror editor
|
||||
var topnode = jQuery('#' + this.id + ' .CodeMirror-measure').first();
|
||||
var topnode = this.element.find('.CodeMirror-measure').first();
|
||||
var top_offset = topnode.offset().top - 4;
|
||||
if(!top_offset) return false;
|
||||
|
||||
@@ -1123,6 +1137,7 @@ jQuery.extend(Mgly.CodeMirrorDiffView.prototype, {
|
||||
var self = this;
|
||||
var led = this.editor[editor_name1];
|
||||
var red = this.editor[editor_name2];
|
||||
var current_diff = this._current_diff;
|
||||
|
||||
var timer = new Mgly.Timer();
|
||||
led.operation(function() {
|
||||
@@ -1137,6 +1152,12 @@ jQuery.extend(Mgly.CodeMirrorDiffView.prototype, {
|
||||
led.addLineClass(llf, 'background', 'start');
|
||||
led.addLineClass(llt, 'background', 'end');
|
||||
|
||||
if (current_diff == i) {
|
||||
if (llf != llt) {
|
||||
led.addLineClass(llf, 'background', 'current');
|
||||
}
|
||||
led.addLineClass(llt, 'background', 'current');
|
||||
}
|
||||
if (llf == 0 && llt == 0 && rlf == 0) {
|
||||
led.addLineClass(llf, 'background', clazz.join(' '));
|
||||
led.addLineClass(llf, 'background', 'first');
|
||||
@@ -1182,7 +1203,13 @@ jQuery.extend(Mgly.CodeMirrorDiffView.prototype, {
|
||||
var clazz = ['mergely', 'rhs', change['op'], 'cid-' + i];
|
||||
red.addLineClass(rlf, 'background', 'start');
|
||||
red.addLineClass(rlt, 'background', 'end');
|
||||
|
||||
|
||||
if (current_diff == i) {
|
||||
if (rlf != rlt) {
|
||||
red.addLineClass(rlf, 'background', 'current');
|
||||
}
|
||||
red.addLineClass(rlt, 'background', 'current');
|
||||
}
|
||||
if (rlf == 0 && rlt == 0 && llf == 0) {
|
||||
red.addLineClass(rlf, 'background', clazz.join(' '));
|
||||
red.addLineClass(rlf, 'background', 'first');
|
||||
@@ -1283,6 +1310,7 @@ jQuery.extend(Mgly.CodeMirrorDiffView.prototype, {
|
||||
self.chfns[self.id + '-rhs'].push(m[0].markText(m[1], m[2], m[3]));
|
||||
}
|
||||
});
|
||||
|
||||
this.trace('change', 'LCS markup time', timer.stop());
|
||||
|
||||
// merge buttons
|
||||
@@ -1311,6 +1339,35 @@ jQuery.extend(Mgly.CodeMirrorDiffView.prototype, {
|
||||
self._merge_change(change, side, oside);
|
||||
return false;
|
||||
});
|
||||
|
||||
// gutter markup
|
||||
var lhsLineNumbers = $('#mergely-lhs ~ .CodeMirror').find('.CodeMirror-linenumber');
|
||||
var rhsLineNumbers = $('#mergely-rhs ~ .CodeMirror').find('.CodeMirror-linenumber');
|
||||
rhsLineNumbers.removeClass('mergely current');
|
||||
lhsLineNumbers.removeClass('mergely current');
|
||||
for (var i = 0; i < changes.length; ++i) {
|
||||
if (current_diff == i && change.op !== 'd') {
|
||||
var change = changes[i];
|
||||
var j, jf = change['rhs-line-from'], jt = change['rhs-line-to'] + 1;
|
||||
for (j = jf; j < jt; j++) {
|
||||
var n = (j + 1).toString();
|
||||
rhsLineNumbers
|
||||
.filter(function(i, node) { return $(node).text() === n; })
|
||||
.addClass('mergely current');
|
||||
}
|
||||
}
|
||||
if (current_diff == i && change.op !== 'a') {
|
||||
var change = changes[i];
|
||||
jf = change['lhs-line-from'], jt = change['lhs-line-to'] + 1;
|
||||
for (j = jf; j < jt; j++) {
|
||||
var n = (j + 1).toString();
|
||||
lhsLineNumbers
|
||||
.filter(function(i, node) { return $(node).text() === n; })
|
||||
.addClass('mergely current');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
this.trace('change', 'markup buttons time', timer.stop());
|
||||
},
|
||||
_merge_change : function(change, side, oside) {
|
||||
@@ -1370,8 +1427,8 @@ jQuery.extend(Mgly.CodeMirrorDiffView.prototype, {
|
||||
var gutter_height = jQuery(this.editor[editor_name1].getScrollerElement()).children(':first-child').height();
|
||||
var dcanvas = document.getElementById(editor_name1 + '-' + editor_name2 + '-canvas');
|
||||
if (dcanvas == undefined) throw 'Failed to find: ' + editor_name1 + '-' + editor_name2 + '-canvas';
|
||||
var clhs = jQuery('#' + this.id + '-lhs-margin');
|
||||
var crhs = jQuery('#' + this.id + '-rhs-margin');
|
||||
var clhs = this.element.find('#' + this.id + '-lhs-margin');
|
||||
var crhs = this.element.find('#' + this.id + '-rhs-margin');
|
||||
return {
|
||||
visible_page_height: visible_page_height,
|
||||
gutter_height: gutter_height,
|
||||
@@ -1402,7 +1459,7 @@ jQuery.extend(Mgly.CodeMirrorDiffView.prototype, {
|
||||
this.trace('draw', 'lhs-scroller-top', ex.lhs_scroller.scrollTop());
|
||||
this.trace('draw', 'rhs-scroller-top', ex.rhs_scroller.scrollTop());
|
||||
|
||||
jQuery.each(jQuery.find('#' + this.id + ' canvas'), function () {
|
||||
jQuery.each(this.element.find('canvas'), function () {
|
||||
jQuery(this).get(0).height = ex.visible_page_height;
|
||||
});
|
||||
|
||||
@@ -1424,6 +1481,10 @@ jQuery.extend(Mgly.CodeMirrorDiffView.prototype, {
|
||||
var vp = this._get_viewport(editor_name1, editor_name2);
|
||||
for (var i = 0; i < changes.length; ++i) {
|
||||
var change = changes[i];
|
||||
var fill = this.settings.fgcolor[change['op']];
|
||||
if (this._current_diff==i) {
|
||||
fill = '#000';
|
||||
}
|
||||
|
||||
this.trace('draw', change);
|
||||
// margin indicators
|
||||
@@ -1434,14 +1495,14 @@ jQuery.extend(Mgly.CodeMirrorDiffView.prototype, {
|
||||
this.trace('draw', 'marker calculated', lhs_y_start, lhs_y_end, rhs_y_start, rhs_y_end);
|
||||
|
||||
ctx_lhs.beginPath();
|
||||
ctx_lhs.fillStyle = this.settings.fgcolor[(this._current_diff==i?'c':'')+change['op']];
|
||||
ctx_lhs.fillStyle = fill;
|
||||
ctx_lhs.strokeStyle = '#000';
|
||||
ctx_lhs.lineWidth = 0.5;
|
||||
ctx_lhs.fillRect(1.5, lhs_y_start, 4.5, Math.max(lhs_y_end - lhs_y_start, 5));
|
||||
ctx_lhs.strokeRect(1.5, lhs_y_start, 4.5, Math.max(lhs_y_end - lhs_y_start, 5));
|
||||
|
||||
ctx_rhs.beginPath();
|
||||
ctx_rhs.fillStyle = this.settings.fgcolor[(this._current_diff==i?'c':'')+change['op']];
|
||||
ctx_rhs.fillStyle = fill;
|
||||
ctx_rhs.strokeStyle = '#000';
|
||||
ctx_rhs.lineWidth = 0.5;
|
||||
ctx_rhs.fillRect(1.5, rhs_y_start, 4.5, Math.max(rhs_y_end - rhs_y_start, 5));
|
||||
@@ -1460,7 +1521,7 @@ jQuery.extend(Mgly.CodeMirrorDiffView.prototype, {
|
||||
|
||||
// draw left box
|
||||
ctx.beginPath();
|
||||
ctx.strokeStyle = this.settings.fgcolor[(this._current_diff==i?'c':'')+change['op']];
|
||||
ctx.strokeStyle = fill;
|
||||
ctx.lineWidth = (this._current_diff==i) ? 1.5 : 1;
|
||||
|
||||
var rectWidth = this.draw_lhs_width;
|
||||
|
||||
7
lib/mergely.min.js
vendored
7
lib/mergely.min.js
vendored
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user