Skip to content

Commit

Permalink
OWF-5553: Calendar icon in Widget Views widget moves one pixel to lef…
Browse files Browse the repository at this point in the history
…t on mouse over and two pixels left on select while using Large Text theme.
  • Loading branch information
Greg Traub committed Oct 12, 2012
1 parent 9c7e757 commit 8dbe39c
Showing 1 changed file with 97 additions and 90 deletions.
187 changes: 97 additions & 90 deletions web-app/js/components/admin/TagCloud.js
@@ -1,105 +1,112 @@
Ext.define('Ozone.components.admin.TagCloud', { Ext.define('Ozone.components.admin.TagCloud', {
extend: 'Ext.panel.Panel', extend: 'Ext.panel.Panel',
alias: ['widget.tagcloud', 'widget.Ozone.components.admin.TagCloud'], alias: ['widget.tagcloud', 'widget.Ozone.components.admin.TagCloud'],


generateTagCloud: function(params) { generateTagCloud: function(params) {
params = params || {}; params = params || {};
var fromDate = params.fromDate; var fromDate = params.fromDate;
var toDate = params.toDate; var toDate = params.toDate;
scope = this; scope = this;


var dateObj = new Date(); var dateObj = new Date();
if (toDate == null) { if (toDate == null) {
toDate = new Date(); toDate = new Date();
} else { } else {
toDate = new Date(toDate); toDate = new Date(toDate);
} }


// Change toDate to last millisecond of selected date because date picker will // Change toDate to last millisecond of selected date because date picker will
// not consider time so the full day won't be included in the totals. // not consider time so the full day won't be included in the totals.
var year = toDate.getFullYear(); var year = toDate.getFullYear();
var month = toDate.getMonth(); var month = toDate.getMonth();
var day = toDate.getDate(); var day = toDate.getDate();
toDate = new Date(year, month, day, 23, 59, 59, 999); toDate = new Date(year, month, day, 23, 59, 59, 999);


if (fromDate == null) { if (fromDate == null) {
// fromDate defaults to one year from toDate // fromDate defaults to one year from toDate
fromDate = new Date(year - 1, month, day); fromDate = new Date(year - 1, month, day);
} else { } else {
fromDate = new Date(fromDate); fromDate = new Date(fromDate);
} }


Ext.Ajax.request({ Ext.Ajax.request({
url: Ozone.metrics.util.contextPath() + '/tagCloudMetric', url: Ozone.metrics.util.contextPath() + '/tagCloudMetric',
params: { params: {
fromDate: fromDate.getTime(), fromDate: fromDate.getTime(),
toDate: toDate.getTime() toDate: toDate.getTime()
}, },
success: function(response){ success: function(response){
var data = Ext.decode(response.responseText).results; var data = Ext.decode(response.responseText).results;
scope.update(data);
}
});
},


var instance; initComponent: function() {
var max = -1; var me = this;
var min = -1; me.tpl = new Ext.XTemplate(
'<ul class="cloud">{[this.initialize(values)]}' +
'<tpl for=".">' +
'<li>' +
'<span ' +
'id={componentId} ' +
'title="{total}" ' +
'class="tag" ' +
'style="font-size:{[this.fontSize(values)]}em" ' +
'onmouseover="document.getElementById(\'{componentId}\').className=\'tag-active\'" ' +
'onmouseout="document.getElementById(\'{componentId}\').className=\'tag\'" ' +
'onclick = "graph(\'{componentId}\')" ' +
'>' +
'{[this.nameNoSpace(values)]} ' +
'</span>' +
'</li>' +
'</tpl>' +
'</ul>',
{
min: -1,
minSize: 0,
constant: 0,
initialize: function(values) {
var instance;
var max = -1;
var min = -1;


//find max and min number of views //find max and min number of views
for(var i = 0; i < data.length; i++){ for (var i = 0; i < values.length; i++) {
instance = data[i]; instance = values[i];
var views = instance.total; var views = instance.total;


if(max == -1){ if (max == -1) {
max = views; max = views;
}else if(max < views){ } else if (max < views) {
max = views; max = views;
} }


if(min == -1){ if (min == -1) {
min = views; min = views;
}else if (min > views){ } else if (min > views) {
min = views; min = views;
} }
} }


var numFonts = 8; var maxSize = 2.5;
var delta = (max - min)/ numFonts; var minSize = 1.0;
var intervals = []; var constant = Math.log(max - (min - 1)) / (maxSize - minSize)


for(var k = 1; k <= numFonts; k++){ this.min = min;
intervals[k - 1] = min + (k * delta); this.minSize = minSize;
} this.constant = constant;

},
var html = '<ul class ="cloud">'; nameNoSpace: function(values) {
var tag = 'tag'; var name = values.component.toLowerCase();
var views; return Ozone.util.HTMLEncode(name.replace(/ /g, '_'));
var maxSize = 2.5; },
var minSize = 1.0; fontSize: function(values) {
var constant = Math.log(max - (min - 1)) / (maxSize - minSize) return Math.log(values.total - (this.min - 1)) / this.constant + this.minSize;

}
for(var j = 0; j < data.length; j++){ }
instance = data[j]; );
views = instance.total; this.generateTagCloud();

this.callParent();
var fontSize = Math.log(views - (min - 1)) / constant + minSize; }
var name = instance.component.toLowerCase();
var nameNoSpace = Ozone.util.HTMLEncode(name.replace(/ /g, '_'));
var nameSafe = nameNoSpace.replace(/\\/g, '__');
var componentId = instance.componentId;
var component = instance.component;

// adds the widget name to the list with the views as a tooltip
html += '<li><span id =' + nameSafe + ' title="' + instance.total + '" class="' + tag + '" style="font-size:' + fontSize + 'em" ' +
'onmouseover = "document.getElementById(\'' + nameSafe + '\').className=\'' + tag + '-active\'" ' + '" onmouseout = "document.getElementById(\'' + nameSafe + '\').className=\'' + tag + '\'"' +
' onclick = "graph(\'' + componentId +'\',\'' + component + '\')" >' + nameNoSpace + ' ' + '</span></li>'
}

html += '</ul>'
scope.update(html)
}
});
},

initComponent: function() {
this.generateTagCloud();
this.callParent();
}
}); });

0 comments on commit 8dbe39c

Please sign in to comment.