From 7abfe41ab792e93b94e186f9ece4a5fd3b58a3e4 Mon Sep 17 00:00:00 2001
From: Aleksander Machniak <alec@alec.pl>
Date: Sun, 24 Apr 2016 05:12:38 -0400
Subject: [PATCH] Fix bug where getting HTML editor content could steal focus from other form controls (#5223)

---
 program/js/googiespell.js |   44 +++++++++++++++++++++++---------------------
 1 files changed, 23 insertions(+), 21 deletions(-)

diff --git a/program/js/googiespell.js b/program/js/googiespell.js
index 707efd1..bf0eede 100644
--- a/program/js/googiespell.js
+++ b/program/js/googiespell.js
@@ -106,11 +106,11 @@
     this.cnt_errors_fixed = 0;
 
     // Set document's onclick to hide the language and error menu
-    $(document).bind('click', function(e) {
+    $(document).click(function(e) {
         var target = $(e.target);
-        if(target.attr('googie_action_btn') != '1' && ref.isLangWindowShown())
+        if (target.attr('googie_action_btn') != '1' && ref.isLangWindowShown())
             ref.hideLangWindow();
-        if(target.attr('googie_action_btn') != '1' && ref.isErrorWindowShown())
+        if (target.attr('googie_action_btn') != '1' && ref.isErrorWindowShown())
             ref.hideErrorWindow();
     });
 
@@ -312,7 +312,9 @@
     this.ignore = ignore;
     this.hideLangWindow();
 
-    if ($(this.text_area).val() == '' || ignore) {
+    var area = $(this.text_area);
+
+    if (area.val() == '' || ignore) {
         if (!this.custom_no_spelling_error)
             this.flashNoSpellingErrorState();
         else
@@ -321,7 +323,7 @@
         return;
     }
 
-    this.createEditLayer(this.text_area.offsetWidth, this.text_area.offsetHeight);
+    this.createEditLayer(area.width(), area.height());
     this.createErrorWindow();
     $('body').append(this.error_window);
 
@@ -329,9 +331,9 @@
     catch (e) { }
 
     if (this.main_controller)
-        $(this.spell_span).unbind('click');
+        $(this.spell_span).off('click');
 
-    this.orginal_text = $(this.text_area).val();
+    this.orginal_text = area.val();
 };
 
 this.parseResult = function(r_text)
@@ -463,7 +465,7 @@
 this.ignoreError = function(elm, id)
 {
     // @TODO: ignore all same words
-    $(elm).removeAttr('class').css('color', '').unbind();
+    $(elm).removeAttr('class').css('color', '').off();
     this.hideErrorWindow();
 };
 
@@ -674,10 +676,10 @@
 {
     this.edit_layer = document.createElement('div');
     $(this.edit_layer).addClass('googie_edit_layer').attr('id', 'googie_edit_layer')
-        .width('auto').height(height);
+        .width(width).height(height);
 
     if (this.text_area.nodeName.toLowerCase() != 'input' || $(this.text_area).val() == '') {
-        $(this.edit_layer).css('overflow', 'auto').height(height-4);
+        $(this.edit_layer).css('overflow', 'auto');
     } else {
         $(this.edit_layer).css('overflow', 'hidden');
     }
@@ -841,7 +843,7 @@
         this.lang_elms.push(item);
 
         $(item).attr('googieId', this.langlist_codes[i])
-            .bind('click', function(e) {
+            .click(function(e) {
                 ref.deHighlightCurSel();
                 ref.setCurrentLanguage($(this).attr('googieId'));
 
@@ -852,11 +854,11 @@
                 ref.highlightCurSel();
                 ref.hideLangWindow();
             })
-            .bind('mouseover', function(e) {
+            .mouseover(function(e) {
                 if (this.className != "googie_list_selected")
                     this.className = "googie_list_onhover";
             })
-            .bind('mouseout', function(e) {
+            .mouseout(function(e) {
                 if (this.className != "googie_list_selected")
                     this.className = "googie_list_onout";
             });
@@ -939,7 +941,7 @@
 
     $(switch_lan).addClass('googie_lang_3d_on')
         .append(img)
-        .bind('click', function(e) {
+        .click(function(e) {
             var elm = this.tagName.toLowerCase() == 'img' ? this.parentNode : this;
             if($(elm).hasClass('googie_lang_3d_click')) {
                 elm.className = 'googie_lang_3d_on';
@@ -1007,8 +1009,8 @@
     var ref = this;
 
         $(this.switch_lan_pic).hide();
-        $(this.spell_span).empty().unbind().append(rsm)
-            .bind('click', function() { ref.resumeEditing() })
+        $(this.spell_span).empty().off().append(rsm)
+            .click(function() { ref.resumeEditing(); })
             .removeClass().addClass('googie_resume_editing');
     }
 
@@ -1030,9 +1032,9 @@
         ref = this;
 
     if (this.custom_spellcheck_starter)
-        $(span_chck).bind('click', function(e) { ref.custom_spellcheck_starter() });
+        $(span_chck).click(function(e) { ref.custom_spellcheck_starter(); });
     else {
-        $(span_chck).bind('click', function(e) { ref.spellCheck() });
+        $(span_chck).click(function(e) { ref.spellCheck(); });
     }
 
     if (this.main_controller) {
@@ -1088,9 +1090,9 @@
         spn_btn = document.createTextNode(name);
     }
 
-    $(btn).bind('click', c_fn)
-        .bind('mouseover', this.item_onmouseover)
-        .bind('mouseout', this.item_onmouseout);
+    $(btn).click(c_fn)
+        .mouseover(this.item_onmouseover)
+        .mouseout(this.item_onmouseout);
 
     btn.appendChild(spn_btn);
     btn_row.appendChild(btn);

--
Gitblit v1.9.1