diff --git a/web/js/events.js b/web/js/events.js new file mode 100644 index 00000000..ccbf89ab --- /dev/null +++ b/web/js/events.js @@ -0,0 +1,124 @@ +// Init kinda namespace object +var VE = { // Vesta Events object + core: {}, // core functions + callbacks: { // events callback functions + click: {}, + mouseover: {}, + mouseout: {}, + keypress: {} + }, + helpers: {}, // simple handy methods + tmp: {} +}; + +/* + * Main method that invokes further event processing + * @param root is root HTML DOM element that. Pass HTML DOM Element or css selector + * @param event_type (eg: click, mouseover etc..) + */ +VE.core.register = function(root, event_type) { + var root = !root ? 'body' : root; // if elm is not passed just bind events to body DOM Element + var event_type = !event_type ? 'click' : event_type; // set event type to "click" by default + $(root).bind(event_type, function(evt) { + var elm = $(evt.target); + VE.core.dispatch(evt, elm, event_type); // dispatch captured event + }); +} + +/* + * Dispatch event that was previously registered + * @param evt related event object + * @param elm that was catched + * @param event_type (eg: click, mouseover etc..) + */ +VE.core.dispatch = function(evt, elm, event_type) { + if ('undefined' == typeof VE.callbacks[event_type]) { + return VE.helpers.warn('There is no corresponding object that should contain event callbacks for "'+event_type+'" event type'); + } + // get class of element + var classes = $(elm).attr('class'); + // if no classes are attached, then just stop any further processings + if (!classes) { + return; // no classes assigned + } + // split the classes and check if it related to function + $(classes.split(/\s/)).each(function(i, key) { + VE.callbacks[event_type][key] && VE.callbacks[event_type][key](evt, elm); + }); +} + +// +// CALLBACKS +// + + + +/* + * Suspend action + */ +VE.callbacks.click.do_suspend = function(evt, elm) { + var ref = elm.hasClass('data-controls') ? elm : elm.parents('.data-controls'); + var url = $('input[name="suspend_url"]', ref).val(); + var dialog_elm = ref.find('.confirmation-text-suspention'); + VE.helpers.createConfirmationDialog(dialog_elm, 'Confirm SUSPEND', url); +} + +/* + * Unsuspend action + */ +VE.callbacks.click.do_unsuspend = function(evt, elm) { + var ref = elm.hasClass('data-controls') ? elm : elm.parents('.data-controls'); + var url = $('input[name="unsuspend_url"]', ref).val(); + var dialog_elm = ref.find('.confirmation-text-suspention'); + VE.helpers.createConfirmationDialog(dialog_elm, 'Confirm UNSUSPEND', url); +} + +/* + * Delete action + */ +VE.callbacks.click.do_delete = function(evt, elm) { + var ref = elm.hasClass('data-controls') ? elm : elm.parents('.data-controls'); + var url = $('input[name="delete_url"]', ref).val(); + var dialog_elm = ref.find('.confirmation-text-delete'); + VE.helpers.createConfirmationDialog(dialog_elm, 'Confirm DELETE', url); +} + + +/* + * Create dialog box on the fly + * @param elm Element which contains the dialog contents + * @param dialog_title + * @param confirmed_location_url URL that will be redirected to if user hit "OK" + * @param custom_config Custom configuration parameters passed to dialog initialization (optional) + */ +VE.helpers.createConfirmationDialog = function(elm, dialog_title, confirmed_location_url, custom_config) { + var custom_config = !custom_config ? {} : custom_config; + var config = { + modal: true, + autoOpen: true, + width: 360, + title: dialog_title, + close: function() { + $(this).dialog("destroy"); + }, + buttons: { + "Ok": function(event, ui) { + location.href = confirmed_location_url; + }, + "Cancel": function() { + $(this).dialog("close"); + $(this).dialog("destroy"); + } + } + } + config = $.extend(config, custom_config); + var reference_copied = $(elm).clone(); + $(reference_copied).dialog(config); +} + +/* + * Simple debug output + */ +VE.helpers.warn = function(msg) { + alert('WARNING: ' + msg); +} diff --git a/web/templates/admin/list_backup.html b/web/templates/admin/list_backup.html index 97492074..f7c50ed5 100644 --- a/web/templates/admin/list_backup.html +++ b/web/templates/admin/list_backup.html @@ -44,46 +44,6 @@ if (!empty($data[$key]['DB'])) $db = 'yes ยจ'; ?> - - @@ -96,19 +56,14 @@
- - - + + diff --git a/web/templates/admin/list_cron.html b/web/templates/admin/list_cron.html index 82fa93a1..a7379960 100644 --- a/web/templates/admin/list_cron.html +++ b/web/templates/admin/list_cron.html @@ -44,44 +44,6 @@ ?> -
download - - "> restore -
" title="Confirmation"> -

