Proyectos de Subversion Moodle

Rev

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

{"version":3,"file":"view_dates.min.js","sources":["../src/view_dates.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 * Manage the timeline dates view for the timeline block.\n *\n * @copyright  2018 Ryan Wyllie <ryan@moodle.com>\n * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\n\ndefine(\n[\n    'jquery',\n    'block_timeline/event_list',\n    'core/pubsub',\n    'core/paged_content_events'\n],\nfunction(\n    $,\n    EventList,\n    PubSub,\n    PagedContentEvents\n) {\n\n    var SELECTORS = {\n        EVENT_LIST_CONTAINER: '[data-region=\"event-list-container\"]',\n        NO_COURSES_EMPTY_MESSAGE: '[data-region=\"no-courses-empty-message\"]',\n    };\n\n    /**\n     * Setup the listeners for the timeline block\n     *\n     * @param {string} root view dates container\n     * @param {string} namespace The namespace for the paged content\n     */\n    var registerEventListeners = function(root, namespace) {\n        var event = namespace + PagedContentEvents.SET_ITEMS_PER_PAGE_LIMIT;\n        PubSub.subscribe(event, function(limit) {\n            $(root).data('limit', limit);\n        });\n    };\n\n    /**\n     * Initialise the event list and being loading the events.\n     *\n     * @param {object} root The root element for the timeline dates view.\n     */\n    var load = function(root) {\n\n        if (!root.find(SELECTORS.NO_COURSES_EMPTY_MESSAGE).length) {\n            var eventListContainer = root.find(SELECTORS.EVENT_LIST_CONTAINER);\n            var namespace = $(eventListContainer).attr('id') + \"user_block_timeline\" + Math.random();\n            registerEventListeners(root, namespace);\n\n            var config = {\n                persistentLimitKey: \"block_timeline_user_limit_preference\",\n                eventNamespace: namespace\n            };\n            EventList.init(eventListContainer, config);\n        }\n    };\n\n    /**\n     * Initialise the timeline dates view. Begin loading the events\n     * if this view is active.\n     *\n     * @param {object} root The root element for the timeline courses view.\n     */\n    var init = function(root) {\n        root = $(root);\n\n        // Only need to handle events loading if the user is actively enrolled in a course and this view is active.\n        if (root.hasClass('active') && !root.find(SELECTORS.NO_COURSES_EMPTY_MESSAGE).length) {\n            load(root);\n            root.attr('data-seen', true);\n        }\n    };\n\n    /**\n     * Reset the view back to it's initial state. If this view is active then\n     * beging loading the events.\n     *\n     * @param {object} root The root element for the timeline courses view.\n     */\n    var reset = function(root) {\n        root.removeAttr('data-seen');\n        if (root.hasClass('active')) {\n            load(root);\n            root.attr('data-seen', true);\n        }\n    };\n\n    /**\n     * Load the events if this is the first time the view is displayed.\n     *\n     * @param {object} root The root element for the timeline courses view.\n     */\n    var shown = function(root) {\n        if (!root.attr('data-seen')) {\n            load(root);\n            root.attr('data-seen', true);\n        }\n    };\n\n    return {\n        init: init,\n        reset: reset,\n        shown: shown\n    };\n});\n"],"names":["define","$","EventList","PubSub","PagedContentEvents","SELECTORS","load","root","find","length","eventListContainer","namespace","attr","Math","random","event","SET_ITEMS_PER_PAGE_LIMIT","subscribe","limit","data","registerEventListeners","config","persistentLimitKey","eventNamespace","init","hasClass","reset","removeAttr","shown"],"mappings":";;;;;;AAsBAA,mCACA,CACI,SACA,4BACA,cACA,8BAEJ,SACIC,EACAC,UACAC,OACAC,wBAGIC,+BACsB,uCADtBA,mCAE0B,2CAqB1BC,KAAO,SAASC,UAEXA,KAAKC,KAAKH,oCAAoCI,OAAQ,KACnDC,mBAAqBH,KAAKC,KAAKH,gCAC/BM,UAAYV,EAAES,oBAAoBE,KAAK,MAAQ,sBAAwBC,KAAKC,UAhB3D,SAASP,KAAMI,eACpCI,MAAQJ,UAAYP,mBAAmBY,yBAC3Cb,OAAOc,UAAUF,OAAO,SAASG,OAC7BjB,EAAEM,MAAMY,KAAK,QAASD,UActBE,CAAuBb,KAAMI,eAEzBU,OAAS,CACTC,mBAAoB,uCACpBC,eAAgBZ,WAEpBT,UAAUsB,KAAKd,mBAAoBW,gBA8CpC,CACHG,KArCO,SAASjB,OAChBA,KAAON,EAAEM,OAGAkB,SAAS,YAAclB,KAAKC,KAAKH,oCAAoCI,SAC1EH,KAAKC,MACLA,KAAKK,KAAK,aAAa,KAgC3Bc,MAtBQ,SAASnB,MACjBA,KAAKoB,WAAW,aACZpB,KAAKkB,SAAS,YACdnB,KAAKC,MACLA,KAAKK,KAAK,aAAa,KAmB3BgB,MAVQ,SAASrB,MACZA,KAAKK,KAAK,eACXN,KAAKC,MACLA,KAAKK,KAAK,aAAa"}