org.symbian.tools.wrttools/projecttemplates/WRTKit/UI/UIManager.js
author Eugene Ostroukhov <eugeneo@symbian.org>
Thu, 15 Apr 2010 16:00:54 -0700
changeset 308 c521df56b15d
parent 273 b1f63c2c240c
permissions -rw-r--r--
Bug 2514 - Allow the user to package applications even if there are errors
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
210
0f7abfd6ae62 Fixed bug 2072: update .js files with EPL
tasneems@symbian.org
parents: 102
diff changeset
     1
/**
0f7abfd6ae62 Fixed bug 2072: update .js files with EPL
tasneems@symbian.org
parents: 102
diff changeset
     2
 * Copyright (c) 2009-2010 Symbian Foundation and/or its subsidiary(-ies).
0f7abfd6ae62 Fixed bug 2072: update .js files with EPL
tasneems@symbian.org
parents: 102
diff changeset
     3
 * All rights reserved.
0f7abfd6ae62 Fixed bug 2072: update .js files with EPL
tasneems@symbian.org
parents: 102
diff changeset
     4
 * This component and the accompanying materials are made available
0f7abfd6ae62 Fixed bug 2072: update .js files with EPL
tasneems@symbian.org
parents: 102
diff changeset
     5
 * under the terms of the License "Eclipse Public License v1.0"
0f7abfd6ae62 Fixed bug 2072: update .js files with EPL
tasneems@symbian.org
parents: 102
diff changeset
     6
 * which accompanies this distribution, and is available
0f7abfd6ae62 Fixed bug 2072: update .js files with EPL
tasneems@symbian.org
parents: 102
diff changeset
     7
 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
0f7abfd6ae62 Fixed bug 2072: update .js files with EPL
tasneems@symbian.org
parents: 102
diff changeset
     8
 *
0f7abfd6ae62 Fixed bug 2072: update .js files with EPL
tasneems@symbian.org
parents: 102
diff changeset
     9
 * Initial Contributors:
273
b1f63c2c240c Bug 2072 - Update .js files with EPL
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 211
diff changeset
    10
 * Nokia Corporation - initial contribution.
b1f63c2c240c Bug 2072 - Update .js files with EPL
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 211
diff changeset
    11
 * 
210
0f7abfd6ae62 Fixed bug 2072: update .js files with EPL
tasneems@symbian.org
parents: 102
diff changeset
    12
 * Contributors:
273
b1f63c2c240c Bug 2072 - Update .js files with EPL
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 211
diff changeset
    13
 * 
b1f63c2c240c Bug 2072 - Update .js files with EPL
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 211
diff changeset
    14
 * Description:
b1f63c2c240c Bug 2072 - Update .js files with EPL
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 211
diff changeset
    15
 * 
210
0f7abfd6ae62 Fixed bug 2072: update .js files with EPL
tasneems@symbian.org
parents: 102
diff changeset
    16
 */
73
c56c874eef47 Added WRTKit
tasneems@symbian.org
parents:
diff changeset
    17
c56c874eef47 Added WRTKit
tasneems@symbian.org
parents:
diff changeset
    18
///////////////////////////////////////////////////////////////////////////////
c56c874eef47 Added WRTKit
tasneems@symbian.org
parents:
diff changeset
    19
// The UI manager manages a set of views and other user interface elements.
c56c874eef47 Added WRTKit
tasneems@symbian.org
parents:
diff changeset
    20
c56c874eef47 Added WRTKit
tasneems@symbian.org
parents:
diff changeset
    21
// Constructor.
c56c874eef47 Added WRTKit
tasneems@symbian.org
parents:
diff changeset
    22
function UIManager(viewParentElement, scrollbarParentElement, enableScrollBar, delayInit) {    
c56c874eef47 Added WRTKit
tasneems@symbian.org
parents:
diff changeset
    23
    uiLogger.debug("UIManager(" + viewParentElement + ", " + scrollbarParentElement + ")");
c56c874eef47 Added WRTKit
tasneems@symbian.org
parents:
diff changeset
    24
    if (delayInit == null) {
c56c874eef47 Added WRTKit
tasneems@symbian.org
parents:
diff changeset
    25
        this.init(viewParentElement, enableScrollBar, scrollbarParentElement);
c56c874eef47 Added WRTKit
tasneems@symbian.org
parents:
diff changeset
    26
    }
c56c874eef47 Added WRTKit
tasneems@symbian.org
parents:
diff changeset
    27
}
c56c874eef47 Added WRTKit
tasneems@symbian.org
parents:
diff changeset
    28
