moving controls object into its own module

v1.18.x
psychobunny 11 years ago
parent 775e6ec8ce
commit 4b18403fa6

@ -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){

@ -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;
});
Loading…
Cancel
Save