-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSPP_CheckOut.js
More file actions
35 lines (32 loc) · 1.3 KB
/
Copy pathSPP_CheckOut.js
File metadata and controls
35 lines (32 loc) · 1.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
/*
SPP_CheckOut Plugin written by John Green for The Physician's Postgraduate Press in May, 2019
The prupose of this plugin is to extend SharePointPlus's capabilities to allow checking files out.
(The library has a native check-in function, but no checkout function).
*/
$SP().registerPlugin('CheckOut', function(setup) {
// default values
var _this=this;
return _this._promise(function(prom_resolve, prom_reject) {
setup = setup || {};
if (!setup.destination) throw "[SharepointPlus Plugin 'CheckOut'] the file destination path is required.";
setup.url = ((setup.url ===undefined)?window.location.protocol + '//' + window.location.hostname:setup.url);
setup.toLocal = ((setup.toLocal ===undefined)?false:setup.toLocal);
_this.ajax({
url: setup.url + "/_vti_bin/Lists.asmx",
body:_this._buildBodyForSOAP("CheckOutFile",
'<pageUrl>'+setup.destination+'</pageUrl>'+
'<checkoutToLocal>'+setup.toLocal+'</checkoutToLocal>'
),
headers:{'SOAPAction':'http://schemas.microsoft.com/sharepoint/soap/CheckOutFile'}
}).then(function(data) {
var res = data.getElementsByTagName('CheckOutFileResult');
res = (res.length>0 ? res[0] : null);
if (res && res.firstChild.nodeValue != "true") {
prom_reject(res);
} else {
prom_resolve();
}
},
function(err) { prom_reject(err) });
});
});