In this article I will describe how to implement and use the jQuery shadow plugin to create great looking shadowed panels within your XPages application.
The demonstration database can be downloaded from the link above or from here
“Adapted from Nicholas Gallagher’s CSS drop shadows without images demo “
Adding “depth” to the visual aspect of your website is one of those things which can make them “pop” (pun intended). Using the shadow plugin, one line of code can be the difference between “meh” and “wow”.
Here’s the nice bit IE9, Firefox 3.5 Chrome, Safari – which means it works in XPiNC as well, and that’s sweet!
How does it work?
The main driver behind this plugin is really Nicholas Gallagher’s CSS drop shadows without images demo. The plug author just wrapped it as a jQuery plugin to make his and everyone else’s life easier.
Using the plugin could not be easier. Using the normal jQuery selector you identify the design element(s) you want to add a shadow to and then determine which type of shadow to add.
We add the plugin to the WebContent folder within our database and reference it in our source code
<script src="jquery-shadow/jquery.shadow.js"></script> <link rel="stylesheet" href="jquery-shadow/jquery.shadow.css" />
And then add the code to call the plugin updating the elements with the vpDemo class
The first example you can see on the website is just a simple view panel. You click the but to. And you can see the effect.
The second example is an xe:widgetContainer widget from the extension library – this has a dojo stylesheet already applied but the shadow works nicely
The final example allows you appling it to the xp:panel.
There are other styles available other than ‘raised’ check out the website demo examples to see the others but be aware that they do not all work in all browsers.
As with most of the plugins in this series – for next to no effort, you get a big payoff in user interface enhancements. In this case even more so because this is all CSS3 and no images necessary.
Just a note
Many people ask me how long it really takes to create the demos and get the functionality into the database.
Well figured this out at 3pm this afternoon, finished work (at 5pm), cooked dinner for the kids, went to a school PTA meeting, put the kids to bed, started writing the blog and finished the demo by 11pm – so not long really🙂
Caveat from the author
These are his words on the git hub repo – heed them, or not🙂
“The purpose of this is to make it easier, as you don’t need to remember the specific css class names.
However, this is extremely bad practice… and should not be used for a production site, but feel free to use it for prototyping…”