Remove scripts that are no longer needed

refs #4456
This commit is contained in:
Matthias Jentsch 2013-08-20 20:03:43 +02:00 committed by Marius Hein
parent 6aca723f6d
commit a66934e41d
5 changed files with 0 additions and 475 deletions

View File

@ -1,97 +0,0 @@
/*global Icinga:false, document: false, define:false require:false base_url:false console:false */
/**
* Main-Detail layout behaviour as described in
* https://wiki.icinga.org/display/cranberry/Frontend+Components#FrontendComponents-Behaviour
*
*/
define(['jquery','logging','icinga/util/async'],function($,log,async) {
"use strict";
var MainDetailBehaviour = function() {
var onOuterLinkClick = function(ev) {
var a = $(ev.currentTarget),
target = a.attr("target"),
href = a.attr("href");
ev.stopImmediatePropagation();
collapseDetailView();
async.loadToTarget("icinga-main",href);
return false;
};
var onLinkTagClick = function(ev) {
var a = $(ev.currentTarget),
target = a.attr("target"),
href = a.attr("href");
// check for protocol://
if(/^[A-Z]{2,10}\:\/\//i.test(href)) {
window.open(href);
ev.stopImmediatePropagation();
return false;
}
// check for link in table header
if(a.parents('th').length > 0) {
ev.stopImmediatePropagation();
return false;
}
if(typeof target === "undefined") {
if(a.parents("#icinga-detail").length) {
log.debug("Parent is detail, loading into detail");
async.loadToTarget("icinga-detail",href);
} else {
log.debug("Parent is not detail, loading into main");
async.loadToTarget("icinga-main",href);
}
} else {
switch(target) {
case "body":
async.loadToTarget("body", href);
break;
case "main":
async.loadToTarget("icinga-main",href);
collapseDetailView();
break;
case "detail":
log.debug("Target: detail");
async.loadToTarget("icinga-detail",href);
break;
case "popup":
log.debug("No target");
async.loadToTarget(null,href);
break;
default:
return true;
}
}
ev.stopImmediatePropagation();
return false;
};
var expandDetailView = function() {
$("#icinga-detail").parents(".collapsed").removeClass('collapsed');
};
var collapseDetailView = function(elementInDetailView) {
$("#icinga-detail").parents(".layout-main-detail").addClass('collapsed');
};
this.expandDetailView = expandDetailView;
this.collapseDetailView = collapseDetailView;
this.eventHandler = {
'.layout-main-detail * a' : {
'click' : onLinkTagClick
},
'.layout-main-detail .icinga-container#icinga-detail' : {
'focus' : expandDetailView
}
};
};
return new MainDetailBehaviour();
});

View File

@ -1,27 +0,0 @@
(function() {
"use strict";
var Timer = function() {
this.resolution = 1000; // 1 second resolution
this.containers = {
};
this.registerContainer = function(container) {
this.containers[container.attr('container-id')] = container;
};
var tick = function() {
for(var container in this.containers) {
var el = this.containers[container];
// document does not exist anymore
if(!jQuery.contains(document.documentElement, el[0])) {
delete this.containers[container];
continue;
}
}
};
};
})();

View File

