mirror of
https://github.com/OpenNebula/one.git
synced 2026-11-20 11:52:37 +09:00
feature #3758: Refactor dialogs
This commit is contained in:
1 parent
61b627e6f4
commit
e21d4ac97c
2 files changed
+49
-12
No files matched your search
@@ -1,6 +1,6 @@
|
||||
define(function(require) {
|
||||
require('jquery');
|
||||
require('foundation.core')
|
||||
require('foundation.reveal');
|
||||
|
||||
var Config = require('sunstone-config');
|
||||
var Locale = require('utils/locale');
|
||||
@@ -15,18 +15,15 @@ define(function(require) {
|
||||
"form_panels" : {}
|
||||
};
|
||||
|
||||
var _addActions = function(actions) {
|
||||
for (action in actions) {
|
||||
SunstoneCfg["actions"][action] = actions[action];
|
||||
}
|
||||
}
|
||||
|
||||
var _addMainTab = function(tadId, tabObj) {
|
||||
if (Config.isTabEnabled(tadId)) {
|
||||
SunstoneCfg["tabs"][tadId] = tabObj;
|
||||
|
||||
if (tabObj.actions) {
|
||||
_addActions(tabObj.actions);
|
||||
|
||||
var actions = tabObj.actions;
|
||||
if (actions) {
|
||||
$.each(actions, function(actionName, action){
|
||||
SunstoneCfg["actions"][actionName] = action;
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -509,6 +506,43 @@ define(function(require) {
|
||||
});
|
||||
}
|
||||
|
||||
var _insertDialog = function(dialog) {
|
||||
var dialogElement = $(dialog.html()).appendTo('div#dialogs');
|
||||
dialog.setup(dialogElement);
|
||||
dialogElement.foundation('reveal', 'reflow');
|
||||
|
||||
dialogElement.on('opened.fndtn.reveal', function () {
|
||||
dialog.onShow(dialogElement);
|
||||
});
|
||||
|
||||
return dialogElement;
|
||||
}
|
||||
|
||||
var _showDialog = function(tabName, dialogId) {
|
||||
var dialog = SunstoneCfg['tabs'][tabName]['dialogs'][dialogId];
|
||||
var dialogElement = $('#' + dialog.dialogId);
|
||||
if (dialogElement.length == 0) {
|
||||
dialogElement = _insertDialog(dialog);
|
||||
}
|
||||
|
||||
dialogElement.foundation('reveal', 'open');
|
||||
return false;
|
||||
}
|
||||
|
||||
var _hideDialog = function(tabName, dialogId) {
|
||||
var dialog = SunstoneCfg['tabs'][tabName]['dialogs'][dialogId];
|
||||
var dialogElement = $('#' + dialog.dialogId);
|
||||
dialogElement.foundation('reveal', 'close')
|
||||
}
|
||||
|
||||
var _resetDialog = function(tabName, dialogId) {
|
||||
var dialog = SunstoneCfg['tabs'][tabName]['dialogs'][dialogId];
|
||||
var dialogElement = $('#' + dialog.dialogId);
|
||||
dialogElement.remove();
|
||||
dialogElement = _insertDialog(dialog);
|
||||
return false;
|
||||
}
|
||||
|
||||
//Runs a predefined action. Wraps the calls to opennebula.js and
|
||||
//can be use to run action depending on conditions and notify them
|
||||
//if desired. Returns 1 if some problem has been detected: i.e
|
||||
@@ -611,7 +645,6 @@ define(function(require) {
|
||||
|
||||
var Sunstone = {
|
||||
//Adds several actions encapsulated in an js object.
|
||||
"addActions" : _addActions,
|
||||
|
||||
"addMainTab" : _addMainTab,
|
||||
|
||||
@@ -624,6 +657,10 @@ define(function(require) {
|
||||
"showElement" : _showElement,
|
||||
"insertPanels" : _insertPanels,
|
||||
|
||||
"showDialog": _showDialog,
|
||||
"hideDialog": _hideDialog,
|
||||
"resetDialog": _resetDialog,
|
||||
|
||||
"popUpFormPanel" : function(formName, selectedTab, action, reset, initalizeFunc) {
|
||||
var context = $("#" + selectedTab);
|
||||
popFormDialogLoading(context);
|
||||
|
||||
@@ -153,7 +153,7 @@
|
||||
<div id="footer" class="text-center large-10 columns right">
|
||||
<a href="http://opennebula.org" target="_blank">OpenNebula 4.12.0</a> by <a href="http://OpenNebula.systems" target="_blank">OpenNebula Systems</a>.
|
||||
</div>
|
||||
<div class="large-12 columns hidden" id="dialogs"></div>
|
||||
<div class="large-12 columns" id="dialogs"></div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
Reference in new issue
Block a user