mirror of
https://github.com/moodle/moodle.git
synced 2025-01-18 22:08:20 +01:00
Merge branch 'MDL-38935' of git://github.com/timhunt/moodle
This commit is contained in:
commit
f8ddbd24d7
File diff suppressed because one or more lines are too long
@ -121,9 +121,11 @@ M.mod_quiz.autosave = {
|
||||
* or enough time has passed.
|
||||
*/
|
||||
init_tinymce: function(repeatcount) {
|
||||
if (typeof tinymce === 'undefined') {
|
||||
if (typeof tinyMCE === 'undefined') {
|
||||
if (repeatcount > 0) {
|
||||
Y.later(this.TINYMCE_DETECTION_DELAY, this, this.init_tinymce, [repeatcount - 1]);
|
||||
} else {
|
||||
Y.log('Gave up looking for TinyMCE.');
|
||||
}
|
||||
return;
|
||||
}
|
||||
@ -147,7 +149,8 @@ M.mod_quiz.autosave = {
|
||||
},
|
||||
|
||||
value_changed: function(e) {
|
||||
if (e.target.get('name') === 'thispage' || e.target.get('name').match(/_:flagged$/)) {
|
||||
if (e.target.get('name') === 'thispage' || e.target.get('name') === 'scrollpos' ||
|
||||
e.target.get('name').match(/_:flagged$/)) {
|
||||
return; // Not interesting.
|
||||
}
|
||||
Y.log('Detected a value change in element ' + e.target.get('name') + '.');
|
||||
@ -193,6 +196,9 @@ M.mod_quiz.autosave = {
|
||||
}
|
||||
|
||||
Y.log('Doing a save.');
|
||||
if (typeof tinyMCE !== 'undefined') {
|
||||
tinyMCE.triggerSave();
|
||||
}
|
||||
this.save_transaction = Y.io(this.AUTOSAVE_HANDLER, {
|
||||
method: 'POST',
|
||||
form: {id: this.form},
|
||||
|
@ -1 +1 @@
|
||||
YUI.add("moodle-mod_quiz-autosave",function(e,t){M.mod_quiz=M.mod_quiz||{},M.mod_quiz.autosave={TINYMCE_DETECTION_DELAY:500,TINYMCE_DETECTION_REPEATS:20,WATCH_HIDDEN_DELAY:1e3,SELECTORS:{QUIZ_FORM:"#responseform",VALUE_CHANGE_ELEMENTS:"input, textarea",CHANGE_ELEMENTS:"input, select",HIDDEN_INPUTS:"input[type=hidden]"},AUTOSAVE_HANDLER:M.cfg.wwwroot+"/mod/quiz/autosave.ajax.php",delay:12e4,form:null,dirty:!1,delay_timer:null,save_transaction:null,editor_change_handler:null,hidden_field_values:{},init:function(t){this.form=e.one(this.SELECTORS.QUIZ_FORM);if(!this.form)return;this.delay=t*1e3,this.form.delegate("valuechange",this.value_changed,this.SELECTORS.VALUE_CHANGE_ELEMENTS,this),this.form.delegate("change",this.value_changed,this.SELECTORS.CHANGE_ELEMENTS,this),this.form.on("submit",this.stop_autosaving,this),this.init_tinymce(this.TINYMCE_DETECTION_REPEATS),this.save_hidden_field_values(),this.watch_hidden_fields()},save_hidden_field_values:function(){this.form.all(this.SELECTORS.HIDDEN_INPUTS).each(function(e){var t=e.get("name");if(!t)return;this.hidden_field_values[t]=e.get("value")},this)},watch_hidden_fields:function(){this.detect_hidden_field_changes(),e.later(this.WATCH_HIDDEN_DELAY,this,this.watch_hidden_fields)},detect_hidden_field_changes:function(){this.form.all(this.SELECTORS.HIDDEN_INPUTS).each(function(e){var t=e.get("name"),n=e.get("value");if(!t)return;if(!(t in this.hidden_field_values)||n!==this.hidden_field_values[t])this.hidden_field_values[t]=n,this.value_changed({target:e})},this)},init_tinymce:function(t){if(typeof tinymce=="undefined"){t>0&&e.later(this.TINYMCE_DETECTION_DELAY,this,this.init_tinymce,[t-1]);return}this.editor_change_handler=e.bind(this.editor_changed,this),tinyMCE.onAddEditor.add(e.bind(this.init_tinymce_editor,this))},init_tinymce_editor:function(e,t){t.onChange.add(this.editor_change_handler),t.onRedo.add(this.editor_change_handler),t.onUndo.add(this.editor_change_handler),t.onKeyDown.add(this.editor_change_handler)},value_changed:function(e){if(e.target.get("name")==="thispage"||e.target.get("name").match(/_:flagged$/))return;this.start_save_timer_if_necessary()},editor_changed:function(e){this.start_save_timer_if_necessary()},start_save_timer_if_necessary:function(){this.dirty=!0;if(this.delay_timer||this.save_transaction)return;this.start_save_timer()},start_save_timer:function(){this.cancel_delay(),this.delay_timer=e.later(this.delay,this,this.save_changes)},cancel_delay:function(){this.delay_timer&&this.delay_timer!==!0&&this.delay_timer.cancel(),this.delay_timer=null},save_changes:function(){this.cancel_delay(),this.dirty=!1;if(this.is_time_nearly_over()){this.stop_autosaving();return}this.save_transaction=e.io(this.AUTOSAVE_HANDLER,{method:"POST",form:{id:this.form},on:{complete:this.save_done},context:this})},save_done:function(){this.save_transaction=null,this.dirty&&this.start_save_timer()},is_time_nearly_over:function(){return M.mod_quiz.timer&&M.mod_quiz.timer.endtime&&(new Date).getTime()+2*this.delay>M.mod_quiz.timer.endtime},stop_autosaving:function(){this.cancel_delay(),this.delay_timer=!0,this.save_transaction&&this.save_transaction.abort()}}},"@VERSION@",{requires:["base","node","event","event-valuechange","node-event-delegate","io-form"]});
|
||||
YUI.add("moodle-mod_quiz-autosave",function(e,t){M.mod_quiz=M.mod_quiz||{},M.mod_quiz.autosave={TINYMCE_DETECTION_DELAY:500,TINYMCE_DETECTION_REPEATS:20,WATCH_HIDDEN_DELAY:1e3,SELECTORS:{QUIZ_FORM:"#responseform",VALUE_CHANGE_ELEMENTS:"input, textarea",CHANGE_ELEMENTS:"input, select",HIDDEN_INPUTS:"input[type=hidden]"},AUTOSAVE_HANDLER:M.cfg.wwwroot+"/mod/quiz/autosave.ajax.php",delay:12e4,form:null,dirty:!1,delay_timer:null,save_transaction:null,editor_change_handler:null,hidden_field_values:{},init:function(t){this.form=e.one(this.SELECTORS.QUIZ_FORM);if(!this.form)return;this.delay=t*1e3,this.form.delegate("valuechange",this.value_changed,this.SELECTORS.VALUE_CHANGE_ELEMENTS,this),this.form.delegate("change",this.value_changed,this.SELECTORS.CHANGE_ELEMENTS,this),this.form.on("submit",this.stop_autosaving,this),this.init_tinymce(this.TINYMCE_DETECTION_REPEATS),this.save_hidden_field_values(),this.watch_hidden_fields()},save_hidden_field_values:function(){this.form.all(this.SELECTORS.HIDDEN_INPUTS).each(function(e){var t=e.get("name");if(!t)return;this.hidden_field_values[t]=e.get("value")},this)},watch_hidden_fields:function(){this.detect_hidden_field_changes(),e.later(this.WATCH_HIDDEN_DELAY,this,this.watch_hidden_fields)},detect_hidden_field_changes:function(){this.form.all(this.SELECTORS.HIDDEN_INPUTS).each(function(e){var t=e.get("name"),n=e.get("value");if(!t)return;if(!(t in this.hidden_field_values)||n!==this.hidden_field_values[t])this.hidden_field_values[t]=n,this.value_changed({target:e})},this)},init_tinymce:function(t){if(typeof tinyMCE=="undefined"){t>0&&e.later(this.TINYMCE_DETECTION_DELAY,this,this.init_tinymce,[t-1]);return}this.editor_change_handler=e.bind(this.editor_changed,this),tinyMCE.onAddEditor.add(e.bind(this.init_tinymce_editor,this))},init_tinymce_editor:function(e,t){t.onChange.add(this.editor_change_handler),t.onRedo.add(this.editor_change_handler),t.onUndo.add(this.editor_change_handler),t.onKeyDown.add(this.editor_change_handler)},value_changed:function(e){if(e.target.get("name")==="thispage"||e.target.get("name")==="scrollpos"||e.target.get("name").match(/_:flagged$/))return;this.start_save_timer_if_necessary()},editor_changed:function(e){this.start_save_timer_if_necessary()},start_save_timer_if_necessary:function(){this.dirty=!0;if(this.delay_timer||this.save_transaction)return;this.start_save_timer()},start_save_timer:function(){this.cancel_delay(),this.delay_timer=e.later(this.delay,this,this.save_changes)},cancel_delay:function(){this.delay_timer&&this.delay_timer!==!0&&this.delay_timer.cancel(),this.delay_timer=null},save_changes:function(){this.cancel_delay(),this.dirty=!1;if(this.is_time_nearly_over()){this.stop_autosaving();return}typeof tinyMCE!="undefined"&&tinyMCE.triggerSave(),this.save_transaction=e.io(this.AUTOSAVE_HANDLER,{method:"POST",form:{id:this.form},on:{complete:this.save_done},context:this})},save_done:function(){this.save_transaction=null,this.dirty&&this.start_save_timer()},is_time_nearly_over:function(){return M.mod_quiz.timer&&M.mod_quiz.timer.endtime&&(new Date).getTime()+2*this.delay>M.mod_quiz.timer.endtime},stop_autosaving:function(){this.cancel_delay(),this.delay_timer=!0,this.save_transaction&&this.save_transaction.abort()}}},"@VERSION@",{requires:["base","node","event","event-valuechange","node-event-delegate","io-form"]});
|
||||
|
@ -120,9 +120,10 @@ M.mod_quiz.autosave = {
|
||||
* or enough time has passed.
|
||||
*/
|
||||
init_tinymce: function(repeatcount) {
|
||||
if (typeof tinymce === 'undefined') {
|
||||
if (typeof tinyMCE === 'undefined') {
|
||||
if (repeatcount > 0) {
|
||||
Y.later(this.TINYMCE_DETECTION_DELAY, this, this.init_tinymce, [repeatcount - 1]);
|
||||
} else {
|
||||
}
|
||||
return;
|
||||
}
|
||||
@ -144,7 +145,8 @@ M.mod_quiz.autosave = {
|
||||
},
|
||||
|
||||
value_changed: function(e) {
|
||||
if (e.target.get('name') === 'thispage' || e.target.get('name').match(/_:flagged$/)) {
|
||||
if (e.target.get('name') === 'thispage' || e.target.get('name') === 'scrollpos' ||
|
||||
e.target.get('name').match(/_:flagged$/)) {
|
||||
return; // Not interesting.
|
||||
}
|
||||
this.start_save_timer_if_necessary();
|
||||
@ -186,6 +188,9 @@ M.mod_quiz.autosave = {
|
||||
return;
|
||||
}
|
||||
|
||||
if (typeof tinyMCE !== 'undefined') {
|
||||
tinyMCE.triggerSave();
|
||||
}
|
||||
this.save_transaction = Y.io(this.AUTOSAVE_HANDLER, {
|
||||
method: 'POST',
|
||||
form: {id: this.form},
|
||||
|
10
mod/quiz/yui/src/autosave/js/autosave.js
vendored
10
mod/quiz/yui/src/autosave/js/autosave.js
vendored
@ -119,9 +119,11 @@ M.mod_quiz.autosave = {
|
||||
* or enough time has passed.
|
||||
*/
|
||||
init_tinymce: function(repeatcount) {
|
||||
if (typeof tinymce === 'undefined') {
|
||||
if (typeof tinyMCE === 'undefined') {
|
||||
if (repeatcount > 0) {
|
||||
Y.later(this.TINYMCE_DETECTION_DELAY, this, this.init_tinymce, [repeatcount - 1]);
|
||||
} else {
|
||||
Y.log('Gave up looking for TinyMCE.');
|
||||
}
|
||||
return;
|
||||
}
|
||||
@ -145,7 +147,8 @@ M.mod_quiz.autosave = {
|
||||
},
|
||||
|
||||
value_changed: function(e) {
|
||||
if (e.target.get('name') === 'thispage' || e.target.get('name').match(/_:flagged$/)) {
|
||||
if (e.target.get('name') === 'thispage' || e.target.get('name') === 'scrollpos' ||
|
||||
e.target.get('name').match(/_:flagged$/)) {
|
||||
return; // Not interesting.
|
||||
}
|
||||
Y.log('Detected a value change in element ' + e.target.get('name') + '.');
|
||||
@ -191,6 +194,9 @@ M.mod_quiz.autosave = {
|
||||
}
|
||||
|
||||
Y.log('Doing a save.');
|
||||
if (typeof tinyMCE !== 'undefined') {
|
||||
tinyMCE.triggerSave();
|
||||
}
|
||||
this.save_transaction = Y.io(this.AUTOSAVE_HANDLER, {
|
||||
method: 'POST',
|
||||
form: {id: this.form},
|
||||
|
Loading…
x
Reference in New Issue
Block a user