Ads

Tuesday, 1 July 2014

New or latest best, top excellent useful SQL server (Database) Tutorials or Online Learning websites For Beginners 2014

We’ve covered several programming languages now, but we haven’t really gotten into database development yet. Although NoSQL is hot, SQL (structured query language) isn’t going away. Different databases (such as Oracle, MySQL and PostgreSQL) use different variations, but the idea is to have a unified system so that a developer can move from database to database with a minimum of relearning.


If you’re not quite sure yet what a relational database is or why someone would use one, check out our guide to database terminology. Otherwise, let’s dive into some books for beginners, and one for experienced database developers.


Practical PostgreSQL



Practical PostgreSQL from O’Reilly Media is designed to introduce the SQL beginner to PostgreSQL. The book is focused on Postgres running on Red Hat, but has many lessons applicable to other environments.


W3 Schools SQL Tutorial


Love ‘em or hate ‘em, W3 Schools has tutorials on nearly every Web development subject, and SQL is no exception.


Oracle Database 10g Express Edition Tutorial


This Oracle Database 10g Express Edition tutorial introduces Oracle’s SQL database using its free version.


Build Your Own Database Driven Web Site Using PHP & MySQL



If you’re planning on learning MySQL along with PHP, you can check out Sitepoint’s Build Your Own Database Driven Web Site Using PHP & MySQL by Kevin Yank. The first 168 pages are available as a free PDF if you’re willing to fork over your e-mail address. However, you can find much of the material on the Web in this series of tutorials by Yank.


You can find more resources for learning PHP here.


SQL Performance Explained



For the more advanced practitioner, there’s SQL Performance Explained. In the words of the publisher it “It avoids unnecessary details about database internals but highlights the one topic that is most often neglected: proper indexing.” It’s available as an e-pub, or as a continually updated website called Use The Index, Luke.


=======================================================


10 Easy Steps to a Complete Understanding of SQL


 


Too many programmers think SQL is a bit of a beast. It is one of the few declarative languages out there, and as such, behaves in an entirely different way from imperative, object-oriented, or even functional languages (although, some say that SQL is alsosomewhat functional).


I’m writing SQL every day and embracing SQL with myOpen Source Software jOOQ. I thus feel compelled to bring the beauty of SQL a bit closer to those of you still struggling with it. The following tutorial is destined for


  • readers who have already worked with SQL but never completely understood it

  • readers who know SQL well but have never really thought about its syntax

  • readers who want to teach SQL to others

This tutorial will focus on SELECT statements only. Other DML statements will be covered in another tutorial. Here are…


10 Easy Steps to a Complete Understanding of SQL.


1. SQL is declarative


Get this into your head first. Declarative. The only paradigm where you “just” declare the nature of the results that you would like to get. Not how your computer shall compute those results. Isn’t that wonderful?


SELECT first_name, last_name FROM employees WHERE salary >100000

Easy to understand. You don’t care where employee records physically come from. You just want those that have a decent salary.


What do we learn from this?


So if this is so simple, what’s the problem? The problem is that most of us intuitively think in terms of imperative programming. As in: “machine, do this, and then do that, but before, run a check and fail if this-and-that”. This includes storing temporary results in variables, writing loops, iterating, calling functions, etc. etc.


Forget about all that. Think about how to declare things. Not about how to tell the machine to compute things.


2. SQL syntax is not “well-ordered”


A common source of confusion is the simple fact that SQL syntax elements are not ordered in the way they are executed. The lexical ordering is:


  • SELECT [ DISTINCT ]

  • FROM

  • WHERE

  • GROUP BY

  • HAVING

  • UNION

  • ORDER BY

For simplicity, not all SQL clauses are listed. This lexical ordering differs fundamentally from the logical order, i.e. from the order of execution:


  • FROM

  • WHERE

  • GROUP BY

  • HAVING

  • SELECT

  • DISTINCT

  • UNION

  • ORDER BY

There are three things to note:


  1. FROM is the first clause, not SELECT. The first thing that happens is loading data from the disk into memory, in order to operate on such data.

  2. SELECT is executed after most other clauses. Most importantly, after FROM and GROUP BY. This is important to understand when you think you can reference stuff that you declare in the SELECT clause from the WHERE clause. The following is not possible:
    SELECT A.x + A.y AS z
    FROM A
    WHERE z
    =10-- z isnot available here!

    If you wanted to reuse z, you have two options. Either repeat the expression:


    SELECT A.x + A.y AS z
    FROM A
    WHERE
    (A.x + A.y)=10

    … or you resort to derived tables, common table expressions, or views to avoid code repetition. See examples further down.


  3. UNION is placed before ORDER BY in both lexical and logical ordering. Many people think that each UNION subselect can be ordered, but according to the SQL standard and most SQL dialects, that is not true. While some dialects allow for orderingsubqueries or derived tables, there is no guarantee that such ordering will be retained after a UNION operation

Note, not all databases implement things the same way. Rule number 2, for instance, does not apply exactly in the above way to MySQL, PostgreSQL, and SQLite.


What do we learn from this?


Always remember both the lexical order and the logical order of SQL clauses to avoid very common mistakes. If you understand that distinction, it will become very obvious why some things work and others don’t.


