fix(issue-77): hides both sidebars when initializing with 'sidebar: false' (#81)

This commit is contained in:
Jamie Peabody
2018-05-26 12:48:15 -07:00
committed by GitHub
parent 157d763af6
commit d7a7ddcd55
2 changed files with 26 additions and 4 deletions

View File

@@ -691,9 +691,6 @@ jQuery.extend(Mgly.CodeMirrorDiffView.prototype, {
this.element.append(jQuery('<div style="position:relative;width:' + width + '; height:' + height + '" id="' + this.id + '-editor-lhs" class="mergely-column"><textarea style="" id="' + this.id + '-lhs"></textarea></div>'));
this.element.append(jQuery('<div class="mergely-canvas" style="height: ' + height + '"><canvas id="' + this.id + '-lhs-' + this.id + '-rhs-canvas" style="width:28px" width="28px" height="' + height + '"></canvas></div>'));
var rmargin = jQuery('<div class="mergely-margin" style="height: ' + height + '"><canvas id="' + this.id + '-rhs-margin" width="8px" height="' + height + '"></canvas></div>');
if (!this.settings.sidebar) {
this.element.find('.mergely-margin').css({display: 'none'});
}
if (this.settings.rhs_margin == 'left') {
this.element.append(rmargin);
}
@@ -701,6 +698,9 @@ jQuery.extend(Mgly.CodeMirrorDiffView.prototype, {
if (this.settings.rhs_margin != 'left') {
this.element.append(rmargin);
}
if (!this.settings.sidebar) {
this.element.find('.mergely-margin').css({display: 'none'});
}
if (['lgpl-separate-notice', 'gpl-separate-notice', 'mpl-separate-notice', 'commercial'].indexOf(this.settings.license) < 0) {
const _lic = {
'lgpl': 'GNU LGPL v3.0',

View File

@@ -42,7 +42,7 @@ describe('mergely', function () {
});
});
it.only('initializes with static arguments for lhs/rhs text', function (done) {
it('initializes with static arguments for lhs/rhs text', function (done) {
$(document).ready(() => {
const editor = init({
height: 100,
@@ -70,5 +70,27 @@ describe('mergely', function () {
});
});
it('initializes with no sidebar', function (done) {
$(document).ready(() => {
const editor = init({
height: 100,
license: 'lgpl-separate-notice',
sidebar: false
});
expect(editor).to.exist;
expect(editor.mergely).to.exist;
const children = editor.children();
expect(children.length).to.equal(6);
expect($(children[0]).attr('id')).to.equal('mergely-splash');
expect($(children[1]).attr('class')).to.equal('mergely-margin');
expect($(children[1]).css('display')).to.equal('none');
expect($(children[2]).attr('class')).to.equal('mergely-column');
expect($(children[3]).attr('class')).to.equal('mergely-canvas');
expect($(children[4]).attr('class')).to.equal('mergely-column');
expect($(children[5]).attr('class')).to.equal('mergely-margin');
expect($(children[5]).css('display')).to.equal('none');
done();
});
});
});
});