MDL-22676 language customization: enlarge the input textarea fields
This patch combines the solution submitted by Ray Guo (computed min-height) and the one used in AMOS (set the height of the textarea so that it takes all available space in the row).
This commit is contained in:
@@ -38,7 +38,7 @@ $PAGE->set_url('/admin/report/customlang/edit.php', array('lng' => $lng));
|
||||
navigation_node::override_active_url(new moodle_url('/admin/report/customlang/index.php'));
|
||||
$PAGE->set_title(get_string('pluginname', 'report_customlang'));
|
||||
$PAGE->set_heading(get_string('pluginname', 'report_customlang'));
|
||||
//$PAGE->requires->js_init_call('M.report_customlang.init_translator', array(), true);
|
||||
$PAGE->requires->js_init_call('M.report_customlang.init_editor', array(), true);
|
||||
|
||||
if (empty($lng)) {
|
||||
// PARAM_LANG validation failed
|
||||
|
||||
@@ -0,0 +1,45 @@
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* @package report
|
||||
* @subpackage customlang
|
||||
* @copyright 2010 David Mudrak <[email protected]>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
/**
|
||||
* @namespace
|
||||
*/
|
||||
M.report_customlang = M.report_customlang || {};
|
||||
|
||||
/**
|
||||
* YUI instance holder
|
||||
*/
|
||||
M.report_customlang.Y = {};
|
||||
|
||||
/**
|
||||
* Initialize JS support for the edit.php
|
||||
*
|
||||
* @param {Object} Y YUI instance
|
||||
*/
|
||||
M.report_customlang.init_editor = function(Y) {
|
||||
M.report_customlang.Y = Y;
|
||||
|
||||
Y.all('#translator .local textarea').each(function (textarea) {
|
||||
var cell = textarea.get('parentNode');
|
||||
textarea.setStyle('height', cell.getComputedStyle('height'));
|
||||
});
|
||||
}
|
||||
@@ -76,6 +76,7 @@ class report_customlang_renderer extends plugin_renderer_base {
|
||||
$cells[1]->attributes['class'] = 'stringid';
|
||||
// master translation of the string
|
||||
$master = html_writer::tag('div', s($string->master), array('class' => 'preformatted'));
|
||||
$minheight = strlen($string->master) / 200;
|
||||
if (preg_match('/\{\$a(->.+)?\}/', $string->master)) {
|
||||
$master .= html_writer::tag('div', $this->help_icon('placeholder', 'report_customlang',
|
||||
get_string('placeholderwarning', 'report_customlang')), array('class' => 'placeholderinfo'));
|
||||
@@ -83,7 +84,11 @@ class report_customlang_renderer extends plugin_renderer_base {
|
||||
$cells[2] = new html_table_cell($master);
|
||||
$cells[2]->attributes['class'] = 'standard master';
|
||||
// local customization of the string
|
||||
$textarea = html_writer::tag('textarea', s($string->local), array('name'=>'cust['.$string->id.']'));
|
||||
$textareaattributes = array('name'=>'cust['.$string->id.']', 'cols'=>40, 'rows'=>3);
|
||||
if ($minheight>1) {
|
||||
$textareaattributes['style'] = 'min-height:' . (int) 4*$minheight . 'em;';
|
||||
}
|
||||
$textarea = html_writer::tag('textarea', s($string->local), $textareaattributes);
|
||||
$cells[3] = new html_table_cell($textarea);
|
||||
if (!is_null($string->local) and $string->outdated) {
|
||||
$mark = html_writer::empty_tag('input', array('type' => 'checkbox', 'id' => 'update_' . $string->id,
|
||||
|
||||
@@ -24,5 +24,5 @@
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
$plugin->version = 2010111500;
|
||||
$plugin->requires = 2010111002;
|
||||
$plugin->version = 2010120900;
|
||||
$plugin->requires = 2010120700;
|
||||
|
||||
Reference in New Issue
Block a user