Proyectos de Subversion Moodle

Rev

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

{"version":3,"file":"notification_repository.min.js","sources":["../src/notification_repository.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 * Retrieves notifications from the server.\n *\n * @module     message_popup/notification_repository\n * @copyright  2016 Ryan Wyllie <ryan@moodle.com>\n * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\ndefine(['core/ajax', 'core/notification'], function(Ajax, Notification) {\n    /**\n     * Retrieve a list of notifications from the server.\n     *\n     * @param {object} args The request arguments\n     * @return {object} jQuery promise\n     */\n    var query = function(args) {\n        if (typeof args.limit === 'undefined') {\n            args.limit = 20;\n        }\n\n        if (typeof args.offset === 'undefined') {\n            args.offset = 0;\n        }\n\n        var request = {\n            methodname: 'message_popup_get_popup_notifications',\n            args: args\n        };\n\n        var promise = Ajax.call([request])[0];\n\n        promise.fail(Notification.exception);\n\n        return promise;\n    };\n\n    /**\n     * Get the number of unread notifications from the server.\n     *\n     * @param {object} args The request arguments\n     * @return {object} jQuery promise\n     */\n    var countUnread = function(args) {\n        var request = {\n            methodname: 'message_popup_get_unread_popup_notification_count',\n            args: args\n        };\n\n        var promise = Ajax.call([request])[0];\n\n        promise.fail(Notification.exception);\n\n        return promise;\n    };\n\n    /**\n     * Mark all notifications for the given user as read.\n     *\n     * @param {object} args The request arguments:\n     * @return {object} jQuery promise\n     */\n    var markAllAsRead = function(args) {\n        var request = {\n            methodname: 'core_message_mark_all_notifications_as_read',\n            args: args\n        };\n\n        var promise = Ajax.call([request])[0];\n\n        promise.fail(Notification.exception);\n\n        return promise;\n    };\n\n    /**\n     * Mark a specific notification as read.\n     *\n     * @param {int} id The notification id\n     * @param {int} timeread The read timestamp (optional)\n     * @return {object} jQuery promise\n     */\n    var markAsRead = function(id, timeread) {\n        var args = {\n            notificationid: id,\n        };\n\n        if (timeread) {\n            args.timeread = timeread;\n        }\n\n        var request = {\n            methodname: 'core_message_mark_notification_read',\n            args: args\n        };\n\n        var promise = Ajax.call([request])[0];\n\n        promise.fail(Notification.exception);\n\n        return promise;\n    };\n\n    return {\n        query: query,\n        countUnread: countUnread,\n        markAllAsRead: markAllAsRead,\n        markAsRead: markAsRead,\n    };\n});\n"],"names":["define","Ajax","Notification","query","args","limit","offset","request","methodname","promise","call","fail","exception","countUnread","markAllAsRead","markAsRead","id","timeread","notificationid"],"mappings":";;;;;;;AAsBAA,+CAAO,CAAC,YAAa,sBAAsB,SAASC,KAAMC,oBA8F/C,CACHC,MAxFQ,SAASC,WACS,IAAfA,KAAKC,QACZD,KAAKC,MAAQ,SAGU,IAAhBD,KAAKE,SACZF,KAAKE,OAAS,OAGdC,QAAU,CACVC,WAAY,wCACZJ,KAAMA,MAGNK,QAAUR,KAAKS,KAAK,CAACH,UAAU,UAEnCE,QAAQE,KAAKT,aAAaU,WAEnBH,SAuEPI,YA9Dc,SAAST,UACnBG,QAAU,CACVC,WAAY,oDACZJ,KAAMA,MAGNK,QAAUR,KAAKS,KAAK,CAACH,UAAU,UAEnCE,QAAQE,KAAKT,aAAaU,WAEnBH,SAqDPK,cA5CgB,SAASV,UACrBG,QAAU,CACVC,WAAY,8CACZJ,KAAMA,MAGNK,QAAUR,KAAKS,KAAK,CAACH,UAAU,UAEnCE,QAAQE,KAAKT,aAAaU,WAEnBH,SAmCPM,WAzBa,SAASC,GAAIC,cACtBb,KAAO,CACPc,eAAgBF,IAGhBC,WACAb,KAAKa,SAAWA,cAGhBV,QAAU,CACVC,WAAY,sCACZJ,KAAMA,MAGNK,QAAUR,KAAKS,KAAK,CAACH,UAAU,UAEnCE,QAAQE,KAAKT,aAAaU,WAEnBH"}