Of course, it would have been nice if the language was designed in a way that the lexical order actually reflected the logical order, as it is implemented in Microsoft’s LINQ.


3. SQL is about table references


Because of the difference between lexical ordering and logical ordering, most beginners are probably tricked into thinking that column values are the first-class citizens in SQL. They are not. The most important things are table references.


The SQL standard defines the FROM clause as such:


<fromclause> ::= FROM <tablereference> [ <comma><tablereference> ... ]

The “output” of the FROM clause is a combined table reference of the combined degree of all table references. Let’s digest this, slowly.


FROM a, b

The above produces a combined table reference of the degree of a + the degree of b. If a has 3 columns and b has 5 columns, then the “output table” will have 8 (3 + 5) columns.


The records contained in this combined table reference are those of the cross product / cartesian product of a x b. In other words, each record of a is paired with each record of b. If a has 3 records and b has 5 records, then the above combined table reference will produce 15 records (3 x 5).


This “output” is “fed” / “piped” into the GROUP BY clause (after filtering in the WHERE clause), where it is transformed into a new “output”. We’ll deal with that later on.


If we’re looking at these things from a relational algebra / set theory perspective, a SQL table is a relation or a set of tuples. And each SQL clause will transform one or several relations in order to produce new relations.


What do we learn from this?


Always think in terms of table references to understand how data is “pipelined” through your SQL clauses.


4. SQL table references can be rather powerful


A table reference is something rather powerful. A simple example of their power is the JOIN keyword, which is actually not part of the SELECT statement, but part of a “special” table reference. The joined table, as defined in the SQL standard (simplified):


<tablereference> ::=
<tablename>
|
<derivedtable>
|
<joinedtable>

If we take again the example from before:


FROM a, b

a can be a joined table as such:


a1 JOIN a2 ON a1.id = a2.id

Expanding this into the previous expression, we’d get:


FROM a1 JOIN a2 ON a1.id = a2.id, b

While it is discouraged to combine the comma-separated list of table references syntax with the joined table syntax, you can most certainly do this. The resulting, combined table reference will now have a degree of a1+a2+b.


Derived tables are even more powerful than joined tables. We’ll get to that.


What do we learn from this?


Always, always think in terms of table references. Not only is this important to understand how data is “pipelined” through your SQL clauses (see previous section), it will also help you understand how complex table references are constructed.


And, importantly, understand that JOIN is a keyword for constructing joined tables. Not a part of the SELECT statement. Some databases allow for using JOIN in INSERT, UPDATE, DELETE


5. SQL JOIN tables should be used rather than comma-separated tables


Before, we’ve seen this clause:


FROM a, b

Advanced SQL developers will probably tell you that it is discouraged to use the comma-separated list at all, and always fully express your JOINs. This will help you improve readability of your SQL statement, and thus prevent mistakes.


One very common mistake is to forget a JOIN predicate somewhere. Think about the following:


FROM a, b, c, d, e, f, g, h
WHERE a
.a1 = b.bx
AND a
.a2 = c.c1
AND d
.d1 = b.bc
-- etc...

The join table syntax is both


  • Safer, as you can place join predicates close to the joined tables, thus preventing mistakes.

  • More expressive, as you can distinguish between OUTER JOIN, INNER JOIN, etc.

What do we learn from this?


Always use JOIN. Never use comma-separated table references in your FROM clauses.


6. SQL’s different JOIN operations


JOIN operations essentially come with five flavours:


  • EQUI JOIN

  • SEMI JOIN

  • ANTI JOIN

  • CROSS JOIN

  • DIVISION

These terms are commonly used in relational algebra. SQL uses different terms for the above concepts, if they exist at all. Let’s have a closer look:


EQUI JOIN


This is the most common JOIN operation. It has two sub-flavours:


  • INNER JOIN (or just JOIN)

  • OUTER JOIN (further sub-flavoured as LEFT, RIGHT, FULL OUTER JOIN)

The difference is best explained by example:


--This table reference contains authors and their books.--Thereis one record for each book and its author.-- authors without books are NOT included
author JOIN book ON author
.id = book.author_id

--This table reference contains authors and their books
--Thereis one record for each book and its author.--... OR there is an "empty" record for authors without books
--("empty" meaning that all book columns are NULL)
author LEFT OUTER JOIN book ON author
.id = book.author_id

SEMI JOIN


This relational concept can be expressed in two ways in SQL: Using an IN predicate, or using an EXISTS predicate. “Semi” means “half” in latin. This type of join is used to join only “half” of a table reference. What does that mean? Consider again the above joining of author and book. Let’s imagine that we don’t want author/book combinations, but just those authors who actually also have books. Then we can write:


--Using IN
FROM author
WHERE author
.id IN (SELECT book.author_id FROM book)--Using EXISTS
FROM author
WHERE EXISTS
(SELECT 1 FROM book WHERE book.author_id = author.id)

While there is no general rule as to whether you should prefer IN or EXISTS, these things can be said:


  • IN predicates tend to be more readable than EXISTS predicates

  • EXISTS predicates tend to be more expressive than IN predicates (i.e. it is easier to express very complex SEMI JOIN)

  • There is no formal difference in performance. There may, however, be a huge performance difference on some databases.

Because INNER JOIN also produces only those authors that actually have books, many beginners may think that they can then remove duplicates using DISTINCT. They think they can express a SEMI JOIN like this:


--Find only those authors who also have books
SELECT DISTINCT first_name
, last_name
FROM author
JOIN book ON author
.id = book.author_id

This is very bad practice for two reasons:


  • It is very slow, as the database has to load a lot of data into memory, just to remove duplicates again.

  • It is not entirely correct, even if it produces the correct result in this simple example. But as soon as you JOIN more table references, you will have a very hard time correctly removing duplicates from your results.

Some more information about abuse of DISTINCT can be seen in this blog post.


ANTI JOIN


This relational concept is just the opposite of a SEMI JOIN. You can produce it simply by adding a NOT keyword to the IN or EXISTS predicates. An example, where we’ll select those authors who do not have any books:


--Using IN
FROM author
WHERE author
.id NOT IN (SELECT book.author_id FROM book)--Using EXISTS
FROM author
WHERE NOT EXISTS
(SELECT 1 FROM book WHERE book.author_id = author.id)

The same rules with respect to performance, readability, expressivity apply. However, there is a small caveat with respect to NULLs when using NOT IN, which is a bit out of scope for this tutorial.


CROSS JOIN


This produces a cross product of the two joined table references, combining every record of the first table reference with every record of the second table reference. We have seen before, that this can be achieved with comma-separated table references in the FROM clause. In the rare cases where this is really desired, you can also write a CROSS JOIN explicitly, in most SQL dialects:


--Combine every author with every book
author CROSS JOIN book

DIVISION


The relational division is really a beast of its own breed. In short, if JOIN is multiplication, division is the inverse of JOIN. Relational divisions are very tough to express in SQL. As this is a beginners’ tutorial, explaining it is out of scope. For the brave among you, read on about it here, here, and here.


What do we learn from this?


A lot. Again, let’s hammer this into our heads. SQL is about table references. Joined tables are quite sophisticated table references. But there is a difference in relational-speak and SQL-speak. Not all relational join operations are also formal SQL join operations. With a bit of practice and knowledge about relational theory, you will always be able to choose the right type of relational JOIN and be able to translate it to the correct SQL.


7. SQL’s derived tables are like table variables


Before, we’ve learned that SQL is a declarative language, and as such, variables do not have a place (they do in some SQL dialects, though). But you can write something likevariables. And those beasts are called derived tables.


A derived table is nothing but a subquery wrapped in parentheses.


-- A derived table
FROM
(SELECT * FROM author)

Note that some SQL dialects require derived tables to have a correlation name (also known as alias).


-- A derived table with an alias
FROM
(SELECT * FROM author) a

Derived tables are awesome when you want to circumvent the problems caused by thelogical ordering of SQL clauses. For instance, if you want to reuse a column expression in both the SELECT and the WHERE clause, just write (Oracle dialect):


--Get authors' first and last names, and their age in days
SELECT first_name, last_name, age
FROM (
SELECT first_name, last_name, current_date - date_of_birth age
FROM author
)
-- If the age is greater than 10000 days
WHERE age > 10000

Note that some databases, and the SQL:1999 standard have taken derived tables to the next level, introducing common table expressions. This will allow you to reuse the samederived table several times within a single SQL SELECT statement. The above query would then translate to the (almost) equivalent:


WITH a AS (
SELECT first_name
, last_name, current_date - date_of_birth age
FROM author
)
SELECT
*
FROM a
WHERE age
>10000

Obviously, you could also externalise “a” into a standalone view for even broader reuse of common SQL subselects. Read more about views here.


What do we learn from this?


Again, again, again. SQL is mostly about table references, not columns. Make use of them. Don’t be afraid of writing derived tables or other complex table references.


8. SQL GROUP BY transforms previous table references


Let’s reconsider our previous FROM clause:


FROM a, b

And now, let’s apply a GROUP BY clause to the above combined table reference


GROUP BY A.x, A.y, B.z

The above produces a new table reference with only three remaining columns (!). Let’s digest this again. If you apply GROUP BY, then you reduce the number of available columns in all subsequent logical clauses – including SELECT. This is the syntactical reason why you can only reference columns from the GROUP BY clause in the SELECT clause.


  • Note that other columns may still be available as arguments of aggregate functions:
    SELECT A.x, A.y, SUM(A.z)
    FROM A
    GROUP BY A
    .x, A.y


  • Note that MySQL, unfortunately, doesn’t adhere to this standard, causing nothing but confusion. Don’t fall for MySQL’s tricks. GROUP BY transforms table references. You can thus only reference columns also referenced in the GROUP BY clause.

What do we learn from this?


GROUP BY, again, operates on table references, transforming them into a new form.


9. SQL SELECT is called projection in relational algebra


I personally like the term “projection”, as it is used in relational algebra. Once you’ve generated your table reference, filtered it, transformed it, you can step to projecting it to another form. The SELECT clause is like a projector. A table function making use of arow value expression to transform each record from the previously constructed table reference into the final outcome.


Within the SELECT clause, you can finally operate on columns, creating complex column expressions as parts of the record / row.


There are a lot of special rules with respect to the nature of available expressions, functions, etc. Most importantly, you should remember these:


  1. You can only use column references that can be produced from the “output” table reference

  2. If you have a GROUP BY clause, you may only reference columns from that clause, or aggregate functions.

  3. You can use window functions instead of aggregate functions, when you don’t have a GROUP BY clause.

  4. If you don’t have a GROUP BY clause, you must not combine aggregate functions with non-aggregate functions.

  5. There are some rules with respect to wrapping regular functions in aggregate functions and vice-versa.

  6. There are …

Well, there are lots of complex rules. They could fill yet another tutorial. For instance, the reason why you cannot combine aggregate functions with non-aggregate functions in the projection of a SELECT statement without GROUP BY clause (rule number 4) is this:


  1. It doesn’t make sense. Intuitively.

  2. If intuition doesn’t help (it hardly does, with a SQL beginner), then syntax rules do. SQL:1999 introduced GROUPING SETS, and SQL:2003 introduced empty grouping sets: GROUP BY (). Whenever an aggregate function is present, and there is no explicit GROUP BY clause, an implicit, empty GROUPING SET is applied (rule number 2). Hence, the original rules about logical ordering aren’t exactly true anymore, and the projection (SELECT) influences the outcome of a logically preceding, yet lexically succeeding clause (GROUP BY).

Confused? Yes. Me too. Let’s get back to simpler things.


What do we learn from this?


The SELECT clause may be one of the most complex clauses in SQL, even if it appears so simple. All other clauses just “pipe” table references from one to another. The SELECT clause messes up the beauty of these table references, by completely transforming them, applying some rules to them retroactively.


In order to understand SQL, it is important to understand everything else first, before trying to tackle SELECT. Even if SELECT is the first clause in lexical ordering, it should be the last.


10. SQL DISTINCT, UNION, ORDER BY, and OFFSET are simple again


After the complicated SELECT, we can get back to simple things again:


  • Set operations (DISTINCT and UNION)

  • Ordering operations (ORDER BY, OFFSET .. FETCH)

Set operations


Set operations operate on “sets”, which are actually nothing other than… tables. Well, almost. Conceptually, they’re easy to understand.


  • DISTINCT removes duplicates after the projection.

  • UNION concatenates two subselects and removes duplicates

  • UNION ALL concatenates two subselects retaining duplicates

  • EXCEPT removes records from the first subselect that are also contained in the second subselect (and then removes duplicates)

  • INTERSECT retains only records contained in both subselects (and then removes duplicates)

All of this removing duplicates is usually non-sense. Most often, you should just use UNION ALL, when you want to concatenate subselects.


Ordering operations


Ordering is not a relational feature. It is a SQL-only feature. It is applied at the very end of both lexical ordering and logical ordering of your SQL statement. Using ORDER BY and OFFSET .. FETCH is the only way to guarantee that records can be accessed by index in a reliable way. All other ordering is always arbitrary and random, even if it may appear to be reproducible.


OFFSET .. FETCH is only one syntax variant. Other variants include MySQL’s and PostgreSQL’s LIMIT .. OFFSET, or SQL Server’s and Sybase’s TOP .. START AT. A good overview of various ways to implement OFFSET .. FETCH can be seen here.



New or latest best, top excellent useful SQL server (Database) Tutorials or Online Learning websites For Beginners 2014

30+ New or latest best, top excellent useful CSS, CSS# tutorials or plugins examples and demos 2014

If you are thinking about doing something different just with CSS3, then try using it to develop amazing 3D ribbons. The options are countless and you can keep experimenting with them to come up with an exclusive looking website. For example, the innovative coding techniques and plug-in features of CSS allow you to design an easy to navigate tabbed bar. The technique is simple but very effective. Use it once; you will surely love the look it will give to your website. You can also use a combination ofjQuery and CSS3 to custom built a dialog box in your website. It’s a fantastic tool and you can definitely derive optimum benefits from it. A custom dialog box can help you take care of the incompatibility issues with different browsers.


Do you want to build an attractive website? If yes, then try using any of the 30+ best CSS/jQuery plugins and coding techniques that can help you big time. By using CSS/jQuery plugins and coding techniques, you can develop an advanced website and that too with extreme ease. So are you ready for this? You can apply CSS3 to build a gorgeous stack of index cards with the dynamic transition and transform effects. Or, apply the awesome JavaScript to design moveable objects. Have you heard about thejQuery And CSS3 functions? No! Don’t worry. You can use these to create a vertical sliding panel on the website. The elements arranged in the panel give users an easy access to their desired location compared to the horizontal sliding panel, which rolls down the list.


The choices of CSS/JavaScript plugins and coding techniques are vast. You just have to explore each one of them to continuously upgrade your site and offer your users an easy navigation experience. If you want your website to be a huge success, do try these technologically sound tools.


CSS, CSS3/jQuery Plugins and Coding Techniques


Create CSS3 Pricing Tables


CSS3 Pricing Tables


Grid Navigation Effects with jQuery



The 30 CSS Selectors you Must Memorize



Beautiful Slide Out Navigation: A CSS and jQuery Tutorial



Fixed Fade Out Menu: A CSS and jQuery Tutorial



Beautiful Slide Out Navigation Revised



Beautiful Background Image Navigation with jQuery



Twitter API and jQuery Showcase: Display your Followers or Friends



CSS and jQuery Tutorial: Fancy Apple-Style Icon Slide Out Navigation



A Fresh Bottom Slide Out Menu with jQuery



Vertical Sliding Accordion with jQuery



Animated Text and Icon Menu with jQuery



Circular Content Carousel with jQuery



Portfolio Image Navigation with jQuery



Expanding Fullscreen Grid Portfolio



 


Simple jQuery Fluid Thumbnail menu Bar



Slides, A Slideshow Plugin for jQuery



Colorful Sliders With jQuery & CSS3



SEE ALSO: Startup Framework on Rails


Contextual Slideout Tips With jQuery & CSS3



Awesome Cufonized Fly-out Menu with jQuery and CSS3



Thumbnails Navigation Gallery with jQuery



Creating a Fancy menu using CSS3 and jQuery



Feature Table Design



CSS & jQuery clickable map of Europe



Easy Display Switch with CSS and jQuery



Perfect Full Page Background Image



Codename Rainbows



Pure CSS3 bokeh effect with some jQuery help



jQuery UI Selectmenu: An ARIA-Accessible Plugin for Styling a Custom HTML Select Element



jQuery & CSS Sprite Animation Explained In Under 5 Minutes




30+ New or latest best, top excellent useful CSS, CSS# tutorials or plugins examples and demos 2014

Top 10 New or latest best, excellent useful AJAX tutorials or plugins examples and demos 2014

AJAX provides Web developers with plenty of opportunities toenhance the user experience and improve the performance of their websites. There are countless ways that AJAX can be used, and fortunately there are plenty of good and useful AJAX tutorials out there to help you with your own implementation.


This post serves as a collection of useful tutorials on working with AJAX in a wide variety of ways. You’ll find tutorials on working with forms, building shopping carts, creating chat features, working with log-ins and usernames and much more.


Shopping Cart with jQuery, PHP and CSS based on AJAX


Best AJAX Tutorials (1)


Using this tutorial, you can easily create an AJAX based shopping cart. You can store all the products in MYSQL by using PHP. The use of jQuery will deliver AJAX on website page. If you use simpletip plug-in, you can easily deliver interactive checkout process.


Twitter List Fan Page Powered by AJAX


Best AJAX Tutorials (2)


Twitter had launched ‘lists’ feature recently. Using it, you can group your followers and categorize them. You can also learn how create widget which will flip list the other way round. You have to use a new API Key for this purpose. This widget will allow the viewers to fill their Twitter names and join special fan list.


AJAX website with jQuery


Best AJAX Tutorials (3)


You can create a basic AJAX based website using PHP, CSS, and jQuery. After completing the coding work, the website will load its pages through AJAX taking PHP as backend. It also supports the browser history completely. Achieving this is a great task using AJAX.


Multiple File Upload Form through AJAX using jQuery


Best AJAX Tutorials (4)


The AJAX multiple file upload form option uses negligible server side code and provides a great user interface. This reduces the time required in its actual development. jQuery had helped significantly in this process.


AJAX Delete jQuery


Best AJAX Tutorials (5)


Removing content using AJAX is very helpful for web designer. The few lines of jQuery can easily remove or delete the entries and records from the database through AJAX. With this demo, you can see a red cross on right of each comment. You can also remove the comment DIV by clicking to this cross and also through slide up animation.


AJAX jQuery and PHP based Voting System


Best AJAX Tutorials (6)


The Dzone will suggest the users to vote for any particular link, giving their reviews to the article or website content. In this demo, you will learn to re-create unique voting system by use of AJAX, PHP, and jQuery.


AJAXify WordPress Comment Posting


Best AJAX Tutorials (7)


You can learn how to facilitate AJAXed comments through client side JavaScript comment form for any WordPress Blog. There are many plug-INS in WordPress to AJAXify comments.


AJAX powered Dynamic Scrolling Content Box


Best AJAX Tutorials (8)


This tutorial will help you out in creating dynamic content box that will easily load list items, add on the list items just like the Google Reader does.


Creating AJAX File Uploader


Best AJAX Tutorials (9)


This application will allow the users to upload multiple files without refreshing the page. It also supports front-end and back-end validation, so that upload of unwanted files is prevented to your server.


Making Web Application Using AJAX


Best AJAX Tutorials (10)


The AJAX based web applications will allow you to create slideshow presentation. It makes use of vigorous functionality with simple code to create such web application.



Top 10 New or latest best, excellent useful AJAX tutorials or plugins examples and demos 2014

LiteBox

Download   Demo


LiteBox is a versatile, auto detecting content, lightbox/modal window for use with images, embedded content (YouTube, Vimeo, Daily Motion and KickStarter), iframes and inline html.



Browser Compatibility


  • IE 8+

  • Firefox

  • Chrome

  • Safari

  • Opera

  • Most mobile browsers


 


1. INCLUDE CSS AND JS FILES


<link href="assets/css/litebox.css" rel="stylesheet" type="text/css" media="all" />
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<script src="assets/js/images-loaded.min.js" type="text/javascript"></script>
<script src="assets/js/litebox.js" type="text/javascript"></script>

2. HTML


<a href="001.jpg" target="_self" class="litebox"><img src="001-thumb.jpg" alt="Image 001" /></a>

For embedded content, you only need the URL to the page, not the embed code they provide, as the script will dynamically create the correct link to fetch the video.


<a href="https://www.youtube.com/watch?v=[token-id]" target="_self" class="litebox">YouTube</a>
<a href="https://www.youtu.be/[token-id]" target="_self" class="litebox">YouTube (Alt)</a>
<a href="http://vimeo.com/[token-id]" target="_self" class="litebox">Vimeo</a>
<a href="http://www.dailymotion.com/video/[token-id]" target="_self" class="litebox">Daily Motion</a>
<a href="https://www.kickstarter.com/projects/[token-id]/[token-name]/" target="_self" class="litebox">KickStarter</a>

To place a website in an iframe, just link to that particular page as you would do any other hyperlink. For inline content, create the element somewhere on your page, set its display to none, within there create your element and give it an unique id. Then place this id (with the hashtag) in the href attributes value.


<a href="http://www.bing.com" target="_self" class="litebox">Iframe</a>
<a href="#inline-html-1" target="_self" class="litebox">Inline HTML </a>

<div>
<div id="inline-html-1">
<h1 class="bm-large tm-large">Inline HTML Example</h1>
<p class="bm-large">In here you can pull any elements from the page to display in the Litebox</p>
</div>
</div>

You can also create a gallery/group where you can navigate through the content by adding the attribute data-litebox-group, this works for any type of content and can even have mixed content.


<a href="001.jpg" target="_self" class="litebox" data-litebox-group="group-1"><img src="001-thumb.jpg" alt="Image 001" /></a>
<a href="002.jpg" target="_self" class="litebox" data-litebox-group="group-1"><img src="002-thumb.jpg" alt="Image 002" /></a>
<a href="003.jpg" target="_self" class="litebox" data-litebox-group="group-1"><img src="003-thumb.jpg" alt="Image 003" /></a>
<a href="004.jpg" target="_self" class="litebox" data-litebox-group="group-1"><img src="004-thumb.jpg" alt="Image 004" /></a>

3. JAVASCRIPT


$('.litebox').liteBox();

4. OPTIONS















































OptionsDefaultDescription
revealSpeed400The fade in time of the lightbox
background‘rgba(0, 0, 0, .8)’Sets the background color of the dimmer that overlays the viewport.
overlayClosetrueWhen set to true, clicking the overlay will close the lightbox.
escKeytrueWhen set to true, pressing the Esc key will close the lightbox.
navKeytrueWhen set to true, pressing the Left or Right arrow keys will navigation through any grouped content in the lightbox
callbackInitfunction() Calls a JavaScript function when the lightbox is initiated.
callbackBeforeOpenfunction() Calls a JavaScript function before the lightbox is opened.
callbackAfterOpenfunction() Calls a JavaScript function after the lightbox is opened.
callbackBeforeClosefunction() Calls a JavaScript function before the lightbox is closed.
callbackAfterClosefunction() Calls a JavaScript function after the lightbox is closed.
callbackErrorfunction() Calls a JavaScript function when the lightbox encounters an error.
callbackPrevfunction() Calls a JavaScript function when the prev button of the lightbox is triggered.
callbackNextfunction() Calls a JavaScript function when the next button of the lightbox is triggered.
errorMessage‘Error loading content.’Sets the error message that is displayed upon the plugin encountering an error.

LiteBox

jQuery msgbox

Download   Demo


Msgbox is an versatile jQuery popup plugin for creating modals, dialogs, message boxes that are draggable, themable, resizable and fully customizable.


Why another jquery popup plugin ?


Most of the exising jquery popup plugins are lacking some of the features:


  • Multiple instances support

  • Resize handler to resize the popup box

  • Maximization/Minimization of the popup box

  • Dragging support

  • Theme customization

  • Key bindings support

  • Working as a photo slideshow

  • Fourth party library indenpendent (some may dependent on jQuery UI, etc)

If you are looking for a plugin with most of the above features, here it is


Features


(c) could be customized


  • Key bindings (c)

  • Overlay events (c)

  • Draggable

  • Resizable

  • Icons, (prev,play,next,min,max,close) (c)

  • Buttons in footer, and their events could be fully customized (c)

  • Working as a photo viewer

  • Themes (c)

  • Multiple instances (task tar simulation)

  • Internationalization (c)

  • API

1. INCLUDE CSS AND JS FILES


<link rel="stylesheet" href="../themes/metro/css/jquery.msgbox.css" type="text/css" />
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<script type="text/javascript" src="../jquery.msgbox.i18n.js"></script>
<script type="text/javascript" src="../jquery.msgbox.js"></script>

2. HTML


<a href="javascript:;" class="msgbox basic">Open basic msgbox</a>

3. JAVASCRIPT


$(".msgbox.basic").msgbox(
content: 'Hello world',
padding: 12
);

4. OPTIONS


jquery.msgbox could be either initialized by $.msgbox(arguments) or $(SELECTOR).msgbox(arguments)


The arguments is an javascript object with key-value pairs (e.g. title: ‘Hello’, content: ‘Hello world!’):


NOTICE: Although no arguments is required, to initialize a msgbox, an object, even an empty object (), is needed.


Because we use $.msgbox() and $(SELECTOR).msgbox() to retrieve the object.


 

































































































































































































