From b3d79da0a6fcfd34461a54147ad2e1666a22679d Mon Sep 17 00:00:00 2001 From: Antonin <zepcome@gmail.com> Date: Thu, 26 Mar 2015 17:09:52 +0100 Subject: [PATCH] Changing message creation logic. --- js/app/studs.js | 8 +++----- studs.php | 1 + tpl/studs.tpl | 6 ++++-- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/js/app/studs.js b/js/app/studs.js index 7a32203a..a41f1564 100644 --- a/js/app/studs.js +++ b/js/app/studs.js @@ -6,12 +6,10 @@ $(document).ready(function() { var regex = new RegExp(regexContent[1], regexContent[2]); if (name.length == 0 || !regex.test(name)) { event.preventDefault(); - var errorMessage = $("#parameter_name_error").text(); - var addedDiv = "<div class='alert alert-dismissible alert-danger' role='alert'>"; - addedDiv += errorMessage; - addedDiv += "<button type='button' class='close' data-dismiss='alert' aria-label='Close'><span aria-hidden='true'>×</span></button></div>"; + var newMessage = $("#nameErrorMessage").clone(); $("#message-container").empty(); - $("#message-container").append(addedDiv); + $("#message-container").append(newMessage); + newMessage.removeClass("hidden"); $('html, body').animate({ scrollTop: $("#message-container").offset().top }, 750); diff --git a/studs.php b/studs.php index 461d86d9..1bfbb525 100644 --- a/studs.php +++ b/studs.php @@ -203,5 +203,6 @@ $smarty->assign('editingVoteId', $editingVoteId); $smarty->assign('message', $message); $smarty->assign('admin', false); $smarty->assign('parameter_name_regex', NAME_REGEX); +$smarty->assign('parameter_name_error', _('Name is incorrect.')); $smarty->display('studs.tpl'); diff --git a/tpl/studs.tpl b/tpl/studs.tpl index b83f36ad..2c9b3819 100644 --- a/tpl/studs.tpl +++ b/tpl/studs.tpl @@ -6,13 +6,16 @@ {block name=main} + <div id="message-container"> {if !empty($message)} <div class="alert alert-dismissible alert-{$message->type|html}" role="alert">{$message->message|html}<button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">×</span></button></div> {/if} </div> + <div id="nameErrorMessage" class="hidden alert alert-dismissible alert-danger" role="alert">{__('PollInfo\\The name is invalid.')}<button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">×</span></button></div> + -{* Global informations about the current poll *} + {* Global informations about the current poll *} {include 'part/poll_info.tpl' admin=$admin} @@ -45,7 +48,6 @@ <div class="hidden"> <p id="parameter_name_regex">{$parameter_name_regex}</p> - <p id="parameter_name_error">{__('Error','Name is incorrect.')|var_dump}</p> </div> -- GitLab