1/* global jQuery */ 2 3(function() { 4 5 "use strict"; 6 7 var requestAnimationFrame = trx_addons_request_animation_frame(); 8 9 var mouseX = null, mouseY = null, 10 realX = null, realY = null, 11 destX = [0,0,0,0,0,0,0,0,0,0], // Allow up to 10 helper parts to move 12 destY = [0,0,0,0,0,0,0,0,0,0]; 13 14 var mouse_helper_timeout = 0, 15 mouse_helper_target = null, 16 mouse_helper_last_target = null, 17 mouse_helper_action = '', 18 mouse_helper_last_action = '', 19 mouse_helper_callback = '', 20 mouse_helper_axis = 'xy', 21 mouse_helper_delay = 1, 22 mouse_helper_smooth = true; 23 24 var mouse_helper_original_styles = [ {}, {}, {}, {}, {}, {}, {}, {}, {}, {} ]; 25 26 var $window = jQuery( window ), 27 $document = jQuery( document ), 28 $body = jQuery( 'body' ), 29 $mouse_helper = jQuery('.trx_addons_mouse_helper'); 30 31 if ( $mouse_helper.eq(0).hasClass( 'trx_addons_mouse_helper_smooth' ) ) { 32 mouse_helper_smooth = true; 33 } 34 35 var $mouse_helper_targets, 36 $mouse_helper_magnets; 37 38 // Update links and values after the new post added 39 $document.on( 'action.got_ajax_response', update_jquery_links ); 40 $document.on( 'action.init_hidden_elements', update_jquery_links ); 41 var first_run = true; 42 function update_jquery_links(e) { 43 if ( first_run && e && e.namespace == 'init_hidden_elements' ) { 44 first_run = false; 45 return; 46 } 47 $mouse_helper_targets = jQuery('[data-mouse-helper]'); 48 $mouse_helper_magnets = jQuery('[data-mouse-helper-magnet]:not([data-mouse-helper-magnet="0"])'); 49 } 50 update_jquery_links(); 51 52 53 // Init Mouse helper 54 $document.on('action.init_trx_addons', function() { 55 56 if ( TRX_ADDONS_STORAGE['mouse_helper'] > 0 && $mouse_helper.length > 0 && requestAnimationFrame ) { 57 58 $mouse_helper.each( function( idx ) { 59 mouse_helper_original_styles[ idx ] = { 60 blend_mode: $mouse_helper.eq(idx).css( 'mix-blend-mode' ), 61 color: $mouse_helper.eq(idx).css( 'color' ), 62 bg_color: $mouse_helper.eq(idx).css( 'background-color' ), 63 bd_color: $mouse_helper.eq(idx).css( 'border-color' ), 64 bd_width: $mouse_helper.eq(idx).css( 'border-width' ), 65 bd_style: $mouse_helper.eq(idx).css( 'border-style' ) 66 }; 67 } ); 68 69 mouse_helper_delay = TRX_ADDONS_STORAGE['mouse_helper_delay']; 70 71 var pointermove_allowed = false; 72 73 $document 74 .on( 'mousemove pointermove', function(e) { 75 if ( e.originalEvent.type == 'pointermove' ) { 76 pointermove_allowed = true; 77 } 78 if ( e.originalEvent.type == 'mousemove' && pointermove_allowed ) { 79 return; 80 } 81 trx_addons_mouse_helper_get_state(e); 82 if ( mouse_helper_callback && typeof window[mouse_helper_callback] == 'function' ) { 83 window[mouse_helper_callback]( 'mousemove', $mouse_helper, mouse_helper_target, e ); 84 } else if ( typeof window['trx_addons_mouse_helper_callback_' + mouse_helper_action] == 'function' ) { 85 window['trx_addons_mouse_helper_callback_' + mouse_helper_action]( 'mousemove', $mouse_helper, mouse_helper_target, e ); 86 } 87 if ( mouse_helper_action == 'highlight' && mouse_helper_target ) { 88 var targetOffset = mouse_helper_target.offset(), 89 targetX = targetOffset.left - trx_addons_window_scroll_left(), 90 targetY = targetOffset.top - trx_addons_window_scroll_top(), 91 size = parseFloat( mouse_helper_target.css('background-size').split(' ')[0] ) / 2; 92 mouse_helper_target.css( 'background-position', ( mouseX - targetX - size) + 'px ' + ( mouseY - targetY - size ) + 'px' ); 93 } 94 if ( trx_addons_window_width() >= TRX_ADDONS_STORAGE['mobile_breakpoint_mousehelper_off'] ) { 95 if ( mouse_helper_delay < 2 ) { 96 destX.fill( mouseX ); 97 destY.fill( mouseY ); 98 $mouse_helper.css("transform", "translate(" + destX[0] + "px," + destY[0] + "px)"); 99 } 100 if ( mouseX > trx_addons_window_width() - 100 ) { 101 if ( ! $mouse_helper.hasClass( 'trx_addons_mouse_helper_left' ) ) { 102 $mouse_helper.addClass( 'trx_addons_mouse_helper_left' ); 103 } 104 } else { 105 if ( $mouse_helper.hasClass( 'trx_addons_mouse_helper_left' ) ) { 106 $mouse_helper.removeClass( 'trx_addons_mouse_helper_left' ); 107 } 108 } 109 if ( mouseY > trx_addons_window_height() - 100 ) { 110 if ( ! $mouse_helper.hasClass( 'trx_addons_mouse_helper_top' ) ) { 111 $mouse_helper.addClass( 'trx_addons_mouse_helper_top' ); 112 } 113 } else { 114 if ( $mouse_helper.hasClass( 'trx_addons_mouse_helper_top' ) ) { 115 $mouse_helper.removeClass( 'trx_addons_mouse_helper_top' ); 116 } 117 } 118 // Check magnets 119 trx_addons_mouse_helper_check_magnets(); 120 } 121 } ) 122 123 .on( "mouseenter", '[data-mouse-helper]', function(e) { 124 e.stopPropagation(); 125 var $self = jQuery(this).addClass('trx_addons_mouse_helper_over'); 126 // Set new target 127 mouse_helper_target = mouse_helper_last_target = $self; 128 mouse_helper_action = mouse_helper_last_action = $self.data( 'mouse-helper' ); 129 if ( trx_addons_window_width() >= TRX_ADDONS_STORAGE['mobile_breakpoint_mousehelper_off'] ) { 130 mouse_helper_reset(); 131 if ( mouse_helper_timeout ) { 132 clearTimeout( mouse_helper_timeout ); 133 mouse_helper_timeout = 0; 134 } 135 } 136 mouse_helper_callback = $self.data( 'mouse-helper-callback' ); 137 if ( mouse_helper_callback === undefined ) { 138 mouse_helper_callback = ''; 139 } 140 if ( mouse_helper_callback && typeof window[mouse_helper_callback] == 'function' ) { 141 window[mouse_helper_callback]( 'mouseenter', $mouse_helper, $self, e ); 142 } else if ( typeof window['trx_addons_mouse_helper_callback_' + mouse_helper_action] == 'function' ) { 143 window['trx_addons_mouse_helper_callback_' + mouse_helper_action]( 'mouseenter', $mouse_helper, $self, e ); 144 } 145 mouse_helper_axis = $self.data( 'mouse-helper-axis' ); 146 if ( mouse_helper_axis === undefined ) { 147 mouse_helper_axis = 'xy'; 148 } 149 mouse_helper_delay = $self.data( 'mouse-helper-delay' ); 150 if ( mouse_helper_delay === undefined ) { 151 mouse_helper_delay = TRX_ADDONS_STORAGE['mouse_helper_delay']; 152 } 153 154 trx_addons_mouse_helper_get_state(e); 155 156 if ( trx_addons_window_width() >= TRX_ADDONS_STORAGE['mobile_breakpoint_mousehelper_off'] ) { 157 // Hide helper 158 var hide = $self.data("mouse-helper-hide-helper") || ''; 159 if ( hide ) { 160 $mouse_helper.addClass( 'trx_addons_mouse_helper_hide' ); 161 } 162 // Centered 163 var pos = ( TRX_ADDONS_STORAGE['mouse_helper_centered'] > 0 && ( $self.data("mouse-helper-centered") === undefined || $self.data("mouse-helper-centered") === '' ) ) 164 || $self.data("mouse-helper-centered") > 0 165 || ''; 166 $mouse_helper.toggleClass( 'trx_addons_mouse_helper_centered', pos > 0 ); 167 // Overlay mode 168 var mode = $self.data("mouse-helper-mode") || ''; 169 if ( mode ) { 170 $mouse_helper.css( 'mix-blend-mode', mode ); 171 } 172 // Text color 173 var color = $self.data("mouse-helper-color") || ''; 174 if ( color ) { 175 $mouse_helper.css( 'color', color ); 176 }
177 // Background color 178 var bg_color = $self.data("mouse-helper-bg-color") || ''; 179 if ( bg_color ) { 180 $mouse_helper.css( 'background-color', bg_color ); 181 } 182 // Border color 183 var bd_color = $self.data("mouse-helper-bd-color") || ''; 184 if ( bd_color ) { 185 $mouse_helper.css( 'border-color', bd_color ); 186 } 187 // Border width 188 var bd_width = $self.data("mouse-helper-bd-width"); 189 if ( bd_width === undefined ) { 190 bd_width = ''; 191 } 192 if ( bd_width !== '' && bd_width >= 0 ) { 193 $mouse_helper.css( { 194 'border-width': bd_width + 'px', 195 'border-style': bd_width > 0 ? 'solid' : 'none' 196 } ); 197 } 198 // Add image 199 var img = $self.data("mouse-helper-image") || ''; 200 if ( img ) { 201 $mouse_helper.eq(0) 202 .find('.trx_addons_mouse_helper_image').remove(); 203 $mouse_helper.eq(0) 204 .append( '<span class="trx_addons_mouse_helper_image" style="background-image:url(' + img + ');"></span>' ) 205 .addClass( "trx_addons_mouse_helper_with_image"); 206 } 207 // Add icon 208 var icon = $self.data("mouse-helper-icon") || ''; 209 if ( icon && icon != 'none' ) { 210 var icon_color = $self.data("mouse-helper-icon-color") || '', 211 icon_size = $self.data("mouse-helper-icon-size") || ''; 212 $mouse_helper.eq(0) 213 .find('.trx_addons_mouse_helper_icon').remove().end() 214 .append( '<span class="trx_addons_mouse_helper_icon ' + icon + '"' 215 + ' style="' 216 + ( icon_color ? 'color: ' + icon_color + ';' : '' ) 217 + ( icon_size ? 'font-size: ' + icon_size + 'em;' : '' ) 218 + '"' 219 +'></span>' ) 220 .addClass( 'trx_addons_mouse_helper_with_icon' ); 221 } 222 // Add text 223 var text = $self.data("mouse-helper-text") || '', 224 text_round = $self.data("mouse-helper-text-round") > 0 || false, 225 text_size = $self.data("mouse-helper-text-size") || ''; 226 if ( text ) { 227 $mouse_helper.eq(0) 228 .find('.trx_addons_mouse_helper_text').remove().end() 229 .append( '<span class="trx_addons_mouse_helper_text' + ( text_round ? ' trx_addons_mouse_helper_text_round' : '' ) + '"' 230 + ( text_size ? ' style="font-size:' + text_size + 'em;"' : '' ) 231 + '>' 232 + ( text_round ? trx_addons_wrap_chars( text, '<span class="trx_addons_mouse_helper_text_round_item">', '</span>' ) : text ) 233 + '</span>' ) 234 .addClass( 'trx_addons_mouse_helper_with_text' + ( text_round ? ' trx_addons_mouse_helper_with_text_round' : '' ) ); 235 if ( text_round ) { 236 var rtl = $body.hasClass( 'rtl' ); 237 setTimeout( function() { 238 var text_wrap = $mouse_helper.eq(0).find( '.trx_addons_mouse_helper_text' ), 239 items = text_wrap.find( '.trx_addons_mouse_helper_text_round_item' ); 240 if ( items.length > 0) {
241 var r = Math.ceil( text_wrap.width() / 2 ), 242 a = 0, 243 hide = false; 244 items.each( function( idx ) { 245 if ( hide ) { 246 items.eq( idx ).hide(); 247 } else { 248 if ( a >= ( rtl ? 310 : 330 ) ) { // If fill whole round - hide rest chars and replace its with '...' 249 items.eq( idx ).html('…'); 250 hide = true; 251 } 252 var x = r + r * Math.sin( a / 180 * Math.PI ), 253 y = r - r * Math.cos( a / 180 * Math.PI ), 254 css = { 255 'transform': 'rotate(' + ( rtl ? -a : a ) + 'deg)', 256 'top': y + 'px' 257 }; 258 if ( rtl ) { 259 css.right = x + 'px'; 260 } else { 261 css.left = x + 'px'; 262 } 263 items.eq( idx ).css( css ); 264 a += 2 * Math.asin( ( items.eq( idx ).width() + ( rtl ? 3 : 3 ) ) / ( 2 * r ) ) * 180 / Math.PI; 265 } 266 } ); 267 } 268 }, 350); 269 } 270 } 271 // Add custom HTML code 272 var layout = $self.data("mouse-helper-layout") || ''; 273 if ( layout ) { 274 $mouse_helper.eq(0) 275 .find('.trx_addons_mouse_helper_layout').remove().end() 276 .append( '<span class="trx_addons_mouse_helper_layout">' + layout + '</span>' ) 277 .addClass( 'trx_addons_mouse_helper_with_layout' ); 278 } 279 // Add class to the mouse helper with type of the target 280 var obj_type = $self.data( 'element_type' ) || ''; 281 if ( obj_type === 'widget' ) { 282 obj_type = $self.data( 'widget_type' ) || ''; 283 } 284 if ( obj_type === '' ) { 285 if ( $self.hasClass( 'slider_container' ) ) { 286 obj_type = 'slider'; 287 } 288 } else { 289 obj_type = obj_type.split('.')[0]; 290 } 291 if ( obj_type !== '' ) { 292 $mouse_helper.eq(0).addClass( 'trx_addons_mouse_helper_over_element_' + obj_type ); 293 } 294 // Set 'active' and 'action' classes 295 $mouse_helper.addClass( "trx_addons_mouse_helper_active trx_addons_mouse_helper_action_" + mouse_helper_action); 296 } 297 } ) 298 299 .on( "mouseleave", '[data-mouse-helper]', function(e) { 300 e.stopPropagation(); 301 if ( mouse_helper_callback && typeof window[mouse_helper_callback] == 'function' ) { 302 window[mouse_helper_callback]( 'mouseleave', $mouse_helper, mouse_helper_target, e ); 303 mouse_helper_callback = ''; 304 } else if ( typeof window['trx_addons_mouse_helper_callback_' + mouse_helper_action] == 'function' ) { 305 window['trx_addons_mouse_helper_callback_' + mouse_helper_action]( 'mouseleave', $mouse_helper, mouse_helper_target, e ); 306 } 307 $mouse_helper.removeClass( 'trx_addons_mouse_helper_click' 308 + ' trx_addons_mouse_helper_action_' + mouse_helper_action 309 ); 310 if ( mouse_helper_target ) { 311 mouse_helper_target.removeClass('trx_addons_mouse_helper_over'); 312 } 313 mouse_helper_target = null; 314 mouse_helper_action = ''; 315 mouse_helper_axis = 'xy'; 316 mouse_helper_delay = TRX_ADDONS_STORAGE['mouse_helper_delay']; 317 if ( trx_addons_window_width() >= TRX_ADDONS_STORAGE['mobile_breakpoint_mousehelper_off'] ) { 318 mouse_helper_timeout = setTimeout( function() { 319 mouse_helper_reset(); 320 }, mouse_helper_smooth ? 10 : 0 ); //300 321 } 322 if ( e.relatedTarget ) { 323 var newTarget = jQuery(e.relatedTarget); 324 if ( ! newTarget.data('mouse-helper') ) { 325 newTarget = newTarget.parents('[data-mouse-helper]').eq(0); 326 } 327 if ( newTarget.length > 0 && newTarget.data('mouse-helper') ) { 328 setTimeout( function() { 329 newTarget.trigger('mouseenter'); 330 }, 0 ); 331 } 332 } 333 } ) 334 335 .on( "mousedown swiper_touch_start", '[data-mouse-helper]', function(e) { 336 var $self = jQuery(this); 337 $mouse_helper.addClass('trx_addons_mouse_helper_click'); 338 mouse_helper_callback = $self.data( 'mouse-helper-callback' ); 339 if ( mouse_helper_callback === undefined ) { 340 mouse_helper_callback = ''; 341 } 342 if ( mouse_helper_callback && typeof window[mouse_helper_callback] == 'function' ) { 343 window[mouse_helper_callback]( 'mousedown', $mouse_helper, $self, e ); 344 } else if ( typeof window['trx_addons_mouse_helper_callback_' + mouse_helper_action] == 'function' ) { 345 window['trx_addons_mouse_helper_callback_' + mouse_helper_action]( 'mousedown', $mouse_helper, $self, e ); 346 } 347 } ) 348 349 .on( "mouseup swiper_touch_end", '[data-mouse-helper]', function(e) { 350 var $self = jQuery(this); 351 $mouse_helper.removeClass('trx_addons_mouse_helper_click'); 352 mouse_helper_callback = $self.data( 'mouse-helper-callback' ); 353 if ( mouse_helper_callback === undefined ) { 354 mouse_helper_callback = ''; 355 } 356 if ( mouse_helper_callback && typeof window[mouse_helper_callback] == 'function' ) { 357 window[mouse_helper_callback]( 'mouseup', $mouse_helper, $self, e ); 358 } else if ( typeof window['trx_addons_mouse_helper_callback_' + mouse_helper_action] == 'function' ) { 359 window['trx_addons_mouse_helper_callback_' + mouse_helper_action]( 'mouseup', $mouse_helper, $self, e ); 360 } 361 } ); 362 363 var mouse_helper_links = trx_addons_apply_filters( 364 'trx_addons_filter_mouse_helper_links', 365 'a,button,input[type="button"],input[type="submit"],input[type="reset"]' 366 ); 367 $document
368 .on( "mouseenter", mouse_helper_links, function(e) { 369 $mouse_helper.addClass( "trx_addons_mouse_helper_over_link" ); 370 371 } ) 372 .on( "mouseleave", mouse_helper_links, function(e) { 373 $mouse_helper.removeClass( "trx_addons_mouse_helper_over_link" ); 374 } ); 375 376 var mouse_helper_reset = function() { 377 $mouse_helper.eq(0).addClass('trx_addons_mouse_helper_reset'); 378 setTimeout( function() { 379 $mouse_helper.eq(0).removeClass('trx_addons_mouse_helper_reset'); 380 }, $mouse_helper.eq(0).hasClass( 'trx_addons_mouse_helper_with_icon' ) 381 || $mouse_helper.eq(0).hasClass( 'trx_addons_mouse_helper_with_text' ) 382 || $mouse_helper.eq(0).hasClass( 'trx_addons_mouse_helper_with_image' ) 383 || $mouse_helper.eq(0).hasClass( 'trx_addons_mouse_helper_with_layout' ) 384 || ( mouse_helper_target && ( 385 mouse_helper_target.data( 'mouse-helper-icon' ) 386 || mouse_helper_target.data( 'mouse-helper-text' ) 387 || mouse_helper_target.data( 'mouse-helper-image' ) 388 || mouse_helper_target.data( 'mouse-helper-layout' ) 389 ) ) 390 ? ( mouse_helper_smooth ? 500 : 0 ) 391 : ( mouse_helper_smooth ? 50 : 0 ) 392 ); 393 $mouse_helper.eq(0) 394 .attr( 'class', trx_addons_chg_class_by_prefix( $mouse_helper.attr( 'class' ), 'trx_addons_mouse_helper_over_element_', '' ) ); 395 var $inner_elements = $mouse_helper.eq(0).find('.trx_addons_mouse_helper_image,.trx_addons_mouse_helper_text,.trx_addons_mouse_helper_icon,.trx_addons_mouse_helper_layout'); 396 if ( $inner_elements.length > 0 ) { 397 if ( true ) { 398 // Abrupt remove of inner elements 399 $inner_elements.remove(); 400 } else { 401 // Smooth remove of inner elements 402 $inner_elements 403 .addClass('trx_addons_mouse_helper_reset_item') 404 .animate( { 405 opacity: 0, 406 height: 0, 407 width: 0 408 }, 409 mouse_helper_smooth ? 500 : 0, 410 function() { 411 var $self = jQuery(this); 412 if ( $self.hasClass('trx_addons_mouse_helper_reset_item') ) { 413 $self.remove(); 414 } 415 } ); 416 } 417 } 418 $mouse_helper 419 .removeClass( 420 'trx_addons_mouse_helper_active' 421 + ' trx_addons_mouse_helper_hide' 422 + ' trx_addons_mouse_helper_with_icon' 423 + ' trx_addons_mouse_helper_with_text' 424 + ' trx_addons_mouse_helper_with_text_round' 425 + ' trx_addons_mouse_helper_with_image' 426 + ' trx_addons_mouse_helper_with_layout' 427 ) 428 .toggleClass( 'trx_addons_mouse_helper_centered', TRX_ADDONS_STORAGE['mouse_helper_centered'] > 0 ); 429 $mouse_helper.each( function( idx ) { 430 $mouse_helper.eq(idx).css( { 431 'mix-blend-mode': mouse_helper_original_styles[idx].blend_mode, 432 'color': mouse_helper_original_styles[idx].color, 433 'background-color': mouse_helper_original_styles[idx].bg_color, 434 'border-color': mouse_helper_original_styles[idx].bd_color, 435 'border-width': mouse_helper_original_styles[idx].bd_width, 436 'border-style': mouse_helper_original_styles[idx].bd_style 437 } ); 438 } ); 439 if ( mouse_helper_callback && typeof window[mouse_helper_callback] == 'function' ) { 440 window[mouse_helper_callback]( 'reset', $mouse_helper, mouse_helper_last_target, null ); 441 mouse_helper_callback = ''; 442 } else if ( typeof window['trx_addons_mouse_helper_callback_' + mouse_helper_last_action] == 'function' ) { 443 window['trx_addons_mouse_helper_callback_' + mouse_helper_last_action]( 'reset', $mouse_helper, mouse_helper_last_target, e ); 444 } 445 }; 446 447 var mouse_helper_move = function() { 448 cancelAnimationFrame(mouse_helper_move); 449 if ( trx_addons_window_width() >= TRX_ADDONS_STORAGE['mobile_breakpoint_mousehelper_off'] && null !== mouseX && mouse_helper_delay > 1 ) { 450 $mouse_helper.each( function( idx ) { 451 if ( destX[idx] != mouseX || destY[idx] != mouseY ) { 452 if ( $mouse_helper.eq( idx ).hasClass( 'trx_addons_mouse_helper_permanent' ) || $mouse_helper.eq( idx ).hasClass( 'trx_addons_mouse_helper_active' ) ) { 453 var delay = ( $mouse_helper.eq( idx ).data( 'delay' ) || 0 ) * 1 + mouse_helper_delay * 1; 454 destX[idx] += ( mouseX - destX[idx] ) / delay; 455 destY[idx] += ( mouseY - destY[idx] ) / delay; 456 } else { 457 destX[idx] = mouseX; 458 destY[idx] = mouseY; 459 } 460 $mouse_helper.eq( idx ).css("transform", "translate(" + destX[idx] + "px," + destY[idx] + "px)"); 461 } 462 } ); 463 } 464 requestAnimationFrame(mouse_helper_move); 465 }; 466 requestAnimationFrame(mouse_helper_move); 467 468 469 // Get current state 470 function trx_addons_mouse_helper_get_state(e) { 471 if ( e.clientX === undefined ) return; 472 realX = e.clientX + trx_addons_window_scroll_left(); 473 realY = e.clientY + trx_addons_window_scroll_top(); 474 if ( mouse_helper_axis.indexOf('x') != -1 ) mouseX = e.clientX; 475 if ( mouse_helper_axis.indexOf('y') != -1 ) mouseY = e.clientY; 476 } 477 478 479 // Check magnets 480 function trx_addons_mouse_helper_check_magnets() { 481 482 $mouse_helper_magnets.each( function() { 483 484 var item = jQuery(this), 485 inner = item.children(), 486 koef = item.data('mouse-helper-magnet-velocity') ? item.data('mouse-helper-magnet-velocity') : 1, 487 delta = item.data('mouse-helper-magnet') * koef; 488 489 var data, cx, cy, iw, ih, ix, iy, near; //position variables 490 491 requestAnimationFrame(control_item); 492 493 function control_item() { 494 var off = item.offset(); 495 cx = realX; 496 cy = realY; 497 iw = item.width(); 498 ih = item.height(); 499 ix = off.left + iw / 2; 500 iy = off.top + ih / 2; 501 near = Math.abs(ix - cx) < iw * koef && Math.abs(iy - cy) < ih * koef; 502 503 if (near) { 504 ! item.hasClass('trx_addons_mouse_helper_near') && move_item(); 505 requestAnimationFrame(control_item); 506 } else { 507 item.hasClass('trx_addons_mouse_helper_near') && reset_item(); 508 } 509 } 510 511 function move_item() { 512 513 item.addClass('trx_addons_mouse_helper_near'); 514 515 var d = get_closest_position(), 516 dx = d.x, 517 dy = d.y, 518 nx = 0, 519 ny = 0; 520 521 transform_item(); 522 523 function transform_item() { 524 var d = get_closest_position(); 525 nx += (d.x - dx) / 5; 526 ny += (d.y - dy) / 5; 527 528 nx.toFixed(2) !== dx.toFixed(2) && 529 inner.css({ 530 'transition': 'none', 531 'transform': 'translate3d(' + nx + 'px, ' + ny + 'px, 0)' 532 }); 533 534 dx = nx; 535 dy = ny; 536 537 requestAnimationFrame(function () { 538 near && transform_item(); 539 }); 540 } 541 542 function get_closest_position() { 543 return { 544 x: Math.abs(cx - ix) < delta ? cx - ix : delta * (cx - ix) / Math.abs(cx - ix), 545 y: Math.abs(cy - iy) < delta ? cy - iy : delta * (cy - iy) / Math.abs(cy - iy) 546 }; 547 } 548 } 549 550 function reset_item() { 551 552 item.removeClass('trx_addons_mouse_helper_near'); 553 554 inner 555 .css({ 556 'transition': 'transform 0.5s', 557 'transform': 'translate3d(0px, 0px, 0px)' 558 }) 559 .one( typeof window.trx_addons_transition_end != 'undefined' ? trx_addons_transition_end() : 'transitionend', function () { 560 inner.css({ 561 'transition': 'none' 562 }); 563 }); 564 } 565 } ); 566 } 567 } 568 } ); 569 570 571 // Add Mouse helper to the TOC menu 572 $document.on( 'action.build_page_toc', function() { 573 jQuery( '#toc_menu .toc_menu_item' ).each( function() { 574 if ( trx_addons_apply_filters( 'trx_addons_filter_mouse_helper_on_toc', TRX_ADDONS_STORAGE['mouse_helper'] > 0 ) ) { 575 var $self = jQuery(this), 576 title = $self.attr( 'title' ) || $self.find('.toc_menu_description_title').text(); 577 $self.attr( { 578 'data-mouse-helper': 'hover', 579 'data-mouse-helper-axis': 'y', 580 'data-mouse-helper-text': TRX_ADDONS_STORAGE['msg_mouse_helper_anchor'] + ( title ? ' ' + title : '' ) 581 } ); 582 } 583 } ); 584 } ); 585 586})();
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.