?? jqueryapi.js
字號(hào):
//當(dāng)前顯示的 menuitem。$(' ') 當(dāng)中的空格字符不能少var displayFunctionMenu = $(' ');//定義全局的 jQuery 對(duì)象,用于加速 jQuery 的搜尋速度,因?yàn)?index.html 文件太大var jMenuItem;var jCategoryItem;var jCurrentItem;var jCurrentContent;$(document).ready(function(){ //文檔加載完后,為 jMenuItem 和 jCategoryItem 賦值 jMenuItem = $('body > .mainmenu > .menuitem'); jCategoryItem = jMenuItem.next('.functionmenu').children('.categoryitem'); var englishCheckbox = $('#english'); //menuitem 單擊事件 jMenuItem.click(function(e){ displayFunctionMenu.hide().prev('.menuitem').removeClass('selecteditem'); displayFunctionMenu = $(e.target).addClass('selecteditem').next('.functionmenu').show(); jCurrentItem = displayFunctionMenu.children(".category").children(".selecteditem"); jCurrentContent = jCurrentItem.next('.content'); }); //categoryitem 單擊事件 jCategoryItem.click(function(e){ $(e.target).next('.category').toggle(); }); //將 functionitem 單擊事件的綁定推遲至 categoryitem 被單擊之后,并且設(shè)置 content 圓角。推遲綁定事件是為是優(yōu)化性能 jCategoryItem.one('click',function(e){ //functionitem 單擊事件 $(e.target).next('.category').children('.functionitem').click(function(o){ // 已有顯示項(xiàng)目 if (jCurrentItem) { jCurrentItem.removeClass('selecteditem'); jCurrentContent.hide(); } jCurrentItem = $(o.target); jCurrentContent = jCurrentItem.next('.content'); jCurrentItem.addClass('selecteditem'); var scrollTop = $(window).scrollTop(); jCurrentContent.css("top",scrollTop>77 ? scrollTop-71 : 0).show(); toggleEnglish(jCurrentContent); }).one('click',function(o){ //設(shè)置 content 圓角 $(o.target).next('.content').corner(); }); }); //English checkbox 事件 englishCheckbox.click(function(){ if (jCurrentContent) { toggleEnglish(jCurrentContent); } }); function toggleEnglish(jItem) { var items = jItem; var hr = items.find('hr:first'); if ( hr.length > 0 ) { if ( englishCheckbox.is(':checked') ) { if ( hr.is(':hidden') ) { items = items.find('*'); items.slice(items.index(hr.get(0))).show(); } } else { if ( hr.is(':visible') ) { items = items.find('*'); items.slice(items.index(hr.get(0)),items.index(items.filter('h2:first').get(0))).hide(); } } } } //Fold button 事件 $('#fold').click(function(){ displayFunctionMenu.children('.category').hide(); }); //Expand button 事件 $('#expand').click(function(){ //以觸發(fā) categoryitem 的單擊事件來(lái)代替直接的 show category,以免錯(cuò)過(guò)由 categoryitem 引發(fā)的 functionitem 單擊事件綁定 displayFunctionMenu.children('.category:hidden').prev('.categoryitem').click(); }); //Fold all button 事件 $('#foldall').click(function(){ jCategoryItem.next('.category').hide(); }); //Expand all button 事件;首次單擊的時(shí)候,會(huì)觸發(fā) categoryitem 的單擊事件來(lái)代替直接的 show category,可以使 functionitem 單擊事件能順利綁定 $('#expandall').one('click',function(e){ jCategoryItem.click().next('.category').show(); //Expand all button 單擊事件 $('#expandall').click(function(){ jCategoryItem.next('.category').show(); }); });});
?? 快捷鍵說(shuō)明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -