First Project w/ jQuery and SharePoint: An Image Slider
Ok, after all the intro articles, after setting up the scripting resource center, after researching and dodging the bullet for the past two weeks, I’m ready to start my first jQuery and SharePoint project. I’m going to try and implement a simple, image slider solution.
This will be a multiple article solution. I will document each step of the way with screenshots and descriptions, getting the basic, simple solution working, then take feedback from the people following the series to add refinements and enhancements to the solutions.
So here goes: The EUSP Handy Dandy Image Slider Solution for SharePoint. Follow at your own risk.
The Basic Setup
To begin the project, I created a blank site. That gives me a completely empty canvas to start from. Into that site, I put a picture library to hold the images that will appear in the EUSP Image Slider. For now, I left the default columns and settings on the library, with plans to modify it through a content type if the need arises.
While I’m at it, I also deleted the advertisement for Microsoft SharePoint Services and inserted by own logo. Might as well take advantage of it while I’ve got the chance.
Selecting Images for the Slider
The holiday season left me with a lot of pictures in my camera, so I’m going to use some of those to get the ball rolling. For this project, I pulled down about a dozen images, just so I can put the solution to a solid test. The images are stored within the Resources-Images library.
I purposely left them at different sizes. One of the enhancements I’d like to implement is the ability for the solution to handle different sized images.
Selection of a jQuery Slider Solutions
I spent the past two weeks collecting resources and links for various jQuery solutions I found interesting. There are literally dozens to choose from just from one simple search. In my case, I follow Smashing Magazine, especially their twitter feed, because of the high quality of links they provide. One of those links was “13 Super Useful jQuery Content Slider Scripts and Tutorials” on the WDL site.
After looking through the selections, I chose Chris Coyier’s “AnythingSlider jQuery Plugin“. This has a ton of features already built in, so hopefully, it will be a good way to learn about the various functionality available with jQuery and sliders.
First Mistake
I downloaded the resource files from Chris’ site, popped them open and started poking around. The first thing I found was an index.php file. I don’t have php running on my laptop, so I changed the file extension to .html and opened it in my web browser. Everything worked perfectly… oh, oh, that’s NOT supposed to happen. Where’s the call to jQuery? Where are the scripts? What’s going on here?
After closer examination, I see that the resources that I’ve downloaded are CSS files and javascripts, nothing to do with jQuery! I’ve downloaded my first project for jQuery, and failed by selecting a solution that doesn’t even use it. Kind of sad, when you think about it.
Update: A deeper, deeper dive shows that Chris has implemented some jQuery in the solution so all is not lost!
What’s Next
I like Chris’ solution a lot. There is a ton of functionality there. I’m going to go ahead and implement it as well as I can just to get a feel for getting something in the “wild” transformed and working in SharePoint. I’ll still document the process and point you to his resources, since I think the first objective is to get something useful to work.
I’ll get back to you in a day or two.
Mark
- SharePoint and jQuery for the Common Man
- SharePoint and jQuery for the Common Man: Resources
- Build a SharePoint Scripting Resource Center
- Resources for jQuery Projects in SharePoint
- First Project w/ jQuery and SharePoint: An Image Slider
Good start. It took me a couple hours of trial and error to figure this thing out: http://davecavins.com/2009/12/css-tricks-anythingslider-in-sharepoint/
I understand your purpose, but… if you can achieve the same result with pure JavaScript without the need for jQuery, isn’t it even better? No reason to be disapointed!
David – It looks like you’ve done all my work for me! Nice article. — Mark
Thanks for your great effort, kindly continue with your article, if possible let us know (as SharePoint Endsuers), how to have a solution for showing latest pictures as well as how to create archive of the gallery.
Hope this will benefit a lots of endusers(who are not developers).
Thanks
This is really cool! I just got this working on my site. The only question I have is it appears that the anythingslider object is left justifying itself in the webpart I place it in. I would like it centered. I can’t figure out what to change in order to do this… I’ve looked in the Slider.css and page.css files and didn’t find it in there.
Any thoughts?
Thanks for the idea. Live demo on my home page showing latest SharePoint Internet Sites.
http://www.wssdemo.com/
(just need to make the “love handles” a bit smaller and it will look like a regular web part)
@ Greg E, I know you got the answer to your question on Dave’s page but I am pasting it here for others to refer to in case they have the same question. Cheers!
davecavins said at 7:34 am on January 13th, 2010:
“@ Greg E, you should be able to center it in the webpart zone by adding some css to the “anythingSlider” div.
you can try this:
div.anythingSlider {text-align:center} It may mess up some of the formatting so I would suggest you wrap a div around the slider and use css to center its contents.
div.sliderwrapper {text-align:center; margin:0 auto;}
I will experiment with this and see if I can find a good solution.”