PageSourceSearch

https://www.actions4photoshop.com/atn/Scripts/ddsmoothmenu.js

js actions4photoshop.com collected 2026-10-06 02:47:00 UTC 8,027 bytes, 136 lines download raw bytes

1//** Smooth Navigational Menu- By Dynamic Drive DHTML code library: http://www.dynamicdrive.com
2//** Script Download/ instructions page: http://www.dynamicdrive.com/dynamicindex1/ddlevelsmenu/
3//** Menu created: Nov 12, 2008
4
5//** Dec 12th, 08" (v1.01): Fixed Shadow issue when multiple LIs within the same UL (level) contain sub menus: http://www.dynamicdrive.com/forums/showthread.php?t=39177&highlight=smooth
6
7//** Feb 11th, 09" (v1.02): The currently active main menu item (LI A) now gets a CSS class of ".selected", including sub menu items.
8
9//** May 1st, 09" (v1.3):
10//** 1) Now supports vertical (side bar) menu mode- set "orientation" to 'v'
11//** 2) In IE6, shadows are now always disabled
12
13//** July 27th, 09" (v1.31): Fixed bug so shadows can be disabled if desired.
14
15
16var ddsmoothmenu = {
17
18    //Specify full URL to down and right arrow images (23 is padding-right added to top level LIs with drop downs):
19    arrowimages: { down: ['downarrowclass', 'down.gif', 0], right: ['rightarrowclass', 'right.gif', 0] },
20
21    transition: { overtime: 0, outtime: 0 }, //duration of slide in/ out animation, in milliseconds
22    shadow: { enable: false, offsetx: 5, offsety: 5 },
23
24    ///////Stop configuring beyond here///////////////////////////
25
26    detectwebkit: navigator.userAgent.toLowerCase().indexOf("applewebkit") != -1, //detect WebKit browsers (Safari, Chrome etc)
27    detectie6: document.all && !window.XMLHttpRequest,
28
29    getajaxmenu: function ($, setting) { //function to fetch external page containing the panel DIVs
30        var $menucontainer = $('#' + setting.contentsource[0]) //reference empty div on page that will hold menu
31        $menucontainer.html("Loading Menu...")
32        $.ajax({
33            url: setting.contentsource[1], //path to external menu file
34            async: true,
35            error: function (ajaxrequest) {
36                $menucontainer.html('Error fetching content. Server Response: ' + ajaxrequest.responseText)
37            },
38            success: function (content) {
39                $menucontainer.html(content)
40                ddsmoothmenu.buildmenu($, setting)
41            }
42        })
43    },
44
45
46    buildmenu: function ($, setting) {
47        var smoothmenu = ddsmoothmenu
48        var $mainmenu = $("#" + setting.mainmenuid + ">ul") //reference main menu UL
49        $mainmenu.parent().get(0).className = setting.classname || "ddsmoothmenu"
50        var $headers = $mainmenu.find("ul").parent()
51        $headers.hover(
52		function (e) {
53		    $(this).children('a:eq(0)').addClass('selected')
54		},
55		function (e) {
56		    $(this).children('a:eq(0)').removeClass('selected')
57		}
58	)
59        $headers.each(function (i) { //loop through each LI header
60            var $curobj = $(this).css({ zIndex: 100 - i }) //reference current LI header
61            var $subul = $(this).find('ul:eq(0)').css({ display: 'block' })
62            this._dimensions = { w: this.offsetWidth, h: this.offsetHeight - 1, subulw: $subul.outerWidth(), subulh: $subul.outerHeight() }
63            this.istopheader = $curobj.parents("ul").length == 1 ? true : false //is top level header?
64            $subul.css({ top: this.istopheader && setting.orientation != 'v' ? this._dimensions.h + "px" : 0 })
65            /*$curobj.children("a:eq(0)").css(this.istopheader? {paddingRight: smoothmenu.arrowimages.down[2]} : {}).append( //add arrow images
66            '<img src="'+ (this.istopheader && setting.orientation!='v'? smoothmenu.arrowimages.down[1] : smoothmenu.arrowimages.right[1])
67            +'" class="' + (this.istopheader && setting.orientation!='v'? smoothmenu.arrowimages.down[0] : smoothmenu.arrowimages.right[0])
68            + '" style="border:0;" />'
69            )*/
70            if (smoothmenu.shadow.enable) {
71                this._shadowoffset = { x: (this.istopheader ? $subul.offset().left + smoothmenu.shadow.offsetx : this._dimensions.w), y: (this.istopheader ? $subul.offset().top + smoothmenu.shadow.offsety : $curobj.position().top)} //store this shadow's offsets
72                if (this.istopheader)
73                    $parentshadow = $(document.body)
74                else {
75                    var $parentLi = $curobj.parents("li:eq(0)")
76                    $parentshadow = $parentLi.get(0).$shadow
77                }
78                this.$shadow = $('<div class="ddshadow' + (this.istopheader ? ' toplevelshadow' : '') + '"></div>').prependTo($parentshadow).css({ left: this._shadowoffset.x + 'px', top: this._shadowoffset.y + 'px' })  //insert shadow DIV and set it to parent node for the next shadow div
79            }
80            $curobj.hover(
81			function (e) {
82			    var $targetul = $(this).children("ul:eq(0)")
83			    this._offsets = { left: $(this).offset().left, top: $(this).offset().top }
84			    var menuleft = this.istopheader && setting.orientation != 'v' ? 0 : this._dimensions.w
85			    menuleft = (this._offsets.left + menuleft + this._dimensions.subulw > $(window).width()) ? (this.istopheader && setting.orientation != 'v' ? -this._dimensions.subulw + this._dimensions.w : -this._dimensions.w) : menuleft //calculate this sub menu's offsets from its parent
86			    if ($targetul.queue().length <= 1) { //if 1 or less queued animations
87			        $targetul.css({ left: menuleft + "px", width: this._dimensions.subulw + 'px' }).animate({ height: 'show', opacity: 'show' }, ddsmoothmenu.transition.overtime)
88			        if (smoothmenu.shadow.enable) {
89			            var shadowleft = this.istopheader ? $targetul.offset().left + ddsmoothmenu.shadow.offsetx : menuleft
90			            var shadowtop = this.istopheader ? $targetul.offset().top + smoothmenu.shadow.offsety : this._shadowoffset.y
91			            if (!this.istopheader && ddsmoothmenu.detectwebkit) { //in WebKit browsers, restore shadow's opacity to full
92			                this.$shadow.css({ opacity: 1 })
93			            }
94			            this.$shadow.css({ overflow: '', width: this._dimensions.subulw + 'px', left: shadowleft + 'px', top: shadowtop + 'px' }).animate({ height: this._dimensions.subulh + 'px' }
94, ddsmoothmenu.transition.overtime)
95			        }
96			    }
97			},
98			function (e) {
99			    var $targetul = $(this).children("ul:eq(0)")
100			    $targetul.animate({ height: 'hide', opacity: 'hide' }, ddsmoothmenu.transition.outtime)
101			    if (smoothmenu.shadow.enable) {
102			        if (ddsmoothmenu.detectwebkit) { //in WebKit browsers, set first child shadow's opacity to 0, as "overflow:hidden" doesn't work in them
103			            this.$shadow.children('div:eq(0)').css({ opacity: 0 })
104			        }
105			        this.$shadow.css({ overflow: 'hidden' }).animate({ height: 0 }, ddsmoothmenu.transition.outtime)
106			    }
107			}
108		) //end hover
109        }) //end $headers.each()
110        $mainmenu.find("ul").css({ display: 'none', visibility: 'visible' })
111    },
112
113    init: function (setting) {
114        if (typeof setting.customtheme == "object" && setting.customtheme.length == 2) { //override default menu colors (default/hover) with custom set?
115            var mainmenuid = '#' + setting.mainmenuid
116            var mainselector = (setting.orientation == "v") ? mainmenuid : mainmenuid + ', ' + mainmenuid
117            document.write('<style type="text/css">\n'
118			+ mainselector + ' ul li a {background:' + setting.customtheme[0] + ';}\n'
119			+ mainmenuid + ' ul li a:hover {background:' + setting.customtheme[1] + ';}\n'
120		+ '</style>')
121        }
122        this.shadow.enable = (document.all && !window.XMLHttpRequest) ? false : this.shadow.enable //in IE6, always disable shadow
123        jQuery(document).ready(function ($) { //ajax menu?
124            if (typeof setting.contentsource == "object") { //if external ajax menu
125                ddsmoothmenu.getajaxmenu($, setting)
126            }
127            else { //else if markup menu
128                ddsmoothmenu.buildmenu($, setting)
129            }
130        })
131    }
132
133} //end ddsmoothmenu variable
134
135//Initialize Menu instance(s):
136

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.