| 1 |
<!doctype html> |
| 2 |
<html lang="en"> |
| 3 |
<head> |
| 4 |
<meta charset="utf-8"> |
| 5 |
<meta http-equiv="X-UA-Compatible" content="IE=edge"> |
| 6 |
<meta name="description" content="Alertify.js is a lightweight brower alert and dialog plugin."> |
| 7 |
<meta name="viewport" content="width=device-width, initial-scale=1"> |
| 8 |
<title>alertify.js</title> |
| 9 |
<link rel="stylesheet" href="/css/styles.min.css"> |
| 10 |
<script> |
| 11 |
var env = document.domain === "alertifyjs.org" ? "production" : "local"; |
| 12 |
if (env === "production") { |
| 13 |
var _rollbarConfig = { |
| 14 |
accessToken: "cffbf4470b49484b9e94498203125ab4", |
| 15 |
captureUncaught: true, |
| 16 |
payload: { environment: env } |
| 17 |
}; |
| 18 |
!function(r){function t(o){if(e[o])return e[o].exports;var n=e[o]={exports:{},id:o,loaded:!1};return r[o].call(n.exports,n,n.exports,t),n.loaded=!0,n.exports}var e={};return t.m=r,t.c=e,t.p="",t(0)}([function(r,t,e){"use strict";var o=e(1).Rollbar,n=e(2),a="https://d37gvrvc0wt4s1.cloudfront.net/js/v1.6/rollbar.min.js";_rollbarConfig.rollbarJsUrl=_rollbarConfig.rollbarJsUrl||a;var i=o.init(window,_rollbarConfig),l=n(i,_rollbarConfig);i.loadFull(window,document,!1,_rollbarConfig,l)},function(r,t){"use strict";function e(){var r=window.console;r&&"function"==typeof r.log&&r.log.apply(r,arguments)}function o(r,t){return t=t||e,function(){try{return r.apply(this,arguments)}catch(e){t("Rollbar internal error:",e)}}}function n(r,t,e){window._rollbarWrappedError&&(e[4]||(e[4]=window._rollbarWrappedError),e[5]||(e[5]=window._rollbarWrappedError._rollbarContext),window._rollbarWrappedError=null),r.uncaughtError.apply(r,e),t&&t.apply(window,e)}function a(r){this.shimId=++u,this.notifier=null,this.parentShim=r,this.logger=e,this._rollbarOldOnError=null}function i(r){var t=a;return o(function(){if(this.notifier)return this.notifier[r].apply(this.notifier,arguments);var e=this,o="scope"===r;o&&(e=new t(this));var n=Array.prototype.slice.call(arguments,0),a={shim:e,method:r,args:n,ts:new Date};return window._rollbarShimQueue.push(a),o?e:void 0})}function l(r,t){if(t.hasOwnProperty&&t.hasOwnProperty("addEventListener")){var e=t.addEventListener;t.addEventListener=function(t,o,n){e.call(this,t,r.wrap(o),n)};var o=t.removeEventListener;t.removeEventListener=function(r,t,e){o.call(this,r,t&&t._wrapped?t._wrapped:t,e)}}}var u=0;a.init=function(r,t){var e=t.globalAlias||"Rollbar";if("object"==typeof r[e])return r[e];r._rollbarShimQueue=[],r._rollbarWrappedError=null,t=t||{};var i=new a;return o(function(){if(i.configure(t),t.captureUncaught){i._rollbarOldOnError=r.onerror,r.onerror=function(){var r=Array.prototype.slice.call(arguments,0);n(i,i._rollbarOldOnError,r)};var o,a,u="EventTarget,Window,Node,ApplicationCache,AudioTrackList,ChannelMergerNode,CryptoOperation,EventSource,FileReader,HTMLUnknownElement,IDBDatabase,IDBRequest,IDBTransaction,KeyOperation,MediaController,MessagePort,ModalWindow,Notification,SVGElementInstance,Screen,TextTrack,TextTrackCue,TextTrackList,WebSocket,WebSocketWorker,Worker,XMLHttpRequest,XMLHttpRequestEventTarget,XMLHttpRequestUpload".split(",");for(o=0;o<u.length;++o)a=u[o],r[a]&&r[a].prototype&&l(i,r[a].prototype)}return r[e]=i,i},i.logger)()},a.prototype.loadFull=function(r,t,e,n,a){var i=function(){var t;if(void 0===r._rollbarPayloadQueue){var e,o,n,i;for(t=new Error("rollbar.js did not load");e=r._rollbarShimQueue.shift();)for(n=e.args,i=0;i<n.length;++i)if(o=n[i],"function"==typeof o){o(t);break}}"function"==typeof a&&a(t)},l=!1,u=t.createElement("script"),s=t.getElementsByTagName("script")[0],p=s.parentNode;u.src=n.rollbarJsUrl,u.async=!e,u.onload=u.onreadystatechange=o(function(){if(!(l||this.readyState&&"loaded"!==this.readyState&&"complete"!==this.readyState)){u.onload=u.onreadystatechange=null;try{p.removeChild(u)}catch(r){}l=!0,i()}},this.logger),p.insertBefore(u,s)},a.prototype.wrap=function(r,t){try{var e;if(e="function"==typeof t?t:function(){return t||{}},"function"!=typeof r)return r;if(r._isWrap)return r;if(!r._wrapped){r._wrapped=function(){try{return r.apply(this,arguments)}catch(t){throw t._rollbarContext=e()||{},t._rollbarContext._wrappedSource=r.toString(),window._rollbarWrappedError=t,t}},r._wrapped._isWrap=!0;for(var o in r)r.hasOwnProperty(o)&&(r._wrapped[o]=r[o])}return r._wrapped}catch(n){return r}};for(var s="log,debug,info,warn,warning,error,critical,global,configure,scope,uncaughtError".split(","),p=0;p<s.length;++p)a.prototype[s[p]]=i(s[p]);r.exports={Rollbar:a,_rollbarWindowOnError:n}},function(r,t){"use strict";r.exports=function(r,t){return function(e){if(!e&&!window._rollbarInitialized){var o=window.RollbarNotifier,n=t||{},a=n.globalAlias||"Rollbar",i=window.Rollbar.init(n,r);i._processShimQueue(window._rollbarShimQueue||[]),window[a]=i,window._rollbarInitialized=!0,o.processPayloads()}}}}]); |
| 19 |
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){ |
| 20 |
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o), |
| 21 |
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m) |
| 22 |
})(window,document,'script','//www.google-analytics.com/analytics.js','ga'); |
| 23 |
ga('create', 'UA-64348743-1', 'auto'); |
| 24 |
ga('send', 'pageview'); |
| 25 |
} |
| 26 |
</script> |
| 27 |
</head> |
| 28 |
<body> |
| 29 |
<div class="layout-transparent mdl-layout mdl-js-layout"> |
| 30 |
<header class="mdl-layout__header mdl-layout__header--transparent"> |
| 31 |
<div class="mdl-layout__header-row"> |
| 32 |
<!-- Title --> |
| 33 |
<span class="mdl-layout-title ">alertify.js</span> |
| 34 |
<!-- Add spacer, to align navigation to the right --> |
| 35 |
<div class="mdl-layout-spacer"></div> |
| 36 |
<!-- Navigation --> |
| 37 |
<nav class="mdl-navigation"> |
| 38 |
<a class="mdl-navigation__link" href="#getting-started">Getting Started</a> |
| 39 |
<a class="mdl-navigation__link" href="#performance">Performance</a> |
| 40 |
<a class="mdl-navigation__link" href="#usage">Usage</a> |
| 41 |
<a class="mdl-navigation__link" href="https://github.com/alertifyjs/alertify.js">View on GitHub</a> |
| 42 |
</nav> |
| 43 |
</div> |
| 44 |
</header> |
| 45 |
<div class="mdl-layout__drawer"> |
| 46 |
<span class="mdl-layout-title">alertify.js</span> |
| 47 |
<nav class="mdl-navigation"> |
| 48 |
<a class="mdl-navigation__link" href="#getting-started">Getting Started</a> |
| 49 |
<a class="mdl-navigation__link" href="#performance">Performance</a> |
| 50 |
<a class="mdl-navigation__link" href="#usage">Usage</a> |
| 51 |
<a class="mdl-navigation__link" href="https://github.com/alertifyjs/alertify.js">View on GitHub</a> |
| 52 |
</nav> |
| 53 |
</div> |
| 54 |
<main class="mdl-layout__content"> |
| 55 |
<div class="container text-center"> |
| 56 |
<h1 class="mdl-typography--display-4">alertify.js</h1> |
| 57 |
<h3 class="mdl-typography--display-2">Simple browser dialogs <small>v1.0.12</small></h3> |
| 58 |
<a href="https://github.com/alertifyjs/alertify.js/archive/master.zip" |
| 59 |
class="mdl-button mdl-button--large mdl-button--accent mdl-js-button mdl-button--raised mdl-js-ripple-effect"> |
| 60 |
<i class="material-icons md-24">file_download</i> |
| 61 |
Download Now |
| 62 |
</a> |
| 63 |
</div> |
| 64 |
<div style="background: #eee; padding: 1em 0; color: #555;"> |
| 65 |
<div class="container"> |
| 66 |
<p class="mdl-typography--subhead"> |
| 67 |
Alertify.js is a small library which provides light-weight, high |
| 68 |
performance browser dialogs. Since it uses only 1 HTTP request |
| 69 |
and a payload of less than 3kB, it's a great option for |
| 70 |
adding basic style to alert, dialog, prompt and log messages |
| 71 |
even on low bandwidth connections. |
| 72 |
</p> |
| 73 |
</div> |
| 74 |
</div> |
| 75 |
<div class="page-content"> |
| 76 |
<div class="container"> |
| 77 |
|
| 78 |
<h2 class="mdl-typeography--display-3" id="getting-started">Getting Started</h2> |
| 79 |
|
| 80 |
<div class="mdl-grid"> |
| 81 |
<div class="mdl-cell mdl-cell--8-col mdl-cell--5-col-desktop left-col"> |
| 82 |
<h4 class="mdl-typeograph--headline">Notes</h4> |
| 83 |
<p> |
| 84 |
We're working to get the latest version on all major public CDN's |
| 85 |
but until then, you'll need to either use a GitHub raw service, |
| 86 |
download it, or install via NPM or Bower. |
| 87 |
</p> |
| 88 |
<p> |
| 89 |
Obviously, if you're installing via Bower or NPM, you'll need |
| 90 |
to include the files in the "dist" directory in your |
| 91 |
HTML for everything to work. But you knew that already. |
| 92 |
</p> |
| 93 |
<p> |
| 94 |
It's also worth noting that the CSS is bundled by default, |
| 95 |
so there's no need to include any stylesheets to use the |
| 96 |
default theme. It's dyamically inserted before any other |
| 97 |
<link> elements (like) stylesheets so it's super |
| 98 |
easy to override with your own styles. |
| 99 |
</p> |
| 100 |
</div> |
| 101 |
<div class="mdl-cell mdl-cell--8-col mdl-cell--7-col-desktop right-col"> |
| 102 |
<h4 class="mdl-typeograph--headline">Via RawGit</h4> |
| 103 |
<pre> |
| 104 |
<-- standard version --> |
| 105 |
<script src="https://cdn.rawgit.com/alertifyjs/alertify.js/v1.0.12/dist/js/alertify.js"></script> |
| 106 |
|
| 107 |
<-- angular module --> |
| 108 |
<script src="https://cdn.rawgit.com/alertifyjs/alertify.js/v1.0.12/dist/js/ngAlertify.js"></script> |
| 109 |
</pre> |
| 110 |
<h4 class="mdl-typeograph--headline">Via Bower</h4> |
| 111 |
<pre>bower install --save alertifyjs</pre> |
| 112 |
<h4 class="mdl-typeograph--headline">Via NPM</h4> |
| 113 |
<pre>npm install --save alertify.js</pre> |
| 114 |
|
| 115 |
<h4 class="mdl-typeograph--headline">Disabling CSS Injection</h4> |
| 116 |
<p> |
| 117 |
If you don't want to inject CSS for some reason, just |
| 118 |
insert your own styles (any style or link element with |
| 119 |
an id of alertifyCSS) before the javascript file: |
| 120 |
</p> |
| 121 |
<pre> |
| 122 |
<link rel="stylesheet" |
| 123 |
href="/path/to/custom/styles.css" |
| 124 |
id="alertifyCSS"> |
| 125 |
<script src="/path/to/alertify.js"></script></pre> |
| 126 |
</div> |
| 127 |
</div> |
| 128 |
<div class="mdl-grid"> |
| 129 |
<div class="mdl-cell mdl-cell--8-col mdl-cell--5-col-desktop left-col"> |
| 130 |
<h4 class="mdl-typeograph--headline">AngularJS</h4> |
| 131 |
<p> |
| 132 |
An AngularJS module is also included. It's in the |
| 133 |
"ngAlertify.js" file, so use that instead if you're building |
| 134 |
an AngularJS app. |
| 135 |
</p> |
| 136 |
<p> |
| 137 |
If you want to check out a live demo of log messages with |
| 138 |
ngAlertify, <a href="/angular.html">click here</a>. |
| 139 |
</p> |
| 140 |
</div> |
| 141 |
<div class="mdl-cell mdl-cell--8-col mdl-cell--7-col-desktop right-col"> |
| 142 |
<h4 class="mdl-typeograph--headline">Initialize ngAlertify</h4> |
| 143 |
<pre> |
| 144 |
// Make sure to include the ngAlertify.js file. |
| 145 |
angular |
| 146 |
.module("myApp", ["ngAlertify"]) |
| 147 |
.controller("myController", function($scope, alertify) { |
| 148 |
alertify.success("Welcome to alertify!"); |
| 149 |
}); |
| 150 |
</pre> |
| 151 |
</div> |
| 152 |
</div> |
| 153 |
</div> |
| 154 |
<div class="styles__ribbon styles__ribbon--teal"> |
| 155 |
<div class="container"> |
| 156 |
<h2 class="mdl-typeography--display-3" id="performance">Performance</h2> |
| 157 |
<p> |
| 158 |
Alertify is designed from the ground-up for great performance |
| 159 |
and a small footprint. That means it's not as feature-rich as |
| 160 |
some other options. That's on purpose. We don't plan on adding |
| 161 |
a lot more features so it stays a great option for every |
| 162 |
kind of website and user. |
| 163 |
</p> |
| 164 |
<p> |
| 165 |
Currently, the entire library, with JavaScript and CSS |
| 166 |
is ~2.29 kB (gzipped), and getting smaller all the time. |
| 167 |
That's quite impressive considering it's only a single HTTP |
| 168 |
request, and no external dependencies at all being required. |
| 169 |
</p> |
| 170 |
<p>The Angular module is only 2.32kB, so that's light, too!</p> |
| 171 |
</div> |
| 172 |
</div> |
| 173 |
|
| 174 |
<div class="container"> |
| 175 |
<h2 class="mdl-typeography--display-3" id="usage">Usage</h2> |
| 176 |
<h3 class="mdl-typeography--display-2">Dialogs</h3> |
| 177 |
<div class="mdl-grid"> |
| 178 |
<div class="mdl-cell mdl-cell--8-col mdl-cell--5-col-desktop left-col"> |
| 179 |
<h5 class="mdl-typeography--headline">Alert Dialog</h5> |
| 180 |
<p> |
| 181 |
Dialogs display a text and require |
| 182 |
user to acknowledge the message. |
| 183 |
</p> |
| 184 |
<a class="mdl-button mdl-js-button mdl-button--raised mdl-js-ripple-effect" id="alert">Try It</a><br> |
| 185 |
</div> |
| 186 |
<div class="mdl-cell mdl-cell--8-col mdl-cell--7-col-desktop right-col"> |
| 187 |
<h5 class="mdl-typeography--headline">Code Example</h5> |
| 188 |
<pre>alertify.alert("Message");</pre> |
| 189 |
</div> |
| 190 |
</div> |
| 191 |
<div class="mdl-grid"> |
| 192 |
<div class="mdl-cell mdl-cell--8-col mdl-cell--5-col-desktop left-col"> |
| 193 |
<h5 class="mdl-typeography--headline">Confirm Dialog</h5> |
| 194 |
<p></p> |
| 195 |
<a class="mdl-button mdl-js-button mdl-button--raised mdl-js-ripple-effect" id="confirm">Try It</a><br> |
| 196 |
</div> |
| 197 |
<div class="mdl-cell mdl-cell--8-col mdl-cell--7-col-desktop right-col"> |
| 198 |
<h5 class="mdl-typeography--headline">Code Example</h5> |
| 199 |
<pre> |
| 200 |
// confirm dialog |
| 201 |
alertify.confirm("Message", function () { |
| 202 |
// user clicked "ok" |
| 203 |
}, function() { |
| 204 |
// user clicked "cancel" |
| 205 |
}); |
| 206 |
</pre> |
| 207 |
</div> |
| 208 |
</div> |
| 209 |
<div class="mdl-grid"> |
| 210 |
<div class="mdl-cell mdl-cell--8-col mdl-cell--5-col-desktop left-col"> |
| 211 |
<h5 class="mdl-typeography--headline">Prompt Dialog</h5> |
| 212 |
<p></p> |
| 213 |
<a class="mdl-button mdl-js-button mdl-button--raised mdl-js-ripple-effect" id="prompt">Try It</a> |
| 214 |
</div> |
| 215 |
<div class="mdl-cell mdl-cell--8-col mdl-cell--7-col-desktop right-col"> |
| 216 |
<h5 class="mdl-typeography--headline">Code Example</h5> |
| 217 |
<pre> |
| 218 |
alertify |
| 219 |
.defaultValue("Default Value") |
| 220 |
.prompt("This is a prompt dialog", |
| 221 |
function (val, ev) { |
| 222 |
|
| 223 |
// The click event is in the event variable, so you can use it here. |
| 224 |
ev.preventDefault(); |
| 225 |
|
| 226 |
// The value entered is availble in the val variable. |
| 227 |
alertify.success("You've clicked OK and typed: " + val); |
| 228 |
|
| 229 |
}, function(ev) { |
| 230 |
|
| 231 |
// The click event is in the event variable, so you can use it here. |
| 232 |
ev.preventDefault(); |
| 233 |
|
| 234 |
alertify.error("You've clicked Cancel"); |
| 235 |
|
| 236 |
} |
| 237 |
}); |
| 238 |
</pre> |
| 239 |
</div> |
| 240 |
</div> |
| 241 |
<div class="mdl-grid"> |
| 242 |
<div class="mdl-cell mdl-cell--8-col mdl-cell--5-col-desktop left-col"> |
| 243 |
<h5 class="mdl-typeography--headline">Custom Labels</h5> |
| 244 |
<p> |
| 245 |
You're not limited to the "Ok" and "Cancel" button labels. |
| 246 |
You can easily set your own labels. |
| 247 |
</p> |
| 248 |
<a class="mdl-button mdl-js-button mdl-button--raised mdl-js-ripple-effect" id="labels">Try It</a> |
| 249 |
</div> |
| 250 |
<div class="mdl-cell mdl-cell--8-col mdl-cell--7-col-desktop right-col"> |
| 251 |
<h5 class="mdl-typeography--headline">Code Example</h5> |
| 252 |
<pre> |
| 253 |
alertify |
| 254 |
.okBtn("Accept") |
| 255 |
.cancelBtn("Deny") |
| 256 |
.confirm("Confirm dialog with custom button labels", function (ev) { |
| 257 |
|
| 258 |
// The click event is in the |
| 259 |
// event variable, so you can use |
| 260 |
// it here. |
| 261 |
ev.preventDefault(); |
| 262 |
alertify.success("You've clicked OK"); |
| 263 |
|
| 264 |
}, function(ev) { |
| 265 |
|
| 266 |
// The click event is in the |
| 267 |
// event variable, so you can use |
| 268 |
// it here. |
| 269 |
ev.preventDefault(); |
| 270 |
|
| 271 |
alertify.error("You've clicked Cancel"); |
| 272 |
|
| 273 |
}); |
| 274 |
</pre> |
| 275 |
</div> |
| 276 |
</div> |
| 277 |
|
| 278 |
<div class="mdl-grid"> |
| 279 |
<div class="mdl-cell mdl-cell--8-col mdl-cell--5-col-desktop left-col"> |
| 280 |
<h5 class="mdl-typeography--headline">Ajax - Multiple Dialog</h5> |
| 281 |
<p></p> |
| 282 |
<a class="mdl-button mdl-js-button mdl-button--raised mdl-js-ripple-effect" id="ajax">Try It</a> |
| 283 |
</div> |
| 284 |
<div class="mdl-cell mdl-cell--8-col mdl-cell--7-col-desktop right-col"> |
| 285 |
<h5 class="mdl-typeography--headline">Code Example</h5> |
| 286 |
<pre> |
| 287 |
alertify.confirm("Confirm?", function (ev) { |
| 288 |
|
| 289 |
// The click event is in the |
| 290 |
// event variable, so you can use |
| 291 |
// it here. |
| 292 |
ev.preventDefault(); |
| 293 |
|
| 294 |
alertify.alert("Successful AJAX after OK"); |
| 295 |
|
| 296 |
|
| 297 |
}, function(ev) { |
| 298 |
|
| 299 |
// The click event is in the |
| 300 |
// event variable, so you can use |
| 301 |
// it here. |
| 302 |
ev.preventDefault(); |
| 303 |
|
| 304 |
alertify.alert("Successful AJAX after Cancel"); |
| 305 |
|
| 306 |
}); |
| 307 |
</pre> |
| 308 |
</div> |
| 309 |
</div> |
| 310 |
|
| 311 |
<div class="mdl-grid"> |
| 312 |
<div class="mdl-cell mdl-cell--8-col mdl-cell--5-col-desktop left-col"> |
| 313 |
<h5 class="mdl-typeography--headline">Promise Aware</h5> |
| 314 |
<p>If your browser supports promises, you can use them instead of callbacks</p> |
| 315 |
<a class="mdl-button mdl-js-button mdl-button--raised mdl-js-ripple-effect" id="promise">Try It</a> |
| 316 |
</div> |
| 317 |
<div class="mdl-cell mdl-cell--8-col mdl-cell--7-col-desktop right-col"> |
| 318 |
<h5 class="mdl-typeography--headline">Code Example</h5> |
| 319 |
<pre> |
| 320 |
if ("function" !== typeof Promise) { |
| 321 |
alertify.alert("Your browser doesn't support promises"); |
| 322 |
return; |
| 323 |
} |
| 324 |
|
| 325 |
alertify.confirm("Confirm?").then(function (resolvedValue) { |
| 326 |
// "resolvedValue" is an object with the following keys: |
| 327 |
// buttonClicked |
| 328 |
// inputValue (only for prompts) |
| 329 |
// event |
| 330 |
|
| 331 |
// The click event is in |
| 332 |
// resolvedValue, so you can use |
| 333 |
// it here. |
| 334 |
resolvedValue.event.preventDefault(); |
| 335 |
alertify.alert("You clicked the " + resolvedValue.buttonClicked + " button!"); |
| 336 |
}); |
| 337 |
</pre> |
| 338 |
</div> |
| 339 |
</div> |
| 340 |
|
| 341 |
<hr> |
| 342 |
|
| 343 |
<h3 class="mdl-typeography--display-2" id="log-messages">Log Messages</h3> |
| 344 |
|
| 345 |
<div class="mdl-grid"> |
| 346 |
<div class="mdl-cell mdl-cell--8-col mdl-cell--5-col-desktop left-col"> |
| 347 |
<h5 class="mdl-typeography--headline">Setting the Position</h5> |
| 348 |
<p></p> |
| 349 |
<a class="mdl-button mdl-js-button mdl-button--raised mdl-js-ripple-effect" id="log-position">Try It</a> |
| 350 |
</div> |
| 351 |
<div class="mdl-cell mdl-cell--8-col mdl-cell--7-col-desktop right-col"> |
| 352 |
<h5 class="mdl-typeography--headline">Code Example</h5> |
| 353 |
<pre> |
| 354 |
alertify.delay(1000); // This is just to make the demo go faster. |
| 355 |
alertify.log("Default botoom left position"); |
| 356 |
setTimeout(function() { |
| 357 |
alertify.logPosition("top left"); |
| 358 |
alertify.log("top left"); |
| 359 |
}, 1500); |
| 360 |
setTimeout(function() { |
| 361 |
alertify.logPosition("top right"); |
| 362 |
alertify.log("top right"); |
| 363 |
}, 3000); |
| 364 |
setTimeout(function() { |
| 365 |
alertify.logPosition("bottom right"); |
| 366 |
alertify.log("bottom right"); |
| 367 |
}, 4500); |
| 368 |
setTimeout(function() { |
| 369 |
alertify.reset(); // Puts the message back to default position. |
| 370 |
alertify.log("Back to default"); |
| 371 |
}, 6000); |
| 372 |
</pre> |
| 373 |
</div> |
| 374 |
</div> |
| 375 |
|
| 376 |
|
| 377 |
<div class="mdl-grid"> |
| 378 |
<div class="mdl-cell mdl-cell--8-col mdl-cell--5-col-desktop left-col"> |
| 379 |
<h5 class="mdl-typeography--headline">Setting the parent element</h5> |
| 380 |
<p>You can set where parent element where Alertify is appended into the DOM. |
| 381 |
|
| 382 |
</p> |
| 383 |
</div> |
| 384 |
<div class="mdl-cell mdl-cell--8-col mdl-cell--7-col-desktop right-col"> |
| 385 |
<h5 class="mdl-typeography--headline">Code Example</h5> |
| 386 |
<pre> |
| 387 |
// By default, Alertify is appended to document.body. |
| 388 |
// You can easily change that, though, like this: |
| 389 |
var elem = document.getElementById("my-element"); |
| 390 |
alertify.parent(elem); |
| 391 |
</pre> |
| 392 |
</div> |
| 393 |
</div> |
| 394 |
|
| 395 |
<div class="mdl-grid"> |
| 396 |
<div class="mdl-cell mdl-cell--8-col mdl-cell--5-col-desktop left-col"> |
| 397 |
<h5 class="mdl-typeography--headline">Standard Log</h5> |
| 398 |
<p></p> |
| 399 |
<a class="mdl-button mdl-js-button mdl-button--raised mdl-js-ripple-effect" id="notification">Try It</a> |
| 400 |
</div> |
| 401 |
<div class="mdl-cell mdl-cell--8-col mdl-cell--7-col-desktop right-col"> |
| 402 |
<h5 class="mdl-typeography--headline">Code Example</h5> |
| 403 |
<pre> |
| 404 |
alertify.log("Standard log message"); |
| 405 |
</pre> |
| 406 |
</div> |
| 407 |
</div> |
| 408 |
|
| 409 |
<div class="mdl-grid"> |
| 410 |
<div class="mdl-cell mdl-cell--8-col mdl-cell--5-col-desktop left-col"> |
| 411 |
<h5 class="mdl-typeography--headline">Standard Log With HTML</h5> |
| 412 |
<p>HTML works just fine in log messages. Have at it!</p> |
| 413 |
<a class="mdl-button mdl-js-button mdl-button--raised mdl-js-ripple-effect" id="notification-html">Try It</a> |
| 414 |
</div> |
| 415 |
<div class="mdl-cell mdl-cell--8-col mdl-cell--7-col-desktop right-col"> |
| 416 |
<h5 class="mdl-typeography--headline">Code Example</h5> |
| 417 |
<pre> |
| 418 |
var msg = "<img src='https://placehold.it/256x128'>" + |
| 419 |
"<h3>This is HTML</h3>" + |
| 420 |
"<p>It's great, right?</p>"; |
| 421 |
alertify.log(msg); |
| 422 |
</pre> |
| 423 |
</div> |
| 424 |
</div> |
| 425 |
|
| 426 |
<div class="mdl-grid"> |
| 427 |
<div class="mdl-cell mdl-cell--8-col mdl-cell--5-col-desktop left-col"> |
| 428 |
<h5 class="mdl-typeography--headline">Standard Log with callback</h5> |
| 429 |
<p> |
| 430 |
Keep in mind that the when setting a callback, clicking the log message |
| 431 |
doesn't automatically close the log message, which is different than |
| 432 |
previous functionality. This means that the callback could be called |
| 433 |
multiple times if the user clicks multiple times. If you're callback is |
| 434 |
an action that must be completed only once, you'll need to keep track |
| 435 |
of that separately. |
| 436 |
</p> |
| 437 |
<a class="mdl-button mdl-js-button mdl-button--raised mdl-js-ripple-effect" id="notification-callback">Try It</a> |
| 438 |
</div> |
| 439 |
<div class="mdl-cell mdl-cell--8-col mdl-cell--7-col-desktop right-col"> |
| 440 |
<h5 class="mdl-typeography--headline">Code Example</h5> |
| 441 |
<pre> |
| 442 |
alertify.log("Standard log message with callback", function(ev) { |
| 443 |
|
| 444 |
// The click event is in the |
| 445 |
// event variable, so you can use |
| 446 |
// it here. |
| 447 |
ev.preventDefault(); |
| 448 |
|
| 449 |
alertify.log("You clicked the notification"); |
| 450 |
|
| 451 |
}); |
| 452 |
</pre> |
| 453 |
</div> |
| 454 |
</div> |
| 455 |
|
| 456 |
<div class="mdl-grid"> |
| 457 |
<div class="mdl-cell mdl-cell--8-col mdl-cell--5-col-desktop left-col"> |
| 458 |
<h5 class="mdl-typeography--headline">Success Log</h5> |
| 459 |
<p></p> |
| 460 |
<a class="mdl-button mdl-js-button mdl-button--raised mdl-js-ripple-effect" id="success">Try It</a> |
| 461 |
</div> |
| 462 |
<div class="mdl-cell mdl-cell--8-col mdl-cell--7-col-desktop right-col"> |
| 463 |
<h5 class="mdl-typeography--headline">Code Example</h5> |
| 464 |
<pre> |
| 465 |
alertify.success("Success log message"); |
| 466 |
</pre> |
| 467 |
</div> |
| 468 |
</div> |
| 469 |
|
| 470 |
<div class="mdl-grid"> |
| 471 |
<div class="mdl-cell mdl-cell--8-col mdl-cell--5-col-desktop left-col"> |
| 472 |
<h5 class="mdl-typeography--headline">Success Log with callback</h5> |
| 473 |
<p></p> |
| 474 |
<a class="mdl-button mdl-js-button mdl-button--raised mdl-js-ripple-effect" id="success-callback">Try It</a> |
| 475 |
</div> |
| 476 |
<div class="mdl-cell mdl-cell--8-col mdl-cell--7-col-desktop right-col"> |
| 477 |
<h5 class="mdl-typeography--headline">Code Example</h5> |
| 478 |
<pre> |
| 479 |
alertify.success("Standard log message with callback", function(ev) { |
| 480 |
|
| 481 |
// The click event is in the |
| 482 |
// event variable, so you can use |
| 483 |
// it here. |
| 484 |
ev.preventDefault(); |
| 485 |
|
| 486 |
alertify.success("You clicked the notification"); |
| 487 |
|
| 488 |
}); |
| 489 |
</pre> |
| 490 |
</div> |
| 491 |
</div> |
| 492 |
<div class="mdl-grid"> |
| 493 |
<div class="mdl-cell mdl-cell--8-col mdl-cell--5-col-desktop left-col"> |
| 494 |
<h5 class="mdl-typeography--headline">Error Log</h5> |
| 495 |
<p></p> |
| 496 |
<a class="mdl-button mdl-js-button mdl-button--raised mdl-js-ripple-effect" id="error">Try It</a> |
| 497 |
</div> |
| 498 |
<div class="mdl-cell mdl-cell--8-col mdl-cell--7-col-desktop right-col"> |
| 499 |
<h5 class="mdl-typeography--headline">Code Example</h5> |
| 500 |
<pre>alertify.error("Error log message");</pre> |
| 501 |
</div> |
| 502 |
</div> |
| 503 |
<div class="mdl-grid"> |
| 504 |
<div class="mdl-cell mdl-cell--8-col mdl-cell--5-col-desktop left-col"> |
| 505 |
<h5 class="mdl-typeography--headline">Error Log with callback</h5> |
| 506 |
<p></p> |
| 507 |
<a class="mdl-button mdl-js-button mdl-button--raised mdl-js-ripple-effect" id="error-callback">Try It</a> |
| 508 |
</div> |
| 509 |
<div class="mdl-cell mdl-cell--8-col mdl-cell--7-col-desktop right-col"> |
| 510 |
<h5 class="mdl-typeography--headline">Code Example</h5> |
| 511 |
<pre> |
| 512 |
alertify.error("Standard log message with callback", function(ev) { |
| 513 |
|
| 514 |
// The click event is in the |
| 515 |
// event variable, so you can use |
| 516 |
// it here. ev.preventDefault(); |
| 517 |
alertify.error("You clicked the notification"); |
| 518 |
|
| 519 |
}); |
| 520 |
</pre> |
| 521 |
</div> |
| 522 |
</div> |
| 523 |
|
| 524 |
<div class="mdl-grid"> |
| 525 |
<div class="mdl-cell mdl-cell--8-col mdl-cell--5-col-desktop left-col"> |
| 526 |
<h5 class="mdl-typeography--headline">Closing Log On Click</h5> |
| 527 |
<p></p> |
| 528 |
<a class="mdl-button mdl-js-button mdl-button--raised mdl-js-ripple-effect" id="click-to-close">Try It</a> |
| 529 |
</div> |
| 530 |
<div class="mdl-cell mdl-cell--8-col mdl-cell--7-col-desktop right-col"> |
| 531 |
<h5 class="mdl-typeography--headline">Code Example</h5> |
| 532 |
<pre> |
| 533 |
alertify |
| 534 |
.closeLogOnClick(true) |
| 535 |
.log("Click me to close!"); |
| 536 |
</pre> |
| 537 |
</div> |
| 538 |
</div> |
| 539 |
|
| 540 |
<div class="mdl-grid"> |
| 541 |
<div class="mdl-cell mdl-cell--8-col mdl-cell--5-col-desktop left-col"> |
| 542 |
<h5 class="mdl-typeography--headline">Disable Log On Click</h5> |
| 543 |
<p> |
| 544 |
Clicking on a log message to close is disabled by default, |
| 545 |
but if you've enabled it and need to reset it to disabled, |
| 546 |
you can do so very easily. |
| 547 |
</p> |
| 548 |
<p> |
| 549 |
The decision to disable it by default was to allow any type |
| 550 |
of html to be included in the log messages, including links. |
| 551 |
</p> |
| 552 |
<a class="mdl-button mdl-js-button mdl-button--raised mdl-js-ripple-effect" id="disable-click-to-close">Try It</a> |
| 553 |
</div> |
| 554 |
<div class="mdl-cell mdl-cell--8-col mdl-cell--7-col-desktop right-col"> |
| 555 |
<h5 class="mdl-typeography--headline">Code Example</h5> |
| 556 |
<pre> |
| 557 |
alertify |
| 558 |
.closeLogOnClick(true) |
| 559 |
.log("Click me to close!") |
| 560 |
.closeLogOnClick(false) |
| 561 |
.log("You can't click to close this!"); |
| 562 |
</pre> |
| 563 |
</div> |
| 564 |
</div> |
| 565 |
|
| 566 |
<div class="mdl-grid"> |
| 567 |
<div class="mdl-cell mdl-cell--8-col mdl-cell--5-col-desktop left-col"> |
| 568 |
<h5 class="mdl-typeography--headline">Hide in 10 seconds</h5> |
| 569 |
<p></p> |
| 570 |
<a class="mdl-button mdl-js-button mdl-button--raised mdl-js-ripple-effect" id="delay">Try It</a> |
| 571 |
</div> |
| 572 |
<div class="mdl-cell mdl-cell--8-col mdl-cell--7-col-desktop right-col"> |
| 573 |
<h5 class="mdl-typeography--headline">Code Example</h5> |
| 574 |
<pre> |
| 575 |
alertify.delay(10000).log("Hiding in 10 seconds"); |
| 576 |
</pre> |
| 577 |
</div> |
| 578 |
</div> |
| 579 |
|
| 580 |
<div class="mdl-grid"> |
| 581 |
<div class="mdl-cell mdl-cell--8-col mdl-cell--5-col-desktop left-col"> |
| 582 |
<h5 class="mdl-typeography--headline">Persistent Log</h5> |
| 583 |
<p> |
| 584 |
Persistent log messages will stay until clicked |
| 585 |
(if closeLogOnClick(true) is set) or until forcibly removed |
| 586 |
when the number of messages exceeds the maxLogItems setting. |
| 587 |
</p> |
| 588 |
<a class="mdl-button mdl-js-button mdl-button--raised mdl-js-ripple-effect" id="forever">Try It</a> |
| 589 |
</div> |
| 590 |
<div class="mdl-cell mdl-cell--8-col mdl-cell--7-col-desktop right-col"> |
| 591 |
<h5 class="mdl-typeography--headline">Code Example</h5> |
| 592 |
<pre> |
| 593 |
alertify.delay(0).log("Will stay until clicked"); |
| 594 |
</pre> |
| 595 |
</div> |
| 596 |
</div> |
| 597 |
<div class="mdl-grid"> |
| 598 |
<div class="mdl-cell mdl-cell--8-col mdl-cell--5-col-desktop left-col"> |
| 599 |
<h5 class="mdl-typeography--headline">Maximum Number of Log Messages</h5> |
| 600 |
<p> |
| 601 |
You can easily set the maximum number of log/success/error |
| 602 |
messages that will be displayed at a single time. The default |
| 603 |
is two. |
| 604 |
</p> |
| 605 |
<a class="mdl-button mdl-js-button mdl-button--raised mdl-js-ripple-effect" id="max-log-items">Try It</a> |
| 606 |
</div> |
| 607 |
<div class="mdl-cell mdl-cell--8-col mdl-cell--7-col-desktop right-col"> |
| 608 |
<h5 class="mdl-typeography--headline">Code Example</h5> |
| 609 |
<pre> |
| 610 |
alertify |
| 611 |
.maxLogItems(1) |
| 612 |
.log("This is the first message"); |
| 613 |
|
| 614 |
// The timeout is just for visual effect. |
| 615 |
setTimeout(function() { |
| 616 |
alertify.log("The second message will force the first to close."); |
| 617 |
}, 1000); |
| 618 |
</pre> |
| 619 |
</div> |
| 620 |
</div> |
| 621 |
<div class="mdl-grid"> |
| 622 |
<div class="mdl-cell mdl-cell--8-col mdl-cell--5-col-desktop left-col"> |
| 623 |
<h5 class="mdl-typeography--headline">Setting a template for logs</h5> |
| 624 |
<p> |
| 625 |
You can change the template for all logs. |
| 626 |
</p> |
| 627 |
<a class="mdl-button mdl-js-button mdl-button--raised mdl-js-ripple-effect" id="log-template">Try It</a> |
| 628 |
</div> |
| 629 |
<div class="mdl-cell mdl-cell--8-col mdl-cell--7-col-desktop right-col"> |
| 630 |
<h5 class="mdl-typeography--headline">Code Example</h5> |
| 631 |
<pre> |
| 632 |
alertify |
| 633 |
.setLogTemplate(function (input) { return 'log message: ' + input; }) |
| 634 |
.log("This is the message"); |
| 635 |
</pre> |
| 636 |
</div> |
| 637 |
</div> |
| 638 |
<hr> |
| 639 |
<h3 class="mdl-typeography--display-2">Other Options</h3> |
| 640 |
<div class="mdl-grid"> |
| 641 |
<div class="mdl-cell mdl-cell--8-col mdl-cell--5-col-desktop left-col"> |
| 642 |
<h5 class="mdl-typeography--headline">Resetting Default Values</h5> |
| 643 |
<p> |
| 644 |
When you change values like the button labels, delays, |
| 645 |
default prompt values or placeholders, etc., you can easily |
| 646 |
reset the defaults. |
| 647 |
</p> |
| 648 |
<a class="mdl-button mdl-js-button mdl-button--raised mdl-js-ripple-effect" id="reset">Try It</a> |
| 649 |
</div> |
| 650 |
<div class="mdl-cell mdl-cell--8-col mdl-cell--7-col-desktop right-col"> |
| 651 |
<h5 class="mdl-typeography--headline">Code Example</h5> |
| 652 |
<pre> |
| 653 |
// Notice the okay button is not the custom value, it was reset. |
| 654 |
alertify |
| 655 |
.okBtn("Go For It!") |
| 656 |
.reset() |
| 657 |
.alert("Custom values were reset!"); |
| 658 |
</pre> |
| 659 |
</div> |
| 660 |
</div> |
| 661 |
|
| 662 |
<!-- <div class="mdl-grid"> |
| 663 |
<div class="mdl-cell mdl-cell--8-col mdl-cell--5-col-desktop left-col"> |
| 664 |
<p></p> |
| 665 |
</div> |
| 666 |
<div class="mdl-cell mdl-cell--8-col mdl-cell--7-col-desktop right-col"> |
| 667 |
<h5 class="mdl-typeography--headline">Code Example</h5> |
| 668 |
<pre> |
| 669 |
</pre> |
| 670 |
</div> |
| 671 |
</div> --> |
| 672 |
</div> |
| 673 |
</div> |
| 674 |
<footer> |
| 675 |
<div class="container"> |
| 676 |
<p>Alertify.js is released under the <a href="http://opensource.org/licenses/MIT">MIT license</a>. © 2015 <a href="https://bradb.net">Brad Berger</a> and contributors. |
| 677 |
</div> |
| 678 |
</footer> |
| 679 |
</main> |
| 680 |
</div> |
| 681 |
<script src="/js/all.js"></script> |
| 682 |
</body> |
| 683 |
</html> |