1/** 2 * jquery.tcfloatbox.js 3 * 4 * @param {Object} $ The jQuery object 5 * @version: v1.2 6 * @author: ThemeComplete 7 * 8 * Created by ThemeComplete 9 * 10 * Copyright (c) 2023 themeComplete http://themecomplete.com 11 */ 12( function( $ ) { 13 'use strict'; 14 15 var FloatBox = function( dom, options ) { 16 this.element = $( dom ); 17 18 this.settings = $.extend( {}, $.fn.tcFloatBox.defaults, options ); 19 this.settings.type = '<' + this.settings.type + '>'; 20 21 this.top = 0; 22 this.left = 0; 23 this.ticking = false; 24 25 if ( this.element.length === 1 ) { 26 this.init(); 27 return this; 28 } 29 30 return false; 31 }; 32 33 FloatBox.prototype = { 34 constructor: FloatBox, 35 36 destroy: function() { 37 var settings = this.settings; 38 39 if ( this.instance !== undefined ) { 40 $.fn.tcFloatBox.instances.splice( this.instance, 1 ); 41 42 delete this.instance; 43 44 if ( settings.hideelements ) { 45 $( 'embed, object, select' ).css( { 46 visibility: 'visible' 47 } ); 48 } 49 50 if ( settings._ovl ) { 51 settings._ovl.off(); 52 settings._ovl.remove(); 53 delete settings._ovl; 54 } 55 56 $( settings.floatboxID ).remove(); 57 58 this.element.removeData( 'tcfloatbox' ); 59 60 $( window ).off( 'scroll.tcfloatbox' + this.instance ); 61 $( window ).off( 'resize.tcfloatbox' + this.instance ); 62 } 63 64 return this; 65 }, 66 67 hide: function() { 68 var settings = this.settings; 69 70 if ( settings.hideelements ) { 71 $( 'embed, object, select' ).css( { 72 visibility: 'visible' 73 } ); 74 } 75 if ( settings.showoverlay === true ) { 76 if ( settings._ovl ) { 77 settings._ovl.hide(); 78 } 79 } 80 81 $( settings.floatboxID ) 82 .addClass( 'tc-closing' ) 83 .removeClass( settings.animateIn ) 84 .addClass( settings.animateOut ); 85 $( settings.floatboxID ).animate( 86 { 87 opacity: 0 88 }, 89 settings.closefadeouttime, 90 function() { 91 $( settings.floatboxID ).hide(); 92 $( settings.floatboxID ) 93 .removeClass( 'tc-closing' ) 94 .addClass( 'tc-closed' ); 95 } 96 ); 97 98 $( window ).off( 'scroll.tcfloatbox' + this.instance ); 99 $( window ).off( 'resize.tcfloatbox' + this.instance ); 100 }, 101 102 requestTick: function() { 103 var settings = this.settings; 104 105 if ( ! this.ticking ) { 106 if ( settings.refresh ) { 107 setTimeout( 108 this.requestAnimationFrame.bind( this ), 109 settings.refresh 110 ); 111 } else { 112 requestAnimationFrame( this.update ); 113 } 114 115 this.ticking = true; 116 } 117 }, 118 119 requestAnimationFrame: function() { 120 requestAnimationFrame( this.update.bind( this ) ); 121 }, 122 123 update: function() { 124 this.render(); 125 this.ticking = false; 126 }, 127 128 doit: function() { 129 this.requestTick(); 130 }, 131 132 render: function() { 133 var settings = this.settings; 134 var size = $.epoAPI.dom.size(); 135 var scroll; 136 var top; 137 var left; 138 139 if ( settings.refresh === 'fixed' ) { 140 scroll = { top: 0, left: 0 }; 141 } else { 142 scroll = $.epoAPI.dom.scroll(); 143 } 144 145 top = parseInt( 146 scroll.top + 147 ( ( size.visibleHeight - $( settings.floatboxID ).height() ) / 2 ), 148 10 149 ); 150 left = parseInt( 151 scroll.left + 152 ( ( size.visibleWidth - $( settings.floatboxID ).width() ) / 2 ), 153 10 154 ); 155 156 top = parseInt( ( top - this.top ) / settings.fps, 10 ); 157 left = parseInt( ( left - this.left ) / settings.fps, 10 ); 158 159 this.top += top; 160 this.left += left; 161 162 $( settings.floatboxID ).css( { 163 top: this.top + 'px', 164 left: this.left + 'px', 165 opacity: 1 166 } ); 167 }, 168 169 show: function() { 170 var settings = this.settings; 171 var top; 172 var size; 173 174 if ( this.element.length === 1 ) { 175 if ( this.instance === undefined ) { 176 this.init(); 177 } 178 179 if ( settings.hideelements ) { 180 $( 'embed, object, select' ).css( { 181 visibility: 'hidden' 182 } ); 183 } 184 185 size = $.epoAPI.dom.size(); 186 187 if ( settings.showoverlay === true ) { 188 if ( ! settings._ovl ) { 189 settings._ovl = $( '<div class="fl-overlay"></div>' ).css( 190 { 191 zIndex: parseInt( settings.zIndex, 10 ) - 1, 192 opacity: settings.overlayopacity 193 } 194 ); 195 settings._ovl.appendTo( 'body' ); 196 if ( ! settings.ismodal ) { 197 if ( settings.cancelEvent || settings.unique ) { 198 settings._ovl.on( 199 'click', 200 this.applyCancelEvent.bind( this ) 201 ); 202 } else { 203 settings._ovl.on( 204 'click', 205 settings.cancelfunc.bind( this ) 206 ); 207 } 208 } 209 } else { 210 settings._ovl.show(); 211 } 212 } 213 214 if ( settings.showfunc ) {
215 settings.showfunc.call(); 216 } 217 218 $( settings.floatboxID ) 219 .removeClass( 'tc-closing' ) 220 .addClass( 221 settings.animationBaseClass + ' ' + settings.animateIn 222 ); 223 224 if ( settings.refresh === 'fixed' ) { 225 if ( settings.top !== false ) { 226 top = settings.top; 227 } else { 228 top = parseInt( 229 ( size.visibleHeight - 230 $( settings.floatboxID ).height() ) / 231 2, 232 10 233 ); 234 top = top + 'px'; 235 } 236 $( settings.floatboxID ).css( { 237 position: 'fixed', 238 top: top 239 } ); 240 241 if ( settings.left !== false ) { 242 $( settings.floatboxID ).css( { 243 left: settings.left 244 } ); 245 } 246 } else { 247 this.render(); 248 } 249 } 250 }, 251 252 applyCancelEvent: function() { 253 var settings = this.settings; 254 255 if ( settings.cancelEvent === true ) { 256 this.destroy(); 257 } else if ( typeof settings.cancelEvent === 'function' ) { 258 settings.cancelEvent.call( this, this ); 259 } 260 }, 261 262 applyCancelEventFromKey: function( e ) { 263 if ( e.which === 27 ) { 264 this.applyCancelEvent(); 265 } 266 }, 267 268 applyUpdateEvent: function() { 269 var settings = this.settings; 270 271 if ( typeof settings.updateEvent === 'function' ) { 272 settings.updateEvent.call( this, this ); 273 } 274 }, 275 276 applyUpdateEventFromKey: function( e ) { 277 if ( e.which === 13 ) { 278 this.applyUpdateEvent(); 279 } 280 }, 281 282 init: function() { 283 var settings = this.settings; 284 var size; 285 var scroll; 286 var l = 0; 287 var h; 288 289 if ( this.element.length === 1 ) { 290 // Instance initialization 291 if ( $.fn.tcFloatBox.instances.length > 0 ) { 292 settings.zIndex = 293 parseInt( 294 $.fn.tcFloatBox.instances[ 295 $.fn.tcFloatBox.instances.length - 1 296 ].zIndex, 297 10 298 ) + 100; 299 } 300 this.instance = $.fn.tcFloatBox.instances.length; 301 $.fn.tcFloatBox.instances.push( settings ); 302 303 settings.id = settings.id + this.instance; 304 settings.floatboxID = '#' + $.epoAPI.dom.id( settings.id ); 305 306 this.hide(); 307 308 size = $.epoAPI.dom.size(); 309 scroll = $.epoAPI.dom.scroll(); 310 311 $( settings.type ) 312 .attr( 'id', settings.id ) 313 .addClass( settings.classname ) 314 .html( settings.data ) 315 .appendTo( this.element ); 316 317 $( settings.floatboxID ).css( { 318 width: settings.width, 319 height: settings.height 320 } ); 321 322 if ( settings.minWidth ) { 323 $( settings.floatboxID ).css( { 324 'min-width': settings.minWidth 325 } ); 326 } 327 328 if ( settings.minHeight ) { 329 $( settings.floatboxID ).css( { 330 'min-height': settings.minHeight 331 } ); 332 } 333 334 h = parseInt( 335 scroll.left + 336 ( ( size.visibleWidth - $( settings.floatboxID ).width() ) / 2 ), 337 10 338 ); 339 340 $( settings.floatboxID ).css( { 341 top: l + 'px', 342 left: h + 'px', 343 'z-index': settings.zIndex 344 } ); 345 346 this.top = l; 347 this.left = h; 348 this.cancelfunc = settings.cancelfunc; 349 350 if ( settings.cancelEvent && settings.cancelClass ) { 351 $( settings.floatboxID ) 352 .find( settings.cancelClass ) 353 .on( 'click', this.applyCancelEvent.bind( this ) ); 354 if ( settings.isconfirm ) { 355 $( document ) 356 .off( 'keyup.escape-' + settings.floatboxID ) 357 .on( 358 'keyup.escape-' + settings.floatboxID, 359 this.applyCancelEventFromKey.bind( this ) 360 ); 361 } 362 } 363 364 if ( settings.updateEvent && settings.updateClass ) { 365 $( settings.floatboxID ) 366 .find( settings.updateClass ) 367 .on( 'click', this.applyUpdateEvent.bind( this ) ); 368 if ( settings.isconfirm ) { 369 $( document ) 370 .off( 'keyup.enter-' + settings.floatboxID ) 371 .on( 372 'keyup.enter-' + settings.floatboxID, 373 this.applyUpdateEventFromKey.bind( this ) 374 ); 375 } 376 } 377 378 this.show(); 379 380 if ( settings.refresh !== 'fixed' ) { 381 $( window ).on( 382 'scroll.tcfloatbox' + this.instance, 383 this.doit.bind( this ) 384 ); 385 } 386 387 $( window ).on( 388 'resize.tcfloatbox' + this.instance, 389 this.doit.bind( this ) 390 ); 391 } 392 } 393 }; 394 395 $.fn.tcFloatBox = function( option ) { 396 var methodReturn; 397 var targets = $( this ); 398 var data = targets.data( 'tcfloatbox' ); 399 var options; 400 var ret; 401 402 if ( typeof option === 'object' ) { 403 options = option; 404 } else { 405 options = {}; 406 } 407 408 if ( ! data ) { 409 data = new FloatBox( this, options ); 410 targets.data( 'tcfloatbox', data ); 411 } 412 413 if ( typeof option === 'string' ) { 414 methodReturn = data[ option ].apply( data, [] ); 415 } 416 417 if ( methodReturn === undefined ) { 418 ret = targets; 419 } else { 420 ret = methodReturn; 421 } 422 423 return ret; 424 }; 425 426 $.fn.tcFloatBox.defaults = { 427 id: 'flasho', 428 classname: 'flasho', 429 type: 'div', 430 data: '', 431 width: '500px', 432 height: 'auto', 433 minWidth: 0, 434 minHeight: 0, 435 closefadeouttime: 1000, 436 animationBaseClass: 'tm-animated', 437 animateIn: 'fadein', 438 animateOut: 'fadeout', 439 top: false, 440 left: false, 441 refresh: false, 442 fps: 4, 443 hideelements: false, 444 showoverlay: true, 445 zIndex: 100100, 446 ismodal: false, 447 cancelfunc: FloatBox.prototype.hide, 448 showfunc: null, 449 cancelEvent: true, 450 cancelClass: '.floatbox-cancel', 451 updateEvent: false,
452 updateClass: false, 453 unique: true, 454 overlayopacity: 0.5, 455 isconfirm: false 456 }; 457 458 $.fn.tcFloatBox.instances = []; 459 460 $.fn.tcFloatBox.Constructor = FloatBox; 461 462 $.tcFloatBox = function( options ) { 463 var targets = $( 'body' ); 464 var data = false; 465 var hasAtLeastOneNonToolTip = targets 466 .map( function() { 467 return $( this ).data( 'tcfloatbox' ) || ''; 468 } ) 469 .get() 470 .some( function( value ) { 471 return value === ''; 472 } ); 473 if ( hasAtLeastOneNonToolTip || options.unique ) { 474 data = new FloatBox( targets, options ); 475 targets.data( 'tcfloatbox', data ); 476 } else { 477 data = targets.data( 'tcfloatbox' ); 478 data.init(); 479 } 480 return data; 481 }; 482}( window.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.