css style in the ext js combo box - css

My code:
{
border: 1,
bodyStyle: 'margin:0 0 0 140px;',
style: {
borderColor: 'black',
borderStyle: 'solid', //margin:'0 0 0 140' //margin-left: '140px' }, width: 140, name: 'comp', id:'compId', triggerAction: 'all', mode: 'local', store: new Ext.data.SimpleStore({
fields: ['myId', 'displayText'],
data: [
[1, 'item1'],
[2, 'item2']
]
}), displayField: 'displayText', xtype: 'combo',
},
here in ext js 2.3 bodyStyle is not getting appended to the combobox.Can anyone suggest how to resolve this?
Thanks

I think this could be what you need.
{
xtype: 'combo'
style : 'margin-left: 140px; border: solid black 1px;',
name: 'comp',
id:'compId',
triggerAction: 'all',
mode: 'local',
store: new Ext.data.SimpleStore({
fields: ['myId', 'displayText'],
data: [
[1, 'item1'],
[2, 'item2']
]
}),
displayField: 'displayText',
valueField : 'myId'
}
Note there is no bodyStyle config option according to the docs - http://docs.sencha.com/extjs/2.3.0/#!/api/Ext.form.ComboBox
I removed the width option as with the margin-left style attribute (also 140px) I thought you may end up with something odd looking.

