Fixes #37: Enable use within shadow-dom by searching beneath this.element.
This commit is contained in:
@@ -539,10 +539,10 @@ jQuery.extend(Mgly.CodeMirrorDiffView.prototype, {
|
|||||||
if (this.settings.hasOwnProperty('sidebar')) {
|
if (this.settings.hasOwnProperty('sidebar')) {
|
||||||
// dynamically enable sidebars
|
// dynamically enable sidebars
|
||||||
if (this.settings.sidebar) {
|
if (this.settings.sidebar) {
|
||||||
jQuery(this.element).find('.mergely-margin').css({display: 'block'});
|
this.element.find('.mergely-margin').css({display: 'block'});
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
jQuery(this.element).find('.mergely-margin').css({display: 'none'});
|
this.element.find('.mergely-margin').css({display: 'none'});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
var le, re;
|
var le, re;
|
||||||
@@ -689,12 +689,12 @@ jQuery.extend(Mgly.CodeMirrorDiffView.prototype, {
|
|||||||
jQuery('<style type="text/css">' + cmstyle + '</style>').appendTo('head');
|
jQuery('<style type="text/css">' + cmstyle + '</style>').appendTo('head');
|
||||||
|
|
||||||
//bind
|
//bind
|
||||||
var rhstx = jQuery('#' + this.id + '-rhs').get(0);
|
var rhstx = this.element.find('#' + this.id + '-rhs').get(0);
|
||||||
if (!rhstx) {
|
if (!rhstx) {
|
||||||
console.error('rhs textarea not defined - Mergely not initialized properly');
|
console.error('rhs textarea not defined - Mergely not initialized properly');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var lhstx = jQuery('#' + this.id + '-lhs').get(0);
|
var lhstx = this.element.find('#' + this.id + '-lhs').get(0);
|
||||||
if (!rhstx) {
|
if (!rhstx) {
|
||||||
console.error('lhs textarea not defined - Mergely not initialized properly');
|
console.error('lhs textarea not defined - Mergely not initialized properly');
|
||||||
return;
|
return;
|
||||||
@@ -989,7 +989,7 @@ jQuery.extend(Mgly.CodeMirrorDiffView.prototype, {
|
|||||||
|
|
||||||
// this is the distance from the top of the screen to the top of the
|
// this is the distance from the top of the screen to the top of the
|
||||||
// content of the first codemirror editor
|
// 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;
|
var top_offset = topnode.offset().top - 4;
|
||||||
if(!top_offset) return false;
|
if(!top_offset) return false;
|
||||||
|
|
||||||
@@ -1370,8 +1370,8 @@ jQuery.extend(Mgly.CodeMirrorDiffView.prototype, {
|
|||||||
var gutter_height = jQuery(this.editor[editor_name1].getScrollerElement()).children(':first-child').height();
|
var gutter_height = jQuery(this.editor[editor_name1].getScrollerElement()).children(':first-child').height();
|
||||||
var dcanvas = document.getElementById(editor_name1 + '-' + editor_name2 + '-canvas');
|
var dcanvas = document.getElementById(editor_name1 + '-' + editor_name2 + '-canvas');
|
||||||
if (dcanvas == undefined) throw 'Failed to find: ' + 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 clhs = this.element.find('#' + this.id + '-lhs-margin');
|
||||||
var crhs = jQuery('#' + this.id + '-rhs-margin');
|
var crhs = this.element.find('#' + this.id + '-rhs-margin');
|
||||||
return {
|
return {
|
||||||
visible_page_height: visible_page_height,
|
visible_page_height: visible_page_height,
|
||||||
gutter_height: gutter_height,
|
gutter_height: gutter_height,
|
||||||
@@ -1402,7 +1402,7 @@ jQuery.extend(Mgly.CodeMirrorDiffView.prototype, {
|
|||||||
this.trace('draw', 'lhs-scroller-top', ex.lhs_scroller.scrollTop());
|
this.trace('draw', 'lhs-scroller-top', ex.lhs_scroller.scrollTop());
|
||||||
this.trace('draw', 'rhs-scroller-top', ex.rhs_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;
|
jQuery(this).get(0).height = ex.visible_page_height;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user