{"version":3,"file":"browser_storage.min.js","sources":["https:\/\/kundenportal.comm-unity.at\/course\/format\/tiles\/amd\/src\/browser_storage.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 .\n\n\/**\n * Javascript Module to handle browser storage for format_tiles for student view.\n * (Can also be used by staff when they view the student view).\n * Stores and retrieves course content and settings\n * e.g. which filter button do I have pressed\n *\n * @module format_tiles\/browser_storage\n * @copyright 2018 David Watson {@link http:\/\/evolutioncode.uk}\n * @license http:\/\/www.gnu.org\/copyleft\/gpl.html GNU GPL v3 or later\n * @since Moodle 3.3\n *\/\n\n\/* eslint space-before-function-paren: 0 *\/\n\ndefine([\"jquery\", \"format_tiles\/browser_storage_set_up\"], function ($, storageSetUp) {\n \"use strict\";\n\n var courseId;\n var userId;\n\n var localStorageKeyElements = {\n prefix: \"mdl-tiles-\",\n course: \"mdl-tiles-course-\",\n lastSection: \"-lastSecId\",\n content: \"-content\",\n lastUpdated: \"-lastUpdated\",\n collapseSecZero: \"-collapsesec0\",\n user: \"-user-\",\n section: \"-sec-\",\n userChoicePrefix: \"mdl-tiles-userPrefStorage-\"\n };\n\n \/**\n * The last visited section number will be stored with a key in the format\n * mdl-tiles-course-[courseid]-lastSecId\n * @returns {string} the key to use for this course\n *\/\n var encodeLastVistedSectionKeyName = function() {\n return localStorageKeyElements.course + courseId\n + localStorageKeyElements.user + userId\n + localStorageKeyElements.lastSection;\n };\n\n \/**\n * Whether or not section zero is collapsed for this course\/user\n * will be stored with a key in this format\n * @returns {string} the key to use\n *\/\n var collapseSecZeroKey = function() {\n return localStorageKeyElements.course + courseId\n + localStorageKeyElements.user + userId\n + localStorageKeyElements.collapseSecZero;\n };\n\n \/**\n * Set the last visited section for the user for this course\n * Used to reload that section on next visit\n * Data is just an integer for section if\n * Uses local storage not session storage so that it persists\n * @param {number} sectionNum the section number last visited\n *\/\n var setLastVisitedSection = function (sectionNum) {\n if (sectionNum && storageSetUp.Enabled.local) {\n localStorage.setItem(encodeLastVistedSectionKeyName(), sectionNum.toString());\n } else {\n localStorage.removeItem(encodeLastVistedSectionKeyName());\n }\n };\n\n return {\n\n init: function (\n course,\n isEditing,\n sectionNum,\n assumeDataStoreConsent,\n user\n ) {\n courseId = course.toString();\n userId = user.toString();\n storageSetUp.init(userId, assumeDataStoreConsent);\n\n $(document).ready(function () {\n if (isEditing) {\n \/\/ Teacher is editing now so not using JS nav but set their current section for when they stop editing.\n setLastVisitedSection(sectionNum);\n }\n });\n },\n\n storageEnabledSession: function () {\n return storageSetUp.Enabled.session;\n },\n storageEnabledLocal: function () {\n return storageSetUp.Enabled.local;\n },\n\n \/**\n * Get the user's last visited section id for this course\n * @return {string|null} the section ID or null if none stored\n *\/\n getLastVisitedSection: function () {\n return storageSetUp.Enabled.local && localStorage.getItem(encodeLastVistedSectionKeyName());\n },\n\n \/**\n * When user collapsed or expands section zero, record their choice in localStorage so\n * that it can be applied next time they visit\n * @param {string} status to be applied\n *\/\n setSecZeroCollapseStatus: function (status) {\n if (storageSetUp.Enabled.local && storageSetUp.storageAllowed()) {\n if (status === \"collapsed\") {\n localStorage.removeItem(collapseSecZeroKey());\n } else {\n localStorage.setItem(collapseSecZeroKey(), \"1\");\n }\n }\n },\n \/**\n * Get the last status of section zero for the present course from localStorage\n * @returns {boolean} whether collapsed or not\n *\/\n getSecZeroCollapseStatus: function () {\n return !!localStorage.getItem(collapseSecZeroKey());\n },\n\n setLastVisitedSection: function (sectionNum) {\n \/\/ Return object (\"public\") access to the \"private\" method above.\n if (storageSetUp.storageAllowed()) {\n setLastVisitedSection(sectionNum);\n } else {\n setLastVisitedSection(null);\n }\n }\n };\n});"],"names":["define","$","storageSetUp","courseId","userId","localStorageKeyElements","encodeLastVistedSectionKeyName","collapseSecZeroKey","setLastVisitedSection","sectionNum","Enabled","local","localStorage","setItem","toString","removeItem","init","course","isEditing","assumeDataStoreConsent","user","document","ready","storageEnabledSession","session","storageEnabledLocal","getLastVisitedSection","getItem","setSecZeroCollapseStatus","status","storageAllowed","getSecZeroCollapseStatus"],"mappings":";;;;;;;;;;;AA6BAA,sCAAO,CAAC,SAAU,wCAAwC,SAAUC,EAAGC,kBAG\/DC,SACAC,OAEAC,+BAEQ,oBAFRA,oCAGa,aAHbA,wCAMiB,gBANjBA,6BAOM,SAUNC,+BAAiC,kBAC1BD,+BAAiCF,SAClCE,6BAA+BD,OAC\/BC,qCAQNE,mBAAqB,kBACdF,+BAAiCF,SAClCE,6BAA+BD,OAC\/BC,yCAUNG,sBAAwB,SAAUC,YAC9BA,YAAcP,aAAaQ,QAAQC,MACnCC,aAAaC,QAAQP,iCAAkCG,WAAWK,YAElEF,aAAaG,WAAWT,yCAIzB,CAEHU,KAAM,SACFC,OACAC,UACAT,WACAU,uBACAC,MAEAjB,SAAWc,OAAOH,WAClBV,OAASgB,KAAKN,WACdZ,aAAac,KAAKZ,OAAQe,wBAE1BlB,EAAEoB,UAAUC,OAAM,WACVJ,WAEAV,sBAAsBC,gBAKlCc,sBAAuB,kBACZrB,aAAaQ,QAAQc,SAEhCC,oBAAqB,kBACVvB,aAAaQ,QAAQC,OAOhCe,sBAAuB,kBACZxB,aAAaQ,QAAQC,OAASC,aAAae,QAAQrB,mCAQ9DsB,yBAA0B,SAAUC,QAC5B3B,aAAaQ,QAAQC,OAAST,aAAa4B,mBAC5B,cAAXD,OACAjB,aAAaG,WAAWR,sBAExBK,aAAaC,QAAQN,qBAAsB,OAQvDwB,yBAA0B,mBACbnB,aAAae,QAAQpB,uBAGlCC,sBAAuB,SAAUC,YAEzBP,aAAa4B,iBACbtB,sBAAsBC,YAEtBD,sBAAsB"}