1/* 2 3Quicksand 1.6.0 4 5Reorder and filter items with a nice shuffling animation. 6 7Copyright (c) 2010 Jacek Galanciak (razorjack.net) 8Big thanks for Piotr Petrus (riddle.pl) for deep code review and wonderful docs & demos. 9 10Dual licensed under the MIT and GPL version 2 licenses. 11https://raw.githubusercontent.com/razorjack/quicksand/master/MIT-LICENSE.txt 12https://raw.githubusercontent.com/razorjack/quicksand/master/GPL-LICENSE.txt 13 14Project site: https://razorjack.net/quicksand 15Github site: https://github.com/razorjack/quicksand 16 17 */ 18 19// Uses CommonJS, AMD or browser globals to create a jQuery plugin. 20(function (factory) { 21 if (typeof define === 'function' && define.amd) { 22 // AMD. Register as an anonymous module. 23 define(['jquery'], factory); 24 } else if (typeof module === 'object' && module.exports) { 25 // Node/CommonJS 26 module.exports = function( root, jQuery ) { 27 if ( jQuery === undefined ) { 28 // require('jQuery') returns a factory that requires window to 29 // build a jQuery instance, we normalize how we use modules 30 // that require this pattern but the window provided is a noop 31 // if it's defined (how jquery works) 32 if ( typeof window !== 'undefined' ) { 33 jQuery = require('jquery'); 34 } 35 else { 36 jQuery = require('jquery')(root); 37 } 38 } 39 factory(jQuery); 40 return jQuery; 41 }; 42 } else { 43 // Browser globals 44 factory(jQuery); 45 } 46}(function ($) { 47 var cloneWithCanvases = function(jqueryObject) { 48 var clonedJqueryObject = jqueryObject.clone(true, true); 49 var canvases = jqueryObject.find('canvas'); 50 if (canvases.length) { 51 var clonedCanvases = clonedJqueryObject.find('canvas'); 52 clonedCanvases.each(function(index) { 53 var context = this.getContext('2d'); 54 context.drawImage(canvases.get(index), 0, 0); 55 }); 56 } 57 return clonedJqueryObject; 58 }; 59 60 $.fn.quicksand = function(collection, customOptions) { 61 var options = { 62 duration : 750, 63 easing : 'swing', 64 attribute : 'data-id', // attribute to recognize same items within source and dest 65 adjustHeight : 'call', // 'dynamic' animates height during shuffling (slow), 'call' adjusts it 66 // before or after the animation, false leaves height alone, 'auto' sets it to auto 67 adjustWidth : false, // 'dynamic' animates width during shuffling (slow), 68 // 'call' adjusts it before or after the animation, false leaves the width alone, 'auto' sets it to auto 69 useScaling : false, // enable it if you're using scaling effect 70 enhancement : function(c) {}, // Visual enhacement (eg. font replacement) function for cloned elements 71 selector : '> *', 72 atomic : false, 73 dx : 0, 74 dy : 0, 75 maxWidth : 0, 76 retainExisting : true // disable if you want the collection of items to be replaced completely by incoming items. 77 }; 78 79 $.extend(options, customOptions); 80 81 if ((typeof ($.transform) == 'undefined')) { 82 options.useScaling = false; 83 } 84 85 var callbackFunction; 86 if (typeof (arguments[1]) == 'function') { 87 callbackFunction = arguments[1]; 88 } else if (typeof (arguments[2] == 'function')) { 89 callbackFunction = arguments[2]; 90 } 91 92 var that = this; 93 return this.each(function(i) { 94 var val; 95 var animationQueue = []; // used to store all the animation params before starting the animation; 96 // solves initial animation slowdowns 97 var $collection; 98 if (typeof(options.attribute) == 'function') { 99 $collection = $(collection); 100 } else { 101 $collection = cloneWithCanvases($(collection).filter('[' + options.attribute + ']')); // destination (target) collection 102 } 103 var $sourceParent = $(this); // source, the visible container of source collection 104 var sourceHeight = $(this).css('height'); // used to keep height and document flow during the animation 105 var sourceWidth = $(this).css('width'); // used to keep width and document flow during the animation 106 var destHeight, destWidth; 107 var adjustHeightOnCallback = false; 108 var adjustWidthOnCallback = false; 109 var offset = $($sourceParent).offset(); // offset of visible container, used in animation calculations 110 var offsets = []; // coordinates of every source collection item 111 var $source = $(this).find(options.selector); // source collection items 112 var width = $($source).innerWidth(); // need for the responsive design 113 114 // Replace the collection and quit if IE6 115 if (navigator.userAgent.match(/msie [6]/i)) { 116 $sourceParent.html('').append($collection); 117 return; 118 } 119 120 // Gets called when any animation is finished 121 var postCallbackPerformed = 0; // prevents the function from being called more than one time 122 var postCallback = function() { 123 $(this).css('margin', '').css('position', '').css('top', '').css('left', '').css('opacity', ''); 124 if (!postCallbackPerformed) { 125 postCallbackPerformed = 1; 126 127 if (!options.atomic) { 128 // hack: used to be: $sourceParent.html($dest.html()); 129 // put target HTML into visible source container 130 // but new webkit builds cause flickering when replacing the collections 131 var $toDelete = $sourceParent.find(options.selector); 132 if (!options.retainExisting) {
133 $sourceParent.prepend($dest.find(options.selector)); 134 $toDelete.remove(); 135 } else { 136 // Avoid replacing elements because we may have already altered items in significant 137 // ways and it would be bad to have to do it again. (i.e. lazy load images) 138 // But $dest holds the correct ordering. So we must re-sequence items in $sourceParent to match. 139 var $keepElements = $([]); 140 $dest.find(options.selector).each(function(i) { 141 var $matchedElement = $([]); 142 if (typeof (options.attribute) == 'function') { 143 var val = options.attribute($(this)); 144 $toDelete.each(function() { 145 if (options.attribute(this) == val) { 146 $matchedElement = $(this); 147 return false; 148 } 149 }); 150 } else { 151 $matchedElement = $toDelete.filter( 152 '[' + options.attribute + '="'+ 153 $(this).attr(options.attribute) + '"]'); 154 } 155 if ($matchedElement.length > 0) { 156 // There is a matching element in the $toDelete list and in $dest 157 // list, so make sure it is in the right location within $sourceParent 158 // and put it in the list of elements we need to not delete. 159 $keepElements = $keepElements.add($matchedElement); 160 if (i === 0) { 161 $sourceParent.prepend($matchedElement); 162 } else { 163 $matchedElement.insertAfter($sourceParent.find(options.selector).get(i - 1)); 164 } 165 } 166 }); 167 // Remove whatever is remaining from the DOM 168 $toDelete.not($keepElements).remove(); 169 } 170 171 if (adjustHeightOnCallback) { 172 $sourceParent.css('height', destHeight); 173 } 174 if (adjustWidthOnCallback) { 175 $sourceParent.css('width', sourceWidth); 176 } 177 } 178 options.enhancement($sourceParent); // Perform custom visual enhancements on a newly replaced collection 179 if (typeof callbackFunction == 'function') { 180 callbackFunction.call(that); 181 } 182 } 183 184 if ('auto' === options.adjustHeight) { 185 $sourceParent.css('height', 'auto'); 186 } 187 188 if ('auto' === options.adjustWidth) { 189 $sourceParent.css('width', 'auto'); 190 } 191 }; 192 193 // Position: relative situations 194 var $correctionParent = $sourceParent.offsetParent(); 195 var correctionOffset = $correctionParent.offset(); 196 if ($correctionParent.css('position') == 'relative') { 197 if ($correctionParent.get(0).nodeName.toLowerCase() != 'body') { 198 correctionOffset.top += (parseFloat($correctionParent.css('border-top-width')) || 0); 199 correctionOffset.left += (parseFloat($correctionParent.css('border-left-width')) || 0); 200 } 201 } else { 202 correctionOffset.top -= (parseFloat($correctionParent.css('border-top-width')) || 0); 203 correctionOffset.left -= (parseFloat($correctionParent.css('border-left-width')) || 0); 204 correctionOffset.top -= (parseFloat($correctionParent.css('margin-top')) || 0); 205 correctionOffset.left -= (parseFloat($correctionParent.css('margin-left')) || 0); 206 } 207 208 // perform custom corrections from options (use when Quicksand fails to detect proper correction) 209 if (isNaN(correctionOffset.left)) { 210 correctionOffset.left = 0; 211 } 212 if (isNaN(correctionOffset.top)) { 213 correctionOffset.top = 0; 214 } 215 216 correctionOffset.left -= options.dx; 217 correctionOffset.top -= options.dy; 218 219 // keeps nodes after source container, holding their position 220 if (options.adjustHeight !== false) { 221 $sourceParent.css('height', $(this).height()); 222 } 223 if (options.adjustWidth !== false) { 224 $sourceParent.css('width', $(this).width()); 225 } 226 227 // get positions of source collections 228 $source.each(function(i) { 229 offsets[i] = $(this).offset(); 230 }); 231 232 // stops previous animations on source container 233 $(this).stop(); 234 var dx = 0; 235 var dy = 0; 236 $source.each(function(i) { 237 $(this).stop(); // stop animation of collection items 238 var rawObj = $(this).get(0); 239 if (rawObj.style.position == 'absolute') { 240 dx = -options.dx; 241 dy = -options.dy; 242 } else { 243 dx = options.dx; 244 dy = options.dy; 245 } 246 247 rawObj.style.position = 'absolute'; 248 rawObj.style.margin = '0'; 249 250 if (!options.adjustWidth) { 251 rawObj.style.width = (width + 'px'); // sets the width to the current element 252 // with even if it has been changed 253 // by a responsive design 254 } 255 256 rawObj.style.top = (offsets[i].top- parseFloat(rawObj.style.marginTop) - correctionOffset.top + dy) + 'px'; 257 rawObj.style.left = (offsets[i].left- parseFloat(rawObj.style.marginLeft) - correctionOffset.left + dx) + 'px'; 258 259 if (options.maxWidth > 0 && offsets[i].left > options.maxWidth) { 260 rawObj.style.display = 'none'; 261 } 262 }); 263 264 // create temporary container with destination collection 265 var $dest = cloneWithCanvases($($sourceParent)); 266 var rawDest = $dest.get(0); 267 rawDest.innerHTML = ''; 268 rawDest.setAttribute('id', ''); 269 rawDest.style.height = 'auto'; 270 rawDest.style.width = $sourceParent.width() + 'px'; 271 $dest.append($collection); 272 // Inserts node into HTML. Note that the node is under visible source container in the exactly same position 273 // The browser render all the items without showing them (opacity: 0.0) No offset calculations are needed, 274 // the browser just extracts position from underlayered destination items and sets animation to destination positions. 275 $dest.insertBefore($sourceParent); 276 $dest.css('opacity', 0.0); 277 rawDest.style.zIndex = -1; 278 279 rawDest.style.margin = '0'; 280 rawDest.style.position = 'absolute'; 281 rawDest.style.top = offset.top - correctionOffset.top + 'px'; 282 rawDest.style.left = offset.left - correctionOffset.left + 'px'; 283 284 if (options.adjustHeight === 'dynamic') { 285 // If destination container has different height than source container the height can be animated, 286 // adjusting it to destination height 287 $sourceParent.animate({ height : $dest.height() }, options.duration, options.easing); 288 } else if (options.adjustHeight === 'call') { 289 destHeight = $dest.height(); 290 if (parseFloat(sourceHeight) < parseFloat(destHeight)) { 291 // Adjust the height now so that the items don't move out of the container 292 $sourceParent.css('height', destHeight); 293 } else { 294 // Adjust later, on callback 295 adjustHeightOnCallback = true; 296 } 297 } 298 299 if (options.adjustWidth === 'dynamic') { 300 // If destination container has different width than source container the width can be animated, 301 // adjusting it to destination width
302 $sourceParent.animate({ width : $dest.width() }, options.duration, options.easing); 303 } else if (options.adjustWidth === 'call') { 304 destWidth = $dest.width(); 305 if (parseFloat(sourceWidth) < parseFloat(destWidth)) { 306 // Adjust the height now so that the items don't move out of the container 307 $sourceParent.css('width', destWidth); 308 } else { 309 // Adjust later, on callback 310 adjustWidthOnCallback = true; 311 } 312 } 313 314 // Now it's time to do shuffling animation. First of all, we need to identify same elements within 315 // source and destination collections 316 $source.each(function(i) { 317 var destElement = []; 318 if (typeof (options.attribute) == 'function') { 319 val = options.attribute($(this)); 320 $collection.each(function() { 321 if (options.attribute(this) == val) { 322 destElement = $(this); 323 return false; 324 } 325 }); 326 } else { 327 destElement = $collection.filter('[' + options.attribute + '="' + $(this).attr(options.attribute) + '"]'); 328 } 329 if (destElement.length) { 330 // The item is both in source and destination collections. It it's under different position, let's move it 331 if (!options.useScaling) { 332 animationQueue.push({ 333 element : $(this), dest : destElement, 334 style : { 335 top : $(this).offset().top, 336 left : $(this).offset().left, 337 opacity : "" 338 }, 339 animation : { 340 top : destElement.offset().top - correctionOffset.top, 341 left : destElement.offset().left - correctionOffset.left, 342 opacity : 1.0 343 } 344 }); 345 } else { 346 animationQueue.push({ 347 element : $(this), dest : destElement, 348 style : { 349 top : $(this).offset().top, 350 left : $(this).offset().left, 351 opacity : "" 352 }, 353 animation : { 354 top : destElement.offset().top - correctionOffset.top, 355 left : destElement.offset().left - correctionOffset.left, 356 opacity : 1.0, 357 transform : 'scale(1.0)' 358 } 359 }); 360 } 361 } else { 362 // The item from source collection is not present in destination collections. Let's remove it 363 if (!options.useScaling) { 364 animationQueue.push({ 365 element : $(this), 366 style : { 367 top : $(this).offset().top, 368 left : $(this).offset().left, 369 opacity : "" 370 }, 371 animation : { 372 opacity : '0.0' 373 } 374 }); 375 } else { 376 animationQueue.push({ 377 element : $(this), 378 style : { 379 top : $(this).offset().top, 380 left : $(this).offset().left, 381 opacity : "" 382 }, 383 animation : { 384 opacity : '0.0', 385 transform : 'scale(0.0)' 386 } 387 }); 388 } 389 } 390 }); 391 392 $collection.each(function(i) { 393 // Grab all items from target collection not present in visible source collection 394 var sourceElement = []; 395 var destElement = []; 396 if (typeof (options.attribute) == 'function') { 397 val = options.attribute($(this)); 398 $source.each(function() { 399 if (options.attribute(this) == val) { 400 sourceElement = $(this); 401 return false; 402 } 403 }); 404 405 $collection.each(function() { 406 if (options.attribute(this) == val) { 407 destElement = $(this); 408 return false; 409 } 410 }); 411 } else { 412 sourceElement = $source.filter('[' + options.attribute + '="' + $(this).attr(options.attribute) + '"]'); 413 destElement = $collection.filter('[' + options.attribute + '="' + $(this).attr(options.attribute) + '"]'); 414 } 415 416 var animationOptions; 417 if (sourceElement.length === 0 && destElement.length > 0) { 418 419 // No such element in source collection...
420 if (!options.useScaling) { 421 animationOptions = {opacity : '1.0'}; 422 } else { 423 animationOptions = {opacity : '1.0', transform : 'scale(1.0)'}; 424 } 425 426 // Let's create it 427 var d = cloneWithCanvases(destElement); 428 var rawDestElement = d.get(0); 429 rawDestElement.style.position = 'absolute'; 430 rawDestElement.style.margin = '0'; 431 432 if (!options.adjustWidth) { 433 // sets the width to the current element with even if it has been changed by a responsive design 434 rawDestElement.style.width = width + 'px'; 435 } 436 437 rawDestElement.style.top = destElement.offset().top - correctionOffset.top + 'px'; 438 rawDestElement.style.left = destElement.offset().left - correctionOffset.left + 'px'; 439 440 d.css('opacity', 0.0); // IE 441 442 if (options.useScaling) { 443 d.css("transform", "scale(0.0)"); 444 } 445 d.appendTo($sourceParent); 446 447 if (options.maxWidth === 0 || destElement.offset().left < options.maxWidth) { 448 animationQueue.push({element : $(d), dest : destElement,animation : animationOptions}); 449 } 450 } 451 }); 452 453 $dest.remove(); 454 if (!options.atomic) { 455 options.enhancement($sourceParent); // Perform custom visual enhancements during the animation 456 for (i = 0; i < animationQueue.length; i++) { 457 animationQueue[i].element.animate(animationQueue[i].animation, options.duration, options.easing, postCallback); 458 } 459 } else { 460 $toDelete = $sourceParent.find(options.selector); 461 $sourceParent.prepend($dest.find(options.selector)); 462 for (i = 0; i < animationQueue.length; i++) { 463 if (animationQueue[i].dest && animationQueue[i].style) { 464 var destElement = animationQueue[i].dest; 465 var destOffset = destElement.offset(); 466 467 destElement.css({ 468 position : 'relative', 469 top : (animationQueue[i].style.top - destOffset.top), 470 left : (animationQueue[i].style.left - destOffset.left) 471 }); 472 473 destElement.animate({top : "0", left : "0"}, 474 options.duration, 475 options.easing, 476 postCallback); 477 } else { 478 animationQueue[i].element.animate(animationQueue[i].animation, 479 options.duration, 480 options.easing, 481 postCallback); 482 } 483 } 484 $toDelete.remove(); 485 } 486 }); 487 }; 488}));; 489jQuery.noConflict();jQuery(document).ready(function($){function lightboxPhoto(){jQuery("a[rel^='prettyPhoto']").prettyPhoto({theme:'light_square',animation_speed:'fast',slideshow:5000,show_title:false,overlay_gallery:false,autoplay:true,keyboard_shortcuts:true,allow_resize:true,allow_expand:true,modal:true});} 490if(jQuery().prettyPhoto){lightboxPhoto();} 491if(jQuery().quicksand){var $data=jQuery(".portfolio-area").clone();jQuery('.portfolio-categ li').click(function(e){jQuery(".filter li").removeClass("active");var filterClass=jQuery(this).attr('class').split(' ').slice(-1)[0];if(filterClass=='all'){var $filteredData=$data.find('.portfolio-item2');}else{var $filteredData=$data.find('.portfolio-item2[data-type='+filterClass+']');} 492jQuery(".portfolio-area").quicksand($filteredData,{duration:1000,},function(){lightboxPhoto();});jQuery(this).addClass("active");return false;});}});; 493/*! 494* jquery.counterup.js 1.0 495* 496* Copyright 2013, Benjamin Intal http://gambit.ph @bfintal 497* Released under the GPL v2 License 498* 499* Date: Nov 26, 2013 500*/(function(e){"use strict";e.fn.counterUp=function(t){var n=e.extend({time:400,delay:10},t);return this.each(function(){var t=e(this),r=n,i=function(){var e=[],n=r.time/r.delay,i=t.text(),s=/[0-9]+,[0-9]+/.test(i);i=i.replace(/,/g,"");var o=/^[0-9]+$/.test(i),u=/^[0-9]+\.[0-9]+$/.test(i),a=u?(i.split(".")[1]||[]).length:0;for(var f=n;f>=1;f--){var l=parseInt(i/n*f);u&&(l=parseFloat(i/n*f).toFixed(a));if(s)while(/(\d+)(\d{3})/.test(l.toString()))l=l.toString().replace(/(\d+)(\d{3})/,"$1,$2");e.unshift(l)}t.data("counterup-nums",e);t.text("0");var c=function(){t.text(t.data("counterup-nums").shift());if(t.data("counterup-nums").length)setTimeout(t.data("counterup-func"),r.delay);else{delete t.data("counterup-nums");t.data("counterup-nums",null);t.data("counterup-func",null)}};t.data("counterup-func",c);setTimeout(t.data("counterup-func"),r.delay)};t.waypoint(i,{offset:"100%",triggerOnce:!0})})}})(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.