From d9d23c3c9474070d8ea9c01bb03c9205b4896f96 Mon Sep 17 00:00:00 2001 From: David DeSandro Date: Thu, 30 Dec 2010 08:45:08 -0500 Subject: [PATCH] docs : add sorting doc --- _includes/layout-change.js | 43 +++++++------ _includes/option-buttons.js | 26 ++++---- _includes/sort-buttons.html | 24 +++++++ _includes/sort-buttons.js | 16 +++++ _layouts/elements.html | 44 +------------ _posts/demos/2010-12-29-layout-modes.html | 4 +- _posts/demos/2010-12-30-sorting.html | 78 +++++++++++++++++++++++ 7 files changed, 157 insertions(+), 78 deletions(-) create mode 100644 _includes/sort-buttons.html create mode 100644 _includes/sort-buttons.js create mode 100644 _posts/demos/2010-12-30-sorting.html diff --git a/_includes/layout-change.js b/_includes/layout-change.js index 6a17718..ffb765c 100644 --- a/_includes/layout-change.js +++ b/_includes/layout-change.js @@ -1,24 +1,25 @@ -// change layout -var isHorizontal = false; -$('#layouts a').click(function(){ - var mode = $(this).attr('href').slice(1); - wasHorizontal = isHorizontal; - isHorizontal = $(this).hasClass('horizontal'); + + // change layout + var isHorizontal = false; + $('#layouts a').click(function(){ + var mode = $(this).attr('href').slice(1); + wasHorizontal = isHorizontal; + isHorizontal = $(this).hasClass('horizontal'); - if ( wasHorizontal !== isHorizontal ) { - // need to do some clean up for transitions and sizes - var style = isHorizontal ? - { height: '80%', width: $demo.width() } : - { width: 'auto' }; - $demo.addClass('no-transition').css( style ); - setTimeout(function(){ - $demo.removeClass('no-transition').isotope({ layoutMode : mode }); - }, 100 ) - } else { - // go ahead and apply new layout - $demo.isotope({ layoutMode : mode }); + if ( wasHorizontal !== isHorizontal ) { + // need to do some clean up for transitions and sizes + var style = isHorizontal ? + { height: '80%', width: $demo.width() } : + { width: 'auto' }; + $demo.addClass('no-transition').css( style ); + setTimeout(function(){ + $demo.removeClass('no-transition').isotope({ layoutMode : mode }); + }, 100 ) + } else { + // go ahead and apply new layout + $demo.isotope({ layoutMode : mode }); - } + } - return false; -}); \ No newline at end of file + return false; + }); \ No newline at end of file diff --git a/_includes/option-buttons.js b/_includes/option-buttons.js index ea411d9..d710e07 100644 --- a/_includes/option-buttons.js +++ b/_includes/option-buttons.js @@ -1,12 +1,14 @@ -$('#options').find('.option-set a').click(function(){ - var $this = $(this); - - // don't proceed if already selected - if ( $this.hasClass('selected') ) { - return; - } - - $this.parents('.option-set').find('.selected').removeClass('selected'); - $this.addClass('selected'); - -}); + + // switches selected class on buttons + $('#options').find('.option-set a').click(function(){ + var $this = $(this); + + // don't proceed if already selected + if ( $this.hasClass('selected') ) { + return; + } + + $this.parents('.option-set').find('.selected').removeClass('selected'); + $this.addClass('selected'); + + }); diff --git a/_includes/sort-buttons.html b/_includes/sort-buttons.html new file mode 100644 index 0000000..a7f06e2 --- /dev/null +++ b/_includes/sort-buttons.html @@ -0,0 +1,24 @@ +

Sort

+ + \ No newline at end of file diff --git a/_includes/sort-buttons.js b/_includes/sort-buttons.js new file mode 100644 index 0000000..ceafb6b --- /dev/null +++ b/_includes/sort-buttons.js @@ -0,0 +1,16 @@ + + // sorting + $('#sort a').click(function(){ + // get href attribute, minus the # + var $this = $(this), + sortName = $this.attr('href').slice(1), + asc = $this.parents('.sort').hasClass('asc'); + // var sortTest = 'sort ' + sortName + ' ' + direction; + // console.time( sortTest ); + $demo.isotope({ + sortBy : sortName, + sortAscending : asc + }); + // console.timeEnd( sortTest ); + return false; + }); \ No newline at end of file diff --git a/_layouts/elements.html b/_layouts/elements.html index 22fd264..6b85961 100644 --- a/_layouts/elements.html +++ b/_layouts/elements.html @@ -31,34 +31,7 @@
  • noble-gas
  • - -

    Sort

    - - - - - + {% include sort-buttons.html %} {% include layout-options.html %} @@ -158,20 +131,7 @@ return false; }); - $('#sort a').click(function(){ - // get href attribute, minus the # - var $this = $(this), - sortName = $this.attr('href').slice(1), - asc = $this.parents('.sort').hasClass('asc'); - // var sortTest = 'sort ' + sortName + ' ' + direction; - // console.time( sortTest ); - $demo.isotope({ - sortBy : sortName, - sortAscending : asc - }); - // console.timeEnd( sortTest ); - return false; - }); + {% include sort-buttons.js %} // change size of clicked element $demo.find('.element').live('click', function(){ diff --git a/_posts/demos/2010-12-29-layout-modes.html b/_posts/demos/2010-12-29-layout-modes.html index 5319683..4305a7c 100644 --- a/_posts/demos/2010-12-29-layout-modes.html +++ b/_posts/demos/2010-12-29-layout-modes.html @@ -40,12 +40,10 @@ category: demos - + + + + + + + + + \ No newline at end of file