~zack-krejci/healthscapes-dsp/trunk

« back to all changes in this revision

Viewing changes to static/scripts/GeoExt/lib/GeoExt/widgets/tree/BaseLayerContainer.js

  • Committer: Zack
  • Date: 2011-02-28 21:37:27 UTC
  • Revision ID: zack@zack-laptop-20110228213727-tqig2kgx9vz0uhq9
Updated pages

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/**
 
2
 * Copyright (c) 2008-2011 The Open Source Geospatial Foundation
 
3
 * 
 
4
 * Published under the BSD license.
 
5
 * See http://svn.geoext.org/core/trunk/geoext/license.txt for the full text
 
6
 * of the license.
 
7
 */
 
8
 
 
9
/**
 
10
 * @requires GeoExt/widgets/tree/LayerContainer.js
 
11
 */
 
12
Ext.namespace("GeoExt.tree");
 
13
 
 
14
/** api: (define)
 
15
 *  module = GeoExt.tree
 
16
 *  class = BaseLayerContainer
 
17
 */
 
18
 
 
19
/** api: (extends)
 
20
 * GeoExt/widgets/tree/LayerContainer.js
 
21
 */
 
22
 
 
23
/** api: constructor
 
24
 *  .. class:: BaseLayerContainer
 
25
 * 
 
26
 *     A layer container that will collect all base layers of an OpenLayers
 
27
 *     map. Only layers that have displayInLayerSwitcher set to true will be
 
28
 *     included. The childrens' iconCls defaults to
 
29
 *     "gx-tree-baselayer-icon" and this node' text defaults to
 
30
 *     "Base Layer".
 
31
 *     
 
32
 *     Children will be rendered with a radio button instead of a checkbox,
 
33
 *     showing the user that only one base layer can be active at a time.
 
34
 * 
 
35
 *     To use this node type in ``TreePanel`` config, set nodeType to
 
36
 *     "gx_baselayercontainer".
 
37
 */
 
38
GeoExt.tree.BaseLayerContainer = Ext.extend(GeoExt.tree.LayerContainer, {
 
39
 
 
40
    /** private: property[text]
 
41
     *  ``String`` The text for this node.
 
42
     */
 
43
    text: 'Base Layer',
 
44
 
 
45
    /** private: method[constructor]
 
46
     *  Private constructor override.
 
47
     */
 
48
    constructor: function(config) {
 
49
        config = Ext.applyIf(config || {}, {
 
50
            text: this.text,
 
51
            loader: {}
 
52
        });
 
53
        config.loader = Ext.applyIf(config.loader, {
 
54
            baseAttrs: Ext.applyIf(config.loader.baseAttrs || {}, {
 
55
                iconCls: 'gx-tree-baselayer-icon',
 
56
                checkedGroup: 'baselayer'
 
57
            }),
 
58
            filter: function(record) {
 
59
                var layer = record.getLayer();
 
60
                return layer.displayInLayerSwitcher === true &&
 
61
                    layer.isBaseLayer === true;
 
62
            }
 
63
        });
 
64
 
 
65
        GeoExt.tree.BaseLayerContainer.superclass.constructor.call(this,
 
66
            config);
 
67
    }
 
68
});
 
69
 
 
70
/**
 
71
 * NodeType: gx_baselayercontainer
 
72
 */
 
73
Ext.tree.TreePanel.nodeTypes.gx_baselayercontainer = GeoExt.tree.BaseLayerContainer;