$(function(){ // 一次性初始化所有弹出框 $('[data-toggle="popover"]').popover(); // 图片lazyload $('img.lazy').lazyload({ effect : 'fadeIn', data_attribute : 'src', placeholder : $('#corethink_home_img').val()+'/default/default.gif' }); // 刷新验证码 $(document).on('click', '.reload-verify', function() { var verifyimg = $(this).attr("src"); if (verifyimg.indexOf('?') > 0) { $(this).attr("src", verifyimg + '&random=' + Math.random()); } else { $(this).attr("src", verifyimg.replace(/\?.*$/, '') + '?' + Math.random()); } }); //全选/反选/单选的实现 $(document).on('click', '.check-all', function() { $(".ids").prop("checked", this.checked); }); $(document).on('click', '.ids', function() { var option = $(".ids"); option.each(function() { if (!this.checked) { $(".check-all").prop("checked", false); return false; } else { $(".check-all").prop("checked", true); } }); }); //搜索功能 $(document).on('click', '.search-btn', function() { var url = $(this).closest('form').attr('action'); var query = $(this).closest('form').serialize(); query = query.replace(/(&|^)(\w*?\d*?\-*?_*?)*?=?((?=&)|(?=$))/g, ''); query = query.replace(/(^&)|(\+)/g, ''); if (url.indexOf('?') > 0) { url += '&' + query; } else { url += '?' + query; } window.location.href = url; return false; }); //回车搜索 $(document).on('keydown', '.search-input', function(e) { if (e.keyCode === 13) { $(this).closest('form').find('.search-btn').click(); return false; } }); // 设置ct-tab的宽度 $('.ct-tab').width($(window).width()-373); // 打开新Tab $(document).on('click', '#sidebar .open-tab', function() { var tab_url = $(this).attr('href'); var tab_name = $(this).attr('tab-name'); var is_open = $('.ct-tab-content #' + tab_name).length; if(is_open !== 0){ $('.ct-tab a[href=#' + tab_name + ']').tab('show'); } else { var tab = '