Merge branch 'MDL-65516-master' of git://github.com/mihailges/moodle
This commit is contained in:
+1
-1
@@ -1 +1 @@
|
||||
define(["jquery","core/templates","core/notification","mod_forum/selectors","mod_forum/inpage_reply"],function(a,b,c,d,e){var f=function(e){e.on("click",d.post.inpageReplyLink,function(e){e.preventDefault();var f=a(e.currentTarget).parents(d.post.forumCoreContent),g=f.find(d.post.forumSubject),h=a(e.currentTarget).parents(d.post.forumContent),i={postid:a(h).data("post-id"),reply_url:a(e.currentTarget).attr("href"),sesskey:M.cfg.sesskey,parentsubject:g.html()};if(h.find(d.post.inpageReplyContent).length){var j=h.find(d.post.inpageReplyContent);j.toggle(),j.is(":visible")&&j.find("textarea").focus()}else b.render("mod_forum/inpage_reply",i).then(function(a,c){return b.appendNodeContents(f,a,c)}).then(function(){return h.find(d.post.inpageReplyContent).toggle().find("textarea").focus()}).fail(c.exception)})};return{init:function(a){f(a),e.init(a)}}});
|
||||
define(["jquery","core/templates","core/notification","mod_forum/selectors","mod_forum/inpage_reply"],function(a,b,c,d,e){var f=function(e){e.on("click",d.post.inpageReplyLink,function(e){if(e.preventDefault(),window.location.hash){var f=window.location.href.split("#")[0];history.pushState({},document.title,f)}var g=a(e.currentTarget).parents(d.post.forumCoreContent),h=g.find(d.post.forumSubject),i=a(e.currentTarget).parents(d.post.forumContent),j={postid:a(i).data("post-id"),reply_url:a(e.currentTarget).attr("href"),sesskey:M.cfg.sesskey,parentsubject:h.html()};if(i.find(d.post.inpageReplyContent).length){var k=i.find(d.post.inpageReplyContent);k.slideToggle(300),k.is(":visible")&&k.find("textarea").focus()}else b.render("mod_forum/inpage_reply",j).then(function(a,c){return b.appendNodeContents(g,a,c)}).then(function(){return i.find(d.post.inpageReplyContent).slideToggle(300).find("textarea").focus()}).fail(c.exception)})};return{init:function(a){f(a),e.init(a)}}});
|
||||
@@ -42,6 +42,16 @@ define([
|
||||
var registerEventListeners = function(root) {
|
||||
root.on('click', Selectors.post.inpageReplyLink, function(e) {
|
||||
e.preventDefault();
|
||||
// After adding a reply a url hash is being generated that scrolls (points) to the newly added reply.
|
||||
// The hash being present causes this scrolling behavior to the particular reply to persists even when
|
||||
// another, non-related in-page replay link is being clicked which ultimately causes a bad user experience.
|
||||
// A particular solution for this problem would be changing the browser's history state when a url hash is
|
||||
// present.
|
||||
if (window.location.hash) {
|
||||
// Remove the fragment identifier from the url.
|
||||
var url = window.location.href.split('#')[0];
|
||||
history.pushState({}, document.title, url);
|
||||
}
|
||||
var currentTarget = $(e.currentTarget).parents(Selectors.post.forumCoreContent);
|
||||
var currentSubject = currentTarget.find(Selectors.post.forumSubject);
|
||||
var currentRoot = $(e.currentTarget).parents(Selectors.post.forumContent);
|
||||
@@ -58,12 +68,12 @@ define([
|
||||
return Templates.appendNodeContents(currentTarget, html, js);
|
||||
})
|
||||
.then(function() {
|
||||
return currentRoot.find(Selectors.post.inpageReplyContent).toggle().find('textarea').focus();
|
||||
return currentRoot.find(Selectors.post.inpageReplyContent).slideToggle(300).find('textarea').focus();
|
||||
})
|
||||
.fail(Notification.exception);
|
||||
} else {
|
||||
var form = currentRoot.find(Selectors.post.inpageReplyContent);
|
||||
form.toggle();
|
||||
form.slideToggle(300);
|
||||
if (form.is(':visible')) {
|
||||
form.find('textarea').focus();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user