Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $(function() {
- // setInitial
- var body = $('body'),
- header = body.find('.header'),
- aside = body.find('.sidebar'),
- content = body.find('.content'),
- entry = content.find('.entry'),
- footer = body.find('.footer'),
- account = body.find('.site > .account');
- /* add links */
- $('.addlinks').click(function() {
- window.open('/toolbar/popup/link', 'links add', 'width=400, height=185, scrollbars=no, status=no;');
- return false;
- });
- /* asideButton */
- var asideSecondary = aside.find('.secondary'),
- asideButton = header.find($('.aside-button')),
- asideCloseButton = aside.find($('.aside-close-button'));
- asideButton.click(function() {
- if (!body.hasClass('aside-open') && ((asideSecondary.attr('aria-hidden') === 'true' || asideSecondary.attr('aria-hidden') === undefined))) {
- // toggle
- body.addClass('aside-open');
- // visible
- setTimeout(function() {
- aside.addClass('open');
- }, 10);
- // attr change
- setTimeout(function() {
- asideSecondary.attr('aria-hidden', 'false');
- }, 218);
- }
- });
- /* asideCloseButton */
- asideCloseButton.click(function() {
- if (body.hasClass('aside-open') && asideSecondary.attr('aria-hidden') === 'false') {
- // visible
- aside.removeClass('open')
- // toggle, attr change
- setTimeout(function() {
- body.removeClass('aside-open');
- asideSecondary.attr('aria-hidden', 'true');
- }, 218);
- }
- });
- /* search_none */
- var currentUrl = window.location.pathname,
- url = currentUrl.split('/');
- var pageType,
- listItem = entry.find('> .article'),
- tagContent = entry.find('> .entry-article.tag');
- if ($.isNumeric(url[1])) {
- url[1] = 'article';
- }
- switch (url[1]) {
- case 'tag':
- // check: tagContent.length < 1
- if (tagContent.length < 1) {
- pageType = 'list';
- }
- break;
- case 'category':
- pageType = 'list';
- break;
- case 'search':
- pageType = 'list';
- break;
- case 'archive':
- pageType = 'list';
- break;
- default:
- }
- if (pageType === 'list') {
- // check: listItem < 1
- if (listItem.length < 1) {
- body.addClass('empty');
- }
- }
- /* #################################################### */
- /* ################## DEVOLOPERS! #################### */
- /* #################################################### */
- /* checkAccountDropdown() */
- function checkAccountDropdown() {
- if (!body.hasClass('account-open') && !account.hasClass('.open')) {
- // toggle
- body.addClass('account-open');
- // visible
- setTimeout(function() {
- account.addClass('open');
- }, 10);
- // attr change
- setTimeout(function() {
- account.attr('aria-hidden', 'false');
- }, 218);
- } else {
- // visible
- account.removeClass('open');
- // toggle, attr change
- setTimeout(function() {
- body.removeClass('account-open');
- account.attr('aria-hidden', 'true');
- }, 218);
- }
- }
- /* dropdownClose(el) */
- function dropdownClose(el) {
- // visible
- setTimeout(function() {
- checkDropdownOpen = 'close';
- $(el).removeClass('open');
- }, 10);
- // attr change
- setTimeout(function() {
- $(el).attr('aria-hidden', 'true');
- }, 218);
- }
- /* dropdownOpen(el) */
- function dropdownOpen(el) {
- // visible
- setTimeout(function() {
- checkDropdownOpen = 'open';
- $(el).addClass('open');
- }, 10);
- // attr change
- setTimeout(function() {
- $(el).attr('aria-hidden', 'false');
- }, 218);
- }
- /* dropdown */
- var dropdown = $('.dropdown'),
- dropdownToggle = dropdown.find('.toggle'),
- dropdownMenu = dropdown.find('.menu'),
- checkDropdownOpen = 'close';
- dropdownToggle.click(function() {
- dropdownClose(dropdownMenu);
- $(this).each(function() {
- // setInitial
- var thisDropdown = $(this).parent('.dropdown'),
- thisDropdownToggle = $(this),
- thisDropdownMenu = $(this).next('.menu');
- // checkAccountDropdown
- if (thisDropdown.hasClass('account-dropdown')) {
- checkAccountDropdown();
- }
- // checkDropdownMenu = open
- if (!thisDropdownMenu.hasClass('open') && (thisDropdownMenu.attr('aria-hidden') === 'true' || thisDropdownMenu.attr('aria-hidden') === undefined)) {
- dropdownOpen(thisDropdownMenu);
- } else if (thisDropdownMenu.hasClass('open') && thisDropdownMenu.attr('aria-hidden') === 'false') {
- dropdownClose(thisDropdownMenu);
- }
- })
- });
- /* login link */
- var accountToolbar = header.find('.account'),
- tistoryToolbar = $('#tistorytoolbarid');
- if (tistoryToolbar.length > 0) {
- var toolbarLogin = tistoryToolbar.find('.tt_menubar_logout > a'),
- toolbarLoginText = toolbarLogin.text(),
- toolbarLoginHref = toolbarLogin.attr('href');
- accountToolbar.find('.account-dropdown .menu > nav ul').append('<li><a class="primary" href="' + toolbarLoginHref + '">' + toolbarLoginText + '</a>');
- }
- /* document click */
- $(document).click(function(e) {
- if (!body.hasClass('account-open') && !account.hasClass('.open')) {
- // closest dropdown
- if (!$(e.target).closest(dropdown).length) {
- dropdownClose(dropdownMenu);
- }
- } else {
- // closest dropdown, account
- if (!$(e.target).closest(dropdown).length && !$(e.target).closest(account).length) {
- dropdownClose(dropdownMenu);
- }
- }
- });
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement