Click here to Skip to main content
15,886,678 members
Articles / Programming Languages / Javascript
Tip/Trick

PopScript.js: A New Way Creating Lightboxes and Tooltips

Rate me:
Please Sign up or sign in to vote.
5.00/5 (1 vote)
28 Apr 2014CPOL1 min read 8.8K   7  
A basic tutorial on using PopScript.js

History

As a front-end developer, there is that eternal question poking your head at all times: "what's the best way that I can present the data to the users?" With the advent of AJAX data delivery, it is more common to piece together data sent from the server and presenting it to the users without having them to visit a different page. Today, one of the most popular ways of presenting the delivered data is through lightboxes, and sometime tooltips, which the user can close at his/her will.

Introduction

HTML was always designed to be great for documents and not for dynamic elements. For abstracting the process of creating these lightboxes, modals, and tooltips, we now have libraries to the aid. PopScript.js (http://popscript.relfor.co) gives you the ability to bring all these libraries together and provide you a declarative (like of CSS) interface to creating these elements, whether its a lightbox, modal, or a tooltip.

Using the Code

After inserting the "popscript.js" and "popscript.css" files available from http://popscript.relfor.co:

JavaScript
pop("Hello World"); 

The first argument is the content of the pop up. In this case: "Hello World".

This argument could be an HTML node or an HTML string too. For example:

JavaScript
var el = document.createElement('b');
el.innerHTML = 'Hello World'; 
pop(el);  
// OR
pop("<b>Hello World</b>"); 

Pop Classes (The Second Argument)

JavaScript
pop("Hello World", "success");

The second argument here is the pop class. In this case "success".

JavaScript
success: {
    STYLE: {
        CLASS: {
            box: 'success'
        }
    },
    ANIMATION: {
        IN: {
            box: 'drop'
        },
        OUT: {
            box: 'undrop'
        }
    },
    POSITION: {
        y: 'top'
    },
    
    cross: false ,
    full_draggable: false ,
    click_me_out: true
}   

The above declaration for 'success' is stored with every other pop class in the "popscript.js".

For learning about more such properties to configure your pop ups, visit the official website at http://popscript.relfor.co.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Canada Canada
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions

 
-- There are no messages in this forum --