1/* 2 * CSS3 Animate it 3 * Copyright (c) 2014 Jack McCourt 4 * https://github.com/kriegar/css3-animate-it / http://jackonthe.net/css3animateit/ 5 * Version: 0.1.0 6 * 7 * I utilise the jQuery.appear plugin within this javascript file so here is a link to that too 8 * https://github.com/morr/jquery.appear 9 * 10 * I also utilise the jQuery.doTimeout plugin for the data-sequence functionality so here is a link back to them. 11 * http://benalman.com/projects/jquery-dotimeout-plugin/ 12 */ 13(function($) { 14 var selectors = []; 15 16 var check_binded = false; 17 var check_lock = false; 18 var defaults = { 19 interval: 250, 20 force_process: false 21 } 22 var $window = $(window); 23 24 var $prior_appeared; 25 26 function process() { 27 check_lock = false; 28 for (var index = 0; index < selectors.length; index++) { 29 var $appeared = $(selectors[index]).filter(function() { 30 return $(this).is(':appeared'); 31 }); 32 33 $appeared.trigger('appear', [$appeared]); 34 35 if ($prior_appeared) { 36 37 var $disappeared = $prior_appeared.not($appeared); 38 $disappeared.trigger('disappear', [$disappeared]); 39 } 40 $prior_appeared = $appeared; 41 } 42 } 43 44 // "appeared" custom filter 45 $.expr[':']['appeared'] = function(element) { 46 var $element = $(element); 47 if (!$element.is(':visible')) { 48 return false; 49 } 50 51 var window_left = $window.scrollLeft(); 52 var window_top = $window.scrollTop(); 53 var offset = $element.offset(); 54 var left = offset.left; 55 var top = offset.top; 56 57 if (top + $element.height() >= window_top && 58 top - ($element.data('appear-top-offset') || 0) <= window_top + $window.height() && 59 left + $element.width() >= window_left && 60 left - ($element.data('appear-left-offset') || 0) <= window_left + $window.width()) { 61 return true; 62 } else { 63 return false; 64 } 65 } 66 67 $.fn.extend({ 68 // watching for element's appearance in browser viewport 69 appear: function(options) { 70 var opts = $.extend({}, defaults, options || {}); 71 var selector = this.selector || this; 72 if (!check_binded) { 73 var on_check = function() { 74 if (check_lock) { 75 return; 76 } 77 check_lock = true; 78 79 setTimeout(process, opts.interval); 80 }; 81 82 $(window).scroll(on_check).resize(on_check); 83 check_binded = true; 84 } 85 86 if (opts.force_process) { 87 setTimeout(process, opts.interval); 88 } 89 selectors.push(selector); 90 return $(selector); 91 } 92 }); 93 94 $.extend({ 95 // force elements's appearance check 96 force_appear: function() { 97 if (check_binded) { 98 process(); 99 return true; 100 }; 101 return false; 102 } 103 }); 104})(jQuery); 105 106 107 108/*! 109 * jQuery doTimeout: Like setTimeout, but better! - v1.0 - 3/3/2010 110 * http://benalman.com/projects/jquery-dotimeout-plugin/ 111 * 112 * Copyright (c) 2010 "Cowboy" Ben Alman 113 * Dual licensed under the MIT and GPL licenses. 114 * http://benalman.com/about/license/ 115 */ 116 117// Script: jQuery doTimeout: Like setTimeout, but better! 118// 119// *Version: 1.0, Last updated: 3/3/2010* 120// 121// Project Home - http://benalman.com/projects/jquery-dotimeout-plugin/ 122// GitHub - http://github.com/cowboy/jquery-dotimeout/ 123// Source - http://github.com/cowboy/jquery-dotimeout/raw/master/jquery.ba-dotimeout.js 124// (Minified) - http://github.com/cowboy/jquery-dotimeout/raw/master/jquery.ba-dotimeout.min.js (1.0kb) 125// 126// About: License 127// 128// Copyright (c) 2010 "Cowboy" Ben Alman, 129// Dual licensed under the MIT and GPL licenses. 130// http://benalman.com/about/license/ 131// 132// About: Examples 133// 134// These working examples, complete with fully commented code, illustrate a few 135// ways in which this plugin can be used. 136// 137// Debouncing - http://benalman.com/code/projects/jquery-dotimeout/examples/debouncing/ 138// Delays, Polling - http://benalman.com/code/projects/jquery-dotimeout/examples/delay-poll/ 139// Hover Intent - http://benalman.com/code/projects/jquery-dotimeout/examples/hoverintent/ 140// 141// About: Support and Testing 142// 143// Information about what version or versions of jQuery this plugin has been 144// tested with, what browsers it has been tested in, and where the unit tests 145// reside (so you can test it yourself). 146// 147// jQuery Versions - 1.3.2, 1.4.2 148// Browsers Tested - Internet Explorer 6-8, Firefox 2-3.6, Safari 3-4, Chrome 4-5, Opera 9.6-10.1. 149// Unit Tests - http://benalman.com/code/projects/jquery-dotimeout/unit/ 150// 151// About: Release History 152// 153// 1.0 - (3/3/2010) Callback can now be a string, in which case it will call 154// the appropriate $.method or $.fn.method, depending on where .doTimeout 155// was called. Callback must now return `true` (not just a truthy value) 156// to poll. 157// 0.4 - (7/15/2009) Made the "id" argument optional, some other minor tweaks 158// 0.3 - (6/25/2009) Initial release 159 160(function($){ 161 '$:nomunge'; // Used by YUI compressor. 162 163 var cache = {}, 164 165 // Reused internal string. 166 doTimeout = 'doTimeout', 167 168 // A convenient shortcut. 169 aps = Array.prototype.slice; 170 171 // Method: jQuery.doTimeout 172 // 173 // Initialize, cancel, or force execution of a callback after a delay. 174 // 175 // If delay and callback are specified, a doTimeout is initialized. The 176 // callback will execute, asynchronously, after the delay. If an id is 177 // specified, this doTimeout will override and cancel any existing doTimeout 178 // with the same id. Any additional arguments will be passed into callback 179 // when it is executed. 180 // 181 // If the callback returns true, the doTimeout loop will execute again, after 182 // the delay, creating a polling loop until the callback returns a non-true 183 // value. 184 // 185 // Note that if an id is not passed as the first argument, this doTimeout will 186 // NOT be able to be manually canceled or forced. (for debouncing, be sure to 187 // specify an id). 188 // 189 // If id is specified, but delay and callback are not, the doTimeout will be 190 // canceled without executing the callback. If force_mode is specified, the 191 // callback will be executed, synchronously, but will only be allowed to 192 // continue a polling loop if force_mode is true (provided the callback 193 // returns true, of course). If force_mode is false, no polling loop will 194 // continue, even if the callback returns true. 195 // 196 // Usage: 197 // 198 // > jQuery.doTimeout( [ id, ] delay, callback [, arg ... ] ); 199 // > jQuery.doTimeout( id [, force_mode ] ); 200 // 201 // Arguments: 202 // 203 // id - (String) An optional unique identifier for this doTimeout. If id is 204 // not specified, the doTimeout will NOT be able to be manually canceled or 205 // forced. 206 // delay - (Number) A zero-or-greater delay in milliseconds after which 207 // callback will be executed. 208 // callback - (Function) A function to be executed after delay milliseconds. 209 // callback - (String) A jQuery method to be executed after delay 210 // milliseconds. This method will only poll if it explicitly returns 211 // true. 212 // force_mode - (Boolean) If true, execute that id's doTimeout callback 213 // immediately and synchronously, continuing any callback return-true 214 // polling loop. If false, execute the callback immediately and 215 // synchronously but do NOT continue a callback return-true polling loop. 216 // If omitted, cancel that id's doTimeout. 217 // 218 // Returns: 219 // 220 // If force_mode is true, false or undefined and there is a 221 // yet-to-be-executed callback to cancel, true is returned, but if no 222 // callback remains to be executed, undefined is returned. 223 224 $[doTimeout] = function() { 225 return p_doTimeout.apply( window, [ 0 ].concat( aps.call( arguments ) ) ); 226 }; 227 228 // Method: jQuery.fn.doTimeout 229 // 230 // Initialize, cancel, or force execution of a callback after a delay. 231 // Operates like <jQuery.doTimeout>, but the passed callback executes in the 232 // context of the jQuery collection of elements, and the id is stored as data 233 // on the first element in that collection. 234 // 235 // If delay and callback are specified, a doTimeout is initialized. The 236 // callback will execute, asynchronously, after the delay. If an id is 237 // specified, this doTimeout will override and cancel any existing doTimeout 238 // with the same id. Any additional arguments will be passed into callback 239 // when it is executed. 240 // 241 // If the callback returns true, the doTimeout loop will execute again, after 242 // the delay, creating a polling loop until the callback returns a non-true 243 // value. 244 // 245 // Note that if an id is not passed as the first argument, this doTimeout will 246 // NOT be able to be manually canceled or forced (for debouncing, be sure to 247 // specify an id). 248 // 249 // If id is specified, but delay and callback are not, the doTimeout will be 250 // canceled without executing the callback. If force_mode is specified, the 251 // callback will be executed, synchronously, but will only be allowed to 252 // continue a polling loop if force_mode is true (provided the callback 253 // returns true, of course). If force_mode is false, no polling loop will 254 // continue, even if the callback returns true. 255 // 256 // Usage: 257 // 258 // > jQuery('selector').doTimeout( [ id, ] delay, callback [, arg ... ] ); 259 // > jQuery('selector').doTimeout( id [, force_mode ] ); 260 // 261 // Arguments: 262 // 263 // id - (String) An optional unique identifier for this doTimeout, stored as 264 // jQuery data on the element. If id is not specified, the doTimeout will 265 // NOT be able to be manually canceled or forced. 266 // delay - (Number) A zero-or-greater delay in milliseconds after which 267 // callback will be executed. 268 // callback - (Function) A function to be executed after delay milliseconds. 269 // callback - (String) A jQuery.fn method to be executed after delay 270 // milliseconds. This method will only poll if it explicitly returns 271 // true (most jQuery.fn methods return a jQuery object, and not `true`, 272 // which allows them to be chained and prevents polling). 273 // force_mode - (Boolean) If true, execute that id's doTimeout callback 274 // immediately and synchronously, continuing any callback return-true 275 // polling loop. If false, execute the callback immediately and 276 // synchronously but do NOT continue a callback return-true polling loop. 277 // If omitted, cancel that id's doTimeout. 278 // 279 // Returns: 280 // 281 // When creating a <jQuery.fn.doTimeout>, the initial jQuery collection of 282 // elements is returned. Otherwise, if force_mode is true, false or undefined 283 // and there is a yet-to-be-executed callback to cancel, true is returned, 284 // but if no callback remains to be executed, undefined is returned. 285 286 $.fn[doTimeout] = function() { 287 var args = aps.call( arguments ), 288 result = p_doTimeout.apply( this, [ doTimeout + args[0] ].concat( args ) ); 289 290 return typeof args[0] === 'number' || typeof args[1] === 'number' 291 ? this 292 : result; 293 }; 294 295 function p_doTimeout( jquery_data_key ) { 296 var that = this, 297 elem, 298 data = {}, 299 300 // Allows the plugin to call a string callback method. 301 method_base = jquery_data_key ? $.fn : $, 302 303 // Any additional arguments will be passed to the callback. 304 args = arguments, 305 slice_args = 4, 306 307 id = args[1], 308 delay = args[2], 309 callback = args[3]; 310 311 if ( typeof id !== 'string' ) { 312 slice_args--; 313 314 id = jquery_data_key = 0; 315 delay = args[1]; 316 callback = args[2]; 317 } 318 319 // If id is passed, store a data reference either as .data on the first
320 // element in a jQuery collection, or in the internal cache. 321 if ( jquery_data_key ) { // Note: key is 'doTimeout' + id 322 323 // Get id-object from the first element's data, otherwise initialize it to {}. 324 elem = that.eq(0); 325 elem.data( jquery_data_key, data = elem.data( jquery_data_key ) || {} ); 326 327 } else if ( id ) { 328 // Get id-object from the cache, otherwise initialize it to {}. 329 data = cache[ id ] || ( cache[ id ] = {} ); 330 } 331 332 // Clear any existing timeout for this id. 333 data.id && clearTimeout( data.id ); 334 delete data.id; 335 336 // Clean up when necessary. 337 function cleanup() { 338 if ( jquery_data_key ) { 339 elem.removeData( jquery_data_key ); 340 } else if ( id ) { 341 delete cache[ id ]; 342 } 343 }; 344 345 // Yes, there actually is a setTimeout call in here! 346 function actually_setTimeout() { 347 data.id = setTimeout( function(){ data.fn(); }, delay ); 348 }; 349 350 if ( callback ) { 351 // A callback (and delay) were specified. Store the callback reference for 352 // possible later use, and then setTimeout. 353 data.fn = function( no_polling_loop ) { 354 355 // If the callback value is a string, it is assumed to be the name of a 356 // method on $ or $.fn depending on where doTimeout was executed. 357 if ( typeof callback === 'string' ) { 358 callback = method_base[ callback ]; 359 } 360 361 callback.apply( that, aps.call( args, slice_args ) ) === true && !no_polling_loop 362 363 // Since the callback returned true, and we're not specifically 364 // canceling a polling loop, do it again! 365 ? actually_setTimeout() 366 367 // Otherwise, clean up and quit. 368 : cleanup(); 369 }; 370 371 // Set that timeout! 372 actually_setTimeout(); 373 374 } else if ( data.fn ) { 375 // No callback passed. If force_mode (delay) is true, execute the data.fn 376 // callback immediately, continuing any callback return-true polling loop. 377 // If force_mode is false, execute the data.fn callback immediately but do 378 // NOT continue a callback return-true polling loop. If force_mode is 379 // undefined, simply clean up. Since data.fn was still defined, whatever 380 // was supposed to happen hadn't yet, so return true. 381 delay === undefined ? cleanup() : data.fn( delay === false ); 382 return true; 383 384 } else { 385 // Since no callback was passed, and data.fn isn't defined, it looks like 386 // whatever was supposed to happen already did. Clean up and quit! 387 cleanup(); 388 } 389 390 }; 391 392})(jQuery); 393 394 395 396 397//CSS3 Animate-it 398$('.animatedParent').appear(); 399$('.animatedClick').click(function(){ 400 var target = $(this).attr('data-target'); 401 402 403 if($(this).attr('data-sequence') != undefined){ 404 var firstId = $("."+target+":first").attr('data-id'); 405 var lastId = $("."+target+":last").attr('data-id'); 406 var number = firstId; 407 408 //Add or remove the class 409 if($("."+target+"[data-id="+ number +"]").hasClass('go')){ 410 $("."+target+"[data-id="+ number +"]").addClass('goAway'); 411 $("."+target+"[data-id="+ number +"]").removeClass('go'); 412 }else{ 413 $("."+target+"[data-id="+ number +"]").addClass('go'); 414 $("."+target+"[data-id="+ number +"]").removeClass('goAway'); 415 } 416 number ++; 417 delay = Number($(this).attr('data-sequence')); 418 $.doTimeout(delay, function(){ 419 console.log(lastId); 420 421 //Add or remove the class 422 if($("."+target+"[data-id="+ number +"]").hasClass('go')){ 423 $("."+target+"[data-id="+ number +"]").addClass('goAway'); 424 $("."+target+"[data-id="+ number +"]").removeClass('go'); 425 }else{ 426 $("."+target+"[data-id="+ number +"]").addClass('go'); 427 $("."+target+"[data-id="+ number +"]").removeClass('goAway'); 428 } 429 430 //increment 431 ++number; 432 433 //continute looping till reached last ID 434 if(number <= lastId){return true;} 435 }); 436 }else{ 437 if($('.'+target).hasClass('go')){ 438 $('.'+target).addClass('goAway'); 439 $('.'+target).removeClass('go'); 440 }else{ 441 $('.'+target).addClass('go'); 442 $('.'+target).removeClass('goAway'); 443 } 444 } 445}); 446 447$(document.body).on('appear', '.animatedParent', function(e, $affected){ 448 var ele = $(this).find('.animated'); 449 var parent = $(this); 450 451 452 if(parent.attr('data-sequence') != undefined){ 453 454 var firstId = $(this).find('.animated:first').attr('data-id'); 455 var number = firstId; 456 var lastId = $(this).find('.animated:last').attr('data-id'); 457 458 $(parent).find(".animated[data-id="+ number +"]").addClass('go'); 459 number ++;
460 delay = Number(parent.attr('data-sequence')); 461 462 $.doTimeout(delay, function(){ 463 $(parent).find(".animated[data-id="+ number +"]").addClass('go'); 464 ++number; 465 if(number <= lastId){return true;} 466 }); 467 }else{ 468 ele.addClass('go'); 469 } 470 471}); 472 473 $(document.body).on('disappear', '.animatedParent', function(e, $affected) { 474 if(!$(this).hasClass('animateOnce')){ 475 $(this).find('.animated').removeClass('go'); 476 } 477 }); 478 479 $(window).on('load',function(){ 480 $.force_appear(); 481 });
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.