mirror of
https://github.com/moodle/moodle.git
synced 2025-01-19 14:27:22 +01:00
0a4047ab31
Unfortunately the babel minify-mangle plugin seems to be abandoned and in certain circumstances can be very buggy. The only safe options are to disable it, or to switch to a different minification library. Not minifying our javascript is not ideal, so this commit updates the javascript tasks to use a rollup, combined with babel, and terser. Babel still converts code from ES/UMD/AMD to AMD modules with the relevant browser support, whilst terser minifies the code. The rollup bundler handles tracking and creation of sourcemaps, and supports better parallelisation of the tasks. Since the upgrade to Node LTS/Gallium requires an upgrade to @babel/core and eslint, which change the built files anyway, this seems like the ideal time to make this change.
3 lines
4.8 KiB
JavaScript
3 lines
4.8 KiB
JavaScript
define("core/toast",["exports","core/templates","core/notification","core/pending"],(function(_exports,_templates,_notification,_pending){function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj}}function ownKeys(object,enumerableOnly){var keys=Object.keys(object);if(Object.getOwnPropertySymbols){var symbols=Object.getOwnPropertySymbols(object);enumerableOnly&&(symbols=symbols.filter((function(sym){return Object.getOwnPropertyDescriptor(object,sym).enumerable}))),keys.push.apply(keys,symbols)}return keys}function _objectSpread(target){for(var i=1;i<arguments.length;i++){var source=null!=arguments[i]?arguments[i]:{};i%2?ownKeys(Object(source),!0).forEach((function(key){_defineProperty(target,key,source[key])})):Object.getOwnPropertyDescriptors?Object.defineProperties(target,Object.getOwnPropertyDescriptors(source)):ownKeys(Object(source)).forEach((function(key){Object.defineProperty(target,key,Object.getOwnPropertyDescriptor(source,key))}))}return target}function _defineProperty(obj,key,value){return key in obj?Object.defineProperty(obj,key,{value:value,enumerable:!0,configurable:!0,writable:!0}):obj[key]=value,obj}function asyncGeneratorStep(gen,resolve,reject,_next,_throw,key,arg){try{var info=gen[key](arg),value=info.value}catch(error){return void reject(error)}info.done?resolve(value):Promise.resolve(value).then(_next,_throw)}function _asyncToGenerator(fn){return function(){var self=this,args=arguments;return new Promise((function(resolve,reject){var gen=fn.apply(self,args);function _next(value){asyncGeneratorStep(gen,resolve,reject,_next,_throw,"next",value)}function _throw(err){asyncGeneratorStep(gen,resolve,reject,_next,_throw,"throw",err)}_next(void 0)}))}}Object.defineProperty(_exports,"__esModule",{value:!0}),_exports.addToastRegion=_exports.add=void 0,_templates=_interopRequireDefault(_templates),_notification=_interopRequireDefault(_notification),_pending=_interopRequireDefault(_pending);var _ref,addToastRegion=(_ref=_asyncToGenerator(regeneratorRuntime.mark((function _callee(parent){var pendingPromise,_yield$Templates$rend,html,js;return regeneratorRuntime.wrap((function(_context){for(;;)switch(_context.prev=_context.next){case 0:return pendingPromise=new _pending.default("addToastRegion"),_context.prev=1,_context.next=4,_templates.default.renderForPromise("core/local/toast/wrapper",{});case 4:_yield$Templates$rend=_context.sent,html=_yield$Templates$rend.html,js=_yield$Templates$rend.js,_templates.default.prependNodeContents(parent,html,js),_context.next=13;break;case 10:_context.prev=10,_context.t0=_context.catch(1),_notification.default.exception(_context.t0);case 13:pendingPromise.resolve();case 14:case"end":return _context.stop()}}),_callee,null,[[1,10]])}))),function(_x){return _ref.apply(this,arguments)});_exports.addToastRegion=addToastRegion;var _ref2,add=(_ref2=_asyncToGenerator(regeneratorRuntime.mark((function _callee2(message,configuration){var pendingPromise,templateName,targetNode,_yield$Templates$rend2,html,js;return regeneratorRuntime.wrap((function(_context2){for(;;)switch(_context2.prev=_context2.next){case 0:return pendingPromise=new _pending.default("addToastRegion"),configuration=_objectSpread({type:"info",closeButton:!1,autohide:!0,delay:4e3},configuration),templateName="core/local/toast/message",_context2.prev=3,_context2.next=6,getTargetNode();case 6:return targetNode=_context2.sent,_context2.t0=_templates.default,_context2.t1=templateName,_context2.t2=_objectSpread,_context2.next=12,message;case 12:return _context2.t3=_context2.sent,_context2.t4={message:_context2.t3},_context2.t5=configuration,_context2.t6=(0,_context2.t2)(_context2.t4,_context2.t5),_context2.next=18,_context2.t0.renderForPromise.call(_context2.t0,_context2.t1,_context2.t6);case 18:_yield$Templates$rend2=_context2.sent,html=_yield$Templates$rend2.html,js=_yield$Templates$rend2.js,_templates.default.prependNodeContents(targetNode,html,js),_context2.next=27;break;case 24:_context2.prev=24,_context2.t7=_context2.catch(3),_notification.default.exception(_context2.t7);case 27:pendingPromise.resolve();case 28:case"end":return _context2.stop()}}),_callee2,null,[[3,24]])}))),function(_x2,_x3){return _ref2.apply(this,arguments)});_exports.add=add;var _ref3,getTargetNode=(_ref3=_asyncToGenerator(regeneratorRuntime.mark((function _callee3(){var regions;return regeneratorRuntime.wrap((function(_context3){for(;;)switch(_context3.prev=_context3.next){case 0:if(!(regions=document.querySelectorAll(".toast-wrapper")).length){_context3.next=3;break}return _context3.abrupt("return",regions[regions.length-1]);case 3:return _context3.next=5,addToastRegion(document.body,"fixed-bottom");case 5:return _context3.abrupt("return",getTargetNode());case 6:case"end":return _context3.stop()}}),_callee3)}))),function(){return _ref3.apply(this,arguments)})}));
|
|
|
|
//# sourceMappingURL=toast.min.js.map
|