-
-
Save tmitz/4173232 to your computer and use it in GitHub Desktop.
Revisions
-
mitz revised this gist
Nov 30, 2012 . 1 changed file with 3 additions and 3 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -3,7 +3,7 @@ $(function() { var contents = '.list li'; // 対象のlist var trigger = '.trigger'; // スイッチ // listがn個以上ある場合 if ($(contents).length > n) { // server sideでやって欲しい // span は追加してもた @@ -36,8 +36,8 @@ $(function() { $(contents).slice(n).fadeToggle('fast'); }); // listがn個以下の場合はスイッチを隠す } else { $(trigger).hide(); } }); -
tmitz revised this gist
Nov 30, 2012 . 1 changed file with 35 additions and 32 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,40 +1,43 @@ $(function() { var n = 10; // 初期状態で表出したいlistの個数 var contents = '.list li'; // 対象のlist var trigger = '.trigger'; // スイッチ // listがn個以上ある場合は if ($(contents).length > n) { // server sideでやって欲しい // span は追加してもた if ($(contents).eq(n).is(":hidden")) { $(trigger).html([ '<a href="#">', '<i class="icon-sort-up" style="display:none"></i>', '<span class="icon-sort-close" style="display:none">閉じる</span>', '<i class="icon-sort-down"></i>', '<span class="icon-sort-more">もっと見る</span>', '</a>' ].join('')); } else { $(trigger).html([ '<a href="#">', '<i class="icon-sort-up"></i>', '<span class="icon-sort-close">閉じる</span>', '<i class="icon-sort-down" style="display:none"></i>', '<span class="icon-sort-more" style="display:none">もっと見る</span>', '</a>' ].join('')); } // sliceでn番目以降を隠す $(contents).slice(n).hide(); // toggle ベースに $(trigger).on('click', function() { $(".icon-sort-up, .icon-sort-down").toggle(); $(".icon-sort-more, .icon-sort-close").toggle(); $(contents).slice(n).fadeToggle('fast'); }); //listがn個以下の場合はスイッチを隠す } else { $(trigger).hide(); } }); -
taea revised this gist
Nov 29, 2012 . No changes.There are no files selected for viewing
-
taea revised this gist
Nov 29, 2012 . 1 changed file with 37 additions and 38 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,41 +1,40 @@ $(function(){ var contents = '.list li'; //対象のlist var trigger = '.trigger'; //スイッチ var contentsLength = $(contents).length; //listの個数 var n = 10; //初期状態で表出したいlistの個数 //listがn個以上ある場合は if(contentsLength > n){ //n番目以降を隠す for(var i=n; i<contentsLength; i++){ $(contents+ ':eq(' +i+ ')').hide(); } $(trigger).click(function(){ if($(contents + ':eq(' +n+ ')').is(":hidden")){ for(var i=n; i<contentsLength; i++){ $(contents+ ':eq(' +i+ ')').fadeIn("fast"); } $(trigger).html([ '<a href="#">', '<i class="icon-sort-up"></i>', '閉じる', '</a>' ].join('')); }else{ for(var i=n; i<contentsLength; i++){ $(contents + ':eq(' +i+ ')').fadeOut("fast"); } $(trigger).html([ '<a href="#">', '<i class="icon-sort-down"></i>', 'もっと見る', '</a>' ].join('')); } }); //listがn個以下の場合はスイッチを隠す }else{ $(trigger).hide(); } }); -
taea revised this gist
Nov 29, 2012 . 1 changed file with 0 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -7,7 +7,6 @@ //listがn個以上ある場合は if(contentsLength > n){ //n番目以降を隠す for(var i=n; i<contentsLength; i++){ $(contents+ ':eq(' +i+ ')').hide(); -
taea revised this gist
Nov 29, 2012 . No changes.There are no files selected for viewing
-
taea revised this gist
Nov 29, 2012 . 1 changed file with 3 additions and 3 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,11 +1,11 @@ :javascript $(function(){ var contents = '.list li'; //対象のlist var trigger = '.trigger'; //スイッチ var contentsLength = $(contents).length; //listの個数 var n = 10; //初期状態で表出したいlistの個数 //listがn個以上ある場合は if(contentsLength > n){ alert(contentsLength); //n番目以降を隠す -
taea created this gist
Nov 29, 2012 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,42 @@ :javascript $(function(){ var contents = '.skilltags-more li'; //対象のlist var trigger = '.skilltag-more-trigger'; //スイッチ var contentsLength = $(contents).length; //listの個数 var n = 10; //初期状態で表出したいlistの個数 //listが10個以上ある場合は if(contentsLength > n){ alert(contentsLength); //n番目以降を隠す for(var i=n; i<contentsLength; i++){ $(contents+ ':eq(' +i+ ')').hide(); } $(trigger).click(function(){ if($(contents + ':eq(' +n+ ')').is(":hidden")){ for(var i=n; i<contentsLength; i++){ $(contents+ ':eq(' +i+ ')').fadeIn("fast"); } $(trigger).html([ '<a href="#">', '<i class="icon-sort-up"></i>', '閉じる', '</a>' ].join('')); }else{ for(var i=n; i<contentsLength; i++){ $(contents + ':eq(' +i+ ')').fadeOut("fast"); } $(trigger).html([ '<a href="#">', '<i class="icon-sort-down"></i>', 'もっと見る', '</a>' ].join('')); } }); //listがn個以下の場合はスイッチを隠す }else{ $(trigger).hide(); } });