Skip to content

Commit

Permalink
MDL-22676 language customization: enlarge the input textarea fields
Browse files Browse the repository at this point in the history
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).
  • Loading branch information
mudrd8mz committed Dec 9, 2010
1 parent 424d60d commit fda6946
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 4 deletions.
2 changes: 1 addition & 1 deletion admin/report/customlang/edit.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
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
Expand Down
45 changes: 45 additions & 0 deletions admin/report/customlang/module.js
Original file line number Diff line number Diff line change
@@ -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'));
});
}
7 changes: 6 additions & 1 deletion admin/report/customlang/renderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,14 +76,19 @@ protected function render_report_customlang_translator(report_customlang_transla
$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'));
}
$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,
Expand Down
4 changes: 2 additions & 2 deletions admin/report/customlang/version.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,5 @@

defined('MOODLE_INTERNAL') || die();

$plugin->version = 2010111500;
$plugin->requires = 2010111002;
$plugin->version = 2010120900;
$plugin->requires = 2010120700;

0 comments on commit fda6946

Please sign in to comment.