2 Plone unlock handler; attaches an unlock handler to $('form.enableUnlockProtection')
8 /*global plone:true, setInterval:false, clearInterval:false */
9 /*jslint nomen:false */
11 /* Unlock the object on form unload, and refresh the lock every 5 minutes */
12 if (typeof(plone
) === 'undefined') {
17 plone
.UnlockHandler
= {
19 // set up the handler, if there are any forms
20 if ($('form.enableUnlockProtection').length
) {
21 $(window
).unload(plone
.UnlockHandler
.execute
);
22 plone
.UnlockHandler
._refresher
= setInterval(plone
.UnlockHandler
.refresh
, 300000);
27 $(window
).unbind('unload', plone
.UnlockHandler
.execute
);
28 clearInterval(plone
.UnlockHandler
._refresher
);
32 // this.submitting is set from the form unload handler
33 // (formUnload.js) and signifies that we are in the
34 // form submit process. This means: no unlock needed,
35 // and it also would be harmful (ConflictError)
36 if (this.submitting
) {return;}
37 $.get(plone
.UnlockHandler
._baseUrl() + '/@@plone_lock_operations/safe_unlock');
41 if (this.submitting
) {return;}
42 $.get(plone
.UnlockHandler
._baseUrl() + '/@@plone_lock_operations/refresh_lock');
45 _baseUrl: function() {
48 baseUrl
= $('base').attr('href');
50 pieces
= window
.location
.href
.split('/');
52 baseUrl
= pieces
.join('/');
58 $(plone
.UnlockHandler
.init
);