Skip to content

Commit

Permalink
MDL-48206 block_comments: textarea width 100%
Browse files Browse the repository at this point in the history
  • Loading branch information
Sam Hemelryk committed Nov 13, 2014
1 parent c106341 commit 2ff98fb
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 2 deletions.
1 change: 1 addition & 0 deletions blocks/comments/block_comments.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ function get_content() {
$args->displaycancel = false;
$comment = new comment($args);
$comment->set_view_permission(true);
$comment->set_fullwidth();

$this->content = new stdClass();
$this->content->text = $comment->output(true);
Expand Down
29 changes: 28 additions & 1 deletion comment/lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,12 @@ class comment {
/** @var int The number of comments associated with this comments params */
protected $totalcommentcount = null;

/**
* Set to true to remove the col attribute from the textarea making it full width.
* @var bool
*/
protected $fullwidth = false;

/** @var bool Use non-javascript UI */
private static $nonjs = false;
/** @var int comment itemid used in non-javascript UI */
Expand Down Expand Up @@ -459,9 +465,20 @@ public function output($return = true) {

if ($this->can_post()) {
// print posting textarea
$textareaattrs = array(
'name' => 'content',
'rows' => 2,
'id' => 'dlg-content-'.$this->cid
);
if (!$this->fullwidth) {
$textareaattrs['cols'] = '20';
} else {
$textareaattrs['class'] = 'fullwidth';
}

$html .= html_writer::start_tag('div', array('class' => 'comment-area'));
$html .= html_writer::start_tag('div', array('class' => 'db'));
$html .= html_writer::tag('textarea', '', array('name' => 'content', 'rows' => 2, 'cols' => 20, 'id' => 'dlg-content-'.$this->cid));
$html .= html_writer::tag('textarea', '', $textareaattrs);
$html .= html_writer::end_tag('div'); // .db

$html .= html_writer::start_tag('div', array('class' => 'fd', 'id' => 'comment-action-'.$this->cid));
Expand Down Expand Up @@ -945,6 +962,16 @@ public function get_itemid() {
public function get_commentarea() {
return $this->commentarea;
}

/**
* Make the comments textarea fullwidth.
*
* @since 2.8.1 + 2.7.4
* @param bool $fullwidth
*/
public function set_fullwidth($fullwidth = true) {
$this->fullwidth = (bool)$fullwidth;
}
}

/**
Expand Down
1 change: 1 addition & 0 deletions theme/base/style/core.css
Original file line number Diff line number Diff line change
Expand Up @@ -680,6 +680,7 @@ table.mod_index {width:100%;}
.comment-ctrl h5 {margin:0;padding: 5px;}
.comment-area {max-width: 400px;padding: 5px;}
.comment-area textarea {width:100%;overflow:auto;}
.comment-area textarea.fullwidth {-webkit-box-sizing: border-box; -moz-box-sizing: border-box; box-sizing: border-box;}
.comment-area .fd {text-align:right;}
.comment-meta span {color:gray;}
.comment-link img { vertical-align: text-bottom; }
Expand Down
5 changes: 5 additions & 0 deletions theme/bootstrapbase/less/moodle/core.less
Original file line number Diff line number Diff line change
Expand Up @@ -590,6 +590,11 @@ table.mod_index {
.comment-area textarea {
width: 100%;
overflow: auto;
&.fullwidth {
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
}
}
.comment-area .fd {
text-align: right;
Expand Down
2 changes: 1 addition & 1 deletion theme/bootstrapbase/style/moodle.css

Large diffs are not rendered by default.

0 comments on commit 2ff98fb

Please sign in to comment.