changed git call from https to git readonly
[atutor.git] / mods / photo_album / fluid / component-templates / js / jquery.ui-1.0 / ui.shadow.js
1 (function($) {\r
2 \r
3         //If the UI scope is not available, add it\r
4         $.ui = $.ui || {};\r
5         \r
6         //Make nodes selectable by expression\r
7         $.extend($.expr[':'], { shadowed: "(' '+a.className+' ').indexOf(' ui-shadowed ')" });\r
8         \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
11         \r
12         $.fn.shadow = function(options) {\r
13                 \r
14                 options = options || {};\r
15                 options.offset = options.offset ? options.offset : 0;\r
16                 options.opacity = options.opacity ? options.opacity : 0.2;\r
17                 \r
18                 return this.each(function() {\r
19                         \r
20                         var cur = $(this);\r
21                         \r
22                         //Create a shadow element\r
23                         var shadow = $("<div class='ui-shadow'></div>"); cur.after(shadow);\r
24                         \r
25                         //Figure the base height and width\r
26                         var baseWidth = cur.outerWidth();\r
27                         var baseHeight = cur.outerHeight();\r
28                         \r
29                         //get the offset\r
30                         var position = cur.position();\r
31                         \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
37                         \r
38                         //If we have a color, use it\r
39                         if(options.color)\r
40                                 $("div.ui-shadow-color", shadow).css("background-color", options.color);\r
41                         \r
42                         //Determine the stack order (attention: the zIndex will get one higher!)\r
43                         if(!cur.css("zIndex") || cur.css("zIndex") == "auto") {\r
44                                 var stack = 0;\r
45                                 cur.css("position", (cur.css("position") == "static" ? "relative" : cur.css("position"))).css("z-index", "1");\r
46                         } else {\r
47                                 var stack = parseInt(cur.css("zIndex"));\r
48                                 cur.css("zIndex", stack+1);\r
49                         }\r
50                         \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
53                         shadow.css({\r
54                                 position: "absolute",\r
55                                 zIndex: stack,\r
56                                 left: position.left,\r
57                                 top: position.top,\r
58                                 width: baseWidth,\r
59                                 height: baseHeight,\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
64                         });\r
65                         \r
66                         \r
67                         function rearrangeShadow(el,sh) {\r
68                                 var $el = $(el);\r
69                                 $(sh).css($el.position());\r
70                                 $(sh).children().css({ height: $el.outerHeight()+"px", width: $el.outerWidth()+"px" });\r
71                         }\r
72                         \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
77                         } else {\r
78                                 //Bind events for good browsers\r
79                                 this.addEventListener("DOMAttrModified",function() { rearrangeShadow(this,shadow); },false);\r
80                         }\r
81 \r
82                                 \r
83                 });\r
84         };\r
85         \r
86 \r
87 })($);