1$.fn.pagination = function(config) { 2 // ãªãã·ã§ã³ 3 var o = $.extend({ 4 pager : $('.pager'), 5 prevText : 'prev', 6 nextText : 'next', 7 firstText : 'first', 8 lastText : 'last', 9 ellipsisText : 'â¦', 10 viewNum : 6, 11 pagerNum : 3, 12 ellipsis : true, 13 linkInvalid : false, 14 goTop : true, 15 firstLastNav : true, 16 prevNextNav : true 17 }, config); 18 19 // ã»ã¬ã¯ã¿ 20 var $element = $(this); 21 var $pager = o.pager; 22 if(o.ellipsis){ 23 var $ellipsisFirst= $('<span class="ellipsis"/>').text(o.ellipsisText); 24 var $ellipsisLast= $('<span class="ellipsis"/>').text(o.ellipsisText); 25 } 26 27 // å¤åå¾ 28 var tatalItemNum =$element.length; 29 var tatalpageNum = Math.ceil(tatalItemNum /o.viewNum); 30 var ellipsisFlag = false; 31 32 // 夿°è¨å® 33 var currentIndex = 0; 34 35 // çç¥è¨å·ãã©ã°å¤å® 36 if(tatalpageNum > o.pagerNum) { ellipsisFlag = true;} 37 38 // ãã¼ã¸ã£ã¼ã®çæ 39 for (var i=0; i < tatalpageNum; i++) { 40 $('<span/>').text(i + 1).appendTo($pager); 41 }; 42 if(o.firstLastNav){ 43 $('<span class="prev"/>').text(o.prevText).prependTo($pager); 44 $('<span class="next"/>').text(o.nextText).appendTo($pager); 45 } 46 if(o.prevNextNav){ 47 $('<span class="first"/>').text(o.firstText).prependTo($pager); 48 $('<span class="last"/>').text(o.lastText).appendTo($pager); 49 } 50 var $pagerInner = $pager.find('span').not('.prev, .next, .first, .last'); 51 52 // ã³ã³ãã³ãã®åæè¡¨ç¤º 53 $element.hide(); 54 for (var i=0; i < o.viewNum; i++) { 55 $($element[i]).show(); 56 }; 57 58 // ãã¼ã¸ã£ã¼ã®åæè¡¨ç¤º 59 $pagerInner.hide(); 60 for (var i=0; i < o.pagerNum; i++) { 61 $($pagerInner[i]).show(); 62 }; 63 $($pagerInner[0]).addClass('current'); 64 if (o.linkInvalid) { 65 $('.prev').addClass('invalid'); 66 $('.first').addClass('invalid'); 67 } 68 if(o.ellipsis) { 69 if(ellipsisFlag){ 70 if(tatalpageNum - o.pagerNum > 1) { 71 $($pagerInner[tatalpageNum-1]).before(function() { 72 return $ellipsisLast; 73 }); 74 } 75 $($pagerInner[tatalpageNum-1]).show(); 76 } 77 } 78 79 // æåã®ãã¿ã³ãã¯ãªã㯠80 $('.first').on('click', function(){ 81 var current = 0; 82 if(currentIndex == 0){ 83 if (o.linkInvalid) { 84 return false; 85 } 86 } 87 change(current); 88 }); 89 90 // æå¾ã®ãã¿ã³ãã¯ãªã㯠91 $('.last').on('click', function(){ 92 var current = tatalpageNum - 1; 93 if(currentIndex == $pagerInner.length-1){ 94 if (o.linkInvalid) { 95 return false; 96 } 97 } 98 change(current); 99 }); 100 101 // åã®ãã¿ã³ãã¯ãªã㯠102 $('.prev').on('click', function(){ 103 var current = currentIndex - 1; 104 if(currentIndex == 0){ 105 if (o.linkInvalid) { 106 return false; 107 } else { 108 current = currentIndex; 109 } 110 } 111 change(current); 112 }); 113 114 // 次ã®ãã¿ã³ãã¯ãªã㯠115 $('.next').on('click', function(){ 116 var current = currentIndex + 1; 117 if(currentIndex == $pagerInner.length-1){ 118 if (o.linkInvalid) { 119 return false; 120 } else { 121 current = currentIndex; 122 } 123 } 124 change(current); 125 }); 126 127 // çªå·ãã¯ãªã㯠128 $pagerInner.each(function (current) { 129 $(this).on('click', function(){ 130 if($(this).hasClass('current')){ 131 if (o.linkInvalid) { 132 return false; 133 } 134 } 135 change(current); 136 }); 137 }); 138 139 // åãæ¿ãå®è¡ 140 var change = function (current) { 141 // ã³ã³ãã³ãã®è¡¨ç¤º 142 $element.hide(); 143 for(var i = (current * o.viewNum) ; i < ((current + 1) * o.viewNum) ; i++){ 144 $($element[i]).show(); 145 } 146 // ãã¼ã¸ã£ã¼ã®è¡¨ç¤º 147 $pagerInner.hide(); 148 if(o.ellipsis) { 149 if(ellipsisFlag){ 150 $ellipsisFirst.remove(); 151 $ellipsisLast.remove(); 152 } 153 } 154 var num = current -1; 155 if(num > (tatalpageNum - o.pagerNum)){ 156 num = tatalpageNum - o.pagerNum; 157 } 158 for(var i = num ; i < (num + o.pagerNum) ; i++){ 159 $($pagerInner[i]).show(); 160 }; 161 // çç¥è¨å·ã®è¡¨ç¤º 162 if(o.ellipsis) { 163 if(ellipsisFlag){ 164 // åã®çç¥è¨å· 165 $($pagerInner[0]).show(); 166 if(num > 1){ 167 $($pagerInner[0]).after(function() { 168 return $ellipsisFirst; 169 }); 170 } 171 // å¾ãã®çç¥è¨å· 172 if(num < (tatalpageNum - o.pagerNum -1)) { 173 $($pagerInner[tatalpageNum -1]).before(function() { 174 return $ellipsisLast; 175 }); 176 } 177 $($pagerInner[tatalpageNum -1]).show(); 178 } 179 } 180 // ç¾å¨ä½ç½®è¨å® 181 currentIndex = current; 182 // ãã¶ã¤ã³ 183 $pagerInner.removeClass('current'); 184 $($pagerInner[current]).addClass('current'); 185 if (o.linkInvalid) { 186 if(current == 0 ) { 187 $('.prev').addClass('invalid'); 188 $('.first').addClass('invalid'); 189 } else { 190 $('.prev').removeClass('invalid'); 191 $('.first').removeClass('invalid'); 192 } 193 if(current == tatalpageNum - 1 ) { 194 $('.next').addClass('invalid'); 195 $('.last').addClass('invalid'); 196 } else { 197 $('.next').removeClass('invalid'); 198 $('.last').removeClass('invalid'); 199 } 200 } 201 if(o.goTop){ 202 $('html,body').scrollTop(0); 203 } 204 } 205}
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.