Permalink
Browse files

added modal login box

  • Loading branch information...
inmarelibero committed Nov 19, 2012
1 parent 26b6fb3 commit 0b0f4964b7e0d7d2377e48f37e35f2d15cdf7093
@@ -242,3 +242,15 @@ for example: Bricks\SiteBundle\resources\views\macros\macrosInfo.html.twig
}
}
+/* login modal */
+#modal-login {
+ form {
+ padding: 0px;
+ input[type="text"], input[type="password"] {
+ width: 300px;
+ }
+ }
+ .modal-body {
+ padding-left: 180px;
+ }
+}
@@ -96,10 +96,8 @@
<i class="icon-user"></i> <a href="{{ path('userprofile_show', {'username': brick.user.username}) }}">{{ brick.user }}</a>
|
<i class="icon-calendar"></i> {{ 'brick.last_update'|trans }}: {{ brick.updatedAt|date('d/m/Y') }}
- {% if is_granted('IS_AUTHENTICATED_FULLY') %}
- |
- {{ macrosBrick.toggleUserStarsBrick(brick) }}
- {% endif %}
+ |
+ {{ macrosBrick.toggleUserStarsBrick(brick) }}
</p>
</li>
{% endfor %}
@@ -188,6 +188,8 @@
</div>
</div>
</footer>
+
+ {% render 'BricksUserBundle:Security:_modalLogin' %}
{% javascripts '@javascripts' %}
<script type="text/javascript" src="{{ asset_url }}"></script>
@@ -10,26 +10,34 @@
{% set elementId = "toggle-user-stars-brick-"~brick.id %}
- {% set userIsStarringBrick = app.user.isStarringBrick(brick) %}
-
- <a href="javascript:void(0)"
- id="{{ elementId }}"
- class="toggle-user-stars-brick {{ (userIsStarringBrick) ? 'active':'' }}"
-
- data-brick-id="{{ brick.id }}"
+ {% if is_granted('IS_AUTHENTICATED_FULLY') %}
+ {% set userIsStarringBrick = app.user.isStarringBrick(brick) %}
- data-state="{{ (userIsStarringBrick) ? 'starring':'notstarring' }}"
- data-starring-text="{{ 'brick.starring_text'|trans }}"
- data-notstarring-text="{{ 'brick.not_starring_text'|trans }}"
- >
- <i class="icon-star"></i>
- <span id="text">
- {% if userIsStarringBrick %}
- {{ 'brick.starring_text'|trans }}
- {% else %}
- {{ 'brick.not_starring_text'|trans }}
- {% endif %}
- </span>
- </a>
+ <a href="javascript:void(0)"
+ id="{{ elementId }}"
+ class="toggle-user-stars-brick {{ (userIsStarringBrick) ? 'active':'' }}"
+
+ data-brick-id="{{ brick.id }}"
+
+ data-state="{{ (userIsStarringBrick) ? 'starring':'notstarring' }}"
+ data-starring-text="{{ 'brick.starring_text'|trans }}"
+ data-notstarring-text="{{ 'brick.not_starring_text'|trans }}"
+ >
+ <i class="icon-star"></i>
+ <span id="text">
+ {% if userIsStarringBrick %}
+ {{ 'brick.starring_text'|trans }}
+ {% else %}
+ {{ 'brick.not_starring_text'|trans }}
+ {% endif %}
+ </span>
+ </a>
+ {% else %}
+
+ <a href="#modal-login" class="toggle-user-stars-brick" data-toggle="modal">
+ <i class="icon-star"></i> {{ 'brick.not_starring_text'|trans }}
+ </a>
+
+ {% endif %}
{% endmacro %}
@@ -0,0 +1,20 @@
+<?php
+
+namespace Bricks\UserBundle\Controller;
+
+use FOS\UserBundle\Controller\SecurityController as BaseController;
+
+class SecurityController extends BaseController
+{
+ /**
+ * print the code for the modal login box
+ */
+ public function _modalLoginAction()
+ {
+ $csrfToken = $this->container->get('form.csrf_provider')->generateCsrfToken('authenticate');
+
+ return $this->container->get('templating')->renderResponse('BricksUserBundle:Security:_modalLogin.html.twig', array(
+ 'csrf_token' => $csrfToken
+ ));
+ }
+}
@@ -21,6 +21,7 @@ change_password:
# Registration
registration:
+ action: Register
title: Register on SymfonyBricks
submit: Confirm subscription
email:
@@ -21,6 +21,7 @@ change_password:
# Registration
registration:
+ action: Regístrate
title: Inscripción a SymfonyBricks
submit: Confirmar inscripción
email:
@@ -21,6 +21,7 @@ change_password:
# Registration
registration:
+ action: Registrati
title: Registrati su SymfonyBricks
submit: Conferma iscrizione
email:
@@ -0,0 +1,43 @@
+<div id="modal-login" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="modal-login-label" aria-hidden="true">
+ <form action="{{ path("fos_user_security_check") }}" method="post" class="security-form">
+
+ <div class="modal-header">
+ <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
+ <h3 id="modal-login-label">
+ {{ 'main_navbar.sign_in'|trans|capitalize }}
+ </h3>
+ </div>
+ <div class="modal-body">
+
+
+ <input type="hidden" name="_csrf_token" value="{{ csrf_token }}" />
+
+ <label for="username">{{ 'security.login.username'|trans({}, 'FOSUserBundle') }}</label>
+ <input type="text" id="username" name="_username" required="required" />
+
+ <label for="password">{{ 'security.login.password'|trans({}, 'FOSUserBundle') }}</label>
+ <input type="password" id="password" name="_password" required="required" />
+
+ <br>
+ <input type="checkbox" id="remember_me" name="_remember_me" value="on" />
+ <label for="remember_me">{{ 'security.login.remember_me'|trans({}, 'FOSUserBundle') }}</label>
+ <br><br>
+
+ <input type="hidden" name="_target_path" value="{{ app.request.uri }}" />
+
+ <a href="{{ path('fos_user_resetting_request') }}">{{ 'security.forgot_password'|trans({}, 'FOSUserBundle') }}</a>
+
+ </div>
+ <div class="modal-footer">
+ <button type="submit" id="_submit" name="_submit" class="btn btn-primary" >
+ {{ 'security.login.submit'|trans({}, 'FOSUserBundle') }}
+ </button>
+
+ |
+ <a href="{{ path('fos_user_registration_register') }}" id="btn-signup">
+ {{ 'registration.action'|trans({}, 'FOSUserBundle') }}
+ </a>
+ </div>
+
+ </form>
+</div>
@@ -28,7 +28,7 @@
<input type="checkbox" id="remember_me" name="_remember_me" value="on" />
<label for="remember_me">{{ 'security.login.remember_me'|trans({}, 'FOSUserBundle') }}</label>
-
+
<input type="submit" id="_submit" name="_submit" value="{{ 'security.login.submit'|trans({}, 'FOSUserBundle') }}" class="btn btn-primary" />
</form>

0 comments on commit 0b0f496

Please sign in to comment.