Loading Changelog.md +1 −0 Original line number Diff line number Diff line Loading @@ -3,6 +3,7 @@ ## Refactor ## Bug fixes * Fix mention autocomplete when pasting the username [#6510](https://github.com/diaspora/diaspora/pull/6510) ## Features Loading lib/assets/javascripts/jquery.mentionsInput.js +15 −4 Original line number Diff line number Diff line Loading @@ -8,17 +8,19 @@ * * License: MIT License - http://www.opensource.org/licenses/mit-license.php * * Modifcations for Diaspora: * Modifications for Diaspora: * * Prevent replacing the wrong text by marking the replacement position with a special character * Don't add a space after inserting a mention * Only use the first div as a wrapperBox * Binded paste event on input box to trigger contacts search for autocompletion while adding mention via clipboard */ (function ($, _, undefined) { // Settings var KEY = { BACKSPACE : 8, TAB : 9, RETURN : 13, ESC : 27, LEFT : 37, UP : 38, RIGHT : 39, DOWN : 40, COMMA : 188, SPACE : 32, HOME : 36, END : 35 }; // Keys "enum" var KEY = { PASTE : 118, BACKSPACE : 8, TAB : 9, RETURN : 13, ESC : 27, LEFT : 37, UP : 38, RIGHT : 39, DOWN : 40, COMMA : 188, SPACE : 32, HOME : 36, END : 35 }; // Keys "enum" var defaultSettings = { triggerChar : '@', onDataRequest : $.noop, Loading Loading @@ -95,6 +97,7 @@ elmInputBox.attr('data-mentions-input', 'true'); elmInputBox.bind('keydown', onInputBoxKeyDown); elmInputBox.bind('keypress', onInputBoxKeyPress); elmInputBox.bind('paste',onInputBoxPaste); elmInputBox.bind('input', onInputBoxInput); elmInputBox.bind('click', onInputBoxClick); elmInputBox.bind('blur', onInputBoxBlur); Loading Loading @@ -208,6 +211,13 @@ hideAutoComplete(); } function onInputBoxPaste(e) { pastedData = e.originalEvent.clipboardData.getData("text/plain"); dataArray = pastedData.split(""); _.each(dataArray, function(value) { inputBuffer.push(value); }); } function onInputBoxInput(e) { updateValues(); updateMentionsCollection(); Loading @@ -223,7 +233,8 @@ } function onInputBoxKeyPress(e) { if(e.keyCode !== KEY.BACKSPACE) { // Excluding ctrl+v from key press event in firefox if (!((e.which === KEY.PASTE && e.ctrlKey) || (e.keyCode === KEY.BACKSPACE))) { var typedValue = String.fromCharCode(e.which || e.keyCode); inputBuffer.push(typedValue); } Loading Loading
Changelog.md +1 −0 Original line number Diff line number Diff line Loading @@ -3,6 +3,7 @@ ## Refactor ## Bug fixes * Fix mention autocomplete when pasting the username [#6510](https://github.com/diaspora/diaspora/pull/6510) ## Features Loading
lib/assets/javascripts/jquery.mentionsInput.js +15 −4 Original line number Diff line number Diff line Loading @@ -8,17 +8,19 @@ * * License: MIT License - http://www.opensource.org/licenses/mit-license.php * * Modifcations for Diaspora: * Modifications for Diaspora: * * Prevent replacing the wrong text by marking the replacement position with a special character * Don't add a space after inserting a mention * Only use the first div as a wrapperBox * Binded paste event on input box to trigger contacts search for autocompletion while adding mention via clipboard */ (function ($, _, undefined) { // Settings var KEY = { BACKSPACE : 8, TAB : 9, RETURN : 13, ESC : 27, LEFT : 37, UP : 38, RIGHT : 39, DOWN : 40, COMMA : 188, SPACE : 32, HOME : 36, END : 35 }; // Keys "enum" var KEY = { PASTE : 118, BACKSPACE : 8, TAB : 9, RETURN : 13, ESC : 27, LEFT : 37, UP : 38, RIGHT : 39, DOWN : 40, COMMA : 188, SPACE : 32, HOME : 36, END : 35 }; // Keys "enum" var defaultSettings = { triggerChar : '@', onDataRequest : $.noop, Loading Loading @@ -95,6 +97,7 @@ elmInputBox.attr('data-mentions-input', 'true'); elmInputBox.bind('keydown', onInputBoxKeyDown); elmInputBox.bind('keypress', onInputBoxKeyPress); elmInputBox.bind('paste',onInputBoxPaste); elmInputBox.bind('input', onInputBoxInput); elmInputBox.bind('click', onInputBoxClick); elmInputBox.bind('blur', onInputBoxBlur); Loading Loading @@ -208,6 +211,13 @@ hideAutoComplete(); } function onInputBoxPaste(e) { pastedData = e.originalEvent.clipboardData.getData("text/plain"); dataArray = pastedData.split(""); _.each(dataArray, function(value) { inputBuffer.push(value); }); } function onInputBoxInput(e) { updateValues(); updateMentionsCollection(); Loading @@ -223,7 +233,8 @@ } function onInputBoxKeyPress(e) { if(e.keyCode !== KEY.BACKSPACE) { // Excluding ctrl+v from key press event in firefox if (!((e.which === KEY.PASTE && e.ctrlKey) || (e.keyCode === KEY.BACKSPACE))) { var typedValue = String.fromCharCode(e.which || e.keyCode); inputBuffer.push(typedValue); } Loading