Revert "Retinajs patched version"
After this change retina styles applied on every device
This reverts commit d8de9fdddf
This commit is contained in:
parent
d8de9fdddf
commit
2eae55e04a
|
@ -6,6 +6,7 @@
|
|||
"requirejs-text": "2.0.10",
|
||||
"require-css": "0.1.0",
|
||||
"lodash": "1.1.1",
|
||||
"retina.js": "1.1.0",
|
||||
"autoNumeric": "http://github.com/BobKnothe/autoNumeric/zipball/1.9.12",
|
||||
"jquery.timeout": "http://jquery-timeout.googlecode.com/files/jquery.timeout-1.1.0.js",
|
||||
"backbone.stickit": "https://raw.github.com/NYTimes/backbone.stickit/7437202ec91863aa29a6ad31b0bd00c6b130f506/backbone.stickit.js",
|
||||
|
@ -26,6 +27,9 @@
|
|||
"lodash": {
|
||||
"js": "lodash.js"
|
||||
},
|
||||
"retina.js": {
|
||||
"js": "src/retina.js"
|
||||
},
|
||||
"autoNumeric": {
|
||||
"js": "autoNumeric.js"
|
||||
},
|
||||
|
|
|
@ -1,2 +1 @@
|
|||
@import 'main.css';
|
||||
@import 'retina.css';
|
|
@ -1,119 +0,0 @@
|
|||
(function() {
|
||||
var root = (typeof exports == 'undefined' ? window : exports);
|
||||
var config = {
|
||||
cssPath: "/static/css/retina.css",
|
||||
// Ensure Content-Type is an image before trying to load @2x image
|
||||
// https://github.com/imulus/retinajs/pull/45)
|
||||
check_mime_type: true
|
||||
};
|
||||
root.Retina = Retina;
|
||||
function Retina() {}
|
||||
Retina.configure = function(options) {
|
||||
if (options == null) options = {};
|
||||
for (var prop in options) config[prop] = options[prop];
|
||||
};
|
||||
Retina.init = function(context) {
|
||||
if (context == null) context = root;
|
||||
|
||||
var existing_onload = context.onload || new Function;
|
||||
|
||||
var head = document.head;//.getElementsByTagName('head')[0];
|
||||
head.innerHTML += "<link id='retinacss' href='" + config.cssPath + "' type='text/css' rel='stylesheet' />";
|
||||
|
||||
context.onload = function() {
|
||||
var images = document.getElementsByTagName("img"), retinaImages = [], i, image;
|
||||
for (i = 0; i < images.length; i++) {
|
||||
image = images[i];
|
||||
retinaImages.push(new RetinaImage(image));
|
||||
}
|
||||
existing_onload();
|
||||
}
|
||||
};
|
||||
Retina.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 (root.devicePixelRatio > 1)
|
||||
return true;
|
||||
|
||||
if (root.matchMedia && root.matchMedia(mediaQuery).matches)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
};
|
||||
root.RetinaImagePath = RetinaImagePath;
|
||||
function RetinaImagePath(path, at_2x_path) {
|
||||
this.path = path;
|
||||
if (typeof at_2x_path !== "undefined" && at_2x_path !== null) {
|
||||
this.at_2x_path = at_2x_path;
|
||||
this.perform_check = false;
|
||||
} else {
|
||||
this.at_2x_path = path.replace(/\.\w+$/, function(match) { return "@2x" + match; });
|
||||
this.perform_check = true;
|
||||
}
|
||||
}
|
||||
RetinaImagePath.confirmed_paths = [];
|
||||
RetinaImagePath.prototype.is_external = function() {
|
||||
return !!(this.path.match(/^https?\:/i) && !this.path.match('//' + document.domain) )
|
||||
}
|
||||
RetinaImagePath.prototype.check_2x_variant = function(callback) {
|
||||
var http, that = this;
|
||||
if (this.is_external()) {
|
||||
return callback(false);
|
||||
} else if (!this.perform_check && typeof this.at_2x_path !== "undefined" && this.at_2x_path !== null) {
|
||||
return callback(true);
|
||||
} else if (this.at_2x_path in RetinaImagePath.confirmed_paths) {
|
||||
return callback(true);
|
||||
} else {
|
||||
http = new XMLHttpRequest;
|
||||
http.open('HEAD', this.at_2x_path);
|
||||
http.onreadystatechange = function() {
|
||||
if (http.readyState != 4) {
|
||||
return callback(false);
|
||||
}
|
||||
if (http.status >= 200 && http.status <= 399) {
|
||||
if (config.check_mime_type) {
|
||||
var type = http.getResponseHeader('Content-Type');
|
||||
if (type == null || !type.match(/^image/i)) {
|
||||
return callback(false);
|
||||
}
|
||||
}
|
||||
RetinaImagePath.confirmed_paths.push(that.at_2x_path);
|
||||
return callback(true);
|
||||
} else {
|
||||
return callback(false);
|
||||
}
|
||||
}
|
||||
http.send();
|
||||
}
|
||||
}
|
||||
function RetinaImage(el) {
|
||||
this.el = el;
|
||||
this.path = new RetinaImagePath(this.el.getAttribute('src'), this.el.getAttribute('data-at2x'));
|
||||
var that = this;
|
||||
this.path.check_2x_variant(function(hasVariant) {
|
||||
if (hasVariant) that.swap();
|
||||
});
|
||||
}
|
||||
root.RetinaImage = RetinaImage;
|
||||
RetinaImage.prototype.swap = function(path) {
|
||||
if (typeof path == 'undefined') path = this.path.at_2x_path;
|
||||
|
||||
var that = this;
|
||||
function load() {
|
||||
if (! that.el.complete) {
|
||||
setTimeout(load, 5);
|
||||
} else {
|
||||
that.el.setAttribute('width', that.el.offsetWidth);
|
||||
that.el.setAttribute('height', that.el.offsetHeight);
|
||||
that.el.setAttribute('src', path);
|
||||
}
|
||||
}
|
||||
load();
|
||||
}
|
||||
if (Retina.isRetina()) {
|
||||
Retina.init(root);
|
||||
}
|
||||
})();
|
|
@ -30,7 +30,7 @@ requirejs.config({
|
|||
coccyx: 'js/libs/custom/coccyx',
|
||||
bootstrap: 'js/libs/custom/bootstrap.min',
|
||||
text: 'js/libs/bower/requirejs-text/js/text',
|
||||
retina: 'js/libs/custom/retina',
|
||||
retina: 'js/libs/bower/retina.js/js/retina',
|
||||
i18next: 'js/libs/bower/i18next/js/i18next-1.7.1',
|
||||
underscore: 'js/libs/bower/lodash/js/lodash',
|
||||
deepModel: 'js/libs/bower/backbone-deep-model/js/deep-model',
|
||||
|
|
Loading…
Reference in New Issue