closing iframe on esc key or clicking anywhere else - php

i want to close the iframe box as soon as i hit esc or i click outside the iframe area at the moment i have to click back on hideshow icon to hide the iframe again is there a method that i can use to close the iframe with esc or clicking outside the iframe area
index.php
<div id="msg_pic">
<a class="msg_pic_link" id="hideshow"><span><img src="emptymsg.png" width="21px" height="21px"/></span></a>
</div>
<div id="message" >
<iframe id="iframe" style=" border-color:#080000; background-color: white ;" src="conversation.php" width="300" height="300"></iframe>
</div>
hide-show.js
$('#hideshow').on("click", function() {
var text = $(this).val();
$("#message").toggle();
});
mycss.css
#message
{
display:none;
position: absolute;
z-index: 1;
}
the question how can i press esc key or click outside the msg_pic_link div to close message

Try using $(window).on("click keydown") , .is()
$('#hideshow').on("click", function() {
var text = $(this).val();
$("#message").toggle();
$(window).focus()
});
$(window).on("click keydown", function(e) {
//e.preventDefault()
if (e.keyCode === 27 || !$(e.target).is(function() {
return $("#message, #hideshow")
})) {
$("#message").hide()
}
}).focus()
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<div id="msg_pic">
<a class="msg_pic_link" id="hideshow"><span><img src="emptymsg.png" width="21px" height="21px"/></span></a>
</div>
<div id="message">
<iframe id="iframe" style=" border-color:#080000; background-color: white ;" src="conversation.php" width="300" height="300"></iframe>
</div>
jsfiddle http://jsfiddle.net/pb47m0om/2/

Related

Hiding video source url

Currently I am using CKPlayer for my video in the website.
But in the source code, it showed all the video url.
Is there a method to hide them?
Thank you
<div class="title">Video Title</div>
<div class="playbox">
<div id="playbox" style="background-color: rgb(0, 0, 0); width:
962px; height: 400px;"><video controls=""
src="http://www.example.com/video/firstvideo.m3u8" id="ckplayer_a1"
width="100%" height="400" autoplay="autoplay"></video></div>
<script type="text/javascript">
var flashvars={
f:'http://www.example.com/video/ckplayer/firstvideo.swf',
a:'http://www.example.com/video/firstvideo.m3u8',
c:0,
s:4,
h:3,
p:1,
i:'',//
};
var video=['http://www.example.com/video/firstvideo.m3u8'];
if(navigator.userAgent.indexOf('Mobile')>0||navigator.userAgent.indexOf('Pad')>0){
var html5first = true;
}else{
var html5first = false;
}
CKobject.embed('http://www.example.com/statics/building/js/video/ckplayer/ckplayer.s
wf','playbox','ckplayer_a1','100%','400',html5first,flashvars,video)
</script>
</div>

JQuery 5 star rating system

I'm creating a 5 star rating system with html php and jquery i dont know how to stop the stars rating when user has clicked on rating.
In my code when user click on 4 stars the alert box shows 4 stars but when the user move his mouse from stars the stars shows 0 rating.
here is my code, i'm not posting the css here
HTML :
<div class="rating">
<div class="ratings_stars" data-rating="1"></div>
<div class="ratings_stars" data-rating="2"></div>
<div class="ratings_stars" data-rating="3"></div>
<div class="ratings_stars" data-rating="4"></div>
<div class="ratings_stars" data-rating="5"></div>
</div>
JQUERY :
$('.ratings_stars').hover(
// Handles the mouseover
function() {
$(this).prevAll().andSelf().addClass('ratings_over');
$(this).nextAll().removeClass('ratings_vote');
},
// Handles the mouseout
function() {
$(this).prevAll().andSelf().removeClass('ratings_over');
}
);
$('.ratings_stars').click(function() {
$('.ratings_stars').removeClass('selected'); // Removes the selected class from all of them
$(this).addClass('selected'); // Adds the selected class to just the one you clicked
var rating = $(this).data('rating');
alert(rating);
// Get the rating from the selected star
$('#rating').val(rating); // Set the value of the hidden rating form element
});
Guessing because you haven't said what you expect to happen. It could be that you want the selected rating, and the stars before it, to be highlighted.
So instead of this
$(this).addClass('selected');
you use this, similar to how you have previously.
$(this).prevAll().andSelf().addClass('selected');
But I would also remove the hover class so that it's obvious to the user on click
$(this).prevAll().andSelf().addClass('selected').removeClass('ratings_over');
Demo
<!--SAVE AS WHATEVAUWANNA.HTML AND TEST-->
<html>
<head>
<title>Rating System jQuery Plug by Aldanis Vigo</title>
<script src='https://ajax.googleapis.com/ajax/libs/jquery/2.2.2/jquery.min.js'></script>
<style type='text/css' language='css'>
.record{
opacity: .50;
}
#value-display{
position: relative;
top: -5px;
margin-left: 10px;
color: orange;
font-weight: bold;
}
</style>
</head>
<body>
<span value='0' id='ratingbar'>
<img class='record' number='1'/>
<img class='record' number='2'/>
<img class='record' number='3'/>
<img class='record' number='4'/>
<img class='record' number='5'/>
<span id='value-display'>0 / 5</span>
</span>
</body>
<script>
//Change these variables to your liking!!
var iconsrc = 'https://upload.wikimedia.org/wikipedia/commons/a/ae/Record2.png';
var iconwidth = '20px';
var iconheight = '20px';
var value = $('#ratingbar').attr('value');
$('#ratingbar img').each(function(){
//Set the icon for each
$(this).attr('src', iconsrc);
$(this).attr('width', iconwidth);
$(this).attr('height', iconheight);
$(this).hover( function(){
$(this).css('opacity','1');
$(this).prevAll().css('opacity','1');
});
$(this).click( function(){
//Clear all of them
$(this).parent().attr('value',$(this).attr('number'));
$(this).parent().children('#value-display').html($(this).attr('number') + ' / 5');
//Color up to the selected ones.
$('#ratingbar img').each( function(){
if($(this).attr('number') <= $(this).parent().attr('value')){
$(this).css('opacity','1');
}else{
$(this).css('opacity','.50');
}
});
});
$(this).mouseout( function(){
$(this).css('opacity','.50');
$(this).prevAll().css('opacity','.50');
//Color up to the selected ones.
$('#ratingbar img').each( function(){
if($(this).attr('number') <= $(this).parent().attr('value')){
$(this).css('opacity','1');
}
});
});
});
</script>
</html>

