From 20e6e6300249a63324d5b36da75c869f7f024ec9 Mon Sep 17 00:00:00 2001 From: martec Date: Sat, 30 Aug 2014 22:00:04 +0900 Subject: [PATCH] code improve --- inc/plugins/quickadveditor.php | 60 ++++++++++++++++------------------ 1 file changed, 28 insertions(+), 32 deletions(-) diff --git a/inc/plugins/quickadveditor.php b/inc/plugins/quickadveditor.php index af37d65..c2f5394 100644 --- a/inc/plugins/quickadveditor.php +++ b/inc/plugins/quickadveditor.php @@ -14,7 +14,7 @@ function quickadveditor_info () "website" => "", "author" => "martec", "authorsite" => "", - "version" => "3.3.2", + "version" => "4.0.0", "guid" => "", "compatibility" => "17*,18*" ); @@ -136,46 +136,42 @@ function quickadveditor_activate() }); } -(\$.fn.on || \$.fn.live).call(\$(document), \'focus\', \'#message\', function () { +function call_editor() { if (typeof sceditor == \'undefined\') { - \$(this).sceditor(opt_editor); + \$(\'#message\').sceditor(opt_editor); if(\$(\'#clickable_smilies\').length) { \$(\'#clickable_smilies\').closest(\'div\').show(); } - MyBBEditor = \$(this).sceditor(\'instance\'); - setTimeout(function() { - if (MyBBEditor) { - MyBBEditor.focus(); - } - offset = \$(\'#message\').next().offset().top - 60; - setTimeout(function() { - \$(\'html, body\').animate({ - scrollTop: offset - }, 700); - },200); - },100); + MyBBEditor = \$(\'#message\').sceditor(\'instance\'); {\$sourcemode} } +} + +function focus_editor() { + setTimeout(function() { + if (MyBBEditor) { + MyBBEditor.focus(); + } + offset = \$(\'#message\').next().offset().top - 60; + setTimeout(function() { + \$(\'html, body\').animate({ + scrollTop: offset + }, 700); + },200); + },100); +} + +(\$.fn.on || \$.fn.live).call(\$(document), \'focus\', \'#message\', function () { + call_editor(); + focus_editor(); }); (\$.fn.on || \$.fn.live).call(\$(document), \'click\', \'a[id*=\"multiquote_link_\"]\', function () { - if (typeof sceditor == \'undefined\') { - \$(\'#message\').sceditor(opt_editor); - if(\$(\'#clickable_smilies\').length) { - \$(\'#clickable_smilies\').closest(\'div\').show(); - } - MyBBEditor = \$(\'#message\').sceditor(\'instance\'); - {\$sourcemode} - } + call_editor(); }); if(Cookie.get(\'multiquote\')) { - \$(\'#message\').sceditor(opt_editor); - if(\$(\'#clickable_smilies\').length) { - \$(\'#clickable_smilies\').closest(\'div\').show(); - } - MyBBEditor = \$(\'#message\').sceditor(\'instance\'); - {\$sourcemode} + call_editor(); }; /********************************** @@ -218,7 +214,7 @@ function quickadveditor_activate() '#' . preg_quote('') . '#i', ' {$codebutquickedt}' - ); + ); } function quickadveditor_deactivate() @@ -245,7 +241,7 @@ function quickadveditor_deactivate() '#' . preg_quote(' {$codebutquickedt}') . '#i', '' - ); + ); } function mycode_inserter_quick($smilies = true) @@ -488,7 +484,7 @@ function codebuttonsquick () { } if($mybb->settings['quickreply'] == 0) { $codebutquickedt = mycode_inserter_quick(); - } + } } ?> \ No newline at end of file