JSFiddle - React, Tailwind, and code Playground
HTML
<script src="http://dev.sencha.com/deploy/ext-4.0.0/bootstrap.js"></script>
<link rel="stylesheet" href="http://dev.sencha.com/deploy/ext-4.0.0/resources/css/ext-all.css">
<div id="placeholder"></div>
CSS
.signature {
padding: 5px;
border: 1px solid black;
margin: 10px;
}
.signature a {
color: #505050;
text-decoration: none;
}
.signature a:hover {
color: black;
text-decoration: underline;
}
.signature .name {
font-size: 1.5em;
}
.signature .department{
font-size: 0.8em;
font-style: italic;
}
.signature .phone {
color: silver;
margin: 5px 0 0 5px;
}
.signature .phone .number {
color: black;
display: inline-block;
margin-right: 5px;
}
.signature .email {
color: silver;
margin: 5px 0 0 5px;
}
.signature .email .address {
color: gray;
display: inline-block;
margin-right: 5px;
}
/* dynamic content management */
.signature .phone:before { content: '#: '; }
.signature .email:before { content: '@: '; }
.signature .phone .number:after,
.signature .email .address:after { content: ','; }
.signature .phone .number.last:after,
.signature .email .address.last:after { content: ''; }
JavaScript
Ext.define('Ext.ux.Signature', {
// new ExtJs 4 method for defining objects
extend: "Ext.Component",
alternateClassName : 'Ext.Signature',
// these are the signature configurations
config: {
name: '',
department: '',
phoneNumbers: [],
emailAddresses: []
},
// define our template right here (to allow extensions)
signatureTpl: [
'var template_chart = new Ext.XTemplate(
'<tpl for="dados">',
'<tpl if=isNum({#})>',
'<tpl if=isNotaAluno({#})>',
'<tpl switch=[xkey]>',
'<tpl case="nb1" case="nb">',
'<tpl if="({.} < 60 && rec1 == 0)||(rec_final == 0)">' ,
'6',
'</tpl>',
'<tpl default>',
'{{.}/10}',
'</tpl>',
'</tpl>',
'<tpl case="nb3" case="nb4">',
'<tpl if="({.} < 60 && rec2 == 0)||(rec_final == 0)">' ,
'6',
'</tpl>',
'<tpl default>',
'{{.}/10}',
'</tpl>',
'</tpl>',
'</tpl>',
'</tpl>',
'<tpl default>',
'{{.}/10}',
'</tpl>',
'</tpl>',
'<tpl default>',
'{.}',
'</tpl>',
'</tpl>',
{
isNum: function(campo){
return !((campo=='descricao')||(campo=='rec1')||(campo=='rec2')||(campo=='rec_final'))
},
isNotaAluno: function(campo){
return ((campo=='nb1')||(campo=='nb2')||(campo=='nb3')||(campo=='nb4'))
},
}
);
],
constructor: function(c){
// call superclass constructor method
this.callParent(arguments);
// initialize our config from arguments, this is an Ext.define helper method
this.initConfig(c);
// (re)load the signature template
this.reloadTemplate();
return this;
},
reloadTemplate: function(){
// initialize our template, store in private variable to be recycled
this._signatureTemplate = Ext.isObject(this.signatureTpl) ?
this.signatureTpl:
new Ext.XTemplate( this.signatureTpl);
// compile the template to save on multiple iterations
...