1/** 2 * @name Shuffle Letters 3 * @author Martin Angelov 4 * @version 1.0 5 * @url http://tutorialzine.com/2011/09/shuffle-letters-effect-jquery/ 6 * @license MIT License 7 */ 8 9var $ = jQuery.noConflict(); 10 11 12 13 14 15 16$(document).ready(function() { 17 18 19 20 21 $.fn.shuffleLetters = function(prop){ 22 23 var options = $.extend({ 24 "step" : 8, // How many times should the letters be changed 25 "fps" : 25, // Frames Per Second 26 "text" : "", // Use this text instead of the contents 27 "callback" : function(){} // Run once the animation is complete 28 },prop) 29 30 return this.each(function(){ 31 32 var el = $(this), 33 str = ""; 34 35 36 // Preventing parallel animations using a flag; 37 38 if(el.data('animated')){ 39 return true; 40 } 41 42 el.data('animated',true); 43 44 45 if(options.text) { 46 str = options.text.split(''); 47 } 48 else { 49 str = el.text().split(''); 50 } 51 52 // The types array holds the type for each character; 53 // Letters holds the positions of non-space characters; 54 55 var types = [], 56 letters = []; 57 58 // Looping through all the chars of the string 59 60 for(var i=0;i<str.length;i++){ 61 62 var ch = str[i]; 63 64 if(ch == " "){ 65 types[i] = "space"; 66 continue; 67 } 68 else if(/[a-z]/.test(ch)){ 69 types[i] = "lowerLetter"; 70 } 71 else if(/[A-Z]/.test(ch)){ 72 types[i] = "upperLetter"; 73 } 74 else { 75 types[i] = "symbol"; 76 } 77 78 letters.push(i); 79 } 80 81 el.html(""); 82 83 // Self executing named function expression: 84 85 (function shuffle(start){ 86 87 // This code is run options.fps times per second 88 // and updates the contents of the page element 89 90 var i, 91 len = letters.length, 92 strCopy = str.slice(0); // Fresh copy of the string 93 94 if(start>len){ 95 96 // The animation is complete. Updating the 97 // flag and triggering the callback; 98 99 el.data('animated',false); 100 options.callback(el); 101 return; 102 } 103 104 // All the work gets done here 105 for(i=Math.max(start,0); i < len; i++){ 106 107 // The start argument and options.step limit 108 // the characters we will be working on at once 109 110 if( i < start+options.step){ 111 // Generate a random character at thsi position 112 strCopy[letters[i]] = randomChar(types[letters[i]]); 113 } 114 else { 115 strCopy[letters[i]] = ""; 116 } 117 } 118 119 el.text(strCopy.join("")); 120 121 setTimeout(function(){ 122 123 shuffle(start+1); 124 125 },1000/options.fps); 126 127 })(-options.step); 128 129 130 }); 131 }; 132 133 function randomChar(type){ 134 var pool = ""; 135 136 if (type == "lowerLetter"){ 137 pool = ""; 138 } 139 else if (type == "upperLetter"){ 140 pool = ""; 141 } 142 else if (type == "symbol"){ 143 pool = ""; 144 } 145 146 var arr = pool.split(''); 147 return arr[Math.floor(Math.random()*arr.length)]; 148 } 149 150}); 151 152 153 154 155$(document).ready(function() { 156 157 158 159 $(".shuffle h4 ,.vc_custom_heading.shuffle").each(function (i) { 160 161 162 163$(this) .waypoint(function() { 164 165 var container = $(this) ; 166 167 container.addClass("shuffle-start"); 168 169 170 container.shuffleLetters(); 171 172 173 }, { 174 triggerOnce: true, 175 offset: '90%' 176 }); 177 178 179 180 181 182}); 183 184 185 186 187 188 189 190 191 192 193 194 195 196 });
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.