Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on May 2nd, 2012  |  syntax: None  |  size: 3.28 KB  |  hits: 19  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. Jquery image slide from Sharepoint picture library
  2. <IMG ID="slideshowPicturePlaceholder" src="/_layouts/images/GEARS_AN.GIF" style="display:none"/>
  3. <center><div id="slideshowContentArea" style="display:none; width:255px;">
  4.     <div class='nav'><a id='prev' href='#'>Prev</a><a id='next' href='#'>Next</a></div>
  5.     <div id="slideshow" class="pics" style="position: relative; overflow-x: hidden; overflow-y: hidden; height:255px; width:255px">&nbsp;</div>
  6. </div></center>
  7.  
  8. <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script>
  9.  
  10. <script type="text/javascript" src="http://malsup.github.com/chili-1.7.pack.js"></script>
  11.  
  12. <script type="text/javascript" src="http://cloud.github.com/downloads/malsup/cycle/jquery.cycle.all.2.72.js"></script>
  13.  
  14.  
  15. <script>
  16.  function GetAllImages()
  17. {
  18. $("#slideshowPicturePlaceholder").css("display", "block");    
  19. var soapEnv = "<soapenv:Envelope xmlns:soapenv='http://schemas.xmlsoap.org/soap/envelope/'><soapenv:Body><GetListItems xmlns='http://schemas.microsoft.com/sharepoint/soap/'>";
  20.     //The name of the image library is called 'SlideShow'. Replace the name bewlo with the name of your image library
  21.  soapEnv += "<listName>SlideShow</listName>";
  22.     soapEnv += "<query><Query><OrderBy Override='TRUE'><FieldRef Name='Created' Ascending='FALSE' /></OrderBy></Query></query>";
  23.     soapEnv += "<viewFields><ViewFields><FieldRef Name='Title'/><FieldRef Name='ows_FileLeafRef'/></ViewFields></viewFields><rowLimit></rowLimit>";
  24.     soapEnv += "</GetListItems></soapenv:Body></soapenv:Envelope>";
  25.  
  26. var port = window.location.port;
  27. if (port.length <= 0)
  28.  port = "";
  29. else
  30.  port = ":"+port;
  31. var webservice = window.location.protocol+"//"+window.location.hostname+port+L_Menu_BaseUrl+"/_vti_bin/lists.asmx";
  32.  
  33.     $.ajax({
  34.         url: webservice,
  35.         type: "POST",
  36.         dataType: "xml",
  37.         data: soapEnv,
  38.         complete: processQueryResults,
  39.         contentType: "text/xml; charset=utf-8",
  40.          error: function(xhr) {
  41.         alert('Error!  Status = ' + xhr.status);}
  42.     });
  43. }
  44.  
  45. function onAfter(curr, next, opts) {
  46.     var index = opts.currSlide;
  47.     $('#prev')[index == 0 ? 'hide' : 'show']();
  48.     $('#next')[index == opts.slideCount - 1 ? 'hide' : 'show']();
  49. }
  50.  
  51. function processQueryResults(xData, status)
  52. {
  53. var port = window.location.port;
  54. if (port.length <= 0)
  55.  port = "";
  56. else
  57.  port = ":"+port;
  58. //Change the below to point to your image library
  59. var imageURL = window.location.protocol+"//"+window.location.hostname+port+L_Menu_BaseUrl+"/SlideShow/";
  60. var itemURL = window.location.protocol+"//"+window.location.hostname+port+L_Menu_BaseUrl+"/SlideShow/Forms/DispForm.aspx?ID=";
  61.  
  62.  
  63. $(xData.responseXML).find("z\:row").each(function() {
  64.   var title = $(this).attr("ows_Title");
  65.   var imageLink = imageURL+$(this).attr("ows_FileLeafRef").substring($(this).attr("ows_FileLeafRef").indexOf('#')+1);
  66.   var itemLink = itemURL+$(this).attr("ows_ID");
  67.   var Html ="<a target='_blank' border='0' href='"+itemLink+"'><img width='250' height='250'  src='"+ imageLink +"'/></a>";
  68.  
  69.         $("#slideshow").append(Html);
  70.     });
  71.  
  72. $("#slideshowPicturePlaceholder").css("display", "none");
  73. $("#slideshowContentArea").css("display", "block");
  74. $('#slideshow').cycle({fx:'scrollHorz',prev:'#prev',next:'#next',after:onAfter,timeout:0});
  75.  
  76. }
  77.  
  78. GetAllImages();
  79. </script>