Created
April 8, 2013 18:04
-
-
Save raramuridesign/5339006 to your computer and use it in GitHub Desktop.
Bootstrap with ChronoForms
http://www.chronoengine.com/faqs/view/3677/can-i-use-bootstrap-with-chronoforms.html To use this add this code to a Load JS action in the On Load event of your form.
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
window.addEvent('domready', function(){ | |
var frontforms_css, template_css, bootstrap_css; | |
// remove ChronoForms CSS | |
frontforms_css = $$('link[href$="frontforms.css"]')[0]; | |
frontforms_css.setProperty('href', ''); | |
// move bootstrap.css | |
template_css = $$('link[href$="template.css"]')[0]; | |
bootstrap_css = new Element('link', | |
{ | |
type: 'text/css', | |
href: 'media/jui/css/bootstrap.min.css', | |
rel: 'stylesheet' | |
}); | |
bootstrap_css.inject(template_css, 'after'); | |
// update checkboxes | |
var cbx_labels, cbx_for, cbx_input, cbx_float; | |
cbx_labels = $$('.cfdiv_checkboxgroup label'); | |
cbx_labels.each(function(item) { | |
cbx_for = item.getProperty('for'); | |
if ( cbx_for ) { | |
// this is a label for a checkbox | |
if ( item.getParent().getParent().hasClass('radios_over') ) { | |
item.addClass('checkbox'); | |
} else { | |
item.addClass('checkbox inline'); | |
} | |
cbx_input = $(cbx_for); | |
cbx_input.inject(item, 'bottom'); | |
} | |
}); | |
// update radio buttons | |
var rad_labels, rad_for, rad_input, rad_float; | |
rad_labels = $$('.cfdiv_radio label'); | |
rad_labels.each(function(item) { | |
rad_for = item.getProperty('for'); | |
if ( rad_for ) { | |
// this is a label for a radio | |
item.addClass('radio inline'); | |
rad_input = $(rad_for); | |
rad_input.inject(item, 'bottom'); | |
} | |
}); | |
rad_float = $$('div[style*="float:left"]'); | |
rad_float.each(function(item) { | |
item.setProperty('style', ''); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment