Popup <a> tag on click i need to pass href - popup

I am using Fancy popup in a tag on click it show it working fine. Below my code
<script type="text/javascript" src="http://code.jquery.com/jquery-latest.min.js"></script>
<link rel="stylesheet" href="http://fancyapps.com//fancybox/source/jquery.fancybox.css?v=2.1.5" type="text/css" media="screen" />
<script type="text/javascript" src="http://fancyapps.com//fancybox/source/jquery.fancybox.pack.js?v=2.1.5"></script>
Click Me
<div style="display:none">
<div id="myDivID">
<input type="text" id="fname" name="fname" placeholder="First Name" required="true" class="form-text" />
</div>
</div>
<script type="text/javascript">
jQuery(document).ready(function($) {
$("a#fancyBoxLink").fancybox({
// 'href' : '#myDivID',
'titleShow' : true,
'transitionIn' : 'elastic',
'transitionOut' : 'elastic',
'openEffect' : 'elastic',
'closeEffect' : 'elastic',
'maxWidth' : 800,
'maxHeight' : 600,
'fitToView' : false,
'width' : '70%',
'height' : '70%',
'autoSize' : false,
'closeClick' : false
}); });
</script>
Now My problem is i want to i want to call that a tag link in this html so i added below script
<script>
$(document).on('click', 'a', function(e) {
e.preventDefault();
e = $(this).attr('href');//this gets the href
//e = $(this).text();//This gets the text
$('#fname').val(e);
});
</script>
I want to pass href to that input box so I change this to Click Me
this Click Me after this it stop working how i make it as working

Related

Alfresco - Categories Picker

I want to use the JavaScript Alfresco.ObjectPicker component in order to have category picker into the file: dnd-upload.get.html.ftl
<div class="form-field inlineable">
<label >Catégories:</label>
<div class="object-finder inlineable" id="a_default_prop_cm_categories-cntrl">
<div class="current-values inlineable object-finder-items" id="b_default_prop_cm_categories-cntrl-currentValueDisplay"></div>
<input type="hidden" value="" name="prop_cm_categories" id="c_default_prop_cm_categories"/>
<div class="show-picker inlineable" id="d_default_prop_cm_categories-cntrl-itemGroupActions"><span class="yui-button yui-push-button" id="yui-gen7"><span class="first-child"><button type="button" tabindex="0" id="yui-gen7-button" >Sélectionner</button></span></span></div>
<script type="text/javascript"> //<![CDATA[
(function(){
var picker = new Alfresco.ObjectFinder("a_default_prop_cm_categories-cntrl", "c_default_prop_cm_categories").setOptions(
{
field: "prop_cm_categories",
compactMode: true,
mandatory: false,
currentValue: "",
selectActionLabel: "Sélectionner",
minSearchTermLength: 1,
maxSearchResults: 1000
}).setMessages(
{""}
);
picker.setOptions(
{
itemType: "cm:category",
multipleSelectMode: true,
parentNodeRef: "alfresco://category/root",
itemFamily: "category",
maintainAddedRemovedItems: false,
params: "",
createNewItemUri: "",
createNewItemIcon: ""
});
})();
//]]>
</script>
</div>
</div>
And I have declared a JS dependency in the same file: dnd-upload.get.html.ftl
<#script type="text/javascript" src="${url.context}/res/components/object-finder/object-finder.js" group="objectfinder"/>
When I click on the button : "Sélectionner" , nothing happens and I have no console error neither.
Do you , Please, have any idea about how to make this Picker Working ?
Regards,
Sofia.

