diff --git a/blocks/comments/block_comments.php b/blocks/comments/block_comments.php index 979a8d82cb5..af88a4fbe68 100644 --- a/blocks/comments/block_comments.php +++ b/blocks/comments/block_comments.php @@ -47,6 +47,9 @@ class block_comments extends block_base { $args->env = 'block_comments'; $args->component = 'block_comments'; $args->linktext = get_string('showcomments'); + $args->notoggle = true; + $args->autostart = true; + $args->displaycancel = true; $comment = new comment($args); $comment->set_view_permission(true); diff --git a/comment/comment.js b/comment/comment.js index 604a939ca7b..2774ce6b9f1 100644 --- a/comment/comment.js +++ b/comment/comment.js @@ -41,8 +41,9 @@ M.core_comment = { this.courseid = args.courseid; this.contextid = args.contextid; this.env = args.env; + this.autostart = (args.autostart); // expand comments? - if (args.autostart) { + if (this.autostart) { this.view(args.page); } // load comments @@ -347,7 +348,7 @@ bodyContent: '
' . $this->template . '
'; + $html .= html_writer::tag('div', $this->template, array('style' => 'display:none', 'id' => 'cmt-tmpl')); $template_printed = true; } if (!empty($this->viewcap)) { // print commenting icon and tooltip - $icon = $OUTPUT->pix_url('t/collapsed'); - $html .= << -{$strshowcomments} -EOD; - if ($this->env != 'block_comments') { - $html .= << - {$this->linktext} - {$this->linktext} {$this->count} - -EOD; + $html .= html_writer::start_tag('div', array('class' => 'mdl-left')); + $html .= html_writer::link($this->get_nojslink($PAGE), get_string('showcommentsnonjs'), array('class' => 'showcommentsnonjs')); + + if (!$this->notoggle) { + // If toggling is enabled (notoggle=false) then print the controls to toggle + // comments open and closed + $html .= html_writer::start_tag('a', array('class' => 'comment-link', 'id' => 'comment-link-'.$this->cid, 'href' => '#')); + $html .= html_writer::empty_tag('img', array('id' => 'comment-img-'.$this->cid, 'src' => $OUTPUT->pix_url('t/collapsed'), 'alt' => $this->linktext, 'title' => $this->linktext)); + $html .= html_writer::tag('span', $this->linktext.' '.$this->count, array('id' => 'comment-link-text-'.$this->cid)); + $html .= html_writer::end_tag('a'); } - $html .= << - '; + $html .= html_writer::end_tag('ul'); // .comment-list $html .= $this->get_pagination(0); } else { - $html .= << -
-EOD; + $html .= html_writer::end_tag('ul'); // .comment-list + $html .= html_writer::tag('div', '', array('id' => 'comment-pagination-'.$this->cid, 'class' => 'comment-pagination')); } - // print posting textarea if (!empty($this->postcap)) { - $html .= << -
- -
-
- {$strsubmit} -EOD; - if ($this->env != 'block_comments') { - $html .= " | cid}\"> {$strcancel} "; + // print posting textarea + $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::end_tag('div'); // .db + + $html .= html_writer::start_tag('div', array('class' => 'fd', 'id' => 'comment-action-'.$this->cid)); + $html .= html_writer::link('#', get_string('savecomment'), array('id' => 'comment-action-post-'.$this->cid)); + + if ($this->displaycancel) { + $html .= html_writer::tag('span', ' | '); + $html .= html_writer::link('#', get_string('cancel'), array('id' => 'comment-action-cancel-'.$this->cid)); } - $html .= << -
-
-EOD; + + $html .= html_writer::end_tag('div'); // .fd + $html .= html_writer::end_tag('div'); // .comment-area + $html .= html_writer::tag('div', '', array('class' => 'clearer')); } - $html .= << - -EOD; + $html .= html_writer::end_tag('div'); // .comment-ctrl + $html .= html_writer::end_tag('div'); // .mdl-left } else { $html = ''; } @@ -457,11 +543,11 @@ EOD; $count = $this->count(); $pages = (int)ceil($count/$CFG->commentsperpage); if ($pages == 1 || $pages == 0) { - return ''; + return html_writer::tag('div', '', array('id' => 'comment-pagination-'.$this->cid, 'class' => 'comment-pagination')); } if (!empty(self::$nonjs)) { // used in non-js interface - return $OUTPUT->paging_bar($count, $page, $CFG->commentsperpage, $this->link, 'comment_page'); + return $OUTPUT->paging_bar($count, $page, $CFG->commentsperpage, $this->get_nojslink(), 'comment_page'); } else { // return ajax paging bar $str = '';