diff --git a/src/gulpfile.js b/src/gulpfile.js index c480210..2b41502 100644 --- a/src/gulpfile.js +++ b/src/gulpfile.js @@ -16,7 +16,7 @@ var catchError = function(err) { paths.view = { js: [ 'bower_components/jQuery/dist/jquery.min.js', - '../src/scripts/_frameworks.js', + '../src/scripts/_gup.js', '../src/scripts/view/main.js' ], coffee: [ diff --git a/src/scripts/_frameworks.js b/src/scripts/_frameworks.js deleted file mode 100755 index 39ac35a..0000000 --- a/src/scripts/_frameworks.js +++ /dev/null @@ -1,8 +0,0 @@ -/* Browser Detection */ -var BrowserDetect={init:function(){this.browser=this.searchString(this.dataBrowser)||"An unknown browser";this.version=this.searchVersion(navigator.userAgent)||this.searchVersion(navigator.appVersion)||"an unknown version";this.OS=this.searchString(this.dataOS)||"an unknown OS"},searchString:function(d){for(var a=0;a1){this.each(function(){var e=a(this);if(this.tagName.toLowerCase()=="img"&&e.attr("src")){var g=e.attr("src").replace(/\.(?!.*\.)/,d["retina-suffix"]+".");b(g,function(h){e.attr("src",h.src);var i=a("
").append(e.clone()).remove().html();if(!(/(width|height)=["']\d+["']/.test(i))){e.attr("width",h.width/2) -}})}if(d["retina-background"]){var f=e.css("background-image");if(/^url\(.*\)$/.test(f)){var g=f.substring(4,f.length-1).replace(/\.(?!.*\.)/,d["retina-suffix"]+".");b(g,function(h){e.css("background-image","url("+h.src+")");if(e.css("background-size")=="auto auto"){e.css("background-size",(h.width/2)+"px auto")}})}}})}}})(jQuery); \ No newline at end of file diff --git a/src/scripts/_gup.js b/src/scripts/_gup.js new file mode 100644 index 0000000..5ca85c3 --- /dev/null +++ b/src/scripts/_gup.js @@ -0,0 +1,12 @@ +function gup(b) { + + b = b.replace(/[\[]/, "\\[").replace(/[\]]/, "\\]"); + + var a = "[\\?&]" + b + "=([^&#]*)", + d = new RegExp(a), + c = d.exec(window.location.href); + + if (c === null) return ''; + else return c[1]; + +}; \ No newline at end of file diff --git a/src/scripts/_retina.js b/src/scripts/_retina.js new file mode 100755 index 0000000..9252836 --- /dev/null +++ b/src/scripts/_retina.js @@ -0,0 +1,46 @@ +/*! jQuery Retina Plugin */ +(function(a) { + a.fn.retina = function(c) { + var d = { + "retina-background": false, + "retina-suffix": "@2x" + }; + if (c) { + a.extend(d, c) + } + var b = function(f, g) { + var e = new Image(); + e.onload = function() { + g(e) + }; + e.src = f + }; + if (window.devicePixelRatio > 1) { + this.each(function() { + var e = a(this); + if (this.tagName.toLowerCase() == "img" && e.attr("src")) { + var g = e.attr("src").replace(/\.(?!.*\.)/, d["retina-suffix"] + "."); + b(g, function(h) { + e.attr("src", h.src); + var i = a("
").append(e.clone()).remove().html(); + if (!(/(width|height)=["']\d+["']/.test(i))) { + e.attr("width", h.width / 2) + } + }) + } + if (d["retina-background"]) { + var f = e.css("background-image"); + if (/^url\(.*\)$/.test(f)) { + var g = f.substring(4, f.length - 1).replace(/\.(?!.*\.)/, d["retina-suffix"] + "."); + b(g, function(h) { + e.css("background-image", "url(" + h.src + ")"); + if (e.css("background-size") == "auto auto") { + e.css("background-size", (h.width / 2) + "px auto") + } + }) + } + } + }) + } + } +})(jQuery); \ No newline at end of file