Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $(function() {
- $('#category-1-button a').bind('click', function() {
- $(this).css({opacity:'1'});
- $('#category-2-button a,#category-3-button a').css({opacity:'0.4'});
- $('#blog-headers').css({backgroundPosition: '0 0'});
- $('#category_2,#category_3').hide(0, function() {
- $('#category_1').show(0);
- });
- });
- });
- $(function() {
- $('#category-2-button a').bind('click', function() {
- $(this).css({opacity:'1'});
- $('#category-1-button a,#category-3-button a').css({opacity:'0.4'});
- $('#blog-headers').css({backgroundPosition: '0 -144px'});
- $('#category_1,#category_3').hide(0, function() {
- $('#category_2').show(0);
- });
- });
- });
- $(function() {
- $('#category-3-button a').bind('click', function() {
- $(this).css({opacity:'1'});
- $('#category-1-button a,#category-2-button a').css({opacity:'0.4'});
- $('#blog-headers').css({backgroundPosition: '0 -288px'});
- $('#category_1,#category_2').hide(0, function() {
- $('#category_3').show(0);
- });
- });
- });
- $(function() {
- $('#category-1-button a, #category-2-button a, #category-3-button a').click(function () {
- $('#category-1-button a,#category-2-button a,#category-3-button a').not(this).css({opacity:'0.4'});
- $(this).css({opacity:'1'});
- var myParent = $(this).parent();
- if (myParent == $('#category-1-button')) {
- $('#blog-headers').css({backgroundPosition: '0 0'});
- $('#category_3,#category_2').hide(0, function() {
- $('#category_1').show(0);
- });
- } else if (myParent == $('#category-2-button')) {
- $('#blog-headers').css({backgroundPosition: '0 -144px'});
- $('#category_1,#category_3').hide(0, function() {
- $('#category_2').show(0);
- });
- } else if (myParent == $('#category-3-button')) {
- $('#blog-headers').css({backgroundPosition: '0 -288px'});
- $('#category_1,#category_2').hide(0, function() {
- $('#category_3').show(0);
- });
- }
- });
- }
- $(function() {
- var categories = $('[id^="category_"]');
- var category_buttons_a = $('.category_button a').each(function( idx ) {
- $(this).bind('click', function() {
- $(this).css({opacity:'1'});
- category_buttons_a.not(this).css({opacity:'0.4'});
- $('#blog-headers').css({backgroundPosition: '0 ' + (idx * -144) + 'px'});
- categories.hide().filter( '#category_' + (idx + 1) ).show();
- });
- });
- });
- (function($){
- "use strict";
- var $categoryButtonLinks;
- $categoryButtonLinks = $('#category-1-button a, #category-2-button a, #category-3-button a').click(clickCategoryButtonLink);
- $categories = $('#category_1, #category_2, #category_3');
- function clickCategoryButtonLink(e)
- {
- var $this, $category, index, offset;
- $this = $(this).css('opacity', '1');
- index = $categoryButtonLinks.index($this);
- offset = -144 * index;
- index += 1;
- $category = $('#category_'+index);
- $categoryButtonLinks.not($this).css('opacity', '0.4');
- $('#blog-headers').css('background-position', '0 ' + offset + 'px' );
- $categories.not($category).hide(0, function(){
- $category.show(0);
- });
- }
- })(jQuery);
- <div id="class="category-1-button" class="category_button">
- <a href="#Category_1">Category 1</a>
- </div>
- .category_button a {
- opacity: 0.4;
- }
- .category {
- display: none;
- }
- /* The following rules/selectors could/should be generated by a script */
- .category_1_selected #category-1-button a,
- .category_2_selected #category-2-button a,
- .category_3_selected #category-3-button a {
- opacity: 1;
- }
- .category_1_selected #category_1,
- .category_2_selected #category_2,
- .category_3_selected #category_3 {
- display: block;
- }
- .category_1_selected #blog-headers {
- background-position: 0 0;
- }
- .category_2_selected #blog-headers {
- background-position: 0 -144px;
- }
- .category_3_selected #blog-headers {
- background-position: 0 -288px;
- }
- $(function() {
- var category_buttons_a = $('.category_button a').click(function() {
- // I'm putting the class on the body as an example, but any other element the
- // surrounds the buttons, categorys and the blog header is fine.
- $("body").removeClass().addClass(this.href.slice(1) + "_selected");
- });
- });
- <div>
- <a href="#Category_1" id="class="category-1-button" class="category_button">Category 1</a>
- </div>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement