Commit 688a5063 authored by Richard Mansfield's avatar Richard Mansfield
Browse files

Add option for larger editor in text box block config (work around bug #530656)


Signed-off-by: default avatarRichard Mansfield <richard.mansfield@catalyst.net.nz>
parent fc7e760b
......@@ -72,12 +72,13 @@ class PluginBlocktypeTextbox extends SystemBlocktype {
public static function instance_config_form($instance) {
$configdata = $instance->get('configdata');
$h = param_integer('cfheight', 0);
return array(
'text' => array(
'type' => 'wysiwyg',
'title' => get_string('blockcontent', 'blocktype.textbox'),
'width' => '90%',
'height' => '150px',
'width' => '100%',
'height' => ($h ? $h * 0.7 : 150) . 'px',
'defaultvalue' => isset($configdata['text']) ? $configdata['text'] : '',
),
);
......
......@@ -295,6 +295,11 @@ function ViewManager() {
var contentDiv = getFirstElementByTagAndClassName('div', 'blockinstance-content', blockinstance);
var pd = {'id': $('viewid').value, 'change': 1};
if (config.blockeditormaxwidth) {
// Shouldn't have to pass browser window dimensions here, but can't find
// another way to get tinymce elements to use up the available height.
pd['cfheight'] = getViewportDimensions().h - 100;
}
pd[getNodeAttribute(button, 'name')] = 1;
var oldContent = contentDiv.innerHTML;
......@@ -374,10 +379,26 @@ function ViewManager() {
var d = getElementDimensions(newblock);
var vpdim = getViewportDimensions();
var newtop = getViewportPosition().y + Math.max((vpdim.h - d.h) / 2, 5);
var h = Math.max(d.h, 200);
if (config.blockeditormaxwidth && getFirstElementByTagAndClassName('textarea', 'wysiwyg', newblock)) {
var w = vpdim.w - (h > vpdim.h ? 80 : 50);
}
else {
var w = Math.max(d.w, 500);
}
var tborder = parseFloat(getStyle(newblock, 'border-top-width'));
var tpadding = parseFloat(getStyle(newblock, 'padding-top'));
var newtop = getViewportPosition().y + Math.max((vpdim.h - h) / 2 - tborder - tpadding, 5);
var lborder = parseFloat(getStyle(newblock, 'border-left-width'));
var lpadding = parseFloat(getStyle(newblock, 'padding-left'));
setStyle(newblock, {
'width': d.w + 'px',
'left': (vpdim.w - d.w) / 2 + 'px',
'width': w + 'px',
'height': h + 'px',
'left': ((vpdim.w - w) / 2 - lborder - lpadding) + 'px',
'top': newtop + 'px',
'position': 'absolute',
'z-index': 1
......@@ -1005,6 +1026,9 @@ function ViewManager() {
'change': 1,
'blocktype': getFirstElementByTagAndClassName('input', 'blocktype-radio', self.currentlyMovingObject).value
};
if (config.blockeditormaxwidth) {
pd['cfheight'] = getViewportDimensions().h - 100;
}
pd['action_addblocktype_column_' + whereTo['column'] + '_order_' + whereTo['order']] = true;
sendjsonrequest(config['wwwroot'] + 'view/blocks.json.php', pd, 'POST', function(data) {
var div = DIV();
......
......@@ -224,6 +224,10 @@ html>body #column-container {
padding: 1em;
}
.blockinstance.configure .mceEditor {
width: 100%;
}
/* header */
.blockinstance-header {
width: 100%;
......
......@@ -198,6 +198,9 @@ $smarty->assign('category', $category);
$smarty->assign('new', $new);
$smarty->assign('profile', $profile);
$smarty->assign('dashboard', $dashboard);
if (get_config('blockeditormaxwidth')) {
$smarty->assign('INLINEJAVASCRIPT', 'config.blockeditormaxwidth = true;');
}
$viewid = $view->get('id');
$viewtype = $view->get('type');
$viewtitle = $view->get('title');
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment