From c5681f7ff1c9af0ee38c5eba91adb22e48d39215 Mon Sep 17 00:00:00 2001 From: Jun Pataleta Date: Tue, 25 Jun 2019 09:54:10 +0800 Subject: [PATCH] MDL-60013 amd: Final removal of core/modal_confirm --- lib/amd/build/modal_confirm.min.js | 1 - lib/amd/build/modal_events.min.js | 2 +- lib/amd/build/modal_factory.min.js | 2 +- lib/amd/src/modal_confirm.js | 46 ------------------------------ lib/amd/src/modal_events.js | 4 --- lib/amd/src/modal_factory.js | 10 ++----- lib/upgrade.txt | 1 + 7 files changed, 5 insertions(+), 61 deletions(-) delete mode 100644 lib/amd/build/modal_confirm.min.js delete mode 100644 lib/amd/src/modal_confirm.js diff --git a/lib/amd/build/modal_confirm.min.js b/lib/amd/build/modal_confirm.min.js deleted file mode 100644 index 68df0319578..00000000000 --- a/lib/amd/build/modal_confirm.min.js +++ /dev/null @@ -1 +0,0 @@ -define(["jquery","core/custom_interaction_events","core/modal_events","core/modal_save_cancel","core/log"],function(a,b,c,d,e){var f=function(a){e.warn("The CONFIRM modal type has been deprecated and should not be used anymore. Please use the SAVE_CANCEL modal type instead."),d.call(this,a)};return f.prototype=Object.create(d.prototype),f.prototype.constructor=f,f}); \ No newline at end of file diff --git a/lib/amd/build/modal_events.min.js b/lib/amd/build/modal_events.min.js index 5fc8341f154..e657fbf80c7 100644 --- a/lib/amd/build/modal_events.min.js +++ b/lib/amd/build/modal_events.min.js @@ -1 +1 @@ -define([],function(){return{shown:"modal:shown",hidden:"modal:hidden",destroyed:"modal:destroyed",bodyRendered:"modal:bodyRendered",save:"modal-save-cancel:save",cancel:"modal-save-cancel:cancel",yes:"modal-save-cancel:save",no:"modal-save-cancel:cancel"}}); \ No newline at end of file +define([],function(){return{shown:"modal:shown",hidden:"modal:hidden",destroyed:"modal:destroyed",bodyRendered:"modal:bodyRendered",save:"modal-save-cancel:save",cancel:"modal-save-cancel:cancel"}}); \ No newline at end of file diff --git a/lib/amd/build/modal_factory.min.js b/lib/amd/build/modal_factory.min.js index 5494e45c2c6..01db748508c 100644 --- a/lib/amd/build/modal_factory.min.js +++ b/lib/amd/build/modal_factory.min.js @@ -1 +1 @@ -define(["jquery","core/modal_events","core/modal_registry","core/modal","core/modal_save_cancel","core/modal_confirm","core/modal_cancel","core/templates","core/notification","core/custom_interaction_events"],function(a,b,c,d,e,f,g,h,i,j){var k={DEFAULT:"core/modal",SAVE_CANCEL:"core/modal_save_cancel",CONFIRM:"core/modal_save_cancel",CANCEL:"core/modal_cancel"},l={DEFAULT:"DEFAULT",SAVE_CANCEL:"SAVE_CANCEL",CONFIRM:"CONFIRM",CANCEL:"CANCEL"};c.register(l.DEFAULT,d,k.DEFAULT),c.register(l.SAVE_CANCEL,e,k.SAVE_CANCEL),c.register(l.CONFIRM,f,k.CONFIRM),c.register(l.CANCEL,g,k.CANCEL);var m=function(c,d,e){var f=null,g="function"==typeof e.preShowCallback,h=function(b,d){f=a(b.currentTarget),c.then(function(a){return g&&e.preShowCallback(f,a),a.show(),a}),d.originalEvent.preventDefault()};if(Array.isArray(d)){var i=d[1];d=d[0],j.define(d,[j.events.activate]),d.on(j.events.activate,i,h)}else j.define(d,[j.events.activate]),d.on(j.events.activate,h);c.then(function(a){return a.getRoot().on(b.hidden,function(){null!==f&&f.focus()}),a})},n=function(b,c){c=a(c);var d=b.module,e=new d(c);return e},o=function(b,c){var d=b.template,e=h.render(d,c).then(function(c){var d=a(c);return n(b,d)}).fail(i.exception);return e},p=function(a,b){var d=a.type||l.DEFAULT,e=!!a.large,f=null,g={};f=c.get(d),f||i.exception({message:"Unable to find modal of type: "+d}),"undefined"!=typeof a.templateContext&&(g=a.templateContext);var h=o(f,g).then(function(b){return"undefined"!=typeof a.title&&b.setTitle(a.title),"undefined"!=typeof a.body&&b.setBody(a.body),"undefined"!=typeof a.footer&&b.setFooter(a.footer),e&&b.setLarge(),b});return"undefined"!=typeof b&&m(h,b,a),h};return{create:p,types:l}}); \ No newline at end of file +define(["jquery","core/modal_events","core/modal_registry","core/modal","core/modal_save_cancel","core/modal_cancel","core/templates","core/notification","core/custom_interaction_events"],function(a,b,c,d,e,f,g,h,i){var j={DEFAULT:"core/modal",SAVE_CANCEL:"core/modal_save_cancel",CANCEL:"core/modal_cancel"},k={DEFAULT:"DEFAULT",SAVE_CANCEL:"SAVE_CANCEL",CANCEL:"CANCEL"};c.register(k.DEFAULT,d,j.DEFAULT),c.register(k.SAVE_CANCEL,e,j.SAVE_CANCEL),c.register(k.CANCEL,f,j.CANCEL);var l=function(c,d,e){var f=null,g="function"==typeof e.preShowCallback,h=function(b,d){f=a(b.currentTarget),c.then(function(a){return g&&e.preShowCallback(f,a),a.show(),a}),d.originalEvent.preventDefault()};if(Array.isArray(d)){var j=d[1];d=d[0],i.define(d,[i.events.activate]),d.on(i.events.activate,j,h)}else i.define(d,[i.events.activate]),d.on(i.events.activate,h);c.then(function(a){return a.getRoot().on(b.hidden,function(){null!==f&&f.focus()}),a})},m=function(b,c){c=a(c);var d=b.module,e=new d(c);return e},n=function(b,c){var d=b.template,e=g.render(d,c).then(function(c){var d=a(c);return m(b,d)}).fail(h.exception);return e},o=function(a,b){var d=a.type||k.DEFAULT,e=!!a.large,f=null,g={};f=c.get(d),f||h.exception({message:"Unable to find modal of type: "+d}),"undefined"!=typeof a.templateContext&&(g=a.templateContext);var i=n(f,g).then(function(b){return"undefined"!=typeof a.title&&b.setTitle(a.title),"undefined"!=typeof a.body&&b.setBody(a.body),"undefined"!=typeof a.footer&&b.setFooter(a.footer),e&&b.setLarge(),b});return"undefined"!=typeof b&&l(i,b,a),i};return{create:o,types:k}}); \ No newline at end of file diff --git a/lib/amd/src/modal_confirm.js b/lib/amd/src/modal_confirm.js deleted file mode 100644 index f396c8e18c2..00000000000 --- a/lib/amd/src/modal_confirm.js +++ /dev/null @@ -1,46 +0,0 @@ -// This file is part of Moodle - http://moodle.org/ -// -// Moodle is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// Moodle is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with Moodle. If not, see . - -/** - * Contain the logic for the yes/no confirmation modal. - * This has been deprecated and should not be used anymore. Please use core/modal_save_cancel instead. - * See MDL-59759. - * - * @deprecated Since Moodle 3.4 - * @module core/modal_confirm - * @class modal_confirm - * @package core - * @copyright 2016 Ryan Wyllie - * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later - */ -define(['jquery', 'core/custom_interaction_events', 'core/modal_events', 'core/modal_save_cancel', 'core/log'], - function($, CustomEvents, ModalEvents, ModalSaveCancel, Log) { - - /** - * Constructor for the Modal. - * - * @param {object} root The root jQuery element for the modal - */ - var ModalConfirm = function(root) { - Log.warn("The CONFIRM modal type has been deprecated and should not be used anymore." + - " Please use the SAVE_CANCEL modal type instead."); - ModalSaveCancel.call(this, root); - }; - - ModalConfirm.prototype = Object.create(ModalSaveCancel.prototype); - ModalConfirm.prototype.constructor = ModalConfirm; - - return ModalConfirm; -}); diff --git a/lib/amd/src/modal_events.js b/lib/amd/src/modal_events.js index 9c261795314..234d3d7cc5d 100644 --- a/lib/amd/src/modal_events.js +++ b/lib/amd/src/modal_events.js @@ -32,9 +32,5 @@ define([], function() { // ModalSaveCancel events. save: 'modal-save-cancel:save', cancel: 'modal-save-cancel:cancel', - // ModalConfirm events. Deprecated since Moodle 3.4. See MDL-59759. - // Point core/modal_confirm events to save/cancel events of core/modal_save_cancel. - yes: 'modal-save-cancel:save', - no: 'modal-save-cancel:cancel', }; }); diff --git a/lib/amd/src/modal_factory.js b/lib/amd/src/modal_factory.js index b9463900ff5..4e9381ea14b 100644 --- a/lib/amd/src/modal_factory.js +++ b/lib/amd/src/modal_factory.js @@ -23,17 +23,15 @@ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ define(['jquery', 'core/modal_events', 'core/modal_registry', 'core/modal', - 'core/modal_save_cancel', 'core/modal_confirm', 'core/modal_cancel', + 'core/modal_save_cancel', 'core/modal_cancel', 'core/templates', 'core/notification', 'core/custom_interaction_events'], - function($, ModalEvents, ModalRegistry, Modal, ModalSaveCancel, ModalConfirm, + function($, ModalEvents, ModalRegistry, Modal, ModalSaveCancel, ModalCancel, Templates, Notification, CustomEvents) { // The templates for each type of modal. var TEMPLATES = { DEFAULT: 'core/modal', SAVE_CANCEL: 'core/modal_save_cancel', - // Deprecated since Moodle 3.4. Point template to core/modal_save_cancel instead. See MDL-59759. - CONFIRM: 'core/modal_save_cancel', CANCEL: 'core/modal_cancel', }; @@ -41,16 +39,12 @@ define(['jquery', 'core/modal_events', 'core/modal_registry', 'core/modal', var TYPES = { DEFAULT: 'DEFAULT', SAVE_CANCEL: 'SAVE_CANCEL', - // Deprecated since Moodle 3.4. See MDL-59759. - CONFIRM: 'CONFIRM', CANCEL: 'CANCEL', }; // Register the common set of modals. ModalRegistry.register(TYPES.DEFAULT, Modal, TEMPLATES.DEFAULT); ModalRegistry.register(TYPES.SAVE_CANCEL, ModalSaveCancel, TEMPLATES.SAVE_CANCEL); - // Deprecated since Moodle 3.4. See MDL-59759. - ModalRegistry.register(TYPES.CONFIRM, ModalConfirm, TEMPLATES.CONFIRM); ModalRegistry.register(TYPES.CANCEL, ModalCancel, TEMPLATES.CANCEL); /** diff --git a/lib/upgrade.txt b/lib/upgrade.txt index 3c5e180c8d1..38083f4266c 100644 --- a/lib/upgrade.txt +++ b/lib/upgrade.txt @@ -14,6 +14,7 @@ information provided here is intended especially for developers. * allow_switch() * Remove duplicate font-awesome SCSS, Please see /theme/boost/scss/fontawesome for usage (MDL-65936) * Remove lib/pear/Crypt/CHAP.php (MDL-65747) +* Final deprecation (removal) of the core/modal_confirm dialogue. === 3.7 ===