How can I position the image and then click it and do the remove function jquery?

Click http://jsfiddle.net/4y1b1j8g/25/ to see the result. I want to move the cross sign to the right side which will not appear over the text. I want it to be like Stackoverflow tag. And then click the image and remove it. I've try to use $(removePic).click.(function() { $(removePic).remove()}):, but it is not working.
var removePic = $('.test').css({'background-image' : 'url(https://cdn3.iconfinder.com/data/icons/softwaredemo/PNG/16x16/DeleteRed.png)',
'background-repeat' : 'no-repeat',
'background-position' : 'right'})
.test {
display: inline-block;
margin: 0 3px 0 0;
border:solid;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.0/jquery.min.js"></script>
<div class="test" id="test0">dog</div>
<div class="test" id="test1">lion</div>
<div class="test" id="test2">cat</div>
$(document).ready(function(){
$(".test").append('<img src="https://cdn3.iconfinder.com/data/icons/softwaredemo/PNG/16x16/DeleteRed.png">');
$(document).on("click", ".test img", function() {
$(this).parent().remove();
});
});
Working Fiddle

prevent tabs to be seen while window reloading

I have a page which has 4 jquery UI tabs. The first tab just displays a message saying "HELLO". The 2nd, 3rd and 4th tabs have some html and php scripts running. All the pages are getting displayed properly. But say for example I am executing the php script on the 3rd tab by submitting a button. It does get executed but when the page reloads, I see the first tab flicker for a second and then the 3rd tab gets displayed. Same is the case for all the tabs. The first tab always gets displayed for a seconds and then it goes. Could you please let me know to add some code so that the 1st tab (or the div in which it is written ) is bypassed when other tab executes some php script.
My Javascript is as follows :
<script type="text/javascript" src="http://www.google.com/jsapi"></script>
<script src="http://code.jquery.com/jquery-1.9.1.js"></script>
<script src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"></script>
<script>
$(document).ready(function()
{
$("#menu ul li a").click(function(e) {
e.preventDefault();
$("#menu ul li a").each(function() {
$(this).removeClass("active");
});
$(this).addClass("active");
});
$("#menu").tabs({
fx: { height: 'toggle', opacity: 'toggle' }
});
});
My HTML code is as follows :
<div id="menu">
<ul>
<li><a href="#tab-1" onClick="window.location.href='#tab-1';return false;" >Welcome</a></li>
<li>Activation Response Generator </li>
<li>Decode Support Key</li>
<li>Decode Recovery Key</li>
</ul>
<div id="tab-1" >
<div id ="main">
<div align=center>
<table style="padding-top:20px;"> <tr>
<td style="padding-left:20px;"> <img src="Aruba_Networks_newLogo.png " /> </td>
<br/>
</div>
<?php session_start();$user = $_SESSION['usr'];?>
</br>
<tr>
<td> <font size ="6"> <b> <u> Welcome <?php echo $user; ?></u> </b> </font> </td>
</br>
</br>
<td> <font size ="6"> <b> <u> HAVE A GREAT DAY </u> </b> </font> </td>
</br>
</br>
<td> <font size ="6"> <b> Logout </b> </font></td>
</tr>
</div>
</div>
<div id="tab-2">
<div id= "main">
SOME HTML SUBMIT BUTTONS AND TEXTBOXES TO DISPLAY OUTPUT WITH PHP RUNNING IN THE BACKGROUND
</div>
</div>
<div id="tab-3">
<div id= "main">
SOME HTML SUBMIT BUTTONS AND TEXTBOXES TO DISPLAY OUTPUT WITH PHP RUNNING IN THE BACKGROUND
</div>
</div>
<div id="tab-4">
<div id= "main">
SOME HTML SUBMIT BUTTONS AND TEXTBOXES TO DISPLAY OUTPUT WITH PHP RUNNING IN THE BACKGROUND
</div>
</div>
</div>
Create a overlay div. Put this inside the body for the whole page, or inside a div with position: relative.
CodePen
.overlay {
position: fixed; /* or absolute if inside a div */
width: 100%; height: 100%;
background: white;
}
At some point, hide that div to show the underlying content. This would likely be in a document ready handler, or after an AJAX call.
$(document).ready(function(){ $('.overlay').fadeOut(); });
You can also spice it up, and put a loading message inside the overlay.
<div class="overlay">
<h1>Loading</h1>
</div>
.overlay h1 {
position: absolute;
top: 45%; /* nearly the center, good enough for a second of visibility */
text-align: center;
width: 100%;
}

link to follow on tooltip is shown but doesn't bring me there

Using the code at the bottom, the a href part does show the relevant link where my mouse is at, but when I click it it just redirects to .../index.php#.
I need some coding help - so it redirects me to the actual url - which is held in var totalService3 = data.getValue(e.row, 4); and as I said, is being shown in the tooltip div.
regards
Peter
google.visualization.events.addListener(tree, 'onmouseover', function (e) {
var provider = data.getValue(e.row, 0);
var totalService = data.getValue(e.row, 2);
var totalService2 = data.getValue(e.row, 3);
var totalService3 = data.getValue(e.row, 4);
// populate the tooltip with data
$('#tooltipTopLine').html(provider);
$('#tooltipMiddleLine').html(totalService);
$('#tooltipBottomLine').html(totalService2);
$('#tooltipHyperlink').html(totalService3);
// show the tooltip
$('#tooltip').show();
});
google.setOnLoadCallback(drawVisualization);
// make the tooltip div follow the mouse
$(function () {
$('#visualization').mousemove(function (e) {
$('#tooltip').css({
left: e.pageX,
top: e.pageY - 40
});
});
});
}
<div id="container" style="width:400px; height: 1200px;padding-top: 20px;">
<div id="visualization" style="width: 400px; height: 400px;"></div>
<div id="tooltip" style="padding-bottom:10px;"> <span id="tooltipTopLine"></span>
<br />Price 1 <span id="tooltipMiddleLine"></span>
<br />Price 2 <span id="tooltipBottomLine"></span>
<br />Link
</div>
Not tested:
google.visualization.events.addListener(tree, 'onmouseover', function (e) {
// your code
$('#tooltip a').attr('href', totalService3);
// show the tooltip
$('#tooltip').show();
});
or
google.visualization.events.addListener(tree, 'onmouseover', function (e) {
//your code
$('#tooltipHyperlink').attr('href', totalService3);
// show the tooltip
$('#tooltip').show();
});

Categories