Created
September 24, 2012 14:31
-
-
Save og-shawn-crigger/3776230 to your computer and use it in GitHub Desktop.
Some JS i use a lot for bonfire sites
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
// ------------------------------------------------------------------------ | |
// SET NAMESPACE TO AVOID CONFLICTS AND HOLD CONFIG VALUES | |
// ------------------------------------------------------------------------ | |
var bonfire = bonfire || {}; | |
bonfire = { | |
config: { | |
site_url: '<?php echo $site_url ?>', | |
base_url: '<?php echo $base_url ?>', | |
csrf: { | |
<?php if (config_item('csrf_protection') === TRUE) : ?> | |
token : "<?php echo config_item('csrf_token_name'); ?>", | |
coookie : "<?php echo config_item('csrf_cookie_name'); ?>", | |
expire : <?php echo config_item('csrf_expire'); ?>, | |
csrf : null, | |
<?php endif; ?> | |
enabled : <?php echo (config_item('csrf_protection') === FALSE) ? 'false' : 'true'; ?> | |
}, | |
debug: true | |
}, | |
// Setup some global language vars | |
language: { | |
"delete-all" : "<?php echo lang('ig_delete_all'); ?>" | |
}, | |
/** | |
* Creates Alert Message inside of Element using message.status for type and message.message for text. | |
* | |
* @param {object} element DOM Element to insert the alert message into. (IE #alert-here or .alert-here) | |
* @param {object} message JSON response with a status and message. | |
* | |
* @author Shawn Crigger <blog.shawnc.org> | |
* | |
* @return {void} | |
*/ | |
bonfire.notify = function(element, message) { | |
if ($(element).length === 0 || typeof message !== 'object' || typeof message.status !== 'string' || typeof message.message !== 'string') | |
{ | |
return false; | |
} | |
//Remove any old elements will class 'remove' | |
$('.remove').remove(); | |
var icon = ''; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment