4 |
4 |
5 /*! |
5 /*! |
6 Class to handle displaying the zoom bar. The zoom bar is displayed when the |
6 Class to handle displaying the zoom bar. The zoom bar is displayed when the |
7 user presses the zoom button on the toolbar. It provides access to the zoom |
7 user presses the zoom button on the toolbar. It provides access to the zoom |
8 in and out functions. It is hidden when the main toolbar is hidden on user inactivity |
8 in and out functions. It is hidden when the main toolbar is hidden on user inactivity |
|
9 and on timer maintained by native code |
9 */ |
10 */ |
10 function ZoomBar() |
11 function ZoomBar() |
11 { |
12 { |
12 var timeoutId = 0; // inactivity timer ID |
|
13 var ZB_TIMEOUT = 5000; // hide zoombar after 5 secs |
|
14 var zooming = false; // true when in the process of zooming |
|
15 var enabled = true; // zooming enabled flag - initially enabled |
13 var enabled = true; // zooming enabled flag - initially enabled |
16 |
14 |
17 // Private Methods |
15 // Private Methods |
18 //! Write zoom bar HTML code to document. |
16 //! Write zoom bar HTML code to document. |
19 function _zoombar_write() { |
17 function _zoombar_write() { |
20 var html = ''+ |
18 var html = ''+ |
21 '<div id="zoomBarDiv">'+ |
19 '<div id="zoomBarDiv">'+ |
22 '<img class="zoomBarBtn" id="zoomBarBtnIn">'+ |
20 '<div class = "GinebraSnippet zoomBarBtn" id="zoomBarBtnIn" data-GinebraVisible="false" data-GinebraHidesContent="true" data-GinebraNativeClass="ActionButton"> </div>'+ |
23 '<img class="zoomBarBtn" id="zoomBarBtnOut">'+ |
21 '<div class = "GinebraSnippet zoomBarBtn" id="zoomBarBtnOut" data-GinebraVisible="false" data-GinebraHidesContent="true" data-GinebraNativeClass="ActionButton"> </div>'+ |
|
22 |
24 '</div>'; |
23 '</div>'; |
25 document.write(html); |
24 document.write(html); |
26 } |
25 } |
27 |
26 |
28 //! Create zoom in & out buttons. |
27 //! Create zoom in & out buttons. |
29 function _setActions() { |
28 function _setActions() { |
30 new ActionButton("zoomBarBtnIn", |
29 snippets.zoomBarBtnIn.connectAction("zoomIn", "WebView", true, true); |
31 "zoombar.snippet/icons/icon_zoom+.png", |
30 snippets.zoomBarBtnOut.connectAction("zoomOut", "WebView", true, true); |
32 "zoombar.snippet/icons/icon_zoom+_pressed.png", |
31 snippets.zoomBarBtnIn.setIcon(":/chrome/bedrockchrome/zoombar.snippet/icons/icon_zoom+.png"); |
33 "zoombar.snippet/icons/icon_zoom+_disabled.png", |
32 snippets.zoomBarBtnIn.setActiveIcon(":/chrome/bedrockchrome/zoombar.snippet/icons/icon_zoom+_pressed.png"); |
34 window.views.WebView.actions.zoomIn, |
33 snippets.zoomBarBtnIn.setDisabledIcon(":/chrome/bedrockchrome/zoombar.snippet/icons/icon_zoom+_disabled.png"); |
35 true,true,true); |
34 snippets.zoomBarBtnOut.setIcon(":/chrome/bedrockchrome/zoombar.snippet/icons/icon_zoom-.png"); |
|
35 snippets.zoomBarBtnOut.setActiveIcon(":/chrome/bedrockchrome/zoombar.snippet/icons/icon_zoom-_pressed.png"); |
|
36 snippets.zoomBarBtnOut.setDisabledIcon(":/chrome/bedrockchrome/zoombar.snippet/icons/icon_zoom-_disabled.png"); |
36 |
37 |
37 new ActionButton("zoomBarBtnOut", |
|
38 "zoombar.snippet/icons/icon_zoom-.png", |
|
39 "zoombar.snippet/icons/icon_zoom-_pressed.png", |
|
40 "zoombar.snippet/icons/icon_zoom-_disabled.png", |
|
41 window.views.WebView.actions.zoomOut, |
|
42 true,true,true); |
|
43 |
|
44 // reset toolbar timeout each time a zoom is triggered |
|
45 // window.views.WebView.actions.zoomIn.triggered.connect( |
|
46 // function(checked) {handleZoom();}); |
|
47 // window.views.WebView.actions.zoomOut.triggered.connect( |
|
48 // function(checked) {handleZoom();}); |
|
49 // Connect to each action's "changed" signal. |
38 // Connect to each action's "changed" signal. |
50 window.views.WebView.actions.zoomIn.changed.connect( |
39 window.views.WebView.actions.zoomIn.changed.connect( |
51 createDelegate(this, handleChange)); |
40 createDelegate(this, handleChange)); |
52 window.views.WebView.actions.zoomOut.changed.connect( |
41 window.views.WebView.actions.zoomOut.changed.connect( |
53 createDelegate(this, handleChange)); |
42 createDelegate(this, handleChange)); |
54 } |
|
55 |
43 |
56 //! Set inactivity timer when not zooming. |
|
57 function handleZoom() |
|
58 { |
|
59 // zoom activation toggles zoom on/off |
|
60 zooming = !zooming; // toggle zoom state |
|
61 clearTimeout(timeoutId); |
|
62 if (!zooming) { |
|
63 // close zoom after 5 secs |
|
64 timeoutId = setTimeout('window.snippets.ZoomBarId.hide()', ZB_TIMEOUT); |
|
65 } |
|
66 } |
|
67 |
|
68 //! Start inactivity timer when zoom bar is shown. |
|
69 function handleShow() |
|
70 { |
|
71 timeoutId = setTimeout('window.snippets.ZoomBarId.hide()', ZB_TIMEOUT); // close zoom after 5 secs |
|
72 } |
|
73 |
|
74 //! Clear inactivity timer when zoom bar is hidden. |
|
75 function handleHide() |
|
76 { |
|
77 clearTimeout(timeoutId); |
|
78 zooming = false; // ensure zooming state doesn't get out of sync |
|
79 } |
44 } |
80 |
45 |
81 //! Handle action object changes. In particular we are interested in |
46 //! Handle action object changes. In particular we are interested in |
82 //! changes to the enabled state of the object. |
47 //! changes to the enabled state of the object. |
83 function handleChange() { |
48 function handleChange() { |