1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
|
/* Authors:
* Petr Vobornik <pvoborni@redhat.com>
*
* Copyright (C) 2013 Red Hat
* see file 'COPYING' for use and warranty information
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
define([
'dojo/_base/lang',
'./app_container',
'./ipa',
'exports' // for handling circular dependency
],
function(lang, app_container, IPA, exports) {
var get_menu = function() {
return app_container.app.menu;
},
/**
* Menu proxy.
*
* Exports public interface for dealing with menu items.
* @class menu
*/
/**
* Adds menu item.
* Takes a spec of menu item.
* Normalizes item's name, parent, adds children if specified
*
* @method add_item
* @param {navigation.MenuItem} item
* @param {string|navigation.MenuItem} parent
* @param {Object} options
*/
add_item = function(item, parent, options) {
var menu = get_menu();
return menu.add_item(item, parent, options);
},
/**
* Removes menu item
*
* @method remove_item
* @param {string|navigation.MenuItem} name or menu item to remove
*/
remove_item = function(item) {
var menu = get_menu();
return menu.items.remove(item);
},
/**
* Query internal data store by using default search options or supplied
* search options.
*
* @method query
* @param {Object} query
* @param {Object} [search_options] Search options, overrides default
* @return {QueryResult}
*/
query = function(query, search_options) {
var menu = get_menu();
if (search_options) {
return menu.items.query(query, search_options);
} else {
return menu.query(query);
}
},
/**
* Get current instance of menu
* @method get
* @return {navigation.Menu}
*/
get = function() {
return get_menu();
};
// Module export
exports = {
add_item: add_item,
remove_item: remove_item,
query: query,
get: get
};
return exports;
});
|