source:
trunk/workshop-routing-foss4g/web/GeoExt/lib/GeoExt/widgets/tips/LayerOpacitySliderTip.js
@
76
Revision 76, 2.0 KB checked in by djay, 12 years ago (diff) | |
---|---|
|
Rev | Line | |
---|---|---|
[76] | 1 | /** |
2 | * Copyright (c) 2008-2010 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/tips/SliderTip.js | |
11 | */ | |
12 | ||
13 | /** api: (extends) | |
14 | * GeoExt/widgets/tips/SliderTip.js | |
15 | */ | |
16 | ||
17 | /** api: (define) | |
18 | * module = GeoExt | |
19 | * class = LayerOpacitySliderTip | |
20 | * base_link = `Ext.Tip <http://dev.sencha.com/deploy/dev/docs/?class=Ext.Tip>`_ | |
21 | */ | |
22 | Ext.namespace("GeoExt"); | |
23 | ||
24 | /** api: example | |
25 | * Sample code to create a slider tip to display scale and resolution: | |
26 | * | |
27 | * .. code-block:: javascript | |
28 | * | |
29 | * var slider = new GeoExt.LayerOpacitySlider({ | |
30 | * renderTo: document.body, | |
31 | * width: 200, | |
32 | * layer: layer, | |
33 | * plugins: new GeoExt.LayerOpacitySliderTip({ | |
34 | * template: "Opacity: {opacity}%" | |
35 | * }) | |
36 | * }); | |
37 | */ | |
38 | ||
39 | /** api: constructor | |
40 | * .. class:: LayerOpacitySliderTip(config) | |
41 | * | |
42 | * Create a slider tip displaying :class:`GeoExt.LayerOpacitySlider` values. | |
43 | */ | |
44 | GeoExt.LayerOpacitySliderTip = Ext.extend(GeoExt.SliderTip, { | |
45 | ||
46 | /** api: config[template] | |
47 | * ``String`` | |
48 | * Template for the tip. Can be customized using the following keywords in | |
49 | * curly braces: | |
50 | * | |
51 | * * ``opacity`` - the opacity value in percent. | |
52 | */ | |
53 | template: '<div>{opacity}%</div>', | |
54 | ||
55 | /** private: property[compiledTemplate] | |
56 | * ``Ext.Template`` | |
57 | * The template compiled from the ``template`` string on init. | |
58 | */ | |
59 | compiledTemplate: null, | |
60 | ||
61 | /** private: method[init] | |
62 | * Called to initialize the plugin. | |
63 | */ | |
64 | init: function(slider) { | |
65 | this.compiledTemplate = new Ext.Template(this.template); | |
66 | GeoExt.LayerOpacitySliderTip.superclass.init.call(this, slider); | |
67 | }, | |
68 | ||
69 | /** private: method[getText] | |
70 | * :param slider: ``Ext.Slider`` The slider this tip is attached to. | |
71 | */ | |
72 | getText: function(thumb) { | |
73 | var data = { | |
74 | opacity: thumb.value | |
75 | }; | |
76 | return this.compiledTemplate.apply(data); | |
77 | } | |
78 | }); |
Note: See TracBrowser
for help on using the repository browser.