Created
September 14, 2013 15:16
-
-
Save dinnouti/6562830 to your computer and use it in GitHub Desktop.
jQuery Shadowbox and Photo Library
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- script begin --> | |
<script type="text/javascript" src="/_layouts/js/jquery-1.3.2.min.js"></script> | |
<script type="text/javascript" src="/_layouts/js/shadowbox/shadowbox.js"></script> | |
<link rel="stylesheet" type="text/css" href="/_layouts/js/shadowbox/shadowbox.css"> | |
<script type="text/javascript"> | |
Shadowbox.init({ | |
language: 'en', | |
players: ['img','swf','flv'] | |
}); | |
</script> | |
<script type="text/javascript"> | |
PhotoOftheMonthWebService(); | |
function PhotoOftheMonthWebService(){ | |
var soapEnv = " \ | |
<soapenv:Envelope xmlns:soapenv='http://schemas.xmlsoap.org/soap/envelope/'> \ | |
<soapenv:Body> \ | |
<GetListItems xmlns='http://schemas.microsoft.com/sharepoint/soap/'> \ | |
<listName>{903556F0-543A-4E7E-A2A4-B4461C4ACAE0}</listName> \ | |
<query><Query><OrderBy><FieldRef Name='Modified' Ascending='False' /></OrderBy></Query></query> \ | |
<viewFields> \ | |
<ViewFields> \ | |
<FieldRef Name='EncodedAbsThumbnailUrl' /> \ | |
<FieldRef Name='FileRef' /> \ | |
<FieldRef Name='EncodedAbsWebImgUrl' /> \ | |
<FieldRef Name='Title'/> \ | |
<FieldRef Name='Description'/> \ | |
<FieldRef Name='NameOrTitle' /> \ | |
<FieldRef Name='Modified' /> \ | |
</ViewFields> \ | |
</viewFields> \ | |
<RowLimit>1</RowLimit> \ | |
</GetListItems> \ | |
</soapenv:Body> \ | |
</soapenv:Envelope>"; | |
$.ajax({ | |
url: "/_vti_bin/lists.asmx", | |
type: "POST", | |
dataType: "xml", | |
data: soapEnv, | |
complete: processResult, | |
contentType: "text/xml; charset=\"utf-8\"" | |
}); | |
}; | |
function processResult(xData, status) { | |
var isFirst = 1; | |
jQuery(xData.responseXML).find("z\\:row").each(function() { | |
var url = jQuery(this).attr("ows_FileRef"); | |
url = url.substring(url.indexOf(';#') + 2); | |
var title = jQuery(this).attr("ows_Title"); | |
if (title == undefined) | |
title = jQuery(this).attr("ows_NameOrTitle"); | |
if (jQuery(this).attr("ows_Description") != undefined) | |
title += " – "+ jQuery(this).attr("ows_Description"); | |
var divPOTM = ''; | |
if (isFirst == 1){ | |
divPOTM += '<center>'; | |
divPOTM += title; | |
divPOTM += ' | |
'; | |
divPOTM += '<img src="'+ jQuery(this).attr("ows_EncodedAbsThumbnailUrl") +'"/>'; | |
divPOTM += ' | |
<a href="'+ jQuery(this).attr("ows_EncodedAbsWebImgUrl") +'" rel="shadowbox[POTM]" title="'+ title +'">View Slideshow</a>'; | |
divPOTM += '</center>'; | |
isFirst = 2; | |
} else { | |
divPOTM += '<p>'; | |
divPOTM += '<a href="'+ jQuery(this).attr("ows_EncodedAbsWebImgUrl") +'" rel="shadowbox[POTM]" title="'+ title +'"></a>'; | |
divPOTM += '</p>'; | |
}; | |
jQuery("#ciPhotoOfTheMonth").append(divPOTM); | |
}); | |
Shadowbox.setup(); | |
}; // end of processResult | |
</script> | |
<span id="ciPhotoOfTheMonth"></span> | |
<!-- script end --> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment