293 lines
11 KiB
JavaScript
293 lines
11 KiB
JavaScript
// Easy Responsive Tabs Plugin
|
||
// Author: Samson.Onna <Email : samson3d@gmail.com>
|
||
(function ($) {
|
||
$.fn.extend({
|
||
easyResponsiveTabs: function (options) {
|
||
//Set the default values, use comma to separate the settings, example:
|
||
var defaults = {
|
||
type: 'default', //default, vertical, accordion;
|
||
width: 'auto',
|
||
fit: true
|
||
}
|
||
//Variables
|
||
var options = $.extend(defaults, options);
|
||
var opt = options, jtype = opt.type, jfit = opt.fit, jwidth = opt.width, vtabs = 'vertical', accord = 'accordion';
|
||
|
||
//Main function
|
||
this.each(function () {
|
||
var $respTabs = $(this);
|
||
$respTabs.find('ul.resp-tabs-list li').addClass('resp-tab-item');
|
||
$respTabs.css({
|
||
'display': 'block',
|
||
'width': jwidth
|
||
});
|
||
|
||
$respTabs.find('.resp-tabs-container > div').addClass('resp-tab-content');
|
||
jtab_options();
|
||
//Properties Function
|
||
function jtab_options() {
|
||
if (jtype == vtabs) {
|
||
$respTabs.addClass('resp-vtabs');
|
||
}
|
||
if (jfit == true) {
|
||
$respTabs.css({ width: '100%', margin: '0px' });
|
||
}
|
||
if (jtype == accord) {
|
||
$respTabs.addClass('resp-easy-accordion');
|
||
$respTabs.find('.resp-tabs-list').css('display', 'none');
|
||
}
|
||
}
|
||
|
||
//Assigning the h2 markup
|
||
var $tabItemh2;
|
||
$respTabs.find('.resp-tab-content').before("<h2 class='resp-accordion' role='tab'><span class='resp-arrow'></span></h2>");
|
||
|
||
var itemCount = 0;
|
||
$respTabs.find('.resp-accordion').each(function () {
|
||
$tabItemh2 = $(this);
|
||
var innertext = $respTabs.find('.resp-tab-item:eq(' + itemCount + ')').text();
|
||
$respTabs.find('.resp-accordion:eq(' + itemCount + ')').append(innertext);
|
||
$tabItemh2.attr('aria-controls', 'tab_item-' + (itemCount));
|
||
itemCount++;
|
||
});
|
||
|
||
//Assigning the 'aria-controls' to Tab items
|
||
var count = 0,
|
||
$tabContent;
|
||
$respTabs.find('.resp-tab-item').each(function () {
|
||
$tabItem = $(this);
|
||
$tabItem.attr('aria-controls', 'tab_item-' + (count));
|
||
$tabItem.attr('role', 'tab');
|
||
|
||
//First active tab
|
||
$respTabs.find('.resp-tab-item').first().addClass('resp-tab-active');
|
||
$respTabs.find('.resp-accordion').first().addClass('resp-tab-active');
|
||
$respTabs.find('.resp-tab-content').first().addClass('resp-tab-content-active').attr('style', 'display:block');
|
||
|
||
//Assigning the 'aria-labelledby' attr to tab-content
|
||
var tabcount = 0;
|
||
$respTabs.find('.resp-tab-content').each(function () {
|
||
$tabContent = $(this);
|
||
$tabContent.attr('aria-labelledby', 'tab_item-' + (tabcount));
|
||
tabcount++;
|
||
});
|
||
count++;
|
||
});
|
||
|
||
//Tab Click action function
|
||
$respTabs.find("[role=tab]").each(function () {
|
||
var $currentTab = $(this);
|
||
$currentTab.click(function () {
|
||
|
||
var $tabAria = $currentTab.attr('aria-controls');
|
||
|
||
if ($currentTab.hasClass('resp-accordion') && $currentTab.hasClass('resp-tab-active')) {
|
||
$respTabs.find('.resp-tab-content-active').slideUp('', function () { $(this).addClass('resp-accordion-closed'); });
|
||
$currentTab.removeClass('resp-tab-active');
|
||
return false;
|
||
}
|
||
if (!$currentTab.hasClass('resp-tab-active') && $currentTab.hasClass('resp-accordion')) {
|
||
$respTabs.find('.resp-tab-active').removeClass('resp-tab-active');
|
||
$respTabs.find('.resp-tab-content-active').slideUp().removeClass('resp-tab-content-active resp-accordion-closed');
|
||
$respTabs.find("[aria-controls=" + $tabAria + "]").addClass('resp-tab-active');
|
||
|
||
$respTabs.find('.resp-tab-content[aria-labelledby = ' + $tabAria + ']').slideDown().addClass('resp-tab-content-active');
|
||
} else {
|
||
$respTabs.find('.resp-tab-active').removeClass('resp-tab-active');
|
||
$respTabs.find('.resp-tab-content-active').removeAttr('style').removeClass('resp-tab-content-active').removeClass('resp-accordion-closed');
|
||
$respTabs.find("[aria-controls=" + $tabAria + "]").addClass('resp-tab-active');
|
||
$respTabs.find('.resp-tab-content[aria-labelledby = ' + $tabAria + ']').addClass('resp-tab-content-active').attr('style', 'display:block');
|
||
}
|
||
});
|
||
//Window resize function
|
||
$(window).resize(function () {
|
||
$respTabs.find('.resp-accordion-closed').removeAttr('style');
|
||
});
|
||
});
|
||
|
||
|
||
});
|
||
}
|
||
});
|
||
|
||
|
||
})(jQuery);
|
||
|
||
///JavaScript Document
|
||
var box_view_btn="loginBtn";//初始化按钮值
|
||
$(function () {
|
||
|
||
errorclean();
|
||
// getVerifyCode();
|
||
//监听docuemnt的onkeydown事件看是不是按了回车键
|
||
$(document).keydown(function(event){
|
||
event = event ? event : window.event;
|
||
if (event.keyCode === 13){
|
||
$("#"+box_view_btn).trigger("click");
|
||
}
|
||
});
|
||
//登录
|
||
|
||
|
||
$("#loginBtn").click(function () {
|
||
errorclean();
|
||
// alert($("#accountNameId").val());
|
||
|
||
if($("#accountNameId").val()==''){
|
||
/*$("#accountNameId").tips({side : 3,msg : "用户名不能为空!",bg : '#FF2D2D',time : 2});*/
|
||
$("#usererror").append("登录名不能为空");
|
||
// $("#accountNameId").focus();
|
||
|
||
}else if( $("#passwordId").val()==''){
|
||
$("#passworderror").append("密码不能为空");
|
||
// $("#passwordId").tips({side : 3,msg : "密码不能为空!",bg : '#FF2D2D',time : 2});
|
||
// $("#passwordId").focus();
|
||
|
||
}/*else if("" == $("#verifyCodeId").val()){
|
||
$("#verifyCodeId").tips({side : 3,msg : "验证码不能为空!",bg : '#FF2D2D',time : 2});
|
||
$("#verifyCodeId").focus();
|
||
} */ else{
|
||
// alert("else");
|
||
dialogloading();
|
||
var loginname = $("#accountNameId").val();
|
||
var password = $("#passwordId").val();
|
||
// alert(password);
|
||
var verifyCode=$("#verifyCodeId").val();
|
||
var verifyCode=null;
|
||
var code = loginname+",jy,"+$.md5(password)+",jy,"+verifyCode;
|
||
|
||
// alert(code);
|
||
$.ajax({type:'POST',url:bonuspath +'/system_login',data:{KEYDATA:code,tm:new Date().getTime()},
|
||
dataType:'json',success:function(data, textStatus){
|
||
dialogloadingClose();
|
||
var result=data.result;
|
||
//alert(JSON.stringify(result));
|
||
if ("success" == result){ //如果登录不成功,则再次刷新验证码
|
||
// if($_SESSION['value'] == 13){
|
||
// window.location.href=bonuspath+"/backstage/user/personalCenter";
|
||
// }else{
|
||
// // alert(result);
|
||
// dialogloadingClose();
|
||
// clearLoginForm();//清除信息
|
||
// loginAlert(result);
|
||
// // alert(result);
|
||
// window.location.href=bonuspath+"/backstage/index";
|
||
// }
|
||
window.location.href=bonuspath+"/backstage/user/personalCenter";
|
||
}else{
|
||
clearLoginForm();
|
||
|
||
loginAlert(result);
|
||
|
||
var errInfo=" ";
|
||
data.result=" ";
|
||
}
|
||
}
|
||
});
|
||
}
|
||
});
|
||
|
||
$("#vimg").click(function () {
|
||
getVerifyCode();
|
||
});
|
||
//改写dialog是title可以使用html
|
||
$.widget("ui.dialog", $.extend({}, $.ui.dialog.prototype, {
|
||
_title: function(title) {
|
||
var $title = this.options.title || ' ';
|
||
if(("title_html" in this.options)&&(this.options.title_html == true))title.html($title);
|
||
else title.text($title);
|
||
}
|
||
}));
|
||
});
|
||
function clean(){
|
||
errorclean();
|
||
|
||
}
|
||
|
||
|
||
//自定义错误提示staart
|
||
function errorclean(){
|
||
$("#usererror").empty();
|
||
$("#passworderror").empty();
|
||
}
|
||
//自定义结束end
|
||
|
||
|
||
|
||
function clearLoginForm(){
|
||
$("#verifyCodeId").val("");
|
||
$("#passwordId").val("");
|
||
getVerifyCode();
|
||
}
|
||
//切换窗口
|
||
function show_box(id) {
|
||
var strs= new Array(); //定义一数组
|
||
strs=id.split("-"); //字符分割
|
||
box_view_btn=strs[0]+"Btn";
|
||
jQuery('.widget-box.visible').removeClass('visible');
|
||
jQuery('#'+id).addClass('visible');
|
||
}
|
||
//刷新验证码
|
||
|
||
function getVerifyCode() {
|
||
$("#vimg").attr("src", "verifyCode/slogin.do?random=" + Math.random());
|
||
}
|
||
|
||
function loginAlert(msg) {
|
||
// alert(msg);
|
||
if("codeerror" == msg){
|
||
// alert("11");
|
||
$("#verifyCodeId").tips({side : 3,msg : "验证码不正确!",bg : '#FF2D2D',time : 2});
|
||
$("#`").focus();
|
||
}else if("nullup" == msg){
|
||
$("#accountNameId").tips({side : 3,msg : "用户名或密码不能为空!",bg : '#FF2D2D',time : 2});
|
||
$("#accountNameId").focus();
|
||
}else if("nullcode" == msg){
|
||
$("#verifyCodeId").tips({side : 3,msg : "验证码不能为空!",bg : '#FF2D2D',time : 2});
|
||
$("#verifyCodeId").focus();
|
||
}else if("usererror" == msg){
|
||
$("#accountNameId").tips({side : 3,msg : "用户名或密码有误!",bg : '#FF2D2D',time : 2});
|
||
$("#accountNameId").focus();
|
||
}else if("attemptserror" == msg){
|
||
dialogerror("错误次数过多!");
|
||
}else if("error" == msg){
|
||
dialogerror("输入有误!");
|
||
}else if("inactive" == msg){
|
||
dialogerror("未激活!");
|
||
}
|
||
}
|
||
|
||
function dialogerror(Str){
|
||
$("#jyErrorStr").empty().append(Str);
|
||
$("#jyError").removeClass('hide').dialog({
|
||
resizable: false,
|
||
dialogClass: "title-no-close",
|
||
modal: true,//设置为true,该dialog将会有遮罩层
|
||
title: "<div class='widget-header'><h4 class='font-bold red' >错误</h4></div>",
|
||
title_html: true,
|
||
show:{effect:"shake",duration: 100},
|
||
hide:{effect:"explode"},
|
||
buttons: [{
|
||
html: "<i class='icon-ok bigger-110'></i> 确认","class" : "btn btn-primary btn-xs",
|
||
click: function() {
|
||
$(this).dialog("close");
|
||
}
|
||
}]
|
||
});
|
||
};
|
||
|
||
function dialogloading(){
|
||
$("#jyLoadingStr").empty().append("正在登录 , 请稍后 ...");
|
||
$("#jyLoading").removeClass('hide').dialog({
|
||
dialogClass: "loading-no-close",
|
||
minHeight: 50,
|
||
resizable: false,
|
||
modal: true,
|
||
show:{effect:"fade"},hide:{effect:"fade"}
|
||
});
|
||
};
|
||
|
||
function dialogloadingClose(){
|
||
$("#jyLoading").dialog("close");
|
||
};
|