I'm trying to assign three different colours to three different articles on a single page using a:hover in Wordpress.
This is the site http://paragrams.wpshower.com/
At present all the articles turn pale yellow on a:hover. I'm trying to create different colours for each article (for example, first article to be yellow, the second article red, third blue and so on).
Below is the php & CSS for the a:hover at present. I assume I need to wrap each thumb id in a different div and specify the colour in the CSS?
PHP:
<ul class="mcol">
<?php if(have_posts()) : ?><?php while(have_posts()) : the_post(); ?>
<li class="article">
<?php
if ( has_post_thumbnail() ) { ?>
<?php
$imgsrcparam = array(
'alt' => trim(strip_tags( $post- >post_excerpt )),
'title' => trim(strip_tags( $post- >post_title )),
);
$thumbID = get_the_post_thumbnail( $post->ID, 'background', $imgsrcparam ); ?>
<div><?php echo "$thumbID"; ?></div>
<?php } ?>
<h2><?php the_title(); ?></h2>
and CSS:
.li_container {
background-attachment: scroll;
background-image: url(images/main-bg.gif);
background-repeat: repeat-y;
background-position: left top;
}
.li_container .article:hover {
background-color:#57bfeb;
}
This is the js:
# * Splits a <ul>/<ol>-list into equal-sized columns.
# *
# * Requirements:
# * <ul>
# * <li>"ul" or "ol" element must be styled with margin</li>
# * </ul>
# *
# * #see http://www.codeasily.com/jquery/multi-column-list-with-jquery
# */
jQuery.fn.makeacolumnlists = function(settings){
settings = jQuery.extend({
cols: 3, // set number of columns
colWidth: 0, // set width for each column or leave 0 for auto width
equalHeight: 'li', // can be false, 'ul', 'ol', 'li'
startN: 1 // first number on your ordered list
}, settings);
if(jQuery('> li', this)) {
this.each(function(y) {
var y=jQuery('.li_container').size(),
height = 0,
maxHeight = 0,
t = jQuery(this),
classN = t.attr('class'),
listsize = jQuery('> li', this).size(),
percol = Math.ceil(listsize/settings.cols),
contW = t.width(),
bl = ( isNaN(parseInt(t.css('borderLeftWidth'),10)) ? 0 : parseInt(t.css('borderLeftWidth'),10) ),
br = ( isNaN(parseInt(t.css('borderRightWidth'),10)) ? 0 : parseInt(t.css('borderRightWidth'),10) ),
pl = parseInt(t.css('paddingLeft'),10),
pr = parseInt(t.css('paddingRight'),10),
ml = parseInt(t.css('marginLeft'),10),
mr = parseInt(t.css('marginRight'),10),
col_Width = Math.floor((contW - (settings.cols-1)*(bl+br+pl+pr+ml+mr))/settings.cols);
if (settings.colWidth) {
col_Width = settings.colWidth;
}
var colnum=1,
percol2=percol;
jQuery(this).addClass('li_cont1').wrap('<div id="li_container' + (++y) + '" class="li_container"></div>');
for (var i=0; i<=listsize; i++) {
if (colnum > settings.cols) colnum = 1;
var eq = jQuery('> li:eq('+i+')',this);
eq.addClass('li_col'+colnum);
colnum++;
//if(i>=percol2) { percol2+=percol; colnum++; }
//var eq = jQuery('> li:eq('+i+')',this);
//eq.addClass('li_col'+ colnum);
//if(jQuery(this).is('ol')){eq.attr('value', ''+(i+settings.startN))+'';}
}
jQuery(this).css({cssFloat:'left', width:''+col_Width+'px'});
for (colnum=2; colnum<=settings.cols; colnum++) {
if(jQuery(this).is('ol')) {
jQuery('li.li_col'+ colnum, this).appendTo('#li_container' + y).wrapAll('<ol class="li_cont'+colnum +' ' + classN + '" style="float:left; width: '+col_Width+'px;"></ol>');
} else {
jQuery('li.li_col'+ colnum, this).appendTo('#li_container' + y).wrapAll('<ul class="li_cont'+colnum +' ' + classN + '" style="float:left; width: '+col_Width+'px;"></ul>');
}
}
if (settings.equalHeight=='li') {
for (colnum=1; colnum<=settings.cols; colnum++) {
jQuery('#li_container'+ y +' li').each(function() {
var e = jQuery(this);
var border_top = ( isNaN(parseInt(e.css('borderTopWidth'),10)) ? 0 : parseInt(e.css('borderTopWidth'),10) );
var border_bottom = ( isNaN(parseInt(e.css('borderBottomWidth'),10)) ? 0 : parseInt(e.css('borderBottomWidth'),10) );
height = e.height() + parseInt(e.css('paddingTop'), 10) + parseInt(e.css('paddingBottom'), 10) + border_top + border_bottom;
maxHeight = (height > maxHeight) ? height : maxHeight;
});
}
for (colnum=1; colnum<=settings.cols; colnum++) {
var eh = jQuery('#li_container'+ y +' li');
var border_top = ( isNaN(parseInt(eh.css('borderTopWidth'),10)) ? 0 : parseInt(eh.css('borderTopWidth'),10) );
var border_bottom = ( isNaN(parseInt(eh.css('borderBottomWidth'),10)) ? 0 : parseInt(eh.css('borderBottomWidth'),10) );
mh = maxHeight - (parseInt(eh.css('paddingTop'), 10) + parseInt(eh.css('paddingBottom'), 10) + border_top + border_bottom );
eh.height(mh);
}
} else
if (settings.equalHeight=='ul' || settings.equalHeight=='ol') {
for (colnum=1; colnum<=settings.cols; colnum++) {
jQuery('#li_container'+ y +' .li_cont'+colnum).each(function() {
var e = jQuery(this);
var border_top = ( isNaN(parseInt(e.css('borderTopWidth'),10)) ? 0 : parseInt(e.css('borderTopWidth'),10) );
var border_bottom = ( isNaN(parseInt(e.css('borderBottomWidth'),10)) ? 0 : parseInt(e.css('borderBottomWidth'),10) );
height = e.height() + parseInt(e.css('paddingTop'), 10) + parseInt(e.css('paddingBottom'), 10) + border_top + border_bottom;
maxHeight = (height > maxHeight) ? height : maxHeight;
});
}
for (colnum=1; colnum<=settings.cols; colnum++) {
var eh = jQuery('#li_container'+ y +' .li_cont'+colnum);
var border_top = ( isNaN(parseInt(eh.css('borderTopWidth'),10)) ? 0 : parseInt(eh.css('borderTopWidth'),10) );
var border_bottom = ( isNaN(parseInt(eh.css('borderBottomWidth'),10)) ? 0 : parseInt(eh.css('borderBottomWidth'),10) );
mh = maxHeight - (parseInt(eh.css('paddingTop'), 10) + parseInt(eh.css('paddingBottom'), 10) + border_top + border_bottom );
/*eh.height(mh);*/
}
}
jQuery('#li_container' + y).append('<div style="clear:both; overflow:hidden; height:0px;"></div>');
});
}
}
jQuery.fn.uncolumnlists = function(){
jQuery('.li_cont1').each(function(i) {
var onecolSize = jQuery('#li_container' + (++i) + ' .li_cont1 > li').size();
if(jQuery('#li_container' + i + ' .li_cont1').is('ul')) {
jQuery('#li_container' + i + ' > ul > li').appendTo('#li_container' + i + ' ul:first');
for (var j=1; j<=onecolSize; j++) {
jQuery('#li_container' + i + ' ul:first li').removeAttr('class').removeAttr('style');
}
jQuery('#li_container' + i + ' ul:first').removeAttr('style').removeClass('li_cont1').insertBefore('#li_container' + i);
} else {
jQuery('#li_container' + i + ' > ol > li').appendTo('#li_container' + i + ' ol:first');
for (var j=1; j<=onecolSize; j++) {
jQuery('#li_container' + i + ' ol:first li').removeAttr('class').removeAttr('style');
}
jQuery('#li_container' + i + ' ol:first').removeAttr('style').removeClass('li_cont1').insertBefore('#li_container' + i);
}
jQuery('#li_container' + i).remove();
});
}
You wouldn't need to do anything fancy with divs; just give each li tag a unique class, and specify those class colors in css.
From your code, you could change the line
<li class="article">
to
<?php
switch($post->ID) {
case 1:
$class = 'yellow'; break;
case 2:
$class = 'blue'; break;
case 3:
$class = 'green'; break;
}
?>
<li class="article <?php echo $class; ?>">
This will effectively output class='article yellow' for the first article, class='article blue' for the second, etc. You can then make this all work by changing the css as follows:
.li_container .article.yellow:hover { background-color:#57bfeb; }
.li_container .article.green:hover { background-color:green; }
.li_container .article.blue:hover { background-color:blue; }
If you want to get fancy, you could also change switch($post->ID) to switch(mod($post->ID,3)) to do lots of color changing.
eykanal has a good solution. Just to throw out another option, you could use jquery and just dynamically add the classes based on the article positions in the dom. Something like:
Add this inside the head element of your page:
<script type="text/javascript"src="https://ajax.googleapis.com/ajax/libs/jquery/1.5.0/jquery.min.js"></script>
<script type="text/javascript">
$(document).ready(function () {
$('.mcol li.article:nth-child(1)').addClass('yellow')
$('.mcol li.article:nth-child(2)').addClass('red')
$('.mcol li.article:nth-child(3)').addClass('blue')
});
</script>
You would then add something like this to your css file:
.yellow:hover { background-color: yellow; }
.red:hover { background-color: red; }
.blue:hover { background-color: blue; }
Change the colors to the hex codes of your choice of course.
Have Fun!
What i'd personally do is add an incrementing class using PHP, like so..
<ul class="mcol">
<?php if(have_posts()) : $i = 0; while(have_posts()) : the_post(); $i++; ?>
<li class="article <?php echo "item-$i";?>">
You then get something like..
<li class="article item-1">content</li>
<li class="article item-2">content</li>
<li class="article item-3">content</li>
Then toggle a class on hover to..
$(document).ready(function(){
$('li.article').hover(function(){
$(this).toggleClass('active-item');
});
});
That then gives you one class that covers all list items, one unique to each item shown, and one that is only attached to the element on hover..
li.article { /* CSS for all list items */ }
li.article.active-item { /* CSS for all any item active */ }
li.item-1 { /* CSS for the first item */ }
li.item-2 { /* CSS for the second item */ }
li.active-item.item-1 { /* CSS for the first item when hovered */ }
li.active-item.item-2 { /* CSS for the secpnd item when hovered */ }
NOTE: It doesn't hurt to make your CSS selectors more specific, adding an ID infront of those(say, the parent list ID) will help ensure you get less conflict with other competing styles.
I hope that's helpful.. ;)
Related
here is the link which i want to use for template design http://interactjs.io/
i can drag the module height from one container into second container and can drag position by using interact.js functionality by using jquery and php... record should be update ib database on drop... see screen below for more detail
see screenshot for more help
need solution with jquery and PHP...interact.js is compulsory :)
HTML:
<div class="containerdiv" style="float:left">
<div id="drag-450-180" class="draggable js-drag">180</div>
<div id="drag-900-180" class="draggable js-drag">180</div>
<div id="drag-450-240" class="draggable js-drag">240 </div>
<div id="drag-900-240" class="draggable js-drag">240 </div>
<div id="drag-450-360" class="draggable js-drag">360 </div>
<div id="drag-900-360" class="draggable js-drag">360 </div>
<div id="drag-450-480" class="draggable js-drag">360 </div>
<div id="drag-900-480" class="draggable js-drag">360 </div>
</div>
<div class="dropzone-wrapper">
<div id="drop1" class="dropzone js-drop">Dropzone</div>
</div>
interact('.js-drag')
.draggable({
restrict: {
restriction: "parent",
endOnly: true,
elementRect: { top: 0, left: 0, bottom: 1, right: 1 }
},
overlap: 'pointer',
inertia: true,
checker: function (dragEvent, // related dragmove or dragend
event, // Touch, Pointer or Mouse Event
dropped, // bool default checker result
dropzone, // dropzone Interactable
dropElement, // dropzone elemnt
draggable, // draggable Interactable
draggableElement) {// draggable element
// only allow drops into empty dropzone elements
return dropped && !dropElement.hasChildNodes();
}
})
.on('dragstart', function (event) {
event.interaction.x = parseInt(event.target.getAttribute('data-x'), 10) || 0;
event.interaction.y = parseInt(event.target.getAttribute('data-y'), 10) || 0;
})
.on('dragmove', function (event) {
event.interaction.x += event.dx;
event.interaction.y += event.dy;
if (transformProp) {
event.target.style[transformProp] =
'translate(' + event.interaction.x + 'px, ' + event.interaction.y + 'px)';
}
else {
event.target.style.left = event.interaction.x + 'px';
event.target.style.top = event.interaction.y + 'px';
}
})
.on('dragend', function (event) {
// event.target.setAttribute('data-x', event.interaction.x);
// event.target.setAttribute('data-y', event.interaction.y);
event.target.setAttribute('data-x', 0);
event.target.setAttribute('data-y', 0);
event.target.removeAttribute('style');
});
interact('.js-drag2')
.draggable({
restrict: {
restriction: "parent",
endOnly: true,
elementRect: { top: 0, left: 0, bottom: 1, right: 1 }
} ,
inertia: true,
overlap: 0.01,
checker: function (dragEvent, // related dragmove or dragend
event, // Touch, Pointer or Mouse Event
dropped, // bool default checker result
dropzone, // dropzone Interactable
dropElement, // dropzone elemnt
draggable, // draggable Interactable
draggableElement) {// draggable element
// only allow drops into empty dropzone elements
return dropped && !dropElement.hasChildNodes();
}
})
.on('dragstart', function (event) {
event.interaction.x = parseInt(event.target.getAttribute('data-x'), 10) || 0;
event.interaction.y = parseInt(event.target.getAttribute('data-y'), 10) || 0;
})
.on('dragmove', function (event) {
event.interaction.x += event.dx;
event.interaction.y += event.dy;
if (transformProp) {
event.target.style[transformProp] =
'translate(' + event.interaction.x + 'px, ' + event.interaction.y + 'px)';
}
else {
event.target.style.left = event.interaction.x + 'px';
event.target.style.top = event.interaction.y + 'px';
}
})
.on('dragend', function (event) {
event.target.setAttribute('data-x', event.interaction.x);
event.target.setAttribute('data-y', event.interaction.y);
});
I have a big problem. I have a mysql database which contains 12 character length fields. I would like to display somehow.
Sample data from the field:
233215334523
I would like to display 0 and 1 with red background 2 3 with yellow background and 4 5 with green background.
Important! I know str_split could split the string into characters, or I could use $string[1] $string[2] etc. also, but not now, because this cms use the lex parser ( you couldn't use php variables here!).
So I need some great idea how could I split virtual this 12 character length variable. The best should be some which display these numbers with the background colors what I wrote earlier.
I hope someone could help for me, because I have no idea. Many thanks!
Wrap each character in a span, with a classname:
HTML:
<div id="fieldToSplit">233215334523</div>
javascript:
var element = document.getElementById("fieldToSplit")
var data = element.innerHTML.split("");
var wrappedString = "";
for (var i = 0; i < data.length; i++) {
wrappedString += "<span class='shade" + data[i] + "'>" + data[i] + "</span>";
}
element.innerHTML = wrappedString;
CSS:
.shade0, .shade1 {
background-color: #FF0000;
}
.shade2, .shade3 {
background-color: #FFFF00;
}
.shade4, .shade5 {
background-color: #00FF00;
}
This solution allows you to freely style each digit independently, say you wanted a darker green for 5 than for 4. And if later you need styles for 6,7,8, and 9, all you need to do is add classes .shade6, .shade7, .shade8, and .shade9.
Fiddle here:
http://jsfiddle.net/rwbm9ttn/1/
Something like this?
$(document).ready(function() {
var letters = $('.source').html().split(/\s?/)
for (var i = 0; i <= letters.length; ++i) {
$('<span class="lt' + letters[i] + '">').html(letters[i]).appendTo(".letters");
}
});
.lt2 {
background: yellow;
}
.lt3 {
background: green;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.0.3/jquery.min.js"></script>
<div class="source">233215334523</div>
<div class="letters"></div>
Here is a pure jquery & CSS solution:
http://jsfiddle.net/k91ax5g9/1/
HTML
<div class='num'>101234567</div>
<div class='num'>1011223444</div>
<div class='num'>124413223</div>
<div class='num'>323123133</div>
JS
$(".num").each(function(){
var $el = $(this);
var t =$el.html();
$el.html('');
for(var c in t){
var char = t[c];
$el.append($("<span>", {'text_val': char}).html(char));
}
});
CSS
[text_val="0"], [text_val="1"]{
background: red;
}
[text_val="2"], [text_val="3"]{
background: orange;
}
[text_val="4"], [text_val="5"]{
background: green;
}
An entirely jQuery version would be like this -
$(document).ready(function(){
var data = 233215334523;
var str = data.toString();
var hold = '';
for(var i = 0; i<str.length; i++)
{
if(str[i] == 0 || str[i] == 1)
{
hold = hold + '<span style="background-color: red;">'+str[i]+'</span>';
$('.print').html(hold);
}
else if(str[i] == 2 || str[i] == 3)
{
hold = hold + '<span style="background-color: yellow;">'+str[i]+'</span>';
$('.print').html(hold);
}
else if(str[i] == 4 || str[i] == 5)
{
hold = hold + '<span style="background-color: green;">'+str[i]+'</span>';
$('.print').html(hold);
}
}
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<p class="print"></p>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8"/>
<title>Yelp Search API Example</title>
<style type="text/css">
html, body {width: 100%; height: 100%; font-family: arial;}
body {margin:0;padding 0;overflow: hidden;}
#mapContainer {padding-top: 50px;}
#map, #mapContainer {width:100%; height: 100%;}
#top {position:absolute; top:0; left:0; width: 100%; height: 50px; line-height: 50px;}
#spinner { visibility: hidden; margin-left:3px;}
#poweredby, #searchbox {line-height: 50px;}
#searchbox {text-align: center;}
#poweredby { float: right; margin-right: 3px;}
#poweredby img { vertical-align: baseline;}
.marker {font-size: 11px;}
.marker .businessimage { float: left;}
.marker .ratingsimage {vertical-align:middle; margin-top:0px;}
.marker .businessinfo { margin-left: 110px;}
</style>
<script src="http://maps.google.com/maps?file=api&v=2&key=[AIzaSyByEg0pBD4dGr3gZCk863XZZ0ZBkqhDhR4]"
type="text/javascript"></script>
<script type="text/javascript">
var YWSID = "aSVpoAZwxvtcwsscdWjBBw"; // common required parameter (api key)
var map = null;
var icon = null;
/*
* Creates the map object and calls setCenterAndBounds
* to instantiate it.
*/
function load() {
map = new GMap2(document.getElementById("map"));
GEvent.addListener(map, "load", function() {updateMap();});
map.setCenter(new GLatLng(40.296448,-79.478141),13);
map.addControl(new GLargeMapControl());
map.addControl(new GMapTypeControl());
map.setMapType(G_HYBRID_MAP);
if (window.attachEvent) window.attachEvent("onresize", function() { map.checkResize()} );
else if (window.addEventListener) window.addEventListener("resize", function() { map.checkResize()}, false);
// setup our marker icon
icon = new GIcon();
icon.image = "images/marker_star.png";
icon.shadow = "images/marker_shadow.png";
icon.iconSize = new GSize(20, 29);
icon.shadowSize = new GSize(38, 29);
icon.iconAnchor = new GPoint(15, 29);
icon.infoWindowAnchor = new GPoint(15, 3);
}
/*
* Construct the URL to call for the API request
*/
function constructYelpURL() {
var mapBounds = map.getBounds();
var URL = "http://api.yelp.com/" +
"business_review_search?"+
"callback=" + "handleResults" +
"&term=" + document.getElementById("term").value +
"&num_biz_requested=10" +
"&tl_lat=" + mapBounds.getSouthWest().lat() +
"&tl_long=" + mapBounds.getSouthWest().lng() +
"&br_lat=" + mapBounds.getNorthEast().lat() +
"&br_long=" + mapBounds.getNorthEast().lng() +
"&ywsid=" + YWSID;
return encodeURI(URL);
}
/*
* Called on the form submission: updates the map by
* placing markers on it at the appropriate places
*/
function updateMap() {
// turn on spinner animation
document.getElementById("spinner").style.visibility = 'visible';
var yelpRequestURL = constructYelpURL();
/* clear existing markers */
map.clearOverlays();
/* do the api request */
var script = document.createElement('script');
script.src = yelpRequestURL;
script.type = 'text/javascript';
var head = document.getElementsByTagName('head').item(0);
head.appendChild(script);
return false;
}
/*
* If a sucessful API response is received, place
* markers on the map. If not, display an error.
*/
function handleResults(data) {
// turn off spinner animation
document.getElementById("spinner").style.visibility = 'hidden';
if(data.message.text == "OK") {
if (data.businesses.length == 0) {
alert("Error: No businesses were found near that location");
return;
}
for(var i=0; i<data.businesses.length; i++) {
biz = data.businesses[i];
createMarker(biz, new GLatLng(biz.latitude, biz.longitude), i);
}
}
else {
alert("Error: " + data.message.text);
}
}
/*
* Formats and returns the Info Window HTML
* (displayed in a balloon when a marker is clicked)
*/
function generateInfoWindowHtml(biz) {
var text = '<div class="marker">';
// image and rating
text += '<img class="businessimage" src="'+biz.photo_url+'"/>';
// div start
text += '<div class="businessinfo">';
// name/url
text += ''+biz.name+'<br/>';
// stars
text += '<img class="ratingsimage" src="'+biz.rating_img_url_small+'"/> based on ';
// reviews
text += biz.review_count + ' reviews<br/><br />';
// categories
text += formatCategories(biz.categories);
// neighborhoods
if(biz.neighborhoods.length)
text += formatNeighborhoods(biz.neighborhoods);
// address
text += biz.address1 + '<br/>';
// address2
if(biz.address2.length)
text += biz.address2+ '<br/>';
// city, state and zip
text += biz.city + ', ' + biz.state + ' ' + biz.zip + '<br/>';
// phone number
if(biz.phone.length)
text += formatPhoneNumber(biz.phone);
// Read the reviews
text += '<br/>Read the reviews ยป<br/>';
// div end
text += '</div></div>'
return text;
}
/*
* Formats the categories HTML
*/
function formatCategories(cats) {
var s = 'Categories: ';
for(var i=0; i<cats.length; i++) {
s+= cats[i].name;
if(i != cats.length-1) s += ', ';
}
s += '<br/>';
return s;
}
/*
* Formats the neighborhoods HTML
*/
function formatNeighborhoods(neighborhoods) {
s = 'Neighborhoods: ';
for(var i=0; i<neighborhoods.length; i++) {
s += '' + neighborhoods[i].name + '';
if (i != neighborhoods.length-1) s += ', ';
}
s += '<br/>';
return s;
}
/*
* Formats the phone number HTML
*/
function formatPhoneNumber(num) {
if(num.length != 10) return '';
return '(' + num.slice(0,3) + ') ' + num.slice(3,6) + '-' + num.slice(6,10) + '<br/>';
}
/*
* Creates a marker for the given business and point
*/
function createMarker(biz, point, markerNum) {
var infoWindowHtml = generateInfoWindowHtml(biz)
var marker = new GMarker(point, icon);
map.addOverlay(marker);
GEvent.addListener(marker, "click", function() {
marker.openInfoWindowHtml(infoWindowHtml, {maxWidth:400});
});
// automatically open first marker
if (markerNum == 0)
marker.openInfoWindowHtml(infoWindowHtml, {maxWidth:400});
}
//]]>
</script>
</head>
<body onload="load()">
<div id="top">
<div id="poweredby">Powered by <img src="http://static.px.yelp.com/i/map/miniMapLogo.png" border="0" /></div>
<div id="searchbox">
<form>
Search for <input type="text" id="term" name="term" value="flannery-cars-greensburg"/> <input type="button" value="Search" onclick="return updateMap();"/>
<img id="spinner" src="images/spinner.gif" />
<span class="error" id="errorMessage" />
</form>
</div>
</div>
<div id="mapContainer"><div id="map"></div></div>
</body>
</html>
Website
http://www.724-streamline-marketing.com/testing2.html
I am trying to gather metrics for reviews, rating, map location from the yelp api, I am unsure why it will not stay.
Any help would be grateful or even point me in the right direction on using a 3rd party app to create yelp data
Your problem is simple,
<script src="http://maps.google.com/maps?file=api&v=2&key=[AIzaSyByEg0pBD4dGr3gZCk863XZZ0ZBkqhDhR4]"
Get rid of the brackets [] surrounding the key.
I'm using flexiquoterotator for word press I tweaked it to show the next and previous button following is my code
function ($) {
var callquote;
quoteRotator = {
i: 1,
quotes: [";
$i=0;
foreach($results as $result){
echo "\"$openquote<span id='quote'>$result->quote</span>$closequote";
if($result->author != '')
echo " <span id='quoteauthor'>$result->author</span>";
echo "\",\n";
$i++;
}
],
numQuotes: ".$i.",
fadeDuration: ".$fade.",
fadeoutDuration: ".$fadeout.",
delay: ".$delay.",
quotesInit: function(){
if (this.numQuotes < 1){
document.getElementById('quoterotator').innerHTML=\"No Quotes Found\";
} else {
this.navQuote();
this.quoteRotate();
this.quotehover();
}
},
navQuote: function() {
$('<div id=\"quotenav\"></div>').insertAfter('#quotearea');
for (n=1; n <= this.numQuotes ; n++) {
}
$('#quotenav').append('<span onclick=\"quoteRotator.callQuote(this,'+n+')\">Next</span>');
for (k= -3; k <= this.numQuotes ; k++) {
}
$('#quotenav').append('<span id=\"test\" onclick=\"quoteRotator.callQuote(this,'+k+')\">Prev</span>');
// insert style
$('head').append('<style type=\"text/css\">#quotenav {display: block;text-align: center;font-size: 50px;color: #000;}#quotenav span {margin: 0 3px;cursor: pointer;}#quotenav span.active,#quotenav span:hover{color: red;}</style>');
},
quoteRotate: function(i){
if(!i) {
i = this.i;
}
$('#quotenav span').each(function () {
$(this).removeClass('active');
});
$('#quotenav span:nth-child('+i+')').addClass('active');
jQuery('#quoterotator').hide().html(this.quotes[i - 1]).fadeIn(this.fadeDuration * 1000).css('filter','');
this.i = i % (this.numQuotes) + 1;
callquote = setTimeout('quoteRotator.quoteRotate()', (this.delay + this.fadeDuration) * 1000);
},
callQuote: function(e,n) {
clearTimeout(callquote);
this.quoteRotate(n);
},
quotehover: function() {
jQuery('#quotearea').mouseenter(function () {
clearTimeout(callquote);
}).mouseleave(function(){
setTimeout('quoteRotator.quoteRotate()', 500);
});
}
}
})(jQuery);
The above code doesn't shows the next and prev buttons instead it works for dot base navigation.
I Changed the location for buttons and it worked.
For some reason the editor is very limited and I can't color my text
What I want to achieve on text inside a HTML tag:
Black White Black White
How the HTML look:
<h3 class="widget-title">Black White Black White</h3>
I know it is possible to fix this by adding span tags:
<h3 class="widget-title">Black <span style="color:FFF;">White</span> Black <span style="color:FFF;">White</span></h3>
Are there any easier work-around on this? Is this supported in CSS3 somehow or do I have to code this in JQuery to achieve it?
Thanks for the answer guys. Perhaps, I wasn't clear on my question... What I want was make the even word to change color. Here is a modified snippet from undefined.
var txt = $('.widget-title').text().split(' ');
var str = "";
$.each(txt, function(i,v){
if ( (i&1) == 1 ) {
str += " <span style='color:red'>" + v + "</span> ";
} else {
str += " " + v;
}
})
$('.widget-title').html(str)
try this:
var txt = $('.widget-title').text().split(' ');
var str = "";
$.each(txt, function(i,v){
if (v == 'something') {
str += "<span class='something'>" + v + "</span>"
} else { str += " " + v}
})
$('.widget-title').html(str)
DEMO
This could be achieved by javascript:
var title = document.getElementsByClassName('widget-title')[0],
titleText = title.innerHTML,
words = titleText.split(' '),
len = words.length,
i;
title.innerHTML = '';
for (i = 0 ; i < len ; i++) {
var elem = document.createElement('span');
elem.innerHTML = words[i];
elem.style.color = words[i];
title.appendChild(elem);
}
JSFiddle
http://jsfiddle.net/kastU/2/
This appears to be exactly what you're looking for:
http://www.codingforums.com/showthread.php?t=6858
(found with "the Google")
Following is the code to do this with PHP, You need to call function colorize("Enter text which you want to see in Black and White style");
<?php
function colorize($text) {
$array = explode(' ', $text);
$index = 1;
foreach ($array as $value) {
if ($index%2) {
echo '<span style="color:#FFF;">';
echo $value;
echo '</span>';
} else {
echo '<span style="color:#000;">';
echo $value;
echo '</span>';
}
$index++;
}
}
?>