tinyMCE.execCommand('mceInsertContent' automatically getting undone

When I am adding some text with tinyMCE.execCommand it appears for couple of seconds and then automatically undoes.
Trying to understand how the undo level works.
How to add undo/manage level?
Striped down version of code used:
<html>
<head>
<title>TinyMCE editor</title>
<script type="text/javascript" src="tiny_mce/tiny_mce.js"></script>
<script type="text/javascript" src="jquery/jquery-1.10.2.js"></script>
<script type="text/javascript" src="jquery/jquery-ui.js"></script>
<script type="text/javascript">
var toolbar =
"fontselect,fontsizeselect, formatselect, bold,italic,underline,|," +
"forecolor,backcolor,|,removeformat,cleanup,|,codemirror2,charmap,|,fullscreen";
var toolbar2 =
"undo,redo,|,pastetext,pasteword,|,bullist,numlist,|,outdent,indent,|," +
"justifyleft,justifycenter,justifyright,justifyfull,|,link,unlink,anchor,image";
var initHtmlMode = {
mode: "textareas",
theme: "advanced",
theme_advanced_buttons1: toolbar,
theme_advanced_buttons2: toolbar2,
theme_advanced_toolbar_location: "top",
theme_advanced_toolbar_align: "left",
theme_advanced_statusbar_location: "bottom",
theme_advanced_resizing: true
};
tinyMCE.init(initHtmlMode);
function showList() {
tinyMCE.execCommand('mceInsertContent', false, 'some text');
}
</script>
</head>
<body>
<form>
<textarea id="content" rows="15" style="width: 80%"></textarea>
<br/>
<button onclick="showList()">Insert</button>
</form>
</body>
</html>
onclick() was refreshing the page
<form onsubmit="return false">
Fixed it.

Need Infinitescroll to work with a simple Masonry tumblr

Not sure what I'm doing wrong. The Masonry works, but the Infinite Scroll doesn't.
I'm trying to make the simplest Masonry/InfiniteScroll theme to build upon. I've tried a lot of different methods but I still get stuck.
<title>{title}</title>
<meta name="description" content="{MetaDescription}" />
<link rel="shortcut icon" href="{Favicon}">
<!--[if IE]><script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script><![endif]-->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
<script src="http://static.tumblr.com/wgijwsy/Ebfm2v4gy/jquery.masonry.min.js"></script>
<script type="https://github.com/paulirish/infinite-scroll/blob/master/jquery.infinitescroll.min.js"></script>
<script type="text/javascript">
$(window).load(function () {
var $content = $('#container');
$content.masonry({itemSelector: '.item', columnWidth:300
});
$content.infinitescroll({
navSelector : 'div#pagination',
nextSelector : 'div#pagination a#nextPage',
itemSelector : '.item'
});
});
</script>
<style>
.item{width:300px;}
img{max-width:100%;}
</style>
</head>
<body>
<div id="container">
{block:Posts}
{block:Photo}
<div class="item"><img src="{PhotoUrl-500}" title="{PhotoAlt}"/></div>
{/block:Photo}
{/block:Posts}
</div><!--wall-->
{block:Pagination}
<div id="pagination">
{block:NextPage}
<a id="nextPage" href="{NextPage}"></a>
{/block:NextPage}
{block:PreviousPage}
{/block:PreviousPage}
</div>
{/block:Pagination}
{/block:IndexPage}
</div>
</body>
</html>
Perhaps you could use this code if you want, this is the best one i have found so far:
<script type="text/javascript" src="http://static.tumblr.com/dbek3sy/iBElrgjim/jquerymasonry.js"></script>
<script type="text/javascript" src="http://static.tumblr.com/dbek3sy/Qyblrgjfn/jqueryinfintescroll.js"></script>
<script type="text/javascript">
$(window).load(function(){
var $wall = $('.posts');
$wall.imagesLoaded(function(){
$wall.masonry({
itemSelector: '.entry',
isAnimated : false
});
});
$wall.infinitescroll({
navSelector : "div#navigation",
nextSelector : "div#navigation a#nextPage",
itemSelector : ".entry",
bufferPx : 2000,
debug : false,
errorCallback: function() {
$('#infscr-loading').fadeOut('normal');
}},
function( newElements ) {
var $newElems = $( newElements );
$newElems.hide();
$newElems.imagesLoaded(function(){
$wall.masonry( 'appended', $newElems,{isAnimated: false}, function(){$newElems.fadeIn('slow');} );
});
}); $('.posts').show(500);
});
</script>
<script>
$.fn.changebackgroundColor = function(msg) {
$("#perma").css("#000");
};
</script>
I have no issue with the infinite scroll with it and it's rather simple. You should just check the Selector and var names to put those that are in your theme. else than that, I think the problem could be the scripts you are using. Try to use different ones maybe. I used to have some similar to yours and I realized that they didn't even respond when i debugged my page. It could be a similar issue.

fancybox and onfocus

I need to load fancybox with inside php file, when I will click on textarea.
My code:
<script type="text/javascript">
$("#mypop").click(function() {
$.fancybox({
'href' : 'file.php',
'transitionIn' : 'none',
'transitionOut' : 'none',
'titleShow' : false,
'overlayColor' : '#fff',
'overlayOpacity': 0.8 }); });</script>
<textarea rows="4" cols="50" onfocus="#mypop" ></textarea>
Why this is not working ?
You need to change your textarea tag: remove onfocus="#mypop" and add id="mypop". The $("#mypop") function-call will search for an element with id="mypop", and the click(function(){...}) function will add the event-listener. This function-call also makes the onfocus=-attribute unnecessary.
<script type="text/javascript">
$("#mypop").click(function() {
$.fancybox("<iframe src='file.php' frameborder='0'></iframe>",{
maxWidth : 700,
maxHeight : 600,
fitToView : false,
width : '50%',
height : '50%',
autoSize : true,
closeClick: false
});
});
</script>
<textarea rows="4" cols="50" id="mypop" ></textarea>
By: Jose ALfredo Cocom Chan

Open an image in an existing gallery with fancybox 2

I've a simple gallery:
<ul class="gallery">
<li><a class="fancybox-buttons" data-fancybox-group="gallery" href="/path/to/image1.jpg"><img src="/path/to/image1_thumb.jpg" /></a></li>
<li><a class="fancybox-buttons" data-fancybox-group="gallery" href="/path/to/image2.jpg"><img src="/path/to/image3_thumb.jpg" /></a></li>
<li><a class="fancybox-buttons" data-fancybox-group="gallery" href="/path/to/image3.jpg"><img src="/path/to/image3_thumb.jpg" /></a></li>
</ul>
In my HTML-Head I added:
<link rel="stylesheet" type="text/css" href="/path/to/jquery.fancybox.css" media="all" />
<link rel="stylesheet" type="text/css" href="/path/to/jquery.fancybox-buttons.css" media="all" />
<link rel="stylesheet" type="text/css" href="/path/to/jquery.fancybox-thumbs.css" media="all" />
<script type="text/javascript" src="/path/to/jquery.min.js"></script>
<script type="text/javascript" src="/path/to/jquery.fancybox.pack.js"></script>
<script type="text/javascript" src="/path/to/jquery.fancybox-buttons.js"></script>
<script type="text/javascript" src="/path/to/jquery.fancybox-thumbs.js"></script>
<script type="text/javascript">
$(document).ready(function() {
$('.fancybox-buttons').fancybox({
openEffect : 'none',
closeEffect : 'none',
prevEffect : 'none',
nextEffect : 'none',
closeBtn : false,
helpers : {
title : {
type : 'inside'
},
buttons : {},
thumbs : {
width : 120,
height : 80
}
},
});
});
The gallery works fine!
Now I want to open the first item (index 0) of the gallery with a link, inclusive buttons, and thumbs:
show gallery
The link opens the fancybox but the gallery isn´t shown. Why?
If you already bound fancybox to a specific selector, you just need to trigger it using the .eq() method to select the index you want like :
show gallery