Skip to content

Commit

Permalink
Replace default HTML Renderer implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
Marin Procureur committed Feb 2, 2016
1 parent 070fc66 commit df93fb6
Show file tree
Hide file tree
Showing 8 changed files with 52 additions and 99 deletions.
105 changes: 20 additions & 85 deletions examples/HeatMapExample/HeatMapExample.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ var Component = {
getRange : function(rowsObjects, columnsObjects){

var dataRowHead = this.dataRowHead,
dataColumnHead = this.dataColumnHead,
dataColumnHead = this.dataColumnHead,
communCarac = 0,
stringRow,
splitStringRow,
Expand Down Expand Up @@ -60,7 +60,7 @@ var Component = {
console.log(dataRowHead[j], dataColumnHead[i]);
valReturnCarac = communCarac; //init of the first datacell
}

communCarac = 0;
};

Expand Down Expand Up @@ -98,12 +98,12 @@ var DataProvider = {
var headerArray = new Array();
var text = '';
var possible = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
var cpt = Math.floor(Math.random() * (41 - 11 ) + 11);
var cpt = Math.floor(Math.random() * (100 - 11) + 11);

for (var i = 0; i < cpt; i++) {
var cpt1 = Math.floor(Math.random() * (21 - 11 ) + 11);
var cpt1 = Math.floor(Math.random() * (5 - 1) + 1);
for (var j = 0; j < cpt1; j++){
text+= possible.charAt(Math.floor(Math.random() * possible.length));
text+= possible.charAt(Math.floor(Math.random() * possible.length));
}
headerArray.push(text);
text = '';
Expand All @@ -127,7 +127,7 @@ var DataProvider = {
for (var j = 0; j < columnsObjects.length; j++) {
var stringColumn = columnsObjects[i],
splitStringColumn = stringColumn.split("");

for (var k = 0; k < splitStringRows.length; k++) {
for (var n = 0; n < splitStringColumn.length; n++) {
if (splitStringColumn[n] == splitStringRows[k]) {
Expand All @@ -139,7 +139,7 @@ var DataProvider = {
dataArray.push(communCarac);
};
}
return dataArray; //return of the data cell
return dataArray; //return of the data cell
}


Expand Down Expand Up @@ -173,7 +173,7 @@ var Renderer = {
this.renderer.createElementWithText("th", rowObject),
"id",
this.template.getAttribute("rowHeader","idPrefix") + rowNumber
),
),
true,
true
)
Expand All @@ -193,7 +193,7 @@ var Renderer = {
this.renderer.createElementWithText("th", columnObject),
"id",
this.template.getAttribute("columnHeader","idPrefix") + columnNumber
),
),
true,
true
)
Expand All @@ -202,8 +202,10 @@ var Renderer = {
},

renderCell : function(rowsNumbers, columnsNumbers, cellData, eventsCallBacks){

var cell = this.renderer.createElementWithText("td", cellData[0]);
if (!cellData[0])
var cell = this.renderer.createElement("td");
else
var cell = this.renderer.createElementWithText("td", cellData[0]);
cell = this.addEventsToRendering(cell, eventsCallBacks);

for (var row in rowsNumbers){
Expand Down Expand Up @@ -244,14 +246,14 @@ var Renderer = {
colorGreen = Math.floor(255 / rangeNumber); //init of the rangecolor

for (var i = 0; i < rangeNumber; i++) { //creation of the color function of the data cell
if (dataNumber == this.component.rangeNumbersHead[i]) {

if (dataNumber == this.component.rangeNumbersHead[i]) {

colorGreen = 255 - colorGreen * i;
colorCell = 'rgb(255, '+ colorGreen +' , 0)';
colorCell = 'rgb(255, '+ colorGreen +' ,0)';
cpt ++;
return colorCell;

};
};
return colorCell;
Expand All @@ -263,77 +265,10 @@ var Renderer = {
Renderer = Class.extend(DefaultHTMLRenderer, Renderer);

var Controller = {

initialize : function(parent, core){
this.component = parent;
this.core = core;
},

onCellHover : function(event){
info_debug("onCellHover");
var classes = event.target.className.split(" ");
var elements = new Array();
console.log($(event.target));
for (i = 0; i < classes.length; i++){
elements = document.getElementsByClassName(classes[i]);

for (var j = 0; j < elements.length; j++){
if (elements[j].tagName == "TD")
this.component.renderer.setCSSProperty("background-color", elements[j], "#e3e3e3");
else if (elements[j].tagName == "TH")
this.component.renderer.setCSSProperty("background-color", elements[j], "#d77b18");
}
}
this.component.renderer.setCSSProperty("background-color", event.target, "#d77b18");
},

onCellOut : function(event){
info_debug("onCellOut");
var classes = event.target.className.split(" ");
var elements = new Array();
var dataCell;

console.log($(event.target));
console.log("event", dataCell);

for (i = 0; i < classes.length; i++){
elements = document.getElementsByClassName(classes[i]);


for (var j = 0; j < elements.length; j++){

if (elements[j].tagName == "TD"){

dataCell = elements[j].textContent;
this.component.renderer.setCSSProperty("background-color",
elements[j],
this.component.renderer.renderColorCell(dataCell, //applied of a color, function of the datacell
this.component.minNumber,
this.component.maxNumber));
}
else if (elements[j].tagName == "TH")
this.component.renderer.emptyCSSProperty("background-color",
elements[j]);
}
}
},

onCellClick : function(event, cellData){
alert("there is " + cellData[0] + " characters shared");
},

onHeaderClick : function(event, headerNode){
console.log("headerClick", headerNode);
this.core.toggleHeader(headerNode);
this.core.refresh(this.core.getHeaderType(headerNode))
},

onHeaderHover : function(event){
info_debug("onHeaderHover", event);
},

onHeaderOut : function(event){
info_debug("onHeaderOut", event);
}
};

Expand Down Expand Up @@ -380,4 +315,4 @@ ast = pro.ast_mangle(ast); // get a new AST with mangled names
ast = pro.ast_squeeze(ast); // get an AST with compression optimizations
var final_code = pro.gen_code(ast); // compressed code here
alert(ast);
//alert("displayed : " + (new Date() - start));
//alert("displayed : " + (new Date() - start));
13 changes: 2 additions & 11 deletions examples/HeatMapExample/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,8 @@
<script src="https://netdna.bootstrapcdn.com/bootstrap/3.0.0/js/bootstrap.min.js" type="text/javascript"></script>

<!-- all ij.js files -->
<script type="text/javascript" src="../../src/js/ij.IIJRenderer.HTMLTemplate.js"></script>
<script type="text/javascript" src="../../src/js/ij.IIJRenderer.HTMLRenderer.js"></script>
<script type="text/javascript" src="../../src/js/ij.IIJRenderer.js"></script>
<script type="text/javascript" src="../../src/js/ij.IIJDefaultHTMLRenderer.js"></script>
<script type="text/javascript" src="../../src/js/ij.IIJController.js"></script>
<script type="text/javascript" src="../../src/js/ij.IIJDataProvider.Aggregator.js"></script>
<script type="text/javascript" src="../../src/js/ij.IIJDataProvider.js"></script>
<script type="text/javascript" src="../../src/js/ij.Core.DataCell.js"></script>
<script type="text/javascript" src="../../src/js/ij.Core.DataHeader.State.js"></script>
<script type="text/javascript" src="../../src/js/ij.Core.DataHeader.js"></script>
<script type="text/javascript" src="../../src/js/ij.Core.js"></script>
<script type="text/javascript" src="../../min/ij.min.js"></script>
<script type="text/javascript" src="../../src/js/defaultImplementations/defaultHTMLRenderer/ij.IIJDefaultHTMLRenderer.js"></script>
<title>HeatMapExample</title>
</head>
<body>
Expand Down
1 change: 1 addition & 0 deletions examples/hierarchicalExample/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

<!-- all ij.js files -->
<script type="text/javascript" src="../../min/ij.min.js"></script>
<script type="text/javascript" src="../../src/js/defaultImplementations/defaultHTMLRenderer/ij.IIJDefaultHTMLRenderer.js"></script>
<link rel="stylesheet" href="../../src/css/style.css" />
<title></title>
</head>
Expand Down
1 change: 1 addition & 0 deletions examples/htmlTable/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

<!-- all ij.js files -->
<script type="text/javascript" src="../../min/ij.min.js"></script>
<script type="text/javascript" src="../../src/js/defaultImplementations/defaultHTMLRenderer/ij.IIJDefaultHTMLRenderer.js"></script>
<link rel="stylesheet" href="../../src/css/style.css" />
<title></title>
</head>
Expand Down
1 change: 1 addition & 0 deletions examples/simpleExample/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

<!-- all ij.js files -->
<script type="text/javascript" src="../../min/ij.min.js"></script>
<script type="text/javascript" src="../../src/js/defaultImplementations/defaultHTMLRenderer/ij.IIJDefaultHTMLRenderer.js"></script>
<link rel="stylesheet" href="../../src/css/style.css" />
<title></title>
</head>
Expand Down
4 changes: 2 additions & 2 deletions examples/simpleExample/simpleExample.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ var Component = {

getObjects : function(){
var objects = new Array(),
number = 200,
number = 100,
possible = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
for (var i = 0; i < number; i++) {
var text = "";
Expand Down Expand Up @@ -113,7 +113,7 @@ var Renderer = {
},

renderCell : function(rowsNumbers, columnsNumbers, cellData, eventsCallBacks){
if (cellData && cellData.length > 0) {
if (cellData && cellData.length > 0 && cellData[0]) {
var cell = this.renderer.createElementWithText("td", cellData[0]);
this.renderer.addAttribute(cell, "data-toggle", "popover");
this.renderer.addAttribute(cell, "data-original-title", "Summary (first relation)");
Expand Down
2 changes: 1 addition & 1 deletion min/ij.min.js

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,30 @@ var DefaultHTMLRenderer = {
}
return output;
},

reRenderColumn : function(renderedColumn, events){
if (!renderedColumn.children) {
var vtext = this.renderer.createElement("div",
["vtext"]);
var vtextInner = this.renderer.createElementWithText("div",
renderedColumn.label,
["vtext__inner"]);
renderedColumn.rendering.textContent = "";
this.appendChild(vtext,
vtextInner);
this.appendChild(renderedColumn.rendering,
vtext);
}
renderedColumn.rendering = this.addEventsToRendering(renderedColumn.rendering,
events);
return renderedColumn;
},

reRenderRow : function(renderedRow, events){
renderedRow.rendering = this.addEventsToRendering(renderedRow.rendering,
events);
return renderedRow;
}
};

DefaultHTMLRenderer = Class.extend(enioka.ij.IIJRenderer, DefaultHTMLRenderer);

0 comments on commit df93fb6

Please sign in to comment.