MyBB Community Forums

Full Version: MentionMe for 1.8 & MyAlerts 2.0
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2 3 4 5 6 7
OK, thanks.

@jshort - any progress?
This method for having an autocomplete box present in the editor, as pictured here: http://community.mybb.com/thread-164576-...pid1127081


This isn't specific to MentionMe and would be pretty easy to work with DVZ Mentions as well. All this does is create a box that autocompletes the names of users on the board.

Step 1:
In codebuttons template, add:

<link rel="stylesheet" href="{$mybb->asset_url}/jscripts/select2/select2.css">
<script type="text/javascript" src="{$mybb->asset_url}/jscripts/select2/select2.min.js"></script>

To the top of the template, with the other JS inclusions.

Then, find the toolbar line:

toolbar: "{$basic1}{$align}{$font}{$size}{$color}

Add "mention" (without quotes) wherever you want the button to appear, like so:

toolbar: "{$basic1}{$align}{$font}{$size}{$color}{$removeformat}mention,{$basic2}image,{$email}{$link}|{$emoticon}|{$list}code,quote|maximize,source",

Save and close the template.

Step 2:
Then in jscripts/bbcodes_sceditor.js, find:

exec: function (caller) {
			$.sceditor.command.get('email')._dropDown(this, caller);
		}
	});

After that add:

/***************************************
	* Mention Me Button *
	***************************************/
	$.sceditor.command.set('mention', {
		_dropDown: function (editor, caller) {
			var $content;

			$content = $(
				'<div>' +
					'<label for="names">' + editor._('Names to Mention:') + '</label> ' +
					'<input type="text" id="names" />' +					
				'</div>' +
				'<div><input type="button" class="button" value="' + editor._('Insert') + '" /></div>'
			);


			$content.find('.button').click(function (e) {
				var	val = $content.find('#names').val();
				var array = val.split(',');

				if(val) {
					// needed for IE to reset the last range
					editor.focus();
						$.each(array, function(index, value ){
							if(value.replace(/\s/g, '') != "")
							{
								var text = value.replace(/,\s?/g, ", "),
									id = value.replace(/,\s?/g, ", ");
								editor.wysiwygEditorInsertHtml('@"' + text + '" ');	
								
							}
						});
					}
				

				editor.closeDropDown(true);
				e.preventDefault();
			});

			editor.createDropDown(caller, 'insertmention', $content);
		},
		exec: function (caller) {
			$.sceditor.command.get('mention')._dropDown(this, caller);
			MyBB.select2();
			$("#names").select2({
				placeholder: "Search for a User",
				minimumInputLength: 3,
				maximumSelectionSize: 25,
				multiple: true,
				ajax: { // instead of writing the function to execute the request we use Select2's convenient helper
					url: "xmlhttp.php?action=get_users",
					dataType: 'json',
					data: function (term, page) {
						return {
							query: term, // search term
						};
					},
					results: function (data, page) { // parse the results into the format expected by Select2.
						// since we are using custom formatting functions we do not need to alter remote JSON data
						return {results: data};
					}
				},
				initSelection: function(element, callback) {
					var query = $(element).val();
					if (query !== "") {
						var newqueries = [];
						exp_queries = query.split(",");
						$.each(exp_queries, function(index, value ){
							if(value.replace(/\s/g, '') != "")
							{
								var newquery = {
									id: value.replace(/,\s?/g, ", "),
									text: value.replace(/,\s?/g, ", ")
								};
								newqueries.push(newquery);
							}
						});
						callback(newqueries);
					}
				}
			});

		},
		txtExec: ['@'],

	});

You can change the various values here to be what you need (eg. change the text, change the symbol, etc.). Save and upload the file.

Step 3:

Then you have to add the button to the CSS. I use a custom theme for my editor that uses font awesome, so this is what mine looks like. You'll have to update it to use your own image.

.sceditor-button-mention div:before { content: "\f1fa"; }
This displays the @ symbol in the editor row.

That's it. All it does it provided the autocomplete box in the editor. It doesn't tag anybody and it doesn't format names.
Btw I had acconplished a full working autocomplete box that triggers typing @ just like in normal textareas, but within SCEditor. It works in full mode, not in source mode and that's the only issue left to sort out. But I'm too busy on my exams atm so I can't make any progress on it unfortunately.
(2015-01-28, 08:24 PM)Shade Wrote: [ -> ]Btw I had acconplished a full working autocomplete box that triggers typing @ just like in normal textareas, but within SCEditor. It works in full mode, not in source mode and that's the only issue left to sort out. But I'm too busy on my exams atm so I can't make any progress on it unfortunately.

@Shade - unfortunately your solution is not working for me... no autocomplete box for me Sad am I missing something? I changed ccs in mention me into:

div.mentionme_popup {
    position: absolute;
	background: #F5F5F5;
	color: #3D3D3D;
	border: 2px outset #3D3D3D;
	box-shadow: 5px 5px 5px #515151;
    z-index: 99999 !important;
}

IS there anybody who can help me? @Shade wrote me that mentionme_autocomplete.js is not loaded on the page... how to solve this?
Hello everyone, home myalerts 2.0.0 on (mybb 1.8.3) the only problem I have is with MentionMe-myalerts-integration, I received the mention of warning but when I click on it here is what I get

[Image: 1423867191-alerts-mention.png]

an invisible warning, you'd have an idea of the problem please?

sorry for my bad english
Which version of MentionMe are you using? Are you using the one I updated or a different version?
I try version "jnschrag" https://github.com/jnschrag/MentionMe/tr...0959e8d6ba

or I can find your version I tested immediately please Smile

sorry for my bad english Sad and thanks you for your reply Smile

edit: I believe that this is your version I have installed :p
Hmm. No idea then. Looks like you're missing language variables.
thanks for your reply ,So you think the problem would come from a file :

\languages\english mention.lang.php or \languages\english\admin mention.lang.php ?
Well i think there are no time to fork it or use it, but i want to share my file but it's better to stay here only, because i have added many changes on code from users petition on my forum, i did not know theres one already @jshort version that can give me a break when i work on this Big Grin

In my site i share a file and today i want to update a working version but not finished yet, i wait because this thread exist and Wildcard appears and tell he work on it.

I have my own file and works fine on my site but i hope we can do a better version to share.

QUESTION: Did you have added new lan vars to add compatibility with MyAlerts ?
Did you globalize new lang vars ?

Anyway i add my own moded file here, it's the same Wildcard version withh all credits to him, i only add something new, but have to work moe, and more, and more to make a final release.
Pages: 1 2 3 4 5 6 7