How Display Tinybox 2 Popup box on page load?
Use this code on page on which you want to Display Tinybox 2 Popup box on page load
<script type="text/javascript">
window.onload = function()
{
TINY.box.show(html:'You content go here', 1, 400, 350, 1)
}
</script>
To close Popup box after specific time use this
<script type="text/javascript">
window.onload = function()
{
TINY.box.show('contentfile.html', autohide:20, 1, 400, 350, 1)
}
</script>
This will close popup after 20 seconds.
i did it this way.
window.onload = function()
{
TINY.box.show({
url: '/message.html',
width: 403, height: 200, opacity: 20
});
}
Related
I'm having a lot of trouble getting masonry to work alongside infinite scrolling. I've done everything I possibly can do and still nothing. Is there something wrong with my code, or did I just miss something completely?
This is my code:
<script src="//cdnjs.cloudflare.com/ajax/libs/jquery-infinitescroll/2.0b2.120519/jquery.infinitescroll.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/masonry/3.1.2/masonry.pkgd.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/jquery.imagesloaded/3.0.4/jquery.imagesloaded.min.js"></script>
<script src="http://static.tumblr.com/wgijwsy/u2vm2hxv6/jquery.infinitescroll.min.js"></script>
<script>
$(window).load( function() {
$('#content').masonry({
"itemSelector": ".entry",
"columnWidth": ".grid-sizer",
});
$container.infinitescroll({
itemSelector : ".entry",
navSelector : "#pagination",
nextSelector : "#pagination a",
loadingImg : "",
loadingText : "<em></em>",
bufferPx : 10000,
extraScrollPx: 12000,
},
// trigger Masonry as a callback
function( newElements ) {
var $newElems = $( newElements ).css({ opacity: 0 });
// ensure that images load before adding to masonry layout
$newElems.imagesLoaded(function(){
$newElems.animate({ opacity: 1 });
$container.masonry( 'appended', $newElems, true );
});
}
);
});
</script>
You are loading infinite-scroll twice (1st and 4th in the following code) and I do not see you are loading jQuery, which should be first. A jsfiddle would help to narrow down other issues.
<script src="//cdnjs.cloudflare.com/ajax/libs/jquery-infinitescroll/2.0b2.120519/jquery.infinitescroll.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/masonry/3.1.2/masonry.pkgd.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/jquery.imagesloaded/3.0.4/jquery.imagesloaded.min.js"></script>
<script src="http://static.tumblr.com/wgijwsy/u2vm2hxv6/jquery.infinitescroll.min.js"></script>
I am at the end of my wits. am developing my first chrome app.
manifest.json:
{
"name": "My App",
"description": "My App",
"version": "0.1",
"manifest_version": 2,
"app": {
"background": {
"scripts": ["background.js"]
}
},
"icons": { "16": "calculator-16.png", "128": "calculator-128.png" }
}
background.js:
chrome.app.runtime.onLaunched.addListener(function () {
// Center window on screen.
var screenWidth = screen.availWidth;
var screenHeight = screen.availHeight;
var width = 1024;
var height = 768;
chrome.app.window.create('index.html', {
id: "myappid",
bounds: {
width: width,
height: height,
left: Math.round((screenWidth - width) / 2),
top: Math.round((screenHeight - height) / 2)
}
});
});
index.html:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>My App</title>
<link rel="stylesheet" href="app.css" type="text/css" />
<script type="text/javascript" src="app.js"></script>
</head>
<body>
<h1>Hello World!</h1>
<div id="main" style="position:relative">
<div id="board" style="position:absolute"></div>
<div id="div1" style="position:absolute;left:800px"></div>
</div>
</body>
</html>
app.js:
window.onload = function () {
console.log("inside main");
// rest of the code hidden
};
result of launching the app from extensions menu:
i click on inspect background:
and get:
i click on inspect index.html and get:
i am able to open index.html directly in browser and verify it works fine as a stand alone html page - the js executes etc.
As far as I can see, the code you have shown is correct.
Your manifest specifies the background page
The background page correctly listens for the event, and creates the main app window
The app window (index.html) appears on screen, and loads app.js
app.js waits for the window to load, and logs "inside main" to the *foreground page's * console.
Your Chrome app has a background page, and a foreground page, and so it has two consoles. What you have shown is exactly what I would expect to see, given the code you've posted. The background page's console (which you inspected first) is empty, and the foreground page's console (which you inspected by right-clicking and selecting "inspect element") contains "inside main".
If you wanted to, you could see a message printed to the background page's console by using the callback to chrome.app.window.create; something like this:
console.log("Going to create the window");
chrome.app.window.create('index.html', {
id: "myappid",
bounds: {
width: width,
height: height,
left: Math.round((screenWidth - width) / 2),
top: Math.round((screenHeight - height) / 2)
}
}, function() {
console.log("Successfully created the window");
});
That callback should execute before window.onload is fired in the foreground window.
Now, there aren't any errors shown in the foreground console, but without knowing what JavaScript, if any, is in this bit:
// rest of the code hidden
I can't tell what, if anything, should be executing.
I've tried creating pages using the 'standard layout' and 'custom layout' but neither allows the use of the {block:Posts} variable(s). I need to re-create essentially the archive page but with some custom css. Is there any way to accomplish this?
If I try $("#someDiv").load("/archive", "#content"); the whole page formatting gets screwed up. Is there a way to load just the <a> tags into a div on my custom page?
Or would it be possible to use the API entirely client side to accomplish this?
Any ideas on this would be appreciated.
I came up with two possible solutions if anyone else finds themselves stuck on this. I abandoned this first one before finalizing it, so it's a bit rough but a good start. It uses the API to load photos (that was all I needed) as you scroll down the page.
<script>
function getPhotos(offset){
$.ajax({
url: "http://api.tumblr.com/v2/blog/[tumblr].tumblr.com/posts?api_key=[key]&offset="+offset,
dataType: 'jsonp',
success: function(results){
loaded += 20;
total = results.response.blog.posts;
if(total > loaded){
results.response.posts.forEach(function(post){
post.photos.forEach(function(photo){
$("#photos ul").append("<li class='"+post.tags.join(" ")+"'><img src='"+photo.alt_sizes[0].url+"'></li>");
$("#photos").imagesLoaded(function(){
$("#photos").masonry({
itemSelector: 'li'
});
});
});
});
if($("#photos ul").height() < $(window).height()){
getPhotos(loaded);
}
}
}
});
}
loaded = 0;
getPhotos(loaded);
$(window).scroll(function() {
if($(window).scrollTop() + $(window).height() > $(document).height() - 100) {
getPhotos(loaded);
}
});
</script>
What I've ended up doing is just using an iframe with a custom stylesheet appended to the head.
html:
<head>
<script src="http://[remote location]/frame.js"></script>
</head>
<body>
<div id="photos">
<iframe name="frame1" id="frame1" src="http://[tumblr]/archive" frameBorder="0"></iframe>
</div>
</body>
frame.js:
$(function(){
function insertCSS(){
var frm = frames['frame1'].document;
var otherhead = frm.getElementsByTagName("head")[0];
if(otherhead.length != 0){
var link = frm.createElement("link");
link.setAttribute("rel", "stylesheet");
link.setAttribute("type", "text/css");
link.setAttribute("href", "http://[remote location]/frame.css");
otherhead.appendChild(link);
setTimeout(function(){$("#frame1").show();}, 200);
clearInterval(cssInsertion);
}
}
cssInsertion = setInterval(insertCSS, 500);
//setTimeout(insertCSS, 1000);
$(window).scroll(function() {
if($(window).scrollTop() + $(window).height() > $(document).height() - 100 && $("#frame1").height() < 50000) {
$("#frame1").css("height", "+=1000px");
}
});
});
frame.css (stylesheet appended into iframe)
body{
overflow: hidden;
}
#nav_archive{
display: none;
}
.heading{
display: block !important;
}
.old_archive #content{
margin: 0 auto 0;
}
style.css (stylesheet on page where iframe is located)
#frame1{
border: none;
width: 100%;
height: 3000px;
overflow: hidden;
display: none;
}
Currently i am using the google cloudprint button for my site
<script src="//www.google.com/cloudprint/client/cpgadget.js"></script>
<script defer="defer">
var gadget = new cloudprint.Gadget();
gadget.setPrintButton(document.getElementById("custom_print_button"));
gadget.setPrintDocument("url", "Cloud Print test page",
"http://www.google.com/cloudprint/learn/");
</script>
I want to send an email when I hit the print button, is this possible?
No problem at all... just attach an onclick handler to the print button, or bind the click with jQuery and call a function to do your email. I used it to create a document with Ajax before it was printed:
<script>
function printIT() {
jQuery.ajax({
url: "print_this.php",
context: document.body,
success: function(responseText) {
alert("Document sent!");
return false;
}
});
}
</script>
<button id="print_button_container" class="ui-link" onclick="printIT();"></button>
<script src="//www.google.com/cloudprint/client/cpgadget.js">
</script>
<script defer="defer">
var gadget = new cloudprint.Gadget();
gadget.setPrintButton(document.getElementById("print_button_container"));
gadget.setPrintDocument("url", "My Document", "http://www.yourpath.com/yourdoc.html");
</script>
Simplified version... not tested but should work :)
i have fb app and a tab, as the contents grows, scrolls appears with the iframe but i want to no scrolls for the iframes but i want scrolls for the whole page instead of the i frames
You also need to start the timer to call autoresize code. In your applications HTML do:
<div id="fb-root"></div>
<script type="text/javascript">
//<![CDATA[
window.fbAsyncInit = function() {
FB.init({appId: "xxxxxxxxxxxxxxx",
status: true, cookie: true, xfbml: true});
FB.Canvas.setAutoResize();
};
(function() {
var e = document.createElement("script");
e.async = true;
e.src = document.location.protocol + "//connect.facebook.net/en_US/all.js";
document.getElementById("fb-root").appendChild(e);
}());
//]]>
</script>
Above code will check the content dimensions every 100ms. If you want to use different timing you can pass milliseconds as variable:
window.fbAsyncInit = function() {
FB.Canvas.setAutoResize(50);
};
If your content size does not change after page load you can save CPU cycles by changing the content size just once manually:
window.fbAsyncInit = function() {
FB.Canvas.setSize();
}
You can even pass the desired size as parameter
window.fbAsyncInit = function() {
FB.Canvas.setSize({ width: 520, height: 600 });
}
The easiest way to hide the scroll bars is to use
FB.Canvas.setAutoResize()
Please refer to the following article/tutorial for further information.
http://gpiot.com/facebook-page-tab-hide-scroll-bars-from-iframe/