c56c874eef47 Added WRTKit
tasneems@symbian.org
parents:
diff changeset
    29
// Parent element for views.
c56c874eef47 Added WRTKit
tasneems@symbian.org
parents:
diff changeset
    30
UIManager.prototype.viewParentElement = null;
c56c874eef47 Added WRTKit
tasneems@symbian.org
parents:
diff changeset
    31
c56c874eef47 Added WRTKit
tasneems@symbian.org
parents:
diff changeset
    32
// Parent element for scrollbar.
c56c874eef47 Added WRTKit
tasneems@symbian.org
parents:
diff changeset
    33
UIManager.prototype.scrollbarParentElement = null;
c56c874eef47 Added WRTKit
tasneems@symbian.org
parents:
diff changeset
    34
c56c874eef47 Added WRTKit
tasneems@symbian.org
parents:
diff changeset
    35
// The currently displayed view.
c56c874eef47 Added WRTKit
tasneems@symbian.org
parents:
diff changeset
    36
UIManager.prototype.currentView = null;
c56c874eef47 Added WRTKit
tasneems@symbian.org
parents:
diff changeset
    37
c56c874eef47 Added WRTKit
tasneems@symbian.org
parents:
diff changeset
    38
// Reference to the scrollbar.
c56c874eef47 Added WRTKit
tasneems@symbian.org
parents:
diff changeset
    39
UIManager.prototype.scrollbar = null;
c56c874eef47 Added WRTKit
tasneems@symbian.org
parents:
diff changeset
    40
c56c874eef47 Added WRTKit
tasneems@symbian.org
parents:
diff changeset
    41
// Current scroll Y position.
c56c874eef47 Added WRTKit
tasneems@symbian.org
parents:
diff changeset
    42
UIManager.prototype.scrollY = -1;
c56c874eef47 Added WRTKit
tasneems@symbian.org
parents:
diff changeset
    43
c56c874eef47 Added WRTKit
tasneems@symbian.org
parents:
diff changeset
    44
// Current viewport height.
c56c874eef47 Added WRTKit
tasneems@symbian.org
parents:
diff changeset
    45
UIManager.prototype.viewportHeight = -1;
c56c874eef47 Added WRTKit
tasneems@symbian.org
parents:
diff changeset
    46
c56c874eef47 Added WRTKit
tasneems@symbian.org
parents:
diff changeset
    47
// Current document height.
c56c874eef47 Added WRTKit
tasneems@symbian.org
parents:
diff changeset
    48
UIManager.prototype.documentHeight = -1;
c56c874eef47 Added WRTKit
tasneems@symbian.org
parents:
diff changeset
    49
c56c874eef47 Added WRTKit
tasneems@symbian.org
parents:
diff changeset
    50
// Timer identifier or null if no active timer.
c56c874eef47 Added WRTKit
tasneems@symbian.org
parents:
diff changeset
    51
UIManager.prototype.timerId = null;
c56c874eef47 Added WRTKit
tasneems@symbian.org
parents:
diff changeset
    52
c56c874eef47 Added WRTKit
tasneems@symbian.org
parents:
diff changeset
    53
// Interval for timer ticks for the UI manager timer (in milliseconds)
c56c874eef47 Added WRTKit
tasneems@symbian.org
parents:
diff changeset
    54
UIManager.prototype.TIMER_INTERVAL = 250;
c56c874eef47 Added WRTKit
tasneems@symbian.org
parents:
diff changeset
    55
c56c874eef47 Added WRTKit
tasneems@symbian.org
parents:
diff changeset
    56
// Reference to the notification popup used to displays notifications.
c56c874eef47 Added WRTKit
tasneems@symbian.org
parents:
diff changeset
    57
