/*
* FlatElements v0.2 by @andystrobel
* Copyright 2014 HumHub
*
* Modified standard checkboxes and radio buttons
*/
//
// create closure
//
(function ($) {
//
// plugin definition
//
$.fn.flatelements = function (options) {
// build main options before element iteration
var opts = $.extend({}, $.fn.flatelements.defaults, options);
//
// check if an element follow the bootstrap html construction
//
function checkBootstrapStructure($obj) {
//alert($obj.parent().parent().attr('class'));
if ($obj.attr('type') == "checkbox" && $obj.parent().prop("tagName") == "LABEL") {
return true;
} else if ($obj.attr('type') == "radio" && $obj.parent().prop("tagName") == "LABEL") {
return true
} else {
return false;
}
}
// iterate and reformat each matched element
return this.each(function () {
// save object in a variable
$this = $(this);
// Only modify this element, if it follow the bootstrap html construction
if (checkBootstrapStructure($this) == true) {
// modify elements for checkboxes
if ($this.attr('type') == "checkbox") {
// make checkbox to a slider element
if ($this.attr('data-view') == 'slider') {
// check if the standard bootstrap container