Changing message creation logic.

This commit is contained in:
Antonin 2015-03-26 17:09:52 +01:00
parent e4ec0c8105
commit b3d79da0a6
3 changed files with 8 additions and 7 deletions

View File

@ -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'>&times;</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);

View File

@ -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');

View File

@ -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">&times;</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">&times;</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>