mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
MINOR Removed unused functionality from prototype_improvements.js
This commit is contained in:
parent
e59976bb64
commit
ce4f456fc7
184
javascript/prototype_improvements.js
vendored
184
javascript/prototype_improvements.js
vendored
@ -11,24 +11,6 @@ if(typeof $$ != "Function") {
|
|||||||
$$ = document.getElementsBySelector;
|
$$ = document.getElementsBySelector;
|
||||||
}
|
}
|
||||||
|
|
||||||
var SS_DEFAULT_ISO = "en_GB";
|
|
||||||
|
|
||||||
Object.extend(Element, {
|
|
||||||
setStyle: function(element, styles, camelized) {
|
|
||||||
element = $(element);
|
|
||||||
var elementStyle = element.style;
|
|
||||||
|
|
||||||
for (var property in styles)
|
|
||||||
if (property == 'opacity') element.setOpacity(styles[property])
|
|
||||||
else
|
|
||||||
elementStyle[(property == 'float' || property == 'cssFloat') ?
|
|
||||||
(elementStyle.styleFloat === undefined ? 'cssFloat' : 'styleFloat') :
|
|
||||||
(camelized ? property : property.camelize())] = styles[property];
|
|
||||||
|
|
||||||
return element;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
// This code is in the public domain. Feel free to link back to http://jan.moesen.nu/
|
// This code is in the public domain. Feel free to link back to http://jan.moesen.nu/
|
||||||
function sprintf()
|
function sprintf()
|
||||||
{
|
{
|
||||||
@ -84,60 +66,6 @@ function sprintf()
|
|||||||
return str;
|
return str;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Use Firebug-like debugging in non-Firefox-browsers
|
|
||||||
* @see http://wish.hu/firebug-on-explorer
|
|
||||||
*/
|
|
||||||
if (!window.console) {
|
|
||||||
window.console = {
|
|
||||||
timers: {},
|
|
||||||
openwin: function() {
|
|
||||||
window.top.debugWindow =
|
|
||||||
window.open("",
|
|
||||||
"Debug",
|
|
||||||
"left=0,top=0,width=300,height=700,scrollbars=yes,"
|
|
||||||
+"status=yes,resizable=yes");
|
|
||||||
window.top.debugWindow.opener = self;
|
|
||||||
window.top.debugWindow.document.open();
|
|
||||||
window.top.debugWindow.document.write('<html><head><title>debug window</title></head><body><hr><pre>');
|
|
||||||
},
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Caution: Excludes functions in listing
|
|
||||||
*/
|
|
||||||
log: function() {
|
|
||||||
if(Debug.isLive()) return;
|
|
||||||
|
|
||||||
if(!window.top.debugWindow) {
|
|
||||||
console.openwin();
|
|
||||||
}
|
|
||||||
|
|
||||||
var i = 0; content = "";
|
|
||||||
if(arguments.length == 1 && typeof arguments[0] != "object") {
|
|
||||||
content = arguments[0];
|
|
||||||
} else if(arguments.length > 1 && typeof arguments[0] == "string"){
|
|
||||||
content = sprintf(arguments[0], Array.prototype.slice.call(arguments, 1));
|
|
||||||
}
|
|
||||||
|
|
||||||
if(window.top.debugWindow.document) {
|
|
||||||
window.top.debugWindow.document.write(content+"\n");
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
debug: this.log,
|
|
||||||
|
|
||||||
time: function(title) {
|
|
||||||
window.console.timers[title] = new Date().getTime();
|
|
||||||
},
|
|
||||||
|
|
||||||
timeEnd: function(title) {
|
|
||||||
var time = new Date().getTime() - window.console.timers[title];
|
|
||||||
console.log(['<strong>', title, '</strong>: ', time, 'ms'].join(''));
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Number.prototype.CURRENCIES = {
|
Number.prototype.CURRENCIES = {
|
||||||
en_GB: '$ ###,###.##'
|
en_GB: '$ ###,###.##'
|
||||||
};
|
};
|
||||||
@ -163,114 +91,4 @@ Number.prototype.toCurrency = function(iso) {
|
|||||||
String.prototype.ucfirst = function () {
|
String.prototype.ucfirst = function () {
|
||||||
var firstLetter = this.substr(0,1).toUpperCase()
|
var firstLetter = this.substr(0,1).toUpperCase()
|
||||||
return this.substr(0,1).toUpperCase() + this.substr(1,this.length);
|
return this.substr(0,1).toUpperCase() + this.substr(1,this.length);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Show debug-information in the javascript-console or a popup.
|
|
||||||
* Only shows output on dev- or test-environments.
|
|
||||||
* Caution: Behaves like a static class (no prototype methods)
|
|
||||||
*/
|
|
||||||
Debug = Class.create();
|
|
||||||
Debug = {
|
|
||||||
|
|
||||||
environment_type: "live",
|
|
||||||
|
|
||||||
initialize: function() {
|
|
||||||
if(window.location.href.match(/\?(.*)debug_javascript/)) {
|
|
||||||
this.environment_type = "dev";
|
|
||||||
}
|
|
||||||
if(window.location.href.match(/\?(.*)debug_behaviour/)) {
|
|
||||||
Behaviour.debug();
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param type string "live", "test" or "dev"
|
|
||||||
*/
|
|
||||||
set_environment_type: function(type) {
|
|
||||||
this.environment_type = type;
|
|
||||||
},
|
|
||||||
|
|
||||||
isDev: function() {
|
|
||||||
return (window.location.href.match(/test\.|dev\./) || this.environment_type == "dev" || this.environment_type == "test");
|
|
||||||
},
|
|
||||||
|
|
||||||
isTest: function() {
|
|
||||||
return (window.location.href.match(/test\./) || this.environment_type == "test");
|
|
||||||
},
|
|
||||||
|
|
||||||
isLive: function() {
|
|
||||||
return !Debug.isDev();
|
|
||||||
},
|
|
||||||
|
|
||||||
show: function() {
|
|
||||||
if(this.isDev() || this.isTest()) {
|
|
||||||
console.debug.apply(console, arguments);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
debug: this.debug,
|
|
||||||
|
|
||||||
log: function() {
|
|
||||||
if(this.isDev() || this.isTest()) {
|
|
||||||
console.log.apply(console, arguments);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Debug.initialize();
|
|
||||||
|
|
||||||
// Flash plugin version detection from SWFObject
|
|
||||||
// http://blog.deconcept.com/swfobject/
|
|
||||||
getFlashPlayerVersion = function(){
|
|
||||||
var pv = new PlayerVersion([0,0,0]);
|
|
||||||
if(navigator.plugins && navigator.mimeTypes.length){
|
|
||||||
var x = navigator.plugins["Shockwave Flash"];
|
|
||||||
if(x && x.description) {
|
|
||||||
pv = new PlayerVersion(x.description.replace(/([a-zA-Z]|\s)+/, "").replace(/(\s+r|\s+b[0-9]+)/, ".").split("."));
|
|
||||||
}
|
|
||||||
}else if (navigator.userAgent && navigator.userAgent.indexOf("Windows CE") >= 0){ // if Windows CE
|
|
||||||
var axo = 1;
|
|
||||||
var counter = 3;
|
|
||||||
while(axo) {
|
|
||||||
try {
|
|
||||||
counter++;
|
|
||||||
axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash."+ counter);
|
|
||||||
// document.write("player v: "+ counter);
|
|
||||||
pv = new PlayerVersion([counter,0,0]);
|
|
||||||
} catch (e) {
|
|
||||||
axo = null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else { // Win IE (non mobile)
|
|
||||||
// do minor version lookup in IE, but avoid fp6 crashing issues
|
|
||||||
// see http://blog.deconcept.com/2006/01/11/getvariable-setvariable-crash-internet-explorer-flash-6/
|
|
||||||
try{
|
|
||||||
var axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.7");
|
|
||||||
}catch(e){
|
|
||||||
try {
|
|
||||||
var axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.6");
|
|
||||||
pv = new PlayerVersion([6,0,21]);
|
|
||||||
axo.AllowScriptAccess = "always"; // error if player version < 6.0.47 (thanks to Michael Williams @ Adobe for this code)
|
|
||||||
} catch(e) {
|
|
||||||
if (pv.major == 6) {
|
|
||||||
return pv;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
try {
|
|
||||||
axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash");
|
|
||||||
} catch(e) {}
|
|
||||||
}
|
|
||||||
if (axo != null) {
|
|
||||||
pv = new PlayerVersion(axo.GetVariable("$version").split(" ")[1].split(","));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return pv;
|
|
||||||
}
|
|
||||||
|
|
||||||
PlayerVersion = function(arrVersion) {
|
|
||||||
this.major = arrVersion[0] != null ? parseInt(arrVersion[0]) : 0;
|
|
||||||
this.minor = arrVersion[1] != null ? parseInt(arrVersion[1]) : 0;
|
|
||||||
this.rev = arrVersion[2] != null ? parseInt(arrVersion[2]) : 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user