mirror of
https://github.com/NodeBB/NodeBB.git
synced 2026-01-26 17:29:53 +01:00
moving controls object into its own module
This commit is contained in:
@@ -17,6 +17,10 @@ define(['taskbar'], function(taskbar) {
|
||||
socket.emit('modules.composer.pingActive', post_uuid);
|
||||
}
|
||||
});
|
||||
|
||||
require(['composer/controls'], function(composerControls) {
|
||||
controls = composerControls;
|
||||
});
|
||||
}
|
||||
|
||||
initialise();
|
||||
@@ -416,43 +420,6 @@ define(['taskbar'], function(taskbar) {
|
||||
thumbForm.submit();
|
||||
}
|
||||
|
||||
|
||||
/*************************************************/
|
||||
/* Rich Textarea Controls */
|
||||
/*************************************************/
|
||||
controls.insertIntoTextarea = function(textarea, value) {
|
||||
var $textarea = $(textarea);
|
||||
var currentVal = $textarea.val();
|
||||
|
||||
$textarea.val(
|
||||
currentVal.slice(0, textarea.selectionStart) +
|
||||
value +
|
||||
currentVal.slice(textarea.selectionStart)
|
||||
);
|
||||
};
|
||||
|
||||
controls.wrapSelectionInTextareaWith = function(textarea, leading, trailing){
|
||||
if(trailing === undefined){
|
||||
trailing = leading;
|
||||
}
|
||||
|
||||
var $textarea = $(textarea);
|
||||
var currentVal = $textarea.val()
|
||||
|
||||
$textarea.val(
|
||||
currentVal.slice(0, textarea.selectionStart) +
|
||||
leading +
|
||||
currentVal.slice(textarea.selectionStart, textarea.selectionEnd) +
|
||||
trailing +
|
||||
currentVal.slice(textarea.selectionEnd)
|
||||
);
|
||||
};
|
||||
|
||||
controls.updateTextareaSelection = function(textarea, start, end){
|
||||
textarea.setSelectionRange(start, end);
|
||||
$(textarea).focus();
|
||||
};
|
||||
|
||||
var formattingDispatchTable = {
|
||||
'fa fa-bold': function(textarea, selectionStart, selectionEnd){
|
||||
if(selectionStart === selectionEnd){
|
||||
|
||||
46
public/src/modules/composer/controls.js
vendored
Normal file
46
public/src/modules/composer/controls.js
vendored
Normal file
@@ -0,0 +1,46 @@
|
||||
"use strict";
|
||||
|
||||
/*global define*/
|
||||
|
||||
define(function() {
|
||||
var controls = {};
|
||||
|
||||
/*************************************************/
|
||||
/* Rich Textarea Controls */
|
||||
/*************************************************/
|
||||
controls.insertIntoTextarea = function(textarea, value) {
|
||||
var $textarea = $(textarea);
|
||||
var currentVal = $textarea.val();
|
||||
|
||||
$textarea.val(
|
||||
currentVal.slice(0, textarea.selectionStart) +
|
||||
value +
|
||||
currentVal.slice(textarea.selectionStart)
|
||||
);
|
||||
};
|
||||
|
||||
controls.wrapSelectionInTextareaWith = function(textarea, leading, trailing){
|
||||
if(trailing === undefined){
|
||||
trailing = leading;
|
||||
}
|
||||
|
||||
var $textarea = $(textarea);
|
||||
var currentVal = $textarea.val();
|
||||
|
||||
$textarea.val(
|
||||
currentVal.slice(0, textarea.selectionStart) +
|
||||
leading +
|
||||
currentVal.slice(textarea.selectionStart, textarea.selectionEnd) +
|
||||
trailing +
|
||||
currentVal.slice(textarea.selectionEnd)
|
||||
);
|
||||
};
|
||||
|
||||
controls.updateTextareaSelection = function(textarea, start, end){
|
||||
textarea.setSelectionRange(start, end);
|
||||
$(textarea).focus();
|
||||
};
|
||||
|
||||
|
||||
return controls;
|
||||
});
|
||||
Reference in New Issue
Block a user