1(function($) { 2 $.fn.paginate = function(options) { 3 var opts = $.extend({}, $.fn.paginate.defaults, options); 4 return this.each(function() { 5 $this = $(this); 6 var o = $.meta ? $.extend({}, opts, $this.data()) : opts; 7 var selectedpage = o.start; 8 $.fn.draw(o,$this,selectedpage); 9 }); 10 }; 11 var outsidewidth_tmp = 0; 12 var insidewidth = 0; 13 var bName = navigator.appName; 14 var bVer = navigator.appVersion; 15 if(bVer.indexOf('MSIE 7.0') > 0) 16 var ver = "ie7"; 17 $.fn.paginate.defaults = { 18 count : 5, 19 start : 12, 20 display : 5, 21 border : true, 22 border_color : '#fff', 23 text_color : '#8cc59d', 24 background_color : 'black', 25 border_hover_color : '#fff', 26 text_hover_color : '#fff', 27 background_hover_color : '#fff', 28 rotate : true, 29 images : true, 30 mouse : 'slide', 31 onChange : function(){return false;} 32 }; 33 $.fn.draw = function(o,obj,selectedpage){ 34 if(o.display > o.count) 35 o.display = o.count; 36 $this.empty(); 37 if(o.images){ 38 var spreviousclass = 'jPag-sprevious-img'; 39 var previousclass = 'jPag-previous-img'; 40 var snextclass = 'jPag-snext-img'; 41 var nextclass = 'jPag-next-img'; 42 } 43 else{ 44 var spreviousclass = 'jPag-sprevious'; 45 var previousclass = 'jPag-previous'; 46 var snextclass = 'jPag-snext'; 47 var nextclass = 'jPag-next'; 48 } 49 var _first = $(document.createElement('a')).addClass('jPag-first').html('First'); 50 51 if(o.rotate){ 52 if(o.images) var _rotleft = $(document.createElement('span')).addClass(spreviousclass); 53 else var _rotleft = $(document.createElement('span')).addClass(spreviousclass).html('«'); 54 } 55 56 var _divwrapleft = $(document.createElement('div')).addClass('jPag-control-back'); 57 _divwrapleft.append(_first).append(_rotleft); 58 59 var _ulwrapdiv = $(document.createElement('div')).css('overflow','hidden'); 60 var _ul = $(document.createElement('ul')).addClass('jPag-pages') 61 var c = (o.display - 1) / 2; 62 var first = selectedpage - c; 63 var selobj; 64 for(var i = 0; i < o.count; i++){ 65 var val = i+1; 66 if(val == selectedpage){ 67 var _obj = $(document.createElement('li')).html('<span class="jPag-current">'+val+'</span>'); 68 selobj = _obj; 69 _ul.append(_obj); 70 } 71 else{ 72 var _obj = $(document.createElement('li')).html('<a>'+ val +'</a>'); 73 _ul.append(_obj); 74 } 75 } 76 _ulwrapdiv.append(_ul); 77 78 if(o.rotate){ 79 if(o.images) var _rotright = $(document.createElement('span')).addClass(snextclass); 80 else var _rotright = $(document.createElement('span')).addClass(snextclass).html('»'); 81 } 82 83 var _last = $(document.createElement('a')).addClass('jPag-last').html('Last'); 84 var _divwrapright = $(document.createElement('div')).addClass('jPag-control-front'); 85 _divwrapright.append(_rotright).append(_last); 86 87 //append all: 88 $this.addClass('jPaginate').append(_divwrapleft).append(_ulwrapdiv).append(_divwrapright); 89 90 if(!o.border){ 91 if(o.background_color == 'none') var a_css = {'color':o.text_color}; 92 else var a_css = {'color':o.text_color,'background-color':o.background_color}; 93 if(o.background_hover_color == 'none') var hover_css = {'color':o.text_hover_color}; 94 else var hover_css = {'color':o.text_hover_color,'background-color':o.background_hover_color}; 95 } 96 else{ 97 if(o.background_color == 'none') var a_css = {'color':o.text_color,'border':'1px solid '+o.border_color}; 98 else var a_css = {'color':o.text_color,'background-color':o.background_color,'border':'1px solid '+o.border_color}; 99 if(o.background_hover_color == 'none') var hover_css = {'color':o.text_hover_color,'border':'1px solid '+o.border_hover_color}; 100 else var hover_css = {'color':o.text_hover_color,'background-color':o.background_hover_color,'border':'1px solid '+o.border_hover_color}; 101 } 102 103 $.fn.applystyle(o,$this,a_css,hover_css,_first,_ul,_ulwrapdiv,_divwrapright); 104 //calculate width of the ones displayed: 105 var outsidewidth = outsidewidth_tmp - _first.parent().width() -3; 106 if(ver == 'ie7'){ 107 _ulwrapdiv.css('width',outsidewidth+72+'px'); 108 _divwrapright.css('left',outsidewidth_tmp+6+72+'px'); 109 } 110 else{ 111 _ulwrapdiv.css('width',outsidewidth+'px'); 112 _divwrapright.css('left',outsidewidth_tmp+6+'px'); 113 } 114 115 if(o.rotate){ 116 _rotright.hover( 117 function() { 118 thumbs_scroll_interval = setInterval( 119 function() { 120 var left = _ulwrapdiv.scrollLeft() + 1; 121 _ulwrapdiv.scrollLeft(left); 122 }, 123 20 124 ); 125 }, 126 function() { 127 clearInterval(thumbs_scroll_interval); 128 } 129 ); 130 _rotleft.hover( 131 function() { 132 thumbs_scroll_interval = setInterval( 133 function() { 134 var left = _ulwrapdiv.scrollLeft() - 1; 135 _ulwrapdiv.scrollLeft(left); 136 }, 137 20 138 ); 139 }, 140 function() { 141 clearInterval(thumbs_scroll_interval); 142 } 143 ); 144 if(o.mouse == 'press'){ 145 _rotright.mousedown( 146 function() { 147 thumbs_mouse_interval = setInterval( 148 function() { 149 var left = _ulwrapdiv.scrollLeft() + 5; 150 _ulwrapdiv.scrollLeft(left); 151 }, 152 20 153 ); 154 } 155 ).mouseup( 156 function() { 157 clearInterval(thumbs_mouse_interval); 158 } 159 ); 160 _rotleft.mousedown( 161 function() { 162 thumbs_mouse_interval = setInterval( 163 function() { 164 var left = _ulwrapdiv.scrollLeft() - 5; 165 _ulwrapdiv.scrollLeft(left); 166 }, 167 20 168 ); 169 } 170 ).mouseup( 171 function() { 172 clearInterval(thumbs_mouse_interval); 173 } 174 ); 175 } 176 else{ 177 _rotleft.click(function(e){
178 var width = outsidewidth - 10; 179 var left = _ulwrapdiv.scrollLeft() - width; 180 _ulwrapdiv.animate({scrollLeft: left +'px'}); 181 }); 182 183 _rotright.click(function(e){ 184 var width = outsidewidth - 10; 185 var left = _ulwrapdiv.scrollLeft() + width; 186 _ulwrapdiv.animate({scrollLeft: left +'px'}); 187 }); 188 } 189 } 190 191 //first and last: 192 _first.click(function(e){ 193 _ulwrapdiv.animate({scrollLeft: '0px'}); 194 _ulwrapdiv.find('li').eq(0).click(); 195 }); 196 _last.click(function(e){ 197 _ulwrapdiv.animate({scrollLeft: insidewidth +'px'}); 198 _ulwrapdiv.find('li').eq(o.count - 1).click(); 199 }); 200 201 //click a page 202 _ulwrapdiv.find('li').click(function(e){ 203 selobj.html('<a>'+selobj.find('.jPag-current').html()+'</a>'); 204 var currval = $(this).find('a').html(); 205 $(this).html('<span class="jPag-current">'+currval+'</span>'); 206 selobj = $(this); 207 $.fn.applystyle(o,$(this).parent().parent().parent(),a_css,hover_css,_first,_ul,_ulwrapdiv,_divwrapright); 208 var left = (this.offsetLeft) / 2; 209 var left2 = _ulwrapdiv.scrollLeft() + left; 210 var tmp = left - (outsidewidth / 2); 211 if(ver == 'ie7') 212 _ulwrapdiv.animate({scrollLeft: left + tmp - _first.parent().width() + 52 + 'px'}); 213 else 214 _ulwrapdiv.animate({scrollLeft: left + tmp - _first.parent().width() + 'px'}); 215 o.onChange(currval); 216 }); 217 218 var last = _ulwrapdiv.find('li').eq(o.start-1); 219 last.attr('id','tmp'); 220 var left = document.getElementById('tmp').offsetLeft / 2; 221 last.removeAttr('id'); 222 var tmp = left - (outsidewidth / 2); 223 if(ver == 'ie7') _ulwrapdiv.animate({scrollLeft: left + tmp - _first.parent().width() + 52 + 'px'}); 224 else _ulwrapdiv.animate({scrollLeft: left + tmp - _first.parent().width() + 'px'}); 225 } 226 227 $.fn.applystyle = function(o,obj,a_css,hover_css,_first,_ul,_ulwrapdiv,_divwrapright){ 228 obj.find('a').css(a_css); 229 obj.find('span.jPag-current').css(hover_css); 230 obj.find('a').hover( 231 function(){ 232 $(this).css(hover_css); 233 }, 234 function(){ 235 $(this).css(a_css); 236 } 237 ); 238 obj.css('padding-left',_first.parent().width() + 5 +'px'); 239 insidewidth = 0; 240 241 obj.find('li').each(function(i,n){ 242 if(i == (o.display-1)){ 243 outsidewidth_tmp = this.offsetLeft + this.offsetWidth ; 244 } 245 insidewidth += this.offsetWidth; 246 }) 247 _ul.css('width',insidewidth+'px'); 248 } 249})(jQuery);
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.