芝麻web文件管理V1.00
编辑当前文件:/home2/sdektunc/www/cepali/lib/amd/build/notification.min.js
define(["core/yui","jquery","core/log","core/pending"],function(a,b,c,d){var e={types:{success:"core/notification_success",info:"core/notification_info",warning:"core/notification_warning",error:"core/notification_error"},fieldName:"user-notifications",fetchNotifications:function(){var a=new d("core/notification:fetchNotifications");require(["core/ajax"],function(b){var c=b.call([{methodname:"core_fetch_notifications",args:{contextid:e.contextid}}]);c[0].then(e.addNotifications).always(a.resolve)})},addNotifications:function(a){var c=new d("core/notification:addNotifications");a||(a=[]),b.each(a,function(a,b){e.renderNotification(b.template,b.variables)}),c.resolve()},setupTargetRegion:function(){var a=b("#"+e.fieldName);if(a.length)return!1;var c=b("
").attr("id",e.fieldName);return a=b("#region-main"),a.length?a.prepend(c):(a=b('[role="main"]'),a.length?a.prepend(c):(a=b("body"),a.prepend(c)))},addNotification:function(a){var c=new d("core/notification:addNotifications"),f=e.types.error;return a=b.extend({closebutton:!0,announce:!0,type:"error"},a),a.template?(f=a.template,delete a.template):a.type&&("undefined"!=typeof e.types[a.type]&&(f=e.types[a.type]),delete a.type),c.resolve(),e.renderNotification(f,a)},renderNotification:function(a,f){if("undefined"==typeof f.message||!f.message)return void c.debug("Notification received without content. Skipping.");var g=new d("core/notification:renderNotification");require(["core/templates"],function(c){c.render(a,f).then(function(a,d){b("#"+e.fieldName).prepend(a),c.runTemplateJS(d)}).always(g.resolve)["catch"](e.exception)})},alert:function(b,c,e){var f=new d("core/notification:alert");a.use("moodle-core-notification-alert",function(){var a=new M.core.alert({title:b,message:c,yesLabel:e});a.show(),f.resolve()})},confirm:function(b,c,e,f,g,h){var i=new d("core/notification:confirm");a.use("moodle-core-notification-confirm",function(){var a=new M.core.confirm({title:b,question:c,yesLabel:e,noLabel:f});a.on("complete-yes",function(){g()}),h&&a.on("complete-no",function(){h()}),a.show(),i.resolve()})},exception:function(b){var c=new d("core/notification:addNotifications");if("undefined"==typeof b.stack&&(b.stack=""),b.debuginfo&&(b.stack+=b.debuginfo+"\n"),!b.backtrace&&b.stacktrace&&(b.backtrace=b.stacktrace),b.backtrace){b.stack+=b.backtrace;var e=b.backtrace.match(/line ([^ ]*) of/),f=b.backtrace.match(/ of ([^:]*): /);e&&e[1]&&(b.lineNumber=e[1]),f&&f[1]&&(b.fileName=f[1],b.fileName.length>30&&(b.fileName="..."+b.fileName.substr(b.fileName.length-27)))}"undefined"==typeof b.name&&b.errorcode&&(b.name=b.errorcode),a.use("moodle-core-notification-exception",function(){var a=new M.core.exception(b);a.show(),c.resolve()})}};return{init:function(a,b){e.contextid=a,e.setupTargetRegion(),e.addNotifications(b),e.fetchNotifications()},fetchNotifications:e.fetchNotifications,addNotification:e.addNotification,alert:e.alert,confirm:e.confirm,exception:e.exception}});