From 8155d2cd9cb63104cb14d5c9fe10901a0c77194d Mon Sep 17 00:00:00 2001 From: Dima Malishev Date: Sat, 10 Sep 2011 02:10:49 +0300 Subject: [PATCH] js / index.html update set --- web/index.html | 2 +- web/js/actions.js | 37 +++++++++++++++++++++++++++---------- web/js/pages.js | 11 +++++++++++ web/js/templates.js | 24 ++++++++++++------------ web/js/validators.js | 8 ++++---- 5 files changed, 55 insertions(+), 27 deletions(-) diff --git a/web/index.html b/web/index.html index 479163e4..0d0e1635 100644 --- a/web/index.html +++ b/web/index.html @@ -187,7 +187,7 @@
  - add new entry + add new entry
diff --git a/web/js/actions.js b/web/js/actions.js index c5fee877..45a0ac9e 100644 --- a/web/js/actions.js +++ b/web/js/actions.js @@ -89,16 +89,20 @@ App.Actions.save_form = function(evt) { // do_action_edit App.Actions.edit = function(evt) { - var elm = $(evt.target); - elm = elm.hasClass('row') ? elm : elm.parents('.row'); - - var options = elm.find('.source').val(); - var build_method = App.Env.getWorldName() + '_form'; - var tpl = App.HTML.Build[build_method](options); - elm.replaceWith(tpl); - - App.Helpers.disbleNotEditable(); - //App.Helpers.updateScreen(); + if ('undefined' != typeof App.Pages[App.Env.world].edit) { + App.Pages[App.Env.world].edit(evt); + } else { + var elm = $(evt.target); + elm = elm.hasClass('row') ? elm : elm.parents('.row'); + + var options = elm.find('.source').val(); + var build_method = App.Env.getWorldName() + '_form'; + var tpl = App.HTML.Build[build_method](options); + elm.replaceWith(tpl); + + App.Helpers.disbleNotEditable(); + //App.Helpers.updateScreen(); + } } // do_cancel_form @@ -334,3 +338,16 @@ App.Actions.view_full_ns_list = function(evt) var elm = $(evt.target); App.Helpers.openInnerPopup(elm, $(elm).parents('.prop-box').find('.ns-full-list:first').html()); } + +App.Actions.view_template_info = function(evt) +{ + var elm = $(evt.target); + ref = elm.hasClass('row') ? elm : elm.parents('.row'); + + var options = ref.find('.source').val(); + App.Ajax.request('DNS.getTemplateInfo', {spell: options}, function(reply) { + if (reply.result) { + App.Helpers.openInnerPopup(elm, reply.data); + } + }); +} diff --git a/web/js/pages.js b/web/js/pages.js index f400d6ae..f4283288 100644 --- a/web/js/pages.js +++ b/web/js/pages.js @@ -22,6 +22,7 @@ App.Pages.prepareHTML = function() else { App.Model[App.Env.world].loadList(); } + $('#new-entry-keyword').text(App.Env.world.toLowerCase().replace('_', ' ')); } App.Pages.DNS.showSubform = function(ref) @@ -49,3 +50,13 @@ App.Pages.DNS.edit = function(elm) { elm.replaceWith(tpl); } +App.Pages.USER.new_entry = function(evt) +{ + var form_id = App.Constants[App.Env.world + '_FORM_ID']; + $('#'+form_id).remove(); + var build_method = App.Env.getWorldName() + '_form'; + var tpl = App.HTML.Build[build_method]({}, form_id); + App.Ref.CONTENT.prepend(tpl); + App.Helpers.updateScreen(); + $('#'+form_id).find('.ns-entry, .additional-ns-add').addClass('hidden'); +} diff --git a/web/js/templates.js b/web/js/templates.js index 25d4fbf0..bee8b499 100644 --- a/web/js/templates.js +++ b/web/js/templates.js @@ -110,7 +110,7 @@ App.Templates.html = { ~!:IP~!\ \ template:\ - ~!:TPL~!\ + ~!:TPL~!\ \ \ \ @@ -126,7 +126,7 @@ App.Templates.html = { \ \ '], - SUBFORM: ['
\ + SUBFORM: ['
\
\
Hide records
\
\ @@ -153,8 +153,8 @@ App.Templates.html = {
\
\ \ - ~!:RECORD_TYPE_VALUE~!\ - \ ~!:RECORD_TYPE~!\ \
\ @@ -203,7 +203,7 @@ App.Templates.html = {
\
\ \ -
\ +
\ \
\
\ @@ -297,7 +297,7 @@ App.Templates.html = {
\
\ \ - \ + \
\
\ \ @@ -419,7 +419,7 @@ App.Templates.html = { \
\ bandwidth:\ -
\ +
\
\ ~!:U_BANDWIDTH~!\
\ @@ -435,10 +435,6 @@ App.Templates.html = { \
\
\ - \ - web domains:\ - ~!:U_DNS_DOMAINS~! (~!:WEB_DOMAINS~!)\ - \ \ web ssl:\ ~!:U_WEB_SSL~! (~!:WEB_SSL~!)\ @@ -479,7 +475,11 @@ App.Templates.html = { mail domains:\ ~!:U_MAIL_DOMAINS~! (~!:MAIL_DOMAINS~!)\ \ - \ + \ + web domains:\ + ~!:U_WEB_DOMAINS~! (~!:WEB_DOMAINS~!)\ + \ + \ dns domains:\ ~!:U_DNS_DOMAINS~! (~!:DNS_DOMAINS~!)\ \ diff --git a/web/js/validators.js b/web/js/validators.js index b3ddb57b..07f42d19 100644 --- a/web/js/validators.js +++ b/web/js/validators.js @@ -30,7 +30,7 @@ App.Validate.Rule = { if ($(elm).val().trim() == '' || $(elm).val().search(/[^a-zA-Z_]+/) != -1) { return {VALID: false, ERROR: App.Validate.getFieldName(elm) + ' is invalid'}; } - if ($(elm).val().trim() == '' || $(elm).val().length > App.Settings.FIELD_MAX_LEN) { + if ($(elm).val().trim() != '' || $(elm).val().length > App.Settings.FIELD_MAX_LEN) { return {VALID: false, ERROR: App.Validate.getFieldName(elm) + ' too long'}; } } @@ -41,7 +41,7 @@ App.Validate.Rule = { if ($(elm).val().trim() == '') { return {VALID: false, ERROR: App.Validate.getFieldName(elm) + ' is required'}; } - if ($(elm).val().trim() == '' || $(elm).val().length > App.Settings.FIELD_MAX_LEN) { + if ($(elm).val().trim() != '' || $(elm).val().length > App.Settings.FIELD_MAX_LEN) { return {VALID: false, ERROR: App.Validate.getFieldName(elm) + ' too long'}; } } @@ -51,7 +51,7 @@ App.Validate.Rule = { if ($(elm).val().trim() != '' && $(elm).val().search(/[^a-zA-Z_]+/) != -1) { return {VALID: false, ERROR: App.Validate.getFieldName(elm) + ' is invalid'}; } - if ($(elm).val().trim() == '' || $(elm).val().length > App.Settings.FIELD_MAX_LEN) { + if ($(elm).val().trim() != '' || $(elm).val().length > App.Settings.FIELD_MAX_LEN) { return {VALID: false, ERROR: App.Validate.getFieldName(elm) + ' too long'}; } return {VALID: true}; @@ -78,7 +78,7 @@ App.Validate.Rule = { if ($(elm).val().trim() != '' && $(elm).val().search(/[^a-zA-Z]+/) != -1) { return {VALID: false, ERROR: App.Validate.getFieldName(elm) + ' must contain only letters without spaces or other symbols'}; } - if ($(elm).val().trim() == '' || $(elm).val().length > App.Settings.FIELD_MAX_LEN) { + if ($(elm).val().trim() != '' || $(elm).val().length > App.Settings.FIELD_MAX_LEN) { return {VALID: false, ERROR: App.Validate.getFieldName(elm) + ' too long'}; } return {VALID: true};