Skip to content

Commit

Permalink
EZP-28078: Embedding a Content Object in the RichText Editor makes pa…
Browse files Browse the repository at this point in the history
…ge scroll up (ezsystems#920)

* Fix EZP-28078: Embedding a Content Object in the RichText Editor makes page scroll up

* fixup! Fix EZP-28078: Embedding a Content Object in the RichText Editor makes page scroll up

* fixup! Fix EZP-28078: Embedding a Content Object in the RichText Editor makes page scroll up

* fixup! Fix EZP-28078: Embedding a Content Object in the RichText Editor makes page scroll up
  • Loading branch information
adamwojs authored and andrerom committed Nov 17, 2017
1 parent 4bd466f commit 6d835b6
Show file tree
Hide file tree
Showing 6 changed files with 66 additions and 12 deletions.
13 changes: 11 additions & 2 deletions Resources/public/js/alloyeditor/buttons/embed.js
Expand Up @@ -75,9 +75,18 @@ YUI.add('ez-alloyeditor-button-embed', function (Y) {
*/
_addEmbed: function (e) {
var contentInfo = e.selection.contentInfo,
widget;
widget,
scrollY;

if (navigator.userAgent.indexOf('Chrome') > -1) {
// Workaround for https://jira.ez.no/browse/EZP-28078
scrollY = window.pageYOffset;
this.execCommand();
window.scroll(window.pageXOffset, scrollY);
} else {
this.execCommand();
}

this.execCommand();
this._setContentInfo(contentInfo);
widget = this._getWidget().setWidgetContent('');
this._fireUpdatedEmbed(e.selection);
Expand Down
13 changes: 11 additions & 2 deletions Resources/public/js/alloyeditor/buttons/embed.jsx
Expand Up @@ -70,9 +70,18 @@ YUI.add('ez-alloyeditor-button-embed', function (Y) {
*/
_addEmbed: function (e) {
var contentInfo = e.selection.contentInfo,
widget;
widget,
scrollY;

if (navigator.userAgent.indexOf('Chrome') > -1) {
// Workaround for https://jira.ez.no/browse/EZP-28078
scrollY = window.pageYOffset;
this.execCommand();
window.scroll(window.pageXOffset, scrollY);
} else {
this.execCommand();
}

this.execCommand();
this._setContentInfo(contentInfo);
widget = this._getWidget().setWidgetContent('');
this._fireUpdatedEmbed(e.selection);
Expand Down
13 changes: 11 additions & 2 deletions Resources/public/js/alloyeditor/buttons/image.js
Expand Up @@ -78,9 +78,18 @@ YUI.add('ez-alloyeditor-button-image', function (Y) {
* @protected
*/
_addImage: function (e) {
var widget;
var widget,
scrollY;

if (navigator.userAgent.indexOf('Chrome') > -1) {
// Workaround for https://jira.ez.no/browse/EZP-28078
scrollY = window.pageYOffset;
this.execCommand();
window.scroll(window.pageXOffset, scrollY);
} else {
this.execCommand();
}

this.execCommand();
this._setContentInfo(e.selection.contentInfo);

widget = this._getWidget()
Expand Down
13 changes: 11 additions & 2 deletions Resources/public/js/alloyeditor/buttons/image.jsx
Expand Up @@ -73,9 +73,18 @@ YUI.add('ez-alloyeditor-button-image', function (Y) {
* @protected
*/
_addImage: function (e) {
var widget;
var widget,
scrollY;

if (navigator.userAgent.indexOf('Chrome') > -1) {
// Workaround for https://jira.ez.no/browse/EZP-28078
scrollY = window.pageYOffset;
this.execCommand();
window.scroll(window.pageXOffset, scrollY);
} else {
this.execCommand();
}

this.execCommand();
this._setContentInfo(e.selection.contentInfo);

widget = this._getWidget()
Expand Down
13 changes: 11 additions & 2 deletions Resources/public/js/alloyeditor/buttons/linkedit.js
Expand Up @@ -126,9 +126,18 @@ YUI.add('ez-alloyeditor-button-linkedit', function (Y) {
* @protected
*/
_focusEditedLink: function () {
var editor = this.props.editor.get('nativeEditor');
var editor = this.props.editor.get('nativeEditor'),
scrollY;

if (navigator.userAgent.indexOf('Chrome') > -1) {
// Workaround for https://jira.ez.no/browse/EZP-28078
scrollY = window.pageYOffset;
editor.focus();
window.scroll(window.pageXOffset, scrollY);
} else {
editor.focus();
}

editor.focus();
editor.eZ.moveCaretToElement(editor, this.state.element);
editor.fire('actionPerformed', this);
},
Expand Down
13 changes: 11 additions & 2 deletions Resources/public/js/alloyeditor/buttons/linkedit.jsx
Expand Up @@ -121,9 +121,18 @@ YUI.add('ez-alloyeditor-button-linkedit', function (Y) {
* @protected
*/
_focusEditedLink: function () {
var editor = this.props.editor.get('nativeEditor');
var editor = this.props.editor.get('nativeEditor'),
scrollY;

if (navigator.userAgent.indexOf('Chrome') > -1) {
// Workaround for https://jira.ez.no/browse/EZP-28078
scrollY = window.pageYOffset;
editor.focus();
window.scroll(window.pageXOffset, scrollY);
} else {
editor.focus();
}

editor.focus();
editor.eZ.moveCaretToElement(editor, this.state.element);
editor.fire('actionPerformed', this);
},
Expand Down

0 comments on commit 6d835b6

Please sign in to comment.