combo.js :
{xtype:'combobox', cls:'combo'}
combo.css:
.combo .x-boundlist-selected {
background: #757575;
background-image: -webkit-linear-gradient(top, #757575, #474747);
background-image: -moz-linear-gradient(top, #757575, #474747);
background-image: -ms-linear-gradient(top, #757575, #474747);
background-image: -o-linear-gradient(top, #757575, #474747);
background-image: linear-gradient(to bottom, #757575, #474747);
border: solid #4e4e4e 2px;
color: #ffffff;
text-decoration: none;
}
.combo .x-boundlist-item {
background: #757575;
background-image: -webkit-linear-gradient(top, #757575, #474747);
background-image: -moz-linear-gradient(top, #757575, #474747);
background-image: -ms-linear-gradient(top, #757575, #474747);
background-image: -o-linear-gradient(top, #757575, #474747);
background-image: linear-gradient(to bottom, #757575, #474747);
border: solid #4e4e4e 2px;
color: #ffffff;
text-decoration: none;
}

this is one of the code that used bodyStyle atribute in 2.3 version
this may help you.
this.itemCombo= new Ext.form.ComboBox({
name : "combooo",
fieldLabel : "Status",
displayField : 'combo',
valueField : 'id',
mode : 'local',
triggerAction : 'all',
hiddenName : "comboo",
editable : false,
width : 100,
store : this.store,
value : "0"
});
this.frmPanel = new Ext.form.FormPanel({
bodyStyle : "padding:10px",
border : true,
autoScroll : true,
layout : "table",
layoutConfig : {
columns : 1,
style : "vertical-align:top"
},
items : [{
bodyStyle : "padding-right:10px",
xtype : "panel",
layout : "form",
border : false,
labelWidth : 110,
colspan : 2,
items : [this.item1,this.itemCombo]
}]
});

Related

Changing the bar under the tabpanel labels in ExtJS 4.2

I'm developing a Web App using ExtJS 4.2, and I want the layout to look something like this:
So far, I've implemented the different colors for the Tab Label. I made a css file with the following properties:
.x-tab-first.x-tab-default-top{
background: rgb(0, 169, 180) !important;
}
.x-tab-second.x-tab-default-top{
background: rgb(251, 183, 18) !important;
}
.x-tab-third.x-tab-default-top{
background: rgb(2, 153, 130) !important;
}
And in each of the tab in the tab panel, I assigned the corresponding class as their cls, so the first tab has x-tab-first as its cls, and so on.
But as you can see in the following photo, if I click on "Find us here", the tab contents changes accordingly, but the bar below does not change:
And for the other two tabs, the bar below does not change as well, it just stays as is.
I have tried this:
.x-tab-second-active.x-tab-bar-body{
background: rgb(251, 183, 18) !important;
}
However I am not quite sure where and how to place this code.
I want the bar below the tab titles to follow the color as well.
As per your requirement, you need to add your activeTab cls to tabbar-strip by manually on tabchange event.
In this FIDDLE, I have created a demo using tabpanel. I hope this will help/guide you to achieve your requirement.
CODE SNIPPET
CSS part
<style>
.x-my-tabpanel .x-tab-bar {
background: red;
}
.x-my-tabpanel .x-tab-default-top {
border: 0px !important;
box-shadow: 0px 0px 0px;
}
.x-my-tabpanel .x-tab-bar-strip {
top: 23px;
height: 5px !important;
}
.x-tab-first.x-tab-default-top,
.x-tab-first.x-tab-bar-strip {
background: rgb(0, 169, 180);
border-color: rgb(0, 169, 180);
}
.x-tab-second.x-tab-default-top,
.x-tab-second.x-tab-bar-strip {
background: rgb(251, 183, 18);
border-color: rgb(251, 183, 18);
}
.x-tab-third.x-tab-default-top,
.x-tab-third.x-tab-bar-strip {
background: rgb(2, 153, 130);
border-color: rgb(2, 153, 130);
}
.x-my-tabpanel .x-tab .x-tab-inner {
color: #fff;
}
</style>
ExtJS part
Ext.application({
name: 'Fiddle',
launch: function () {
Ext.create('Ext.tab.Panel', {
height: 200,
renderTo: Ext.getBody(),
cls: 'x-my-tabpanel',
activeTab: 0,
defaults: {
padding: 10
},
items: [{
title: 'What to Expect',
html: 'What to Expect'
}, {
title: 'Find us here',
html: 'Find us here'
}, {
title: 'Game Machenics',
html: 'Game Machenics'
}],
listeners: {
/*
* this event will fire on view render
*/
afterrender: function (panel) {
var clsArr = ['first', 'second', 'third'];
panel.query('tab').forEach((item, index) => {
let cls = `x-tab-${clsArr[index]}`;
item.addCls(cls);
item.cls = cls;
});
this.addToStripCls();
},
/*
* this event will fire on tab change
*/
tabchange: function (panel, newtab) {
this.addToStripCls();
}
},
/*
* this function will set active tab cls to strip
* before to adding we need to remove previous cls
*/
addToStripCls: function () {
var strip = Ext.get(this.el.query('.x-tab-bar-strip')[0]),
clsArr = ['first', 'second', 'third']
clsArr.forEach(el => {
if (strip.hasCls(`x-tab-${el}`)) {
strip.removeCls(`x-tab-${el}`);
}
});
strip.addCls(this.activeTab.tab.cls);
}
});
}
});

change the color of Highmap

I'm working on with Highmaps and this is the one I use :
http://www.highcharts.com/maps/demo/data-class-ranges
In this map the colors for different countries goes from white to blue I want to change that to "Red to Blue" gradient like in this css example :
background: -webkit-linear-gradient(red, yellow, green, blue); /* For Safari 5.1 to 6.0 */
background: -o-linear-gradient(red, yellow, green, blue); /* For Opera 11.1 to 12.0 */
background: -moz-linear-gradient(red, yellow, green, blue); /* For Firefox 3.6 to 15 */
background: linear-gradient(red, yellow, green, blue); /* Standard syntax (must be last) */
How can I do that ?
You can specify colors in the colorAxis object.
colorAxis: {
dataClasses: [{
to: 3,
color: "red"
}, {
from: 3,
to: 10,
color: "yellow"
}, {
from: 10,
to: 30,
color: "green"
}, {
from: 30,
to: 100,
color: "blue"
}, {
from: 100,
to: 300,
color: "pink"
}, {
from: 300,
to: 1000,
color: "purple"
}, {
from: 1000,
color: "black"
}]
},
Hex values like #FF0000 work as well.
Working example: http://jsfiddle.net/8wcntpcz/
EDIT:
Docs: http://api.highcharts.com/highmaps#colorAxis.dataClasses

How can I bring the tooltip to the top of chart

I now have a google chart like this bellow picture
Now I want to move the tooltip to the top of chart (dont care the position of my mouse).
How can I do it.
Here is my code :
var chartData = new google.visualization.DataTable();
chartData.addColumn('string', 'Time');
chartData.addColumn('number', 'Average Score');
chartData.addColumn({ 'type': 'string', 'role': 'tooltip', 'p': { 'html': true } });
chartData.addRows(data);
var options = {
chartArea: { left: 0, top: 100, width: "100%", height: "100%" },
title: '',
opacity: 100,
backgroundColor : {fill: '#000'},
hAxis: {
textPosition: 'none',
titleTextStyle: {color: '#333'},
titleTextStyle: {color: '#2902A3'},
},
vAxis: {
textPosition: 'none',
opacity: 100,
minValue: 0,
gridlines: { color: '#0D2B56', count: 10 },
baselineColor: 'white',
},
series:{
0:{
color: '#3C93FF',
areaOpacity: '0.68'
}
},
crosshair: {
orientation: 'vertical',
trigger: 'focus',
color: '#fff'
},
legend: 'none',
tooltip: {isHtml: true},
};
google.load("visualization", "1", { packages: ["corechart"] });
var chart = new google.visualization.AreaChart(document.getElementById('chart'));
chart.draw(chartData, options);
I also use this function to create tooltip's content
var createToolTip = function (name, value) {
return '<div class="googletooltip" ><span>' + name + ':</span><span style="padding-left:20px" >' + value + '</span></div>';
}
and this style also
.googletooltip{
color:#fff;
border-style: solid;
border-width: 2px;
border-color: #3882C4;
background: #000;
padding:2px 15px 2px 15px;
font-weight: bold;
}
Thank a lot
Try adding a top property and a position property for the .googletooltip class. If not, try using the margin property if the other properties are not working. Work around these three properties and see if you will be able to move tooltip up. Let me know if it still isn't working.
.googletooltip{
color:#fff;
border-style: solid;
border-width: 2px;
border-color: #3882C4;
background: #000;
padding:2px 15px 2px 15px;
font-weight: bold;
}
Where are you calling createToolTip function? Is it called while generating data chartData.addRows(data);?
Ref: check how createCustomHTMLContent function is used # https://developers.google.com/chart/interactive/docs/customizing_tooltip_content#custom_html_content

Dynamic event template in FullCalendar

Is there any way to dynamically change event template in FullCalendar?
Update. What I want is to specify new event html (e. g. in eventRender callback) and make FullCalendar to use it for my event rendering. Something like this:
eventRender: function(event, element, view) {
var template = '<div class="customEvent"></div>';
return $.parse(template);
}
Tried the sample above - didn't work.
You can add meta information on the event, like classes, and style accordingly:
events: [{
title: 'Blue Event',
start: '2014-06-01',
description: 'Lorem ipsum lorem ipsum',
class: 'blue main'
}]
And the CSS:
.fc-event.blue {}
.fc-event.main {}
On eventRender insert the classes with
eventRender: function (event, element) {
element.addClass(event.class)
}
And append more content like:
if (event.description) {
element.find('.fc-event-inner')
.append("<div class='desc'>" + event.description + "</div>");
}
$(document).ready(function () {
$('#calendar').fullCalendar({
header: { left: '', center: '', right: '' },
defaultDate: '2014-06-12',
eventRender: function (event, element) {
if (event.description) {
element.find('.fc-event-inner')
.append("<div class='desc'>" + event.description) + "</div>";
}
element.addClass(event.class)
},
events: [{
title: 'Blue Event',
start: '2014-06-01',
description: 'Lorem ipsum lorem ipsum',
class: 'blue main'
}, {
title: 'More Blue',
start: '2014-06-01',
description: 'More lorem ipsum',
class: 'blue main'
}, {
title: 'Long Event',
start: '2014-06-07',
end: '2014-06-10',
class: 'red main'
}, {
title: 'Meeting',
start: '2014-06-12T10:30:00',
end: '2014-06-12T12:30:00',
class: 'blue main'
}, {
title: 'Lunch',
start: '2014-06-12T12:00:00',
class: 'blue main'
}, {
title: 'Birthday Party',
start: '2014-06-13T07:00:00',
class: 'red main'
}, ],
});
});
body {
background-color: #eaefb5;
font-family: sans-serif;
}
.fc-event-time, .fc-event-title {
padding: 0 1px;
float: left;
clear: none;
margin-right: 10px;
}
.fc-event.main {
border: 5px solid #bbb;
margin: 5px;
padding: 3px
}
.fc-event.red {
background-color: #f85032;
}
.fc-event.red .fc-event-title {
font-family: Tahoma;
font-size: 1.2em
}
.fc-event.blue {
background: #87e0fd;
background: -moz-linear-gradient(top, #87e0fd 0%, #53cbf1 40%, #05abe0 100%);
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%, #87e0fd), color-stop(40%, #53cbf1), color-stop(100%, #05abe0));
background: -webkit-linear-gradient(top, #87e0fd 0%, #53cbf1 40%, #05abe0 100%);
background: -o-linear-gradient(top, #87e0fd 0%, #53cbf1 40%, #05abe0 100%);
background: -ms-linear-gradient(top, #87e0fd 0%, #53cbf1 40%, #05abe0 100%);
background: linear-gradient(to bottom, #87e0fd 0%, #53cbf1 40%, #05abe0 100%);
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#87e0fd', endColorstr='#05abe0', GradientType=0);
}
.fc-event.blue .fc-event-title {
font-size: 2em;
color: #EEE;
text-shadow: 2px 2px 4px #300000;
}
.fc-event.blue .desc {
font-size:.8em;
float:left;
clear:both;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<link rel="stylesheet" type="text/css" href="//cdnjs.cloudflare.com/ajax/libs/fullcalendar/2.0.3/fullcalendar.css">
<script type='text/javascript' src="//cdnjs.cloudflare.com/ajax/libs/moment.js/2.7.0/moment.min.js"></script>
<script type='text/javascript' src="//cdnjs.cloudflare.com/ajax/libs/fullcalendar/2.0.3/fullcalendar.min.js"></script>
<div id="calendar"></div>
The eventRender callback function can modify element, return a brand new DOM element that will be used for rendering instead, or it can return false, which will prevent the event from being rendered at all.
http://fullcalendar.io/docs/event_rendering/eventRender/
Example here: http://jsfiddle.net/3E8nk/506/
$('#calendar').fullCalendar({
header: {
left: 'prev,next today',
center: 'title',
right: 'month,agendaWeek,agendaDay'
},
defaultDate: '2014-06-12',
editable: true,
eventRender: function(event, element, view) {
return $('<div>' + event.title + '</div>');
},
events: [
{
title: 'All Day Event',
start: '2014-06-01'
},
{
title: 'Long Event',
start: '2014-06-07',
end: '2014-06-10'
},
{
id: 999,
title: 'Repeating Event',
start: '2014-06-09T16:00:00'
},
{
id: 999,
title: 'Repeating Event',
start: '2014-06-16T16:00:00'
},
{
title: 'Meeting',
start: '2014-06-12T10:30:00',
end: '2014-06-12T12:30:00'
},
{
title: 'Lunch',
start: '2014-06-12T12:00:00'
},
{
title: 'Birthday Party',
start: '2014-06-13T07:00:00'
},
{
title: 'Click for Google',
url: 'http://google.com/',
start: '2014-06-28'
},
]
});
Use the eventRender(callback) function to change the event template. Here is how you can add a tip to the event:
eventRender: function(event, element, view) {
element.qtip({
content: event.description
});
}
With this function you can fully customize any detail of the event that is displayed including adding a complete new event template. For more details check out the documentation:
http://fullcalendar.io/docs/event_rendering/eventRender/
In Version v4 of FullCalendar the arguments have changed (https://fullcalendar.io/docs/eventRender)
eventRender: function(info) {
var node = document.createElement('div');
node.append(document.createTextNode(info.event.title));
return node;
}
If you want to prevent an event from rendering just return false
eventRender: function(info) {
return false;
}
You may append new information like this
eventRender: function( event, element, view ) {
element.find('.fc-title').append('<span class="yourCSS"></span> ');
}

A linear gradient with variable number of stops in LESS? (or Sass)

Here's a CSS that I want to abstract with Less. In this case, there are 4 stops. But I have another class with 10 stops. How can I use variable number of arguments?
I see #arguments in the docs, but as you can notice, the syntax differs: some rules use all the arguments in a row, others group them in pairs: color-stop(x%, #y).
If you know a solution in Sass, suggest it, I can switch to it.
.action {
background: -moz-linear-gradient(top, #6db3f2 0%, #54a3ee 50%, #3690f0 51%, #1e69de 100%); /* FF3.6+ */
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#6db3f2), color-stop(50%,#54a3ee), color-stop(51%,#3690f0), color-stop(100%,#1e69de)); /* Chrome,Safari4+ */
background: -webkit-linear-gradient(top, #6db3f2 0%,#54a3ee 50%,#3690f0 51%,#1e69de 100%); /* Chrome10+,Safari5.1+ */
background: -o-linear-gradient(top, #6db3f2 0%,#54a3ee 50%,#3690f0 51%,#1e69de 100%); /* Opera11.10+ */
background: -ms-linear-gradient(top, #6db3f2 0%,#54a3ee 50%,#3690f0 51%,#1e69de 100%); /* IE10+ */
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#6db3f2', endColorstr='#1e69de',GradientType=0 ); /* IE6-9 */
background: linear-gradient(top, #6db3f2 0%,#54a3ee 50%,#3690f0 51%,#1e69de 100%); /* W3C */background: linear-gradient(top, #1e5799 0%,#2989d8 14%,#207cca 84%,#7db9e8 100%); /* W3C */
}
My own solution, using a modified file from bourbon project:
_linear-gradient.scss
#mixin linear-gradient($pos, $G1, $G2: false,
$G3: false, $G4: false,
$G5: false, $G6: false,
$G7: false, $G8: false,
$G9: false, $G10: false) {
// Detect what type of value exists in $pos
$pos-type: type-of(nth($pos, 1));
// If $pos is missing from mixin, reassign vars and add default position
#if ($pos-type == color) or (nth($pos, 1) == "transparent") {
$G10: $G9; $G9: $G8; $G8: $G7; $G7: $G6; $G6: $G5;
$G5: $G4; $G4: $G3; $G3: $G2; $G2: $G1; $G1: $pos;
$pos: top; // Default position
}
$usual:($G1);
$webkit: color-stop($G1);
#each $g in $G2, $G3, $G4, $G5, $G6, $G7, $G8, $G9, $G10 {
#if $g != false {
$usual: $usual + ',' + $g;
$webkit: $webkit + ',' + color-stop($g);
}
}
$usual: unquote($usual);
$webkit: unquote($webkit);
background-color: nth($G1, 1);
background: deprecated-webkit-gradient(linear, $usual); // Safari <= 5.0
background: -webkit-gradient(linear, $pos, $webkit); // Safari 5.1+, Chrome
background: -webkit-linear-gradient($pos, $usual); // Safari 5.1+, Chrome
background: -moz-linear-gradient($pos, $usual);
background: -ms-linear-gradient($pos, $usual);
background: -o-linear-gradient($pos, $usual);
background: linear-gradient($pos, $usual);
}
usage (screen.sass):
#import linear-gradient
button.action
+linear-gradient(top, #6db3f2 0%, #54a3ee 50%, #3690f0 51%, #1e69de 100%)
How I configured Sass with django-compressor:
STATICFILES_FINDERS = (
'django.contrib.staticfiles.finders.FileSystemFinder',
'django.contrib.staticfiles.finders.AppDirectoriesFinder',
# 'django.contrib.staticfiles.finders.DefaultStorageFinder',
'compressor.finders.CompressorFinder',
)
INSTALLED_APPS = (
...
'compressor',
)
COMPRESS = True
COMPRESS_PRECOMPILERS = (
('text/sass', 'sass {infile} {outfile}'),
)
COMPILER_FORMATS = {
'.sass': {
'binary_path': 'sass',
'arguments': '*.sass *.css'},
}
a template:
{% load compress %}
{% compress css %}
<link href="{{ STATIC_URL }}css/screen.sass" rel="stylesheet" type="text/sass" media="screen,projection"/>
{% endcompress %}

Resources