New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

angular-retina

Package Overview
Dependencies
Maintainers
1
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

angular-retina - npm Package Compare versions

Comparing version 0.1.2 to 0.1.3

128

dist/angular-retina.js

@@ -1,70 +0,68 @@

/*! angular-retina - v0.1.2 - 2013-05-12
/*! angular-retina - v0.1.3 - 2013-05-29
* https://github.com/jrief/angular-retina
* Copyright (c) 2013 Jacob Rief; Licensed MIT */
(function(angular, undefined) {
'use strict';
angular.module('ngRetina', []).config(function($provide) {
$provide.decorator('ngSrcDirective', function($delegate) {
$delegate[0].compile = function(element, attrs) {
// intentionally empty to override the built-in directive ng-src
};
return $delegate;
});
})
.directive('ngSrc', function($window, $http, $cacheFactory) {
var cache = $cacheFactory('retinaImageURLs');
var msie = parseInt(((/msie (\d+)/.exec($window.navigator.userAgent.toLowerCase()) || [])[1]), 10);
var isRetina = (function() {
var mediaQuery = "(-webkit-min-device-pixel-ratio: 1.5), (min--moz-device-pixel-ratio: 1.5), " +
"(-o-min-device-pixel-ratio: 3/2), (min-resolution: 1.5dppx)";
if ($window.devicePixelRatio > 1)
return true;
return ($window.matchMedia && $window.matchMedia(mediaQuery).matches);
})();
function getHighResolutionURL(url) {
var parts = url.split('.');
if (parts.length < 2)
return url;
parts[parts.length - 2] += '@2x';
return parts.join('.');
}
return function(scope, element, attrs) {
function setImgSrc(img_url) {
attrs.$set('src', img_url);
if (msie) element.prop('src', img_url);
(function (angular, undefined) {
'use strict';
angular.module('ngRetina', []).config([
'$provide',
function ($provide) {
$provide.decorator('ngSrcDirective', function ($delegate) {
$delegate[0].compile = function (element, attrs) {
};
return $delegate;
});
}
function set2xVariant(img_url) {
var img_url_2x = cache.get(img_url);
if (img_url_2x === undefined) {
img_url_2x = getHighResolutionURL(img_url);
$http.head(img_url_2x).
success(function(data, status) {
setImgSrc(img_url_2x);
cache.put(img_url, img_url_2x);
}).
error(function(data, status, headers, config) {
setImgSrc(img_url);
cache.put(img_url, img_url);
]).directive('ngSrc', [
'$window',
'$http',
'$cacheFactory',
function ($window, $http, $cacheFactory) {
var cache = $cacheFactory('retinaImageURLs');
var msie = parseInt((/msie (\d+)/.exec($window.navigator.userAgent.toLowerCase()) || [])[1], 10);
var isRetina = function () {
var mediaQuery = '(-webkit-min-device-pixel-ratio: 1.5), (min--moz-device-pixel-ratio: 1.5), ' + '(-o-min-device-pixel-ratio: 3/2), (min-resolution: 1.5dppx)';
if ($window.devicePixelRatio > 1)
return true;
return $window.matchMedia && $window.matchMedia(mediaQuery).matches;
}();
function getHighResolutionURL(url) {
var parts = url.split('.');
if (parts.length < 2)
return url;
parts[parts.length - 2] += '@2x';
return parts.join('.');
}
return function (scope, element, attrs) {
function setImgSrc(img_url) {
attrs.$set('src', img_url);
if (msie)
element.prop('src', img_url);
}
function set2xVariant(img_url) {
var img_url_2x = cache.get(img_url);
if (img_url_2x === undefined) {
img_url_2x = getHighResolutionURL(img_url);
$http.head(img_url_2x).success(function (data, status) {
setImgSrc(img_url_2x);
cache.put(img_url, img_url_2x);
}).error(function (data, status, headers, config) {
setImgSrc(img_url);
cache.put(img_url, img_url);
});
} else {
setImgSrc(img_url_2x);
}
}
attrs.$observe('ngSrc', function (value) {
if (!value)
return;
if (isRetina) {
set2xVariant(value);
} else {
setImgSrc(value);
}
});
} else {
setImgSrc(img_url_2x);
}
};
}
attrs.$observe('ngSrc', function(value) {
if (!value)
return;
if (isRetina) {
set2xVariant(value);
} else {
setImgSrc(value);
}
});
};
});
})(window.angular);
]);
}(window.angular));

@@ -1,4 +0,4 @@

/*! angular-retina - v0.1.2 - 2013-05-12
/*! angular-retina - v0.1.3 - 2013-05-29
* https://github.com/jrief/angular-retina
* Copyright (c) 2013 Jacob Rief; Licensed MIT */
(function(n,e){"use strict";n.module("ngRetina",[]).config(function(n){n.decorator("ngSrcDirective",function(n){return n[0].compile=function(){},n})}).directive("ngSrc",function(n,i,t){function r(n){var e=n.split(".");return 2>e.length?n:(e[e.length-2]+="@2x",e.join("."))}var c=t("retinaImageURLs"),o=parseInt((/msie (\d+)/.exec(n.navigator.userAgent.toLowerCase())||[])[1],10),u=function(){var e="(-webkit-min-device-pixel-ratio: 1.5), (min--moz-device-pixel-ratio: 1.5), (-o-min-device-pixel-ratio: 3/2), (min-resolution: 1.5dppx)";return n.devicePixelRatio>1?!0:n.matchMedia&&n.matchMedia(e).matches}();return function(n,t,a){function s(n){a.$set("src",n),o&&t.prop("src",n)}function f(n){var t=c.get(n);t===e?(t=r(n),i.head(t).success(function(){s(t),c.put(n,t)}).error(function(){s(n),c.put(n,n)})):s(t)}a.$observe("ngSrc",function(n){n&&(u?f(n):s(n))})}})})(window.angular);
(function(e,n){"use strict";e.module("ngRetina",[]).config(["$provide",function(e){e.decorator("ngSrcDirective",function(e){return e[0].compile=function(){},e})}]).directive("ngSrc",["$window","$http","$cacheFactory",function(e,i,t){function r(e){var n=e.split(".");return 2>n.length?e:(n[n.length-2]+="@2x",n.join("."))}var c=t("retinaImageURLs"),o=parseInt((/msie (\d+)/.exec(e.navigator.userAgent.toLowerCase())||[])[1],10),a=function(){var n="(-webkit-min-device-pixel-ratio: 1.5), (min--moz-device-pixel-ratio: 1.5), (-o-min-device-pixel-ratio: 3/2), (min-resolution: 1.5dppx)";return e.devicePixelRatio>1?!0:e.matchMedia&&e.matchMedia(n).matches}();return function(e,t,u){function s(e){u.$set("src",e),o&&t.prop("src",e)}function d(e){var t=c.get(e);t===n?(t=r(e),i.head(t).success(function(){s(t),c.put(e,t)}).error(function(){s(e),c.put(e,e)})):s(t)}u.$observe("ngSrc",function(e){e&&(a?d(e):s(e))})}}])})(window.angular);

@@ -5,89 +5,102 @@ 'use strict';

// Project configuration.
grunt.initConfig({
// Metadata.
pkg: grunt.file.readJSON('package.json'),
banner: '/*! <%= pkg.name %> - v<%= pkg.version %> - ' +
'<%= grunt.template.today("yyyy-mm-dd") %>\n' +
'<%= pkg.homepage ? "* " + pkg.homepage + "\\n" : "" %>' +
'* Copyright (c) <%= grunt.template.today("yyyy") %> <%= pkg.author.name %>;' +
' Licensed <%= _.pluck(pkg.licenses, "type").join(", ") %> */\n',
// Task configuration.
concat: {
options: {
banner: '<%= banner %>',
stripBanners: true
},
dist: {
src: ['lib/<%= pkg.name %>.js'],
dest: 'dist/<%= pkg.name %>.js'
}
},
uglify: {
options: {
banner: '<%= banner %>'
},
dist: {
src: '<%= concat.dist.dest %>',
dest: 'dist/<%= pkg.name %>.min.js'
}
},
jshint: {
files: ['Gruntfile.js', 'lib/*.js'],
options: {
curly: false,
browser: true,
eqeqeq: true,
immed: true,
latedef: true,
newcap: true,
noarg: true,
sub: true,
undef: true,
boss: true,
eqnull: true,
expr: true,
node: true,
globals: {
exports: true,
angular: false,
$: false
}
}
},
karma: {
test: {
options: {
reporters: ['dots'],
browsers: ['Firefox'],
singleRun: true
}
},
options: {
configFile: 'test/karma.conf.js'
}
}
});
// Project configuration.
grunt.initConfig({
// Metadata.
pkg: grunt.file.readJSON('package.json'),
banner: '/*! <%= pkg.name %> - v<%= pkg.version %> - ' +
'<%= grunt.template.today("yyyy-mm-dd") %>\n' +
'<%= pkg.homepage ? "* " + pkg.homepage + "\\n" : "" %>' +
'* Copyright (c) <%= grunt.template.today("yyyy") %> <%= pkg.author.name %>;' +
' Licensed <%= _.pluck(pkg.licenses, "type").join(", ") %> */\n',
// Task configuration.
ngmin: {
dist: {
src: ['lib/<%= pkg.name %>.js'],
dest: 'dist/<%= pkg.name %>.js'
}
},
concat: {
options: {
banner: '<%= banner %>'
},
dist: {
src: '<%= ngmin.dist.dest %>',
dest: 'dist/<%= pkg.name %>.js'
}
},
uglify: {
options: {
banner: '<%= banner %>'
},
dist: {
src: '<%= concat.dist.dest %>',
dest: 'dist/<%= pkg.name %>.min.js'
}
},
jshint: {
files: ['Gruntfile.js', 'lib/*.js'],
options: {
curly: false,
browser: true,
eqeqeq: true,
immed: true,
latedef: true,
newcap: true,
noarg: true,
sub: true,
undef: true,
boss: true,
eqnull: true,
expr: true,
node: true,
globals: {
exports: true,
angular: false,
$: false
}
}
},
karma: {
test: {
options: {
browsers: ['Safari', 'Chrome', 'ChromeCanary', 'Firefox', 'Opera'],
singleRun: true
}
},
'travis-ci': {
options: {
browsers: ['Firefox'],
singleRun: true
}
},
options: {
reporters: ['dots'],
configFile: 'test/karma.conf.js'
}
}
});
// These plugins provide necessary tasks.
grunt.loadNpmTasks('grunt-contrib-concat');
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-contrib-jshint');
// These plugins provide necessary tasks.
grunt.loadNpmTasks('grunt-contrib-concat');
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-contrib-jshint');
grunt.loadNpmTasks('grunt-ngmin');
// Default task.
grunt.registerTask('default', ['test']);
// Default task.
grunt.registerTask('default', ['test']);
// Test tasks.
grunt.registerTask('test', ['jshint', 'karma:test']);
// Test tasks.
grunt.registerTask('test', ['jshint', 'karma:test']);
grunt.registerTask('travis-ci', ['jshint', 'karma:travis-ci']);
// Build task.
grunt.registerTask('build', ['test', 'concat', 'uglify']);
// Build task.
grunt.registerTask('build', ['test', 'ngmin', 'concat', 'uglify']);
// Provides the "karma" task.
grunt.registerMultiTask('karma', 'Starts up a karma server.', function() {
var done = this.async();
require('karma').server.start(this.options(), function(code) {
done(code === 0);
});
});
// Provides the "karma" task.
grunt.registerMultiTask('karma', 'Starts up a karma server.', function() {
var done = this.async();
require('karma').server.start(this.options(), function(code) {
done(code === 0);
});
});
};
{
"name": "angular-retina",
"description": "Replace AngularJS directive 'ng-src' by a version which supports Retina displays",
"version": "0.1.2",
"version": "0.1.3",
"homepage": "https://github.com/jrief/angular-retina",

@@ -35,5 +35,6 @@ "author": {

"grunt-contrib-jshint": "latest",
"grunt-contrib-uglify": "latest"
"grunt-contrib-uglify": "latest",
"grunt-ngmin": "0.0.2"
},
"keywords": []
}

@@ -13,2 +13,4 @@ # angular-retina

```npm install angular-retina```
[min]: https://raw.github.com/jrief/angular-retina/master/dist/angular-retina.min.js

@@ -22,6 +24,8 @@ [max]: https://raw.github.com/jrief/angular-retina/master/dist/angular-retina.js

```html
<script src="//ajax.googleapis.com/ajax/libs/angularjs/1.1.3/angular.min.js"></script>
<script src="//ajax.googleapis.com/ajax/libs/angularjs/1.1.4/angular.min.js"></script>
<script src="/path/to/your/javascript-files/angular-retina.min.js"></script>
```
Please note, that *angular-retina* requires ```angularjs-1.1.3``` or later.
+ and in your main JavaScript file:

@@ -28,0 +32,0 @@

@@ -126,3 +126,3 @@ 'use strict';

beforeEach(inject(function($injector, $rootScope) {
beforeEach(inject(function($rootScope) {
scope = $rootScope.$new();

@@ -129,0 +129,0 @@ }));

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc