77e2018afa663d899d92c531b0765fd395dddd83
[moodle.git] / mod / forum / amd / build / posts_list.min.js.map
1 {"version":3,"sources":["../src/posts_list.js"],"names":["define","$","Templates","Notification","Pending","Selectors","InPageReply","FormChangeChecker","registerEventListeners","root","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","render","then","html","js","appendNodeContents","slideToggle","resolve","focus","watchFormById","catch","exception","form","is","init"],"mappings":"AA0BAA,OAAM,wBAAC,CACH,QADG,CAEH,gBAFG,CAGH,mBAHG,CAIH,cAJG,CAKH,qBALG,CAMH,wBANG,CAOH,yBAPG,CAAD,CAQH,SACCC,CADD,CAECC,CAFD,CAGCC,CAHD,CAICC,CAJD,CAKCC,CALD,CAMCC,CAND,CAOCC,CAPD,CAQD,CAEE,GAAIC,CAAAA,CAAsB,CAAG,SAASC,CAAT,CAAe,CACxCA,CAAI,CAACC,EAAL,CAAQ,OAAR,CAAiBL,CAAS,CAACM,IAAV,CAAeC,eAAhC,CAAiD,SAASC,CAAT,CAAY,CACzDA,CAAC,CAACC,cAAF,GAMA,GAAIC,MAAM,CAACC,QAAP,CAAgBC,IAApB,CAA0B,CAEtB,GAAIC,CAAAA,CAAG,CAAGH,MAAM,CAACC,QAAP,CAAgBG,IAAhB,CAAqBC,KAArB,CAA2B,GAA3B,EAAgC,CAAhC,CAAV,CACAC,OAAO,CAACC,SAAR,CAAkB,EAAlB,CAAsBC,QAAQ,CAACC,KAA/B,CAAsCN,CAAtC,CACH,CAXwD,GAYrDO,CAAAA,CAAO,CAAG,GAAIrB,CAAAA,CAAJ,CAAY,cAAZ,CAZ2C,CAarDsB,CAAa,CAAGzB,CAAC,CAACY,CAAC,CAACa,aAAH,CAAD,CAAmBC,OAAnB,CAA2BtB,CAAS,CAAC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QKN,IARL,CAQU,UAAW,CACb1C,CAAiB,CAACiD,aAAlB,wBAAgDtB,CAAO,CAACC,MAAxD,EAEH,CAXL,EAYKsB,KAZL,CAYWtD,CAAY,CAACuD,SAZxB,CAaH,CAdD,IAcO,CACH,GAAIC,CAAAA,CAAI,CAAG3B,CAAW,CAACF,IAAZ,CAAiBzB,CAAS,CAACM,IAAV,CAAemC,kBAAhC,CAAX,CACAa,CAAI,CAACN,WAAL,CAAiB,GAAjB,CAAsB5B,CAAO,CAAC6B,OAA9B,EACA,GAAIK,CAAI,CAACC,EAAL,CAAQ,UAAR,CAAJ,CAAyB,CACrBD,CAAI,CAAC7B,IAAL,CAAU,UAAV,EAAsByB,KAAtB,EACH,CACJ,CACJ,CA9CD,CA+CH,CAhDD,CAkDA,MAAO,CACHM,IAAI,CAAE,cAASpD,CAAT,CAAe,CACjBD,CAAsB,CAACC,CAAD,CAAtB,CACAH,CAAW,CAACuD,IAAZ,CAAiBpD,CAAjB,CACH,CAJE,CAMV,CA1EK,CAAN","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) {\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            };\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) {\n            registerEventListeners(root);\n            InPageReply.init(root);\n        }\n    };\n});\n"],"file":"posts_list.min.js"}