This repository has been archived on 2024-03-16. You can view files and clone it, but cannot push or open issues or pull requests.
orbit-4-1/app/assets/javascripts/lib/checkbox.card.js

65 lines
1.6 KiB
JavaScript

// function cardCheck() {
// if($('.tags').length) {
// var $card = $('.checkbox-card .card'),
// $check = $card.children($('input[type="checkbox"]'));
// $check.each(function(){
// if($(this).attr('checked')) {
// $(this).parent(".check").addClass("active");
// }
// })
// } else {
// var $card = $('.checkbox-card>li'),
// $check = $('input[type="checkbox"]');
// $check.each(function(){
// if($(this).attr('checked')) {
// $(this).parent("li").addClass("active");
// }
// })
// }
// $card.on('click', function() {
// $(this).toggleClass('active')
// });
// }
// $(function(){
// cardCheck();
// });
!function ($) {
$.fn.cardCheck = function(param) {
_defaultSettings = {
item: '',
};
_set = $.extend(_defaultSettings, param);
$main = $(this);
$check = $main.find('input[type="checkbox"]');
$check.each(function(){
if($(this).prop('checked')) {
$(this).parent(_set.item).addClass("active");
}
});
$main.delegate(_set.item, 'click', function(e) {
$(this).toggleClass('active')
});
}
}(window.jQuery);
optionHeight = function() {
var $H = $(window).height()-parseInt($('.wrap-inner').css('padding-top'))-$('.bottomnav').innerHeight()-$('#orbit-bar').innerHeight()-2;
$('.mini-layout-sidebar .nano').height($H);
}
$(function(){
if($('.mini-layout-sidebar .nano').length) {
optionHeight();
$(window).resize(function() {
optionHeight();
});
$('.mini-layout-sidebar .nano').nanoScroller({ scrollTop: 0, iOSNativeScrolling: true });
}
if($('.tags').length) {
$('.tags-groups').cardCheck({
item: '.card',
});
} else {
$('#card-list').cardCheck({
item: '.filter-item',
});
};
});