In Drupal6, we can use l function to format a link, but how can we set it to a popup window?
Suppose the original code look like:
<?php echo l('product', 'product') ?>
Opening a popup using window.open is not considered a good practice. You may try the lightbox module (http://drupal.org/project/lightbox2) for a better way of showing a popup.
However, if you do want to open a popup using window.open, the following should work -
Create the link with an id
<?php echo l('product', 'product', array('attributes' => array('id' => 'product-link'))); ?>
Add JavaScript (you can add it to your theme's JS file) -
$(document).ready(<br />
function() {<br />
$("#product-link").click(<br />
function(e) {<br />
openWindow(); // function for opening window<br />
e.preventDefault(); // Stop link from opening new page<br />
}
);
}
);
Related
In the documentation of primefaces, it is said that "Note that notificationBar has a default built-in close icon to hide the content.". But so far I could not get it displayed ? Is there a special property or facet required to show the close icon ?
pf version I am using is 6.2
If you see the notification.js resource inside the Primefaces library, you can see that they took into account to give to the close icon the "hide functionality":
primefaces-6_2\src\main\resources\META-INF\resources\primefaces\notificationbar\notificationbar.js =>
/**
* PrimeFaces NotificationBar Widget
*/
PrimeFaces.widget.NotificationBar = PrimeFaces.widget.BaseWidget.extend({
init: function(cfg) {
this._super(cfg);
var _self = this;
//relocate
this.jq.css(this.cfg.position, '0').appendTo($('body'));
//display initially
if(this.cfg.autoDisplay) {
$(this.jq).css('display','block')
}
//bind events
this.jq.children('.ui-notificationbar-close').click(function() {
_self.hide();
});
},
So, considering the previous code, if a children component has the ui-notificationbar-close class and you click on it, the NotificationBar component will be hided calling to hide function automatically (without having to use the PF(widgetVar).hide().
I have tested with the following code and in effect, the notificationbar disappears after clicking on the close icon:
<p:notificationBar id="notificationBar" position="top" effect="slide" styleClass="top" widgetVar="myNotificationBarWV" autoDisplay="false">
<i class="ui-icon ui-icon-closethick ui-notificationbar-close"></i>
<h:outputText value="You Rock!" style="font-size:1.5 rem;"/>
</p:notificationBar>
I want to render a pilet under a tab. I have managed to render the pilet name as a tab but content can't be renderd. I am using Fluent UI Pivots.
https://developer.microsoft.com/en-us/fluentui#/controls/web/pivot
The idea is when you click a a Tab/Pivot name the micro front end should be loaded.
The easiest way I see is to use a conventional extension slot for doing that. A more obvious way (for pilet developers) would be to have a custom API like registerTab for registering tab components.
Following the easy way you could the following for your Pivot:
export const MyTabComponent = () => {
return (
<ExtensionSlot name="tabs" render={children => (
<Pivot>
{children.map((child, i) =>
<PivotItem headerText="First Tab" key={i}>
{child}
</PivotItem>
)}
</Pivot>
)} />
);
};
Using this in your app shell all you'd need to do in a pilet is register an extension for tabs.
export function setup(api) {
api.registerExtension("tabs", () => <div>Sample content!</div>);
}
I am using PrimeFaces 5.1 with PrettyFaces for rewrite URL in my project. I face one problem in PrettyFaces. E.g in same (same window PrettyFaces) view open the page fine. But using menuitem click open page new window time page not show shown so PrettyFaces not working.
I try below code:
prettyface.xml
<url-mapping id="studenFaceId">
<pattern value="/BSCMain" />
<view-id value="/pages/bsc/bscMain.xhtml"/>
</url-mapping>
javascript
function NewWindow(mypage,myname)
{
params = 'width='+screen.width;
params += ', height='+screen.height;
params += ', top=0, left=0';
params +=', scrollbars=yes';
newwin=window.open(mypage,myname, params);
if (window.focus)
{
newwin.focus()
}
return false;
}
xhtml
<p:menuitem id="dashBoard" ajax="false" value="student"
onclick="return NewWindow('./../bsc/bscMain.xhtml','BSCMain');"
update="main"/>
My doubt I use same window prettyface work fine but in same to open new window time prettyface not working it will shown only a empty page.
You should use the pretty URL instead of some relative view id in your JavaScript. Something like:
<p:menuitem id="dashBoard" ajax="false" value="student"
onclick="return NewWindow('#{request.contextPath}/BSCMain','BSCMain');"
update="main"/>
google.com/webstore i have add my extension
i Have check "This item uses inline install."
Websites: chose Verify site
google.com/webmasters i have add site and Verifyed.
when i put this code on me site:
<link rel="chrome-webstore-item"href="https://chrome.google.com/webstore/detail/itemID">
<button onclick="chrome.webstore.install()" id="install-button">Add to Chrome</button>
<script>
if (document.getElementById('extension-is-installed')) {
document.getElementById('install-button').style.display = 'none';
}
</script>
i click on button "Add to Chrome" install app extension, but when i refresh site button "Add to Chrome" is display. why? i cant Understanding
You're obviously following the guide at https://developer.chrome.com/webstore/inline_installation
In that case, you missed a step.. Let's look at the code.
if (document.getElementById('extension-is-installed')) {
document.getElementById('install-button').style.display = 'none';
}
The condition here is whether an element with ID extension-is-installed is present on the page. But what adds it?
A step back:
For example, you could have a content script that targets the installation page:
var isInstalledNode = document.createElement('div');
isInstalledNode.id = 'extension-is-installed';
document.body.appendChild(isInstalledNode);
So, you need to add a Content Script that adds that element to the page.
However, I doubt that guide will work. By default, content scripts execute after DOM is loaded (and therefore, that hiding script has executed). You can make them run at document_start, but then body does not exist yet.
Let me make an alternative hiding script, based on communicating with the extension using "externally_connectable". Suppose your website is example.com, and your extension's ID is itemID
Add example.com to sites you want to be messaged from:
"externally_connectable" : {
"matches" : [
"*://*.example.com/*"
]
},
In your background page, prepare for the message from the webpage:
chrome.runtime.onMessageExternal.addListener(
function(message, sender, sendResponse) {
if(message.areYouThere) sendResponse(true);
}
);
In your page at example.com, add a button (hidden by default) and code to show it when appropriate:
<button onclick="chrome.webstore.install()"
id="install-button" style="display:none;">
Add to Chrome
</button>
<script>
if (chrome) {
// The browser is Chrome, so we may need to show the button
if(chrome.runtime && chrome.runtime.sendMessage) {
// Some extension is ready to receive messages from us
// Test it:
chrome.runtime.sendMessage(
"itemID",
{areYouThere: true},
function(response) {
if(response) {
// Extension is already installed, keep hidden
} else {
// No positive answer - it wasn't our extension
document.getElementById('install-button').style.display = 'block';
}
}
);
} else {
// Extension is not installed, show button
document.getElementById('install-button').style.display = 'block';
}
}
</script>
Was requested to add page reload after install. chrome.webstore.install has a callback parameter specifically for this.
Instead of using onclick attribute, assign a function:
document.getElementById('install-button').addEventListener("click", function(e) {
chrome.webstore.install(function() {
// Installation successful
location.reload();
});
});
I have a problem , i have a script for mobile version of page that will scroll down the page to a specific div tag, it works fine but I would like the script to also open this section (open a tab)
This is what i got so far
The script
<asp:PlaceHolder ID="plhAnimatedScroll" visible="false" runat="server">
<script type="text/javascript">
var navHeight = $('#gecko-sub-navigation').outerHeight();
var buffer = (navHeight * 2) + 70;
$("html, body").animate({ scrollTop: $('#' + '<%=SelectedPage%>').offset().top - buffer }, 1000);
</script>
</asp:PlaceHolder>
One of the sections of the page
<section class="help_section">
Box title
<div class="help_details">
<div class="help_btm_msg"> some text </div>
</div>
</section>
The opening of the tab is triggered by click on anchor tag so the class changes from class="link help_switch closed" to class="link help_switch open" , is there any way to adjust the script so that it will change the class from closed to open or emulate the click ?
Thanks
Since you are using jquery, you can simulate a mouseclick, or trigger a click on a certain element using the trigger function.
jQuery documentation:
.trigger()
The idea is that you can first setup a click handler, and then call that click handler any time by triggering the "click" function in your code:
$( ".help_switch" ).on( "click", function() {
alert("help_switch has been clicked, or triggered.");
// now toggle the open/closed class
var isOpen = !$(this).hasClass("closed");
if(isOpen){
$(this).removeClass("open");
$(this).addClass("closed");
} else {
$(this).removeClass("closed");
$(this).addClass("open");
}
});
// trigger the "click" event on .help_switch when the page loads
// to show an example of how to call it:
$( ".help_switch" ).trigger( "click" );
Hope this helps.
You can see a working example of this code on jsfiddle: http://jsfiddle.net/8cvkm7y3/3/, if you load this code in jsfiddle, then you can watch how the closed and open class toggles on your help_switch class as you click the "Box Title" link by "Inspect Element" in Chrome Developer Tools or your web inspector of choice.