/* * @title やってみたかっただけ * @description はてブロ管理画面メニュー折り畳み cookie 使用しない版 * @include http://blog.hatena.ne.jp/* * @license MIT License * @require */ (function ($) { var menu = $("#admin-menu"); if(!menu) return; /* Selectors */ var menu_sel1 = $('#admin-menu'); var menu_sel2 = $('#admin-main-wrapper-outer'); var menu_sel3 = $('#admin-menu div'); var attributes = { 'id': 'tgl_showhide' ,'class': 'isOpen' }; /* Styles config */ var styles = { 'text-align': 'left' ,'cursor': 'pointer' ,'width' : '160px' }; var admin_menu_open_styles = { 'position': 'absolute' ,'left': '0px' ,'width':'160px' ,'margin-left': '0px' }; var admin_menu_wrapper_outer_open = { 'left' : '0px' ,'position' : 'absolute' }; var admin_menu_close_styles = { 'margin-left': '120px' }; var admin_menu_wrapper_outer_close = { 'left' : '-120px' , 'position' : 'relative' , 'overflow-x' : 'hidden' }; var closeBtn = " ▶"; var openBtn = " ◀"; var menuText = " メニューを閉じる"; $('
').attr(attributes).css(styles).text(openBtn + menuText).on("click", function () { if($(this).hasClass("isOpen")){ $($(this)).removeClass("isOpen"); $($(this)).text(closeBtn + menuText); hideMenu(); } else { $($(this)).text(openBtn + menuText); showMenu(); $($(this)).attr("class","isOpen"); } }).appendTo(menu); function showMenu(){ $(menu_sel1).css(admin_menu_open_styles); $(menu_sel2).css(admin_menu_wrapper_outer_open); $(menu_sel3).show(200); } function hideMenu(){ $(menu).css("width", "39px"); $(menu_sel1).css(admin_menu_close_styles); $(menu_sel2).css(admin_menu_wrapper_outer_close); $(menu_sel3).hide(400); } })(jQuery);