forked from hestiacp/hestiacp
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcore.js
More file actions
78 lines (68 loc) · 2.38 KB
/
core.js
File metadata and controls
78 lines (68 loc) · 2.38 KB
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
/*App.Core.action_reflector = {
'new_entry': App.Actions.newForm,
'cancel_form': App.Actions.cancelForm,
'save_form': App.Actions.saveForm,//App.Pages.IP.saveIpForm,
'remove': App.Actions.remove,//App.Pages.IP.deleteIp,
'cancel_dns_form': App.Pages.DNS.closeForm,
'save_dns_form': App.Pages.DNS.saveForm,
'edit': App.Actions.edit,
'embed_subform': App.Actions.embedSubform,
'form_help': App.Actions.showFormHelp,
'entry_help': App.Actions.showEntryHelp,
'close_popup': App.View.closePopup
};*/
//
// CORE
//
App.Core.listen = function(){
fb.log('start listening');
$(document).bind('click', function(evt){
//App.Pages.IP.customListen && App.Pages.IP.customListen(evt);
var elm = $(evt.target);
var action = $(elm).attr('class');
if (!action) {
return fb.log(':)');
}
action = action.split('do_action_');
if(action.length < 2){
if (elm.hasClass('check-this')) {
var ref = $(elm).parents('.row');
ref.hasClass('checked-row') ? ref.removeClass('checked-row') : ref.addClass('checked-row');
}
return; // no action found attached to the dom object
}
try{
// retrieve the action itself
action_with_params = action[1].split(' ');
action = action_with_params[0];
params = elm.find('.prm-'+action).value || null;
// TODO: filter params here
// Call the action
App.Core.__CALL__(evt, action, params);
}catch(e){
fb.error(e)
}
});
}
/**
* Action caller
* if no action registered, execution will stop
*/
App.Core.__CALL__ = function(evt, action, params){
if('undefined' == typeof App.Actions[action]){
return fb.warn('No action registered for: "'+action+'". Stop propagation');
}else{
return App.Actions[action](evt, params);
}
}
App.Core.initMenu = function(){
$('.section').bind('click', function(evt){
var elm = $(evt.target);
!elm.hasClass('section') ? elm = elm.parents('.section') : -1;
if(App.Env.world != elm.attr('id')){
App.Env.world = elm.attr('id');
App.Pages.init();
fb.warn('Switch page to: ' + App.Env.world);
}
});
}