Showing
7 changed files
with
623 additions
and
0 deletions
pom.xml
0 → 100644
1 | +<?xml version="1.0"?> | |
2 | +<project> | |
3 | + <parent> | |
4 | + <groupId>org.richfaces.sandbox</groupId> | |
5 | + <artifactId>ui</artifactId> | |
6 | + <version>3.3.3.Final</version> | |
7 | + </parent> | |
8 | + <modelVersion>4.0.0</modelVersion> | |
9 | + <groupId>org.richfaces.sandbox.ui</groupId> | |
10 | + <artifactId>dock</artifactId> | |
11 | + <name>dock</name> | |
12 | + <build> | |
13 | + <plugins> | |
14 | + <plugin> | |
15 | + <groupId>org.richfaces.cdk</groupId> | |
16 | + <artifactId>maven-cdk-plugin</artifactId> | |
17 | + <version>${project.version}</version> | |
18 | + <executions> | |
19 | + <execution> | |
20 | + <phase>generate-sources</phase> | |
21 | + <goals> | |
22 | + <goal>generate</goal> | |
23 | + </goals> | |
24 | + </execution> | |
25 | + </executions> | |
26 | + <configuration> | |
27 | + <library> | |
28 | + <prefix>org.richfaces.sandbox.ui</prefix> | |
29 | + <taglib> | |
30 | + <shortName>dock</shortName> | |
31 | + <uri>http://richfaces.org/sandbox/dock</uri> | |
32 | + </taglib> | |
33 | + </library> | |
34 | + </configuration> | |
35 | + </plugin> | |
36 | + <plugin> | |
37 | + <artifactId>maven-compiler-plugin</artifactId> | |
38 | + <inherited>true</inherited> | |
39 | + <configuration> | |
40 | + <source>1.5</source> | |
41 | + <target>1.5</target> | |
42 | + <encoding>${project.build.sourceEncoding}</encoding> | |
43 | + </configuration> | |
44 | + </plugin> | |
45 | + <plugin> | |
46 | + <groupId>org.apache.maven.plugins</groupId> | |
47 | + <artifactId>maven-resources-plugin</artifactId> | |
48 | + <version>2.2</version> | |
49 | + <configuration> | |
50 | + <encoding>${project.build.sourceEncoding}</encoding> | |
51 | + </configuration> | |
52 | + </plugin> | |
53 | + </plugins> | |
54 | + </build> | |
55 | + <dependencies> | |
56 | + <dependency> | |
57 | + <groupId>org.richfaces.framework</groupId> | |
58 | + <artifactId>richfaces-impl</artifactId> | |
59 | + <version>${project.version}</version> | |
60 | + </dependency> | |
61 | + </dependencies> | |
62 | + <properties> | |
63 | + <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> | |
64 | + </properties> | |
65 | + <distributionManagement> | |
66 | + <repository> | |
67 | + <id>bernard.labno.pl</id> | |
68 | + <name>MyCo Internal Repository</name> | |
69 | + <url>http://bernard.labno.pl/artifactory/libs-release-local</url> | |
70 | + </repository> | |
71 | + </distributionManagement> | |
72 | + | |
73 | +</project> | ... | ... |
src/main/config/component/dock.xml
0 → 100644
1 | +<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE components PUBLIC "-//AJAX4JSF//CDK Generator config/EN" | |
2 | + "http://labs.jboss.com/jbossrichfaces/component-config.dtd" | |
3 | + > | |
4 | +<components> | |
5 | + <component> | |
6 | + <name>org.richfaces.Dock</name> | |
7 | + <family>org.richfaces.Dock</family> | |
8 | + <classname>org.richfaces.component.html.HtmlDock</classname> | |
9 | + <superclass>org.richfaces.component.UIDock</superclass> | |
10 | + <description> | |
11 | + The Dock - as anyone familiar with a Mac will know - is a set of iconic images that expand when rolled over | |
12 | + with the cursor, and usually perform some action when clicked. This plugin mimics that behaviour by | |
13 | + transforming a contiguous set of HTML images into an expanding Dock, vertical or horizontal, with or without | |
14 | + labels. | |
15 | + </description> | |
16 | + <renderer generate="false" override="true"> | |
17 | + <name>org.richfaces.DockRenderer</name> | |
18 | + <classname>org.richfaces.renderkit.html.DockRenderer</classname> | |
19 | + </renderer> | |
20 | + <tag> | |
21 | + <name>dock</name> | |
22 | + <classname>org.richfaces.taglib.DockTag</classname> | |
23 | + <superclass> | |
24 | + org.ajax4jsf.webapp.taglib.HtmlComponentTagBase | |
25 | + </superclass> | |
26 | + <!-- | |
27 | + <test> | |
28 | + <classname>org.richfaces.taglib.HtmlDockTagTest</classname> | |
29 | + <superclassname>org.ajax4jsf.tests.AbstractJspTestCase</superclassname> | |
30 | + </test> | |
31 | + --> | |
32 | + | |
33 | + </tag> | |
34 | + | |
35 | + &ui_component_attributes; | |
36 | + &html_style_attributes; | |
37 | + | |
38 | + <property> | |
39 | + <name>active</name> | |
40 | + <classname>int</classname> | |
41 | + <description> | |
42 | + This designates one of the menu's elements to be fully expanded when the dock is initialised. The option | |
43 | + takes a zero-based index of the position of the desired menu element (image) within the dock - so if you | |
44 | + want the 4th of 6 images to be expanded, set active : 3. | |
45 | + | |
46 | + Warning : There are consequences to using this option, which might possibly only become apparent when | |
47 | + you try it. I have provided it because it has specifically been requested, but ... if you set a mid-menu | |
48 | + image initially active, and the user then enters the dock at either end, it is quite likely that the | |
49 | + dock will simply collapse to its 'at rest' state because the resultant animation takes the mouse off the | |
50 | + dock! | |
51 | + </description> | |
52 | + <defaultvalue>-1</defaultvalue> | |
53 | + </property> | |
54 | + | |
55 | + <property> | |
56 | + <name>align</name> | |
57 | + <classname>java.lang.String</classname> | |
58 | + <description> | |
59 | + values = 'top', 'middle', 'bottom', left', center', 'right' | |
60 | + | |
61 | + Fixes the horizontal/vertical main axis, and direction of expansion. | |
62 | + | |
63 | + For a horizontal menu: | |
64 | + * 'top' : fixes the top edge of the dock, so that images expand down | |
65 | + * 'middle' : fixes the middle of the images, so that images expand up and down equally | |
66 | + * 'bottom' : fixes the bottom edge of the dock, so that images expand up | |
67 | + | |
68 | + For a vertical menu: | |
69 | + * 'left' : fixes the left edge of the dock, so that images expand right | |
70 | + * 'center' : fixes the center of the images, so that images expand left and right equally | |
71 | + * 'right' : fixes the right edge of the dock, so that images expand left | |
72 | + </description> | |
73 | + <defaultvalue>"bottom"</defaultvalue> | |
74 | + </property> | |
75 | + | |
76 | + <property> | |
77 | + <name>coefficient</name> | |
78 | + <classname>double</classname> | |
79 | + <description> | |
80 | + Attenuation coefficient. This controls the relationship between the distance from the cursor and the | |
81 | + amount of expansion of any affected image within that distance. A coefficient of 1 makes the expansion | |
82 | + linear with respect to distance from cursor; a larger coefficient gives a greater degree of expansion | |
83 | + the closer to the cursor the affected image is (within distance). # distance : integer, default = 72 | |
84 | + Attenuation distance from cursor, ie the distance (in pixels) from the cursor that an image has to be | |
85 | + within in order to have any expansion applied. | |
86 | + | |
87 | + Note that attenuation is always calculated as if the Dock was 'at rest' (no images expanded), even | |
88 | + though there may be expanded images at the time. | |
89 | + </description> | |
90 | + <defaultvalue>1.5</defaultvalue> | |
91 | + </property> | |
92 | + | |
93 | + <property> | |
94 | + <name>duration</name> | |
95 | + <classname>int</classname> | |
96 | + <description> | |
97 | + The duration (in milliseconds) of the initial 'on-Dock' expansion, and the 'off-Dock' shrinkage. | |
98 | + </description> | |
99 | + <defaultvalue>300</defaultvalue> | |
100 | + </property> | |
101 | + | |
102 | + <property> | |
103 | + <name>fadeIn</name> | |
104 | + <classname>int</classname> | |
105 | + <description> | |
106 | + The amount of time (in milliseconds) for the initial fade-in of the Dock after initialisation. By | |
107 | + default this is set to 0 (zero), which means that the Dock is displayed in full as soon as it can be ( = | |
108 | + show() ). There may be occasions when a 'softer' presentation of the Dock is desirable, and setting | |
109 | + fadeIn to, for example, 400 would fade the Dock in over that period. | |
110 | + </description> | |
111 | + <defaultvalue>0</defaultvalue> | |
112 | + </property> | |
113 | + | |
114 | + <property> | |
115 | + <name>fadeLayer</name> | |
116 | + <classname>java.lang.String</classname> | |
117 | + <description> | |
118 | + By default the fade-in effect (see fadeIn above) is applied to the original target menu element. By | |
119 | + specifying either 'wrap' or 'dock' here, the fade-in element can be switched to the child or grand-child | |
120 | + (ie. div.jqDockWrap or div.jqDock, respectively) of the original target menu element. This option only | |
121 | + has any effect if fadeIn is set, and is really only useful for cases where, for example, background | |
122 | + colours have been styled on the original menu element or div.jqDock, and you don't want them to be faded | |
123 | + in. | |
124 | + </description> | |
125 | + <defaultvalue>null</defaultvalue> | |
126 | + </property> | |
127 | + | |
128 | + <property> | |
129 | + <name>flow</name> | |
130 | + <classname>boolean</classname> | |
131 | + <description> | |
132 | + If set, this alters the default dock behaviour such that the Dock is not auto-centered and the wrap | |
133 | + element (.jqDockWrap, which is relatively positioned) expands and collapses to precisely contain the | |
134 | + Dock (.jqDock); this allows elements positioned around the docked menu to adjust their own relative | |
135 | + position according to the current state of the docked menu. | |
136 | + | |
137 | + Warning : There are consequences to using this option, which might possibly only become apparent when | |
138 | + you try it. I have provided it because it has specifically been requested, but with flow enabled, if you | |
139 | + aim your mouse at a specific menu option you will probably find that quite often you don't stay on that | |
140 | + option without having to move the mouse again! | |
141 | + </description> | |
142 | + <defaultvalue>false</defaultvalue> | |
143 | + </property> | |
144 | + | |
145 | + <property> | |
146 | + <name>idle</name> | |
147 | + <classname>int</classname> | |
148 | + <description> | |
149 | + The period of time (in milliseconds) after the mouse has left the menu (without re-entering, obviously!) | |
150 | + before the Dock attempts to go to sleep. | |
151 | + </description> | |
152 | + <defaultvalue>0</defaultvalue> | |
153 | + </property> | |
154 | + | |
155 | + <property> | |
156 | + <name>inactivity</name> | |
157 | + <classname>int</classname> | |
158 | + <description> | |
159 | + The period of time (in milliseconds) after which the Dock will shrink if there has been no movement of | |
160 | + the mouse while it is over an expanded Dock. | |
161 | + </description> | |
162 | + <defaultvalue>0</defaultvalue> | |
163 | + </property> | |
164 | + | |
165 | + <property> | |
166 | + <name>labels</name> | |
167 | + <classname>java.lang.String</classname> | |
168 | + <description> | |
169 | + values = 'true', 'false', 'tl', 'tc', 'tr', 'ml', 'mc', 'mr', 'bl', 'bc', 'br' | |
170 | + | |
171 | + This enables/disables display of a label on the current image. Allowed string values are 2 characters in | |
172 | + length: the first character indicates horizontal position (t=top, m=middle, b=bottom) and the second | |
173 | + indicates vertical position (l=left, c=center, r=right). So 'br' means bottom-right! If simply set to | |
174 | + true, jqDock will use its default positioning for the label, which is 'tl' (top-left) for any align | |
175 | + setting other than 'top' or 'left'. The defaults for 'top' and 'left' alignment are 'br' (bottom-right) | |
176 | + and 'tr' (top-right) respectively. To determine the text for the label, jqDock looks firstly for text in | |
177 | + the image's 'title' attribute; if not found, it will then look for text in the 'title' attribute of the | |
178 | + parent link - if there is one - and use that if found. | |
179 | + | |
180 | + Please be aware that enabling this option with one of the middle/center label positions (eg. 'ml', 'bc', | |
181 | + etc) may have a slight effect on the performance of the Dock, simply due to the additional processing | |
182 | + required to position the label correctly. | |
183 | + </description> | |
184 | + <defaultvalue>"false"</defaultvalue> | |
185 | + </property> | |
186 | + | |
187 | + <property> | |
188 | + <name>loader</name> | |
189 | + <classname>java.lang.String</classname> | |
190 | + <description> | |
191 | + values = 'image', 'jquery' | |
192 | + | |
193 | + This overrides the default image loader used by jqDock. Depending on the browser, jqDock uses an image | |
194 | + loader based on either "new Image()", or the jQuery HTML constructor "jQuery('<img/>')...". If your | |
195 | + Dock is not being displayed, and you have triple checked all your image paths, try setting this option | |
196 | + to 'image' or 'jquery' to override the default loader. | |
197 | + </description> | |
198 | + <defaultvalue>null</defaultvalue> | |
199 | + </property> | |
200 | + | |
201 | + <property> | |
202 | + <name>noBuffer</name> | |
203 | + <classname>boolean</classname> | |
204 | + <description> | |
205 | + By default, while the dock is asleep the most recent mouse event is buffered, and when the dock is | |
206 | + nudged awake that buffered event is used and acted upon - before any other mouse event that might occur | |
207 | + subsequent to the 'nudge'. Setting the noBuffer option to true will prevent buffering of the mouse | |
208 | + events. | |
209 | + </description> | |
210 | + <defaultvalue>false</defaultvalue> | |
211 | + </property> | |
212 | + | |
213 | + <property> | |
214 | + <name>size</name> | |
215 | + <classname>int</classname> | |
216 | + <description> | |
217 | + This is the maximum value (in pixels) of the minor axis dimension for the 'at rest' images. For example, | |
218 | + an image of natural dimensions 90x120 (width x height), placed in a horizontal Dock (say, 'align' = | |
219 | + 'bottom') would, by default, be sized down to 36x48. This is because height is the minor axis in a | |
220 | + horizontal Dock, and to keep the presentation of the 'at rest' images neat and tidy it is the height | |
221 | + that is governed by the size option. Conversely, in a vertical Dock it would be the width that was | |
222 | + capped at the size value, with height being set proportionately. | |
223 | + </description> | |
224 | + <defaultvalue>48</defaultvalue> | |
225 | + </property> | |
226 | + | |
227 | + <property> | |
228 | + <name>step</name> | |
229 | + <classname>int</classname> | |
230 | + <description> | |
231 | + The timer interval (in milliseconds) between each animation step of the 'on-Dock' expansion, and the | |
232 | + 'off-Dock' shrinkage. | |
233 | + </description> | |
234 | + <defaultvalue>50</defaultvalue> | |
235 | + </property> | |
236 | + | |
237 | + </component> | |
238 | +</components> | ... | ... |
1 | +package org.richfaces.component; | |
2 | + | |
3 | +import javax.faces.component.UIComponentBase; | |
4 | + | |
5 | +public abstract class UIDock extends UIComponentBase { | |
6 | +// ------------------------------ FIELDS ------------------------------ | |
7 | + | |
8 | + public static final String COMPONENT_FAMILY = "org.richfaces.Dock"; | |
9 | + | |
10 | + public static final String COMPONENT_TYPE = "org.richfaces.Dock"; | |
11 | + | |
12 | + public static final boolean DEFAULT_ACTIVE = false; | |
13 | + | |
14 | +// -------------------------- OTHER METHODS -------------------------- | |
15 | + | |
16 | + public abstract int getActive(); | |
17 | + | |
18 | + public abstract String getAlign(); | |
19 | + | |
20 | + public abstract double getCoefficient(); | |
21 | + | |
22 | + public abstract int getDistance(); | |
23 | + | |
24 | + public abstract int getDuration(); | |
25 | + | |
26 | + public abstract int getFadeIn(); | |
27 | + | |
28 | + public abstract String getFadeLayer(); | |
29 | + | |
30 | + public abstract int getIdle(); | |
31 | + | |
32 | + public abstract int getInactivity(); | |
33 | + | |
34 | + public abstract String getLabels(); | |
35 | + | |
36 | + public abstract String getLoader(); | |
37 | + | |
38 | + public abstract int getSize(); | |
39 | + | |
40 | + public abstract int getStep(); | |
41 | + | |
42 | + public abstract String getStyle(); | |
43 | + | |
44 | + public abstract String getStyleClass(); | |
45 | + | |
46 | + public abstract boolean isFlow(); | |
47 | + | |
48 | + public abstract boolean isNoBuffer(); | |
49 | + | |
50 | + public abstract void setActive(int active); | |
51 | + | |
52 | + public abstract void setAlign(String align); | |
53 | + | |
54 | + public abstract void setCoefficient(double coefficient); | |
55 | + | |
56 | + public abstract void setDistance(int distance); | |
57 | + | |
58 | + public abstract void setDuration(int duration); | |
59 | + | |
60 | + public abstract void setFadeIn(int fadeIn); | |
61 | + | |
62 | + public abstract void setFadeLayer(String fadeLayer); | |
63 | + | |
64 | + public abstract void setFlow(boolean flow); | |
65 | + | |
66 | + public abstract void setIdle(int idle); | |
67 | + | |
68 | + public abstract void setInactivity(int inactivity); | |
69 | + | |
70 | + public abstract void setLabels(String labels); | |
71 | + | |
72 | + public abstract void setLoader(String loader); | |
73 | + | |
74 | + public abstract void setNoBuffer(boolean noBuffer); | |
75 | + | |
76 | + public abstract void setSize(int size); | |
77 | + | |
78 | + public abstract void setStep(int step); | |
79 | + | |
80 | + public abstract void setStyle(String style); | |
81 | + | |
82 | + public abstract void setStyleClass(String styleClass); | |
83 | +} | ... | ... |
1 | +/* | |
2 | + * JBoss, Home of Professional Open Source | |
3 | + * Copyright , Red Hat, Inc. and individual contributors | |
4 | + * by the @authors tag. See the copyright.txt in the distribution for a | |
5 | + * full listing of individual contributors. | |
6 | + * | |
7 | + * This is free software; you can redistribute it and/or modify it | |
8 | + * under the terms of the GNU Lesser General Public License as | |
9 | + * published by the Free Software Foundation; either version 2.1 of | |
10 | + * the License, or (at your option) any later version. | |
11 | + * | |
12 | + * This software is distributed in the hope that it will be useful, | |
13 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
14 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
15 | + * Lesser General Public License for more details. | |
16 | + * | |
17 | + * You should have received a copy of the GNU Lesser General Public | |
18 | + * License along with this software; if not, write to the Free | |
19 | + * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA | |
20 | + * 02110-1301 USA, or see the FSF site: http://www.fsf.org. | |
21 | + */ | |
22 | + | |
23 | +package org.richfaces.renderkit.html; | |
24 | + | |
25 | +import org.ajax4jsf.javascript.JSFunction; | |
26 | +import org.ajax4jsf.renderkit.HeaderResourcesRendererBase; | |
27 | +import org.ajax4jsf.renderkit.RendererUtils.HTML; | |
28 | +import org.ajax4jsf.resource.InternetResource; | |
29 | +import org.richfaces.component.UIDock; | |
30 | + | |
31 | +import javax.faces.component.UIComponent; | |
32 | +import javax.faces.context.FacesContext; | |
33 | +import javax.faces.context.ResponseWriter; | |
34 | +import java.io.IOException; | |
35 | +import java.util.Collection; | |
36 | +import java.util.Collections; | |
37 | +import java.util.HashMap; | |
38 | +import java.util.Map; | |
39 | + | |
40 | +public class DockRenderer extends HeaderResourcesRendererBase { | |
41 | +// ------------------------------ FIELDS ------------------------------ | |
42 | + | |
43 | + private static final Map<String, Object> DEFAULTS; | |
44 | + | |
45 | + private final InternetResource[] scripts = { | |
46 | + getResource("/org/richfaces/renderkit/html/scripts/jquery/jquery.js"), | |
47 | + getResource("/org/richfaces/renderkit/html/scripts/jquery.jdock.js"), | |
48 | + getResource("/org/richfaces/renderkit/html/scripts/richfaces.dock.js") | |
49 | + }; | |
50 | + private final InternetResource[] styles = { | |
51 | + getResource("/org/richfaces/renderkit/html/css/dock.xcss") | |
52 | + }; | |
53 | + | |
54 | +// -------------------------- STATIC METHODS -------------------------- | |
55 | + | |
56 | + static { | |
57 | + Map<String, Object> defaults = new HashMap<String, Object>(); | |
58 | + defaults.put("active", -1); | |
59 | + defaults.put("align", "bottom"); | |
60 | + defaults.put("coefficient", 1.5); | |
61 | + defaults.put("duration", 300); | |
62 | + defaults.put("fadeIn", 0); | |
63 | + defaults.put("fadeLayer", ""); | |
64 | + defaults.put("flow", false); | |
65 | + defaults.put("idle", 0); | |
66 | + defaults.put("inactivity", 0); | |
67 | + defaults.put("labels", "false"); | |
68 | + defaults.put("loader", ""); | |
69 | + defaults.put("noBuffer", false); | |
70 | + defaults.put("size", 48); | |
71 | + defaults.put("step", 50); | |
72 | + DEFAULTS = Collections.unmodifiableMap(defaults); | |
73 | + } | |
74 | + | |
75 | +// --------------------- GETTER / SETTER METHODS --------------------- | |
76 | + | |
77 | + protected Class<? extends UIComponent> getComponentClass() { | |
78 | + return UIDock.class; | |
79 | + } | |
80 | + | |
81 | + @Override | |
82 | + protected InternetResource[] getScripts() { | |
83 | + return scripts; | |
84 | + } | |
85 | + | |
86 | + @Override | |
87 | + protected InternetResource[] getStyles() { | |
88 | + return styles; | |
89 | + } | |
90 | + | |
91 | +// -------------------------- OTHER METHODS -------------------------- | |
92 | + | |
93 | + @Override | |
94 | + protected void doEncodeBegin(ResponseWriter writer, FacesContext context, UIComponent component) throws IOException { | |
95 | + writer.startElement(HTML.DIV_ELEM, component); | |
96 | + final String clientId = getUtils().clientId(context, component); | |
97 | + writer.writeAttribute(HTML.id_ATTRIBUTE, clientId, HTML.id_ATTRIBUTE); | |
98 | + writer.startElement(HTML.DIV_ELEM, component); | |
99 | + writer.writeAttribute(HTML.id_ATTRIBUTE, getContainerClientId(context, component), HTML.id_ATTRIBUTE); | |
100 | + Object styleClass = component.getAttributes().get("styleClass"); | |
101 | + styleClass = styleClass == null ? "" : " " + styleClass.toString(); | |
102 | + writer.writeAttribute(HTML.class_ATTRIBUTE, "rf-dk" + styleClass, HTML.class_ATTRIBUTE); | |
103 | + writer.writeAttribute(HTML.style_ATTRIBUTE, component.getAttributes().get("style"), HTML.style_ATTRIBUTE); | |
104 | + } | |
105 | + | |
106 | + @Override | |
107 | + protected void doEncodeEnd(ResponseWriter writer, FacesContext context, UIComponent component) throws IOException { | |
108 | + writer.endElement(HTML.DIV_ELEM); | |
109 | + writer.startElement(HTML.SCRIPT_ELEM, null); | |
110 | + writer.writeAttribute(HTML.TYPE_ATTR, "text/javascript", "type"); | |
111 | + writer.writeText(new JSFunction("RichFaces.Dock", getContainerClientId(context, component), | |
112 | + getOptions((UIDock) component)), null); | |
113 | + writer.writeText(";", null); | |
114 | + writer.endElement(HTML.SCRIPT_ELEM); | |
115 | + writer.endElement(HTML.DIV_ELEM); | |
116 | + } | |
117 | + | |
118 | + private String getContainerClientId(FacesContext context, UIComponent component) { | |
119 | + return getUtils().clientId(context, component) + "Container"; | |
120 | + } | |
121 | + | |
122 | + protected Map<String, Object> getOptions(UIDock dock) throws IOException { | |
123 | + /** | |
124 | + * Include only attributes that are actually set. | |
125 | + */ | |
126 | + Map<String, Object> options = new HashMap<String, Object>(); | |
127 | + addOptionIfSetAndNotDefault("active", dock.getActive(), options); | |
128 | + addOptionIfSetAndNotDefault("align", dock.getAlign(), options); | |
129 | + addOptionIfSetAndNotDefault("coefficient", dock.getCoefficient(), options); | |
130 | + addOptionIfSetAndNotDefault("duration", dock.getDuration(), options); | |
131 | + addOptionIfSetAndNotDefault("fadeIn", dock.getFadeIn(), options); | |
132 | + addOptionIfSetAndNotDefault("fadeLayer", dock.getFadeLayer(), options); | |
133 | + addOptionIfSetAndNotDefault("flow", dock.isFlow(), options); | |
134 | + addOptionIfSetAndNotDefault("idle", dock.getIdle(), options); | |
135 | + addOptionIfSetAndNotDefault("inactivity", dock.getInactivity(), options); | |
136 | + addOptionIfSetAndNotDefault("labels", dock.getLabels(), options); | |
137 | + addOptionIfSetAndNotDefault("loader", dock.getLoader(), options); | |
138 | + addOptionIfSetAndNotDefault("noBuffer", dock.isNoBuffer(), options); | |
139 | + addOptionIfSetAndNotDefault("size", dock.getSize(), options); | |
140 | + addOptionIfSetAndNotDefault("step", dock.getStep(), options); | |
141 | + return options; | |
142 | + } | |
143 | + | |
144 | + protected void addOptionIfSetAndNotDefault(String optionName, Object value, Map<String, Object> options) { | |
145 | + if (value != null && !"".equals(value) | |
146 | + && !value.equals(DEFAULTS.get(optionName)) | |
147 | + && !(value instanceof Collection && ((Collection) value).size() == 0) | |
148 | + && !(value instanceof Map && ((Map) value).size() == 0)) { | |
149 | + options.put(optionName, value); | |
150 | + } | |
151 | + } | |
152 | +} | ... | ... |
1 | +<?xml version="1.0" encoding="UTF-8"?> | |
2 | +<f:template xmlns:f='http:/jsf.exadel.com/template' | |
3 | +xmlns:u='http:/jsf.exadel.com/template/util' | |
4 | +xmlns="http://www.w3.org/1999/xhtml" > | |
5 | + | |
6 | + <f:verbatim> | |
7 | +.rf-dk a { | |
8 | + text-decoration:none; | |
9 | +} | |
10 | + </f:verbatim> | |
11 | + | |
12 | + <u:selector name=".rf-dk .jqDockLabelText"> | |
13 | + <u:style name="color" skin="generalTextColor"/> | |
14 | + <u:style name="font-weight" value="bold"/> | |
15 | + <u:style name="font-size" skin="generalSizeFont"/> | |
16 | + <u:style name="font-family" skin="generalFamilyFont"/> | |
17 | + </u:selector> | |
18 | + | |
19 | +</f:template> | |
\ No newline at end of file | ... | ... |
1 | +/* | |
2 | + jquery.jqDock.js v1.6 | |
3 | +*/ | |
4 | +(function(k,w){if(!k.jqDock){var v=["Top","Right","Bottom","Left"],N=["Major","Minor"],z=["mouseenter","mousemove","mouseleave"],x=["docknudge","dockidle","dockfreeze"],s=["Idler","Inactive","Indock","Overdock","Offdock"],E=['<div style="position:relative;padding:0;',"margin:0;border:0 none;background-color:transparent;",'">'],p={v:{wh:"height",xy:1,tl:"top",lead:0,trail:2,inv:"h"},h:{wh:"width",xy:0,tl:"left",lead:3,trail:1,inv:"v"}},m=[],F=[0,0],X=function(){},C=function(a){a=parseInt(a,10);return isNaN(a)? | |
5 | +0:a},t=function(a,d){for(var c=s[d]?d+1:s.length;d<c&&c--;)if(a[s[c]]){w.clearTimeout(a[s[c]]);a[s[c]]=null}},A=function(a){return a?1*((a.id||"").match(/^jqDock(\d+)$/)||[0,-1])[1]:-1},Y=function(){var a=m[A(k(".jqDockFilter",this).add(this).css({filter:""}).removeClass("jqDockFilter").filter(".jqDock")[0])];if(a){a.Asleep=false;a.Menu.trigger("dockshow",["ready"]).trigger(x[0])}},G=function(a,d){for(var c=true,e=m.length,b;a&&c&&e--&&m[e].Elem;)for(b=m[e].Elem.length;c&&b--;)c=m[e].Elem[b].Img[0]!== | |
6 | +a;return c?!c:d?[e,b]:m[e].Elem[b]},H=function(a){var d=(new Date).getTime();a=a?a.Stamp+a.Opts.duration:0;if(a>d)d-=a-d;return d},O=function(a){var d=m[a.data.id],c=d.Elem[a.data.idx];c.height=this.height;c.width=this.width;--d.Load<=0&&w.setTimeout(function(){k.jqDock.initDock(a.data.id)},0)},Z=function(a,d){for(var c;a&&a.ownerDocument&&a!==d;){if(c=a.className.toString().match(/jqDockMouse(\d+)/))return 1*c[1];a=a.parentNode}return-1},P=function(a,d,c){var e={},b=p[c].wh;c=p[p[c].inv].wh;e[b]= | |
7 | +d;e[c]=Math.round(d*a[c]/a[b]);return e},Q=function(){k(this).prev("img").trigger("click");return false},y=function(a,d){var c=a.Elem[a.Current];if(c&&a.Opts.labels)c.Label.el[d?"show":"hide"]()},R=function(a){var d=p[a.Opts.vh],c=a.Elem.length,e=-1,b=0,f,h,j,i=F[d.xy]-a.Elem[0].Wrap.parent().offset()[d.tl];if(i>=0)for(;e<0&&b<c;b++){f=a.Elem[b];h=f.Pad[d.lead]+f.Pad[d.trail];j=f.Major+h;if(i<j){if(b!=a.Current){y(a);a.Current=b}e=f.Offset+i*(f.Initial+h)/j}else i-=j}return e},S=function(a){for(var d= | |
8 | +a.childNodes.length,c;d;){c=a.childNodes[--d];if(c.childNodes&&c.childNodes.length)S(c);else c.nodeType==3&&a.removeChild(c)}},T=function(a){a.Menu.css({visibility:"visible"}).show()},D=function(a){var d=a.Opts.idle;if(d){t(a,0);a[s[0]]=w.setTimeout(function(){a.Menu.trigger("dockidle")},d)}},$=function(a,d,c){var e=a.Opts,b=e.labels,f=d.Label,h;f.el=k('<div class="jqDockLabel jqDockLabel'+d.Link+'" style="position:absolute;margin:0;"></div>').hide().insertAfter(d.Img);if(b){h=b.charAt(0)=="b";b= | |
9 | +b.charAt(1)=="r";f.el.css({top:h?"auto":0,left:b?"auto":0,bottom:h?0:"auto",right:b?0:"auto"}).click(Q)}a=e.setLabel.call(a.Menu[0],d.Title,c,f.el[0]);a!==false&&k('<div class="jqDockLabelText">'+a.toString()+"</div>").appendTo(f.el)},I=function(a,d){var c=m[a],e=c.Opts,b=p[e.vh].wh,f=c.Elem.length,h,j,i;for(d=d||d===0?d:R(c);f--;){h=c.Elem[f];i=h.Initial;if(d>=0){j=Math.abs(d-h.Centre);if(j<e.distance)i=h[b]-Math.round((h[b]-h.Initial)*Math.pow(j,e.coefficient)/e.attenuation);if(f==c.Current){j= | |
10 | +[F[p[e.vh].xy],c.Current,i].join(",");if(j===c.ToFro[0]&&i!==c.ToFro[2])i=c.ToFro[2];else c.ToFro=[c.ToFro[1],j,i]}}h.Final=i}},aa=function(a){return a},U=function(a,d,c,e){a=m[a];var b=a.Elem[d],f=a.Opts,h=a.Yard,j=p[f.vh],i=p[j.inv],n=b.src!=b.altsrc,o,g,l;if(e||b.Major!=c){o=k.boxModel||f.vh=="v"?0:a.Border[j.lead]+a.Border[j.trail];if(n&&!e&&b.Major==b.Initial)b.Img[0].src=b.altsrc;a.Spread+=c-b.Major;g=P(b,c,f.vh);l=f.size-g[i.wh];if({top:1,left:1}[f.align])g["margin"+v[i.trail]]=l;else if({middle:1, | |
11 | +center:1}[f.align]){g["margin"+v[i.lead]]=(l+l%2)/2;g["margin"+v[i.trail]]=(l-l%2)/2}else g["margin"+v[i.lead]]=l;if(c!=b.Major||e&&!d){f.flow&&h.parent()[j.wh](a.Spread+a.Border[j.lead]+a.Border[j.trail]);h[j.wh](a.Spread+o)}b.Wrap.css(g);f.flow||h.css(j.tl,Math.floor(Math.max(0,(a[j.wh]-a.Spread)/2)));if(a.OnDock){d=!a.Stamp;f=a.Opts.labels;h=p[a.Opts.vh];j=a.Elem[a.Current];var q,r;if(j&&f){o=j.Label;l=o.el;if(o.mc){o.mc=0;for(q in p){o[q]=l[p[q].wh]();for(r in{lead:1,trail:1})o[q]+=C(l.css("padding"+ | |
12 | +v[p[q][r]]))}}f.charAt(0)=="m"&&l.css({top:Math.floor((j[N[p[h.inv].xy]]-o.v)/2)});f.charAt(1)=="c"&&l.css({left:Math.floor((j[N[h.xy]]-o.h)/2)})}d&&y(a,1)}b.Major=c;b.Minor=g[i.wh];if(n&&!e&&c==b.Initial)b.Img[0].src=b.src}},J=function(a){var d=m[a],c=d.Opts,e=p[c.vh],b=c.duration+c.step,f=0,h;if(d.Stamp){b=H()-d.Stamp;if(b>=c.duration)d.Stamp=0}if(b>=c.step){for(h=(c.duration-b)/c.step;f<d.Elem.length;f++){c=d.Elem[f];b=(b=c.Final-c.Major)&&h>1?c.Major+Math[b<0?"floor":"ceil"](b/h):c.Final;U(a, | |
13 | +f,b)}if(d.Spread>d[e.wh]){d.Yard.parent()[e.wh](d.Spread+d.Border[e.lead]+d.Border[e.trail]);d[e.wh]=d.Spread}}},K=function(a,d){var c=m[a],e=c.Elem,b=e.length;t(c,2);if(c.OnDock&&!c.Stamp){for(I(a,d);b--&&e[b].Major==e[b].Final;);if(b<0)y(c,1);else{J(a);c[s[2]]=w.setTimeout(function(){K(a,d)},c.Opts.step)}}},V=function(a,d){var c=m[a],e=c.Elem,b=e.length;if(!c.OnDock){for(;b--&&e[b].Major<=e[b].Initial;);R(c);if(b<0){c.Stamp=0;for(b=e.length;b--;)e[b].Major=e[b].Final=e[b].Initial;c.Current=-1;d|| | |
14 | +D(c)}else{J(a);c[s[4]]=w.setTimeout(function(){V(a,d)},c.Opts.step)}}},W=function(a,d){var c=m[a],e=c.Elem,b=e.length;if(c.OnDock){for(I(a,d);b--&&e[b].Major==e[b].Final;);if(b<0||!c.Stamp){c.Stamp=0;K(a,d)}else{J(a);c[s[3]]=w.setTimeout(function(){W(a,d)},c.Opts.step)}}},B=function(a,d,c,e){var b=m[d],f=b.Elem,h=f.length;if(a===0){b.OnDock=1;b.Current>=0&&b.Current!==c&&y(b);b.Current=c;b.Stamp=e&&e>1?0:H(b);W(d,e?f[c].Centre:null)}if(a===1){if(c!==b.Current){y(b);b.Current=c}K(d)}if(a===2){t(b, | |
15 | +1);b.OnDock=0;y(b);for(b.Stamp=H(b);h--;)f[h].Final=f[h].Initial;V(d,!!e)}},L=function(a){var d=A(this),c=m[d],e=c?Z(a.target,this):-1,b=-1,f;if(c)if(c.Asleep){if(!c.Opts.noBuffer)c.Sleeper={target:a.target,type:a.type,pageX:a.pageX,pageY:a.pageY}}else{f=c.OnDock;t(c,0);F=[a.pageX,a.pageY];if(a.type==z[2])if(f)b=2;else D(c);else{if(c.Opts.inactivity){t(c,1);c[s[1]]=w.setTimeout(function(){B(2,d,e,1)},c.Opts.inactivity)}if(a.type==z[1])if(e<0){if(f&&c.Current>=0)b=2}else b=!f||c.Current<0?0:1;else if(e>= | |
16 | +0&&!f)b=0}c.Sleeper=null;b>=0&&B(b,d,e)}},M=function(a){var d=k(".jqDock",this).get(0),c=A(d),e=m[c],b=a.type==x[2],f=b?"freeze":"sleep";if(e)if(a.type==x[0]){f=e.Frozen?"thaw":"wake";if(e.Asleep&&!(e.Asleep=e.Opts.onWake.call(this,f)===false))e.Frozen=!k(this).trigger("dockwake",[f]);if(!e.Asleep){D(e);e.Sleeper&&L.call(d,e.Sleeper)}}else{t(e,0);a=!e.Asleep||b&&!e.Frozen;if(!a||e.Opts.onSleep.call(e.Menu[0],f)!==false){e.Asleep=!t(e,b?-1:1);e.Frozen=e.Frozen||b;a&&e.Menu.trigger("docksleep",[f]); | |
17 | +if(b)e.Stamp=e.OnDock=0;else B(2,c,0,1)}}};k.jqDock=function(){return{version:1.6,defaults:{size:48,distance:72,coefficient:1.5,duration:300,align:"bottom",labels:0,source:0,loader:0,inactivity:0,fadeIn:0,fadeLayer:"",step:50,setLabel:0,flow:0,idle:0,onReady:0,onSleep:0,onWake:0,noBuffer:0,active:-1},useJqLoader:k.browser.opera||k.browser.safari,initDock:function(a){var d=m[a],c=d.Opts,e=p[c.vh],b=p[e.inv],f=d.Border,h=d.Elem.length,j=E.join(""),i=0,n=0,o,g,l,q=c.fadeLayer;S(d.Menu[0]);for(d.Menu.children().each(function(r, | |
18 | +u){var ba=d.Elem[r].Wrap=k(u).wrap(j+j+"</div></div>").parent();c.vh=="h"&&ba.parent().css("float","left")}).find("img").andSelf().css({position:"relative",padding:0,margin:0,borderWidth:0,borderStyle:"none",verticalAlign:"top",display:"block",width:"100%",height:"100%"});n<h;){g=d.Elem[n++];l=P(g,c.size,e.inv);g.Major=g.Final=g.Initial=l[e.wh];g.Wrap.css(l);g.Img.attr({alt:""}).parent("a").andSelf().removeAttr("title");d[b.wh]=Math.max(d[b.wh],c.size+g.Pad[b.lead]+g.Pad[b.trail]);g.Offset=i;g.Centre= | |
19 | +i+g.Pad[e.lead]+g.Initial/2;i+=g.Initial+g.Pad[e.lead]+g.Pad[e.trail]}for(n=0;n<h;){g=d.Elem[n++];l=g.Pad[e.lead]+g.Pad[e.trail];d.Spread+=g.Initial+l;for(o in{Centre:1,Offset:1}){I(a,g[o]);i=0;for(b=h;b--;)i+=d.Elem[b].Final+l;if(i>d[e.wh])d[e.wh]=i}}for(;n;){g=d.Elem[--n];g.Final=g.Initial}e=[E[0],E[2],'<div id="jqDock',a,'" class="jqDock" style="position:absolute;top:0;left:0;padding:0;margin:0;overflow:visible;height:',d.height,"px;width:",d.width,'px;"></div></div>'].join("");d.Yard=k("div.jqDock", | |
20 | +d.Menu.wrapInner(e));for(b=4;b--;)f[b]=C(d.Yard.css("border"+v[b]+"Width"));for(d.Yard.parent().addClass("jqDockWrap").width(d.width+f[1]+f[3]).height(d.height+f[0]+f[2]);n<h;n++){g=d.Elem[n];l=g.Wrap.parent();for(b=4;b--;)g.Pad[b]&&l.css("padding"+v[b],g.Pad[b]);U(a,n,g.Final,true);l.add(g.Img).addClass("jqDockMouse"+n);$(d,g,n)}g=d.Menu.bind(x.join(" "),M);d.Yard.bind(z.join(" "),L).find("*").css({filter:"inherit"});d.Elem[c.active]&&B(0,a,c.active,2);if(!(d.Asleep=c.onReady.call(d.Menu[0],"ready")=== | |
21 | +false))if(q){if(q!="menu"){g=d.Yard;if(q=="wrap")g=g.parent()}d.Asleep=!!k(".jqDock,.jqDockWrap",g).addClass("jqDockFilter").css({filter:"inherit"});g.css({opacity:0});T(d);g.animate({opacity:1},c.fadeIn,Y)}else{T(d);d.Menu.trigger("dockshow",["ready"]);D(d)}}}}();k.fn.jqDock=function(a){if(a==="nudge"||a==="idle"||a==="freeze")this.filter(".jqDocked").each(function(){M.call(this,{type:"dock"+a})});else if(a==="destroy")this.filter(".jqDocked").each(function(){var c=A(k(".jqDock",k(this).removeClass("jqDocked")).get(0)), | |
22 | +e=m[c],b=z.length,f,h,j;if(e){for(t(e,-1);b--;)e.Yard.unbind(z[b],L);for(b=x.length;b--;)e.Menu.unbind(x[b],M);for(b=0;b<e.Elem.length;b++){h=e.Elem[b];j=h.Img;h.Label.el.unbind("click",Q).remove();j.attr(h.Orig.i).removeClass("jqDockMouse"+b);h.Orig.i.style||j.removeAttr("style");if(h.Link=="Link"){j.parent().attr(h.Orig.a);h.Orig.a.style||j.parent().removeAttr("style")}e.Menu.append(h.Wrap.children());h.Label.el=h.Orig.i=h.Orig.a=null;for(f in h)h[f]=null}k(".jqDockWrap",e.Menu).remove();for(b in e)e[b]= | |
23 | +null;m[c]=null}for(c=m.length;c--&&m[c]===null;);if(c<0)m=[]});else if(a==="active"||a==="expand")this.each(function(){var c=G(this,1),e=c?m[c[0]]:0;if(e){t(e,-1);if(!e.Frozen)e.Frozen=e.Asleep=!!e.Menu.trigger("docksleep",["freeze"]);B(0,c[0],c[1],a=="active"?2:1)}});else if(a==="get"){var d=this.filter(".jqDocked");return(d=d.length?m[A(k(".jqDock",d).get(0))]:G(this.get(0)))?k.extend(true,{},d):null}else this.length&&!this.not("img").length?this.each(function(c,e){var b=G(e),f=0,h,j,i;a=a||{}; | |
24 | +if(b){h=b.Major==b.Initial;for(i in{src:1,altsrc:1})if(a[i]){j=(k.isFunction(a[i])?a[i].call(e,b[i],i):a[i]).toString();if(b[i]!==j){b[i]=j;f=(i=="src"?h:!h)?i:f}}f&&k(e).attr("src",b[f])}}):this.not(".jqDocked").filter(function(){return!k(this).parents(".jqDocked").length&&!k(this).children().not("img").filter(function(){return k(this).filter("a").children("img").parent().children().length!==1}).length}).addClass("jqDocked").each(function(){var c=k(this),e=m.length,b,f,h,j,i;m[e]={Elem:[],Menu:c, | |
25 | +OnDock:0,Stamp:0,width:0,height:0,Spread:0,Border:[],Opts:k.extend({},k.jqDock.defaults,a||{},k.metadata?c.metadata():{}),Current:-1,Load:0,ToFro:["","",0]};b=m[e];f=b.Opts;h=!f.loader&&k.jqDock.useJqLoader||f.loader==="jquery";for(i in{size:1,distance:1,duration:1,inactivity:1,fadeIn:1,step:1,idle:1,active:1})f[i]=C(f[i]);i=f.coefficient*1;f.coefficient=isNaN(i)?1.5:i;f.labels=/^[tmb][lcr]$/.test(f.labels.toString())?f.labels:f.labels?{top:"br",left:"tr"}[f.align]||"tl":"";f.setLabel=f.setLabel? | |
26 | +f.setLabel:aa;f.fadeLayer=f.fadeIn?{dock:1,wrap:1}[f.fadeLayer]?f.fadeLayer:"menu":"";for(i in{onSleep:1,onWake:1,onReady:1,onFreeze:1})f[i]||(f[i]=X);j=/^m|c$/.test(f.labels);f.attenuation=Math.pow(f.distance,f.coefficient);f.vh={left:1,center:1,right:1}[f.align]?"v":"h";k("img",c).each(function(n,o){var g=k(o),l=g.parent("a"),q=l.attr("title")||"",r={},u;for(u in{src:1,alt:1,title:1,style:1})r[u]=g.attr(u)||"";++b.Load;b.Elem[n]={Img:g,src:r.src,altsrc:(f.source?f.source.call(o,n):"")||(/\.(gif|jpg|jpeg|png)$/i.test(r.alt|| | |
27 | +"")?r.alt:"")||r.src,Title:r.title||q||"",Orig:{i:k.extend({},r),a:{title:q,style:l.attr("style")||""}},Label:{mc:j},Pad:[],Link:l.length?"Link":"Image"};for(u=4;u--;)b.Elem[n].Pad[u]=C(g.css("padding"+v[u]))});k.each(b.Elem,function(n,o){var g,l=o.altsrc;if(h)k("<img>").bind("load",{id:e,idx:n},O).attr({src:l});else{g=new Image;g.onload=function(){O.call(this,{data:{id:e,idx:n}});g.onload="";g=null};g.src=l}})});return this}}})(jQuery,window); | ... | ... |
1 | +/* | |
2 | + * JBoss, Home of Professional Open Source | |
3 | + * Copyright , Red Hat, Inc. and individual contributors | |
4 | + * by the @authors tag. See the copyright.txt in the distribution for a | |
5 | + * full listing of individual contributors. | |
6 | + * | |
7 | + * This is free software; you can redistribute it and/or modify it | |
8 | + * under the terms of the GNU Lesser General Public License as | |
9 | + * published by the Free Software Foundation; either version 2.1 of | |
10 | + * the License, or (at your option) any later version. | |
11 | + * | |
12 | + * This software is distributed in the hope that it will be useful, | |
13 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
14 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
15 | + * Lesser General Public License for more details. | |
16 | + * | |
17 | + * You should have received a copy of the GNU Lesser General Public | |
18 | + * License along with this software; if not, write to the Free | |
19 | + * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA | |
20 | + * 02110-1301 USA, or see the FSF site: http://www.fsf.org. | |
21 | + */ | |
22 | + | |
23 | +window.RichFaces = window.RichFaces || {}; | |
24 | +RichFaces.Dock = function(clientId, options) { | |
25 | + var container = jQuery(document.getElementById(clientId)); | |
26 | + /** | |
27 | + * Move all scripts generated by children out of container (jDock requirement). | |
28 | + */ | |
29 | + container.children().filter("script").appendTo(container.parent()); | |
30 | + return container.jqDock(options); | |
31 | +}; | |
\ No newline at end of file | ... | ... |
Please
register
or
login
to post a comment