-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSP_documentLibraryFix.html
35 lines (30 loc) · 1.18 KB
/
SP_documentLibraryFix.html
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
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script>
ExecuteOrDelayUntilScriptLoaded(Initialize, "sp.js");
function Initialize()
{
var allDocuments = toArray(getLinksWithExtension(".doc"));
allDocuments = allDocuments.concat(toArray(getLinksWithExtension(".pdf")));
allDocuments = allDocuments.concat(toArray(getLinksWithExtension(".xls")));
allDocuments = allDocuments.concat(toArray(getLinksWithExtension(".txt")));
for(var i = 0; i < allDocuments.length; i++)
{
var currentDocument = $(allDocuments[i]);
var currentHref = currentDocument.attr("href");
var linkHtml = "<a style='cursor: pointer;' href='" + currentHref + "'></a>";
var parentRow = currentDocument.closest("tr");
var iconElement = parentRow.find(".ms-vb-icon > img");
var titleElement = $(parentRow.find(".ms-vb2")[0]);
iconElement.wrap( linkHtml );
titleElement.wrap( linkHtml );
}
}
function getLinksWithExtension(extension) {
var links = document.querySelectorAll('a[href*="' + extension + '"]');
return links;
}
function toArray(nl) {
for(var a=[], l=nl.length; l--; a[l]=nl[l]);
return a;
}
</script>