mirror of
https://github.com/moodle/moodle.git
synced 2025-01-18 22:08:20 +01:00
"MDL-21170, fixed form conflict"
This commit is contained in:
parent
277e785d95
commit
7e7d2e64f2
@ -48,27 +48,17 @@ M.core_comment = (function(){
|
||||
this.view(0);
|
||||
return false;
|
||||
}, this);
|
||||
Y.one('#comment-action-cancel'+this.client_id).on('click', function(e) {
|
||||
e.preventDefault();
|
||||
this.view(0);
|
||||
return false;
|
||||
}, this);
|
||||
// add new comment
|
||||
Y.one('#comment-action-post-'+this.client_id).on('click', function(e) {
|
||||
e.preventDefault();
|
||||
this.post();
|
||||
return false;
|
||||
}, this);
|
||||
},
|
||||
post: function() {
|
||||
var ta = Y.one('#dlg-content-'+this.client_id);
|
||||
var scope = this;
|
||||
var value = ta.get('value');
|
||||
if (value && value != mstr.moodle.addcomment) {
|
||||
var params = {'content': value};
|
||||
this.request({
|
||||
action: 'add',
|
||||
scope: scope,
|
||||
form: {id:'comment-form-'+this.client_id},
|
||||
params: params,
|
||||
callback: function(id, obj, args) {
|
||||
var scope = args.scope;
|
||||
var cid = scope.client_id;
|
||||
@ -129,7 +119,13 @@ M.core_comment = (function(){
|
||||
return;
|
||||
}
|
||||
var data = json_decode(o.responseText);
|
||||
args.callback(id,data,p);
|
||||
if (data.error) {
|
||||
alert(data.error);
|
||||
return false;
|
||||
} else {
|
||||
args.callback(id,data,p);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
},
|
||||
arguments: {
|
||||
@ -223,6 +219,20 @@ M.core_comment = (function(){
|
||||
}
|
||||
}, true);
|
||||
},
|
||||
register_actions: function() {
|
||||
// add new comment
|
||||
Y.one('#comment-action-post-'+this.client_id).on('click', function(e) {
|
||||
e.preventDefault();
|
||||
this.post();
|
||||
return false;
|
||||
}, this);
|
||||
// cancel comment box
|
||||
Y.one('#comment-action-cancel-'+this.client_id).on('click', function(e) {
|
||||
e.preventDefault();
|
||||
this.view(0);
|
||||
return false;
|
||||
}, this);
|
||||
},
|
||||
register_delete_buttons: function() {
|
||||
var scope = this;
|
||||
// page buttons
|
||||
@ -282,6 +292,7 @@ M.core_comment = (function(){
|
||||
ta.on('blur', function() {
|
||||
this.toggle_textarea(false);
|
||||
}, this);
|
||||
this.register_actions();
|
||||
return false;
|
||||
},
|
||||
toggle_textarea: function(focus) {
|
||||
|
@ -316,18 +316,7 @@ EOD;
|
||||
$html .= <<<EOD
|
||||
<div class='comment-area'>
|
||||
<div class="bd">
|
||||
<form method="post" id="comment-form-{$this->cid}" action="{$CFG->wwwroot}/comment/comment_post.php">
|
||||
<div>
|
||||
<textarea name="content" rows="1" id="dlg-content-{$this->cid}"></textarea>
|
||||
<input type="hidden" name="contextid" value="$this->contextid" />
|
||||
<input type="hidden" name="action" value="add" />
|
||||
<input type="hidden" name="area" value="$this->commentarea" />
|
||||
<input type="hidden" name="itemid" value="$this->itemid" />
|
||||
<input type="hidden" name="courseid" value="{$this->course->id}" />
|
||||
<input type="hidden" name="sesskey" value="{$sesskey}" />
|
||||
<input type="hidden" name="client_id" value="$this->cid" />
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
<div class="fd" id="comment-action-{$this->cid}">
|
||||
<a href="###" id="comment-action-post-{$this->cid}"> {$strsubmit} </a>
|
||||
|
Loading…
x
Reference in New Issue
Block a user