Created
March 10, 2013 00:48
-
-
Save msurguy/5126557 to your computer and use it in GitHub Desktop.
Using Humane.js in Laravel projects. Sometimes you need to show a nice message to the user after some action is executed. Humane.js (http://wavded.github.com/humane-js/) is designed to show you those nice looking messages with ease.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// inside of a controller call: | |
Session::flash('status_success', 'Succesfully submitted!'); | |
// inside of your view : | |
<script> | |
@if (!is_null(Session::get('status_success'))) | |
@if (is_array(Session::get('status_success'))) | |
@foreach (Session::get('status_success') as $success) | |
displayMessage('{{$success }}', "success"); | |
@endforeach | |
@else | |
displayMessage('{{ Session::get('status_success')}}', "success"); | |
@endif | |
@endif | |
</script> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// using jackedup theme of humane.js (make sure you have humane.js and css for the jackedup theme) | |
humane.baseCls = 'humane-jackedup'; | |
function displayMessage(whatToSay, type) { | |
switch(type) { | |
case "success": | |
humane.info = humane.spawn({ addnCls: 'humane-jackedup-success', timeout: 2000 }); | |
break; | |
case "error": | |
humane.info = humane.spawn({ addnCls: 'humane-jackedup-error', timeout: 2000 }); | |
break; | |
case "info": | |
humane.info = humane.spawn({ addnCls: 'humane-jackedup-info', timeout: 2000 }); | |
break; | |
default: | |
humane.info = humane.spawn({ addnCls: 'humane-jackedup-success', timeout: 2000 }); | |
} | |
humane.info(whatToSay); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment