working on it ...


Explore Public Snippets

Sort by

Found 767 snippets matching: popup

    public by cghersi  204467  0  6  2

    Embed a browser into SWT Dialog and manage the firing of popups from links in the displayed page

    This is how to manage an embedded browser. Note: unfortunately this seems not working on some versions of Mac OS X.
    try {
    	Browser browser = new Browser(this, SWT.NONE);
    	browser.addOpenWindowListener(new OpenWindowListener() {
    		public void open(WindowEvent event) {
    			log.debug("Opening browser:" + event);
    			new Thread( new Runnable() {
    	            public void run() {
    	            	log.debug("some stuff t do here...");
    			final Shell shell = new Shell(event.display);
    		    shell.setText("My Browser page");
    		    shell.setLayout(new FillLayout());
    		    event.browser = new Browser(shell, SWT.NONE);
    		    event.browser.addCloseWindowListener(new CloseWindowListener() {
    				public void close(WindowEvent event) {
    } catch (Throwable t) {
    	//on some architecture seems that SWT Browser is not working...
    	log.warn("Cannot display SWT Browser");

    public by paulsimmons  965  0  4  0

    FMEAddons - Magento Popup Window Extension

    Magento popup window extension helps you to create the popups and promote your products with the help of these popups. These popups appear on the website when users land on any page of your website. You can add banner, links, text, and images in the popup to display it your users. You can make fancy products banners and images to attract the cu
    // Enter here the actual content of the snippet.            

    public by Magesolution  692  0  5  0

    Popup for Magento 2 By Magesolution

    Popup extension for Magento 2 is a great solution for those who want their visitors to be aware of all the latest and hot stuff on your store.This is a universal extension to create popups with any HTML content, image or form when pages load for grab customer attention. Promote your products, news, ads and events or collect information from users b				

    public by cghersi  8173  2  7  2

    Java SWT: Combobox with AutoSuggestion feature

    This component can be safely used when you want to have a combobox with the capability to display automatic filtered suggestions based on the text already entered. It uses a couple of callback actions so that the caller can specify what to do when ENTER key is hit and how to load suggestions. The call back actions are specified by a simple interf
    package com.snip2code.ui.swt;
    import java.util.List;
    import java.util.Random;
    import org.apache.log4j.Logger;
    import org.eclipse.swt.SWT;
    import org.eclipse.swt.custom.StackLayout;
    import org.eclipse.swt.layout.FillLayout;
    import org.eclipse.swt.layout.GridData;
    import org.eclipse.swt.layout.GridLayout;
    import org.eclipse.swt.widgets.Composite;
    import org.eclipse.swt.widgets.Control;
    import org.eclipse.swt.widgets.Event;
    import org.eclipse.swt.widgets.Label;
    import org.eclipse.swt.widgets.Listener;
    import org.eclipse.swt.widgets.Shell;
    import org.eclipse.swt.widgets.Table;
    import org.eclipse.swt.widgets.TableItem;
    import org.eclipse.swt.widgets.Text;
    import com.snip2code.utils.Utils;
     * (c) 2011 snip2code inc.
     * This software is property of snip2code inc. Use or reproduction without permission is prohibited 
     * This widget creates a textfield with an autosuggestion feature.
     * The list of suggestion is shown when the user clicks on the text field or starts typing in the text field
    public class AutoSuggestionComposite extends Composite {
    	protected static Logger log = Logger.getLogger(AutoSuggestionComposite.class);
    	private Composite textBoxStackPanel;
    	private StackLayout textboxLayout;
    	private Text textBox;
    	private Label tooltip;
    	private Shell popupShell;
    	private Table table;
    	private String tooltipMsg;
    	private ICallback<String, List<String>> loadSuggestionAction;
    	private ICallback<String, String> onEnterAction;
    	private String text;
    	private int numOfDisplayedSuggestions;
    	private static final String POPUPVISIB = "$$$POPUP_VISIB";
    	private String uniqueID; //used to differentiate AutoSuggestion composites in the same dialog
    	private static Random rdn = new Random();
    	 * Create the dialog.
    	 * @param parent
    	 * @param style
    	 * @param tooltipMsg message to display when no input is entered
    	 * @param numOfDisplayedSuggestions masimum number of items suggested in the popup of suggestions
    	 * @param loadSuggestionAction callback to routine that loads the suggestions for autocomplete
    	 * @param onEnterAction callback when enter is pressed on the textbox
    	public AutoSuggestionComposite(Composite parent, int style, String tooltipMsg, int numOfDisplayedSuggestions, 
    			ICallback<String, List<String>> loadSuggestionAction, ICallback<String, String> onEnterAction) {
    		super(parent, style);
    		textboxLayout = new StackLayout();
    		this.loadSuggestionAction = loadSuggestionAction;
    		this.onEnterAction = onEnterAction;
    		this.numOfDisplayedSuggestions = numOfDisplayedSuggestions;
    		this.tooltipMsg = tooltipMsg;
    		uniqueID = rdn.nextInt() + tooltipMsg;
    	private void createDialogArea() {
    		GridLayout gridLayout = new GridLayout();
    		gridLayout.marginHeight = 0;
    		gridLayout.marginWidth = 0;
    		//Panel with textbox and tooltip:
    		textBoxStackPanel = new Composite(this, SWT.NONE);
    		GridData gdPanel = new GridData(SWT.FILL, SWT.FILL, true, false, 1, 1);
    		gdPanel.verticalIndent = 2;
    		tooltip = new Label(textBoxStackPanel, SWT.NONE);
    		tooltip.setText(" " + tooltipMsg); //manual horizontal indent, cause StackLayout doesn't allow this feature
    		tooltip.addMouseListener(new MouseAdapter() {
    			public void mouseDown(MouseEvent e) {
    				setControlVisib(textBox, true);
    		textBox = new Text(textBoxStackPanel, SWT.NONE);
    		textBox.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false));
    		textBox.setData(POPUPVISIB, uniqueID);
    		//popup for suggestions:
    		popupShell = new Shell(getShell().getDisplay(), SWT.ON_TOP);
    		popupShell.setLayout(new FillLayout());
    		popupShell.setData(POPUPVISIB, uniqueID);
    		table = new Table(popupShell, SWT.SINGLE);
    		table.setData(POPUPVISIB, uniqueID);
    		for (int i = 0; i < numOfDisplayedSuggestions; i++) {
    			new TableItem(table, SWT.NONE);
    		//Key Listener for Keyboards events:
    		textBox.addKeyListener(new KeyAdapter() {
    			public void keyReleased(KeyEvent e) {
    				boolean loadSuggestions = true;
    				switch (e.keyCode) {
    					case SWT.ARROW_DOWN:
    						int index = (table.getSelectionIndex() + 1) % table.getItemCount();
    						e.doit = false;
    					case SWT.ARROW_UP:
    						index = table.getSelectionIndex() - 1;
    						if (index < 0) 
    							index = table.getItemCount() - 1;
    						e.doit = false;
    					case SWT.CR:
    					case SWT.LF:
    					case 16777296: //enter in numeric keypad
    						if (popupShell.isVisible() && table.getSelectionIndex() != -1) {
    						loadSuggestions = false;
    					case SWT.ESC:
    				//only for printable characters, load search history:
    				if (loadSuggestions && (e.keyCode < 256))
    				log.debug("End of key listener");
    		//make sure the input entered in the text box is saved and ready to use:
    		textBox.addFocusListener(new FocusAdapter() {
    			public void focusLost(FocusEvent e) {
    				log.debug("Focus lost by textbox of autosugg from " + tooltipMsg);
    			public void focusGained(FocusEvent e) {
    				if (isDisposed() || getShell().isDisposed() || getShell().getDisplay().isDisposed()) 
    				log.debug("Focus gained by textbox of autosugg from " + tooltipMsg);
    		textBox.addSelectionListener(new SelectionAdapter() {
    			public void widgetSelected(SelectionEvent e) {
    		table.addListener(SWT.DefaultSelection, new Listener() {
    			public void handleEvent(Event event) {
    		//hide the popup of suggestions if the focus is out:
    		Listener focusOutListener = new Listener() {
    			public void handleEvent(Event event) {
    		table.addListener(SWT.FocusOut, focusOutListener);
    		textBox.addListener(SWT.FocusOut, focusOutListener);
    		textBoxStackPanel.addListener(SWT.FocusOut, focusOutListener);
    		popupShell.addListener(SWT.FocusOut, focusOutListener);
    		this.addListener(SWT.FocusOut, focusOutListener);
    		getShell().addListener(SWT.Move, new Listener() {
    			public void handleEvent(Event event) {
    	private void handleFocusLost() {
    		/* async is needed to wait until focus reaches its new Control */
    		if (isDisposed() || getShell().isDisposed() || getShell().getDisplay().isDisposed()) 
    		getShell().getDisplay().asyncExec(new Runnable() {
    			public void run() {
    				log.debug("Running handleFocusLost for " + tooltipMsg);
    				if (isDisposed() || getShell().isDisposed() || getShell().getDisplay().isDisposed()) 
    				Control control = getShell().getDisplay().getFocusControl();
    				log.debug("handleFocusLost for " + tooltipMsg + ": control is " + control + ";uniqueID:" + uniqueID);
    				if ((control == null) || (control.getData(POPUPVISIB) == null) || 
    					!control.getData(POPUPVISIB).toString().equals(uniqueID)) {
    	 * Determines the visibility of textbox content vs tooltip when the textbox is empty
    	public void checkTooltipVisib() {
    		if (Utils.isNullOrEmpty(textBox.getText())) 
    			setControlVisib(tooltip, true);
    			setControlVisib(textBox, true);
    	private void execEnterAction() {
        private void loadSuggestions(String prefix) {
        	log.debug("loading suggestions for " + prefix);
    //		if (Utils.isNullOrEmpty(prefix))
    //			return;
        	Rectangle textBounds = getShell().getDisplay().map(textBoxStackPanel, null, textBox.getBounds());
    		//load suggestions:
        	List<String> suggestions = loadSuggestionAction.exec(prefix);
        	log.debug("loaded " + suggestions.size() + " suggestions");
    		TableItem[] items = table.getItems();
    		int maxWidthOfItem = 0;
    		log.debug("Changing " + items.length + " items in TablePopup");
    		for (int i = 0; i < items.length; i++) {
    			if (i < suggestions.size()) {
    				String sugg = suggestions.get(i);
    				if (!Utils.isNullOrEmpty(sugg)) {
    					int w = items[i].getBounds().width;
    					if (w > maxWidthOfItem)
    						maxWidthOfItem = w;
    //		//avoid the display of horizontal scrollbar when not needed (10 is the width of the scrollbar)
    //		if ((maxWidthOfItem + 10) < textBounds.width)
    //			table.pack();
    		//23 pixels is the height of 1 item in the drop down list; 
    		//always add a blank line at the end of the list to improve readability
    		int popupHeight = (suggestions.size() + 1) * 23; 
    		log.debug("popupHeight for [" + this.tooltipMsg + "]:" + popupHeight);
    		if (popupHeight <= 46)
    			popupHeight = 46; 
    		//set a cap to the maximum height of the popup (17 lines):
    		if (popupHeight > 391) {
    			popupHeight = 391;
    		} else {
    			//avoid the display of horizontal scrollbar when not needed (10 is the width of the scrollbar)
    			if ((maxWidthOfItem + 10) < textBounds.width)
    		log.debug("setBounds popup:" + textBounds.x + ";" + (textBounds.y + textBounds.height + 4) + ";" + 
    					textBounds.width + ";" + popupHeight);
    		popupShell.setBounds(textBounds.x, textBounds.y + textBounds.height + 4, textBounds.width, popupHeight);
    	private void setControlVisib(Control c, boolean visible) {
    		if (c == null)
    		if (visible) 
    			textboxLayout.topControl = c;
    	private void saveInput() {
    		text = textBox.getText();
    		if (text == null)
    			text = "";
    		text = text.trim();
    	 * Returns the content of the textbox
    	public String getText() {
    		return text;
    	 * Sets the content of the textbox
    	public void setText(String text) {
    		this.text = text;
    		setControlVisib(textBox, true);
    	 * Hides the popup of suggestions
    	public void hideSuggestions() {
    	public void dispose() {
    		if (popupShell != null) {

    public by sTiLL-iLL  3359  1  7  19

    Dialog tag example

    Dialog tag example: dilogSnippet.html
      <p>This is da dialog!</p>
      <button id="close">Close</button>
    <button id="show">Open Dialog!</button>
      var dialog = document.querySelector('dialog');
      document.querySelector('#show').onclick = function() {;
      document.querySelector('#close').onclick = function() {

    public by congruityservice  2312  1  5  0

    OpenInsight POPUP Function Example With Literal Data

    The Popup function (see is very flexible but with flexibility comes complexity. This is a code example showing a multi-column Popup with literal data.
    Declare Function Popup
    PopDisp = ''
    PopDisp<PCOL$> = -1
    PopDisp<PROW$> = -1
    PopDisp<PWIDTH$> = -1
    PopDisp<PHEIGHT$> = -1
    PopDisp<PFILE$> = ''
    PopDisp<PMODE$> = 'L'
    PopDisp<PTITLE$> = 'Please choose a line'
    PopDisp<PTYPE$> = 'E'
    //Show multi-column list
    PopDisp<PDISPLAY$> = "One":@SVM:"A is for Apple":@VM:"Two" :@SVM: "B is for Banna":@VM:"Three":@SVM:"C is for Code"
    PopDisp<9> = 1:@SVM:10:@SVM:'L':@SVM:'L':@SVM:'':@SVM:'Num Col':@VM:2:@SVM:25:@SVM:'L':@SVM:'L':@SVM:'':@SVM:'Phrase'
    //For simple single column list
    PopDisp<PDISPLAY$> = "One":@VM:"Two":@VM:"Three"
    PopDisp<PFORMAT$> = 1:@SVM:10:@SVM:'L':@SVM:'L':@SVM:'':@SVM:'Num Col'
    Resp = Popup(@WINDOW, PopDisp)

    public by Magesolution  1029  0  5  0

    Popup for Magento 2

    Popup for Magento 2 is a great solution for those who want their visitors to be aware of all the latest and hot stuff on your store. This is a universal extension to create popups with any HTML content, image or form when pages load for grab customer attention. Promote your products, news, ads and events or collect information from users by any ki

    public by micurs  3912  8  8  1

    Change the address in the browser without reloading

    In HTML5 it is possible to change part of the address in the address browser without reloading the page. This helps building single page site with elements of the UI addressable using a consistent URL. See an example here: . By clicking on any article box a popup within the same page shows the content, and the URL in the
    // This add a new state to the browser history and replace the path
    window.history.pushState( stateObj, 'content title', '/new-path');
    // This replace the current state to the browser history and replace the path
    window.history.replaceState(stateObj, 'content title', '/new-path');

    public by lbottaro  2250  0  5  0

    Linux SSH remote shell cmd

    This command allows to execute a cmd or script in a xterm shell remotely on another machine via ssh. Xterm will popup showing the cmd execution
    ssh -Y <HOSTNAME> xterm -bg DarkBlue -fg white -geometry 128x24 -sl 200000 -hold -T <TERM_TITLE> -exec '<CMD_or_SCRIPT>'

    public by marksimon232  4303  1  7  1

    Swift Collections: Create UIAlertViews in Swift (iOS 8)

    This is how you make an alert popup on your iPhone application.
    For beginners UIAlertViews were, on iOS 7, one of the main ways that iOS Developers had to 
    let the app users know something important about the application and its 
    current state. UIActionSheet was sort of the same thing, but with more 
    action-based focus, prompting the user to do something.
    On iOS 8 these two classes have been merged into one, called UIAlertController.
    We can display a message to the user doing the following:
    var alert = UIAlertController(title: "Alert", message: "Message", preferredStyle: UIAlertControllerStyle.Alert)
    self.presentViewController(alert, animated: true, completion: nil)
    That will display a message to the user, but with no buttons so the user can take any action. Also, note that the constructor for the UIAlertController object accepts a preferredStyle param, which can be anyone of the following:
    .Alert: shows the message to the user at the center of the screen.
    .ActionSheet: shows the message to the user at the bottom of the screen.
    => Actions
    So far we’ve showed the user a message, but we haven’t provided them a way
    to give feedback to us. Enter UIAlertAction. This class has a closure-based 
    syntax and allows us to add buttons to a UIAlertController object, and 
    define what should happen when the user taps that button.
    var alert = ....
    alert.addAction(UIAlertAction(title: "Ok", style: UIAlertActionStyle.Default, handler: {(action: UIAlertAction!) in
    // What happens when the user taps 'Ok'? That goes in here
    self.presentViewController(alert, animated: true, completion: nil)
    The UIAlertAction constructor accepts three params: a title (String), a 
    style (UIAlertActionStyle) and a handle (a closure). The style of the 
    UIAlertAction object can be anyone of the following:
    .Destructive: renders the title property on red
    We can add as many UIAlertActions to a UIAlertController as we want, just be careful not to give your users too many options. Keep things simple.
    • Public Snippets
    • Channels Snippets