| 1 |
'use strict'; |
| 2 |
|
| 3 |
var Boxzilla = require('boxzilla'); |
| 4 |
var options = window.boxzilla_options; |
| 5 |
var isLoggedIn = document.body.className.indexOf('logged-in') > -1; |
| 6 |
|
| 7 |
// print message when test mode is enabled |
| 8 |
if( isLoggedIn && options.testMode ) { |
| 9 |
console.log( 'Boxzilla: Test mode is enabled. Please disable test mode if you\'re done testing.' ); |
| 10 |
} |
| 11 |
|
| 12 |
// init boxzilla |
| 13 |
Boxzilla.init(); |
| 14 |
|
| 15 |
// create boxes from options |
| 16 |
for( var i=0; i < options.boxes.length; i++ ) { |
| 17 |
// get opts |
| 18 |
var boxOpts = options.boxes[i]; |
| 19 |
boxOpts.testMode = isLoggedIn && options.testMode; |
| 20 |
|
| 21 |
// create box |
| 22 |
var box = Boxzilla.create( boxOpts.id, boxOpts); |
| 23 |
|
| 24 |
// add custom css to box |
| 25 |
css(box.element, boxOpts.css); |
| 26 |
} |
| 27 |
|
| 28 |
function css(element, styles) { |
| 29 |
if( styles.background_color ) { |
| 30 |
element.style.background = styles.background_color; |
| 31 |
} |
| 32 |
|
| 33 |
if( styles.color ) { |
| 34 |
element.style.color = styles.color; |
| 35 |
} |
| 36 |
|
| 37 |
if( styles.border_color ) { |
| 38 |
element.style.borderColor = styles.border_color; |
| 39 |
} |
| 40 |
|
| 41 |
if( styles.border_width ) { |
| 42 |
element.style.borderWidth = parseInt(styles.border_width) + "px"; |
| 43 |
} |
| 44 |
|
| 45 |
if( styles.border_style ) { |
| 46 |
element.style.borderStyle = styles.border_style; |
| 47 |
} |
| 48 |
|
| 49 |
if( styles.width ) { |
| 50 |
element.style.maxWidth = parseInt(styles.width) + "px"; |
| 51 |
} |
| 52 |
} |
| 53 |
|
| 54 |
window.Boxzilla = Boxzilla; |