~ubuntu-branches/ubuntu/trusty/moodle/trusty

« back to all changes in this revision

Viewing changes to mod/quiz/yui/build/moodle-mod_quiz-autosave/moodle-mod_quiz-autosave.js

  • Committer: Package Import Robot
  • Author(s): Thijs Kinkhorst
  • Date: 2014-01-21 13:40:52 UTC
  • mfrom: (1.1.13)
  • Revision ID: package-import@ubuntu.com-20140121134052-ym2qvsp2cd9vq0p6
Tags: 2.5.4-1
* New upstream release, fixing security issues:
  - MSA-14-0001 Config passwords visibility issue [CVE-2014-0008]
  - MSA-14-0002 Group constraints lacking in "login as" [CVE-2014-0009]
  - MSA-14-0003 CSRF vulnerability in profile fields [CVE-2014-0010]
* Move /var/lib/moodle directory into package.
* Revert back to bundled yui3. Unfortunately, version in Debian and
  of upstream are not compatible (closes: #735312).

Show diffs side-by-side

added added

removed removed

Lines of Context:
30
30
    TINYMCE_DETECTION_DELAY:  500,
31
31
    TINYMCE_DETECTION_REPEATS: 20,
32
32
    WATCH_HIDDEN_DELAY:      1000,
 
33
    FAILURES_BEFORE_NOTIFY:     1,
 
34
    FIRST_SUCCESSFUL_SAVE:     -1,
33
35
 
34
36
    /** Selectors. */
35
37
    SELECTORS: {
36
38
        QUIZ_FORM:             '#responseform',
37
39
        VALUE_CHANGE_ELEMENTS: 'input, textarea',
38
40
        CHANGE_ELEMENTS:       'input, select',
39
 
        HIDDEN_INPUTS:         'input[type=hidden]'
 
41
        HIDDEN_INPUTS:         'input[type=hidden]',
 
42
        CONNECTION_ERROR:      '#connection-error',
 
43
        CONNECTION_OK:         '#connection-ok'
40
44
    },
41
45
 
42
46
    /** Script that handles the auto-saves. */
57
61
    /** Y.io transaction for the save ajax request. */
58
62
    save_transaction: null,
59
63
 
 
64
    /** @property Failed saves count. */
 
65
    savefailures: 0,
 
66
 
60
67
    /** Properly bound key change handler. */
61
68
    editor_change_handler: null,
62
69
 
 
70
    /** Record of the value of all the hidden fields, last time they were checked. */
63
71
    hidden_field_values: {},
64
72
 
65
73
    /**
194
202
        this.save_transaction = Y.io(this.AUTOSAVE_HANDLER, {
195
203
            method:  'POST',
196
204
            form:    {id: this.form},
197
 
            on:      {complete: this.save_done},
 
205
            on:      {
 
206
                success: this.save_done,
 
207
                failure: this.save_failed
 
208
            },
198
209
            context: this
199
210
        });
200
211
    },
205
216
        if (this.dirty) {
206
217
            this.start_save_timer();
207
218
        }
 
219
 
 
220
        if (this.savefailures > 0) {
 
221
            Y.one(this.SELECTORS.CONNECTION_ERROR).hide();
 
222
            Y.one(this.SELECTORS.CONNECTION_OK).show();
 
223
            this.savefailures = this.FIRST_SUCCESSFUL_SAVE;
 
224
        } else if (this.savefailures === this.FIRST_SUCCESSFUL_SAVE) {
 
225
            Y.one(this.SELECTORS.CONNECTION_OK).hide();
 
226
            this.savefailures = 0;
 
227
        }
 
228
    },
 
229
 
 
230
    save_failed: function() {
 
231
        this.save_transaction = null;
 
232
 
 
233
        // We want to retry soon.
 
234
        this.start_save_timer();
 
235
 
 
236
        this.savefailures = Math.max(1, this.savefailures + 1);
 
237
        if (this.savefailures === this.FAILURES_BEFORE_NOTIFY) {
 
238
            Y.one(this.SELECTORS.CONNECTION_ERROR).show();
 
239
            Y.one(this.SELECTORS.CONNECTION_OK).hide();
 
240
        }
208
241
    },
209
242
 
210
243
    is_time_nearly_over: function() {