From 8d4f0b874128db504706277ba998d15b3ffc7c1c Mon Sep 17 00:00:00 2001 From: Laurent CORROCHANO Date: Wed, 12 Mar 2014 12:40:23 +0100 Subject: [PATCH 1/3] Update plugin.js Like classic library, we look if the bottom of the window is not too close. If it is, we set the position above. --- .../plugins/jqueryspellchecker/plugin.js | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/examples/english/ckeditor/plugins/jqueryspellchecker/plugin.js b/src/examples/english/ckeditor/plugins/jqueryspellchecker/plugin.js index f2afe7d..befa099 100644 --- a/src/examples/english/ckeditor/plugins/jqueryspellchecker/plugin.js +++ b/src/examples/english/ckeditor/plugins/jqueryspellchecker/plugin.js @@ -106,10 +106,18 @@ CKEDITOR.plugins.add('jqueryspellchecker', { var t = this; + var win = $(window); + return function() { var ed = t.editor; var word = (this.wordElement.data('firstElement') || this.wordElement)[0]; + var element = this.wordElement.data('firstElement') || this.wordElement; + var offset = element.offset(); + var boxOffset = this.config.suggestBox.offset; + var containerHeight = this.container.outerHeight(); + var positionAbove = (offset.top - containerHeight - boxOffset); + var positionBelow = (offset.top + element.outerHeight() + boxOffset); var p1 = $(ed.container.$).find('iframe').offset(); var p2 = $(ed.container.$).offset(); @@ -119,11 +127,15 @@ CKEDITOR.plugins.add('jqueryspellchecker', { var top = p3.top + p2.top + (p1.top - p2.top) + word.offsetHeight; top -= $(t.editorWindow).scrollTop(); - + + if (win.height() + win.scrollTop() < positionBelow + containerHeight) { + top = positionAbove; + } + this.container.css({ top: top, left: left }); }; } -}); \ No newline at end of file +}); From 0c2daa5222b6b665b90650244fdf45d9641614e6 Mon Sep 17 00:00:00 2001 From: Laurent CORROCHANO Date: Thu, 13 Mar 2014 11:32:08 +0100 Subject: [PATCH 2/3] Update plugin.js Some modifications, still some problems of offset on position above. --- .../plugins/jqueryspellchecker/plugin.js | 39 +++++++++---------- 1 file changed, 19 insertions(+), 20 deletions(-) diff --git a/src/examples/english/ckeditor/plugins/jqueryspellchecker/plugin.js b/src/examples/english/ckeditor/plugins/jqueryspellchecker/plugin.js index befa099..397ec04 100644 --- a/src/examples/english/ckeditor/plugins/jqueryspellchecker/plugin.js +++ b/src/examples/english/ckeditor/plugins/jqueryspellchecker/plugin.js @@ -110,27 +110,26 @@ CKEDITOR.plugins.add('jqueryspellchecker', { return function() { - var ed = t.editor; - var word = (this.wordElement.data('firstElement') || this.wordElement)[0]; - var element = this.wordElement.data('firstElement') || this.wordElement; - var offset = element.offset(); - var boxOffset = this.config.suggestBox.offset; - var containerHeight = this.container.outerHeight(); - var positionAbove = (offset.top - containerHeight - boxOffset); - var positionBelow = (offset.top + element.outerHeight() + boxOffset); - - var p1 = $(ed.container.$).find('iframe').offset(); - var p2 = $(ed.container.$).offset(); - var p3 = $(word).offset(); - - var left = p3.left + p2.left; - var top = p3.top + p2.top + (p1.top - p2.top) + word.offsetHeight; - - top -= $(t.editorWindow).scrollTop(); + var ed = t.editor; + var word = (this.wordElement.data('firstElement') || this.wordElement)[0]; + var element = this.wordElement.data('firstElement') || this.wordElement; + var offset = element.offset(); + var boxOffset = this.config.suggestBox.offset; + var containerHeight = this.container.outerHeight(); + + var p1 = $(ed.container.$).find('iframe').offset(); + var p2 = $(ed.container.$).offset(); + var p3 = $(word).offset(); + + var left = p3.left + p2.left; + var top = p3.top + p2.top + (p1.top - p2.top) + word.offsetHeight; + var positionAbove =( p3.top + p2.top - word.offsetHeight ) - containerHeight; + + top -= $(t.editorWindow).scrollTop(); - if (win.height() + win.scrollTop() < positionBelow + containerHeight) { - top = positionAbove; - } + if (win.height() + win.scrollTop() < top + containerHeight) { + top = positionAbove; + } this.container.css({ top: top, From 4f288bc4fa6c4a69e75e477281e6eed32b4cc389 Mon Sep 17 00:00:00 2001 From: Laurent CORROCHANO Date: Mon, 17 Mar 2014 15:22:23 +0100 Subject: [PATCH 3/3] Update plugin.js Seems to work fine now, but didn't test deeply --- .../english/ckeditor/plugins/jqueryspellchecker/plugin.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/examples/english/ckeditor/plugins/jqueryspellchecker/plugin.js b/src/examples/english/ckeditor/plugins/jqueryspellchecker/plugin.js index 397ec04..d952806 100644 --- a/src/examples/english/ckeditor/plugins/jqueryspellchecker/plugin.js +++ b/src/examples/english/ckeditor/plugins/jqueryspellchecker/plugin.js @@ -110,7 +110,7 @@ CKEDITOR.plugins.add('jqueryspellchecker', { return function() { - var ed = t.editor; + var ed = t.editor; var word = (this.wordElement.data('firstElement') || this.wordElement)[0]; var element = this.wordElement.data('firstElement') || this.wordElement; var offset = element.offset(); @@ -123,7 +123,7 @@ CKEDITOR.plugins.add('jqueryspellchecker', { var left = p3.left + p2.left; var top = p3.top + p2.top + (p1.top - p2.top) + word.offsetHeight; - var positionAbove =( p3.top + p2.top - word.offsetHeight ) - containerHeight; + var positionAbove = p1.top + ( p3.top - $(ed.container.$).find('iframe').contents().find("html,body").scrollTop() ) - containerHeight; top -= $(t.editorWindow).scrollTop();