Skip to content

Node.js based forum software built for the modern web

moving controls object into its own module

psychobunny4b18403fa626
diff --git a/public/src/modules/composer.js b/public/src/modules/composer.js
index a9b6d332cc..bd97c20b29 100644
--- a/public/src/modules/composer.js
+++ b/public/src/modules/composer.js
@@ -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){
diff --git a/public/src/modules/composer/controls.js b/public/src/modules/composer/controls.js
new file mode 100644
index 0000000000..ca6c436972
--- /dev/null
+++ b/public/src/modules/composer/controls.js
@@ -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;
+});
\ No newline at end of file