@ -1,168 +0,0 @@
/*global Icinga:false, $:true, document: false, define:false require:false base_url:false console:false */
define(['logging','raphael'], function(log,raphael) {
"use strict";
var rad = Math.PI / 180;
var getPaper = function(el,width,height) {
if (el[0]) {
el = el[0];
}
this.paper = raphael(el,width, height);
this.paper.customAttributes.arc = function (xloc, yloc, value, total, R) {
var alpha = 360 / total * value,
a = (90 - alpha) * Math.PI / 180,
x = xloc + R * Math.cos(a),
y = yloc - R * Math.sin(a),
path;
if (total === value) {
path = [
["M", xloc, yloc - R],
["A", R, R, 0, 1, 1, xloc - 0.01, yloc - R]
];
} else {
path = [
["M", xloc, yloc - R],
["A", R, R, 0, +(alpha > 180), 1, x, y]
];
}
return {
path: path
};
};
};
var drawStatusArc = function(color,percentage,width,anim) {
anim = anim || 500;
// how much percentage this sub arc requires
var alpha = this.rot + percentage / 100 * 180; // this is the end angle for the arc
var coords = getCoordsForAngle.call(this,alpha);
var pos = getSection(alpha);
var subArc = this.paper.path().attr({
"stroke": color,
"stroke-width": width || (this.radius/4)+"px",
arc: [this.x, this.y, 0, 100, this.radius]
});
subArc.data("percentage",percentage);
subArc.transform("r" + this.rot + "," + this.x + "," + this.y).animate({
arc: [this.x, this.y, percentage, 100, this.radius]
}, anim, "easeOut");
//subArc.hover(indicateMouseOver,indicateMouseOut);
this.rot += percentage / 100 * 360;
};
var getSection = function(alpha) {
return {
right: alpha < 180,
left: alpha > 180,
top: alpha < 90 || alpha > 270,
bottom: alpha > 90 && alpha < 270
};
};
var getCoordsForAngle = function(alpha) {
var a = (90 - alpha) * Math.PI / 180;
return {
tx : this.x + (this.radius) * Math.cos(a),
ty : this.y - (this.radius) * Math.sin(a)
};
};
var sector = function(startAngle, endAngle) {
var cx = this.x, cy = this.y, r = this.radius;
var x1 = cx + r * Math.cos(-startAngle * rad),
x2 = cx + r * Math.cos(-endAngle * rad),
y1 = cy + r * Math.sin(-startAngle * rad),
y2 = cy + r * Math.sin(-endAngle * rad);
return ["M", cx, cy, "L", x1, y1, "A", r, r, 0, +(endAngle - startAngle > 180), 0, x2, y2, "z"];
};
var inlinePie = function(targetEl,h,w) {
var colors = {
0: '#11ee11',
1: '#ffff00',
2: '#ff2222',
3: '#acacac'
};
targetEl = $(targetEl);
var height = h || targetEl.height();
var width = w || targetEl.width();
this.x = width/2;
this.y = height/2;
this.radius = Math.min(width,height)/2.5;
var values = $(targetEl).html().split(",");
targetEl.html("");
getPaper.call(this,targetEl.first(),width,height);
var total = 0;
for(var i=0;i<values.length;i++) {
total += parseInt(values[i],10);
values[i] = parseInt(values[i],10);
}
var degStart = 0;
var degEnd = 0;
for(i=0;i<values.length;i++) {
degEnd = degStart+(parseInt(values[i],10)/total*360);
if(degEnd >= 360) {
degEnd = 359.9;
}
log.debug(degStart,degEnd);
this.paper.path(sector.call(this,degStart,degEnd)).attr({
fill: colors[i],
"stroke-width": '0.5px'
});
degStart = degEnd;
}
};
var diskStatus = function(targetEl,full,ok,warning,critical) {
targetEl = $(targetEl);
this.rot = 0;
var height = targetEl.height();
var width = targetEl.width();
this.x = width/2;
this.y = height/2;
this.radius = Math.min(width,height)/3;
getPaper.call(this,targetEl.first(),width,height);
for(var i = 0;i<5;i++) {
this.paper
.ellipse(this.x,this.y+(height/10)-i*(height/20),width/5,height/10)
.attr({'fill' : '90-#ddd-#666'});
}
this.radius -= 7;
drawStatusArc.call(this,'#000000',100,1,1);
this.radius += 2;
drawStatusArc.call(this,'#00ff00',ok,3 );
drawStatusArc.call(this,'#ffff00',warning,3);
drawStatusArc.call(this,'#ff0000',critical,3);
this.radius += 2;
drawStatusArc.call(this,'#000000',100,2,1);
this.radius+=4;
this.rot = 0;
drawStatusArc.call(this,'#ff0000',full);
drawStatusArc.call(this,'#0f0',100-full);
this.rot = 0;
this.radius += 5;
drawStatusArc.call(this,'#000000',100,2,1);
};
return {
inlinePie: inlinePie,
diskStatus: diskStatus
};
});

View File

