Bienvenue sur PostGIS.fr

Bienvenue sur PostGIS.fr , le site de la communauté des utilisateurs francophones de PostGIS.

PostGIS ajoute le support d'objets géographique à la base de données PostgreSQL. En effet, PostGIS "spatialise" le serverur PostgreSQL, ce qui permet de l'utiliser comme une base de données SIG.

Maintenu à jour, en fonction de nos disponibilités et des diverses sorties des outils que nous testons, nous vous proposons l'ensemble de nos travaux publiés en langue française.

source: trunk/workshop-routing-foss4g/web/OpenLayers/lib/OpenLayers/BaseTypes/Element.js @ 76

Revision 76, 7.3 KB checked in by djay, 12 years ago (diff)

Ajout du répertoire web

  • Property svn:executable set to *
Line 
1/* Copyright (c) 2006-2010 by OpenLayers Contributors (see authors.txt for
2 * full list of contributors). Published under the Clear BSD license. 
3 * See http://svn.openlayers.org/trunk/openlayers/license.txt for the
4 * full text of the license. */
5
6/**
7 * Namespace: OpenLayers.Element
8 */
9OpenLayers.Element = {
10
11    /**
12     * APIFunction: visible
13     *
14     * Parameters:
15     * element - {DOMElement}
16     *
17     * Returns:
18     * {Boolean} Is the element visible?
19     */
20    visible: function(element) {
21        return OpenLayers.Util.getElement(element).style.display != 'none';
22    },
23
24    /**
25     * APIFunction: toggle
26     * Toggle the visibility of element(s) passed in
27     *
28     * Parameters:
29     * element - {DOMElement} Actually user can pass any number of elements
30     */
31    toggle: function() {
32        for (var i=0, len=arguments.length; i<len; i++) {
33            var element = OpenLayers.Util.getElement(arguments[i]);
34            var display = OpenLayers.Element.visible(element) ? 'hide' 
35                                                              : 'show';
36            OpenLayers.Element[display](element);
37        }
38    },
39
40
41    /**
42     * APIFunction: hide
43     * Hide element(s) passed in
44     *
45     * Parameters:
46     * element - {DOMElement} Actually user can pass any number of elements
47     */
48    hide: function() {
49        for (var i=0, len=arguments.length; i<len; i++) {
50            var element = OpenLayers.Util.getElement(arguments[i]);
51            if (element) {
52                element.style.display = 'none';
53            }
54        }
55    },
56
57    /**
58     * APIFunction: show
59     * Show element(s) passed in
60     *
61     * Parameters:
62     * element - {DOMElement} Actually user can pass any number of elements
63     */
64    show: function() {
65        for (var i=0, len=arguments.length; i<len; i++) {
66            var element = OpenLayers.Util.getElement(arguments[i]);
67            if (element) {
68                element.style.display = '';
69            }
70        }
71    },
72
73    /**
74     * APIFunction: remove
75     * Remove the specified element from the DOM.
76     *
77     * Parameters:
78     * element - {DOMElement}
79     */
80    remove: function(element) {
81        element = OpenLayers.Util.getElement(element);
82        element.parentNode.removeChild(element);
83    },
84
85    /**
86     * APIFunction: getHeight
87     * 
88     * Parameters:
89     * element - {DOMElement}
90     *
91     * Returns:
92     * {Integer} The offset height of the element passed in
93     */
94    getHeight: function(element) {
95        element = OpenLayers.Util.getElement(element);
96        return element.offsetHeight;
97    },
98
99    /**
100     * APIFunction: getDimensions
101     * *Deprecated*. Returns dimensions of the element passed in.
102     * 
103     * Parameters:
104     * element - {DOMElement}
105     *
106     * Returns:
107     * {Object} Object with 'width' and 'height' properties which are the
108     *          dimensions of the element passed in.
109     */
110    getDimensions: function(element) {
111        element = OpenLayers.Util.getElement(element);
112        if (OpenLayers.Element.getStyle(element, 'display') != 'none') {
113            return {width: element.offsetWidth, height: element.offsetHeight};
114        }
115   
116        // All *Width and *Height properties give 0 on elements with display none,
117        // so enable the element temporarily
118        var els = element.style;
119        var originalVisibility = els.visibility;
120        var originalPosition = els.position;
121        var originalDisplay = els.display;
122        els.visibility = 'hidden';
123        els.position = 'absolute';
124        els.display = '';
125        var originalWidth = element.clientWidth;
126        var originalHeight = element.clientHeight;
127        els.display = originalDisplay;
128        els.position = originalPosition;
129        els.visibility = originalVisibility;
130        return {width: originalWidth, height: originalHeight};
131    },
132
133    /**
134     * Function: hasClass
135     * Tests if an element has the given CSS class name.
136     *
137     * Parameters:
138     * element - {DOMElement} A DOM element node.
139     * name - {String} The CSS class name to search for.
140     *
141     * Returns:
142     * {Boolean} The element has the given class name.
143     */
144    hasClass: function(element, name) {
145        var names = element.className;
146        return (!!names && new RegExp("(^|\\s)" + name + "(\\s|$)").test(names));
147    },
148   
149    /**
150     * Function: addClass
151     * Add a CSS class name to an element.  Safe where element already has
152     *     the class name.
153     *
154     * Parameters:
155     * element - {DOMElement} A DOM element node.
156     * name - {String} The CSS class name to add.
157     *
158     * Returns:
159     * {DOMElement} The element.
160     */
161    addClass: function(element, name) {
162        if(!OpenLayers.Element.hasClass(element, name)) {
163            element.className += (element.className ? " " : "") + name;
164        }
165        return element;
166    },
167
168    /**
169     * Function: removeClass
170     * Remove a CSS class name from an element.  Safe where element does not
171     *     have the class name.
172     *
173     * Parameters:
174     * element - {DOMElement} A DOM element node.
175     * name - {String} The CSS class name to remove.
176     *
177     * Returns:
178     * {DOMElement} The element.
179     */
180    removeClass: function(element, name) {
181        var names = element.className;
182        if(names) {
183            element.className = OpenLayers.String.trim(
184                names.replace(
185                    new RegExp("(^|\\s+)" + name + "(\\s+|$)"), " "
186                )
187            );
188        }
189        return element;
190    },
191
192    /**
193     * Function: toggleClass
194     * Remove a CSS class name from an element if it exists.  Add the class name
195     *     if it doesn't exist.
196     *
197     * Parameters:
198     * element - {DOMElement} A DOM element node.
199     * name - {String} The CSS class name to toggle.
200     *
201     * Returns:
202     * {DOMElement} The element.
203     */
204    toggleClass: function(element, name) {
205        if(OpenLayers.Element.hasClass(element, name)) {
206            OpenLayers.Element.removeClass(element, name);
207        } else {
208            OpenLayers.Element.addClass(element, name);
209        }
210        return element;
211    },
212
213    /**
214     * APIFunction: getStyle
215     *
216     * Parameters:
217     * element - {DOMElement}
218     * style - {?}
219     *
220     * Returns:
221     * {?}
222     */
223    getStyle: function(element, style) {
224        element = OpenLayers.Util.getElement(element);
225
226        var value = null;
227        if (element && element.style) {
228            value = element.style[OpenLayers.String.camelize(style)];
229            if (!value) {
230                if (document.defaultView && 
231                    document.defaultView.getComputedStyle) {
232                   
233                    var css = document.defaultView.getComputedStyle(element, null);
234                    value = css ? css.getPropertyValue(style) : null;
235                } else if (element.currentStyle) {
236                    value = element.currentStyle[OpenLayers.String.camelize(style)];
237                }
238            }
239       
240            var positions = ['left', 'top', 'right', 'bottom'];
241            if (window.opera &&
242                (OpenLayers.Util.indexOf(positions,style) != -1) &&
243                (OpenLayers.Element.getStyle(element, 'position') == 'static')) { 
244                value = 'auto';
245            }
246        }
247   
248        return value == 'auto' ? null : value;
249    }
250
251};
Note: See TracBrowser for help on using the repository browser.