{:uriI"üfile:///Users/eduardodeoliveirazaghi/Projects/loldesign/loldesign_publisher/app/assets/javascripts/loldesign_publisher/libs/ui/gumby.retina.js?type=application/javascript&pipeline=self&id=0c65677a25105403b7ccdcad29dd843a61445d1b1b64acdcab1ef52be443ea35:ET:load_pathI"`/Users/eduardodeoliveirazaghi/Projects/loldesign/loldesign_publisher/app/assets/javascripts;T: filenameI"‡/Users/eduardodeoliveirazaghi/Projects/loldesign/loldesign_publisher/app/assets/javascripts/loldesign_publisher/libs/ui/gumby.retina.js;T: nameI"-loldesign_publisher/libs/ui/gumby.retina;T:logical_pathI"5loldesign_publisher/libs/ui/gumby.retina.self.js;T:content_typeI"application/javascript;T: sourceI"y/** * Gumby Retina */ !function($) { 'use strict'; function Retina($el) { Gumby.debug('Initializing Retina', $el); this.$el = $el; this.imageSrc = this.$el.attr('src'); this.retinaSrc = this.fetchRetinaImage(); this.$retinaImg = $(new Image()); var scope = this; // image src not valid if(!this.retinaSrc) { return false; } // load retina image this.$retinaImg.attr('src', this.retinaSrc).load(function() { scope.retinaImageLoaded(); }).error(function() { Gumby.error('Couln\'t load retina image: '+scope.retinaSrc); }); } // fetch retina src by appending '@2x' to image string before extension Retina.prototype.fetchRetinaImage = function() { var imgSrc = this.imageSrc, index = this.imageSrc.search(/(\.|\/)(gif|jpe?g|png)$/i); // image src is not valid if(index < 0) { return false; } // return retina src return imgSrc.substr(0, index) + '@2x' + imgSrc.substr(index, imgSrc.length); }; // once retina image loaded swap original src Retina.prototype.retinaImageLoaded = function() { Gumby.debug('Swapping image for retina version', this.$el); Gumby.debug('Triggering onRetina event', this.$el); this.$el.attr('src', this.$retinaImg.attr('src')).trigger('gumby.onRetina'); }; // add initialisation Gumby.addInitalisation('retina', function() { // this module is for retina devices only if(!window.devicePixelRatio || window.devicePixelRatio <= 1) { return; } $('img[data-retina],img[gumby-retina],img[retina]').each(function() { var $this = $(this); // this element has already been initialized if($this.data('isRetina')) { return true; } // mark element as initialized $this.data('isRetina', true); new Retina($this); }); }); // register UI module Gumby.UIModule({ module: 'retina', events: ['onRetina'], init: function() { Gumby.initialize('retina'); } }); }(jQuery); ;T: metadata{ :dependencieso:Set: @hash{ I"environment-version;TTI"environment-paths;TTI"Zprocessors:type=application/javascript&file_type=application/javascript&pipeline=self;TTI"•file-digest:///Users/eduardodeoliveirazaghi/Projects/loldesign/loldesign_publisher/app/assets/javascripts/loldesign_publisher/libs/ui/gumby.retina.js;TT: requiredo;;{: stubbedo;;{: linkso;;{: charsetI" utf-8;F: digest"%ÈÒ»†ñøùþz¥ ¹\ÁP¥¤çß~Ý‚/ôN¨µ: lengthiy:dependencies_digest"%ì„€nÐDˇ¨ôÜ<(V4tú;žÆs¡¿ÉÇ4ê;