KeyValue typeDefault valueDescription
fixedbooleantrueWhether the position of the box is fixed
overlaybooleantrueWhether to show the overlay or not
overlayEventstring|function‘flash’The event when clicking the overlayIf a string is given, the API will be called; otherwise, the function will be fired.
idstring|number0The identity of the instance, used for multiple instancesMultiple instances are only available by using $.msgbox(…)with a unique id
openboolean$(SELECTOR).msgbox: false

$.msgbox: true
Whether to open the msgbox after initialized.When using $(SELECTOR).msgbox, the msgbox will not be opened until the trigger is clicked or the .open() API is called. When using $.msgbox, it will be opened by default.
dragboolean|jquery selectorwindowWhether to enable the dragging of msgobx.If a jquery selector is given, the msgbox will be allowed only dragged in the element.
resizeboolean|objecttrueWhether to enable the resizing of msgobx.If true is given, it will use width: minWidth, height: titleHeight as default. It defines the minimal scale of msgbox can be resized.
titleboolean|stringfalseThe title of msgboxIf false is given, it will be replace by the attribute “title” of the trigger when in photo/image/gallery/album mode.
typestring‘html’The type of msgboxSupported types: text, ajax, html, iframe, confirm, alert, prompt, warning, info, error, success, photo, image=photo, album, gallery=album
contentboolean|stringfalseThe content of msgboxIf false is given, the content will be replaced by jquery.msgbox version information. Different types have different contents. For text, html, confirm, alert, prompt, warning, info, error, success, the content is the content which will be display in the box. For ajax, iframe, the content is the url to be loaded. Forphoto, image, album, gallery, the content is the jquery selector of the triggers, which are usually links like <a href=”photo.jpg” class=”photo” title=”A photo”>click to show photo</a>.
iconsarraytype=confirm, alert, prompt, warning, info, error, success, photo, image: ['close']

type=album, gallery: ['prev', 'play', 'next', 'min', 'max', 'close']

type=other: ['max', 'close']
The icons of msgboxSupported icons: prev, play, next, min, max, close
buttonsarraytype=confirm, alert, prompt, warning, info, error, success, photo, image: ['OK']

type=confirm, prompt: ['OK', 'Cancel']

type=other: []
The buttons in the footerThis could be fully customized. The events could be specify by buttonEvents
buttonEventsobject
The events bond to the buttonsThe key should exist in buttons, ‘OK’, ‘Cancel’ will override the default actions of the two buttons. When specify a function, this will refer to the msgbox itself. If a string specified to a key, the API will be called. E.g. ‘OK’:’close’ means when click OK button, it will call API close()
keyEventsobject Esc: ‘close’,

Space: ‘play’,

Left: ‘prev’,

Right: ‘next’,

Enter: ‘play’
The key events.Only takes effects on the focusing msgbox. The meaning of the value is the same as buttonEvents
prefixstringjMsgboxThe class prefix or the jquery events binding namespace.E.g. the class of overlay: jMsgbox-overlay (see css file). The event bond to overlay: ‘click.jMsgbox’
widthnumber600The width of msgbox
heightnumber450The height of msgbox
initialWidthnumber350The initial width of msgboxSee initialHeight
initialHeightnumber220The initial height of msgbox1. the initial dimension to be zoomed in/out to width, height

2.If width and height are not given, or exactly the same as the default width and height, they will be specified as initialWidth and initialHeight , respectively, when the type is one of alert, info, prompt, confirm, success, warning, error.
topboolean|numberfalseThe initial top position of the msgboxIf false, it will be placed in the middle of the window
leftboolean|numberfalseThe inital left position of the msgboxIf false, it will be placed in the center of the window
titleHeightnumber40The height of the title wrapperIf the height of .jMsgbox-title is not indicated in css, this value will be used. If you want to override it in css, please use !important
footHeightnumber30The height of the footerSimilar as titleHeight, the class name is .jMsgbox-foot
transitionstringswingThe transition when opening or closing msgboxOnly jquery built-in transition supported: swing, linear
speednumber300The speed of the opening or closing animation
opacitynumber0.9The opacity of the overlayOf course you can use css, but this is an easy way to make it supported by cross-browsers
zIndexnumber99The z-index of overlay and the box wrapperUse it just in case of some elements with greater z-index in the page (, if you want to cover them with msgbox).
langstringenThe language of the msgboxSee Internationalization
minPosstringtopThe position of the “task bar”When create multiple instances, you are able to minimize all of them to simulate a task bar.
minWidthnumber200The minimal width of msgbox1. the width of msgbox when minimized 2. the minimal width when resize msgbox
paddingnumber0The padding of the contentSometimes you need a padding of the content, e.g.: for text type or html type. However, you don’t need them for photos in most cases. CSS cannot differentiate the types, so you can define them here. Remember to use !important to override if you’d like to define it in CSS.
photoAutobooleantrueWhether to start playing the gallery when open it
photoSpeednumber2500The interval of showing a photo in gallery
photoScaledbooleanfalseWhether to scale the photo to width, height. If not, it will show its original dimension.
photoFadebooleantrueWhether to use fadeIn to show the photo after loaded
imgErrorstring‘Failed to load image.’The error message when failed to load image.This could be override by $.msgboxI18N.en.imgError
xhrErrorstringFailed to load URL.The error message when failed to load an ajax URL.This could be override by $.msgboxI18N.en.xhrError
onOpenfunction
The callback when msgbox is opened
onClosefunction
The callback when msgbox is closed
onLoadfunction
The callback when the content is loaded
onBeforeClosefunction
The callback just before the close triggers. The close will be cancelled when it returns false.

