Here is a piece of code from FancyBox ...
JQUERY
// Set custom style, close if clicked, change title type and overlay color
$(".mainmenu").fancybox({
wrapCSS: 'fancybox-custom',
closeClick: false,
topRatio: 0,
scrolling: 'no',
fitToView: 'false',
helpers: {
title: {
type: 'inside'
},
overlay: {
css: {
'background': 'url(img/misc/fancybox_overlay.png)'
}
}
}
});
and additionally, I would like to add the following line to it, but somwhow it doesn't seem to work - getting tons of syntax errors here.
JQUERY
$(".blabla").css({"background-color":"yellow"});
Would be great if anyone could help.
Add your css here:
css : {
'background' : 'url(img/misc/fancybox_overlay.png)',
'background-color': 'yellow',
}
EDITED:
After seen the above discussion on the basis of the answer will be:
$(".maincontent").click(function(){
$(this).css('background-color','yellow');
});
I reckon that should be:
$(".blabla").css("background-color", "yellow");
Related
I make my own language using codemirror, what I want to do when I stop on name of function and hover on it or press on (Ctrl+I) to show tooltip display the type and other data for this function, the code run on jsfiddle.net but not run on jsbin.com
var cm = CodeMirror(document.getElementById("editor"), {
value: "function myScript() {\n return 100;\n}",
indentUnit: 4,
lineNumbers: true
});
var textMarker;
$('#add').click(function() {
textMarker = cm.markText({
line: 1,
ch: 4
}, {
line: 1,
ch: 10
}, {
className: 'marked-text'
});
$('.marked-text').tooltip({
title: 'This is a return statement',
container: 'body',
delay: { "show": 500, "hide": 100 },
animation: false
});
});
$('#remove').click(function() {
if (textMarker) {
textMarker.clear();
}
});
The link to working code: here code works
My try but not work: my try
Try adding libraries under "external resources" from jsfiddle to jsbin.
Edit:
Yes you're right you added the libraries. I made it work putting JQuery as the first script since you can't load bootstrap before JQuery. Then change the http to https.
I have function for creating/rendering input fields but i don't know how to add tool tip on it in EXTjs6
this is my function:
createInputField: function(value, fieldsMarginBottom, readonly) {
var fieldStyle = this.getFieldStyle(readonly);
var nameField = Ext.create('Ext.form.field.Text', {
name: 'name',
readOnly: true,
hideLabel: true,
value: value,
width: this.fieldWidth,
style: {
marginBottom: fieldsMarginBottom + 'px'
},
//My try which is not working
tooltip: {
trackMouse: true,
width: 140,
renderer: function(tip, item){
tip.setTitle('name');
tip.update('Count: ');
}
},
fieldStyle: fieldStyle
});
return nameField;
}
I hope you guys can help me. If you need any additional informations, please let me know and I'll provide. Thank you
As can be seen in the textfield docs, fields do not have a way to add a tooltip to their configuration, so you would have to create the tooltip manually.
If you look at the docs for Ext.tip.ToolTip how to do that, you may find a small example, where you just have to change the target as per the target configuration description:
var tip = Ext.create('Ext.tip.ToolTip', {
target: nameField.getEl(),
html: 'Press this button to clear the form'
});
Above answer is correct. Here is example of generic function which you write once and use wherever you required in project by using using attributes.
addToolTip : function (id, msg) {
new Ext.ToolTip({
target : id,
dismissDelay : 0,
anchor : 'right',
html : msg
});
};
I have two different openers for fancybox on the same page. I want to have a black border on .fancybox2 and the regular white on .fancybox1. There are also some other minor differences. This is the script.
$(".fancybox").fancybox1({
padding:10,
helpers: {
title: {
type: 'inside'
},
overlay: {
css : {
'background': 'rgba(0,0,0,0.6)'
}
}
}
});
//Fancy box number 2 not working with different style
$(".fancybox2").fancybox({
padding:10,
openEffect: 'elastic',
closeEffect: 'elastic',
helpers: {
title: {
type: 'inside'
},
overlay: {
locked: false,
css : {
'background': 'rgba(255,255,255, 0.6)'
}
}
}
});
I have tried to use this style but that will affect both, they will both have black border.enter code here
<style type="text/css">.fancybox-skin {background-color: #000 !important;}</style>
Anyone got some suggestions how to solve this?
Consider declaring your CSS using the Fancybox's Callbacks. For example; Here I can make use of the beforeShow event to change .fancybox-skin to white for every element with class .fancybox1
$(".fancybox1").fancybox({
beforeShow: function(){
// here set the border color for each class
$(".fancybox-skin").css("backgroundColor","white");
},
helpers : {
overlay : {
css : {
'background': 'rgba(0,0,0,0.6)'
}
}
}
});
Here is a full demo as per your requirements
I have some sample code up at http://defyordie.com/testbed/
This is for my portfolio and I'm working on replacing my old plugin with fancybox. My issue is with the responsiveness of the work sample popups. Scroll down to my 'work' section and click on one of the top 3 boxes since those are finished.
I'm working on a big cinema display, so I've noticed that as i expand my window, the royalslider running the slideshow expands horizontally but doesnt expand vertically until i make the browser window almost entirely fill my screen. I had hoped that it would scale proportionally. I've either initalized the fancybox incorrectly, royalslider incorrectly, or I have some sort of CSS issue.
The code :
$(document).ready(function () {
$('.fancybox').fancybox({
beforeShow: function () {
$(window).on({
'resize.fancybox': function () {
$.fancybox.update();
}
});
},
afterClose: function () {
$(window).off('resize.fancybox');
},
padding: 0,
margin: [60, 15, 0, 15],
nextEffect: 'fade',
prevEffect: 'none',
helpers: {
overlay: {
locked: false
}
},
afterLoad: function () {
$.extend(this, {
type: 'html',
width: '95%',
height: '100%',
minWidth: '930px'
});
}
});
});
I would like to get the element that called the qtip popup. In the documentation here it lets you set the position. I want to set the position using a jquery selector like $(this).find('.icon'). The problem is that this isn't the element that called the qtip (I think it's window).
Does anyone know how I can get the handle that called it (like it would if I set target to false)?
Thanks.
In the qtip source code I found this:
if(config.position.target === false) config.position.target = $(this);
Here's the solution I came up with and it seems to work. There probably is a better way to do it if I modified the qtip script but I want to leave that alone.
$(".report-error").qtip(
{
content: 'test content',
position:
{
adjust:
{
screen: true
},
target: false, //it is changed in the 'beforeRender' part in api section. by leaving it as false here in the qtip it will set it as the position I need using $(this)
corner:
{
target: 'bottomMiddle',
tooltip: 'topRight'
}
},
show:
{
when:
{
event: 'click'
}
},
style:
{
name: 'cream',
tip:
{
corner: 'topRight'
},
padding: 0,
width: 400,
border:
{
radius: 5,
width: 0
}
},
hide:
{
when:
{
event: 'unfocus'
}
},
api:
{
beforeRender: function() { //get the position that qtip found with $(this) in it's script and change it using that as the start position
this.options.position.target = $(this.elements.target).find('.icon');
this.elements.target = this.options.position.target; //update this as well. I don't actually know what it's use is
}
}
});
It's working on the site now at http://wncba.co.uk/results/