[MediaWiki-commits] [Gerrit] mediawiki...WikiEditor[master]: Save/restore selection in all browsers
jenkins-bot has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/400705 ) Change subject: Save/restore selection in all browsers .. Save/restore selection in all browsers Previously this wasn't required due to an iFrame mode. Change-Id: Ib89af27d5ab6b9b1b05046b32b05ce368ff47a5f --- M extension.json M modules/jquery.wikiEditor.js 2 files changed, 10 insertions(+), 13 deletions(-) Approvals: Catrope: Looks good to me, approved jenkins-bot: Verified diff --git a/extension.json b/extension.json index 2c7747b..865feb0 100644 --- a/extension.json +++ b/extension.json @@ -272,7 +272,6 @@ ], "dependencies": [ "jquery.async", - "jquery.client", "jquery.cookie", "jquery.suggestions", "jquery.tabIndex", diff --git a/modules/jquery.wikiEditor.js b/modules/jquery.wikiEditor.js index dd50e05..5b098d8 100644 --- a/modules/jquery.wikiEditor.js +++ b/modules/jquery.wikiEditor.js @@ -191,11 +191,8 @@ * @return {jQuery} */ $.fn.wikiEditor = function () { - var context, profile, hasFocus, cursorPos, + var context, hasFocus, cursorPos, args, modules, module, e, call; - - // Save browser profile for detailed tests. - profile = $.client.profile(); /* Initialization */ @@ -404,22 +401,23 @@ }, /** -* Save text selection for old IE (<=10) +* Save text selection */ saveSelection: function () { - if ( profile.name === 'msie' && document.selection && document.selection.createRange ) { - context.$textarea.focus(); - context.savedSelection = document.selection.createRange(); - } + context.$textarea.focus(); + context.savedSelection = { + selectionStart: context.$textarea[ 0 ].selectionStart, + selectionEnd: context.$textarea[ 0 ].selectionEnd + }; }, /** -* Restore text selection for old IE (<=10) +* Restore text selection */ restoreSelection: function () { - if ( profile.name === 'msie' && context.savedSelection !== null ) { + if ( context.savedSelection ) { context.$textarea.focus(); - context.savedSelection.select(); + context.$textarea[ 0 ].setSelectionRange( context.savedSelection.selectionStart, context.savedSelection.selectionEnd ); context.savedSelection = null; } } -- To view, visit https://gerrit.wikimedia.org/r/400705 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: Ib89af27d5ab6b9b1b05046b32b05ce368ff47a5f Gerrit-PatchSet: 4 Gerrit-Project: mediawiki/extensions/WikiEditor Gerrit-Branch: master Gerrit-Owner: EsandersGerrit-Reviewer: Catrope Gerrit-Reviewer: TheDJ Gerrit-Reviewer: jenkins-bot <> ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] mediawiki...WikiEditor[master]: Save/restore selection in all browsers
Esanders has uploaded a new change for review. ( https://gerrit.wikimedia.org/r/400705 ) Change subject: Save/restore selection in all browsers .. Save/restore selection in all browsers Previously this wasn't required due to an iFrame mode. Change-Id: Ib89af27d5ab6b9b1b05046b32b05ce368ff47a5f --- M extension.json M modules/jquery.wikiEditor.js 2 files changed, 10 insertions(+), 12 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/WikiEditor refs/changes/05/400705/1 diff --git a/extension.json b/extension.json index 2c7747b..865feb0 100644 --- a/extension.json +++ b/extension.json @@ -272,7 +272,6 @@ ], "dependencies": [ "jquery.async", - "jquery.client", "jquery.cookie", "jquery.suggestions", "jquery.tabIndex", diff --git a/modules/jquery.wikiEditor.js b/modules/jquery.wikiEditor.js index dd50e05..be6c905 100644 --- a/modules/jquery.wikiEditor.js +++ b/modules/jquery.wikiEditor.js @@ -191,11 +191,9 @@ * @return {jQuery} */ $.fn.wikiEditor = function () { - var context, profile, hasFocus, cursorPos, + var context, hasFocus, cursorPos, args, modules, module, e, call; - // Save browser profile for detailed tests. - profile = $.client.profile(); /* Initialization */ @@ -404,22 +402,23 @@ }, /** -* Save text selection for old IE (<=10) +* Save text selection */ saveSelection: function () { - if ( profile.name === 'msie' && document.selection && document.selection.createRange ) { - context.$textarea.focus(); - context.savedSelection = document.selection.createRange(); - } + context.$textarea.focus(); + context.savedSelection = { + selectionStart: context.$textarea[ 0 ].selectionStart, + selectionEnd: context.$textarea[ 0 ].selectionEnd + }; }, /** -* Restore text selection for old IE (<=10) +* Restore text selection */ restoreSelection: function () { - if ( profile.name === 'msie' && context.savedSelection !== null ) { + if ( context.savedSelection ) { context.$textarea.focus(); - context.savedSelection.select(); + context.$textarea[ 0 ].setSelectionRange( context.savedSelection.selectionStart, context.savedSelection.selectionEnd ); context.savedSelection = null; } } -- To view, visit https://gerrit.wikimedia.org/r/400705 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Ib89af27d5ab6b9b1b05046b32b05ce368ff47a5f Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/WikiEditor Gerrit-Branch: master Gerrit-Owner: Esanders___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits