Proyectos de Subversion Moodle

Rev

Autoría | Ultima modificación | Ver Log |

{"version":3,"file":"posts_list.min.js","sources":["../src/posts_list.js"],"sourcesContent":["// This file is part of Moodle - http://moodle.org/\n//\n// Moodle is free software: you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// Moodle is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with Moodle.  If not, see <http://www.gnu.org/licenses/>.\n\n/**\n * This module is the highest level module for the calendar. It is\n * responsible for initialising all of the components required for\n * the calendar to run. It also coordinates the interaction between\n * components by listening for and responding to different events\n * triggered within the calendar UI.\n *\n * @module     mod_forum/posts_list\n * @copyright  2019 Peter Dias\n * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\ndefine([\n    'jquery',\n    'core/templates',\n    'core/notification',\n    'core/pending',\n    'mod_forum/selectors',\n    'mod_forum/inpage_reply',\n    'core_form/changechecker',\n], function(\n    $,\n    Templates,\n    Notification,\n    Pending,\n    Selectors,\n    InPageReply,\n    FormChangeChecker\n) {\n\n    var registerEventListeners = function(root, throttlingwarningmsg) {\n        root.on('click', Selectors.post.inpageReplyLink, function(e) {\n            e.preventDefault();\n            // After adding a reply a url hash is being generated that scrolls (points) to the newly added reply.\n            // The hash being present causes this scrolling behavior to the particular reply to persists even when\n            // another, non-related in-page replay link is being clicked which ultimately causes a bad user experience.\n            // A particular solution for this problem would be changing the browser's history state when a url hash is\n            // present.\n            if (window.location.hash) {\n                // Remove the fragment identifier from the url.\n                var url = window.location.href.split('#')[0];\n                history.pushState({}, document.title, url);\n            }\n            var pending = new Pending('inpage-reply');\n            var currentTarget = $(e.currentTarget).parents(Selectors.post.forumCoreContent);\n            var currentSubject = currentTarget.find(Selectors.post.forumSubject);\n            var currentRoot = $(e.currentTarget).parents(Selectors.post.forumContent);\n            var context = {\n                postid: $(currentRoot).data('post-id'),\n                \"reply_url\": $(e.currentTarget).attr('href'),\n                sesskey: M.cfg.sesskey,\n                parentsubject: currentSubject.data('replySubject'),\n                canreplyprivately: $(e.currentTarget).data('can-reply-privately'),\n                postformat: InPageReply.CONTENT_FORMATS.MOODLE,\n                throttlingwarningmsg: throttlingwarningmsg\n            };\n\n            if (!currentRoot.find(Selectors.post.inpageReplyContent).length) {\n                Templates.render('mod_forum/inpage_reply', context)\n                    .then(function(html, js) {\n                        return Templates.appendNodeContents(currentTarget, html, js);\n                    })\n                    .then(function() {\n                        return currentRoot.find(Selectors.post.inpageReplyContent)\n                            .slideToggle(300, pending.resolve).find('textarea').focus();\n                    })\n                    .then(function() {\n                        FormChangeChecker.watchFormById(`inpage-reply-${context.postid}`);\n                        return;\n                    })\n                    .catch(Notification.exception);\n            } else {\n                var form = currentRoot.find(Selectors.post.inpageReplyContent);\n                form.slideToggle(300, pending.resolve);\n                if (form.is(':visible')) {\n                    form.find('textarea').focus();\n                }\n            }\n        });\n    };\n\n    return {\n        init: function(root, throttlingwarningmsg) {\n            registerEventListeners(root, throttlingwarningmsg);\n            InPageReply.init(root);\n        }\n    };\n});\n"],"names":["define","$","Templates","Notification","Pending","Selectors","InPageReply","FormChangeChecker","init","root","throttlingwarningmsg","on","post","inpageReplyLink","e","preventDefault","window","location","hash","url","href","split","history","pushState","document","title","pending","currentTarget","parents","forumCoreContent","currentSubject","find","forumSubject","currentRoot","forumContent","context","postid","data","attr","sesskey","M","cfg","parentsubject","canreplyprivately","postformat","CONTENT_FORMATS","MOODLE","inpageReplyContent","length","form","slideToggle","resolve","is","focus","render","then","html","js","appendNodeContents","watchFormById","catch","exception","registerEventListeners"],"mappings":";;;;;;;;;;;AA0BAA,8BAAO,CACH,SACA,iBACA,oBACA,eACA,sBACA,yBACA,4BACD,SACCC,EACAC,UACAC,aACAC,QACAC,UACAC,YACAC,yBAsDO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