Ray's changes for css and js

This commit is contained in:
chris committed 2013-07-22 16:31:44 +08:00
1 parent 408bebaa4b
commit fe82427baa
306 files changed
+20659 -607

No files matched your search

+213 -38
View File
@@ -11,8 +11,18 @@ if($.support.touch) {
mouseenterEvent = "mouseenter";
};
// Focus first element
!function ($) {
// Set sidebarState
sidebarState = function (v) {
if(v) {
window.localStorage.setItem('sidebarState', 1);
} else {
window.localStorage.removeItem('sidebarState');
}
};
// Focus first element
$.fn.focusFirstField = function(){
$this = this;
$this.find(":text:visible:enabled").filter(function(){
@@ -20,11 +30,132 @@ if($.support.touch) {
}).slice(0,1).focus();
return this;
}
}(window.jQuery);
// Search Clear
!function ($) {
//Checked Toggle
$.fn.togglebox = function () {
var $checked = this;
$checked.each(function() {
if(!$(this).closest('div').hasClass('togglebox')) {
$(this).wrap('<div class="toggle-control"/>');
$(this).wrap('<div class="togglebox" />');
$('<label><b></b></label>').insertAfter($(this));
if($(this).data().deploy) {
switch($(this).data().deploy) {
case "left":
$(this).closest('.toggle-control').css('float','left');
break;
case "right":
$(this).closest('.toggle-control').css('float','right');
break;
case "inline":
$(this).closest('.toggle-control').css('display','inline-block');
break;
}
}
if($(this).data().title) {
$(this).closest('.toggle-control').append('<p>'+$(this).data().title+'</p>');
}
}
})
$checked.each(function(i) {
if($(this).attr('type') == "checkbox") {
if($(this).data().disabled) {
$(this).parent('.togglebox').addClass('disabled').closest('li').addClass('disabled');
if($(this).prop('checked')) {
$(this).parent('.togglebox').removeClass('disabled').closest('li').removeClass('disabled');
};
} else {
if($(this).prop('checked')) {
$(this).parent('.togglebox').addClass('disabled').closest('li').addClass('disabled');
};
}
$(this).on({
change: function() {
$(this).parent('.togglebox').toggleClass('disabled');
$(this).closest('tr').toggleClass('disable');
}
});
};
if($(this).attr('type') == "radio") {
if(!$(this).prop('checked')) {
$(this).parent('.togglebox').addClass('disabled').closest('li').addClass('disabled');
$(this).closest('tr').addClass('disable');
};
$(this).on({
change: function() {
$checked.not($(".toggle-check[type='checkbox']")).each(function(i) {
if(!$(this).parent('.togglebox').hasClass('disabled')) {
$(this).parent('.togglebox').toggleClass('disabled');
$(this).closest('tr').toggleClass('disable');
};
});
$(this).parent('.togglebox').toggleClass('disabled')
$(this).closest('tr').toggleClass('disable');
}
});
};
if($('#sitemap').length) {
$(this).on({
change: function() {
$(this).closest('li').toggleClass('disabled');
if($(this).prop('checked')) {
$(this).attr('checked', 'checked');
$(this).parents('h6')
.siblings('ul')
.find('li')
.addClass('disabled')
.find('h6 .togglebox')
.addClass('disabled')
.find('input[type="checkbox"]')
.prop('checked', true)
.attr('checked', 'checked');
} else {
$(this).removeAttr('checked');
$(this).parents('h6')
.siblings('ul')
.find('li')
.removeClass('disabled')
.find('h6 .togglebox')
.removeClass('disabled')
.find('input[type="checkbox"]')
.prop('checked', false)
.removeAttr('checked');
};
$('.toggle-check').each(function(i) {
var len = $(this).closest('ul').children('li').length,
checLen = $(this).closest('ul').children('li').find('input[checked]').length,
checLen = checLen - $(this).closest('ul').children('li').find('ul').find('input[checked]').length;
if(len == checLen) {
$(this).closest('ul')
.parent('li')
.addClass('disabled')
.children('h6')
.find('.togglebox')
.addClass('disabled')
.find('input[type="checkbox"]')
.prop('checked', true)
.attr('checked', 'checked');
} else {
$(this).closest('ul')
.parent('li')
.removeClass('disabled')
.children('h6')
.find('.togglebox')
.removeClass('disabled')
.find('input[type="checkbox"]')
.prop('checked', false)
.removeAttr('checked');
};
});
},
});
};
});
};
// Search Clear
$.fn.searchClear = function (param){
_defaultSettings = {
inputName: ':input',
@@ -84,10 +215,9 @@ if($.support.touch) {
}else{run()}
}else{run()}
}
}(window.jQuery);
// Fixed Nav
!function ($) {
// Fixed Nav
fixedNav = function () {
if($('.fixed-nav').length){
var $fixedNav = $('.fixed-nav');
@@ -106,11 +236,9 @@ if($.support.touch) {
});
}
};
}(window.jQuery);
// Sidebar
!function ($) {
// Sidebar
sidebarNav = function () {
var $sidebar = $('#sidebar'),
$sidebarMenu = $('#sidebar-menu'),
@@ -133,7 +261,7 @@ if($.support.touch) {
if($el.hasClass('active')) {
// Menu defaults active
$elIndex = $el.filter('.active').index();
if($sidebarState) {
if($sidebarState && !$sidebarNav.hasClass('no-sub-nav')) {
$block.eq($elIndex).addClass('show');
$blockList.css({'width': 180});
$wrap.css({
@@ -147,7 +275,7 @@ if($.support.touch) {
'top': $position,
});
}
if($.support.touch) {
if($.support.touch && !$sidebarNav.hasClass('no-sub-nav')) {
$el.find('a').removeAttr('href');
};
$el.on(mouseenterEvent, function(e) {
@@ -186,6 +314,16 @@ if($.support.touch) {
});
}
});
if ($sidebarNav.hasClass('no-sub-nav')) {
$sidebar.on('mouseleave', function() {
$arrow.stop(true, false).animate({
'top': $position,
},{
duration: 500,
easing: 'easeInOutBack',
});
})
};
// $el.on('mouseleave', function() {
// $el.hasClass('active') ? $position = $el.eq($elIndex).offset().top-$el.eq($elIndex).height()/2+$arrowHeightFormat-$(document).scrollTop() : 0;
// $(this).hasClass('active') ? '':$(this).children('span').removeClass('hover');
@@ -278,31 +416,31 @@ if($.support.touch) {
.removeClass('scroller');
$sidebarMenu.nanoScroller({ scrollTop: 0 });
} else {
var sidebarMenu = new iScroll('sidebar-menu', {
vScrollbar: true,
scrollbarClass: 'myScrollbar',
onBeforeScrollStart: function (e) {
var target = e.target;
clearTimeout(this.hoverTimeout);
while (target.nodeName != "SPAN") target = target.parentNode;
$target = $(target.parentNode).index();
},
touch: function () {
if (this.hoverTarget) {
if($('#sidebar').length) {
var sidebarMenu = new iScroll('sidebar-menu', {
vScrollbar: true,
scrollbarClass: 'myScrollbar',
onBeforeScrollStart: function (e) {
var target = e.target;
clearTimeout(this.hoverTimeout);
$('.sub-nav-block').removeClass('show')
$('.sub-nav-block').eq($target).addClass('show')
}
},
});
while (target.nodeName != "SPAN") target = target.parentNode;
$target = $(target.parentNode).index();
},
touch: function () {
if (this.hoverTarget) {
clearTimeout(this.hoverTimeout);
$('.sub-nav-block').removeClass('show')
$('.sub-nav-block').eq($target).addClass('show')
}
},
});
}
};
};
}(window.jQuery);
// Initial State
!function ($) {
// Initial State
initialState = function () {
if($('.bottomnav').length) {
var $bottomnavHeight = $('.bottomnav').outerHeight();
@@ -310,9 +448,11 @@ if($.support.touch) {
'padding-bottom': $bottomnavHeight,
})
if($sidebarState) {
$('.bottomnav').css({
'left': 261,
});
if(!$('.sidebar-nav').hasClass('no-sub-nav')) {
$('.bottomnav').css({
'left': 261,
});
}
}
}
// if($('.topnav').length) {
@@ -331,15 +471,15 @@ function openSlide() {
var $openSlide = $('.open-slide'),
$pageslideW;
$(window).width() > 1440 ? $pageslideW = 1024 : $pageslideW = 960;
$(window).width() > 1440 ? $pageslideW = 1024 : $pageslideW = 954;
$(window).resize(function() {
$(this).width() > 1440 ? $pageslideW = 1024 : $pageslideW = 960;
$(this).width() > 1440 ? $pageslideW = 1024 : $pageslideW = 954;
})
$openSlide.each(function() {
if($(this).hasClass('view-page')) {
$(this).pageslide({ W: $pageslideW, iframe: true});
$(this).pageslide({ W: $pageslideW, iframe: true });
} else if($('#items').length) {
$(this).pageslide({ W: 324});
$(this).pageslide({ W: 324 });
} else {
$(this).pageslide();
};
@@ -350,6 +490,34 @@ function openSlide() {
});
}
function formTip() {
if($('.main-forms').length && $('.add-on').length) {
$('.main-forms .add-on, .main-forms .file-link').tooltip({
position: {
my: "center bottom-4",
at: "center top"
}
});
}
if($('.no-sub-nav').length) {
$('.no-sub-nav li').tooltip({
position: {
my: "left+20 center",
at: "right center"
},
track: true,
tooltipClass: "sidebar-tooltip",
});
}
}
function changeStatusHidden() {
$('#status').find('label.checkbox').each(function() {
$(this).find('input[type="hidden"]').clone().appendTo($(this));
$(this).find('input[type="hidden"]').eq(0).remove();
$(this).find('input[type="checkbox"]').after
});
};
// Document Ready
$(function() {
@@ -390,5 +558,12 @@ $(function() {
if($('#card-list').length) {
$('#filter-input').fastLiveFilter('#card-list', '.filter-item', '.user-name');
}
if($('.toggle-check').length) {
$('.toggle-check').togglebox();
}
if($('#status').length) {
changeStatusHidden();
}
formTip()
sidebarNav();
});