mirror of
https://github.com/moodle/moodle.git
synced 2025-01-19 14:27:22 +01:00
Merge branch 'MDL-51292-master' of git://github.com/cameron1729/moodle
This commit is contained in:
commit
880eb93d3f
@ -3987,6 +3987,7 @@ EOD;
|
||||
'page' => $this->page
|
||||
)
|
||||
);
|
||||
$this->page->requires->string_for_js('changesmadereallygoaway', 'moodle');
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -178,6 +178,14 @@ M.core_formchangechecker.get_form_dirty_state = function() {
|
||||
return 0;
|
||||
};
|
||||
|
||||
/*
|
||||
* Reset the form state
|
||||
*/
|
||||
M.core_formchangechecker.reset_form_dirty_state = function() {
|
||||
M.core_formchangechecker.stateinformation.formsubmitted = false;
|
||||
M.core_formchangechecker.stateinformation.formchanged = false;
|
||||
};
|
||||
|
||||
/*
|
||||
* Return a suitable message if changes have been made to a form
|
||||
*/
|
||||
|
@ -1 +1 @@
|
||||
YUI.add("moodle-core-formchangechecker",function(e,t){var n="core-formchangechecker",r=function(){r.superclass.constructor.apply(this,arguments)};e.extend(r,e.Base,{initialvaluelisteners:[],initializer:function(){var t="form#"+this.get("formid"),n=e.one(t);if(!n)return;n.delegate("change",M.core_formchangechecker.set_form_changed,"input",this),n.delegate("change",M.core_formchangechecker.set_form_changed,"textarea",this),n.delegate("change",M.core_formchangechecker.set_form_changed,"select",this),this.initialvaluelisteners.push(n.delegate("focus",this.store_initial_value,"input",this)),this.initialvaluelisteners.push(n.delegate("focus",this.store_initial_value,"textarea",this)),this.initialvaluelisteners.push(n.delegate("focus",this.store_initial_value,"select",this)),e.one(t).on("submit",M.core_formchangechecker.set_form_submitted,this),window.onbeforeunload=M.core_formchangechecker.report_form_dirty_state},store_initial_value:function(e){var t;if(e.target.hasClass("ignoredirty"))return;if(M.core_formchangechecker.get_form_dirty_state()){while(this.initialvaluelisteners.length)t=this.initialvaluelisteners.shift(),t.detach();return}M.core_formchangechecker.stateinformation.focused_element={element:e.target,initial_value:e.target.get("value")}}},{NAME:n,ATTRS:{formid:{value:""}}}),M.core_formchangechecker=M.core_formchangechecker||{},M.core_formchangechecker.instances=M.core_formchangechecker.instances||[],M.core_formchangechecker.init=function(e){var t=new r(e);return M.core_formchangechecker.instances.push(t),t},M.core_formchangechecker.stateinformation=[],M.core_formchangechecker.set_form_changed=function(e){if(e&&e.target&&e.target.hasClass("ignoredirty"))return;M.core_formchangechecker.stateinformation.formchanged=1,delete M.core_formchangechecker.stateinformation.focused_element},M.core_formchangechecker.set_form_submitted=function(){M.core_formchangechecker.stateinformation.formsubmitted=1},M.core_formchangechecker.get_form_dirty_state=function(){var e=M.core_formchangechecker.stateinformation,t;if(e.formsubmitted)return 0;if(e.formchanged)return 1;if(e.focused_element&&e.focused_element.element.get("value")!==e.focused_element.initial_value)return 1;if(typeof window.tinyMCE!="undefined")for(t in window.tinyMCE.editors)if(window.tinyMCE.editors[t].isDirty())return 1;return 0},M.core_formchangechecker.report_form_dirty_state=function(e){if(!M.core_formchangechecker.get_form_dirty_state())return;var t=M.util.get_string("changesmadereallygoaway","moodle");if(M.cfg.behatsiterunning)return;return e&&(e.returnValue=t),t}},"@VERSION@",{requires:["base","event-focus"]});
|
||||
YUI.add("moodle-core-formchangechecker",function(e,t){var n="core-formchangechecker",r=function(){r.superclass.constructor.apply(this,arguments)};e.extend(r,e.Base,{initialvaluelisteners:[],initializer:function(){var t="form#"+this.get("formid"),n=e.one(t);if(!n)return;n.delegate("change",M.core_formchangechecker.set_form_changed,"input",this),n.delegate("change",M.core_formchangechecker.set_form_changed,"textarea",this),n.delegate("change",M.core_formchangechecker.set_form_changed,"select",this),this.initialvaluelisteners.push(n.delegate("focus",this.store_initial_value,"input",this)),this.initialvaluelisteners.push(n.delegate("focus",this.store_initial_value,"textarea",this)),this.initialvaluelisteners.push(n.delegate("focus",this.store_initial_value,"select",this)),e.one(t).on("submit",M.core_formchangechecker.set_form_submitted,this),window.onbeforeunload=M.core_formchangechecker.report_form_dirty_state},store_initial_value:function(e){var t;if(e.target.hasClass("ignoredirty"))return;if(M.core_formchangechecker.get_form_dirty_state()){while(this.initialvaluelisteners.length)t=this.initialvaluelisteners.shift(),t.detach();return}M.core_formchangechecker.stateinformation.focused_element={element:e.target,initial_value:e.target.get("value")}}},{NAME:n,ATTRS:{formid:{value:""}}}),M.core_formchangechecker=M.core_formchangechecker||{},M.core_formchangechecker.instances=M.core_formchangechecker.instances||[],M.core_formchangechecker.init=function(e){var t=new r(e);return M.core_formchangechecker.instances.push(t),t},M.core_formchangechecker.stateinformation=[],M.core_formchangechecker.set_form_changed=function(e){if(e&&e.target&&e.target.hasClass("ignoredirty"))return;M.core_formchangechecker.stateinformation.formchanged=1,delete M.core_formchangechecker.stateinformation.focused_element},M.core_formchangechecker.set_form_submitted=function(){M.core_formchangechecker.stateinformation.formsubmitted=1},M.core_formchangechecker.get_form_dirty_state=function(){var e=M.core_formchangechecker.stateinformation,t;if(e.formsubmitted)return 0;if(e.formchanged)return 1;if(e.focused_element&&e.focused_element.element.get("value")!==e.focused_element.initial_value)return 1;if(typeof window.tinyMCE!="undefined")for(t in window.tinyMCE.editors)if(window.tinyMCE.editors[t].isDirty())return 1;return 0},M.core_formchangechecker.reset_form_dirty_state=function(){M.core_formchangechecker.stateinformation.formsubmitted=!1,M.core_formchangechecker.stateinformation.formchanged=!1},M.core_formchangechecker.report_form_dirty_state=function(e){if(!M.core_formchangechecker.get_form_dirty_state())return;var t=M.util.get_string("changesmadereallygoaway","moodle");if(M.cfg.behatsiterunning)return;return e&&(e.returnValue=t),t}},"@VERSION@",{requires:["base","event-focus"]});
|
||||
|
@ -178,6 +178,14 @@ M.core_formchangechecker.get_form_dirty_state = function() {
|
||||
return 0;
|
||||
};
|
||||
|
||||
/*
|
||||
* Reset the form state
|
||||
*/
|
||||
M.core_formchangechecker.reset_form_dirty_state = function() {
|
||||
M.core_formchangechecker.stateinformation.formsubmitted = false;
|
||||
M.core_formchangechecker.stateinformation.formchanged = false;
|
||||
};
|
||||
|
||||
/*
|
||||
* Return a suitable message if changes have been made to a form
|
||||
*/
|
||||
|
@ -176,6 +176,14 @@ M.core_formchangechecker.get_form_dirty_state = function() {
|
||||
return 0;
|
||||
};
|
||||
|
||||
/*
|
||||
* Reset the form state
|
||||
*/
|
||||
M.core_formchangechecker.reset_form_dirty_state = function() {
|
||||
M.core_formchangechecker.stateinformation.formsubmitted = false;
|
||||
M.core_formchangechecker.stateinformation.formchanged = false;
|
||||
};
|
||||
|
||||
/*
|
||||
* Return a suitable message if changes have been made to a form
|
||||
*/
|
||||
|
@ -225,7 +225,7 @@ Y.namespace('M.core_message.messenger').sendMessage = Y.extend(SENDMSGDIALOG, M.
|
||||
|
||||
_bb: null,
|
||||
_sendLock: false,
|
||||
|
||||
_hide: null,
|
||||
/**
|
||||
* Initializer.
|
||||
*
|
||||
@ -236,10 +236,11 @@ Y.namespace('M.core_message.messenger').sendMessage = Y.extend(SENDMSGDIALOG, M.
|
||||
content;
|
||||
|
||||
this._bb = this.get('boundingBox');
|
||||
this._hide = this.hide;
|
||||
|
||||
// Prepare the content area.
|
||||
tpl = Y.Handlebars.compile(
|
||||
'<form action="#">' +
|
||||
'<form action="#" id="messageform">' +
|
||||
'<div class="{{CSSR.INPUTAREA}}">' +
|
||||
'<label class="{{CSSR.ACCESSHIDE}}" for="{{id}}">{{labelStr}}</label>' +
|
||||
'<textarea class="{{CSSR.INPUT}}" id="{{id}}"></textarea>' +
|
||||
@ -296,6 +297,11 @@ Y.namespace('M.core_message.messenger').sendMessage = Y.extend(SENDMSGDIALOG, M.
|
||||
|
||||
// Set the content as empty and lock send.
|
||||
this._bb.one(SELECTORS.SENDMSGDIALOG.INPUT).set('value', '');
|
||||
|
||||
// Register form with formchangechecker
|
||||
Y.use('moodle-core-formchangechecker', function() {
|
||||
M.core_formchangechecker.init({formid: "messageform"});
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
@ -369,6 +375,33 @@ Y.namespace('M.core_message.messenger').sendMessage = Y.extend(SENDMSGDIALOG, M.
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* Override the default hide function.
|
||||
* @method hide
|
||||
*/
|
||||
hide: function() {
|
||||
var self = this;
|
||||
|
||||
if (!M.core_formchangechecker.get_form_dirty_state()) {
|
||||
return SENDMSGDIALOG.superclass.hide.call(this, arguments);
|
||||
}
|
||||
|
||||
Y.use('moodle-core-notification-confirm', function() {
|
||||
var confirm = new M.core.confirm({
|
||||
title : M.util.get_string('confirm', 'moodle'),
|
||||
question : M.util.get_string('changesmadereallygoaway', 'moodle'),
|
||||
yesLabel : M.util.get_string('confirm', 'moodle'),
|
||||
noLabel : M.util.get_string('cancel', 'moodle')
|
||||
});
|
||||
confirm.on('complete-yes', function() {
|
||||
M.core_formchangechecker.reset_form_dirty_state();
|
||||
confirm.hide();
|
||||
confirm.destroy();
|
||||
return SENDMSGDIALOG.superclass.hide.call(this, arguments);
|
||||
}, self);
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* Show a notice.
|
||||
*
|
||||
|
File diff suppressed because one or more lines are too long
@ -225,7 +225,7 @@ Y.namespace('M.core_message.messenger').sendMessage = Y.extend(SENDMSGDIALOG, M.
|
||||
|
||||
_bb: null,
|
||||
_sendLock: false,
|
||||
|
||||
_hide: null,
|
||||
/**
|
||||
* Initializer.
|
||||
*
|
||||
@ -236,10 +236,11 @@ Y.namespace('M.core_message.messenger').sendMessage = Y.extend(SENDMSGDIALOG, M.
|
||||
content;
|
||||
|
||||
this._bb = this.get('boundingBox');
|
||||
this._hide = this.hide;
|
||||
|
||||
// Prepare the content area.
|
||||
tpl = Y.Handlebars.compile(
|
||||
'<form action="#">' +
|
||||
'<form action="#" id="messageform">' +
|
||||
'<div class="{{CSSR.INPUTAREA}}">' +
|
||||
'<label class="{{CSSR.ACCESSHIDE}}" for="{{id}}">{{labelStr}}</label>' +
|
||||
'<textarea class="{{CSSR.INPUT}}" id="{{id}}"></textarea>' +
|
||||
@ -296,6 +297,11 @@ Y.namespace('M.core_message.messenger').sendMessage = Y.extend(SENDMSGDIALOG, M.
|
||||
|
||||
// Set the content as empty and lock send.
|
||||
this._bb.one(SELECTORS.SENDMSGDIALOG.INPUT).set('value', '');
|
||||
|
||||
// Register form with formchangechecker
|
||||
Y.use('moodle-core-formchangechecker', function() {
|
||||
M.core_formchangechecker.init({formid: "messageform"});
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
@ -369,6 +375,33 @@ Y.namespace('M.core_message.messenger').sendMessage = Y.extend(SENDMSGDIALOG, M.
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* Override the default hide function.
|
||||
* @method hide
|
||||
*/
|
||||
hide: function() {
|
||||
var self = this;
|
||||
|
||||
if (!M.core_formchangechecker.get_form_dirty_state()) {
|
||||
return SENDMSGDIALOG.superclass.hide.call(this, arguments);
|
||||
}
|
||||
|
||||
Y.use('moodle-core-notification-confirm', function() {
|
||||
var confirm = new M.core.confirm({
|
||||
title : M.util.get_string('confirm', 'moodle'),
|
||||
question : M.util.get_string('changesmadereallygoaway', 'moodle'),
|
||||
yesLabel : M.util.get_string('confirm', 'moodle'),
|
||||
noLabel : M.util.get_string('cancel', 'moodle')
|
||||
});
|
||||
confirm.on('complete-yes', function() {
|
||||
M.core_formchangechecker.reset_form_dirty_state();
|
||||
confirm.hide();
|
||||
confirm.destroy();
|
||||
return SENDMSGDIALOG.superclass.hide.call(this, arguments);
|
||||
}, self);
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* Show a notice.
|
||||
*
|
||||
|
37
message/yui/src/messenger/js/sendmessage.js
vendored
37
message/yui/src/messenger/js/sendmessage.js
vendored
@ -60,7 +60,7 @@ Y.namespace('M.core_message.messenger').sendMessage = Y.extend(SENDMSGDIALOG, M.
|
||||
|
||||
_bb: null,
|
||||
_sendLock: false,
|
||||
|
||||
_hide: null,
|
||||
/**
|
||||
* Initializer.
|
||||
*
|
||||
@ -71,10 +71,11 @@ Y.namespace('M.core_message.messenger').sendMessage = Y.extend(SENDMSGDIALOG, M.
|
||||
content;
|
||||
|
||||
this._bb = this.get('boundingBox');
|
||||
this._hide = this.hide;
|
||||
|
||||
// Prepare the content area.
|
||||
tpl = Y.Handlebars.compile(
|
||||
'<form action="#">' +
|
||||
'<form action="#" id="messageform">' +
|
||||
'<div class="{{CSSR.INPUTAREA}}">' +
|
||||
'<label class="{{CSSR.ACCESSHIDE}}" for="{{id}}">{{labelStr}}</label>' +
|
||||
'<textarea class="{{CSSR.INPUT}}" id="{{id}}"></textarea>' +
|
||||
@ -131,6 +132,11 @@ Y.namespace('M.core_message.messenger').sendMessage = Y.extend(SENDMSGDIALOG, M.
|
||||
|
||||
// Set the content as empty and lock send.
|
||||
this._bb.one(SELECTORS.SENDMSGDIALOG.INPUT).set('value', '');
|
||||
|
||||
// Register form with formchangechecker
|
||||
Y.use('moodle-core-formchangechecker', function() {
|
||||
M.core_formchangechecker.init({formid: "messageform"});
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
@ -204,6 +210,33 @@ Y.namespace('M.core_message.messenger').sendMessage = Y.extend(SENDMSGDIALOG, M.
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* Override the default hide function.
|
||||
* @method hide
|
||||
*/
|
||||
hide: function() {
|
||||
var self = this;
|
||||
|
||||
if (!M.core_formchangechecker.get_form_dirty_state()) {
|
||||
return SENDMSGDIALOG.superclass.hide.call(this, arguments);
|
||||
}
|
||||
|
||||
Y.use('moodle-core-notification-confirm', function() {
|
||||
var confirm = new M.core.confirm({
|
||||
title : M.util.get_string('confirm', 'moodle'),
|
||||
question : M.util.get_string('changesmadereallygoaway', 'moodle'),
|
||||
yesLabel : M.util.get_string('confirm', 'moodle'),
|
||||
noLabel : M.util.get_string('cancel', 'moodle')
|
||||
});
|
||||
confirm.on('complete-yes', function() {
|
||||
M.core_formchangechecker.reset_form_dirty_state();
|
||||
confirm.hide();
|
||||
confirm.destroy();
|
||||
return SENDMSGDIALOG.superclass.hide.call(this, arguments);
|
||||
}, self);
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* Show a notice.
|
||||
*
|
||||
|
Loading…
x
Reference in New Issue
Block a user