564edf5b4c55d5371fb4724e71260fba06d86e62
2 /* - unlockOnFormUnload.js - */
4 Plone unlock handler; attaches an unlock handler to $('form.enableUnlockProtection')
10 /*global plone:true, setInterval:false, clearInterval:false */
11 /*jslint nomen:false */
13 /* Unlock the object on form unload, and refresh the lock every 5 minutes */
14 if (typeof(plone
) === 'undefined') {
19 plone
.UnlockHandler
= {
21 // set up the handler, if there are any forms
22 if ($('form.enableUnlockProtection').length
) {
23 $(window
).unload(plone
.UnlockHandler
.execute
);
24 plone
.UnlockHandler
._refresher
= setInterval(plone
.UnlockHandler
.refresh
, 300000);
29 $(window
).unbind('unload', plone
.UnlockHandler
.execute
);
30 clearInterval(plone
.UnlockHandler
._refresher
);
34 // this.submitting is set from the form unload handler
35 // (formUnload.js) and signifies that we are in the
36 // form submit process. This means: no unlock needed,
37 // and it also would be harmful (ConflictError)
38 if (this.submitting
) {return;}
39 $.get(plone
.UnlockHandler
._baseUrl() + '/@@plone_lock_operations/safe_unlock');
43 if (this.submitting
) {return;}
44 $.get(plone
.UnlockHandler
._baseUrl() + '/@@plone_lock_operations/refresh_lock');
47 _baseUrl: function() {
50 baseUrl
= $('base').attr('href');
52 pieces
= window
.location
.href
.split('/');
54 baseUrl
= pieces
.join('/');
60 $(plone
.UnlockHandler
.init
);