3 //If the UI scope is not available, add it
\r
6 //Make nodes selectable by expression
\r
7 $.extend($.expr[':'], { shadowed: "(' '+a.className+' ').indexOf(' ui-shadowed ')" });
\r
9 $.fn.shadowEnable = function() { if($(this[0]).next().is(".ui-shadow")) $(this[0]).next().show(); }
\r
10 $.fn.shadowDisable = function() { if($(this[0]).next().is(".ui-shadow")) $(this[0]).next().hide(); }
\r
12 $.fn.shadow = function(options) {
\r
14 options = options || {};
\r
15 options.offset = options.offset ? options.offset : 0;
\r
16 options.opacity = options.opacity ? options.opacity : 0.2;
\r
18 return this.each(function() {
\r
22 //Create a shadow element
\r
23 var shadow = $("<div class='ui-shadow'></div>"); cur.after(shadow);
\r
25 //Figure the base height and width
\r
26 var baseWidth = cur.outerWidth();
\r
27 var baseHeight = cur.outerHeight();
\r
30 var position = cur.position();
\r
32 //Append smooth corners
\r
33 $('<div class="ui-shadow-color ui-shadow-layer-1"></div>').css({ opacity: options.opacity-0.05, left: 5+options.offset, top: 5+options.offset, width: baseWidth+1, height: baseHeight+1 }).appendTo(shadow);
\r
34 $('<div class="ui-shadow-color ui-shadow-layer-2"></div>').css({ opacity: options.opacity-0.1, left: 7+options.offset, top: 7+options.offset, width: baseWidth, height: baseHeight-3 }).appendTo(shadow);
\r
35 $('<div class="ui-shadow-color ui-shadow-layer-3"></div>').css({ opacity: options.opacity-0.1, left: 7+options.offset, top: 7+options.offset, width: baseWidth-3, height: baseHeight }).appendTo(shadow);
\r
36 $('<div class="ui-shadow-color ui-shadow-layer-4"></div>').css({ opacity: options.opacity, left: 6+options.offset, top: 6+options.offset, width: baseWidth-1, height: baseHeight-1 }).appendTo(shadow);
\r
38 //If we have a color, use it
\r
40 $("div.ui-shadow-color", shadow).css("background-color", options.color);
\r
42 //Determine the stack order (attention: the zIndex will get one higher!)
\r
43 if(!cur.css("zIndex") || cur.css("zIndex") == "auto") {
\r
45 cur.css("position", (cur.css("position") == "static" ? "relative" : cur.css("position"))).css("z-index", "1");
\r
47 var stack = parseInt(cur.css("zIndex"));
\r
48 cur.css("zIndex", stack+1);
\r
51 //Copy the original z-index and position to the clone
\r
52 //alert(shadow); If you insert this alert, opera will time correctly!!
\r
54 position: "absolute",
\r
56 left: position.left,
\r
60 marginLeft: cur.css("marginLeft"),
\r
61 marginRight: cur.css("marginRight"),
\r
62 marginBottom: cur.css("marginBottom"),
\r
63 marginTop: cur.css("marginTop")
\r
67 function rearrangeShadow(el,sh) {
\r
69 $(sh).css($el.position());
\r
70 $(sh).children().css({ height: $el.outerHeight()+"px", width: $el.outerWidth()+"px" });
\r
73 if($.browser.msie) {
\r
74 //Add dynamic css expressions
\r
75 shadow[0].style.setExpression("left","parseInt(jQuery(this.previousSibling).css('left'))+'px' || jQuery(this.previousSibling).position().left");
\r
76 shadow[0].style.setExpression("top","parseInt(jQuery(this.previousSibling).css('top'))+'px' || jQuery(this.previousSibling).position().top");
\r
78 //Bind events for good browsers
\r
79 this.addEventListener("DOMAttrModified",function() { rearrangeShadow(this,shadow); },false);
\r