UIManager.prototype.notificationPopup = null;
c56c874eef47 Added WRTKit
tasneems@symbian.org
parents:
diff changeset
    58
c56c874eef47 Added WRTKit
tasneems@symbian.org
parents:
diff changeset
    59
// is scrollbar enabled
c56c874eef47 Added WRTKit
tasneems@symbian.org
parents:
diff changeset
    60
UIManager.prototype.enableScrollBar = null;
c56c874eef47 Added WRTKit
tasneems@symbian.org
parents:
diff changeset
    61
c56c874eef47 Added WRTKit
tasneems@symbian.org
parents:
diff changeset
    62
// init function
c56c874eef47 Added WRTKit
tasneems@symbian.org
parents:
diff changeset
    63
UIManager.prototype.init = function(viewParentElement, enableScrollBar, scrollbarParentElement) {
c56c874eef47 Added WRTKit
tasneems@symbian.org
parents:
diff changeset
    64
    this.enableScrollBar = enableScrollBar;
c56c874eef47 Added WRTKit
tasneems@symbian.org
parents:
diff changeset
    65
    
c56c874eef47 Added WRTKit
tasneems@symbian.org
parents:
diff changeset
    66
    // parent element for views
c56c874eef47 Added WRTKit
tasneems@symbian.org
parents:
diff changeset
    67
    if (viewParentElement == null) {
c56c874eef47 Added WRTKit
tasneems@symbian.org
parents:
diff changeset
    68
        // create a parent for views
c56c874eef47 Added WRTKit
tasneems@symbian.org
parents:
diff changeset
    69
        this.viewParentElement = document.createElement("div");
c56c874eef47 Added WRTKit
tasneems@symbian.org
parents:
diff changeset
    70
        this.viewParentElement.className = "ViewContainer";
c56c874eef47 Added WRTKit
tasneems@symbian.org
parents:
diff changeset
    71
        document.body.appendChild(this.viewParentElement);
c56c874eef47 Added WRTKit
tasneems@symbian.org
parents:
diff changeset
    72
    }
c56c874eef47 Added WRTKit
tasneems@symbian.org
parents:
diff changeset
    73
    else {
c56c874eef47 Added WRTKit
tasneems@symbian.org
parents:
diff changeset
    74
        this.viewParentElement = viewParentElement;
c56c874eef47 Added WRTKit
tasneems@symbian.org
parents:
diff changeset
    75
    }
c56c874eef47 Added WRTKit
tasneems@symbian.org
parents:
diff changeset
    76
    
c56c874eef47 Added WRTKit
tasneems@symbian.org
parents:
diff changeset
    77
    // parent element for scrollbar
c56c874eef47 Added WRTKit
tasneems@symbian.org
parents:
diff changeset
    78
    if (enableScrollBar) {
c56c874eef47 Added WRTKit
tasneems@symbian.org
parents:
diff changeset
    79
        if (scrollbarParentElement == null) {
c56c874eef47 Added WRTKit
tasneems@symbian.org
parents:
diff changeset
    80
            // create a parent for the scrollbar
c56c874eef47 Added WRTKit
tasneems@symbian.org
parents:
diff changeset
    81
            this.scrollbarParentElement = document.createElement("div");
c56c874eef47 Added WRTKit
tasneems@symbian.org
parents:
diff changeset
    82
            this.scrollbarParentElement.className = "DocumentScrollbarContainer";
c56c874eef47 Added WRTKit
tasneems@symbian.org
parents:
diff changeset
    83
            document.body.appendChild(this.scrollbarParentElement);
c56c874eef47 Added WRTKit
tasneems@symbian.org
parents:
diff changeset
    84
        }
c56c874eef47 Added WRTKit
tasneems@symbian.org
parents:
diff changeset
    85
        else {
c56c874eef47 Added WRTKit
tasneems@symbian.org
parents:
diff changeset
    86
            this.scrollbarParentElement = scrollbarParentElement;
c56c874eef47 Added WRTKit
tasneems@symbian.org
parents:
diff changeset
    87
        }
c56c874eef47 Added WRTKit
tasneems@symbian.org
parents:
diff changeset
    88
    }
c56c874eef47 Added WRTKit
tasneems@symbian.org
parents:
diff changeset
    89
    
c56c874eef47 Added WRTKit
tasneems@symbian.org
parents:
diff changeset
    90
    // currently selected view
c56c874eef47 Added WRTKit
tasneems@symbian.org
parents:
diff changeset
    91
    this.currentView = null;
c56c874eef47 Added WRTKit
tasneems@symbian.org
parents:
diff changeset
    92
    
c56c874eef47 Added WRTKit
tasneems@symbian.org
parents:
diff changeset
    93
    // create the notification popup
c56c874eef47 Added WRTKit
tasneems@symbian.org
parents:
diff changeset
    94
    // the notification popup adds itself as a child element to the document body
c56c874eef47 Added WRTKit
tasneems@symbian.org
parents:
diff changeset
    95
    this.notificationPopup = new NotificationPopup();
c56c874eef47 Added WRTKit
tasneems@symbian.org
parents:
diff changeset
    96
    
c56c874eef47 Added WRTKit
tasneems@symbian.org
parents:
diff changeset
    97
    // create scrollbar
c56c874eef47 Added WRTKit
tasneems@symbian.org
parents:
diff changeset
    98
    if (enableScrollBar) {
c56c874eef47 Added WRTKit
tasneems@symbian.org
parents:
diff changeset
    99
        this.scrollbar = new Scrollbar(this.scrollbarParentElement);
c56c874eef47 Added WRTKit
tasneems@symbian.org
parents:
diff changeset
   100
    }
c56c874eef47 Added WRTKit
tasneems@symbian.org
parents:
diff changeset
   101
    
c56c874eef47 Added WRTKit
tasneems@symbian.org
parents:
diff changeset
   102
    // setup scrollbar tracking
c56c874eef47 Added WRTKit
tasneems@symbian.org
parents:
diff changeset
   103
    var self = this;
c56c874eef47 Added WRTKit
tasneems@symbian.org
parents:
diff changeset
   104
    this.startTimer();
c56c874eef47 Added WRTKit
tasneems@symbian.org
parents:
diff changeset
   105
    if (enableScrollBar) {
c56c874eef47 Added WRTKit
tasneems@symbian.org
parents:
diff changeset
   106
        window.addEventListener("resize", function(){
c56c874eef47 Added WRTKit
tasneems@symbian.org
parents:
diff changeset
   107
            self.updateScrollbar();
c56c874eef47 Added WRTKit
tasneems@symbian.org
parents:
diff changeset
   108
        }, false);
c56c874eef47 Added WRTKit
tasneems@symbian.org
parents:
diff changeset
   109
        window.addEventListener("scroll", function(){
c56c874eef47 Added WRTKit
tasneems@symbian.org
parents:
diff changeset
   110
            self.updateScrollbar();
c56c874eef47 Added WRTKit
tasneems@symbian.org
parents:
diff changeset
   111
        }, false);
c56c874eef47 Added WRTKit
tasneems@symbian.org
parents:
diff changeset
   112
    }
102
30e0796f3ebb Warnings in new projects were fixed
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 73
diff changeset
   113
};
73
c56c874eef47 Added WRTKit
tasneems@symbian.org
parents:
diff changeset
   114
