I have an input field I changed it to a checkbox for multiple choices.
The worry here I can't add the checkbox, I mean that my user should click on Ctrl and select on the same time several choices. You can see it in this Image:
This following my code of the form:
$app->get('/Chart/{currency}/{year}/{zone}/{lru}....... , function(Request $request,...... $repsite, $lru, $contract, $forecast) use ($app) {
if ($app['security']->isGranted('ROLE_USER')) {
///start form
$user = $app['security']->getToken()->getUser();
$form = $app['form.factory']->createBuilder('form')->setMethod('GET')
.
.
.
.
->add('lru', 'choice', array(
'choices' => array(
'\'ATSU\'' => 'ATSU',
'\'APCC\'' => 'APCC',
.....
),
'required' => FALSE,
'empty_value' => 'ALL',
'empty_data' => NULL,
'multiple' => TRUE
//'expanded' => TRUE
))
I want do a classic checkbox like this on the right:
I did a research on forums I found that I should use multiple and expanded and to set them to TRUE. When I add expanded=TRUE list became very "ugly", I give you a screensheet:
Can you please tell me how can I change my code to do a checkbox for multiple choicelike in the picture above.
I hope that I find solution. Thank you.
you can do this, this is implemented in this with code.
you will require jquery to do this.
change this code according to your use
https://codepen.io/elmahdim/pen/hlmri
/*
Dropdown with Multiple checkbox select with jQuery - May 27, 2013
(c) 2013 #ElmahdiMahmoud
license: https://www.opensource.org/licenses/mit-license.php
*/
$(".dropdown dt a").on('click', function() {
$(".dropdown dd ul").slideToggle('fast');
});
$(".dropdown dd ul li a").on('click', function() {
$(".dropdown dd ul").hide();
});
function getSelectedValue(id) {
return $("#" + id).find("dt a span.value").html();
}
$(document).bind('click', function(e) {
var $clicked = $(e.target);
if (!$clicked.parents().hasClass("dropdown")) $(".dropdown dd ul").hide();
});
$('.mutliSelect input[type="checkbox"]').on('click', function() {
var title = $(this).closest('.mutliSelect').find('input[type="checkbox"]').val(),
title = $(this).val() + ",";
if ($(this).is(':checked')) {
var html = '<span title="' + title + '">' + title + '</span>';
$('.multiSel').append(html);
$(".hida").hide();
} else {
$('span[title="' + title + '"]').remove();
var ret = $(".hida");
$('.dropdown dt a').append(ret);
}
});
body {
font: normal 14px/100% "Andale Mono", AndaleMono, monospace;
color: #fff;
padding: 50px;
width: 300px;
margin: 0 auto;
background-color: #374954;
}
.dropdown {
position: absolute;
top:50%;
transform: translateY(-50%);
}
a {
color: #fff;
}
.dropdown dd,
.dropdown dt {
margin: 0px;
padding: 0px;
}
.dropdown ul {
margin: -1px 0 0 0;
}
.dropdown dd {
position: relative;
}
.dropdown a,
.dropdown a:visited {
color: #fff;
text-decoration: none;
outline: none;
font-size: 12px;
}
.dropdown dt a {
background-color: #4F6877;
display: block;
padding: 8px 20px 5px 10px;
min-height: 25px;
line-height: 24px;
overflow: hidden;
border: 0;
width: 272px;
}
.dropdown dt a span,
.multiSel span {
cursor: pointer;
display: inline-block;
padding: 0 3px 2px 0;
}
.dropdown dd ul {
background-color: #4F6877;
border: 0;
color: #fff;
display: none;
left: 0px;
padding: 2px 15px 2px 5px;
position: absolute;
top: 2px;
width: 280px;
list-style: none;
height: 100px;
overflow: auto;
}
.dropdown span.value {
display: none;
}
.dropdown dd ul li a {
padding: 5px;
display: block;
}
.dropdown dd ul li a:hover {
background-color: #fff;
}
button {
background-color: #6BBE92;
width: 302px;
border: 0;
padding: 10px 0;
margin: 5px 0;
text-align: center;
color: #fff;
font-weight: bold;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
<dl class="dropdown">
<dt>
<a href="#">
<span class="hida">Select</span>
<p class="multiSel"></p>
</a>
</dt>
<dd>
<div class="mutliSelect">
<ul>
<li>
<input type="checkbox" value="Apple" />Apple</li>
<li>
<input type="checkbox" value="Blackberry" />Blackberry</li>
<li>
<input type="checkbox" value="HTC" />HTC</li>
<li>
<input type="checkbox" value="Sony Ericson" />Sony Ericson</li>
<li>
<input type="checkbox" value="Motorola" />Motorola</li>
<li>
<input type="checkbox" value="Nokia" />Nokia</li>
</ul>
</div>
</dd>
<button>Filter</button>
</dl>
Hope this helps
Related
I am using Ultimate Popup Plugin from CodeCanyon on this website Click here to create a login modal.
The code is working fine, but the popup stays even if someone clicks outside the popup, and the user must enter the details and click enter.
This is how it looks;
I tried providing a z-index to keep the popup on but I am stuck.
I had updated the code I have for the wordpress plugin whatever I could find.
This is the CSS and the JS of the popup:
jQuery(window).load(function(){
if (jQuery.cookie("popupTemporaryCookie13428")) {
// Popup is hiding after showing first time!
jQuery("#ultimate-popup-13428").hide();
} else if (jQuery.cookie("popupLongerCookie13428")) {
var inst = jQuery("#ultimate-popup-13428").remodal();
inst.open();
jQuery("#ultimate-popup-13428").addClass("ultimate-popup-wrapper-activate");
} else {
var inst = jQuery("#ultimate-popup-13428").remodal();
inst.open();
jQuery("#ultimate-popup-13428").addClass("ultimate-popup-wrapper-activate");
}
var expiresAt = new Date();
expiresAt.setTime(expiresAt.getTime() + 1*24*60*60*1000); // Days
jQuery.cookie("popupLongerCookie13428", new Date());
jQuery.cookie("popupTemporaryCookie13428", true, { expires: expiresAt });
});
* {
box-sizing: border-box;
}
*:before,
*:after {
box-sizing: border-box;
}
.ultimate-popup-wrapper {
background: #fff none repeat scroll 0 0;
border-top: 8px solid;
padding: 35px;
position: fixed;
text-align: center;
z-index: 9999;
opacity: 0;
filter: alpha(opacity=0);
-webkit-transition: .4s;
transition: .4s;
visibility: hidden;
max-width: 100%;
}
.ultimate-popup-wrapper-activate {
opacity: 1;
filter: alpha(opacity=100);
visibility: visible;
}
.cross-btn-ppm {
font-size: 20px;
font-weight: 700;
position: absolute;
right: 10px;
text-transform: uppercase;
top: 5px;
cursor: pointer;
z-index: 99;
font-family: arial, sans-serif;
}
.ultimate-popup-inner h2,
.entry-content .ultimate-popup-inner h2,
.entry-summary .ultimate-popup-inner h2,
.page-content .ultimate-popup-inner h2,
.comment-content .ultimate-popup-inner h2 {
font-size: 25px;
margin: 0 0 15px;
word-wrap: normal;
-webkit-hyphens: none;
-moz-hyphens: none;
-ms-hyphens: none;
hyphens: none;
}
.ultimate-popup-inner {
font-size: 16px;
}
.ultimate-popup-shortcodes p {
margin-bottom: 15px;
}
.ultimate-popup-shortcodes input[type="text"],
.ultimate-popup-shortcodes input[type="email"] {
border: 1px solid #ddd;
margin-bottom: 10px;
padding: 10px !important;
width: 100% !important;
}
.ultimate-popup-shortcodes {
margin: 30px auto 0;
max-width: 500px;
text-align: left;
}
.ultimate-popup-shortcodes br { display: none }
.ultimate-popup-shortcodes input[type="submit"] {
border: medium none;
border-radius: 7px;
color: #fff;
font-size: 17px;
padding: 15px;
width: 100%;
text-transform: uppercase;
-webkit-transition: .4s;
transition: .4s;
}
.ultimate-popup-shortcodes .gform_wrapper .gform_heading { display: none }
.ultimate-popup-shortcodes .gform_wrapper .gform_footer {
margin: 15px 0 0;
padding: 0;
}
.ultimate-popup-wrapper-hide .lean-overlay,
.ultimate-popup-wrapper-hide .ultimate-popup-wrapper {
display: none !important;
visibility: hidden !important;
}
.ultimate-popup-halfway-scroll-activate .cross-btn-ppm,
.ultimate-popup-halfway-scroll-activate.ultimate-popup-theme-id-2 .cross-btn-ppm,
.ultimate-popup-halfway-scroll-activate.ultimate-popup-theme-id-3 .cross-btn-ppm,
.ultimate-popup-halfway-scroll-activate.ultimate-popup-theme-id-4 .cross-btn-ppm,
.ultimate-popup-halfway-scroll-activate.ultimate-popup-theme-id-8 .cross-btn-ppm,
.ultimate-popup-halfway-scroll-activate.ultimate-popup-theme-id-9 .cross-btn-ppm {
right: 0;
top: 0;
z-index: 99;
border-radius: 0;
}
.ultimate-popup-halfway-scroll-activate.ultimate-popup-theme-id-2 .cross-btn-ppm { top: -8px }
.ultimate-popup-theme-id-5.ultimate-popup-halfway-scroll-activate .cross-btn-ppm {
background: #333;
height: 40px;
width: 40px;
line-height: 40px;
border-radius: 50%;
top: 20px;
z-index: 9;
}
.ultimate-popup-theme-id-5.ultimate-popup-halfway-scroll-activate .popup-inner-col-thumb { padding-top: 5px }
.ultimate-popup-halfway-scroll-activate.ultimate-popup-theme-id-12 .cross-btn-ppm,
.ultimate-popup-halfway-scroll-activate.ultimate-popup-theme-id-10 .cross-btn-ppm,
.ultimate-popup-halfway-scroll-activate.ultimate-popup-theme-id-6 .cross-btn-ppm {
right: 10px;
top: 5px;
}
.ultimate-popup-theme-id-1 .cross-btn-ppm { right: 10px }
/* Mobile Layout: 320px. */
#media only screen and (max-width: 767px) {
.ultimate-popup-wrapper { overflow: auto }
.ultimate-popup-wrapper .pop-inner-column .popup-inner-col-thumb {
float: none;
margin-bottom: 30px;
margin-top: 0;
padding: 0;
width: auto;
}
.ultimate-popup-wrapper .pop-inner-column .popup-inner-col-cont {
float: none;
padding: 25px;
width: auto;
}
.ultimate-popup-automatic-activate .cross-btn-ppm,
.ultimate-popup-automatic-activate.ultimate-popup-theme-id-2 .cross-btn-ppm,
.ultimate-popup-automatic-activate.ultimate-popup-theme-id-3 .cross-btn-ppm,
.ultimate-popup-automatic-activate.ultimate-popup-theme-id-4 .cross-btn-ppm,
.ultimate-popup-automatic-activate.ultimate-popup-theme-id-8 .cross-btn-ppm,
.ultimate-popup-automatic-activate.ultimate-popup-theme-id-9 .cross-btn-ppm {
right: 0;
top: 0;
z-index: 99;
border-radius: 0;
}
}
<div class="remodal" data-remodal-id="modal"
data-remodal-options="hashTracking: false, closeOnOutsideClick: false">
<form method="post">
<div class="form-group">
<label for="email">Login</label>
<input type="text" class="form-control" required name="email" id="email">
</div>
<div class="form-group">
<label for="pwd">Password</label>
<input type="password" class="form-control" required id="pwd" name="pwd">
</div>
<button type="submit" class="btn btn-default">Enter</button>
</form>
</div>
<!--
<script type="text/javascript">
function showSpoiler(obj)
{
var inner = obj.parentNode.getElementsByTagName("div")[0];
if (inner.style.display == "none")
inner.style.display = "";
else
inner.style.display = "none";
}
</script>
<style>
.button1 {
background-color: #4CAF50; /* Green */
border: none;
color: white;
padding: 12px 26px;
text-align: center;
text-decoration: none;
display: inline-block;
font-size: 16px;
cursor: pointer;
outline: none;
background-color: blue;
color: lightblue;
}
.button1:hover {
background-color: lightblue;
color: blue;
}
</style>
<div class="spoiler">
<input type="button" class="button1" onclick="showSpoiler(this);" value="[Spoiler]" />
<div class="inner" style="display:none;">
Hello noobies
</div>
-->
<!DOCTYPE html>
<html>
<style>
tab1 { padding-left: 2em; }
body {font-family: arial;
background-color: #00111a;
color: white;
}
.button1 {
background-color: #4CAF50; /* Green */
border: none;
color: white;
padding: 12px 26px;
text-align: center;
text-decoration: none;
display: inline-block;
font-size: 16px;
cursor: pointer;
outline: none;
background-color: #1ab2ff;
color: white;
font-weight: bold;
transition: 0.3s;
}
.button1:hover {
background-color: #66ccff;
}
.button1:active {
background-color: #0088cc;
}
ul.tab {
list-style-type: none;
margin: 0;
padding: 0;
overflow: hidden;
background-color: #1ab2ff;
}
ul.tab li {float: left;}
ul.tab li a {
display: inline-block;
color: white;
font-weight: bold;
text-align: center;
padding: 14px 16px;
text-decoration: none;
transition: 0.3s;
font-size: 17px;
}
ul.tab li a:hover {
background-color: #66ccff;
}
ul.tab li a:focus, .active {
background-color: #0088cc;
}
.tabcontent {
display: none;
padding: 6px 12px;
border-top: none;
}
h3 {
opacity: 0.5;
}
p {
opacity: 0.5;
}
</style>
<body>
<tab1><h2>SuperBlaze27-Core</h2>
<ul class="tab">
<li>Overview</li>
<li>Files</li>
</ul>
<div id="Overview" class="tabcontent">
<h3>SuperBlaze27 Core</h3>
<p>
Still in development but really cool!<br>
If you want to download click the spoiler button or click files. In the spoiler is the latest version. I would reccomend downloading from the files section. ;)
<div class="spoiler">
<input type="button" class="button1" onclick="showSpoiler(this);" value="[Spoiler]" />
<div class="inner" style="display:none;">
<h3>www.superblaze27.com/site/minecraft/plugins/spigot/projects/superblaze27-core/downloads/latest</h3>
</div>
</p>
</div>
<div id="Files" class="tabcontent">
<h3>Paris</h3>
<p>Paris is the capital of France.</p>
</div>
<script>
function openTab(evt, tabName) {
var i, tabcontent, tablinks;
tabcontent = document.getElementsByClassName("tabcontent");
for (i = 0; i < tabcontent.length; i++) {
tabcontent[i].style.display = "none";
}
tablinks = document.getElementsByClassName("tablinks");
for (i = 0; i < tablinks.length; i++) {
tablinks[i].className = tablinks[i].className.replace(" active", "");
}
document.getElementById(tabName).style.display = "block";
evt.currentTarget.className += " active";
}
// Get the element with id="defaultOpen" and click on it
document.getElementById("defaultOpen").click();
function showSpoiler(obj)
{
var inner = obj.parentNode.getElementsByTagName("div")[0];
if (inner.style.display == "none")
inner.style.display = "";
else
inner.style.display = "none";
}
</script>
</script>
</body>
</html>
With that I want the blue bar to not go all the way to the right and just stop after files. This is just a test but I wanted to see how it can work. I got some of the code from W3Schools. I just couldn't figure out how to get rid of the rest of the bar that isn't being used. THX in advance! ;)
Add display inline-block to both the ul and li.
ul.tab {
list-style-type: none;
margin: 0;
padding: 0;
overflow: hidden;
background-color: #1ab2ff;
display: inline-block;
}
ul.tab li {
float: left;
display: inline-block;
just add the last line to your code:
ul.tab {
list-style-type: none;
margin: 0;
padding: 0;
overflow: hidden;
background-color: #1ab2ff;
display: inline-block;
}
Folowing this tutorial i try to implement on my app based on ZendFramework 2.
I create all what author say and when i test image is successfull uploaded and alias is saved in database. But problem is ajax not show reposition after uploading and not show image. I must refresh browser to see new image.
My code:
<script>
$(document).ready(function()
{
/* Uploading Profile BackGround Image */
$('body').on('change','#bgphotoimg', function()
{
$("#bgimageform").ajaxForm({target: '#timelineBackground',
beforeSubmit:function(){},
success:function(){
$("#timelineShade").hide();
$("#bgimageform").hide();
},
error:function(){
} }).submit();
});
/* Banner position drag */
$("body").on('mouseover','.headerimage',function ()
{
var y1 = $('#timelineBackground').height();
var y2 = $('.headerimage').height();
$(this).draggable({
scroll: false,
axis: "y",
drag: function(event, ui) {
if(ui.position.top >= 0)
{
ui.position.top = 0;
}
else if(ui.position.top <= y1 - y2)
{
ui.position.top = y1 - y2;
}
},
stop: function(event, ui)
{
}
});
});
/* Bannert Position Save*/
$("body").on('click','.bgSave',function ()
{
var id = $(this).attr("id");
var p = $("#timelineBGload").attr("style");
var Y =p.split("top:");
var Z=Y[1].split(";");
var dataString ='position='+Z[0];
$.ajax({
type: "POST",
url: "image_saveBG_ajax_bg.php",
data: dataString,
cache: false,
beforeSend: function(){ },
success: function(html)
{
if(html)
{
$(".bgImage").fadeOut('slow');
$(".bgSave").fadeOut('slow');
$("#timelineShade").fadeIn("slow");
$("#timelineBGload").removeClass("headerimage");
$("#timelineBGload").css({'margin-top':html});
return false;
}
}
});
return false;
});
});
</script>
#timelineBackground {
height: 315px;
position: relative;
margin-top: -20px;
overflow: hidden;
background-color:#ccc;
}
#timelineProfilePic {
width: 170px;
height: 170px;
background-color: #ffffff;
position: absolute;
margin-top: -145px;
margin-left: 20px;
z-index: 1000;
overflow: hidden;
border-radius: 3px;
-moz-border-radius: 3px;
-webkit-border-radius: 3px;
}
#timelineTitle {
color: #ffffff;
font-size: 24px;
margin-top: -45px;
position: absolute;
margin-left: 206px;
font-weight: bold;
text-rendering: optimizelegibility;
text-shadow: 0 0 3px rgba(0,0,0,.8);
z-index: 999;
text-transform: capitalize;
}
#timelineShade {
min-height: 95px;
position: absolute;
margin-top: -95px;
width: 100%;
}
#timelineNav {
background-color: #ffffff;
min-height: 43px;
margin-bottom: 10px;
position: relative;
}
.timelineUploadBG {
position: absolute;
margin-top: 50px;
margin-left: 813px;
height: 32px;
width: 32px;
}
.uploadFile {
background: url('../images/whitecam.png') no-repeat;
height: 32px;
width: 32px;
overflow: hidden;
cursor: pointer;
}
.uploadFile input {
filter: alpha(opacity=0);
opacity: 0;
margin-left: -110px;
}
.custom-file-input {
height: 25px;
cursor: pointer;
}
.bgImage,#timelineBGload
{
width:100%;
}
.headerimage {
cursor: s-resize;
position: absolute;
}
.wallbutton:hover {
text-decoration: none;
}
.blackButton {
background-color: #666666;
border-color: #333333;
}
.bgSave {
position: absolute;
margin-top: 267px;
margin-left: 760px;
z-index: 4000;
}
.wallbutton {
font-weight: bold;
padding: 7px 9px;
background-color: #5fcf80;
color: #fff !important;
font-size: 12px;
font-family: "Helvetica Neue",Helvetica,Arial,sans-serif;
cursor: pointer;
text-decoration: none;
border-width: 1px 1px 3px !important;
border-style: solid;
border-color: #3ac162;
white-space: nowrap;
display: -moz-inline-stack;
-moz-border-radius: 3px;
-ms-border-radius: 3px;
-o-border-radius: 3px;
border-radius: 3px;
}
.bgSave {
position: absolute;
margin-top: 267px;
margin-left: 760px;
z-index: 4000;
}
.wallbutton {
font-weight: bold;
padding: 7px 9px;
background-color: #5fcf80;
color: #fff !important;
font-size: 12px;
font-family: "Helvetica Neue",Helvetica,Arial,sans-serif;
cursor: pointer;
text-decoration: none;
border-width: 1px 1px 3px !important;
border-style: solid;
border-color: #3ac162;
white-space: nowrap;
display: -moz-inline-stack;
-moz-border-radius: 3px;
-ms-border-radius: 3px;
-o-border-radius: 3px;
border-radius: 3px;
}
<div class="image">
<div class="cover-img">
<div id="timelineBackground">
<?php if($cover = getCoverPicture($profile->account_id)): ?>
<?php $cover_image_path = upload_userdata_url() .'/'. $cover->account_id .'/'.'photos/'.$cover->photo_guid .'/'. $cover->photo_name;?>
<img style="margin-top: <?= $cover->photo_bg_position; ?>" class="bgImage" src="<?= $cover_image_path; ?>">
<?php endif; ?>
</div>
<div id="timelineShade" style="">
<form action="photo/uploadCoverPicture" enctype="multipart/form-data" method="post" id="bgimageform">
<div class="uploadFile timelineUploadBG">
<input type="file" original-title="Change Cover Picture" class=" custom-file-input" id="bgphotoimg" name="userfile">
</div>
</form>
</div>
</div>
</div>
i want to put 6 more links on my jQuery slider my site link : http://daplonline.in/
NOTE only for first image not for all images.
i want to make something like this: http://daplonline.in/images/ineed.jpg
But my code is not working. Can anyone give me a solution how to build this?
My CSS code
/*--Main Image Preview--*/
.main_image {
width: 598px; height: 460px;
float: left;
background: #333;
position: relative;
overflow: hidden;
color: #fff;
}
.main_image h2 {
font-size: 2em;
font-weight: normal;
margin: 0 0 5px; padding: 10px;
}
.main_image h2 { display: none; }
.main_image p {
font-size: 1.2em;
padding: 10px; margin: 0;
line-height: 1.6em;
}
.block small {
padding: 0 0 0 20px;
background: url(images/icon_cal.gif) no-repeat 0 center;
font-size: 1em;
display:none;
}
.main_image .block small {margin-left: 10px;}
.main_image .desc{
position: absolute;
bottom: 0; left: 0;
width: 100%;
display:none;
}
.main_image .block{
}
.main_image a.collapse {
background: url(images/btn_coll.gif) no-repeat left top;
height: 27px; width: 93px;
text-indent: -99999px;
position: absolute;
top: -27px; right: 20px;
}
.main_image a.show {background-position: left bottom;}
.image_thumb {
float: left;
width: 299px;
background: #f0f0f0;
border-right: 1px solid #fff;
border-top: 1px solid #ccc;
}
.image_thumb img {
border: 1px solid #ccc;
padding: 5px;
background: #fff;
float: left;
}
.image_thumb ul {
margin: 0; padding: 0;
list-style: none;
}
.image_thumb ul li{
margin: 0; padding: 20px 10px;
background: #f0f0f0 url(../images/nav_a.gif) repeat-x;
width: 279px;
float: left;
border-bottom: 1px solid #ccc;
border-top: 1px solid #fff;
border-right: 1px solid #ccc;
}
.image_thumb ul li.hover {
background: #ddd;
cursor: pointer;
}
.image_thumb ul li.active {
background: #fff;
cursor: default;
}
html .image_thumb ul li h2 {
font-size: 1.4em;
margin: 5px 0; padding: 0;
vertical-align:central;
}
.image_thumb ul li .block {
float: left;
margin-left: 10px;
padding: 0;
width: 180px;
}
.image_thumb ul li p{display: none;}
and my jquery is
<script type="text/javascript">
var intervalId;
var slidetime = 2500; // milliseconds between automatic transitions
$(document).ready(function() {
// Comment out this line to disable auto-play
intervalID = setInterval(cycleImage, slidetime);
$(".main_image .desc").show(); // Show Banner
$(".main_image .block").animate({ opacity: 0.85 }, 1 ); // Set Opacity
// Click and Hover events for thumbnail list
$(".image_thumb ul li:first").addClass('active');
$(".image_thumb ul li").click(function(){
// Set Variables
var imgAlt = $(this).find('img').attr("alt"); // Get Alt Tag of Image
var imgTitle = $(this).find('a').attr("href"); // Get Main Image URL
var imgDesc = $(this).find('.block').html(); // Get HTML of block
var imgDescHeight = $(".main_image").find('.block').height(); // Calculate height of block
if ($(this).is(".active")) { // If it's already active, then...
return false; // Don't click through
} else {
// Animate the Teaser
$(".main_image .block").animate({ opacity: 0, marginBottom: -imgDescHeight }, 250 , function() {
$(".main_image .block").html(imgDesc).animate({ opacity: 0.85, marginBottom: "0" }, 150 );
$(".main_image img").attr({ src: imgTitle , alt: imgAlt});
});
}
$(".image_thumb ul li").removeClass('active'); // Remove class of 'active' on all lists
$(this).addClass('active'); // add class of 'active' on this list only
return false;
}) .hover(function(){
$(this).addClass('hover');
}, function() {
$(this).removeClass('hover');
});
// Toggle Teaser
$("a.collapse").click(function(){
$(".main_image .block").slideToggle();
$("a.collapse").toggleClass("show");
});
// Function to autoplay cycling of images
// Source: http://stackoverflow.com/a/9259171/477958
function cycleImage(){
var onLastLi = $(".image_thumb ul li:last").hasClass("active");
var currentImage = $(".image_thumb ul li.active");
if(onLastLi){
var nextImage = $(".image_thumb ul li:first");
} else {
var nextImage = $(".image_thumb ul li.active").next();
}
$(currentImage).removeClass("active");
$(nextImage).addClass("active");
// Duplicate code for animation
var imgAlt = $(nextImage).find('img').attr("alt");
var imgTitle = $(nextImage).find('a').attr("href");
var imgDesc = $(nextImage).find('.block').html();
var imgDescHeight = $(".main_image").find('.block').height();
$(".main_image .block").animate({ opacity: 0, marginBottom: -imgDescHeight }, 250 , function() {
$(".main_image .block").html(imgDesc).animate({ opacity: 0.85, marginBottom: "0" }, 250 );
$(".main_image img").attr({ src: imgTitle , alt: imgAlt});
});
};
$('.main_image').on("mouseover",function(){
clearInterval(intervalID);
});
$('.main_image').on("mouseout",function(){
intervalID = setInterval(cycleImage, slidetime);
});
$('.image_thumb ul li').on("mouseover",function(){
clearInterval(intervalID);
});
$('.image_thumb ul li').on("mouseout",function(){
intervalID = setInterval(cycleImage, slidetime);
});
});// Close Function
</script>
One solution. Put all these 4 Links on the image itself & then use MAP like following :-
http://www.w3schools.com/tags/tryit.asp?filename=tryhtml_areamap
<img src="images/banner1.png" alt="magic rabbit in the hat" usemap="#planetmap">
<map name="planetmap">
<area shape="rect" coords="0,0,82,126" alt="Register" href="register.htm">
<area shape="circle" coords="90,58,3" alt="Mercury" href="mercur.htm">
<area shape="circle" coords="124,58,8" alt="Venus" href="venus.htm">
</map>
You will have to set the coordinates correctly.
New :-
$(document).ready(function() {
var match_img = $('img[src="images/banner1.png"]');
match_img.attr("usemap", "#planetmap");
// Rest of ur Code
});
I got this code which address my "Get the 1st image of the post then display it" issue.
<?php echo get_first_image() ?>
My problem is, how to i make it to automatically adjust its size (lets say 50x50) then display it.
What i want to to do is simply get the image from my published post, resize it (50x50 and 250x250) then display it. It will be use in a slider/enhance version of recent post.
thank you very much!
HERES THE CODE of the SLIDER/Recent post
$(".main_image .desc").show();
$(".main_image .block").animate({ opacity: 0.85 }, 1 );
$(".image_thumb ul li:first").addClass('active');
$(".image_thumb ul li").click(function(){
//Set Variables
var imgAlt = $(this).find('img').attr("alt");
var imgTitle = $(this).find('a').attr("href");
var imgDesc = $(this).find('.block').html();
var imgDescHeight = $(".main_image").find('.block').height();
if ($(this).is(".active")) {
return false;
} else {
//Animate the Description
$(".main_image .block").animate({ opacity: 0, marginBottom: -imgDescHeight }, 250 , function() {
$(".main_image .block").html(imgDesc).animate({ opacity: 0.85, marginBottom: "0" }, 250 );
$(".main_image img").attr({ src: imgTitle , alt: imgAlt});
});
}
//Show active list-item
$(".image_thumb ul li").removeClass('active');
$(this).addClass('active');
return false;
}) .hover(function(){
$(this).addClass('hover');
}, function() {
$(this).removeClass('hover');
});
$("a.collapse").click(function(){
$(".main_banner .block").slideToggle();
$("a.collapse").toggleClass("show");
});
<div class="main_image">
<img src="banner1.jpg" alt="" />
<div class="desc">
Close Me!
<div class="block">
<h2>Title</h2>
<small>Date</small>
<p>Copy</p>
</div>
</div>
</div>
<div class="image_thumb">
<ul>
<li>
<img src="image\banner1_thumb.jpg" alt="image1234" />
<div class="block">
<h2>Title</h2>
<small>Date</small>
<p>Copy</p>
</div>
</li>
</ul>
</div>
.main_image {
width: 598px;
height: 456px;
float: left;
background: #333;
position: relative;
overflow: hidden;
color: #fff;
}
.main_image h2 {
font-size: 2em;
font-weight: normal;
margin: 0 0 5px;
padding: 10px;
}
.main_image p {
font-size: 1.2em;
line-height: 1.6em;
padding: 10px;
margin: 0;
}
.block small {
font-size: 1em;
padding: 0 0 0 20px;
background: url(iconcalendarKO.gif) no-repeat 0 center;
}
.main_image .block small {margin-left: 10px;}
.main_image .desc{
position: absolute;
bottom: 0;
left: 0;
width: 100%;
display: none;
.main_image .block{
width: 100%;
background: #111;
border-top: 1px solid #000;
}
.main_image a.collapse {
background: url(btn_collapse.gif) no-repeat left top;
height: 27px;
width: 93px;
text-indent: -99999px;
position: absolute;
top: -27px;
right: 20px;
}
.main_image a.show {background-position: left bottom;}image_thumb section CSS
.image_thumb {
float: left;
width: 299px;
background: #f0f0f0;
border-right: 1px solid #fff;
border-top: 1px solid #ccc;
}
.image_thumb img {
border: 1px solid #ccc;
padding: 5px;
background: #fff;
float: left;
}
.image_thumb ul {
margin: 0;
padding: 0;
list-style: none;
}
.image_thumb ul li{
margin: 0;
padding: 12px 10px;
background: #f0f0f0 url(nav_a.gif) repeat-x;
width: 279px;
float: left;
border-bottom: 1px solid #ccc;
border-top: 1px solid #fff;
border-right: 1px solid #ccc;
}
.image_thumb ul li.hover {
.image_thumb {
float: left;
width: 299px;
background: #f0f0f0;
border-right: 1px solid #fff;
border-top: 1px solid #ccc;
}
.image_thumb img {
border: 1px solid #ccc;
padding: 5px;
background: #fff;
float: left;
}
.image_thumb ul {
margin: 0;
padding: 0;
list-style: none;
}
.image_thumb ul li{
margin: 0;
padding: 12px 10px;
background: #f0f0f0 url(nav123_a.gif) repeat-x;
width: 279px;
float: left;
border-bottom: 1px solid #ccc;
border-top: 1px solid #fff;
border-right: 1px solid #ccc;
}
.image_thumb ul li.hover {
background: #ddd;
cursor: pointer;
}
.image_thumb ul li.active {
background: #fff;
cursor: default;
}
html .image_thumb ul li h2 {
font-size: 1.5em;
margin: 5px 0;
padding: 0;
}
.image_thumb ul li .block {
float: left;
margin-left: 10px;
padding: 0;
width: 170px;
}
.image_thumb ul li p{display: none;}
isnt get_the_post_thumbnail enough?
Just call it twice, with different sizes