Giter VIP home page Giter VIP logo

avalertifybundle's Introduction

AvAlertifyBundle

Go here to read more about this plugin : (http://appventus.com/blog/les-notifications-ou-comment-ameliorer-la-user-experience-grace-a-noty-et-aux-modals-en-2-minutes)

What is the point ?

This bundle allow you to easily turn your poor lonely sad notifications into modals from

Installation

First, add these in your deps:

[AvAlertifyBundle]
    git=https://github.com/AppVentus/AvAlertifyBundle.git
    target=bundles/AppVentus/Awesome/AvAlertifyBundle

And never forget to declare it in your AppKernel.php:

public function registerBundles() {
    $bundles = array(
        [...]
        new AppVentus\Awesome\AlertifyBundle\AvAwesomeAlertifyBundle(),
        [...]

And in your autoload.php

$loader->registerNamespaces(array(
    [...]
    'AppVentus' => __DIR__ . '/../vendor',
    [..]

Then, just publish your assets, annnnnnd it's done !

How to ?

It's amazingly easy to use, just follow the following:

Add this block at the end of your twig layout:

 {% block alertify %}
    {{ app.session | alertify|raw }}
 {% endblock %}

Now, anywhere in your controllers you can put your alert in the flash session and enjoy.

Options

Noty (For toastr, just replace noty by toastr)

To call a noty alert, just use a flash named 'noty':

$this->get('session')->setFlash('noty',array('type'=>'success', 'layout'=>'bottom' ,'body'=>"<div>OMG, that's amazing !</div>"));

as you see, you can pass some arguments tu customize the noty, availables ones are:

type:
  success
  error
  warning
  information
layout:
  Bottom[Left|Center|Right]
  Top[Left|Center|Right]
  Center[Left|Right]
body:
  some html content you want to see in the noty 

Modal

To call a modal box, just use a flash named 'modal':

$this->get('session')->setFlash("modal", array('title'=>"Wow",'button_class'=>"btn btn-primary btn-large", "body"=> "<div>Some info</div>"));

as you see, you can pass some arguments tu customize the modal, availables ones are:

title:
  just a string
button-class:
  you con specify classes to customize your button  
body:
  html string

Callback type

There is a final type of Alert you can call, the callback Callbach allow you to call any action in you project, thats awesome if you want put dynamic content in your alery. To work, the called action have to render a view. It's very usefull to include a form in a modal for exemple.

$this->get('session')->setFlash('callback', array('type'=>'modal','title' => 'Wow', 'action'=>'AcmeBundle:Default:hello', 'button_class'=>'btn btn-primary btn-large', 'body'=>'<p>Yeah that's crazy !</p>'));  

This type is very simple to use, just call the callback alery, and in the options define "type" with the final alert you want, the action with the action you want call, and other options specific to the alery you choose.

Confirm modal

After a link's clic or form's submission, we sometimes want to prompt the user to be sure he understood what he did. You can make it as a simply way by following the doc here : (https://github.com/AppVentus/AvAlertifyBundle/blob/master/README_Confirm.md)

avalertifybundle's People

Contributors

paulandrieux avatar lenybernard avatar juliensnz avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.