3D Drop In Notifier Panel v1.1
Note: v1.1 (Dec 22nd, 13): Fixed various issues in legacy browsers such as IE8/9 and Opera, adds alternate transition effect.
Description: 3D Notifier lets you broadcast important information to your visitors using a drop down panel that appears at the top of the page. It gently scrolls the page to the top before revealing the panel in a 3D fashion. The panel contents can either be defined inline on the page, or entirely inside an external file and fetched via Ajax. Two modes of appearing are supported- "manual", where you explicitly open/close the panel, or automatic, where the panel appears automatically once per browser session to each visitor.
Demo: Look up!
Step 1: Insert the following code in the HEAD section of your page
The code above references three external files, which you need to download below (right click/ select "Save As"):
- notifier.js
- notifier.css
- content.txt (markup of Panel, by default, defined inside this file and fetched via Ajax).
By default, upload these files to the same directory as where your webpage resides.
Step 2: Insert the below sample buttons that manipulate the panel into the BODY section of your page:
That's it for installation! Lets move on to understanding how everything works.
HTML Markup of 3D Panel
The markup of the panel can either be defined inside an external file (default setup), or inline on the page. Whichever route you go, it should consist of the below basic structure:
<div class="notify" id="mynotify">
<div class='content'>
Your content here
Your content here
Your content here
"
<div class="close">X Close</div>
</div>
</div>
The markup should contain two outer nested DIVs, with the desired content to show inside the innermost. The outermost DIV should carry an unique but arbitrary ID, with both DIVs adopting the CSS class names you see above. Any element with a class of "close" inside the markup will be treated as a close button by the script.
As mentioned, the markup of the panel can be defined inside an
external file and fetched via Ajax, or inline on the page. If the later, set the
"content" option of the initialization code to "inline
":
jQuery(function(){ // on DOM load
notifier.init({
noteid: 'mynotify', //id of main panel div
content: 'inline', // 'inline' or 'path to external file'
defaultstate: 'open', // 'open' or 'closed'
freq: 'manual', //'manual' or 'session'
oninit: function($el, state){
// do something when panel loads
},
onopenclose: function($el, state){
// do something when panel opens or closes
}
})
})
Speaking of initialization code, it should be called in the HEAD section of your page, after the DOM loads. Lets look at the supported options of this function now, which should each be separated by a comma except the very last option.
Available Options for
notifier.init()
Creating a dynamic toggle button
Using the onopenclose() and oninit() event handlers of the Panel, you can create a toggle button that reflects the inverse ystate of the Panel. Here's an example:
Here's the markup for the toggle button:
<a id="dyntoggle" href="#" class="toggle" onClick="notifier.toggle(); return false">Toggle Panel</a>
And here's the initialization code for the Panel:
<script>
var $togglebutt // register global variable pointing to
toggle button
jQuery(function(){ // on DOM load
notifier.init({
noteid: 'mynotify', //id of main panel div
content: 'inline', // 'inline' or 'path to external file'
defaultstate: 'open', // 'open' or 'closed'
freq: 'manual', //'manual' or 'session'
oninit: function($el, state){
$togglebutt = $('#dyntoggle')
$togglebutt.text( (state == 'open')? 'Close Panel' : 'Open Panel' )
},
onopenclose: function($el, state){
$togglebutt.text( (state == 'open')? 'Close Panel' : 'Open Panel' )
}
})
})
</script>