c56c874eef47 Added WRTKit
tasneems@symbian.org
parents:
diff changeset
   115
// Returns the current view.
c56c874eef47 Added WRTKit
tasneems@symbian.org
parents:
diff changeset
   116
UIManager.prototype.getView = function() {
c56c874eef47 Added WRTKit
tasneems@symbian.org
parents:
diff changeset
   117
    return this.currentView;
102
30e0796f3ebb Warnings in new projects were fixed
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 73
diff changeset
   118
};
73
c56c874eef47 Added WRTKit
tasneems@symbian.org
parents:
diff changeset
   119
c56c874eef47 Added WRTKit
tasneems@symbian.org
parents:
diff changeset
   120
// Switches to the specified view.
c56c874eef47 Added WRTKit
tasneems@symbian.org
parents:
diff changeset
   121
UIManager.prototype.setView = function(view) {
c56c874eef47 Added WRTKit
tasneems@symbian.org
parents:
diff changeset
   122
    uiLogger.debug("View set to " + view.id);
c56c874eef47 Added WRTKit
tasneems@symbian.org
parents:
diff changeset
   123
    
c56c874eef47 Added WRTKit
tasneems@symbian.org
parents:
diff changeset
   124
    // remove the current view from the parent element
c56c874eef47 Added WRTKit
tasneems@symbian.org
parents:
diff changeset
   125
    if (this.currentView != null) {
c56c874eef47 Added WRTKit
tasneems@symbian.org
parents:
diff changeset
   126
        this.viewParentElement.removeChild(this.currentView.rootElement);
c56c874eef47 Added WRTKit
tasneems@symbian.org
parents:
diff changeset
   127
    }
c56c874eef47 Added WRTKit
tasneems@symbian.org
parents:
diff changeset
   128
    
c56c874eef47 Added WRTKit
tasneems@symbian.org
parents:
diff changeset
   129
    // reset scroll
c56c874eef47 Added WRTKit
tasneems@symbian.org
parents:
diff changeset
   130
    window.scrollTo(0, 0);
c56c874eef47 Added WRTKit
tasneems@symbian.org
parents:
diff changeset
   131
    
c56c874eef47 Added WRTKit
tasneems@symbian.org
parents:
diff changeset
   132
    // add the new view to the parent element
c56c874eef47 Added WRTKit
tasneems@symbian.org
parents:
diff changeset
   133
    if (view != null) {
c56c874eef47 Added WRTKit
tasneems@symbian.org
parents:
diff changeset
   134
        this.currentView = view;
c56c874eef47 Added WRTKit
tasneems@symbian.org
parents:
diff changeset
   135
        this.currentView.resetControlFocusStates();
c56c874eef47 Added WRTKit
tasneems@symbian.org
parents:
diff changeset
   136
        this.viewParentElement.appendChild(this.currentView.rootElement);
c56c874eef47 Added WRTKit
tasneems@symbian.org
parents:
diff changeset
   137
    }
c56c874eef47 Added WRTKit
tasneems@symbian.org
parents:
diff changeset
   138
    
c56c874eef47 Added WRTKit
tasneems@symbian.org
parents:
diff changeset
   139
    // update scrollbar
c56c874eef47 Added WRTKit
tasneems@symbian.org
parents:
diff changeset
   140
    if (this.enableScrollBar) {
c56c874eef47 Added WRTKit
tasneems@symbian.org
parents:
diff changeset
   141
        this.updateScrollbar();
c56c874eef47 Added WRTKit
tasneems@symbian.org
parents:
diff changeset
   142
    }
c56c874eef47 Added WRTKit
tasneems@symbian.org
parents:
diff changeset
   143
    
c56c874eef47 Added WRTKit
tasneems@symbian.org
parents:
diff changeset
   144
    // focus the first focusable control
c56c874eef47 Added WRTKit
tasneems@symbian.org
parents:
diff changeset
   145
    // a timer is used to prevent unwanted focus shift
c56c874eef47 Added WRTKit
tasneems@symbian.org
parents:
diff changeset
   146
    setTimeout(function() { view.focusFirstControl(); }, 1);
102
30e0796f3ebb Warnings in new projects were fixed
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 73
diff changeset
   147
};
73
c56c874eef47 Added WRTKit
tasneems@symbian.org
parents:
diff changeset
   148
