~mortenoh/+junk/dhis2-detailed-import-export

« back to all changes in this revision

Viewing changes to gis/dhis-gis-geostat/mfbase/ext/air/src/SystemTray.js

  • Committer: larshelge at gmail
  • Date: 2009-03-03 16:46:36 UTC
  • Revision ID: larshelge@gmail.com-20090303164636-2sjlrquo7ib1gf7r
Initial check-in

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Ext JS Library 0.20
 
3
 * Copyright(c) 2006-2008, Ext JS, LLC.
 
4
 * licensing@extjs.com
 
5
 * 
 
6
 * http://extjs.com/license
 
7
 */
 
8
 
 
9
Ext.air.SystemTray = function(){
 
10
        var app = air.NativeApplication.nativeApplication;
 
11
        var icon, isWindows = false, bitmaps;
 
12
        
 
13
        // windows
 
14
        if(air.NativeApplication.supportsSystemTrayIcon) {
 
15
        icon = app.icon;
 
16
                isWindows = true;
 
17
    }
 
18
    
 
19
        // mac
 
20
    if(air.NativeApplication.supportsDockIcon) {
 
21
                icon = app.icon;
 
22
    }
 
23
        
 
24
        return {
 
25
                
 
26
                setIcon : function(icon, tooltip, initWithIcon){
 
27
                        if(!icon){ // not supported OS
 
28
                                return;
 
29
                        }
 
30
                        var loader = new air.Loader();
 
31
                        loader.contentLoaderInfo.addEventListener(air.Event.COMPLETE, function(e){
 
32
                                bitmaps = new runtime.Array(e.target.content.bitmapData);
 
33
                                if (initWithIcon) {
 
34
                                        icon.bitmaps = bitmaps;
 
35
                                }
 
36
                        });
 
37
                loader.load(new air.URLRequest(icon));
 
38
                        if(tooltip && air.NativeApplication.supportsSystemTrayIcon) {
 
39
                                app.icon.tooltip = tooltip;
 
40
                        }
 
41
                },
 
42
                
 
43
                bounce : function(priority){
 
44
                        icon.bounce(priority);
 
45
                },
 
46
                
 
47
                on : function(eventName, fn, scope){
 
48
                        icon.addEventListener(eventName, function(){
 
49
                                fn.apply(scope || this, arguments);
 
50
                        });
 
51
                },
 
52
                
 
53
                hideIcon : function(){
 
54
                        if(!icon){ // not supported OS
 
55
                                return;
 
56
                        }
 
57
                        icon.bitmaps = [];
 
58
                },
 
59
                
 
60
                showIcon : function(){
 
61
                        if(!icon){ // not supported OS
 
62
                                return;
 
63
                        }
 
64
                        icon.bitmaps = bitmaps;
 
65
                },
 
66
                
 
67
                setMenu: function(actions, _parentMenu){
 
68
                        if(!icon){ // not supported OS
 
69
                                return;
 
70
                        }
 
71
                        var menu = new air.NativeMenu();
 
72
                        
 
73
                        for (var i = 0, len = actions.length; i < len; i++) {
 
74
                                var a = actions[i];
 
75
                                if(a == '-'){
 
76
                                        menu.addItem(new air.NativeMenuItem("", true));
 
77
                                }else{
 
78
                                        var item = menu.addItem(Ext.air.MenuItem(a));
 
79
                                        if(a.menu || (a.initialConfig && a.initialConfig.menu)){
 
80
                                                item.submenu = Ext.air.SystemTray.setMenu(a.menu || a.initialConfig.menu, menu);
 
81
                                        }
 
82
                                }
 
83
                                
 
84
                                if(!_parentMenu){
 
85
                                        icon.menu = menu;
 
86
                                }
 
87
                        }
 
88
                        
 
89
                        return menu;
 
90
                }
 
91
        };      
 
92
}();
 
 
b'\\ No newline at end of file'