@ -1,139 +0,0 @@
define(['jquery','raphael'], function($,Raphael) {
return function(el) {
this.el = $(el);
this.height = this.el.height();
this.width = this.el.width();
this.dataSet = {};
this.paper= null;
this.radius = 0;
this.total = 0;
var construct = (function(el,cfg) {
cfg = cfg || {}
this.radius = cfg.radius || Math.min(this.width,this.height)/4
this.x = cfg.x || this.width/2;
this.y = cfg.y || this.height/2;
this.paper = getPaper();
console.log(this.el);
}).bind(this);
var getSection = function(alpha) {
return {
right: alpha < 180,
left: alpha > 180,
top: alpha < 90 || alpha > 270,
bottom: alpha > 90 && alpha < 270
}
}
var getCoordsForAngle = (function(alpha) {
var a = (90 - alpha) * Math.PI / 180;
return {
tx : this.x + (this.radius) * Math.cos(a),
ty : this.y - (this.radius) * Math.sin(a)
}
}).bind(this);
var drawSubCircle = (function(coords, color,percentage) {
this.paper.circle(coords.tx,coords.ty,0).attr({
fill: color,
stroke: 'none'
}).animate({r: this.radius/2},500, "easeOut");
}).bind(this);
var indicateMouseOver = function() {
this.animate({"stroke-width": 30 }, 400, "bounce");
}
var indicateMouseOut = function() {
this.animate({"stroke-width": 18}, 400, "bounce");
}
var drawSubArcFor = (function(elem,rot) {
var percentage = elem.items.length/this.total*100; // how much percentage this sub arc requires
var alpha = rot + percentage / 100 * 180; // this is the end angle for the arc
var coords = getCoordsForAngle(alpha);
var pos = getSection(alpha);
if(elem.items.length > 10)
drawSubCircle(coords,elem.color,percentage/100);
var subArc = this.paper.path().attr({
"stroke": elem.color,
"stroke-width": 18,
arc: [this.x, this.y, 0, 100, this.radius]
});
subArc.data("percentage",percentage);
subArc.data("item",elem);
subArc.transform("r" + rot + "," + this.x + "," + this.y).animate({
arc: [this.x, this.y, percentage, 100, this.radius]
}, 500, "easeOut");
var text = this.paper
.text(coords.tx,coords.ty,elem.items.length)
.attr({'text-anchor': alpha < 180 ? 'start' : 'end'});
subArc.hover(indicateMouseOver,indicateMouseOut);
return percentage / 100 * 360;
}).bind(this);
var drawContainerCircle = (function() {
var rot = 0;
this.total = 0;
for (var i = 0;i<this.dataSet.childs.length;i++) {
this.total += this.dataSet.childs[i].items.length
}
for (var i = 0;i<this.dataSet.childs.length;i++) {
rot += drawSubArcFor(this.dataSet.childs[i],rot);
}
var innerCircleShadow = this.paper.circle(this.x, this.y + 1, this.radius - 3).attr({
fill: 'black',
stroke: 'none',
opacity: 0.4
});
var innerCircle = this.paper.circle(this.x, this.y, this.radius - 4).attr({
fill: this.dataSet.color,
stroke: 'none'
});
this.paper.text(this.x, this.y,this.dataSet.label);
}).bind(this);
var getPaper = (function() {
var paper = Raphael(this.el.first(),this.width, this.height);
paper.customAttributes.arc = function (xloc, yloc, value, total, R) {
var alpha = 360 / total * value,
a = (90 - alpha) * Math.PI / 180,
x = xloc + R * Math.cos(a),
y = yloc - R * Math.sin(a),
path;
if (total == value) {
path = [
["M", xloc, yloc - R],
["A", R, R, 0, 1, 1, xloc - 0.01, yloc - R]
];
} else {
path = [
["M", xloc, yloc - R],
["A", R, R, 0, +(alpha > 180), 1, x, y]
];
}
return {
path: path
};
};
return paper;
}).bind(this);
this.drawFor = function(dataSet) {
this.dataSet = dataSet;
drawContainerCircle();
}
construct.apply(this,arguments);
}
});

View File

@ -1,44 +0,0 @@
/*global Icinga:false, document: false, define:false require:false base_url:false console:false */
define(['jquery','logging'], function($,log) {
"use strict";
return function() {
this.count = 10;
this.offset = 0;
this.searchable = false;
var construct = function(el) {
this.el = $(el);
this.count = this.el.attr("count") || this.count;
this.searchable = this.el.attr("searchable") || false;
this.render();
};
var renderQuicksearch = (function() {
this.input = $("<input type='text' style='padding:0px;font-size:9pt;padding-left:1em;margin-bottom:2px;line-height:8px' class='search-query input-small pull-right' >");
$('.expand-title',this.el.parents('.expandable').first())
.append(this.input)
.append($("<i class='icon-search pull-right'></i>"));
this.input.on("keyup",this.updateVisible.bind(this));
}).bind(this);
this.updateVisible = function() {
var filter = this.input.val();
$("tbody tr",this.el).hide();
$("td",this.el).each(function() {
if($(this).text().match(filter)) {
$(this).parent("tbody tr").show();
}
});
};
this.render = function() {
renderQuicksearch();
};
construct.apply(this,arguments);
};
});