5. API


As in Full Settings mentioned, we use $.msgbox() and $(SELECTOR).msgbox() to retrieve the msgbox. We can also use $.msgbox(id) to retrieve a msgbox when deal with multiple instances. Once got the object, we can call the API in this wah: $.msgbox().close() or $(SELECTOR).msgbox().close()


In all the callbacks, this will refer to the msgbox object.


NOTICE: When initialize a msgbox: $(SELECTOR).msgbox(…), it will return a jQuery object to keep chaining, instead of a msgbox object.


























































APIArgumentsDescription
enableDrag
To enable dragging
disableDrag
To disable dragging
enableResize
To enable resizing
disableResize
To disable resizing
flashopacity(number): the opacity to change,

interval(number): the interval between each opacity change

callback(function): the callback
To flash the title by changing the opacity 2 times (simulation of windows)
playcallback(function): the callbackTo play the gallery. If the gallery is already playing, it will pause.
nextcallback(function): the callbackTo show the next photo in the gallery.
prevcallback(function): the callbackTo show the previous photo in the gallery
pause
To pause the gallery playing
opencallback(function): the callbackTo open the msgbox
val
To return the value of msgbox. The value is set in prompt or confirm
closecallback(function): the callbackTo close the msgbox
remove
To remove the msgbox. (click the trigger, msgbox will no show any more and new msgbox will not be generated either.)
titlet(string): the new titleTo return the title (if t is not specified), or to set a new title.
reloadcallback(function): the callbackTo reload the content of the msgbox
focuscallback(function): the callbackIf msgbox is minimized, restore it; if it is closed, open it; if it is opened, flash the title.
restorecallback(function): the callbackTo restore the msgbox from minimized or maximized.
mincallback(function): the callbackTo minimize the msgbox. If it is already minimized, restore it.
maxcallback(function): the callbackTo maximize the msgbox. If it is already minimized, restore it.
contentc(string): the new contentTo get the content(html) (if c is not specified), or to set the new content(html).

Static

















APIArgumentsDescription
$.msgbox.defaultsoptions(object)=Change the default settings
$.msgbox.closeAllcallback(function)Close all the msgboxes generated by $.msgbox. Callback will be called after all msgboxes closed.
$.msgbox.restoreAllcallback(function)Restore all the msgboxes generated by $.msgbox. Callback will be called after all msgboxes restored from minimized or maximized.
$.msgbox.minAllcallback(function)Minimize all the msgboxes generated by $.msgbox. Callback will be called after all msgboxes minimized.

6. INTERNATIONALIZATION


Refer the file jquery.msgbox.i18n.js and specify a language lang to use i18n.


























KeyDescription
OKThe value of the ‘OK’ button
CancelThe value of the ‘Cancel’ button
LoadingThe message when an iframe is loading
Play/PauseThe title of the ‘play’ icon
NextThe title of the ‘next’ icon
PrevThe title of the ‘prev’ icon
MinimizeThe title of the ‘min’ icon
MaximizeThe title of the ‘max’ icon
CloseThe title of the ‘close’ icon
xhrErrorThe error message when failed to load the ajax URL.
imgErrorThe error message when failed to load the image.

7. EXAMPLES


text: Open msgbox


$(".jmb-text").msgbox(
type: 'text',
content: 'Text content'
);

html (default): Open msgbox


$(".jmb-html").msgbox(
type: 'html',
content: '<p>HTML content</p><p style="color: #f33;">HTML content</p>'
);

ajax: Open msgbox


$(".jmb-ajax").msgbox(
type: 'ajax',
content: 'index.html'
);

iframe: Open msgbox


$(".jmb-iframe").msgbox(
type: 'iframe',
content: 'index.html'
);

confirm: Open msgbox


$(".jmb-confirm").msgbox(
type: 'confirm',
content: 'Are you sure',
onClose: function()
alert(!!this.val());

);

alert: Open msgbox


$(".jmb-alert").msgbox(
type: 'alert',
content: 'Message',
title: 'Alert'
);

prompt: Open msgbox


$(".jmb-prompt").msgbox(
type: 'prompt',
content: 'Please input: ',
onClose: function()
alert(this.val());

);

photo: Open msgbox Open msgbox by $.msgbox


//<a href="https://www.google.com.hk/images/srpr/logo11w.png" title="Google Logo" class="jmb-photo">Open msgbox</a>
$(".jmb-photo").msgbox(
type: 'photo'
);
$(".jmg-photo-opener").click(function()
$.msgbox(
type: 'photo',
content: '.jmb-photo'
);
);

gallery: Open msgbox (1st photo) Open msgbox (2nd photo) Open msgbox (3rd photo) Open msgbox by $.msgbox


$(".jmb-gallery").msgbox(
type: 'gallery'
);
$(".jmg-gallery-opener").click(function()
$.msgbox(
type: 'gallery',
content: '.jmb-gallery'
);
);


jQuery msgbox