$.notify( string|object, [ options ])
+ string|object - global notification dataoptions - an options object or class name string
diff --git a/CNAME b/CNAME new file mode 100644 index 0000000..31a91ae --- /dev/null +++ b/CNAME @@ -0,0 +1 @@ +notifyjs.com \ No newline at end of file diff --git a/dist/styles/notify-bootstrap.js b/dist/styles/bootstrap/notify-bootstrap.js similarity index 100% rename from dist/styles/notify-bootstrap.js rename to dist/styles/bootstrap/notify-bootstrap.js diff --git a/docs/Gruntsource.json b/docs/Gruntsource.json new file mode 100644 index 0000000..25abc44 --- /dev/null +++ b/docs/Gruntsource.json @@ -0,0 +1,7 @@ +{ + "source": "~/.grunt-sources/web", + "repo": "https://github.com/jpillora/grunt-source-web.git", + "output": { + "html": "../index.html" + } +} \ No newline at end of file diff --git a/docs/css/app.css b/docs/css/app.css new file mode 100644 index 0000000..6e93057 --- /dev/null +++ b/docs/css/app.css @@ -0,0 +1,1467 @@ +/* +* Skeleton V1.2 +* Copyright 2011, Dave Gamache +* www.getskeleton.com +* Free to use under the MIT license. +* http://www.opensource.org/licenses/mit-license.php +* 6/20/2012 +*/ + + +/* Table of Content +================================================== + #Reset & Basics + #Basic Styles + #Site Styles + #Typography + #Links + #Lists + #Images + #Buttons + #Forms + #Misc */ + + +/* #Reset & Basics (Inspired by E. Meyers) +================================================== */ + html, body, div, span, applet, object, iframe, h1, h2, h3, h4, h5, h6, p, blockquote, pre, a, abbr, acronym, address, big, cite, code, del, dfn, em, img, ins, kbd, q, s, samp, small, strike, strong, sub, sup, tt, var, b, u, i, center, dl, dt, dd, ol, ul, li, fieldset, form, label, legend, table, caption, tbody, tfoot, thead, tr, th, td, article, aside, canvas, details, embed, figure, figcaption, footer, header, hgroup, menu, nav, output, ruby, section, summary, time, mark, audio, video { + margin: 0; + padding: 0; + border: 0; + font-size: 100%; + font: inherit; + vertical-align: baseline; } + article, aside, details, figcaption, figure, footer, header, hgroup, menu, nav, section { + display: block; } + body { + line-height: 1; } + ol, ul { + list-style: none; } + blockquote, q { + quotes: none; } + blockquote:before, blockquote:after, + q:before, q:after { + content: ''; + content: none; } + table { + border-collapse: collapse; + border-spacing: 0; } + + +/* #Basic Styles +================================================== */ + body { + background: #fff; + font: 14px/21px 'Merriweather Sans', "HelveticaNeue", "Helvetica Neue", Helvetica, Arial, sans-serif; + color: #444; + -webkit-font-smoothing: antialiased; /* Fix for webkit rendering */ + -webkit-text-size-adjust: 100%; + } + + +/* #Typography +================================================== */ + h1, h2, h3, h4, h5, h6 { + color: #181818; + font-family: 'Merriweather Sans', "Georgia", "Times New Roman", serif; + font-weight: normal; } + h1 a, h2 a, h3 a, h4 a, h5 a, h6 a { font-weight: inherit; } + h1 { font-size: 46px; line-height: 50px; margin-bottom: 14px;} + h2 { font-size: 35px; line-height: 40px; margin-bottom: 10px; } + h3 { font-size: 28px; line-height: 34px; margin-bottom: 8px; } + h4 { font-size: 21px; line-height: 30px; margin-bottom: 4px; } + h5 { font-size: 17px; line-height: 24px; } + h6 { font-size: 14px; line-height: 21px; } + .subheader { color: #777; } + + p { margin: 0 0 20px 0; } + p img { margin: 0; } + p.lead { font-size: 21px; line-height: 27px; color: #777; } + + em { font-style: italic; } + strong { font-weight: bold; color: #333; } + small { font-size: 80%; } + +/* Blockquotes */ + blockquote, blockquote p { font-size: 17px; line-height: 24px; color: #777; font-style: italic; } + blockquote { margin: 0 0 20px; padding: 9px 20px 0 19px; border-left: 1px solid #ddd; } + blockquote cite { display: block; font-size: 12px; color: #555; } + blockquote cite:before { content: "\2014 \0020"; } + blockquote cite a, blockquote cite a:visited, blockquote cite a:visited { color: #555; } + + hr { border: solid #ddd; border-width: 1px 0 0; clear: both; margin: 10px 0 30px; height: 0; } + +/* #Lists +================================================== */ + ul, ol { margin-bottom: 20px; } + ul { list-style: none outside; } + ol { list-style: decimal; } + ol, ul.square, ul.circle, ul.disc { margin-left: 30px; } + ul.square { list-style: square outside; } + ul.circle { list-style: circle outside; } + ul.disc { list-style: disc outside; } + ul ul, ul ol, + ol ol, ol ul { margin: 4px 0 5px 30px; font-size: 90%; } + ul ul li, ul ol li, + ol ol li, ol ul li { margin-bottom: 6px; } + li { line-height: 18px; margin-bottom: 12px; } + ul.large li { line-height: 21px; } + li p { line-height: 21px; } + +/* #Images +================================================== */ + + img.scale-with-grid { + max-width: 100%; + height: auto; } + + +/* #Buttons +================================================== */ + + .button, + button, + input[type="submit"], + input[type="reset"], + input[type="button"] { + background: #eee; /* Old browsers */ + background: #eee -moz-linear-gradient(top, rgba(255,255,255,.2) 0%, rgba(0,0,0,.2) 100%); /* FF3.6+ */ + background: #eee -webkit-gradient(linear, left top, left bottom, color-stop(0%,rgba(255,255,255,.2)), color-stop(100%,rgba(0,0,0,.2))); /* Chrome,Safari4+ */ + background: #eee -webkit-linear-gradient(top, rgba(255,255,255,.2) 0%,rgba(0,0,0,.2) 100%); /* Chrome10+,Safari5.1+ */ + background: #eee -o-linear-gradient(top, rgba(255,255,255,.2) 0%,rgba(0,0,0,.2) 100%); /* Opera11.10+ */ + background: #eee -ms-linear-gradient(top, rgba(255,255,255,.2) 0%,rgba(0,0,0,.2) 100%); /* IE10+ */ + background: #eee linear-gradient(top, rgba(255,255,255,.2) 0%,rgba(0,0,0,.2) 100%); /* W3C */ + border: 1px solid #aaa; + border-top: 1px solid #ccc; + border-left: 1px solid #ccc; + -moz-border-radius: 3px; + -webkit-border-radius: 3px; + border-radius: 3px; + color: #444; + display: inline-block; + font-size: 11px; + font-weight: bold; + text-decoration: none; + text-shadow: 0 1px rgba(255, 255, 255, .75); + cursor: pointer; + margin-bottom: 20px; + line-height: normal; + padding: 8px 10px; + font-family: 'Merriweather Sans', "HelveticaNeue", "Helvetica Neue", Helvetica, Arial, sans-serif; } + + .button:hover, + button:hover, + input[type="submit"]:hover, + input[type="reset"]:hover, + input[type="button"]:hover { + color: #222; + background: #ddd; /* Old browsers */ + background: #ddd -moz-linear-gradient(top, rgba(255,255,255,.3) 0%, rgba(0,0,0,.3) 100%); /* FF3.6+ */ + background: #ddd -webkit-gradient(linear, left top, left bottom, color-stop(0%,rgba(255,255,255,.3)), color-stop(100%,rgba(0,0,0,.3))); /* Chrome,Safari4+ */ + background: #ddd -webkit-linear-gradient(top, rgba(255,255,255,.3) 0%,rgba(0,0,0,.3) 100%); /* Chrome10+,Safari5.1+ */ + background: #ddd -o-linear-gradient(top, rgba(255,255,255,.3) 0%,rgba(0,0,0,.3) 100%); /* Opera11.10+ */ + background: #ddd -ms-linear-gradient(top, rgba(255,255,255,.3) 0%,rgba(0,0,0,.3) 100%); /* IE10+ */ + background: #ddd linear-gradient(top, rgba(255,255,255,.3) 0%,rgba(0,0,0,.3) 100%); /* W3C */ + border: 1px solid #888; + border-top: 1px solid #aaa; + border-left: 1px solid #aaa; } + + .button:active, + button:active, + button.active, + input[type="submit"]:active, + input[type="reset"]:active, + input[type="button"]:active { + border: 1px solid #666; + background: #ccc; /* Old browsers */ + background: #ccc -moz-linear-gradient(top, rgba(255,255,255,.35) 0%, rgba(10,10,10,.4) 100%); /* FF3.6+ */ + background: #ccc -webkit-gradient(linear, left top, left bottom, color-stop(0%,rgba(255,255,255,.35)), color-stop(100%,rgba(10,10,10,.4))); /* Chrome,Safari4+ */ + background: #ccc -webkit-linear-gradient(top, rgba(255,255,255,.35) 0%,rgba(10,10,10,.4) 100%); /* Chrome10+,Safari5.1+ */ + background: #ccc -o-linear-gradient(top, rgba(255,255,255,.35) 0%,rgba(10,10,10,.4) 100%); /* Opera11.10+ */ + background: #ccc -ms-linear-gradient(top, rgba(255,255,255,.35) 0%,rgba(10,10,10,.4) 100%); /* IE10+ */ + background: #ccc linear-gradient(top, rgba(255,255,255,.35) 0%,rgba(10,10,10,.4) 100%); /* W3C */ } + + button.disabled, + button[disabled="disabled"] { + opacity: 0.85; + } + + .button.full-width, + button.full-width, + input[type="submit"].full-width, + input[type="reset"].full-width, + input[type="button"].full-width { + width: 100%; + padding-left: 0 !important; + padding-right: 0 !important; + text-align: center; } + + /* Fix for odd Mozilla border & padding issues */ + button::-moz-focus-inner, + input::-moz-focus-inner { + border: 0; + padding: 0; + } + + +/* #Forms +================================================== */ + + form { + margin-bottom: 20px; } + fieldset { + margin-bottom: 20px; } + input[type="text"], + input[type="password"], + input[type="email"], + textarea, + select { + border: 1px solid #ccc; + padding: 6px 4px; + outline: none; + -moz-border-radius: 2px; + -webkit-border-radius: 2px; + border-radius: 2px; + font: 13px 'Merriweather Sans', "HelveticaNeue", "Helvetica Neue", Helvetica, Arial, sans-serif; + color: #777; + margin: 0; + width: 210px; + max-width: 100%; + display: block; + margin-bottom: 20px; + background: #fff; } + select { + padding: 0; } + input[type="text"]:focus, + input[type="password"]:focus, + input[type="email"]:focus, + textarea:focus { + border: 1px solid #aaa; + color: #444; + -moz-box-shadow: 0 0 3px rgba(0,0,0,.2); + -webkit-box-shadow: 0 0 3px rgba(0,0,0,.2); + box-shadow: 0 0 3px rgba(0,0,0,.2); } + textarea { + min-height: 60px; } + label, + legend { + display: block; + font-weight: bold; + font-size: 13px; } + select { + width: 220px; } + input[type="checkbox"] { + display: inline; } + label span, + legend span { + font-weight: normal; + font-size: 13px; + color: #444; } + +/* #Misc +================================================== */ + .remove-bottom { margin-bottom: 0 !important; } + .half-bottom { margin-bottom: 10px !important; } + .add-bottom { margin-bottom: 20px !important; } + + + +/* +* Skeleton V1.2 +* Copyright 2011, Dave Gamache +* www.getskeleton.com +* Free to use under the MIT license. +* http://www.opensource.org/licenses/mit-license.php +* 6/20/2012 +*/ + +/* Table of Content +================================================== + #Site Styles + #Page Styles + #Media Queries + #Font-Face */ + +/* #Site Styles +================================================== */ + +/* #Page Styles +================================================== */ + +/* #Media Queries +================================================== */ + + /* Smaller than standard 960 (devices and browsers) */ + @media only screen and (max-width: 959px) {} + + /* Tablet Portrait size to standard 960 (devices and browsers) */ + @media only screen and (min-width: 768px) and (max-width: 959px) {} + + /* All Mobile Sizes (devices and browser) */ + @media only screen and (max-width: 767px) {} + + /* Mobile Landscape Size to Tablet Portrait (devices and browsers) */ + @media only screen and (min-width: 480px) and (max-width: 767px) {} + + /* Mobile Portrait Size to Mobile Landscape Size (devices and browsers) */ + @media only screen and (max-width: 479px) {} + + +/* #Font-Face +================================================== */ +/* This is the proper syntax for an @font-face file + Just create a "fonts" folder at the root, + copy your FontName into code below and remove + comment brackets */ + +/* @font-face { + font-family: 'FontName'; + src: url('../fonts/FontName.eot'); + src: url('../fonts/FontName.eot?iefix') format('eot'), + url('../fonts/FontName.woff') format('woff'), + url('../fonts/FontName.ttf') format('truetype'), + url('../fonts/FontName.svg#webfontZam02nTh') format('svg'); + font-weight: normal; + font-style: normal; } +*/ +.pln{color:#000}@media screen{.str{color:#080}.kwd{color:#008}.com{color:#800}.typ{color:#606}.lit{color:#066}.pun,.opn,.clo{color:#660}.tag{color:#008}.atn{color:#606}.atv{color:#080}.dec,.var{color:#606}.fun{color:red}}@media print,projection{.str{color:#060}.kwd{color:#006;font-weight:bold}.com{color:#600;font-style:italic}.typ{color:#404;font-weight:bold}.lit{color:#044}.pun,.opn,.clo{color:#440}.tag{color:#006;font-weight:bold}.atn{color:#404}.atv{color:#060}}pre.prettyprint{padding:2px;border:1px solid #888}ol.linenums{margin-top:0;margin-bottom:0}li.L0,li.L1,li.L2,li.L3,li.L5,li.L6,li.L7,li.L8{list-style-type:none}li.L1,li.L3,li.L5,li.L7,li.L9{background:#eee} +/* +* Skeleton V1.2 +* Copyright 2011, Dave Gamache +* www.getskeleton.com +* Free to use under the MIT license. +* http://www.opensource.org/licenses/mit-license.php +* 6/20/2012 +*/ + + +/* Table of Contents +================================================== + #Base 960 Grid + #Tablet (Portrait) + #Mobile (Portrait) + #Mobile (Landscape) + #Clearing */ + + + +/* #Base 960 Grid +================================================== */ + + .container { position: relative; width: 960px; margin: 0 auto; padding: 0; } + .container .column, + .container .columns { float: left; display: inline; margin-left: 10px; margin-right: 10px; } + .row { margin-bottom: 20px; } + + /* Nested Column Classes */ + .column.alpha, .columns.alpha { margin-left: 0; } + .column.omega, .columns.omega { margin-right: 0; } + + /* Base Grid */ + .container .one.column, + .container .one.columns { width: 40px; } + .container .two.columns { width: 100px; } + .container .three.columns { width: 160px; } + .container .four.columns { width: 220px; } + .container .five.columns { width: 280px; } + .container .six.columns { width: 340px; } + .container .seven.columns { width: 400px; } + .container .eight.columns { width: 460px; } + .container .nine.columns { width: 520px; } + .container .ten.columns { width: 580px; } + .container .eleven.columns { width: 640px; } + .container .twelve.columns { width: 700px; } + .container .thirteen.columns { width: 760px; } + .container .fourteen.columns { width: 820px; } + .container .fifteen.columns { width: 880px; } + .container .sixteen.columns { width: 940px; } + + .container .one-third.column { width: 300px; } + .container .two-thirds.column { width: 620px; } + + /* Offsets */ + .container .offset-by-one { padding-left: 60px; } + .container .offset-by-two { padding-left: 120px; } + .container .offset-by-three { padding-left: 180px; } + .container .offset-by-four { padding-left: 240px; } + .container .offset-by-five { padding-left: 300px; } + .container .offset-by-six { padding-left: 360px; } + .container .offset-by-seven { padding-left: 420px; } + .container .offset-by-eight { padding-left: 480px; } + .container .offset-by-nine { padding-left: 540px; } + .container .offset-by-ten { padding-left: 600px; } + .container .offset-by-eleven { padding-left: 660px; } + .container .offset-by-twelve { padding-left: 720px; } + .container .offset-by-thirteen { padding-left: 780px; } + .container .offset-by-fourteen { padding-left: 840px; } + .container .offset-by-fifteen { padding-left: 900px; } + + + +/* #Tablet (Portrait) +================================================== */ + + /* Note: Design for a width of 768px */ + + @media only screen and (min-width: 768px) and (max-width: 959px) { + .container { width: 768px; } + .container .column, + .container .columns { margin-left: 10px; margin-right: 10px; } + .column.alpha, .columns.alpha { margin-left: 0; margin-right: 10px; } + .column.omega, .columns.omega { margin-right: 0; margin-left: 10px; } + .alpha.omega { margin-left: 0; margin-right: 0; } + + .container .one.column, + .container .one.columns { width: 28px; } + .container .two.columns { width: 76px; } + .container .three.columns { width: 124px; } + .container .four.columns { width: 172px; } + .container .five.columns { width: 220px; } + .container .six.columns { width: 268px; } + .container .seven.columns { width: 316px; } + .container .eight.columns { width: 364px; } + .container .nine.columns { width: 412px; } + .container .ten.columns { width: 460px; } + .container .eleven.columns { width: 508px; } + .container .twelve.columns { width: 556px; } + .container .thirteen.columns { width: 604px; } + .container .fourteen.columns { width: 652px; } + .container .fifteen.columns { width: 700px; } + .container .sixteen.columns { width: 748px; } + + .container .one-third.column { width: 236px; } + .container .two-thirds.column { width: 492px; } + + /* Offsets */ + .container .offset-by-one { padding-left: 48px; } + .container .offset-by-two { padding-left: 96px; } + .container .offset-by-three { padding-left: 144px; } + .container .offset-by-four { padding-left: 192px; } + .container .offset-by-five { padding-left: 240px; } + .container .offset-by-six { padding-left: 288px; } + .container .offset-by-seven { padding-left: 336px; } + .container .offset-by-eight { padding-left: 384px; } + .container .offset-by-nine { padding-left: 432px; } + .container .offset-by-ten { padding-left: 480px; } + .container .offset-by-eleven { padding-left: 528px; } + .container .offset-by-twelve { padding-left: 576px; } + .container .offset-by-thirteen { padding-left: 624px; } + .container .offset-by-fourteen { padding-left: 672px; } + .container .offset-by-fifteen { padding-left: 720px; } + } + + +/* #Mobile (Portrait) +================================================== */ + + /* Note: Design for a width of 320px */ + + @media only screen and (max-width: 767px) { + .container { width: 300px; } + .container .columns, + .container .column { margin: 0; } + + .container .one.column, + .container .one.columns, + .container .two.columns, + .container .three.columns, + .container .four.columns, + .container .five.columns, + .container .six.columns, + .container .seven.columns, + .container .eight.columns, + .container .nine.columns, + .container .ten.columns, + .container .eleven.columns, + .container .twelve.columns, + .container .thirteen.columns, + .container .fourteen.columns, + .container .fifteen.columns, + .container .sixteen.columns, + .container .one-third.column, + .container .two-thirds.column { width: 300px; } + + /* Offsets */ + .container .offset-by-one, + .container .offset-by-two, + .container .offset-by-three, + .container .offset-by-four, + .container .offset-by-five, + .container .offset-by-six, + .container .offset-by-seven, + .container .offset-by-eight, + .container .offset-by-nine, + .container .offset-by-ten, + .container .offset-by-eleven, + .container .offset-by-twelve, + .container .offset-by-thirteen, + .container .offset-by-fourteen, + .container .offset-by-fifteen { padding-left: 0; } + + } + + +/* #Mobile (Landscape) +================================================== */ + + /* Note: Design for a width of 480px */ + + @media only screen and (min-width: 480px) and (max-width: 767px) { + .container { width: 420px; } + .container .columns, + .container .column { margin: 0; } + + .container .one.column, + .container .one.columns, + .container .two.columns, + .container .three.columns, + .container .four.columns, + .container .five.columns, + .container .six.columns, + .container .seven.columns, + .container .eight.columns, + .container .nine.columns, + .container .ten.columns, + .container .eleven.columns, + .container .twelve.columns, + .container .thirteen.columns, + .container .fourteen.columns, + .container .fifteen.columns, + .container .sixteen.columns, + .container .one-third.column, + .container .two-thirds.column { width: 420px; } + } + + +/* #Clearing +================================================== */ + + /* Self Clearing Goodness */ + .container:after { content: "\0020"; display: block; height: 0; clear: both; visibility: hidden; } + + /* Use clearfix class on parent to clear nested columns, + or wrap each row of columns in a
+
+ Notify.js is a jQuery plugin to provide simple yet fully customisable notifications.
+ The javascript code snippets in this documentation with the green edge are runnable by clicking them.
+
+
$.notify("Hello World");
+
+ Download pre-packaged with the Bootstrap notification style:
+
+
Or, create a custom build with your own style
+
+
+
Notify.js Core + +
+Styles
+
Minify + +
++ Made with Compile.js +
+You can place notifications on any element:
++
$(".elem-demo").notify("Hello Box");
+
+ Like this box
++ + If you don't specify an element, notification + will appear in the top left (unless you specify a + different position - See Positioning) +
++
$.notify("I'm over here !");
+
+ + Each style may define a set of classes to use to substyle the notification. + The pre-packaged version includes a bootstrap notification style (see more below in Styling). + These classes include: + +
+$.notify("Access granted", "success");Info
+ $.notify("Do not press this button", "info");Warning
+ $.notify("Warning: Self-destruct in 3.. 2..", "warn");Error
+ $.notify("BOOM!", "error");
+ Note: This page has set the default class to"success" with$.notify.defaults({ className: "success" });.
+ Element notifications and Global notifications can
+ be vertically repositioned to: "top", "middle" or "bottom" and horozontally repositioned to: "left", "center" or "right" .
+
+
$(".pos-demo").notify(
+ "I'm left of the box",
+ { position:"left" }
+);
+
+ We can position the notification around this box
+Use this positioning tool to see all possible position combinations
+An awesome cool larrrggggeeee box
+$.notify( string|object, [ options ])string|object - global notification dataoptions - an options object or class name string
$.notify( element, string|object, [ options ])element - a jquery elementstring|object - element notification dataoptions - an options object or class name string
$( selector ).notify( string|object, [ options ])selector - jquery selectorstring|object - element notification dataoptions - an options object or class name string
$.notify.addStyle( styleName, styleDefinition )styleName - string (the style option references this name)
styleDefinition - style definition object (see Styling below)
$.notify.defaults( options )options - an options object (updates the defaults listed below)
+ + The options object listed above are in the form below. + This object below is the actual used to check option + validity and set defaults. +
+{
+ // whether to hide the notification on click
+ clickToHide: true,
+ // whether to auto-hide the notification
+ autoHide: true,
+ // if autoHide, hide after milliseconds
+ autoHideDelay: 5000,
+ // show the arrow pointing at the element
+ arrowShow: true,
+ // arrow size in pixels
+ arrowSize: 5,
+ // default positions
+ elementPosition: 'bottom left',
+ globalPosition: 'top right',
+ // default style
+ style: 'bootstrap',
+ // default class (string or [string])
+ className: 'error',
+ // show animation
+ showAnimation: 'slideDown',
+ // show animation duration
+ showDuration: 400,
+ // hide animation
+ hideAnimation: 'slideUp',
+ // hide animation duration
+ hideDuration: 200,
+ // padding between element and notification
+ gap: 2
+}
+
+ You can add your own styles to Notify.js with the$.notify.addStyle method. See API.
Style definition objects are in the form:
+{
+ //required html representing each notification
+ html: "",
+ //optional object to be converted to css
+ classes: {
+ <className>: {
+ <propertyName>: <value>
+ },
+ <className>: {
+ ...
+ },
+ ...
+ },
+ //optional css to be inserted onto the page
+ css: ""
+}
+
+ +
data-notify-text or data-notify-html. Use data-notify-html if you wish to display arbitrary HTML inside the notification,
+ otherwise, use data-notify-text as it is more secure.+
+
+ When each notification is constructed, it's container + (outer most element defined in your style html) will automatically + apply the class: +
+notifyjs-<style name>-base
+
+ When you use the class name option (className) the class:
+
notifyjs-<style name>-<class name>
+ will be applied. So if you define your styles in an external CSS file or in the style's css + property, you must define your CSS rules using this naming convention. + +
+If you were to define the style:
+$.notify.addStyle('happyblue', {
+ html: "<div>☺<span data-notify-text/>☺</div>",
+ classes: {
+ base: {
+ "white-space": "nowrap",
+ "background-color": "lightblue",
+ "padding": "5px"
+ },
+ superblue: {
+ "color": "white",
+ "background-color": "blue"
+ }
+ }
+});
+
+ Upon running this code, the classes object in this example will be converted the following css:
.notifyjs-happyblue-base {
+ white-space: nowrap;
+ background-color: lightblue;
+ padding: 5px;
+}
+.notifyjs-happyblue-superblue {
+ color: white;
+ background-color: blue;
+}
+ You can now use your new style with:
+$.notify('hello !!', {
+ style: 'happyblue'
+});
+
+
+
+ and you can use the superblue class with:
+
$.notify('HELLO !!!!', {
+ style: 'happyblue',
+ className: 'superblue'
+});
+
+ Say you wanted to use buttons in your notifications then you could do something like:
+//add a new style 'foo'
+$.notify.addStyle('foo', {
+ html:
+ "<div>" +
+ "<div class='clearfix'>" +
+ "<div class='title' data-notify-html='title'/>" +
+ "<div class='buttons'>" +
+ "<button class='no'>Cancel</button>" +
+ "<button class='yes' data-notify-text='button'></button>" +
+ "</div>" +
+ "</div>" +
+ "</div>"
+});
+
+//listen for click events from this style
+$(document).on('click', '.notifyjs-foo-base .no', function() {
+ //programmatically trigger propogating hide event
+ $(this).trigger('notify-hide');
+});
+$(document).on('click', '.notifyjs-foo-base .yes', function() {
+ //show button text
+ alert($(this).text() + " clicked!");
+ //hide notification
+ $(this).trigger('notify-hide');
+});
+
+
+
+ Notice there is no classes property defined above. Since the CSS in this example is non-trivial, we'll use an exteral CSS file instead:
+
Note: you could also convert this CSS code to a JavaScript string and use it with the css property. It's not very readable though it's better for distribution.
.notifyjs-foo-base {
+ opacity: 0.85;
+ width: 200px;
+ background: #F5F5F5;
+ padding: 5px;
+ border-radius: 10px;
+}
+
+.notifyjs-foo-base .title {
+ width: 100px;
+ float: left;
+ margin: 10px 0 0 10px;
+ text-align: right;
+}
+
+.notifyjs-foo-base .buttons {
+ width: 70px;
+ float: right;
+ font-size: 9px;
+ padding: 5px;
+ margin: 2px;
+}
+
+.notifyjs-foo-base button {
+ font-size: 9px;
+ padding: 5px;
+ margin: 2px;
+ width: 60px;
+}
+
+ You can now use this style with:
+$.notify({
+ title: 'Would you like some Foo ?',
+ button: 'Confirm'
+}, {
+ style: 'foo',
+ autoHide: false,
+ clickToHide: false
+});
+
+
+ If using the above methods still don't provide you
+ with what you need then you can, pass jQuery objects
+ straight into the notification (provided that the
+ element has the data-notify-html attribute):
+
+
var h5 = $("<h5/>").append("You MUST have some Foo !")
+
+$.notify({
+ title: h5,
+ button: 'YES !'
+}, {
+ style: 'foo',
+ autoHide: false,
+ clickToHide: false
+});
+
+ + + Contributing more styles is easy! +
To get people started with some styles ideas, checkout this post on various Growl styles.
++ Note: If you wish to contribute to the library by fixing bugs or adding features, + see the src folder. Also, the source is in CoffeeScript, however, new styles can be either JavaScript or CoffeeScript. + I'm using Grunt to compile, minify and concat the builds, you can do so with: +
cd notifyjsnpm install -g grunt-clinpm installgrunt
+ * k.o.call(this);
+ *
+ */
+ k.o = function () {
+ var s = this;
+
+ this.o = null; // array of options
+ this.$ = null; // jQuery wrapped element
+ this.i = null; // mixed HTMLInputElement or array of HTMLInputElement
+ this.g = null; // 2D graphics context for 'pre-rendering'
+ this.v = null; // value ; mixed array or integer
+ this.cv = null; // change value ; not commited value
+ this.x = 0; // canvas x position
+ this.y = 0; // canvas y position
+ this.$c = null; // jQuery canvas element
+ this.c = null; // rendered canvas context
+ this.t = 0; // touches index
+ this.isInit = false;
+ this.fgColor = null; // main color
+ this.pColor = null; // previous color
+ this.dH = null; // draw hook
+ this.cH = null; // change hook
+ this.eH = null; // cancel hook
+ this.rH = null; // release hook
+
+ this.run = function () {
+ var cf = function (e, conf) {
+ var k;
+ for (k in conf) {
+ s.o[k] = conf[k];
+ }
+ s.init();
+ s._configure()
+ ._draw();
+ };
+
+ if(this.$.data('kontroled')) return;
+ this.$.data('kontroled', true);
+
+ this.extend();
+ this.o = $.extend(
+ {
+ // Config
+ min : this.$.data('min') || 0,
+ max : this.$.data('max') || 100,
+ stopper : true,
+ readOnly : this.$.data('readonly'),
+
+ // UI
+ cursor : (this.$.data('cursor') === true && 30)
+ || this.$.data('cursor')
+ || 0,
+ thickness : this.$.data('thickness') || 0.35,
+ lineCap : this.$.data('linecap') || 'butt',
+ width : this.$.data('width') || 200,
+ height : this.$.data('height') || 200,
+ displayInput : this.$.data('displayinput') == null || this.$.data('displayinput'),
+ displayPrevious : this.$.data('displayprevious'),
+ fgColor : this.$.data('fgcolor') || '#87CEEB',
+ inputColor: this.$.data('inputcolor') || this.$.data('fgcolor') || '#87CEEB',
+ inline : false,
+ step : this.$.data('step') || 1,
+
+ // Hooks
+ draw : null, // function () {}
+ change : null, // function (value) {}
+ cancel : null, // function () {}
+ release : null // function (value) {}
+ }, this.o
+ );
+
+ // routing value
+ if(this.$.is('fieldset')) {
+
+ // fieldset = array of integer
+ this.v = {};
+ this.i = this.$.find('input')
+ this.i.each(function(k) {
+ var $this = $(this);
+ s.i[k] = $this;
+ s.v[k] = $this.val();
+
+ $this.bind(
+ 'change'
+ , function () {
+ var val = {};
+ val[k] = $this.val();
+ s.val(val);
+ }
+ );
+ });
+ this.$.find('legend').remove();
+
+ } else {
+ // input = integer
+ this.i = this.$;
+ this.v = this.$.val();
+ (this.v == '') && (this.v = this.o.min);
+
+ this.$.bind(
+ 'change'
+ , function () {
+ s.val(s._validate(s.$.val()));
+ }
+ );
+ }
+
+ (!this.o.displayInput) && this.$.hide();
+
+ this.$c = $('');
+ this.c = this.$c[0].getContext("2d");
+
+ this.$
+ .wrap($(''))
+ .before(this.$c);
+
+ if (this.v instanceof Object) {
+ this.cv = {};
+ this.copy(this.v, this.cv);
+ } else {
+ this.cv = this.v;
+ }
+
+ this.$
+ .bind("configure", cf)
+ .parent()
+ .bind("configure", cf);
+
+ this._listen()
+ ._configure()
+ ._xy()
+ .init();
+
+ this.isInit = true;
+
+ this._draw();
+
+ return this;
+ };
+
+ this._draw = function () {
+
+ // canvas pre-rendering
+ var d = true,
+ c = document.createElement('canvas');
+
+ c.width = s.o.width;
+ c.height = s.o.height;
+ s.g = c.getContext('2d');
+
+ s.clear();
+
+ s.dH
+ && (d = s.dH());
+
+ (d !== false) && s.draw();
+
+ s.c.drawImage(c, 0, 0);
+ c = null;
+ };
+
+ this._touch = function (e) {
+
+ var touchMove = function (e) {
+
+ var v = s.xy2val(
+ e.originalEvent.touches[s.t].pageX,
+ e.originalEvent.touches[s.t].pageY
+ );
+
+ if (v == s.cv) return;
+
+ if (
+ s.cH
+ && (s.cH(v) === false)
+ ) return;
+
+
+ s.change(s._validate(v));
+ s._draw();
+ };
+
+ // get touches index
+ this.t = k.c.t(e);
+
+ // First touch
+ touchMove(e);
+
+ // Touch events listeners
+ k.c.d
+ .bind("touchmove.k", touchMove)
+ .bind(
+ "touchend.k"
+ , function () {
+ k.c.d.unbind('touchmove.k touchend.k');
+
+ if (
+ s.rH
+ && (s.rH(s.cv) === false)
+ ) return;
+
+ s.val(s.cv);
+ }
+ );
+
+ return this;
+ };
+
+ this._mouse = function (e) {
+
+ var mouseMove = function (e) {
+ var v = s.xy2val(e.pageX, e.pageY);
+ if (v == s.cv) return;
+
+ if (
+ s.cH
+ && (s.cH(v) === false)
+ ) return;
+
+ s.change(s._validate(v));
+ s._draw();
+ };
+
+ // First click
+ mouseMove(e);
+
+ // Mouse events listeners
+ k.c.d
+ .bind("mousemove.k", mouseMove)
+ .bind(
+ // Escape key cancel current change
+ "keyup.k"
+ , function (e) {
+ if (e.keyCode === 27) {
+ k.c.d.unbind("mouseup.k mousemove.k keyup.k");
+
+ if (
+ s.eH
+ && (s.eH() === false)
+ ) return;
+
+ s.cancel();
+ }
+ }
+ )
+ .bind(
+ "mouseup.k"
+ , function (e) {
+ k.c.d.unbind('mousemove.k mouseup.k keyup.k');
+
+ if (
+ s.rH
+ && (s.rH(s.cv) === false)
+ ) return;
+
+ s.val(s.cv);
+ }
+ );
+
+ return this;
+ };
+
+ this._xy = function () {
+ var o = this.$c.offset();
+ this.x = o.left;
+ this.y = o.top;
+ return this;
+ };
+
+ this._listen = function () {
+
+ if (!this.o.readOnly) {
+ this.$c
+ .bind(
+ "mousedown"
+ , function (e) {
+ e.preventDefault();
+ s._xy()._mouse(e);
+ }
+ )
+ .bind(
+ "touchstart"
+ , function (e) {
+ e.preventDefault();
+ s._xy()._touch(e);
+ }
+ );
+ this.listen();
+ } else {
+ this.$.attr('readonly', 'readonly');
+ }
+
+ return this;
+ };
+
+ this._configure = function () {
+
+ // Hooks
+ if (this.o.draw) this.dH = this.o.draw;
+ if (this.o.change) this.cH = this.o.change;
+ if (this.o.cancel) this.eH = this.o.cancel;
+ if (this.o.release) this.rH = this.o.release;
+
+ if (this.o.displayPrevious) {
+ this.pColor = this.h2rgba(this.o.fgColor, "0.4");
+ this.fgColor = this.h2rgba(this.o.fgColor, "0.6");
+ } else {
+ this.fgColor = this.o.fgColor;
+ }
+
+ return this;
+ };
+
+ this._clear = function () {
+ this.$c[0].width = this.$c[0].width;
+ };
+
+ this._validate = function(v) {
+ return (~~ (((v < 0) ? -0.5 : 0.5) + (v/this.o.step))) * this.o.step;
+ };
+
+ // Abstract methods
+ this.listen = function () {}; // on start, one time
+ this.extend = function () {}; // each time configure triggered
+ this.init = function () {}; // each time configure triggered
+ this.change = function (v) {}; // on change
+ this.val = function (v) {}; // on release
+ this.xy2val = function (x, y) {}; //
+ this.draw = function () {}; // on change / on release
+ this.clear = function () { this._clear(); };
+
+ // Utils
+ this.h2rgba = function (h, a) {
+ var rgb;
+ h = h.substring(1,7)
+ rgb = [parseInt(h.substring(0,2),16)
+ ,parseInt(h.substring(2,4),16)
+ ,parseInt(h.substring(4,6),16)];
+ return "rgba(" + rgb[0] + "," + rgb[1] + "," + rgb[2] + "," + a + ")";
+ };
+
+ this.copy = function (f, t) {
+ for (var i in f) { t[i] = f[i]; }
+ };
+ };
+
+
+ /**
+ * k.Dial
+ */
+ k.Dial = function () {
+ k.o.call(this);
+
+ this.startAngle = null;
+ this.xy = null;
+ this.radius = null;
+ this.lineWidth = null;
+ this.cursorExt = null;
+ this.w2 = null;
+ this.PI2 = 2*Math.PI;
+
+ this.extend = function () {
+ this.o = $.extend(
+ {
+ bgColor : this.$.data('bgcolor') || '#EEEEEE',
+ angleOffset : this.$.data('angleoffset') || 0,
+ angleArc : this.$.data('anglearc') || 360,
+ inline : true
+ }, this.o
+ );
+ };
+
+ this.val = function (v) {
+ if (null != v) {
+ this.cv = this.o.stopper ? max(min(v, this.o.max), this.o.min) : v;
+ this.v = this.cv;
+ this.$.val(this.v);
+ this._draw();
+ } else {
+ return this.v;
+ }
+ };
+
+ this.xy2val = function (x, y) {
+ var a, ret;
+
+ a = Math.atan2(
+ x - (this.x + this.w2)
+ , - (y - this.y - this.w2)
+ ) - this.angleOffset;
+
+ if(this.angleArc != this.PI2 && (a < 0) && (a > -0.5)) {
+ // if isset angleArc option, set to min if .5 under min
+ a = 0;
+ } else if (a < 0) {
+ a += this.PI2;
+ }
+
+ ret = ~~ (0.5 + (a * (this.o.max - this.o.min) / this.angleArc))
+ + this.o.min;
+
+ this.o.stopper
+ && (ret = max(min(ret, this.o.max), this.o.min));
+
+ return ret;
+ };
+
+ this.listen = function () {
+ // bind MouseWheel
+ var s = this,
+ mw = function (e) {
+ e.preventDefault();
+ var ori = e.originalEvent
+ ,deltaX = ori.detail || ori.wheelDeltaX
+ ,deltaY = ori.detail || ori.wheelDeltaY
+ ,v = parseInt(s.$.val()) + (deltaX>0 || deltaY>0 ? s.o.step : deltaX<0 || deltaY<0 ? -s.o.step : 0);
+
+ if (
+ s.cH
+ && (s.cH(v) === false)
+ ) return;
+
+ s.val(v);
+ }
+ , kval, to, m = 1, kv = {37:-s.o.step, 38:s.o.step, 39:s.o.step, 40:-s.o.step};
+
+ this.$
+ .bind(
+ "keydown"
+ ,function (e) {
+ var kc = e.keyCode;
+
+ // numpad support
+ if(kc >= 96 && kc <= 105) {
+ kc = e.keyCode = kc - 48;
+ }
+
+ kval = parseInt(String.fromCharCode(kc));
+
+ if (isNaN(kval)) {
+
+ (kc !== 13) // enter
+ && (kc !== 8) // bs
+ && (kc !== 9) // tab
+ && (kc !== 189) // -
+ && e.preventDefault();
+
+ // arrows
+ if ($.inArray(kc,[37,38,39,40]) > -1) {
+ e.preventDefault();
+
+ var v = parseInt(s.$.val()) + kv[kc] * m;
+
+ s.o.stopper
+ && (v = max(min(v, s.o.max), s.o.min));
+
+ s.change(v);
+ s._draw();
+
+ // long time keydown speed-up
+ to = window.setTimeout(
+ function () { m*=2; }
+ ,30
+ );
+ }
+ }
+ }
+ )
+ .bind(
+ "keyup"
+ ,function (e) {
+ if (isNaN(kval)) {
+ if (to) {
+ window.clearTimeout(to);
+ to = null;
+ m = 1;
+ s.val(s.$.val());
+ }
+ } else {
+ // kval postcond
+ (s.$.val() > s.o.max && s.$.val(s.o.max))
+ || (s.$.val() < s.o.min && s.$.val(s.o.min));
+ }
+
+ }
+ );
+
+ this.$c.bind("mousewheel DOMMouseScroll", mw);
+ this.$.bind("mousewheel DOMMouseScroll", mw)
+ };
+
+ this.init = function () {
+
+ if (
+ this.v < this.o.min
+ || this.v > this.o.max
+ ) this.v = this.o.min;
+
+ this.$.val(this.v);
+ this.w2 = this.o.width / 2;
+ this.cursorExt = this.o.cursor / 100;
+ this.xy = this.w2;
+ this.lineWidth = this.xy * this.o.thickness;
+ this.lineCap = this.o.lineCap;
+ this.radius = this.xy - this.lineWidth / 2;
+
+ this.o.angleOffset
+ && (this.o.angleOffset = isNaN(this.o.angleOffset) ? 0 : this.o.angleOffset);
+
+ this.o.angleArc
+ && (this.o.angleArc = isNaN(this.o.angleArc) ? this.PI2 : this.o.angleArc);
+
+ // deg to rad
+ this.angleOffset = this.o.angleOffset * Math.PI / 180;
+ this.angleArc = this.o.angleArc * Math.PI / 180;
+
+ // compute start and end angles
+ this.startAngle = 1.5 * Math.PI + this.angleOffset;
+ this.endAngle = 1.5 * Math.PI + this.angleOffset + this.angleArc;
+
+ var s = max(
+ String(Math.abs(this.o.max)).length
+ , String(Math.abs(this.o.min)).length
+ , 2
+ ) + 2;
+
+ this.o.displayInput
+ && this.i.css({
+ 'width' : ((this.o.width / 2 + 4) >> 0) + 'px'
+ ,'height' : ((this.o.width / 3) >> 0) + 'px'
+ ,'position' : 'absolute'
+ ,'vertical-align' : 'middle'
+ ,'margin-top' : ((this.o.width / 3) >> 0) + 'px'
+ ,'margin-left' : '-' + ((this.o.width * 3 / 4 + 2) >> 0) + 'px'
+ ,'border' : 0
+ ,'background' : 'none'
+ ,'font' : 'bold ' + ((this.o.width / s) >> 0) + 'px Arial'
+ ,'text-align' : 'center'
+ ,'color' : this.o.inputColor || this.o.fgColor
+ ,'padding' : '0px'
+ ,'-webkit-appearance': 'none'
+ })
+ || this.i.css({
+ 'width' : '0px'
+ ,'visibility' : 'hidden'
+ });
+ };
+
+ this.change = function (v) {
+ this.cv = v;
+ this.$.val(v);
+ };
+
+ this.angle = function (v) {
+ return (v - this.o.min) * this.angleArc / (this.o.max - this.o.min);
+ };
+
+ this.draw = function () {
+
+ var c = this.g, // context
+ a = this.angle(this.cv) // Angle
+ , sat = this.startAngle // Start angle
+ , eat = sat + a // End angle
+ , sa, ea // Previous angles
+ , r = 1;
+
+ c.lineWidth = this.lineWidth;
+
+ c.lineCap = this.lineCap;
+
+ this.o.cursor
+ && (sat = eat - this.cursorExt)
+ && (eat = eat + this.cursorExt);
+
+ c.beginPath();
+ c.strokeStyle = this.o.bgColor;
+ c.arc(this.xy, this.xy, this.radius, this.endAngle, this.startAngle, true);
+ c.stroke();
+
+ if (this.o.displayPrevious) {
+ ea = this.startAngle + this.angle(this.v);
+ sa = this.startAngle;
+ this.o.cursor
+ && (sa = ea - this.cursorExt)
+ && (ea = ea + this.cursorExt);
+
+ c.beginPath();
+ c.strokeStyle = this.pColor;
+ c.arc(this.xy, this.xy, this.radius, sa, ea, false);
+ c.stroke();
+ r = (this.cv == this.v);
+ }
+
+ c.beginPath();
+ c.strokeStyle = r ? this.o.fgColor : this.fgColor ;
+ c.arc(this.xy, this.xy, this.radius, sat, eat, false);
+ c.stroke();
+ };
+
+ this.cancel = function () {
+ this.val(this.v);
+ };
+ };
+
+ $.fn.dial = $.fn.knob = function (o) {
+ return this.each(
+ function () {
+ var d = new k.Dial();
+ d.o = o;
+ d.$ = $(this);
+ d.run();
+ }
+ ).parent();
+ };
+
+})(jQuery);
+!function(){var q=null;window.PR_SHOULD_USE_CONTINUATION=!0;
+(function(){function S(a){function d(e){var b=e.charCodeAt(0);if(b!==92)return b;var a=e.charAt(1);return(b=r[a])?b:"0"<=a&&a<="7"?parseInt(e.substring(1),8):a==="u"||a==="x"?parseInt(e.substring(2),16):e.charCodeAt(1)}function g(e){if(e<32)return(e<16?"\\x0":"\\x")+e.toString(16);e=String.fromCharCode(e);return e==="\\"||e==="-"||e==="]"||e==="^"?"\\"+e:e}function b(e){var b=e.substring(1,e.length-1).match(/\\u[\dA-Fa-f]{4}|\\x[\dA-Fa-f]{2}|\\[0-3][0-7]{0,2}|\\[0-7]{1,2}|\\[\S\s]|[^\\]/g),e=[],a=
+b[0]==="^",c=["["];a&&c.push("^");for(var a=a?1:0,f=b.length;a
+
+ Notify.js is a jQuery plugin to provide simple yet fully customisable notifications.
+ The javascript code snippets in this documentation with the green edge are runnable by clicking them.
+
+
$.notify("Hello World");
+
+ Download pre-packaged with the bootstrap notification style:
+
+
Or, create a custom build with a different style
+
+
+
Notify.js Core + +
+Styles
+
Minify + +
++ Made with Compile.js +
+You can place notifications on any element:
++
$(".elem-demo").notify("Hello Box");
+
+ Like this box
++ + If you don't specify an element, notification + will appear in the top left (unless you specify a + different position - See Positioning) +
++
$.notify("I'm over here !");
+
+ + Each style may define a set of classes to use to substyle the notification. + The pre-packaged version includes a bootstrap notification style (see more below in Styling). + These classes include: + +
+$.notify("Access granted", "success");Info
+ $.notify("Do not press this button", "info");Warning
+ $.notify("Warning: Self-destruct in 3.. 2..", "warn");Error
+ $.notify("BOOM!", "error");
+ Note: This page has set the default class to"success" with$.notify.defaults({ className: "success" });.
+ Element notifications and Global notifications can
+ be vertically repositioned to: "top", "middle" or "bottom" and horozontally repositioned to: "left", "center" or "right" .
+
+
$(".pos-demo").notify(
+ "I'm left of the box",
+ { position:"left" }
+);
+
+ We can position the notification around this box
+Use this positioning tool to see all possible position combinations
+An awesome cool larrrggggeeee box
+$.notify( string|object, [ options ])string|object - global notification dataoptions - an options object or class name string
$.notify( element, string|object, [ options ])element - a jquery elementstring|object - element notification dataoptions - an options object or class name string
$( selector ).notify( string|object, [ options ])selector - jquery selectorstring|object - element notification dataoptions - an options object or class name string
$.notify.addStyle( styleName, styleDefinition )styleName - string (the style option references this name)
styleDefinition - style definition object (see Styling below)
$.notify.defaults( options )options - an options object (updates the defaults listed below)
+ + The options object listed above are in the form below. + This object below is the actual used to check option + validity and set defaults. +
+{
+ // whether to hide the notification on click
+ clickToHide: true,
+ // whether to auto-hide the notification
+ autoHide: true,
+ // if autoHide, hide after milliseconds
+ autoHideDelay: 5000,
+ // show the arrow pointing at the element
+ arrowShow: true,
+ // arrow size in pixels
+ arrowSize: 5,
+ // default positions
+ elementPosition: 'bottom left',
+ globalPosition: 'top right',
+ // default style
+ style: 'bootstrap',
+ // default class (string or [string])
+ className: 'error',
+ // show animation
+ showAnimation: 'slideDown',
+ // show animation duration
+ showDuration: 400,
+ // hide animation
+ hideAnimation: 'slideUp',
+ // hide animation duration
+ hideDuration: 200,
+ // padding between element and notification
+ gap: 2
+}
+
+ You can add your own styles to Notify.js with the$.notify.addStyle method. See API.
Style definition objects are in the form:
+{
+ //required html representing each notification
+ html: "",
+ //optional object to be converted to css
+ classes: {
+ <className>: {
+ <propertyName>: <value>
+ },
+ <className>: {
+ ...
+ },
+ ...
+ },
+ //optional css to be inserted onto the page
+ css: ""
+}
+
+ +
data-notify-text or data-notify-html. Use data-notify-html if you wish to display arbitrary HTML inside the notification,
+ otherwise, use data-notify-text as it is more secure.+
+
+ When each notification is constructed, it's container + (outer most element defined in your style html) will automatically + apply the class: +
+notifyjs-<style name>-base
+
+ When you use the class name option (className) the class:
+
notifyjs-<style name>-<class name>
+ will be applied. So if you define your styles in an external CSS file or in the style's css + property, you must define your CSS rules using this naming convention. + +
+If you were to define the style:
+$.notify.addStyle('happyblue', {
+ html: "<div>☺<span data-notify-text/>☺</div>",
+ classes: {
+ base: {
+ "white-space": "nowrap",
+ "background-color": "lightblue",
+ "padding": "5px"
+ },
+ superblue: {
+ "color": "white",
+ "background-color": "blue"
+ }
+ }
+});
+
+ Upon running this code, the classes object in this example will be converted the following css:
.notifyjs-happyblue-base {
+ white-space: nowrap;
+ background-color: lightblue;
+ padding: 5px;
+}
+.notifyjs-happyblue-superblue {
+ color: white;
+ background-color: blue;
+}
+ You can now use your new style with:
+$.notify('hello !!', {
+ style: 'happyblue'
+});
+
+
+
+ and you can use the superblue class with:
+
$.notify('HELLO !!!!', {
+ style: 'happyblue',
+ className: 'superblue'
+});
+
+ Say you wanted to use buttons in your notifications then you could do something like:
+//add a new style 'foo'
+$.notify.addStyle('foo', {
+ html:
+ "<div>" +
+ "<div class='clearfix'>" +
+ "<div class='title' data-notify-html='title'/>" +
+ "<div class='buttons'>" +
+ "<button class='no'>Cancel</button>" +
+ "<button class='yes' data-notify-text='button'></button>" +
+ "</div>" +
+ "</div>" +
+ "</div>"
+});
+
+//listen for click events from this style
+$(document).on('click', '.notifyjs-foo-base .no', function() {
+ //programmatically trigger propogating hide event
+ $(this).trigger('notify-hide');
+});
+$(document).on('click', '.notifyjs-foo-base .yes', function() {
+ //show button text
+ alert($(this).text() + " clicked!");
+ //hide notification
+ $(this).trigger('notify-hide');
+});
+
+
+
+ Notice there is no classes property defined above. Since the CSS in this example is non-trivial, we'll use an exteral CSS file instead:
+
Note: you could also convert this CSS code to a JavaScript string and use it with the css property. It's not very readable though it's better for distribution.
.notifyjs-foo-base {
+ opacity: 0.85;
+ width: 200px;
+ background: #F5F5F5;
+ padding: 5px;
+ border-radius: 10px;
+}
+
+.notifyjs-foo-base .title {
+ width: 100px;
+ float: left;
+ margin: 10px 0 0 10px;
+ text-align: right;
+}
+
+.notifyjs-foo-base .buttons {
+ width: 70px;
+ float: right;
+ font-size: 9px;
+ padding: 5px;
+ margin: 2px;
+}
+
+.notifyjs-foo-base button {
+ font-size: 9px;
+ padding: 5px;
+ margin: 2px;
+ width: 60px;
+}
+
+ You can now use this style with:
+$.notify({
+ title: 'Would you like some Foo ?',
+ button: 'Confirm'
+}, {
+ style: 'foo',
+ autoHide: false,
+ clickToHide: false
+});
+
+
+ If using the above methods still don't provide you
+ with what you need then you can, pass jQuery objects
+ straight into the notification (provided that the
+ element has the data-notify-html attribute):
+
+
var h5 = $("<h5/>").append("You MUST have some Foo !")
+
+$.notify({
+ title: h5,
+ button: 'YES !'
+}, {
+ style: 'foo',
+ autoHide: false,
+ clickToHide: false
+});
+
+ + + Contributing more styles is easy! +
To get people started with some styles ideas, checkout this post on various Growl styles.
++ Note: If you wish to contribute to the library by fixing bugs or adding features, + see the src folder. Also, the source is in CoffeeScript, however, new styles can be either JavaScript or CoffeeScript. + I'm using Grunt to compile, minify and concat the builds, you can do so with: +
cd notifyjsnpm install -g grunt-clinpm installgrunt