Are you sure you want to restore backup?

-
-
- - delete -
-

Are you sure you want to delete backup?

+
download"> restore + + delete + " /> +
@@ -93,18 +55,20 @@
- - + - diff --git a/web/templates/admin/list_db.html b/web/templates/admin/list_db.html index b20e573b..52f141e3 100644 --- a/web/templates/admin/list_db.html +++ b/web/templates/admin/list_db.html @@ -48,44 +48,6 @@ if ($data[$key]['TYPE'] == 'pgsql') $db_admin_link = "http://".$http_host."/phpPgAdmin/"; ?> -
edit - - "> -
" title="Confirmation"> -

Are you sure you want to cron job?

+
edit + + + + - - delete -
+
+ + delete + +
@@ -97,19 +59,21 @@
- - - + + - diff --git a/web/templates/admin/list_dns.html b/web/templates/admin/list_dns.html index 1307d03e..f9db4e85 100644 --- a/web/templates/admin/list_dns.html +++ b/web/templates/admin/list_dns.html @@ -42,45 +42,6 @@ } ?> - -
open edit - - "> -
" title="Confirmation"> +
open edit + + + " /> + - - delete -
+
+ + delete + " /> +
@@ -93,20 +54,22 @@
- - - - + + + - diff --git a/web/templates/admin/list_dns_rec.html b/web/templates/admin/list_dns_rec.html index a4b54ed7..95848038 100644 --- a/web/templates/admin/list_dns_rec.html +++ b/web/templates/admin/list_dns_rec.html @@ -43,45 +43,6 @@ } ?> - -
list records add record edit - - "> -
" title="Confirmation"> -

Are you sure you want to domain?

+
list records add record edit + + + + - - delete -
+
+ + delete + +
@@ -94,18 +55,20 @@
- - + - diff --git a/web/templates/admin/list_ip.html b/web/templates/admin/list_ip.html index cac5aaad..8cdb05a5 100644 --- a/web/templates/admin/list_ip.html +++ b/web/templates/admin/list_ip.html @@ -35,28 +35,6 @@ ++$i; ?> - -
edit - - "> -
" title="Confirmation"> +
edit + + + + - - "> delete -
" title="Confirmation"> +
+ + delete + +
@@ -69,11 +47,12 @@
- - + diff --git a/web/templates/admin/list_mail.html b/web/templates/admin/list_mail.html index 64214095..23b13fbf 100644 --- a/web/templates/admin/list_mail.html +++ b/web/templates/admin/list_mail.html @@ -46,45 +46,6 @@ } ?> - -
edit - - delete -
+
edit + + delete + " /> +
@@ -97,21 +58,23 @@
- - - - - + + + + - diff --git a/web/templates/admin/list_mail_acc.html b/web/templates/admin/list_mail_acc.html index f1caacda..188bc869 100644 --- a/web/templates/admin/list_mail_acc.html +++ b/web/templates/admin/list_mail_acc.html @@ -43,46 +43,6 @@ } ?> - -
list accounts add account " target="_blank"> open webmail edit - - "> -
" title="Confirmation"> +
list accounts add account" target="_blank"> open webmail edit + + + + - - delete -
+
+ + delete + +
@@ -95,18 +55,20 @@
- - + - diff --git a/web/templates/admin/list_packages.html b/web/templates/admin/list_packages.html index 8cad84c7..417bb0aa 100644 --- a/web/templates/admin/list_packages.html +++ b/web/templates/admin/list_packages.html @@ -36,27 +36,6 @@ ?> -
edit - - "> -
" title="Confirmation"> -

Are you sure you want to account?

+
edit + + + + - - "> delete -
" title="Confirmation"> +
+ + delete + +
@@ -68,12 +47,13 @@
- - + diff --git a/web/templates/admin/list_rrd.html b/web/templates/admin/list_rrd.html index 8a40462a..f12d93aa 100644 --- a/web/templates/admin/list_rrd.html +++ b/web/templates/admin/list_rrd.html @@ -44,7 +44,7 @@
edit - - delete -
-

Are you sure you want to delete package?