c56c874eef47 Added WRTKit
tasneems@symbian.org
parents:
diff changeset
   149
// Updates the scrollbar.
c56c874eef47 Added WRTKit
tasneems@symbian.org
parents:
diff changeset
   150
UIManager.prototype.updateScrollbar = function() {
c56c874eef47 Added WRTKit
tasneems@symbian.org
parents:
diff changeset
   151
    if (this.enableScrollBar) {
c56c874eef47 Added WRTKit
tasneems@symbian.org
parents:
diff changeset
   152
        // get current viewport and document position and dimensions
c56c874eef47 Added WRTKit
tasneems@symbian.org
parents:
diff changeset
   153
        var scrollY = window.scrollY;
c56c874eef47 Added WRTKit
tasneems@symbian.org
parents:
diff changeset
   154
        var viewportHeight = window.innerHeight;
c56c874eef47 Added WRTKit
tasneems@symbian.org
parents:
diff changeset
   155
        var documentHeight = Math.max(document.documentElement.scrollHeight, document.height);
c56c874eef47 Added WRTKit
tasneems@symbian.org
parents:
diff changeset
   156
        
c56c874eef47 Added WRTKit
tasneems@symbian.org
parents:
diff changeset
   157
        // check if the scroll position or view has changed
c56c874eef47 Added WRTKit
tasneems@symbian.org
parents:
diff changeset
   158
        if (this.scrollY != scrollY ||
c56c874eef47 Added WRTKit
tasneems@symbian.org
parents:
diff changeset
   159
                this.viewportHeight != viewportHeight ||
c56c874eef47 Added WRTKit
tasneems@symbian.org
parents:
diff changeset
   160
                this.documentHeight != documentHeight) {
c56c874eef47 Added WRTKit
tasneems@symbian.org
parents:
diff changeset
   161
            // scroll position or view has changed
c56c874eef47 Added WRTKit
tasneems@symbian.org
parents:
diff changeset
   162
            this.scrollY = scrollY;
c56c874eef47 Added WRTKit
tasneems@symbian.org
parents:
diff changeset
   163
            this.viewportHeight = viewportHeight;
c56c874eef47 Added WRTKit
tasneems@symbian.org
parents:
diff changeset
   164
            this.documentHeight = documentHeight;
c56c874eef47 Added WRTKit
tasneems@symbian.org
parents:
diff changeset
   165
            
c56c874eef47 Added WRTKit
tasneems@symbian.org
parents:
diff changeset
   166
            // update the scrollbar
c56c874eef47 Added WRTKit
tasneems@symbian.org
parents:
diff changeset
   167
            this.scrollbar.update(scrollY, viewportHeight, documentHeight);
c56c874eef47 Added WRTKit
tasneems@symbian.org
parents:
diff changeset
   168
            uiLogger.debug("Scrollbar updated");
c56c874eef47 Added WRTKit
tasneems@symbian.org
parents:
diff changeset
   169
        }
c56c874eef47 Added WRTKit
tasneems@symbian.org
parents:
diff changeset
   170
    }
102
30e0796f3ebb Warnings in new projects were fixed
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 73
diff changeset
   171
};
73
c56c874eef47 Added WRTKit
tasneems@symbian.org
parents:
diff changeset
   172
