From 53a02682274f3186d1d175db7352e25243490213 Mon Sep 17 00:00:00 2001 From: Malishev Dmitry Date: Mon, 5 Sep 2011 18:55:29 +0300 Subject: [PATCH] Javascript cleanup; new functionality; added jquery-ui --- web/index.html | 3 +- web/js/_settings.js | 1 + web/js/actions.js | 69 +++++++++++++++++++++++++++----------------- web/js/html.js | 9 +++--- web/js/templates.js | 23 +++++++-------- web/js/validators.js | 6 ++++ 6 files changed, 68 insertions(+), 43 deletions(-) diff --git a/web/index.html b/web/index.html index 760a23058..857c81007 100644 --- a/web/index.html +++ b/web/index.html @@ -205,7 +205,8 @@ - + + diff --git a/web/js/_settings.js b/web/js/_settings.js index b2e51b288..802db2b06 100644 --- a/web/js/_settings.js +++ b/web/js/_settings.js @@ -40,6 +40,7 @@ App.Messages.get = function(key, plural) { // Empty App.Empty = {}; App.Empty.USER = {'CONTACT':'', 'PASSWORD':'','LOGIN_NAME':'','LNAME':'', 'FNAME':'','NS1':'','NS2':'','NS3':'','NS4':'','NS5':'','NS6':'','NS7':'','NS8':''}; +App.Empty.WEB_DOMAIN = {'CONTACT':'', 'PASSWORD':'','LOGIN_NAME':'','NS':'', 'DOMAIN':'','SSL_CERT':'','SSL_HOME':'','STATS_PASSWORD':'','STATS_LOGIN':'','ALIAS':''}; App.Settings.getMethodName = function(action) { diff --git a/web/js/actions.js b/web/js/actions.js index ef27f0f45..e02bebea2 100644 --- a/web/js/actions.js +++ b/web/js/actions.js @@ -24,17 +24,6 @@ App.Actions.show_subform = function(evt) // TODO: probably general way to embed subforms } -App.Actions.close_subform = function(evt) -{ - var elm = $(evt.target); - var ref = elm.hasClass('subform') ? elm : elm.parents('.subform'); - var parent_ref = ref.prev('.row'); - if (parent_ref.length > 0) { - parent_ref.find('.show-records').removeClass('hidden'); - } - ref.remove(); -} - App.Actions.view_template_settings = function(evt) { alert('TODO'); @@ -51,17 +40,6 @@ App.Actions.add_subrecord_dns = function(evt) } } -App.Actions.delete_subentry = function(evt) -{ - var sure = confirm(App.i18n.getMessage('confirm')); - if (!sure) { - return; - } - var elm = $(evt.target); - var ref = elm.hasClass('subrow') ? elm : elm.parents('.subrow'); - ref.effect('puff', {}, 300, function(){ref.remove();}) -} - /** * Embeds new item form * if exits custom method (App.Pages[ENVIRONMENT_NAME].newForm) @@ -213,17 +191,56 @@ App.Actions.close_popup = function() App.View.closePopup(); } + +App.Actions.close_subform = function(evt, elm) +{ + var elm = elm || $(evt.target); + var ref = elm.hasClass('subform') ? elm : elm.parents('.subform'); + var parent_ref = ref.prev('.row'); + if (parent_ref.length > 0) { + parent_ref.find('.show-records').removeClass('hidden'); + } + ref.remove(); +} + App.Actions.save_dns_subrecords = function(evt) { var elm = $(evt.target); var ref = elm.hasClass('subform') ? elm : elm.parents('.subform'); - var records = []; - ref.find('.subrow').each(function(i, o){ - records[records.length++] = App.Helpers.getFormValuesFromElement(o); + var data = []; + $('.subform').find('.subrow').each(function(i, o) + { + data[data.length++] = App.Helpers.getFormValues(o); }); - fb.warn($.toJSON(records)); + var parent_row = $(elm).parents('.subform').prev('.dns-details-row'); + var dns_json = $(parent_row).find('.source').val(); + + App.Ajax.request('DNS.changeRecords', {spell: App.Helpers.toJSON(data), dns: dns_json}, function(reply) + { + if (reply.result) { + var emphasize = $('.show-records', parent_row); + App.Actions.close_subform(null, elm); + $(emphasize).effect("highlight", {'color':'#B0D635'}, 3000); + + } + else { + App.Helpers.alert('Changes were not applied'); + } + }); +} + +App.Actions.delete_subentry = function(evt) +{ + var sure = confirm(App.i18n.getMessage('confirm')); + if (!sure) { + return; + } + + var elm = $(evt.target); + var ref = elm.hasClass('subrow') ? elm : elm.parents('.subrow'); + $(ref).remove(); } App.Actions.generate_pass = function() diff --git a/web/js/html.js b/web/js/html.js index 64c440d2a..158244384 100644 --- a/web/js/html.js +++ b/web/js/html.js @@ -83,7 +83,7 @@ App.HTML.Build.dns_form = function(options, id) } tpl.set(':id', id || ''); - tpl.set(':DNS_DOMAIN', options.DNS_DOMAIN || ''); + tpl.set(':DNS_DOMAIN', options.DNS_DOMAIN || ''); tpl.set(':IP', options.IP || ''); tpl.set(':TTL', options.TTL || ''); tpl.set(':SOA', options.SOA || ''); @@ -309,7 +309,7 @@ App.HTML.Build.web_domain_form = function(options, id) tpl.set(':save_button', 'SAVE'); } - options = !App.Helpers.isEmpty(options) ? options : {'CONTACT':'', 'PASSWORD':'','LOGIN_NAME':'','NS':''}; + options = !App.Helpers.isEmpty(options) ? options : App.Empty.WEB_DOMAIN; tpl = App.HTML.setTplKeys(tpl, options, true); tpl = App.HTML.Build.user_selects(tpl, options); @@ -373,11 +373,12 @@ App.HTML.Build.db_form = function(options, id) tpl.set(':save_button', 'SAVE'); } - options = !App.Helpers.isEmpty(options) ? options : {'DB':'', 'USER':'','FORM':'', 'PASSWORD': ''}; - + options = !App.Helpers.isEmpty(options) ? options : {'DB':'', 'USER':'','FORM':'', 'PASSWORD': ''}; tpl = App.HTML.setTplKeys(tpl, options, true); tpl = App.HTML.Build.db_selects(tpl, options); + tpl.set(':PASSWORD', ''); + return tpl.finalize(); } diff --git a/web/js/templates.js b/web/js/templates.js index a69f585a4..831b60a51 100644 --- a/web/js/templates.js +++ b/web/js/templates.js @@ -75,7 +75,7 @@ App.Templates.html = { \
\ \ - \ + \
\
\ \ @@ -139,7 +139,7 @@ App.Templates.html = {
\ \ Cancel\ - Help\ + \
\
'], SUBENTRY: ['
\ @@ -160,7 +160,7 @@ App.Templates.html = {
\
\ \ - \ + \
\
\ '] @@ -497,11 +497,11 @@ App.Templates.html = { \ \
~!:title~!
\ -
\ + \
\ \ - \ + \
\
\ \ @@ -529,7 +529,6 @@ App.Templates.html = { \ \
\ -\
\ \ \ @@ -541,11 +540,11 @@ App.Templates.html = {
\
\ \ - \ + \
\
\ \ - \ + \ Generate\
\
\ @@ -591,7 +590,7 @@ App.Templates.html = { \ \
\ - \ + \ Cancel\ Help\
\ @@ -725,7 +724,7 @@ App.Templates.html = { Generate\ \ \ -
\ + \ @@ -741,7 +740,7 @@ App.Templates.html = {
\
\
\ - delete\ + delete\
\
\
\ @@ -758,7 +757,7 @@ App.Templates.html = { ~!:DB~!\
\
\ -
\ +