+
edit + + delete + " /> +
- +
" target="_blank"> download" target="_blank"> download
diff --git a/web/templates/admin/list_user.html b/web/templates/admin/list_user.html index 611eac0d..f3921edd 100644 --- a/web/templates/admin/list_user.html +++ b/web/templates/admin/list_user.html @@ -56,45 +56,6 @@ } ?> - -
@@ -107,10 +68,10 @@
- '; - echo " open webstats "; + echo ' '; } ?> - - + - diff --git a/web/templates/footer.html b/web/templates/footer.html index caf828f8..f1935d37 100644 --- a/web/templates/footer.html +++ b/web/templates/footer.html @@ -10,6 +10,13 @@
+ logout"; + echo " logout"; if (!empty($_SESSION['look_alert'])) { ?>
@@ -114,22 +76,25 @@ '; + echo ""; + echo ' open webstats "> edit - - "> -
" title="Confirmation"> +
"> edit + + + + - - delete -
+
+ + delete + +
+ + + diff --git a/web/templates/header.html b/web/templates/header.html index 01a28a14..0f2ae172 100644 --- a/web/templates/header.html +++ b/web/templates/header.html @@ -15,6 +15,10 @@ margin: 0; } + .hidden { + display: none; + } + .main { background: #ffffff; box-shadow: 0 0 2px 2px #d7d7d7; @@ -329,9 +333,18 @@ font-family: Arial, sans-serif; padding: 2 5 0 5; letter-spacing: 0.1em; + color: #34536A; + text-decoration: none; + cursor: pointer; } .data-controls:hover { + color: #ffffff; + background: #f79b44; + } + + .data-controls:active { + color: #433832; background: #f79b44; } @@ -342,19 +355,21 @@ .data-controls a:visited { color: #34536A; - text-decoration: none; } .data-controls a:hover { color: #ffffff; - text-decoration: none; } .data-controls a:active { color: #433832; - text-decoration: none; } + .data-controls img { + border: 0px; + } + + .data-count { background: #ebe9dc; color: #555; @@ -680,6 +695,7 @@ +
@@ -74,11 +53,12 @@
- - + diff --git a/web/templates/user/list_db.html b/web/templates/user/list_db.html index 82e75918..35e8d862 100644 --- a/web/templates/user/list_db.html +++ b/web/templates/user/list_db.html @@ -46,27 +46,6 @@ if ($data[$key]['TYPE'] == 'pgsql') $db_admin_link = "http://".$http_host."/phpPgAdmin/"; ?> -
edit - - delete -
+
edit + + delete + +
@@ -78,12 +57,13 @@
- - - + + diff --git a/web/templates/user/list_dns.html b/web/templates/user/list_dns.html index 7d59ad26..cbb37976 100644 --- a/web/templates/user/list_dns.html +++ b/web/templates/user/list_dns.html @@ -40,28 +40,6 @@ } ?> - -
open edit - - delete -
+
open edit + + delete + " /> +
@@ -74,13 +52,14 @@
- - - - + + + diff --git a/web/templates/user/list_dns_rec.html b/web/templates/user/list_dns_rec.html index 38a5fa38..80451f05 100644 --- a/web/templates/user/list_dns_rec.html +++ b/web/templates/user/list_dns_rec.html @@ -41,28 +41,6 @@ } ?> - -
list records add record edit - - delete -
+
list records add record edit + + delete + +
@@ -75,11 +53,12 @@
- - + diff --git a/web/templates/user/list_mail.html b/web/templates/user/list_mail.html index 3e6c8fc2..480f63e9 100644 --- a/web/templates/user/list_mail.html +++ b/web/templates/user/list_mail.html @@ -44,28 +44,6 @@ } ?> - -
edit - - "> delete -
" title="Confirmation"> +
edit + + delete + +
@@ -78,14 +56,15 @@
- - - - - + + + + diff --git a/web/templates/user/list_mail_acc.html b/web/templates/user/list_mail_acc.html index ef42f4f1..d8f53d50 100644 --- a/web/templates/user/list_mail_acc.html +++ b/web/templates/user/list_mail_acc.html @@ -41,28 +41,6 @@ } ?> - -
list accounts add account " target="_blank"> open webmail edit - - delete -
+
list accounts add account" target="_blank"> open webmail edit + + delete + +
@@ -75,11 +53,12 @@
- - + diff --git a/web/templates/user/list_user.html b/web/templates/user/list_user.html index 556e3a67..600d440c 100644 --- a/web/templates/user/list_user.html +++ b/web/templates/user/list_user.html @@ -47,28 +47,6 @@ } ?> - - '; - echo " open webstats "; + echo ' '; } ?> - - +
edit - - "> delete -
" title="Confirmation"> +
edit + + delete + +
@@ -81,7 +59,7 @@
- +
"> edit"> edit
diff --git a/web/templates/user/list_web.html b/web/templates/user/list_web.html index 779c38de..146ac437 100644 --- a/web/templates/user/list_web.html +++ b/web/templates/user/list_web.html @@ -59,27 +59,6 @@ $nginx_ext = str_replace(',', ', ', $data[$key]['NGINX_EXT']); } ?> -
@@ -95,15 +74,17 @@ '; + echo ""; + echo ' open webstats "> edit - - delete -
+
"> edit + + delete + +