c56c874eef47 Added WRTKit
tasneems@symbian.org
parents:
diff changeset
   173
// Starts the view manager timer.
c56c874eef47 Added WRTKit
tasneems@symbian.org
parents:
diff changeset
   174
UIManager.prototype.startTimer = function() {
c56c874eef47 Added WRTKit
tasneems@symbian.org
parents:
diff changeset
   175
    if (this.timerId == null) {
c56c874eef47 Added WRTKit
tasneems@symbian.org
parents:
diff changeset
   176
        uiLogger.debug("UIManager timer started");
c56c874eef47 Added WRTKit
tasneems@symbian.org
parents:
diff changeset
   177
        var self = this;
c56c874eef47 Added WRTKit
tasneems@symbian.org
parents:
diff changeset
   178
        // setup the timer
c56c874eef47 Added WRTKit
tasneems@symbian.org
parents:
diff changeset
   179
        this.timerId = setInterval(function() { self.onTimer(); }, this.TIMER_INTERVAL);
c56c874eef47 Added WRTKit
tasneems@symbian.org
parents:
diff changeset
   180
    } else {
c56c874eef47 Added WRTKit
tasneems@symbian.org
parents:
diff changeset
   181
        uiLogger.warn("UIManager timer already running");
c56c874eef47 Added WRTKit
tasneems@symbian.org
parents:
diff changeset
   182
    }
102
30e0796f3ebb Warnings in new projects were fixed
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 73
diff changeset
   183
};
73
c56c874eef47 Added WRTKit
tasneems@symbian.org
parents:
diff changeset
   184
c56c874eef47 Added WRTKit
tasneems@symbian.org
parents:
diff changeset
   185
