diff --git a/README.md b/README.md index 3e57c5e..052fce7 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -## MentionMe 3.2.5 +## MentionMe 3.2.6 A plugin for MyBB 1.8.x that allows Twitter-style tagging and integration with [MyAlerts](https://github.com/euantorano/MyAlerts) @@ -6,9 +6,12 @@ While this plugin works with MyAlerts, it is not necessary for the tagging featu MyBB Release Thread: http://community.mybb.com/thread-131448.html +Twitter Addons: https://github.com/Advanced-Sidebox/Twitter-Addons + #Features * mention auto-completion while typing`*` * supports standard textarea, SCEditor (default WYSIWYG), CKEditor (Rin Editor, etc.), MHEditor (doylecc) +* DVZ Shoutbox support * full text search`*` * displays avatars in autocomplete popup`*` * uses a prioritizes users from the current thread, when applicable`*` diff --git a/Upload/inc/languages/english/admin/mention.lang.php b/Upload/inc/languages/english/admin/mention.lang.php index 07b1e9b..ce126d3 100644 --- a/Upload/inc/languages/english/admin/mention.lang.php +++ b/Upload/inc/languages/english/admin/mention.lang.php @@ -29,6 +29,9 @@ $l['mention_max_items_title'] = 'Maximum Items In Popup'; $l['mention_max_items_description'] = 'If autocomplete is used, this setting will limit the size of the popup'; +$l['mention_min_width_title'] = 'Minimum Width'; +$l['mention_min_width_description'] = 'If autocomplete is used, this setting will provide a minimum width for the popup, in pixels'; + $l['mention_cache_time_title'] = 'Cache Cut-off Time'; $l['mention_cache_time_description'] = 'The task caches usernames based on when they were last active. In days, specify how far back to go. (Large forums should stick with low numbers to reduce the size of the namecache)'; diff --git a/Upload/inc/plugins/MentionMe/alerts.php b/Upload/inc/plugins/MentionMe/alerts.php index 9157930..14e7a80 100644 --- a/Upload/inc/plugins/MentionMe/alerts.php +++ b/Upload/inc/plugins/MentionMe/alerts.php @@ -89,7 +89,7 @@ function mentionMeMyAlertsDatahandlerPostUpdate($thisPost) */ if ($mentionedAlready[$uid] || $editUID == $uid || - !mentionMeCheckPermissions($username, $uid, $editUID, $fid)) { + !mentionMeCheckPermissions($username, $uid, $editUID, $fid, $tid)) { continue; } $mentionedAlready[$uid] = true; @@ -196,7 +196,7 @@ function mentionMeMyAlertsDoNewReplyEnd() */ if ($mentionedAlready[$uid] || $fromUser == $uid || - !mentionMeCheckPermissions($username, $uid, $fromUser, $fid)) { + !mentionMeCheckPermissions($username, $uid, $fromUser, $fid, $tid)) { continue; } @@ -300,10 +300,10 @@ function mentionMeStripQuotes($message) * @param int id of the forum in which the mention occurred * @return bool true to allow, false to deny */ -function mentionMeCheckPermissions($username, $uid, $fromUID, $fid) +function mentionMeCheckPermissions($username, $uid, $fromUID, $fid, $tid) { global $cache; - static $nameCache, $myCache; + static $nameCache, $myCache, $db; // cache names to reduce queries if ($myCache instanceof MentionMeCache == false) { @@ -353,6 +353,10 @@ function mentionMeCheckPermissions($username, $uid, $fromUID, $fid) return true; } + // check if this is the user's thread + $query = $db->simple_select('thread', 'uid', "tid='{$tid}'"); + $isOp = $uid > 0 && (int) $db->fetch_field($query, 'uid') == $uid; + // check for permissions in all the user's groups foreach ($userGroups as $gid) { // empty 'displaygroup' and 'additionalgroups' are 0 or blank, skip them @@ -360,6 +364,14 @@ function mentionMeCheckPermissions($username, $uid, $fromUID, $fid) continue; } + // if the user can only view their own threads and this thread isn't one of them... + if (isset($forum_permissions[$fid][$gid]) && + $forum_permissions[$fid][$gid]['canonlyviewownthreads'] && + !$isOp) { + // sorry charlie + return false; + } + // the first 'yes' we hear gets us out of the loop with a valid return if (!isset($forum_permissions[$fid][$gid]) || $forum_permissions[$fid][$gid] == 0 || diff --git a/Upload/inc/plugins/MentionMe/classes/MentionMeInstaller.php b/Upload/inc/plugins/MentionMe/classes/MentionMeInstaller.php index 24350d5..7b6c732 100644 --- a/Upload/inc/plugins/MentionMe/classes/MentionMeInstaller.php +++ b/Upload/inc/plugins/MentionMe/classes/MentionMeInstaller.php @@ -4,7 +4,7 @@ * plugin specific extension */ -class MentionMeInstaller extends WildcardPluginInstaller010202 +class MentionMeInstaller extends WildcardPluginInstaller010203 { static public function getInstance() { diff --git a/Upload/inc/plugins/MentionMe/classes/WildcardPluginInstaller010202.php b/Upload/inc/plugins/MentionMe/classes/WildcardPluginInstaller010203.php similarity index 94% rename from Upload/inc/plugins/MentionMe/classes/WildcardPluginInstaller010202.php rename to Upload/inc/plugins/MentionMe/classes/WildcardPluginInstaller010203.php index aa19992..6f73a05 100644 --- a/Upload/inc/plugins/MentionMe/classes/WildcardPluginInstaller010202.php +++ b/Upload/inc/plugins/MentionMe/classes/WildcardPluginInstaller010203.php @@ -9,12 +9,12 @@ * */ -class WildcardPluginInstaller010202 implements WildcardPluginInstallerInterface010000 +class WildcardPluginInstaller010203 implements WildcardPluginInstallerInterface010000 { /** * @const version */ - const VERSION = '1.2.2'; + const VERSION = '1.2.3'; /** * @var object a copy of the MyBB db object @@ -551,7 +551,7 @@ protected function addStyleSheets() // now cache the actual files require_once MYBB_ROOT . "{$config['admin_dir']}/inc/functions_themes.php"; - if(!cache_stylesheet(1, $data['cachefile'], $data['stylesheet'])) + if(!cache_stylesheet(1, $styleSheet['cachefile'], $data['stylesheet'])) { $this->db->update_query("themestylesheets", array('cachefile' => "css.php?stylesheet={$sid}"), "sid='{$sid}'", 1); } @@ -663,7 +663,7 @@ protected function addImages() !mkdir("{$path}/images", 0777, true)) || ($mainFolder && !is_dir("{$path}/images{$mainFolder}") && - !mkdir("{$path}/images{$mainFolder}", 0777, true))) { + !$this->createContentFolder("{$path}/images{$mainFolder}"))) { continue; } @@ -693,7 +693,7 @@ protected function addImages() if (!is_dir($path) || ($mainFolder && !is_dir("{$path}{$mainFolder}") && - !mkdir("{$path}{$mainFolder}", 0777, true))) { + !$this->createContentFolder("{$path}{$mainFolder}"))) { continue; } @@ -867,6 +867,52 @@ private function buildThemeList($acp = false) return $folderList; } + + /** + * verify that path exists or can be created + * + * @param folder path + * @return bool + */ + private function createContentFolder($path) + { + if (mkdir($path, 0777, true)) { + file_put_contents($path . '/index.html', << + + + + + forbidden + + + +
you don't have permission to access this resource
+ + +EOF +); + + return true; + } + + return false; + } } ?> diff --git a/Upload/inc/plugins/MentionMe/forum.php b/Upload/inc/plugins/MentionMe/forum.php index 29a0f46..796b858 100644 --- a/Upload/inc/plugins/MentionMe/forum.php +++ b/Upload/inc/plugins/MentionMe/forum.php @@ -529,6 +529,8 @@ function mentionMeBuildPopup() { $min = '.min'; } + $mybb->settings['mention_min_width'] = (int) $mybb->settings['mention_min_width']; + $mentionAutocomplete = << @@ -541,6 +543,7 @@ function mentionMeBuildPopup() { }, maxLength: '{$mybb->settings['maxnamelength']}', maxItems: '{$mybb->settings['mention_max_items']}', + minWidth: '{$mybb->settings['mention_min_width']}', tid: '{$mybb->input['tid']}', fullText: '{$mybb->settings['mention_full_text_search']}', showAvatars: '{$mybb->settings['mention_show_avatars']}', diff --git a/Upload/inc/plugins/MentionMe/install.php b/Upload/inc/plugins/MentionMe/install.php index 82d0d06..2057c27 100644 --- a/Upload/inc/plugins/MentionMe/install.php +++ b/Upload/inc/plugins/MentionMe/install.php @@ -281,7 +281,7 @@ function mentionMeAddPeekers($peekers) return; } - $peekers[] = 'new Peeker($(".setting_mention_auto_complete"), $("#row_setting_mention_max_items, #row_setting_mention_get_thread_participants, #row_setting_mention_max_thread_participants, #row_setting_mention_full_text_search, #row_setting_mention_show_avatars, #row_setting_mention_lock_selection"), 1, true)'; + $peekers[] = 'new Peeker($(".setting_mention_auto_complete"), $("#row_setting_mention_max_items, #row_setting_mention_min_width, #row_setting_mention_get_thread_participants, #row_setting_mention_max_thread_participants, #row_setting_mention_full_text_search, #row_setting_mention_show_avatars, #row_setting_mention_lock_selection"), 1, true)'; $peekers[] = 'new Peeker($(".setting_mention_add_postbit_button"), $("#row_setting_mention_multiple"), 1, true)'; diff --git a/Upload/inc/plugins/MentionMe/install_data.php b/Upload/inc/plugins/MentionMe/install_data.php index 9da29f3..c52e8cc 100644 --- a/Upload/inc/plugins/MentionMe/install_data.php +++ b/Upload/inc/plugins/MentionMe/install_data.php @@ -35,6 +35,15 @@ 'value' => '5', 'disporder' => '20', ), + 'mention_min_width' => array( + 'sid' => '0', + 'name' => 'mention_min_width', + 'title' => $lang->mention_min_width_title, + 'description' => $lang->mention_min_width_description, + 'optionscode' => 'text', + 'value' => '120', + 'disporder' => '30', + ), 'mention_get_thread_participants' => array( 'sid' => '0', 'name' => 'mention_get_thread_participants', @@ -42,7 +51,7 @@ 'description' => $lang->mention_get_thread_participants_description, 'optionscode' => 'yesno', 'value' => '1', - 'disporder' => '30', + 'disporder' => '40', ), 'mention_max_thread_participants' => array( 'sid' => '0', @@ -51,7 +60,7 @@ 'description' => $lang->mention_max_thread_participants_description, 'optionscode' => 'text', 'value' => '5', - 'disporder' => '40', + 'disporder' => '50', ), 'mention_full_text_search' => array( 'sid' => '0', @@ -60,7 +69,7 @@ 'description' => $lang->mention_full_text_search_description, 'optionscode' => 'yesno', 'value' => '0', - 'disporder' => '50', + 'disporder' => '60', ), 'mention_show_avatars' => array( 'sid' => '0', @@ -69,7 +78,7 @@ 'description' => $lang->mention_show_avatars_description, 'optionscode' => 'yesno', 'value' => '1', - 'disporder' => '60', + 'disporder' => '70', ), 'mention_lock_selection' => array( 'sid' => '0', @@ -78,7 +87,7 @@ 'description' => $lang->mention_lock_selection_description, 'optionscode' => 'yesno', 'value' => '1', - 'disporder' => '70', + 'disporder' => '80', ), 'mention_add_postbit_button' => array( 'sid' => '0', @@ -87,7 +96,7 @@ 'description' => $lang->mention_add_postbit_button_description, 'optionscode' => 'yesno', 'value' => '0', - 'disporder' => '80', + 'disporder' => '90', ), 'mention_multiple' => array( 'sid' => '0', @@ -96,7 +105,7 @@ 'description' => $lang->mention_multiple_description, 'optionscode' => 'yesno', 'value' => '0', - 'disporder' => '90', + 'disporder' => '100', ), 'mention_format_names' => array( 'sid' => '0', @@ -105,7 +114,7 @@ 'description' => $lang->mention_format_names_desc, 'optionscode' => 'yesno', 'value' => '1', - 'disporder' => '100', + 'disporder' => '110', ), 'mention_display_symbol' => array( 'sid' => '0', @@ -114,7 +123,7 @@ 'description' => $lang->mention_display_symbol_desc, 'optionscode' => 'text', 'value' => '@', - 'disporder' => '110', + 'disporder' => '120', ), 'mention_open_link_in_new_window' => array( 'sid' => '0', @@ -123,7 +132,7 @@ 'description' => $lang->mention_open_link_in_new_window_desc, 'optionscode' => 'yesno', 'value' => '0', - 'disporder' => '120', + 'disporder' => '130', ), 'mention_cache_time' => array( 'sid' => '0', @@ -132,7 +141,7 @@ 'description' => $lang->mention_cache_time_description, 'optionscode' => 'text', 'value' => '7', - 'disporder' => '130', + 'disporder' => '140', ), 'mention_minify_js' => array( 'sid' => '0', @@ -141,7 +150,7 @@ 'description' => $lang->mention_minify_js_desc, 'optionscode' => 'yesno', 'value' => '1', - 'disporder' => '140', + 'disporder' => '150', ), ) ) diff --git a/Upload/inc/plugins/mention.php b/Upload/inc/plugins/mention.php index 349b835..d83f450 100644 --- a/Upload/inc/plugins/mention.php +++ b/Upload/inc/plugins/mention.php @@ -14,7 +14,7 @@ // checked by other plugin files define('IN_MENTIONME', true); -define('MENTIONME_VERSION', '3.2.5'); +define('MENTIONME_VERSION', '3.2.6'); // register custom class autoloader spl_autoload_register('mentionMeClassAutoLoad'); diff --git a/Upload/jscripts/MentionMe/autocomplete.js b/Upload/jscripts/MentionMe/autocomplete.js index ced7b2c..81f283f 100644 --- a/Upload/jscripts/MentionMe/autocomplete.js +++ b/Upload/jscripts/MentionMe/autocomplete.js @@ -12,6 +12,7 @@ var MentionMe = (function($, m) { var options = { minLength: 2, maxLength: 30, + minWidth: 120, maxItems: 5, tid: "", fullText: 0, @@ -193,6 +194,7 @@ var MentionMe = (function($, m) { } this.width += pi(this.$body.css("fontSize").replace("px", "") * longestName); + this.width = Math.max(options.minWidth, this.width); style = { height: this.getCurrentHeight() + this.inputHeight + "px", @@ -300,9 +302,9 @@ var MentionMe = (function($, m) { if (options.showAvatars) { avatarPath = data[user]["avatar"]; - if (typeof avatarPath == "undefined") { - avatarPath = options.defaultAvatar; - } else if (avatarPath.length == 0) { + if (typeof avatarPath == "undefined" || + avatarPath == null || + avatarPath.length == 0) { avatarPath = options.defaultAvatar; } @@ -1735,7 +1737,7 @@ var MentionMe = (function($, m) { delete opt.lang; $.extend(options, opt || {}); - $(["minLength", "maxLength", "maxItems", "fullText", "showAvatars", "lockSelection"]).each(function() { + $(["minLength", "maxLength", "minWidth", "maxItems", "fullText", "showAvatars", "lockSelection"]).each(function() { if (typeof options[this] !== "undefined") { options[this] = pi(options[this]); } @@ -1750,7 +1752,8 @@ var MentionMe = (function($, m) { * @return void */ function init() { - var id, key; + var id, key, + $shoutbox = $('.panel > form > input[class="text"]'); if (typeof CKEDITOR !== "undefined" && typeof CKEDITOR.instances !== "undefined") { @@ -1784,6 +1787,11 @@ var MentionMe = (function($, m) { new TextareaInterface(id); } + if ($shoutbox.length) { + $shoutbox.prop("id", "dvz_shoutbox_input"); + new TextareaInterface("dvz_shoutbox_input"); + } + // quick edit $(".quick_edit_button").click(doQuickEdit); $("#quick_reply_submit").click(doQuickReply); diff --git a/Upload/jscripts/MentionMe/autocomplete.min.js b/Upload/jscripts/MentionMe/autocomplete.min.js index d947e94..243996e 100644 --- a/Upload/jscripts/MentionMe/autocomplete.min.js +++ b/Upload/jscripts/MentionMe/autocomplete.min.js @@ -6,74 +6,180 @@ * this file contains a module for the auto-completion functionality */ -var MentionMe=function(b,r){ +var MentionMe=(function($,m){ "use strict"; -function m(c){var a=this.id.split("_").slice(-1)[0],d="quickedit_"+a,l;0!=b("#"+d).length&&("undefined"===typeof CKEDITOR?l=new t(d):setTimeout(function(){l=new u(d)},1100),setTimeout(function(){b("#quicksub_"+a).add(b("#quicksub_"+a).next("button")).click(function(){l.unbindKeyup()})},1100))}function w(c){b(".quick_edit_button").off("click",m);setTimeout(function(){b(".quick_edit_button").click(m)},500)}function n(b){b=b.getSelectedName();var a="";if(b)return-1==b.indexOf('"')? -a='"':-1==b.indexOf("'")?a="'":-1==b.indexOf("`")&&(a="`"),a+b+a+" "}function p(b){return-1===[e.LEFT,e.RIGHT,e.UP,e.DOWN,e.BACKSPACE,e.ESC,e.SHIFT,e.CTRL,e.ALT,e.ENTER,e.DELETE,e.INSERT,e.END,e.NUMLOCK].indexOf(b)}function x(b,a){return b.lengtha.length?1:0}var f={minLength:2,maxLength:30,maxItems:5,tid:"",fullText:0,showAvatars:1,imageDirectory:"images",lockSelection:1},v={instructions:"type a user name"},e={BACKSPACE:8,ENTER:13,SHIFT:16,CTRL:17,ALT:18,ESC:27,PAGE_UP:33,PAGE_DOWN:34, -END:35,HOME:36,LEFT:37,UP:38,RIGHT:39,DOWN:40,INSERT:45,DELETE:46,NUMLOCK:144},q=function(){function c(a){this.editorInterface=a;a=this.editorInterface.getContainer();this.$popup=b("#mentionme_master_popup").clone().attr("id","");this.$spinner=this.$popup.find("div.mentionme_spinner").hide();this.$input=this.$popup.find("input.mentionme_popup_input");this.$inputDiv=this.$popup.find("div.mentionme_popup_input_container");this.$body=this.$popup.find("div.mentionme_popup_body");if("string"===typeof a&& -b("#"+a).length)this.$container=b("#"+a);else if("object"===typeof a&&b(a).length)this.$container=b(a);else return!1;this.$container.append(this.$popup);this.$popup.css({left:"-1000px",top:"-1000px"}).show();this.inputHeight=this.$inputDiv.height();a=b("
");f.showAvatars&&b("",{"class":"mention_user_avatar",src:f.defaultAvatar}).appendTo(a);a.append(Array(f.maxLength+1).join("M")).addClass("mentionme_popup_item");this.$body.html(a);this.lineHeight=parseInt(a.height(),10)+this.editorInterface.lineHeightModifier+ -parseInt(a.css("paddingTop").replace("px",""),10)+parseInt(a.css("paddingBottom").replace("px",""),10);this.$instructions=b("",{"class":"mentionme_popup_instructions"}).html(v.instructions);this.scrollWidthDiff=this.$body.width()-this.$body[0].scrollWidth;this.keyCache=new y(this);this.nameCache=new z(this)}b.extend(c.prototype,{show:function(a,d){this.keyCache.clear();this.update();this.move(a,d);this.$popup.show();this.lastSelected=null;this.select();this.visible=!0;this.$body.mouseover(b.proxy(this.onMouseMove, -this));this.$body.click(b.proxy(this.onClick,this));b(document).click(b.proxy(this.hide,this));this.editorInterface.bindClick(b.proxy(this.hide,this));this.$input.keydown(b.proxy(this.onKeyDown,this));this.$input.keyup(b.proxy(this.updateCheck,this));this.$input.click(b.proxy(this.onInputClick,this));this.$input.focus()},hide:function(){this.$popup.hide();this.$body.off("mouseover",this.onMouseMove);this.$body.off("click",this.onClick);b(document).off("click",this.hide);this.editorInterface.unbindClick(this.hide); -this.$input.off("keydown",this.onKeyDown);this.$input.off("keyup",this.updateCheck);this.$input.off("click",this.onInputClick);this.visible=!1;this.$input.val("")},move:function(a,d){var l=this.nameCache.getLongestName();this.width=0;if(f.showAvatars){var c=b("",{"class":"mention_user_avatar",src:f.defaultAvatar}).css({left:"-1000px",top:"-1000px"}).appendTo(this.$container);this.width+=c.width();c.remove()}this.width+=parseInt(this.$body.css("fontSize").replace("px","")*l,10);l={height:this.getCurrentHeight()+ -this.inputHeight+"px",width:parseInt(this.width-this.scrollWidthDiff,10)+"px"};"undefined"!=typeof a&&(l.left=a+"px");"undefined"!=typeof d&&(l.top=d+"px");this.$popup.css(l);this.$body.css({height:this.getCurrentHeight()+"px",width:this.width})},update:function(){this.nameCache.isReady()?(this.nameCache.match(),this.buildItems(),this.lastSelected=null,this.select(),this.keyCache.getLength()>=f.minLength&&this.nameCache.search()):this.showSpinner()},buildItems:function(){var a,d=this.nameCache.getItemsLength(), -c=this.nameCache.getData(),B=-1!==navigator.userAgent.toLowerCase().indexOf("msie")?"hand":"pointer";this.items=this.nameCache.getItems();if(0===d&&0==this.spinnerVisible)0",{"class":"mentionme_typed_text"}).html(this.keyCache.getText()))):this.showInstructions();else for(this.clear(),a=0;a'+k.slice(g,g+this.keyCache.getLength())+""+k.slice(g+this.keyCache.getLength())}g="";f.showAvatars&&(e=c[e].avatar,0==e.length&&(e=f.defaultAvatar),g=b("",{"class":"mention_user_avatar",src:e}).one("error",function(){this.src=f.defaultAvatar}));this.$body.append(b("
",{"class":"mentionme_popup_item mentionme_popup_item_"+a}).append(g).append(k).css({cursor:B}))}this.isVisible()&&this.move()},clear:function(){this.$body.html(""); -this.lastSelected=null;this.spinnerVisible=!1;this.isVisible()&&this.move()},showSpinner:function(){this.clear();this.$body.html(this.$spinner);this.spinnerVisible=!0;this.isVisible()&&this.move()},showInstructions:function(){this.clear();this.$body.html(this.$instructions)},updateCheck:function(){this.keyCache.update()&&this.update()},select:function(a){var d=this.nameCache.getItemsLength()-1;switch(a){case "last":this.selected=d;break;case "next":this.selected++;this.selected>d&&(this.selected= -0);break;case "previous":this.selected--;0>this.selected&&(this.selected=d);break;case "nextPage":this.selected+=f.maxItems;this.selected>d&&(this.selected=d);break;case "previousPage":this.selected-=f.maxItems;0>this.selected&&(this.selected=0);break;default:this.selected=0}this.highlightSelected()},highlightSelected:function(a){var d=this.$popup.find(".mentionme_popup_item_"+this.selected),b=this.$popup.find(".mentionme_popup_item_"+this.lastSelected),c=b.find("span.mention_name_highlight_on"), -e=this.itemInView(d);this.lastSelected!=this.selected&&0!=d.length&&(b.length&&(b.removeClass("mentionme_popup_item_on"),c.length&&(c.removeClass("mention_name_highlight_on"),c.addClass("mention_name_highlight"))),this.lastSelected=this.selected,d&&(d.hasClass("mentionme_popup_item_on")||d.addClass("mentionme_popup_item_on"),c=d.find("span.mention_name_highlight"),c.length&&(c.removeClass("mention_name_highlight"),c.addClass("mention_name_highlight_on"))),a||1!==f.lockSelection&&!0===e||(f.lockSelection? -0this.longestName&&(this.longestName=a.length);return!0},search:function(){var d=this.keyCache.getText().slice(0, -f.minLength);this.searching||-1!==this.searched.indexOf(d)?this.popup.spinnerIsVisible()&&(this.popup.hide(),this.editorInterface.focus()):(this.searched.push(d),this.searching=!0,0===this.items.length&&this.popup.showSpinner(),b.ajax({type:"post",url:"xmlhttp.php",data:{action:"mentionme",mode:"nameSearch",search:d},success:a.bind(this)}))},load:a,isReady:function(){return this.ready},isLoading:function(){return this.loading},getData:function(){return this.data},getItems:function(){return this.items}, -getItemsLength:function(){return this.items.length},getLongestName:function(){return this.longestName}});return c}(),t=function(){function c(a){this.$textarea=b("#"+a);this.$container=this.$textarea.closest("div");this.selection={start:0,end:0};this.popup=new q(this);this.bindKeyup()}b.extend(c.prototype,{heightModifier:0,lineHeightModifier:0,onKeyUp:function(a){this.popup.isVisible()||(this.getCaret(),p(a.keyCode)&&"@"==this.$textarea.val().slice(this.selection.start-1,this.selection.end)&&this.showPopup())}, -showPopup:function(){var a=this.$textarea.caret("offset");this.popup.show(a.left+3,a.top-5)},insert:function(){var a=n(this.popup);a?(this.getCaret(),this.$textarea.val(this.$textarea.val().slice(0,this.selection.start)+a+this.$textarea.val().slice(this.selection.start)),this.setCaret(this.selection.start+a.length),this.popup.hide()):this.popup.spinnerIsVisible()||this.popup.hide()},getCaret:function(){var a=this.$textarea.caret("pos");this.selection.start=a;this.selection.end=a},setCaret:function(a){var d= -this.$textarea[0];d.setSelectionRange?(d.focus(),d.setSelectionRange(a,a)):d.createTextRange&&(d=d.createTextRange(),d.collapse(!0),d.moveEnd("character",a),d.moveStart("character",a),d.select())},bindClick:function(a){this.$textarea.click(a)},unbindClick:function(a){this.$textarea.off("click",a)},bindKeyup:function(){this.$textarea.keyup(b.proxy(this.onKeyUp,this))},unbindKeyup:function(){this.$textarea.off("keyup")},focus:function(){this.$textarea.focus()},getContainer:function(){return this.$container}}); -return c}(),A=function(){function c(){this.editor=MyBBEditor;this.rangeHelper=this.editor.getRangeHelper();this.$iFrame=b("iframe");this.$container=this.$iFrame.closest("td");this.$body=this.editor.getBody();this.selection={start:0,end:0};this.popup=new q(this);this.editor.keyUp(this.onKeyUp.bind(this))}b.extend(c.prototype,{heightModifier:0,lineHeightModifier:0,onKeyUp:function(a){this.getCaret();if(!a.keyCode)if(a.originalEvent&&a.originalEvent.keyCode)a.keyCode=a.originalEvent.keyCode;else return; -this.popup.isVisible()||p(a.keyCode)&&"@"==this.$currentNode.text().slice(this.selection.start-1,this.selection.end)&&this.showPopup()},showPopup:function(){var a=this.$body.caret("offset",{iframe:this.$iFrame[0]});var d=this.$container.offset();var b=7;this.$currentNode.closest("div").length&&"function"===typeof this.$currentNode.closest("div").css&&(b=parseInt(this.$currentNode.closest("div").css("fontSize").replace("px","")/2,10));b=parseInt(a.left,10)+d.left+parseInt(this.$container.css("paddingLeft").replace("px", -""),10)+b+2;a=parseInt(a.top+this.$container.find("div.sceditor-toolbar").height(),10)+d.top+parseInt(this.$container.css("paddingTop").replace("px",""),10)+3;this.popup.show(b,a)},insert:function(){var a=n(this.popup);a?(this.editor.insert(a),this.popup.hide()):this.popup.spinnerIsVisible()||this.popup.hide()},getCaret:function(){var a=this.rangeHelper.selectedRange();this.$currentNode=a.startContainer?b(a.startContainer):b(editor.currentNode());this.selection.start=a.startOffset;this.selection.end= -a.endOffset},bindClick:function(a){this.$body.click(a)},unbindClick:function(a){this.$body.off("click",a)},focus:function(){this.$iFrame.focus()},getContainer:function(){return this.$container}});return c}(),u=function(){function c(a){if(0!==b("#"+a).length&&"undefined"!==typeof CKEDITOR.instances[a]){this.id=a;this.editor=CKEDITOR.instances[this.id];if("message"===a||"signature"===a)this.editor.on("instanceReady",b.proxy(this.finalize,this));else this.finalize();b("#quick_reply_submit").click(b.proxy(this.quickReplyPosted, -this))}}b.extend(c.prototype,{heightModifier:0,lineHeightModifier:0,finalize:function(){this.doFinalize();this.lastState=this.editor.mode;this.editor.on("mode",b.proxy(this.onModeChange,this))},doFinalize:function(){this.$iFrame=b("#cke_"+this.id).find("iframe");this.$container=this.$iFrame.closest("div");this.$doc=b(this.editor.document.$);this.$body=this.$doc.find("body");this.bindKeyup();this.popup=new q(this)},onModeChange:function(a){"undefined"!=typeof a.sender.mode&&a.sender.mode!=this.lastState&& -(this.lastState=a.sender.mode,"source"==a.sender.mode?this.unbindKeyup():this.doFinalize())},onKeyUp:function(a){this.popup.isVisible()||p(a.keyCode)&&"@"==this.getPrevChar()&&this.showPopup()},quickReplyPosted:function(){"undefined"!==typeof this.$doc&&this.$doc.length&&this.$doc.off("keyup",this.onKeyUp);setTimeout(b.proxy(function(){this.$doc.keyup(b.proxy(this.onKeyUp,this))},this),500)},showPopup:function(){var a=this.$body.caret("offset",{iframe:this.$iFrame[0]}),d=this.$iFrame.offset(),b=parseInt(a.left+ -d.left,10)+2;a=parseInt(a.top+d.top,10)-5;this.popup.show(b,a)},insert:function(){var a=n(this.popup);a?(this.editor.insertText(a),this.popup.hide()):this.popup.spinnerIsVisible()||this.popup.hide()},getPrevChar:function(){var a=this.editor.getSelection().getRanges()[0];if(!a||!a.startContainer)return null;var d=a.startContainer;if(d.type==CKEDITOR.NODE_TEXT&&a.startOffset)return d.getText()[a.startOffset-1];a.collapse(!0);a.setStartAt(this.editor.editable(),CKEDITOR.POSITION_AFTER_START);for(d=new CKEDITOR.dom.walker(a);a= -d.previous();)if(a.type==CKEDITOR.NODE_TEXT)return a.getText().slice(-1);return null},bindClick:function(a){this.$doc.click(a)},unbindClick:function(a){this.$doc.off("click",a)},bindKeyup:function(){this.$doc.keyup(b.proxy(this.onKeyUp,this))},unbindKeyup:function(){this.$doc.off("keyup",this.onKeyUp)},focus:function(){this.editor.focus()},getContainer:function(){return this.$container}});return c}();b(function(){if("undefined"!==typeof CKEDITOR&&"undefined"!==typeof CKEDITOR.instances){var c=b.map(CKEDITOR.instances, -function(a,d){return d})[0];if("object"!==typeof CKEDITOR.instances[c])return!1;new u(c)}else if(null!==MyBBEditor&&"object"===typeof MyBBEditor&&MyBBEditor.getRangeHelper&&"function"===typeof MyBBEditor.getRangeHelper)new A;else if(0a.length?1:0}var f={minLength:2,maxLength:30,maxItems:5,tid:"",fullText:0,showAvatars:1,imageDirectory:"images",lockSelection:1},v={instructions:"type a user name"},e={BACKSPACE:8,ENTER:13,SHIFT:16,CTRL:17,ALT:18,ESC:27,PAGE_UP:33,PAGE_DOWN:34, -END:35,HOME:36,LEFT:37,UP:38,RIGHT:39,DOWN:40,INSERT:45,DELETE:46,NUMLOCK:144},q=function(){function c(a){this.editorInterface=a;a=this.editorInterface.getContainer();this.$popup=b("#mentionme_master_popup").clone().attr("id","");this.$spinner=this.$popup.find("div.mentionme_spinner").hide();this.$input=this.$popup.find("input.mentionme_popup_input");this.$inputDiv=this.$popup.find("div.mentionme_popup_input_container");this.$body=this.$popup.find("div.mentionme_popup_body");if("string"===typeof a&& -b("#"+a).length)this.$container=b("#"+a);else if("object"===typeof a&&b(a).length)this.$container=b(a);else return!1;this.$container.append(this.$popup);this.$popup.css({left:"-1000px",top:"-1000px"}).show();this.inputHeight=this.$inputDiv.height();a=b("
");f.showAvatars&&b("",{"class":"mention_user_avatar",src:f.defaultAvatar}).appendTo(a);a.append(Array(f.maxLength+1).join("M")).addClass("mentionme_popup_item");this.$body.html(a);this.lineHeight=parseInt(a.height(),10)+this.editorInterface.lineHeightModifier+ -parseInt(a.css("paddingTop").replace("px",""),10)+parseInt(a.css("paddingBottom").replace("px",""),10);this.$instructions=b("",{"class":"mentionme_popup_instructions"}).html(v.instructions);this.scrollWidthDiff=this.$body.width()-this.$body[0].scrollWidth;this.keyCache=new y(this);this.nameCache=new z(this)}b.extend(c.prototype,{show:function(a,d){this.keyCache.clear();this.update();this.move(a,d);this.$popup.show();this.lastSelected=null;this.select();this.visible=!0;this.$body.mouseover(b.proxy(this.onMouseMove, -this));this.$body.click(b.proxy(this.onClick,this));b(document).click(b.proxy(this.hide,this));this.editorInterface.bindClick(b.proxy(this.hide,this));this.$input.keydown(b.proxy(this.onKeyDown,this));this.$input.keyup(b.proxy(this.updateCheck,this));this.$input.click(b.proxy(this.onInputClick,this));this.$input.focus()},hide:function(){this.$popup.hide();this.$body.off("mouseover",this.onMouseMove);this.$body.off("click",this.onClick);b(document).off("click",this.hide);this.editorInterface.unbindClick(this.hide); -this.$input.off("keydown",this.onKeyDown);this.$input.off("keyup",this.updateCheck);this.$input.off("click",this.onInputClick);this.visible=!1;this.$input.val("")},move:function(a,d){var c=this.nameCache.getLongestName();this.width=0;if(f.showAvatars){var e=b("",{"class":"mention_user_avatar",src:f.defaultAvatar}).css({left:"-1000px",top:"-1000px"}).appendTo(this.$container);this.width+=e.width();e.remove()}this.width+=parseInt(this.$body.css("fontSize").replace("px","")*c,10);c={height:this.getCurrentHeight()+ -this.inputHeight+"px",width:parseInt(this.width-this.scrollWidthDiff,10)+"px"};"undefined"!=typeof a&&(c.left=a+"px");"undefined"!=typeof d&&(c.top=d+"px");this.$popup.css(c);this.$body.css({height:this.getCurrentHeight()+"px",width:this.width})},update:function(){this.nameCache.isReady()?(this.nameCache.match(),this.buildItems(),this.lastSelected=null,this.select(),this.keyCache.getLength()>=f.minLength&&this.nameCache.search()):this.showSpinner()},buildItems:function(){var a,d=this.nameCache.getItemsLength(), -c=this.nameCache.getData(),e=-1!==navigator.userAgent.toLowerCase().indexOf("msie")?"hand":"pointer";this.items=this.nameCache.getItems();if(0===d&&0==this.spinnerVisible)0",{"class":"mentionme_typed_text"}).html(this.keyCache.getText()))):this.showInstructions();else for(this.clear(),a=0;a'+k.slice(g,g+this.keyCache.getLength())+""+k.slice(g+this.keyCache.getLength())}g="";f.showAvatars&&(h=c[h].avatar,"undefined"==typeof h?h=f.defaultAvatar:0==h.length&&(h=f.defaultAvatar),g=b("",{"class":"mention_user_avatar",src:h}).one("error",function(){this.src=f.defaultAvatar}));this.$body.append(b("
",{"class":"mentionme_popup_item mentionme_popup_item_"+a}).append(g).append(k).css({cursor:e}))}this.isVisible()&&this.move()}, -clear:function(){this.$body.html("");this.lastSelected=null;this.spinnerVisible=!1;this.isVisible()&&this.move()},showSpinner:function(){this.clear();this.$body.html(this.$spinner);this.spinnerVisible=!0;this.isVisible()&&this.move()},showInstructions:function(){this.clear();this.$body.html(this.$instructions)},updateCheck:function(){this.keyCache.update()&&this.update()},select:function(a){var b=this.nameCache.getItemsLength()-1;switch(a){case "last":this.selected=b;break;case "next":this.selected++; -this.selected>b&&(this.selected=0);break;case "previous":this.selected--;0>this.selected&&(this.selected=b);break;case "nextPage":this.selected+=f.maxItems;this.selected>b&&(this.selected=b);break;case "previousPage":this.selected-=f.maxItems;0>this.selected&&(this.selected=0);break;default:this.selected=0}this.highlightSelected()},highlightSelected:function(a){var b=this.$popup.find(".mentionme_popup_item_"+this.selected),c=this.$popup.find(".mentionme_popup_item_"+this.lastSelected),e=c.find("span.mention_name_highlight_on"), -h=this.itemInView(b);this.lastSelected!=this.selected&&0!=b.length&&(c.length&&(c.removeClass("mentionme_popup_item_on"),e.length&&(e.removeClass("mention_name_highlight_on"),e.addClass("mention_name_highlight"))),this.lastSelected=this.selected,b&&(b.hasClass("mentionme_popup_item_on")||b.addClass("mentionme_popup_item_on"),e=b.find("span.mention_name_highlight"),e.length&&(e.removeClass("mention_name_highlight"),e.addClass("mention_name_highlight_on"))),a||1!==f.lockSelection&&!0===h||(f.lockSelection? -0this.longestName&&(this.longestName=a.length);return!0},search:function(){var d=this.keyCache.getText().slice(0, -f.minLength);this.searching||-1!==this.searched.indexOf(d)?this.popup.spinnerIsVisible()&&(this.popup.hide(),this.editorInterface.focus()):(this.searched.push(d),this.searching=!0,0===this.items.length&&this.popup.showSpinner(),b.ajax({type:"post",url:"xmlhttp.php",data:{action:"mentionme",mode:"nameSearch",search:d},success:a.bind(this)}))},load:a,isReady:function(){return this.ready},isLoading:function(){return this.loading},getData:function(){return this.data},getItems:function(){return this.items}, -getItemsLength:function(){return this.items.length},getLongestName:function(){return this.longestName}});return c}(),t=function(){function c(a){this.$textarea=b("#"+a);this.$container=this.$textarea.closest("div");this.selection={start:0,end:0};this.popup=new q(this);this.bindKeyup()}b.extend(c.prototype,{heightModifier:0,lineHeightModifier:0,onKeyUp:function(a){this.popup.isVisible()||(this.getCaret(),p(a.keyCode)&&"@"==this.$textarea.val().slice(this.selection.start-1,this.selection.end)&&this.showPopup())}, -showPopup:function(){var a=this.$textarea.caret("offset");this.popup.show(a.left+3,a.top-5)},insert:function(){var a=n(this.popup);a?(this.getCaret(),this.$textarea.val(this.$textarea.val().slice(0,this.selection.start)+a+this.$textarea.val().slice(this.selection.start)),this.setCaret(this.selection.start+a.length),this.popup.hide()):this.popup.spinnerIsVisible()||this.popup.hide()},getCaret:function(){var a=this.$textarea.caret("pos");this.selection.start=a;this.selection.end=a},setCaret:function(a){var b= -this.$textarea[0];b.setSelectionRange?(b.focus(),b.setSelectionRange(a,a)):b.createTextRange&&(b=b.createTextRange(),b.collapse(!0),b.moveEnd("character",a),b.moveStart("character",a),b.select())},bindClick:function(a){this.$textarea.click(a)},unbindClick:function(a){this.$textarea.off("click",a)},bindKeyup:function(){this.$textarea.keyup(b.proxy(this.onKeyUp,this))},unbindKeyup:function(){this.$textarea.off("keyup")},focus:function(){this.$textarea.focus()},getContainer:function(){return this.$container}}); -return c}(),A=function(){function c(){this.editor=MyBBEditor;this.rangeHelper=this.editor.getRangeHelper();this.$iFrame=b("iframe");this.$container=this.$iFrame.closest("td");this.$body=this.editor.getBody();this.selection={start:0,end:0};this.popup=new q(this);this.editor.keyUp(this.onKeyUp.bind(this))}b.extend(c.prototype,{heightModifier:0,lineHeightModifier:0,onKeyUp:function(a){this.getCaret();if(!a.keyCode)if(a.originalEvent&&a.originalEvent.keyCode)a.keyCode=a.originalEvent.keyCode;else return; -this.popup.isVisible()||p(a.keyCode)&&"@"==this.$currentNode.text().slice(this.selection.start-1,this.selection.end)&&this.showPopup()},showPopup:function(){var a=this.$body.caret("offset",{iframe:this.$iFrame[0]});var b=this.$container.offset();var c=7;this.$currentNode.closest("div").length&&"function"===typeof this.$currentNode.closest("div").css&&(c=parseInt(this.$currentNode.closest("div").css("fontSize").replace("px","")/2,10));c=parseInt(a.left,10)+b.left+parseInt(this.$container.css("paddingLeft").replace("px", -""),10)+c+2;a=parseInt(a.top+this.$container.find("div.sceditor-toolbar").height(),10)+b.top+parseInt(this.$container.css("paddingTop").replace("px",""),10)+3;this.popup.show(c,a)},insert:function(){var a=n(this.popup);a?(this.editor.insert(a),this.popup.hide()):this.popup.spinnerIsVisible()||this.popup.hide()},getCaret:function(){var a=this.rangeHelper.selectedRange();this.$currentNode=a.startContainer?b(a.startContainer):b(editor.currentNode());this.selection.start=a.startOffset;this.selection.end= -a.endOffset},bindClick:function(a){this.$body.click(a)},unbindClick:function(a){this.$body.off("click",a)},focus:function(){this.$iFrame.focus()},getContainer:function(){return this.$container}});return c}(),u=function(){function c(a){if(0!==b("#"+a).length&&"undefined"!==typeof CKEDITOR.instances[a]){this.id=a;this.editor=CKEDITOR.instances[this.id];if("message"===a||"signature"===a)this.editor.on("instanceReady",b.proxy(this.finalize,this));else this.finalize();b("#quick_reply_submit").click(b.proxy(this.quickReplyPosted, -this))}}b.extend(c.prototype,{heightModifier:0,lineHeightModifier:0,finalize:function(){this.doFinalize();this.lastState=this.editor.mode;this.editor.on("mode",b.proxy(this.onModeChange,this))},doFinalize:function(){this.$iFrame=b("#cke_"+this.id).find("iframe");this.$container=this.$iFrame.closest("div");this.$doc=b(this.editor.document.$);this.$body=this.$doc.find("body");this.bindKeyup();this.popup=new q(this)},onModeChange:function(a){"undefined"!=typeof a.sender.mode&&a.sender.mode!=this.lastState&& -(this.lastState=a.sender.mode,"source"==a.sender.mode?this.unbindKeyup():this.doFinalize())},onKeyUp:function(a){this.popup.isVisible()||p(a.keyCode)&&"@"==this.getPrevChar()&&this.showPopup()},quickReplyPosted:function(){"undefined"!==typeof this.$doc&&this.$doc.length&&this.$doc.off("keyup",this.onKeyUp);setTimeout(b.proxy(function(){this.$doc.keyup(b.proxy(this.onKeyUp,this))},this),500)},showPopup:function(){var a=this.$body.caret("offset",{iframe:this.$iFrame[0]}),b=this.$iFrame.offset(),c=parseInt(a.left+ -b.left,10)+2;a=parseInt(a.top+b.top,10)-5;this.popup.show(c,a)},insert:function(){var a=n(this.popup);a?(this.editor.insertText(a),this.popup.hide()):this.popup.spinnerIsVisible()||this.popup.hide()},getPrevChar:function(){var a=this.editor.getSelection().getRanges()[0];if(!a||!a.startContainer)return null;var b=a.startContainer;if(b.type==CKEDITOR.NODE_TEXT&&a.startOffset)return b.getText()[a.startOffset-1];a.collapse(!0);a.setStartAt(this.editor.editable(),CKEDITOR.POSITION_AFTER_START);for(b=new CKEDITOR.dom.walker(a);a= -b.previous();)if(a.type==CKEDITOR.NODE_TEXT)return a.getText().slice(-1);return null},bindClick:function(a){this.$doc.click(a)},unbindClick:function(a){this.$doc.off("click",a)},bindKeyup:function(){this.$doc.keyup(b.proxy(this.onKeyUp,this))},unbindKeyup:function(){this.$doc.off("keyup",this.onKeyUp)},focus:function(){this.editor.focus()},getContainer:function(){return this.$container}});return c}();b(function(){if("undefined"!==typeof CKEDITOR&&"undefined"!==typeof CKEDITOR.instances){var c=b.map(CKEDITOR.instances, -function(a,b){return b})[0];if("object"!==typeof CKEDITOR.instances[c])return!1;new u(c)}else if(null!==MyBBEditor&&"object"===typeof MyBBEditor&&MyBBEditor.getRangeHelper&&"function"===typeof MyBBEditor.getRangeHelper)new A;else if(0");if(options.showAvatars){$testAvatar=$("",{"class":"mention_user_avatar",src:options.defaultAvatar,}).appendTo($testDiv);} +$testDiv.append(Array(options.maxLength+1).join("M")).addClass("mentionme_popup_item");this.$body.html($testDiv);this.lineHeight=pi($testDiv.height())+ +this.editorInterface.lineHeightModifier+ +pi($testDiv.css("paddingTop").replace("px",""))+ +pi($testDiv.css("paddingBottom").replace("px",""));this.$instructions=$("",{"class":"mentionme_popup_instructions",}).html(lang.instructions);this.scrollWidthDiff=this.$body.width()-this.$body[0].scrollWidth;this.keyCache=new KeyCache(this);this.nameCache=new NameCache(this);} +function show(left,top){this.keyCache.clear();this.update();this.move(left,top);this.$popup.show();this.lastSelected=null;this.select();this.visible=true;this.$body.mouseover($.proxy(this.onMouseMove,this));this.$body.click($.proxy(this.onClick,this));$(document).click($.proxy(this.hide,this));this.editorInterface.bindClick($.proxy(this.hide,this));this.$input.keydown($.proxy(this.onKeyDown,this));this.$input.keyup($.proxy(this.updateCheck,this));this.$input.click($.proxy(this.onInputClick,this));this.$input.focus();} +function hide(){this.$popup.hide();this.$body.off("mouseover",this.onMouseMove);this.$body.off("click",this.onClick);$(document).off("click",this.hide);this.editorInterface.unbindClick(this.hide);this.$input.off("keydown",this.onKeyDown);this.$input.off("keyup",this.updateCheck);this.$input.off("click",this.onInputClick);this.visible=false;this.$input.val("");} +function move(left,top){var style,longestName=this.nameCache.getLongestName(),$testAvatar;this.width=0;if(options.showAvatars){$testAvatar=$("",{"class":"mention_user_avatar",src:options.defaultAvatar,}).css({left:"-1000px",top:"-1000px",}).appendTo(this.$container);this.width+=$testAvatar.width();$testAvatar.remove();} +this.width+=pi(this.$body.css("fontSize").replace("px","")*longestName);this.width=Math.max(options.minWidth,this.width);style={height:this.getCurrentHeight()+this.inputHeight+"px",width:pi(this.width-this.scrollWidthDiff)+"px",};if(typeof left!="undefined"){style.left=left+"px";} +if(typeof top!="undefined"){style.top=top+"px";} +this.$popup.css(style);this.$body.css({height:this.getCurrentHeight()+"px",width:this.width,});} +function update(){if(!this.nameCache.isReady()){this.showSpinner();return;} +this.nameCache.match();this.buildItems();this.lastSelected=null;this.select();if(this.keyCache.getLength()>=options.minLength){this.nameCache.search();}} +function buildItems(){var i,text,avatar,avatarPath,start,user,cacheLength=this.nameCache.getItemsLength(),data=this.nameCache.getData(),c=(navigator.userAgent.toLowerCase().indexOf("msie")!==-1)?"hand":"pointer";this.items=this.nameCache.getItems();if(cacheLength===0&&this.spinnerVisible==false){if(this.keyCache.getLength()>0){this.clear();this.$body.html($("",{"class":"mentionme_typed_text",}).html(this.keyCache.getText()));}else{this.showInstructions();} +if(this.isVisible()){this.move();} +return;} +this.clear();for(i=0;i'+ +text.slice(start,start+this.keyCache.getLength())+""+ +text.slice(start+this.keyCache.getLength());}} +avatar="";if(options.showAvatars){avatarPath=data[user]["avatar"];if(typeof avatarPath=="undefined"||avatarPath==null||avatarPath.length==0){avatarPath=options.defaultAvatar;} +avatar=$("",{"class":"mention_user_avatar",src:avatarPath,}).one("error",function(){this.src=options.defaultAvatar;});} +this.$body.append($("
",{"class":"mentionme_popup_item mentionme_popup_item_"+i,}).append(avatar).append(text).css({cursor:c,}));} +if(this.isVisible()){this.move();}} +function clear(){this.$body.html("");this.lastSelected=null;this.spinnerVisible=false;if(this.isVisible()){this.move();}} +function showSpinner(){this.clear();this.$body.html(this.$spinner);this.spinnerVisible=true;if(this.isVisible()){this.move();}} +function showInstructions(){this.clear();this.$body.html(this.$instructions);} +function updateCheck(){if(this.keyCache.update()){this.update();}} +function select(selection){var lastItem=this.nameCache.getItemsLength()-1;switch(selection){case"last":this.selected=lastItem;break;case"next":this.selected++;if(this.selected>lastItem){this.selected=0;} +break;case"previous":this.selected--;if(this.selected<0){this.selected=lastItem;} +break;case"nextPage":this.selected+=options.maxItems;if(this.selected>lastItem){this.selected=lastItem;} +break;case"previousPage":this.selected-=options.maxItems;if(this.selected<0){this.selected=0;} +break;default:this.selected=0;break;} +this.highlightSelected();} +function highlightSelected(noScroll){var $selectedItem=this.$popup.find(".mentionme_popup_item_"+this.selected),$lastSelectedItem=this.$popup.find(".mentionme_popup_item_"+this.lastSelected),$highlightSpan=$lastSelectedItem.find("span.mention_name_highlight_on"),offset=this.itemInView($selectedItem);if(this.lastSelected==this.selected||$selectedItem.length==0){return;} +if($lastSelectedItem.length){$lastSelectedItem.removeClass("mentionme_popup_item_on");if($highlightSpan.length){$highlightSpan.removeClass("mention_name_highlight_on");$highlightSpan.addClass("mention_name_highlight");}} +this.lastSelected=this.selected;if($selectedItem){if(!$selectedItem.hasClass("mentionme_popup_item_on")){$selectedItem.addClass("mentionme_popup_item_on");} +$highlightSpan=$selectedItem.find("span.mention_name_highlight");if($highlightSpan.length){$highlightSpan.removeClass("mention_name_highlight");$highlightSpan.addClass("mention_name_highlight_on");}} +if(noScroll||(options.lockSelection!==1&&offset===true)){return;} +if(options.lockSelection){if(this.nameCache.getItemsLength()-options.maxItems>0){this.$body.prop("scrollTop",pi($selectedItem.prop("offsetTop")-this.inputHeight));} +return;} +if(this.selected==0){this.$body.prop("scrollTop",-this.inputHeight);return;} +if(offset>0){this.$body.prop("scrollTop",pi($selectedItem.prop("offsetTop")-(this.getCurrentHeight()-this.lineHeight)-this.inputHeight));return;} +this.$body.prop("scrollTop",pi($selectedItem.prop("offsetTop")-this.inputHeight));} +function itemInView($el){var offset=$el.prop("offsetTop")-this.$body.prop("scrollTop");if(offset>0&&(offset+this.lineHeight)this.longestName){this.longestName=property.length;} +return true;} +function search(){var search=this.keyCache.getText().slice(0,options.minLength);if(this.searching||this.searched.indexOf(search)!==-1){if(this.popup.spinnerIsVisible()){this.popup.hide();this.editorInterface.focus();} +return;} +this.searched.push(search);this.searching=true;if(this.items.length===0){this.popup.showSpinner();} +$.ajax({type:"post",url:"xmlhttp.php",data:{action:"mentionme",mode:"nameSearch",search:search,},success:load.bind(this),});} +function load(names){var n=0,property;this.searching=false;if(!names){if(this.popup.spinnerIsVisible()){this.popup.hide();this.editorInterface.focus();} +return;} +for(property in names){if(!names.hasOwnProperty(property)||this.data[property]){continue;} +this.data[property]=names[property];n++;} +if(!n||!this.popup.isVisible()){return;} +this.match();this.popup.buildItems();this.popup.select();} +function isReady(){return this.ready;} +function isLoading(){return this.loading;} +function getData(){return this.data;} +function getItems(){return this.items;} +function getItemsLength(){return this.items.length;} +function getLongestName(){return this.longestName;} +$.extend(MentionMeNameCache.prototype,{loadNameCache:loadNameCache,match:match,checkEntry:checkEntry,search:search,load:load,isReady:isReady,isLoading:isLoading,getData:getData,getItems:getItems,getItemsLength:getItemsLength,getLongestName:getLongestName,});return MentionMeNameCache;})(),TextareaInterface=(function(){function AutoCompleteTextareaInterface(textareaId){this.$textarea=$("#"+textareaId);this.$container=this.$textarea.closest("div");this.selection={start:0,end:0,};this.popup=new Popup(this);this.bindKeyup();} +function onKeyUp(e){if(this.popup.isVisible()){return;} +this.getCaret();if(checkKeyCode(e.keyCode)&&this.$textarea.val().slice(this.selection.start-1,this.selection.end)=="@"){this.showPopup();}} +function showPopup(){var coords=this.$textarea.caret("offset"),left=coords.left+3,top=coords.top-5;this.popup.show(left,top);} +function insertMention(){var mention=prepMention(this.popup);if(!mention){if(!this.popup.spinnerIsVisible()){this.popup.hide();} +return;} +this.getCaret();this.$textarea.val(this.$textarea.val().slice(0,this.selection.start)+ +mention+ +this.$textarea.val().slice(this.selection.start));this.setCaret(this.selection.start+mention.length);this.popup.hide();} +function getCaret(){var range=this.$textarea.caret("pos");this.selection.start=range;this.selection.end=range;} +function setCaret(position){var temp=this.$textarea[0],range;if(temp.setSelectionRange){temp.focus();temp.setSelectionRange(position,position);}else if(temp.createTextRange){range=temp.createTextRange();range.collapse(true);range.moveEnd("character",position);range.moveStart("character",position);range.select();}} +function bindClick(f){this.$textarea.click(f);} +function unbindClick(f){this.$textarea.off("click",f);} +function bindKeyup(){this.$textarea.keyup($.proxy(this.onKeyUp,this));} +function unbindKeyup(){this.$textarea.off("keyup");} +function focus(){this.$textarea.focus();} +function getContainer(){return this.$container;} +$.extend(AutoCompleteTextareaInterface.prototype,{heightModifier:0,lineHeightModifier:0,onKeyUp:onKeyUp,showPopup:showPopup,insert:insertMention,getCaret:getCaret,setCaret:setCaret,bindClick:bindClick,unbindClick:unbindClick,bindKeyup:bindKeyup,unbindKeyup:unbindKeyup,focus:focus,getContainer:getContainer,});return AutoCompleteTextareaInterface;})(),SCEditorInterface=(function(){function AutoCompleteSCEditorInterface(){this.editor=MyBBEditor;this.rangeHelper=this.editor.getRangeHelper();this.$iFrame=$("iframe");this.$container=this.$iFrame.closest("td");this.$body=this.editor.getBody();this.selection={start:0,end:0,};this.popup=new Popup(this);this.editor.keyUp(this.onKeyUp.bind(this));} +function onKeyUp(e){this.getCaret();if(!e.keyCode){if(e.originalEvent&&e.originalEvent.keyCode){e.keyCode=e.originalEvent.keyCode;}else{return;}} +if(!this.popup.isVisible()){if(checkKeyCode(e.keyCode)&&this.$currentNode.text().slice(this.selection.start-1,this.selection.end)=="@"){this.showPopup();} +return;}} +function showPopup(){var fontSize,left,top,coords=this.$body.caret("offset",{iframe:this.$iFrame[0],}),containerOffset=this.$container.offset();fontSize=7;if(this.$currentNode.closest("div").length&&typeof this.$currentNode.closest("div").css==="function"){fontSize=pi(this.$currentNode.closest("div").css("fontSize").replace("px","")/2);} +left=pi(coords.left)+containerOffset.left+pi(this.$container.css("paddingLeft").replace("px",""))+fontSize+2;top=pi(coords.top+this.$container.find("div.sceditor-toolbar").height())+containerOffset.top+pi(this.$container.css("paddingTop").replace("px",""))+3;this.popup.show(left,top);} +function insertMention(){var mention=prepMention(this.popup);if(!mention){if(!this.popup.spinnerIsVisible()){this.popup.hide();} +return;} +this.editor.insert(mention);this.popup.hide();} +function getCaret(){var range=this.rangeHelper.selectedRange();if(range.startContainer){this.$currentNode=$(range.startContainer);}else{this.$currentNode=$(editor.currentNode());} +this.selection.start=range.startOffset;this.selection.end=range.endOffset;} +function bindClick(f){this.$body.click(f);} +function unbindClick(f){this.$body.off("click",f);} +function focus(){this.$iFrame.focus();} +function getContainer(){return this.$container;} +$.extend(AutoCompleteSCEditorInterface.prototype,{heightModifier:0,lineHeightModifier:0,onKeyUp:onKeyUp,showPopup:showPopup,insert:insertMention,getCaret:getCaret,bindClick:bindClick,unbindClick:unbindClick,focus:focus,getContainer:getContainer,});return AutoCompleteSCEditorInterface;})(),CKEditorInterface=(function(){function AutoCompleteCKEditorInterface(textareaId){if($("#"+textareaId).length===0||typeof CKEDITOR.instances[textareaId]==="undefined"){return;} +this.id=textareaId;this.editor=CKEDITOR.instances[this.id];if(textareaId==="message"||textareaId==="signature"){this.editor.on("instanceReady",$.proxy(this.finalize,this));}else{this.finalize();} +$("#quick_reply_submit").click($.proxy(this.quickReplyPosted,this));} +function finalize(){this.doFinalize();this.lastState=this.editor.mode;this.editor.on('mode',$.proxy(this.onModeChange,this));} +function doFinalize(){this.$iFrame=$("#cke_"+this.id).find("iframe");this.$container=this.$iFrame.closest("div");this.$doc=$(this.editor.document.$);this.$body=this.$doc.find("body");this.bindKeyup();this.popup=new Popup(this);} +function onModeChange(e){if(typeof e.sender.mode=="undefined"||e.sender.mode==this.lastState){return;} +this.lastState=e.sender.mode;if(e.sender.mode=="source"){this.unbindKeyup();}else{this.doFinalize();}} +function onKeyUp(e){if(!this.popup.isVisible()){if(checkKeyCode(e.keyCode)&&this.getPrevChar()=="@"){this.showPopup();} +return;}} +function quickReplyPosted(){if(typeof this.$doc!=="undefined"&&this.$doc.length){this.$doc.off("keyup",this.onKeyUp);} +setTimeout($.proxy(function(){this.$doc.keyup($.proxy(this.onKeyUp,this));},this),500);} +function showPopup(){var coords=this.$body.caret("offset",{iframe:this.$iFrame[0],}),iFrameOffset=this.$iFrame.offset(),left=pi(coords.left+iFrameOffset.left)+2,top=pi(coords.top+iFrameOffset.top)-5;this.popup.show(left,top);} +function insertMention(){var mention=prepMention(this.popup);if(!mention){if(!this.popup.spinnerIsVisible()){this.popup.hide();} +return;} +this.editor.insertText(mention);this.popup.hide();} +function getPrevChar(){var startNode,walker,node,range=this.editor.getSelection().getRanges()[0];if(!range||!range.startContainer){return null;} +startNode=range.startContainer;if(startNode.type==CKEDITOR.NODE_TEXT&&range.startOffset){return startNode.getText()[range.startOffset-1];}else{range.collapse(true);range.setStartAt(this.editor.editable(),CKEDITOR.POSITION_AFTER_START);walker=new CKEDITOR.dom.walker(range);while(node=walker.previous()){if(node.type==CKEDITOR.NODE_TEXT){return node.getText().slice(-1);}}} +return null;} +function bindClick(f){this.$doc.click(f);} +function unbindClick(f){this.$doc.off("click",f);} +function bindKeyup(){this.$doc.keyup($.proxy(this.onKeyUp,this));} +function unbindKeyup(){this.$doc.off("keyup",this.onKeyUp);} +function focus(){this.editor.focus();} +function getContainer(){return this.$container;} +$.extend(AutoCompleteCKEditorInterface.prototype,{heightModifier:0,lineHeightModifier:0,finalize:finalize,doFinalize:doFinalize,onModeChange:onModeChange,onKeyUp:onKeyUp,quickReplyPosted:quickReplyPosted,showPopup:showPopup,insert:insertMention,getPrevChar:getPrevChar,bindClick:bindClick,unbindClick:unbindClick,bindKeyup:bindKeyup,unbindKeyup:unbindKeyup,focus:focus,getContainer:getContainer,});return AutoCompleteCKEditorInterface;})();function setup(opt){$.extend(lang,opt.lang||{});delete opt.lang;$.extend(options,opt||{});$(["minLength","maxLength","minWidth","maxItems","fullText","showAvatars","lockSelection"]).each(function(){if(typeof options[this]!=="undefined"){options[this]=pi(options[this]);}});options.defaultAvatar=options.imageDirectory+"/default_avatar.png";} +function init(){var id,key,$shoutbox=$('.panel > form > input[class="text"]');if(typeof CKEDITOR!=="undefined"&&typeof CKEDITOR.instances!=="undefined"){key=$.map(CKEDITOR.instances,function(i,k){return k})[0];if(typeof CKEDITOR.instances[key]!=="object"){return false;} +new CKEditorInterface(key);}else if(MyBBEditor!==null&&typeof MyBBEditor==="object"&&MyBBEditor.getRangeHelper&&typeof MyBBEditor.getRangeHelper==="function"){new SCEditorInterface();}else if($("#message").length>0||$("#signature").length>0){if($("#message").length){id="message";}else if($("#signature").length){id="signature";} +if(!id||!$("#"+id).length){return false;} +new TextareaInterface(id);} +if($shoutbox.length){$shoutbox.prop("id","dvz_shoutbox_input");new TextareaInterface("dvz_shoutbox_input");} +$(".quick_edit_button").click(doQuickEdit);$("#quick_reply_submit").click(doQuickReply);} +function doQuickEdit(e){var pid=this.id.split("_").slice(-1)[0],id="quickedit_"+pid,i;if($("#"+id).length==0){return;} +if(typeof CKEDITOR==="undefined"){i=new TextareaInterface(id);}else{setTimeout(function(){i=new CKEditorInterface(id);},1100);} +setTimeout(function(){$("#quicksub_"+pid).add($("#quicksub_"+pid).next("button")).click(function(){i.unbindKeyup();});},1100);} +function doQuickReply(e){$(".quick_edit_button").off("click",doQuickEdit);setTimeout(function(){$(".quick_edit_button").click(doQuickEdit);},500);} +function prepMention(popup){var name=popup.getSelectedName(),quote="";if(!name){return;} +if(name.indexOf('"')==-1){quote='"';}else if(name.indexOf("'")==-1){quote="'";}else if(name.indexOf("`")==-1){quote="`";} +return quote+ +name+ +quote+" ";} +function checkKeyCode(keyCode){return[key.LEFT,key.RIGHT,key.UP,key.DOWN,key.BACKSPACE,key.ESC,key.SHIFT,key.CTRL,key.ALT,key.ENTER,key.DELETE,key.INSERT,key.END,key.NUMLOCK].indexOf(keyCode)===-1;} +function sortByLength(a,b){if(a.lengthb.length){return 1;}else{return 0;}} +function pi(i){return parseInt(i,10);} +$(init);m.autoComplete={setup:setup,};return m;})(jQuery,MentionMe||{}); \ No newline at end of file