Browse files

OWF-5553: Calendar icon in Widget Views widget moves one pixel to lef…

…t on mouse over and two pixels left on select while using Large Text theme.
  • Loading branch information...
1 parent 9c7e757 commit 8dbe39c4cd9d251c0560b7cf4ba4a8e72e489a70 Greg Traub committed Oct 12, 2012
Showing with 97 additions and 90 deletions.
  1. +97 −90 web-app/js/components/admin/TagCloud.js
View
187 web-app/js/components/admin/TagCloud.js
@@ -1,105 +1,112 @@
Ext.define('Ozone.components.admin.TagCloud', {
- extend: 'Ext.panel.Panel',
- alias: ['widget.tagcloud', 'widget.Ozone.components.admin.TagCloud'],
+ extend: 'Ext.panel.Panel',
+ alias: ['widget.tagcloud', 'widget.Ozone.components.admin.TagCloud'],
- generateTagCloud: function(params) {
- params = params || {};
- var fromDate = params.fromDate;
- var toDate = params.toDate;
- scope = this;
+ generateTagCloud: function(params) {
+ params = params || {};
+ var fromDate = params.fromDate;
+ var toDate = params.toDate;
+ scope = this;
- var dateObj = new Date();
+ var dateObj = new Date();
if (toDate == null) {
- toDate = new Date();
+ toDate = new Date();
} else {
- toDate = new Date(toDate);
+ toDate = new Date(toDate);
}
- // 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.
- var year = toDate.getFullYear();
- var month = toDate.getMonth();
- var day = toDate.getDate();
- toDate = new Date(year, month, day, 23, 59, 59, 999);
+ // 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.
+ var year = toDate.getFullYear();
+ var month = toDate.getMonth();
+ var day = toDate.getDate();
+ toDate = new Date(year, month, day, 23, 59, 59, 999);
- if (fromDate == null) {
- // fromDate defaults to one year from toDate
- fromDate = new Date(year - 1, month, day);
- } else {
- fromDate = new Date(fromDate);
- }
+ if (fromDate == null) {
+ // fromDate defaults to one year from toDate
+ fromDate = new Date(year - 1, month, day);
+ } else {
+ fromDate = new Date(fromDate);
+ }
- Ext.Ajax.request({
- url: Ozone.metrics.util.contextPath() + '/tagCloudMetric',
- params: {
- fromDate: fromDate.getTime(),
- toDate: toDate.getTime()
- },
- success: function(response){
- var data = Ext.decode(response.responseText).results;
+ Ext.Ajax.request({
+ url: Ozone.metrics.util.contextPath() + '/tagCloudMetric',
+ params: {
+ fromDate: fromDate.getTime(),
+ toDate: toDate.getTime()
+ },
+ success: function(response){
+ var data = Ext.decode(response.responseText).results;
+ scope.update(data);
+ }
+ });
+ },
- var instance;
- var max = -1;
- var min = -1;
+ initComponent: function() {
+ var me = this;
+ 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
- for(var i = 0; i < data.length; i++){
- instance = data[i];
- var views = instance.total;
+ //find max and min number of views
+ for (var i = 0; i < values.length; i++) {
+ instance = values[i];
+ var views = instance.total;
- if(max == -1){
- max = views;
- }else if(max < views){
- max = views;
- }
+ if (max == -1) {
+ max = views;
+ } else if (max < views) {
+ max = views;
+ }
- if(min == -1){
- min = views;
- }else if (min > views){
- min = views;
- }
- }
+ if (min == -1) {
+ min = views;
+ } else if (min > views) {
+ min = views;
+ }
+ }
- var numFonts = 8;
- var delta = (max - min)/ numFonts;
- var intervals = [];
-
- for(var k = 1; k <= numFonts; k++){
- intervals[k - 1] = min + (k * delta);
- }
-
- var html = '<ul class ="cloud">';
- var tag = 'tag';
- var views;
- var maxSize = 2.5;
- var minSize = 1.0;
- var constant = Math.log(max - (min - 1)) / (maxSize - minSize)
-
- for(var j = 0; j < data.length; j++){
- instance = data[j];
- views = instance.total;
-
- 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();
- }
+ var maxSize = 2.5;
+ var minSize = 1.0;
+ var constant = Math.log(max - (min - 1)) / (maxSize - minSize)
+
+ this.min = min;
+ this.minSize = minSize;
+ this.constant = constant;
+ },
+ nameNoSpace: function(values) {
+ var name = values.component.toLowerCase();
+ return Ozone.util.HTMLEncode(name.replace(/ /g, '_'));
+ },
+ fontSize: function(values) {
+ return Math.log(values.total - (this.min - 1)) / this.constant + this.minSize;
+ }
+ }
+ );
+ this.generateTagCloud();
+ this.callParent();
+ }
});

0 comments on commit 8dbe39c

Please sign in to comment.