1jQuery(document).ready(function ($) { 2 $(window).load(function () { 3 $('.scroller').each(function () { 4 if ($(window).width() <= 639) { 5 $(this).attr('data-width', '1').attr('data-loaiscroll', 'motsp').attr('data-padding', '0'); 6 } 7 var ngangscroll = $(this).find('.scroller_block').width(); 8 var sospdisplay = parseInt($(this).attr('data-width')); 9 var paddingsp = parseInt($(this).attr('data-padding')); 10 // Set ngang và cao cá»§a item và scroll 11 var maxheight = 0; 12 if ($(this).attr('data-chieuscroll') == 'ngang') { 13 paddingsp = ngangscroll / 100 * paddingsp; 14 var ngangsp = (ngangscroll - ((sospdisplay - 1) * paddingsp)) / sospdisplay; 15 $(this).find('.scroller_loptrong').children().each(function () { 16 $(this).css({ 17 "width": ngangsp, 18 "margin-right": paddingsp 19 }); 20 if (maxheight < $(this).height()) { 21 maxheight = $(this).height(); 22 } 23 }); 24 $(this).find('.scroller_loptrong').children().height(maxheight); 25 $(this).find('.scroller_block').height(maxheight); 26 } 27 else{ 28 var ngangsp = ngangscroll; 29 $(this).find('.scroller_loptrong').children().each(function () { 30 $(this).css({ 31 "width": ngangsp 32 }); 33 if (maxheight < $(this).height()) { 34 maxheight = $(this).height(); 35 } 36 }); 37 paddingsp = (sospdisplay*maxheight) / 100 * paddingsp 38 $(this).find('.scroller_loptrong').children().height(maxheight).css('margin-bottom', paddingsp); 39 $(this).find('.scroller_block').height( ((sospdisplay-1) * paddingsp) + (sospdisplay*maxheight) ); 40 } 41 // Set sá» item tá»i thiá»u 42 if( $(this).attr('data-loaiscroll') == 'motsp' ){ 43 var tongsosp = $(this).find('.scroller_loptrong').children().length; 44 if( tongsosp < (sospdisplay) ){ 45 var moithem = (sospdisplay-tongsosp) + sospdisplay; 46 47 } 48 else{ 49 var moithem = sospdisplay; 50 } 51 if( (tongsosp-sospdisplay) <= 0 ){ 52 var scrolltoida = 0; 53 } 54 else{ 55 var scrolltoida = tongsosp-sospdisplay; 56 } 57 } 58 else{ 59 var tongsosp = $(this).find('.scroller_loptrong').children().length; 60 if( tongsosp < sospdisplay ){ 61 var moithem = (sospdisplay-tongsosp) + sospdisplay; 62 63 } 64 else{ 65 if( (tongsosp % sospdisplay) == 0 ){ 66 var moithem = sospdisplay; 67 } 68 else{ 69 var moithem = ( sospdisplay - ( tongsosp % sospdisplay ) ) + sospdisplay; 70 } 71 72 } 73 if( (tongsosp-sospdisplay) <= 0 ){ 74 var scrolltoida = 0; 75 } 76 else{ 77 if( ( tongsosp % sospdisplay ) == 0 ){ 78 var scrolltoida = parseInt((tongsosp/sospdisplay)) - 1; 79 } 80 else{ 81 var scrolltoida = parseInt((tongsosp/sospdisplay)) 82 } 83 } 84 } 85 for (i = 0; i < moithem; i++) { 86 $(this).find('.scroller_loptrong').html( $(this).find('.scroller_loptrong').html() + $(this).find('.scroller_loptrong').children().eq(i).clone().wrap('<div>').parent().html() ); 87 } 88 $(this).find('.scroller_loptrong').attr('data-maxscroll', scrolltoida ).attr('data-currentscroll', 0 ); 89 $(this).css('opacity', '1'); 90 $(this).find('.prev_but, .next_but, .bot_but, .top_but').show(); 91 }); 92 function CantScroll(my){ 93 my.addClass('CantClick'); 94 } 95 function CanScroll(my){ 96 my.removeClass('CantClick'); 97 } 98 function beforescroll(my,move){ 99 // không cho click tiếp 100 CantScroll(my); 101 // Set giá trá» Äá» trả vá» 102 var current_scroll = parseInt(my.find('.scroller_loptrong').attr('data-currentscroll')); 103 var max_scroll = parseInt(my.find('.scroller_loptrong').attr('data-maxscroll')); 104 if( my.attr('data-chieuscroll') == 'ngang' ){ 105 if( my.attr('data-loaiscroll') == 'motsp' ){ 106 var left = my.find('.scroller_loptrong').children().first().width() + parseInt(my.find('.scroller_loptrong').children().first().css('margin-right').replace('px', '')); 107 var tocdo = parseInt(my.attr('data-tocdo')) / ( parseInt(my.attr('data-width')) / 2 ); 108 } 109 else{ 110 var left = ( my.find('.scroller_loptrong').children().first().width() + parseInt(my.find('.scroller_loptrong').children().first().css('margin-right').replace('px', '')) ) * parseInt(my.attr('data-width')); 111 var tocdo = parseInt(my.attr('data-tocdo')); 112 } 113 } 114 else{ 115 if( my.attr('data-loaiscroll') == 'motsp' ){ 116 var left = my.find('.scroller_loptrong').children().first().height() + parseInt(my.find('.scroller_loptrong').children().first().css('margin-bottom').replace('px', '')); 117 var tocdo = parseInt(my.attr('data-tocdo')) / ( parseInt(my.attr('data-width')) / 2 ); 118 } 119 else{ 120 var left = ( my.find('.scroller_loptrong').children().first().height() + parseInt(my.find('.scroller_loptrong').children().first().css('margin-bottom').replace('px', '')) ) * parseInt(my.attr('data-width')); 121 var tocdo = parseInt(my.attr('data-tocdo')); 122 } 123 } 124 if(move == 'plus'){ 125 if( current_scroll < max_scroll ){ 126 var step_scroll = current_scroll + 1;
127 var margin = -(step_scroll * left); 128 } 129 else{ 130 var step_scroll = 0; 131 var margin = -((current_scroll+1) * left); 132 } 133 } 134 else{ 135 if( current_scroll > 0 ){ 136 var step_scroll = current_scroll - 1; 137 var margin = -(step_scroll * left); 138 } 139 else{ 140 var step_scroll = max_scroll; 141 var margin = -(max_scroll * left); 142 } 143 } 144 my.find('.scroller_loptrong').attr('data-currentscroll',step_scroll); 145 return [step_scroll, margin, tocdo, max_scroll, left]; 146 } 147 function scrollationnext(me) { 148 var MyScroll = me.find('.scroller_loptrong'); 149 var action_left = beforescroll(me,'plus'); 150 if( action_left[0] == 0 ){ 151 MyScroll.animate({ 152 "left": action_left[1] 153 }, 154 { 155 duration: action_left[2], 156 complete: function () { 157 $(this).css('left',0); 158 CanScroll(me); 159 } 160 }); 161 } 162 else{ 163 MyScroll.animate({ 164 "left": action_left[1] 165 }, 166 { 167 duration: action_left[2], 168 complete: function () { 169 CanScroll(me); 170 } 171 }); 172 } 173 } 174 function scrollationprev(me) { 175 var MyScroll = me.find('.scroller_loptrong'); 176 var action_left = beforescroll(me,'minus'); 177 if( action_left[0] == action_left[3] ){ 178 MyScroll.css('left', -((action_left[3]+1) * action_left[4]) ); 179 MyScroll.animate({ 180 "left": action_left[1] 181 }, 182 { 183 duration: action_left[2], 184 complete: function () { 185 CanScroll(me); 186 } 187 }); 188 } 189 else{ 190 MyScroll.animate({ 191 "left": action_left[1] 192 }, 193 { 194 duration: action_left[2], 195 complete: function () { 196 CanScroll(me); 197 } 198 }); 199 } 200 } 201 function scrollationbot(me) { 202 var MyScroll = me.find('.scroller_loptrong'); 203 var action_left = beforescroll(me,'plus'); 204 if( action_left[0] == 0 ){ 205 MyScroll.animate({ 206 "top": action_left[1] 207 }, 208 { 209 duration: action_left[2], 210 complete: function () { 211 $(this).css('top',0); 212 CanScroll(me); 213 } 214 }); 215 } 216 else{ 217 MyScroll.animate({ 218 "top": action_left[1] 219 }, 220 { 221 duration: action_left[2], 222 complete: function () { 223 CanScroll(me); 224 } 225 }); 226 } 227 } 228 function scrollationtop(me) { 229 var MyScroll = me.find('.scroller_loptrong'); 230 var action_left = beforescroll(me,'minus'); 231 if( action_left[0] == action_left[3] ){ 232 MyScroll.css('top', -((action_left[3]+1) * action_left[4]) ); 233 MyScroll.animate({ 234 "top": action_left[1] 235 }, 236 { 237 duration: action_left[2], 238 complete: function () { 239 CanScroll(me); 240 } 241 }); 242 } 243 else{ 244 MyScroll.animate({ 245 "top": action_left[1] 246 }, 247 { 248 duration: action_left[2], 249 complete: function () { 250 CanScroll(me); 251 } 252 }); 253 } 254 } 255 var timesecond = 10000; 256 var time = setTimeout(scroller, timesecond); 257 function scroller() { 258 $('.scroller').each(function () { 259 if ($(this).attr('data-chieuscroll') == 'ngang') { 260 scrollationnext($(this)); 261 } 262 else { 263 scrollationbot($(this)); 264 } 265 }); 266 time = setTimeout(scroller, timesecond); 267 } 268 function pauseTimer() { 269 clearTimeout(time); 270 } 271 function playTimer() { 272 time = setTimeout(scroller, timesecond); 273 } 274 $('.scroller').bind('mouseover touchstart',function () { 275 pauseTimer(); 276 }).bind('mouseleave touchend',function () { 277 playTimer(); 278 }); 279 // Nắm chuá»t 280 var MouseDownLeft,MouseDownTop,MouseUpLeft,MouseUpTop; 281 var isTouchDevice = 'ontouchstart' in document.documentElement; 282 if( isTouchDevice ){ 283 var startEventType = 'touchstart'; 284 var endEventType = 'touchend'; 285 } 286 else{ 287 var startEventType = 'mousedown'; 288 var endEventType = 'mouseup'; 289 } 290 $('.scroller').bind(startEventType,function(cursor1){ 291 if( isTouchDevice ){ 292 //alert('xxx'); 293 MouseDownLeft = cursor1.originalEvent.touches[0].pageX; 294 MouseDownTop = cursor1.originalEvent.touches[0].pageY; 295 } 296 else{ 297 MouseDownLeft = cursor1.pageX; 298 MouseDownTop = cursor1.pageY; 299 } 300 $(this).addClass('NamChuot'); 301 }).bind(endEventType,function(cursor2){ 302 if( isTouchDevice ){ 303 MouseUpLeft = cursor2.originalEvent.changedTouches[0].pageX; 304 MouseUpTop = cursor2.originalEvent.changedTouches[0].pageY; 305 } 306 else{ 307 MouseUpLeft = cursor2.pageX; 308 MouseUpTop = cursor2.pageY; 309 } 310 311 if ($(this).attr('data-chieuscroll') == 'ngang') { 312 if( MouseDownLeft == MouseUpLeft ){ 313 314 } 315 else{ 316 if( MouseDownLeft < MouseUpLeft ){ 317 scrollationprev( $(this) ); 318 } 319 else{ 320 scrollationnext( $(this) ); 321 } 322 } 323 } 324 else{ 325 if( MouseDownTop == MouseUpTop ){ 326 327 } 328 else{ 329 if( MouseDownTop < MouseUpTop ){ 330 scrollationbot( $(this) ); 331 } 332 else{ 333 scrollationtop( $(this) ); 334 } 335 } 336 } 337 $(this).removeClass('NamChuot'); 338 }); 339 // Sá»± kiá»n click control 340 $('.next_but').click(function () { 341 if( !$(this).parent().hasClass('CantClick') ){ 342 scrollationnext($(this).parent()); 343 } 344 }); 345 $('.prev_but').click(function () { 346 if( !$(this).parent().hasClass('CantClick') ){ 347 scrollationprev($(this).parent()); 348 } 349 }); 350 $('.bot_but').click(function () { 351 if( !$(this).parent().hasClass('CantClick') ){ 352 scrollationbot($(this).parent()); 353 } 354 }); 355 $('.top_but').click(function () { 356 if( !$(this).parent().hasClass('CantClick') ){ 357 scrollationtop($(this).parent()); 358 } 359 }); 360 }); 361});
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.