// Stops the view manager timer.
c56c874eef47 Added WRTKit
tasneems@symbian.org
parents:
diff changeset
   186
UIManager.prototype.stopTimer = function() {
c56c874eef47 Added WRTKit
tasneems@symbian.org
parents:
diff changeset
   187
    if (this.timerId != null) {
c56c874eef47 Added WRTKit
tasneems@symbian.org
parents:
diff changeset
   188
        // stop the timer
c56c874eef47 Added WRTKit
tasneems@symbian.org
parents:
diff changeset
   189
        clearTimeout(this.timerId);
c56c874eef47 Added WRTKit
tasneems@symbian.org
parents:
diff changeset
   190
        this.timerId = null;
c56c874eef47 Added WRTKit
tasneems@symbian.org
parents:
diff changeset
   191
    } else {
c56c874eef47 Added WRTKit
tasneems@symbian.org
parents:
diff changeset
   192
        uiLogger.warn("UIManager timer already stopped");
c56c874eef47 Added WRTKit
tasneems@symbian.org
parents:
diff changeset
   193
    }
102
30e0796f3ebb Warnings in new projects were fixed
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 73
diff changeset
   194
};
73
c56c874eef47 Added WRTKit
tasneems@symbian.org
parents:
diff changeset
   195
c56c874eef47 Added WRTKit
tasneems@symbian.org
parents:
diff changeset
   196
// Timer callback function.
c56c874eef47 Added WRTKit
tasneems@symbian.org
parents:
diff changeset
   197
UIManager.prototype.onTimer = function() {
c56c874eef47 Added WRTKit
tasneems@symbian.org
parents:
diff changeset
   198
    if (this.enableScrollBar) {
c56c874eef47 Added WRTKit
tasneems@symbian.org
parents:
diff changeset
   199
        // make sure the scrollbar is up to date
c56c874eef47 Added WRTKit
tasneems@symbian.org
parents:
diff changeset
   200
        this.updateScrollbar();
c56c874eef47 Added WRTKit
tasneems@symbian.org
parents:
diff changeset
   201
    }
102
30e0796f3ebb Warnings in new projects were fixed
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 73
diff changeset
   202
};
73
c56c874eef47 Added WRTKit
tasneems@symbian.org
parents:
diff changeset
   203
c56c874eef47 Added WRTKit
tasneems@symbian.org
parents:
diff changeset
   204
// Displays a notification.
c56c874eef47 Added WRTKit
tasneems@symbian.org
parents:
diff changeset
   205
UIManager.prototype.showNotification = function(displayTime, type, text, progress) {
c56c874eef47 Added WRTKit
tasneems@symbian.org
parents:
diff changeset
   206
    uiLogger.debug("UIManager.showNotification(" + displayTime + ", " + type + ", " + text + ", " + progress + ")");
c56c874eef47 Added WRTKit
tasneems@symbian.org
parents:
diff changeset
   207
    // use the notification popup to show the notification
c56c874eef47 Added WRTKit
tasneems@symbian.org
parents:
diff changeset
   208
    this.notificationPopup.showNotification(displayTime, type, text, progress);
102
30e0796f3ebb Warnings in new projects were fixed
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 73
diff changeset
   209
};
73
c56c874eef47 Added WRTKit
tasneems@symbian.org
parents:
diff changeset
   210
c56c874eef47 Added WRTKit
tasneems@symbian.org
parents:
diff changeset
   211
// Hides the currently displayed notification.
c56c874eef47 Added WRTKit
tasneems@symbian.org
parents:
diff changeset
   212
UIManager.prototype.hideNotification = function() {
c56c874eef47 Added WRTKit
tasneems@symbian.org
parents:
diff changeset
   213
    uiLogger.debug("UIManager.hideNotification()");
c56c874eef47 Added WRTKit
tasneems@symbian.org
parents:
diff changeset
   214
    // hide the notification popup
c56c874eef47 Added WRTKit
tasneems@symbian.org
parents:
diff changeset
   215
    this.notificationPopup.hideNotification();
102
30e0796f3ebb Warnings in new projects were fixed
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 73
diff changeset
   216
};