Splited _frameworks.js

This commit is contained in:
Tobias Reich 2015-01-29 23:10:12 +01:00
parent 4fd41b224a
commit 988f41ef1a
4 changed files with 59 additions and 9 deletions

View File

@ -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: [

View File

@ -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;a<d.length;a++){var b=d[a].string;var c=d[a].prop;this.versionSearchString=d[a].versionSearch||d[a].identity;if(b){if(b.indexOf(d[a].subString)!=-1){return d[a].identity}}else{if(c){return d[a].identity}}}},searchVersion:function(b){var a=b.indexOf(this.versionSearchString);if(a==-1){return}return parseFloat(b.substring(a+this.versionSearchString.length+1))},dataBrowser:[{string:navigator.userAgent,subString:"Chrome",identity:"Chrome"},{string:navigator.userAgent,subString:"OmniWeb",versionSearch:"OmniWeb/",identity:"OmniWeb"},{string:navigator.vendor,subString:"Apple",identity:"Safari",versionSearch:"Version"},{prop:window.opera,identity:"Opera"},{string:navigator.vendor,subString:"iCab",identity:"iCab"},{string:navigator.vendor,subString:"KDE",identity:"Konqueror"},{string:navigator.userAgent,subString:"Firefox",identity:"Firefox"},{string:navigator.vendor,subString:"Camino",identity:"Camino"},{string:navigator.userAgent,subString:"Netscape",identity:"Netscape"},{string:navigator.userAgent,subString:"MSIE",identity:"Explorer",versionSearch:"MSIE"},{string:navigator.userAgent,subString:"Gecko",identity:"Mozilla",versionSearch:"rv"},{string:navigator.userAgent,subString:"Mozilla",identity:"Netscape",versionSearch:"Mozilla"}],dataOS:[{string:navigator.platform,subString:"Win",identity:"Windows"},{string:navigator.platform,subString:"Mac",identity:"Mac"},{string:navigator.userAgent,subString:"iPhone",identity:"iPhone/iPod"},{string:navigator.platform,subString:"Linux",identity:"Linux"}]};BrowserDetect.init();
function mobileBrowser() { if (/Android|webOS|iPhone|iPad|iPod|BlackBerry/i.test(navigator.userAgent)) return true; else return false; }
/* GET */
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]}};
/*! 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("<div>").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);

12
src/scripts/_gup.js Normal file
View File

@ -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];
};

46
src/scripts/_retina.js Executable file
View File

@ -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("<div>").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);