├── .gitignore
├── LICENSE
├── README.md
├── bower.json
├── build
├── css
│ └── prophet.css
└── js
│ ├── prophet.js
│ ├── prophet.js.map
│ └── prophet.ts
├── dist
├── css
│ ├── prophet.css
│ └── prophet.min.css
└── js
│ ├── prophet-min.js
│ ├── prophet.js
│ └── prophet.js.map
├── gulpfile.js
├── img
├── message-click-cb.gif
├── message-default-no-click.gif
├── message-error.gif
└── message-stack-up.gif
└── package.json
/.gitignore:
--------------------------------------------------------------------------------
1 | # Created by .ignore support plugin (hsz.mobi)
2 | .idea
3 | .idea/*.*
4 | node_modules
5 |
6 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright (c) 2016 Amin Mohamed Ajani
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in
13 | all copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21 | THE SOFTWARE.
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # prophetjs
2 | [](https://nodei.co/npm/prophetjs/)
3 | [](https://nodei.co/npm/prophetjs/)
4 |
5 | A very lean awesome dependency free javascript library to display toast messages on web pages.
6 | This project adheres to [Semantic Versioning](http://semver.org/). Sometimes I do screw up though. For an AngularJS directive, checkout [ngProphet](https://github.com/binarybaba/ngProphet). Prophet currently supports:
7 | - Chrome v26+
8 | - Firefox v20+
9 | - IE v10+ (sorry)
10 | - Safari v5+
11 |
12 | #### Version 1.0.0
13 |
14 | 
15 |
16 |
17 | #### Table of Contents
18 | - [Installation](#installation)
19 | - [Download](#get-the-files)
20 | - [Install](#find-the-files)
21 | - [Usage](#api)
22 | - [Simplest Display](#simplest-display)
23 | - [Callback](#callback)
24 | - [Options](#options)a
25 | - [Custom Toast Types](#custom-types)
26 | - [Contributing](#contributing)
27 | - [License](#license)
28 |
29 |
30 | ## Installation
31 |
32 | ### Get the files:
33 | Choose any of the ways to get prophet:
34 |
35 | - clone from github `git clone https://github.com/binarybaba/prophetjs.git`
36 | - Install from [npm](https://www.npmjs.com/package/prophetjs) `npm install prophetjs --save`
37 | - Install from [bower](https://bower.io/search/?q=prophetjs) `bower install prophetjs --save`
38 |
39 | ### Find the files
40 | You'll see the files in the dist folder:
41 | ```
42 | dist
43 | ├── css
44 | │ ├── prophet.css
45 | │ └── prophet.min.css
46 | └── js
47 | ├── prophet.js
48 | ├── prophet.js.map
49 | └── prophet-min.js
50 | ```
51 | ### Wire it up
52 | Include the css and js files in your webpage:
53 |
54 | ``
55 |
56 | ``
57 |
58 | `
`
59 |
60 | or
61 |
62 | `import Message from 'prophetjs'`
63 |
64 |
65 | # API
66 |
67 | Prophet exposes a Message API. All customizations and configurations are done through this API.
68 | To show a message, you will have to instantiate an instance of `Message`.
69 |
70 | The toast message stays for a default duration of 4000 milliseconds or until the user clicks on it. After which,
71 | the toast message is removed from the DOM.
72 |
73 | #### Simplest display
74 |
75 | `var toast = new Message('Harambe for president!').show();`
76 |
77 | #### Callback
78 |
79 | You can also provide a callback to every toast message. The callback will be triggered after the toast message is removed or
80 | when the user clicks on it. The callback sends the autogenerated ID of the toast message (which can be overridden).
81 |
82 | 
83 | 
84 |
85 | ```
86 | var toast = new Message("Awesome! We'll contact you soon!", function(id){
87 | console.log('Message ID:', id);
88 | // some more code...
89 | });
90 | toast.show();
91 | }
92 | ```
93 |
94 | #### Options
95 |
96 | You can also optionally include a set of options as a second argument (followed by the callback if any ) on every toast message. If the values are not implemented, the default values take up.
97 | (Prophet was written in TypeScript which enforces type checking for development. Hence, it implements an interface IMessageOptions. More on that here...)
98 | The following are the keys that options takes
99 |
100 | - `id`
101 | *The id is autogenerated per toast message.*
102 | - default: auto-generated
103 | - Type: number
104 | - `type`
105 | *Prophet has 3 presets types:* `success`, `error` *and* `default`. *You can also set more presets. Click [here](#custom-types) to see how.*
106 |
107 | 
108 | - default: `"default"`
109 | - Type: string
110 | - `duration`
111 | *The time each toast message stays on the web page before disappearing. Takes value in miliseconds.*
112 | - default: `4000`
113 | - Type: number
114 |
115 | - `class`
116 | *You can further customize the look of every toast message by providing extra CSS classes to override. Takes a single string of class names seperated by spaces.*
117 | - default: `""`
118 | - Type: string
119 |
120 | ##### Example
121 | ```
122 | var ppap = new Message("Awesome! Pen Pineapple Apple Pen.", {
123 | id:i++, //i defined somewhere up above
124 | duration: 8000,
125 | type: 'success',
126 | class : 'blue-background white-text thin-border'
127 | }).show();
128 | ```
129 |
130 | ## Custom Types
131 | You can also add more types by providing the `background-color`, `color` and `type` for more uses. Please note, all the keys are mandatory.
132 |
133 | ```
134 | Message.config.types({
135 | type: "tip",
136 | backgroundColor:"#fafafa",
137 | color:"#313131"
138 | })
139 | ```
140 |
141 | Now you can use the type while invoking a new Message:
142 |
143 | ```
144 | var ppap = new Message("Awesome! Pen Pineapple Apple Pen.", { type: 'tip'}, function(id){
145 | console.log(id);
146 | })
147 | ppap.show();
148 | ```
149 | 
150 |
151 |
152 | ### Contributing
153 | Thanks for taking out time for actually reading this block. You're awesome!
154 | Prophetjs is written in [TypeScript](http://www.typescriptlang.org). I started writing this library as my venture into getting to know TypeScript better so if you're thinking of
155 | contributing, please do install TypeScript as your dev dependencies. I'll be further updating this section to include guides on how to get
156 | your way around the compiler and how you can install it per your IDE/editor (and maybe put this whole section in a new file)
157 |
158 |
159 | #### License
160 | Open source under the [MIT License](https://github.com/binarybaba/prophetjs/blob/master/LICENSE).
161 | All rights reserved.
162 |
--------------------------------------------------------------------------------
/bower.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "prophetjs",
3 | "vesrion":"1.0.0",
4 | "homepage": "https://github.com/binarybaba/prophetjs",
5 | "repository":{
6 | "type":"git",
7 | "url":"git://github.com/binarybaba/prophetjs"
8 | },
9 | "authors": [
10 | "Amin Mohamed Ajani "
11 | ],
12 | "description": "A very lean dependency free javascript library to display toast messages on web pages.",
13 | "main": "dist/js/prophet.js",
14 | "keywords": [
15 | "notification",
16 | "notifications",
17 | "toasts",
18 | "toast messages",
19 | "toast notification",
20 | "notify",
21 | "jQuery",
22 | "javascript",
23 | "js",
24 | "snarl",
25 | "success",
26 | "error",
27 | "notify",
28 | "alerts",
29 | "alertify",
30 | "messages",
31 | "flash",
32 | "flash messages"
33 | ],
34 | "license": "MIT",
35 | "ignore": [
36 | "**/.*",
37 | "node_modules",
38 | "bower_components",
39 | "public/lib",
40 | "test",
41 | "tests"
42 | ]
43 | }
44 |
--------------------------------------------------------------------------------
/build/css/prophet.css:
--------------------------------------------------------------------------------
1 | @import 'https://fonts.googleapis.com/css?family=Source+Sans+Pro';
2 |
3 | .prophet{
4 | position: fixed;
5 | /*display: inline-block;*/
6 | font-family: 'Source Sans Pro', "HelveticaNeue-Light", "Helvetica Neue Light", "Helvetica Neue", Helvetica, Arial, "Lucida Grande", sans-serif;
7 | margin-left:70%; /*Fallback for FF<26 and safari which doesn't calculate the margin */
8 | transition: margin 0.1s cubic-bezier(.07,.99,.93,.97);
9 |
10 |
11 | }
12 |
13 | .prophet > li{
14 | margin-top:0px;
15 | margin-bottom:0px;
16 | list-style-type: none;
17 | min-width: 100px;
18 | font-family: 'Assistant', sans-serif;
19 | opacity:0;
20 | background-color: #323232;
21 | color: #fafafa;
22 | z-index: 99;
23 | margin-top: 20px;
24 | cursor: pointer;
25 | border-radius: 2px;
26 | padding: 20px;
27 | vertical-align: middle;
28 | max-width: 200px;
29 | text-align: center;
30 | webkit-box-shadow: 1px 1px 1px 0px rgba(0, 0, 0, 0.3);
31 | -moz-box-shadow: 1px 1px 1px 0px rgba(0, 0, 0, 0.3);
32 | box-shadow: 1px 1px 1px 0px rgba(0, 0, 0, 0.3);
33 | -webkit-transition: all 0.4s cubic-bezier(.07,.99,.93,.97);
34 | -moz-transition: all 0.2s cubic-bezier(.07,.99,.93,.97);
35 | -o-transition: all 0.2s cubic-bezier(.07,.99,.93,.97);
36 | transition: all 0.2s cubic-bezier(.07,.99,.93,.97);
37 | }
38 | .prophet > .prophet-message-active{
39 |
40 | margin-top:10px;
41 | margin-bottom:0px;
42 | opacity: 1;
43 | -webkit-transition: all 0.1s cubic-bezier(.07,.99,.93,.97);
44 | -moz-transition: all 0.1s cubic-bezier(.07,.99,.93,.97);
45 | -o-transition: all 0.1s cubic-bezier(.07,.99,.93,.97);
46 | transition: all 0.1s cubic-bezier(.07,.99,.93,.97);
47 | }
48 |
49 | @media only screen and (min-width: 240px){
50 | ul.prophet{
51 | margin-left:10px;
52 | }
53 | }
54 | @media only screen and (min-width: 240px) and (max-width: 320px){
55 | ul.prophet{
56 | margin-left:30%;
57 | }
58 | }
59 | @media only screen and (min-width: 320px) and (max-width: 480px){
60 | ul.prophet{
61 | margin-left:35%;
62 | }
63 | }
64 | @media only screen and (min-width: 480px) and (max-width: 600px){
65 | ul.prophet{
66 | margin-left:50%;
67 | }
68 | }
69 | @media only screen and (min-width: 600px) and (max-width: 720px){
70 | ul.prophet{
71 | margin-left:60%;
72 | }
73 | }
74 | @media only screen and (min-width: 720px) and (max-width: 1024px){
75 | ul.prophet{
76 | margin-left:70%;
77 | }
78 | }
79 | @media only screen and (min-width: 1024px) {
80 | ul.prophet{
81 | margin-left:75%;
82 | }
83 | }
84 |
--------------------------------------------------------------------------------
/build/js/prophet.js:
--------------------------------------------------------------------------------
1 | /*!
2 | * Prophetjs v0.0.9
3 | * Copyright 2016 Amin Mohamed Ajani (http://allrightamin.xyz, http://twitter.com/AminSpeaks)
4 | * Open source under the MIT License (https://github.com/binarybaba/prophetjs/blob/master/LICENSE)
5 | * All rights reserved.
6 | */
7 | /**
8 | * Polyfill DATE.NOW
9 | * Production steps of ECMA-262, Edition 5, 15.4.4.19 */
10 | if (!Date.now) {
11 | Date.now = function now() { return new Date().getTime(); };
12 | }
13 | /**
14 | * Polyfill ARRAY.MAP
15 | * */
16 | if (!Array.prototype.map) {
17 | Array.prototype.map = function (callback, thisArg) {
18 | var T, A, k;
19 | if (this == null)
20 | throw new TypeError(' this is null or not defined');
21 | var O = Object(this);
22 | var len = O.length >>> 0;
23 | if (typeof callback !== 'function')
24 | throw new TypeError(callback + ' is not a function');
25 | if (arguments.length > 1)
26 | T = thisArg;
27 | A = new Array(len);
28 | k = 0;
29 | while (k < len) {
30 | var kValue, mappedValue;
31 | if (k in O) {
32 | kValue = O[k];
33 | mappedValue = callback.call(T, kValue, k, O);
34 | A[k] = mappedValue;
35 | }
36 | k++;
37 | }
38 | return A;
39 | };
40 | }
41 | /*Polyfill TEXTCONTENT for IE8*/
42 | if (Object.defineProperty
43 | && Object.getOwnPropertyDescriptor
44 | && Object.getOwnPropertyDescriptor(Element.prototype, "textContent")
45 | && !Object.getOwnPropertyDescriptor(Element.prototype, "textContent").get) {
46 | (function () {
47 | var innerText = Object.getOwnPropertyDescriptor(Element.prototype, "innerText");
48 | Object.defineProperty(Element.prototype, "textContent", {
49 | get: function () {
50 | return innerText.get.call(this);
51 | },
52 | set: function (s) {
53 | return innerText.set.call(this, s);
54 | }
55 | });
56 | })();
57 | }
58 | var Message = (function () {
59 | function Message(text, options, cb) {
60 | //--- Default values ---
61 | this._text = text || "Awesome!";
62 | this._id = Message.idGen();
63 | this._type = "default";
64 | this._duration = 4000; //defaults to 4000 milliseconds
65 | this._class = " ";
66 | if (options) {
67 | this.cb = cb;
68 | if (typeof (options) === "function")
69 | this.cb = options;
70 | else if (typeof (options) === "object" && !Array.isArray(options)) {
71 | this._type = options.type || this._type;
72 | this._id = options.id || this._id;
73 | this._duration = options.duration || this._duration;
74 | this._class = options.class || this._class;
75 | }
76 | }
77 | this.cb = typeof (options) === "function" ? options : cb;
78 | Message.Stack[Message.Stack.length] = this;
79 | this.init();
80 | return this;
81 | }
82 | Message.idGen = function () {
83 | return Date.now() % 10000;
84 | };
85 | /*NEXTVER: make single clear function in future which clears a specific toast by taking an id as a param. if no id, clears all*/
86 | Message.clearAll = function () {
87 | var messages = document.querySelectorAll('ul.prophet > li');
88 | for (var i = 0, len = messages.length; i < len; i++) {
89 | messages[i].classList.remove('prophet-message-active');
90 | Message.parent.removeChild(messages[i]);
91 | }
92 | };
93 | Message.prototype.init = function () {
94 | var _this = this;
95 | this.cbFired = false;
96 | this.toast = document.createElement('li');
97 | var toast = this.toast;
98 | _a = ["message " + this._class, this._text], toast.className = _a[0], toast.textContent = _a[1];
99 | this.stylize();
100 | toast.addEventListener('click', function () {
101 | toast.classList.remove('prophet-message-active');
102 | if (_this.cb) {
103 | _this.cb(_this._id);
104 | _this.cbFired = true;
105 | }
106 | setTimeout(function () {
107 | Message.parent.removeChild(toast);
108 | }, 60);
109 | });
110 | var _a;
111 | };
112 | Message.prototype.show = function () {
113 | var _this = this;
114 | var toast = this.toast;
115 | Message.parent.appendChild(this.toast);
116 | setTimeout(function () {
117 | toast.classList.add('prophet-message-active');
118 | }, 10);
119 | setTimeout(function () {
120 | toast.classList.remove('prophet-message-active');
121 | if (!_this.cbFired)
122 | if (_this.cb)
123 | _this.cb(_this._id);
124 | setTimeout(function () {
125 | try {
126 | Message.parent.removeChild(toast);
127 | }
128 | catch (e) { }
129 | }, 30);
130 | }, this._duration);
131 | return this;
132 | };
133 | Message.prototype.stylize = function () {
134 | var foundPos = Message.Util.find(Message.stylePresets, this._type);
135 | /*NEXTVER: Make all copying loop instead of manual in next ver*/
136 | if (foundPos !== -1) {
137 | this.toast.style.backgroundColor = Message.stylePresets[foundPos].backgroundColor;
138 | this.toast.style.color = Message.stylePresets[foundPos].color;
139 | }
140 | };
141 | Message.Util = {
142 | find: function (objArr, keyToFind) {
143 | return objArr.map(function (preset) { return preset.type; }).indexOf(keyToFind);
144 | },
145 | toDash: function (prop) {
146 | return prop.replace(/([A-Z])/g, function ($1) { return "-" + $1.toLowerCase(); });
147 | },
148 | getSizes: function () {
149 | var viewportwidth;
150 | var viewportheight;
151 | // the more standards compliant browsers (mozilla/netscape/opera/IE7) use window.innerWidth and window.innerHeight
152 | if (typeof window.innerWidth != 'undefined') {
153 | viewportwidth = window.innerWidth, viewportheight = window.innerHeight;
154 | }
155 | else if (typeof document.documentElement != 'undefined' && typeof document.documentElement.clientWidth != 'undefined' && document.documentElement.clientWidth != 0) {
156 | viewportwidth = document.documentElement.clientWidth,
157 | viewportheight = document.documentElement.clientHeight;
158 | }
159 | else {
160 | viewportwidth = document.getElementsByTagName('body')[0].clientWidth, viewportheight = document.getElementsByTagName('body')[0].clientHeight;
161 | }
162 | return { width: viewportwidth, height: viewportheight };
163 | },
164 | rePosition: function () {
165 | var width = Message.Util.getSizes().width;
166 | /*NEXTVER: portrait and landscape modes*/
167 | var height = Message.Util.getSizes().height;
168 | var p = document.getElementsByClassName('prophet')[0];
169 | if (width < 240)
170 | p.style.marginLeft = "10px";
171 | else if (width > 240 && width < 320)
172 | p.style.marginLeft = 0.3 * width + "px";
173 | else if (width > 320 && width < 480)
174 | p.style.marginLeft = 0.35 * width + "px";
175 | else if (width > 480 && width < 600)
176 | p.style.marginLeft = 0.5 * width + "px";
177 | else if (width > 600 && width < 720)
178 | p.style.marginLeft = 0.6 * width + "px";
179 | else if (width > 720 && width < 1024)
180 | p.style.marginLeft = 0.7 * width + "px";
181 | else if (width > 1024)
182 | p.style.marginLeft = (0.75 * width) + "px";
183 | else if (width > 1024)
184 | p.style.marginLeft = (0.75 * width) + "px";
185 | }
186 | };
187 | Message.Dbg = {
188 | stackTrace: function () { return console.dir(Message.Stack); },
189 | presets: function () { return console.dir(Message.stylePresets); }
190 | };
191 | Message.parent = document.getElementsByClassName('prophet')[0];
192 | Message.stylePresets = [
193 | { type: "default", backgroundColor: "#1c2e2d", color: "#FAFAFA" },
194 | { type: "success", backgroundColor: "#4daf7c", color: "#FAFAFA" },
195 | { type: "error", backgroundColor: "#D45A43", color: "#FAFAFA" }
196 | ];
197 | Message.config = {
198 | types: function (newPresets) {
199 | newPresets = [].concat(newPresets);
200 | for (var i = 0, len = newPresets.length, current; i < len; i++) {
201 | var pos = Message.Util.find(Message.stylePresets, newPresets[i].type);
202 | current = newPresets[i];
203 | if (pos !== -1)
204 | for (var key in current)
205 | Message.stylePresets[pos][key] = current[key];
206 | else
207 | Message.stylePresets[Message.stylePresets.length] = current;
208 | }
209 | }
210 | };
211 | Message.Stack = [];
212 | return Message;
213 | }());
214 | //# sourceMappingURL=prophet.js.map
--------------------------------------------------------------------------------
/build/js/prophet.js.map:
--------------------------------------------------------------------------------
1 | {"version":3,"file":"prophet.js","sourceRoot":"","sources":["prophet.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH;;wDAEwD;AACxD,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;IAAC,IAAI,CAAC,GAAG,GAAG,iBAAiB,MAAM,CAAC,IAAI,IAAI,EAAE,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,CAAC;AAAC,CAAC;AAC9E;;KAEK;AAEL,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,CAAC;IACxB,KAAK,CAAC,SAAS,CAAC,GAAG,GAAG,UAAS,QAAQ,EAAE,OAAO;QAC3C,IAAI,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC;QACZ,EAAE,CAAC,CAAC,IAAI,IAAI,IAAI,CAAC;YAAE,MAAM,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AE,SAAS,EAAC;QACjE,EAAE,IAAI,EAAE,SAAS,EAAE,eAAe,EAAE,SAAS,EAAE,KAAK,EAAE,SAAS,EAAE;QACjE,EAAE,IAAI,EAAE,OAAO,EAAE,eAAe,EAAE,SAAS,EAAE,KAAK,EAAE,SAAS,EAAC;KAC7D,CAAC;IACC,cAAM,GAAY;QACrB,KAAK,YAAC,UAA+C;YACjD,UAAU,GAAG,EAAE,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC;YACnC,GAAG,CAAA,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,GAAG,GAAG,UAAU,CAAC,MAAM,EAAE,OAAO,EAAE,CAAC,GAAE,GAAG,EAAE,CAAC,EAAE,EAAC,CAAC;gBAC1D,IAAI,GAAG,GAAG,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,YAAY,EAAE,UAAU,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAA;gBACrE,OAAO,GAAG,UAAU,CAAC,CAAC,CAAC,CAAC;gBACxB,EAAE,CAAA,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC;oBAAC,GAAG,CAAA,CAAC,IAAI,GAAG,IAAI,OAAO,CAAC;wBAAC,OAAO,CAAC,YAAY,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC;gBACrF,IAAI;oBAAC,OAAO,CAAC,YAAY,CAAC,OAAO,CAAC,YAAY,CAAC,MAAM,CAAC,GAAG,OAAO,CAAC;YACrE,CAAC;QACL,CAAC;KACJ,CAAC;IACK,aAAK,GAAoB,EAAE,CAAC;IA0FvC,cAAC;AAAD,CAAC,AAxJD,IAwJC"}
--------------------------------------------------------------------------------
/build/js/prophet.ts:
--------------------------------------------------------------------------------
1 | /*!
2 | * Prophetjs v0.0.9
3 | * Copyright 2016 Amin Mohamed Ajani (http://allrightamin.xyz, http://twitter.com/AminSpeaks)
4 | * Open source under the MIT License (https://github.com/binarybaba/prophetjs/blob/master/LICENSE)
5 | * All rights reserved.
6 | */
7 |
8 |
9 | /**
10 | * Polyfill DATE.NOW
11 | * Production steps of ECMA-262, Edition 5, 15.4.4.19 */
12 | if (!Date.now) { Date.now = function now() { return new Date().getTime(); }; }
13 | /**
14 | * Polyfill ARRAY.MAP
15 | * */
16 |
17 | if (!Array.prototype.map) {
18 | Array.prototype.map = function(callback, thisArg) {
19 | var T, A, k;
20 | if (this == null) throw new TypeError(' this is null or not defined');
21 | var O = Object(this);
22 | var len = O.length >>> 0;
23 | if (typeof callback !== 'function') throw new TypeError(callback + ' is not a function');
24 | if (arguments.length > 1) T = thisArg;
25 | A = new Array(len); k = 0;
26 | while (k < len) { var kValue, mappedValue;
27 | if (k in O) {
28 | kValue = O[k];
29 | mappedValue = callback.call(T, kValue, k, O);
30 | A[k] = mappedValue;
31 | }
32 | k++;
33 | }
34 | return A;
35 | };
36 | }
37 | /*Polyfill TEXTCONTENT for IE8*/
38 | if (Object.defineProperty
39 | && Object.getOwnPropertyDescriptor
40 | && Object.getOwnPropertyDescriptor(Element.prototype, "textContent")
41 | && !Object.getOwnPropertyDescriptor(Element.prototype, "textContent").get) {
42 | (function() {
43 | var innerText = Object.getOwnPropertyDescriptor(Element.prototype, "innerText");
44 | Object.defineProperty(Element.prototype, "textContent",
45 | {
46 | get: function() {
47 | return innerText.get.call(this);
48 | },
49 | set: function(s) {
50 | return innerText.set.call(this, s);
51 | }
52 | }
53 | );
54 | })();
55 | }
56 |
57 | interface IStylePreset {
58 | type : string;
59 | backgroundColor : string;
60 | color : string
61 | }
62 | interface IMessageOptions{
63 | id? : number;
64 | type?: string;
65 | duration? :number; //defaults to 4000 milliseconds
66 | class? : string;
67 | position?: string; ///*NEXTVER: left,right,center?: */
68 |
69 | }
70 |
71 |
72 | class Message{
73 | static Util = {
74 | find : (objArr : Array, keyToFind : string) : number => {
75 | return objArr.map(function(preset){ return preset.type; }).indexOf(keyToFind);
76 | },
77 | toDash: (prop : string): string => {
78 | return prop.replace(/([A-Z])/g, function($1){return "-"+$1.toLowerCase();});
79 | },
80 | getSizes: () =>{
81 | var viewportwidth;
82 | var viewportheight;
83 | // the more standards compliant browsers (mozilla/netscape/opera/IE7) use window.innerWidth and window.innerHeight
84 | if (typeof window.innerWidth != 'undefined'){ viewportwidth = window.innerWidth, viewportheight = window.innerHeight }
85 | // IE6 in standards compliant mode (i.e. with a valid doctype as the first line in the document)
86 | else if (typeof document.documentElement != 'undefined' && typeof document.documentElement.clientWidth != 'undefined' && document.documentElement.clientWidth != 0) {
87 | viewportwidth = document.documentElement.clientWidth,
88 | viewportheight = document.documentElement.clientHeight
89 | }
90 | // older versions of IE
91 | else{ viewportwidth = document.getElementsByTagName('body')[0].clientWidth, viewportheight = document.getElementsByTagName('body')[0].clientHeight }
92 | return { width: viewportwidth , height:viewportheight}
93 |
94 | },
95 | rePosition: () :void =>{
96 |
97 | var width = Message.Util.getSizes().width;
98 | /*NEXTVER: portrait and landscape modes*/
99 | var height = Message.Util.getSizes().height;
100 | var p = document.getElementsByClassName('prophet')[0];
101 | if(width<240) p.style.marginLeft="10px";
102 | else if (width>240 && width < 320) p.style.marginLeft=0.3*width+"px";
103 | else if (width>320 && width < 480) p.style.marginLeft=0.35*width+"px";
104 | else if (width>480 && width < 600) p.style.marginLeft=0.5*width+"px";
105 | else if (width>600 && width < 720) p.style.marginLeft=0.6*width+"px";
106 | else if (width>720 && width < 1024) p.style.marginLeft=0.7*width+"px";
107 | else if (width > 1024) p.style.marginLeft=(0.75*width)+"px";
108 | else if (width > 1024) p.style.marginLeft=(0.75*width)+"px";
109 |
110 | }
111 |
112 | };
113 | static Dbg = {
114 | stackTrace: (): void => console.dir(Message.Stack),
115 | presets: () : void => console.dir(Message.stylePresets)
116 | };
117 | static parent : HTMLElement = document.getElementsByClassName('prophet')[0];
118 | static stylePresets : Array = [
119 | { type: "default", backgroundColor: "#1c2e2d" , color: "#FAFAFA"},
120 | { type: "success", backgroundColor: "#4daf7c", color: "#FAFAFA" },
121 | { type: "error", backgroundColor: "#D45A43", color: "#FAFAFA"}
122 | ];
123 | static config : Object = {
124 | types(newPresets : IStylePreset | Array) : void {
125 | newPresets = [].concat(newPresets);
126 | for(var i = 0, len = newPresets.length, current; i< len; i++){
127 | var pos = Message.Util.find(Message.stylePresets, newPresets[i].type)
128 | current = newPresets[i];
129 | if(pos !== -1) for(var key in current) Message.stylePresets[pos][key] = current[key];
130 | else Message.stylePresets[Message.stylePresets.length] = current;
131 | }
132 | }
133 | };
134 | static Stack : Array = [];
135 | static idGen() : number{
136 | return Date.now()%10000;
137 | }
138 | /*NEXTVER: make single clear function in future which clears a specific toast by taking an id as a param. if no id, clears all*/
139 | static clearAll() : void {
140 | var messages = document.querySelectorAll('ul.prophet > li');
141 | for(var i = 0, len = messages.length; i< len; i++){
142 | messages[i].classList.remove('prophet-message-active');
143 | Message.parent.removeChild(messages[i]);
144 | }
145 | }
146 |
147 | _id : number;
148 | _text : string;
149 | _type: string;
150 | _duration :number;
151 | _class : string;
152 | cbFired:boolean;
153 | toast:HTMLElement;
154 | cb: Function;
155 | callStack : [Function]; //NEXTVER: promises maybe?
156 |
157 | constructor(text: string, options : IMessageOptions, cb : Function) {
158 | //--- Default values ---
159 | this._text = text || "Awesome!";
160 | this._id = Message.idGen();
161 | this._type ="default";
162 | this._duration = 4000; //defaults to 4000 milliseconds
163 | this._class = " ";
164 | if (options){
165 | this.cb = cb;
166 | if(typeof(options) === "function" ) this.cb = options;
167 | else if(typeof(options) === "object" && !Array.isArray(options)){
168 | this._type = options.type || this._type;
169 | this._id = options.id || this._id;
170 | this._duration= options.duration || this._duration;
171 | this._class=options.class || this._class;
172 | }
173 |
174 | }
175 | this.cb = typeof(options) === "function" ? options: cb;
176 | Message.Stack[Message.Stack.length] = this;
177 | this.init();
178 | return this;
179 | }
180 | init(): void{
181 | var _this = this;
182 | this.cbFired = false;
183 | this.toast = document.createElement('li');
184 | var toast = this.toast;
185 | [toast.className, toast.textContent] = ["message "+ this._class, this._text];
186 | this.stylize();
187 | toast.addEventListener('click', function(){
188 | toast.classList.remove('prophet-message-active');
189 | if(_this.cb){
190 | _this.cb(_this._id);
191 | _this.cbFired = true;
192 | }
193 | setTimeout(function(){
194 | Message.parent.removeChild(toast);
195 | },60);
196 | });
197 |
198 | }
199 | show(): Message{
200 | var _this = this;
201 | var toast = this.toast;
202 | Message.parent.appendChild(this.toast);
203 | setTimeout(function(){
204 | toast.classList.add('prophet-message-active');
205 | },10);
206 | setTimeout(function(){
207 | toast.classList.remove('prophet-message-active');
208 | if(!_this.cbFired) if(_this.cb) _this.cb(_this._id);
209 | setTimeout(function(){
210 | try {Message.parent.removeChild(toast);} catch (e){}
211 | }, 30);
212 | },this._duration);
213 | return this;
214 | }
215 | stylize(){
216 | var foundPos = Message.Util.find(Message.stylePresets,this._type);
217 | /*NEXTVER: Make all copying loop instead of manual in next ver*/
218 | if (foundPos !== -1){
219 | this.toast.style.backgroundColor = Message.stylePresets[foundPos].backgroundColor;
220 | this.toast.style.color = Message.stylePresets[foundPos].color;
221 | }
222 | }
223 |
224 | }
225 |
226 | if (typeof module !== "undefined")
227 | module["exports"] = Message;
228 | else
229 | window["Message"] = Message;
230 |
231 |
--------------------------------------------------------------------------------
/dist/css/prophet.css:
--------------------------------------------------------------------------------
1 | @import 'https://fonts.googleapis.com/css?family=Source+Sans+Pro';
2 |
3 | .prophet{
4 | position: fixed;
5 | /*display: inline-block;*/
6 | font-family: 'Source Sans Pro', "HelveticaNeue-Light", "Helvetica Neue Light", "Helvetica Neue", Helvetica, Arial, "Lucida Grande", sans-serif;
7 | margin-left:70%; /*Fallback for FF<26 and safari which doesn't calculate the margin */
8 | transition: margin 0.1s cubic-bezier(.07,.99,.93,.97);
9 |
10 |
11 | }
12 |
13 | .prophet > li{
14 | margin-top:0px;
15 | margin-bottom:0px;
16 | list-style-type: none;
17 | min-width: 100px;
18 | font-family: 'Assistant', sans-serif;
19 | opacity:0;
20 | background-color: #323232;
21 | color: #fafafa;
22 | z-index: 99;
23 | margin-top: 20px;
24 | cursor: pointer;
25 | border-radius: 2px;
26 | padding: 20px;
27 | vertical-align: middle;
28 | max-width: 200px;
29 | text-align: center;
30 | webkit-box-shadow: 1px 1px 1px 0px rgba(0, 0, 0, 0.3);
31 | -moz-box-shadow: 1px 1px 1px 0px rgba(0, 0, 0, 0.3);
32 | box-shadow: 1px 1px 1px 0px rgba(0, 0, 0, 0.3);
33 | -webkit-transition: all 0.4s cubic-bezier(.07,.99,.93,.97);
34 | -moz-transition: all 0.2s cubic-bezier(.07,.99,.93,.97);
35 | -o-transition: all 0.2s cubic-bezier(.07,.99,.93,.97);
36 | transition: all 0.2s cubic-bezier(.07,.99,.93,.97);
37 | }
38 | .prophet > .prophet-message-active{
39 |
40 | margin-top:10px;
41 | margin-bottom:0px;
42 | opacity: 1;
43 | -webkit-transition: all 0.1s cubic-bezier(.07,.99,.93,.97);
44 | -moz-transition: all 0.1s cubic-bezier(.07,.99,.93,.97);
45 | -o-transition: all 0.1s cubic-bezier(.07,.99,.93,.97);
46 | transition: all 0.1s cubic-bezier(.07,.99,.93,.97);
47 | }
48 |
49 | @media only screen and (min-width: 240px){
50 | ul.prophet{
51 | margin-left:10px;
52 | }
53 | }
54 | @media only screen and (min-width: 240px) and (max-width: 320px){
55 | ul.prophet{
56 | margin-left:30%;
57 | }
58 | }
59 | @media only screen and (min-width: 320px) and (max-width: 480px){
60 | ul.prophet{
61 | margin-left:35%;
62 | }
63 | }
64 | @media only screen and (min-width: 480px) and (max-width: 600px){
65 | ul.prophet{
66 | margin-left:50%;
67 | }
68 | }
69 | @media only screen and (min-width: 600px) and (max-width: 720px){
70 | ul.prophet{
71 | margin-left:60%;
72 | }
73 | }
74 | @media only screen and (min-width: 720px) and (max-width: 1024px){
75 | ul.prophet{
76 | margin-left:70%;
77 | }
78 | }
79 | @media only screen and (min-width: 1024px) {
80 | ul.prophet{
81 | margin-left:75%;
82 | }
83 | }
84 |
--------------------------------------------------------------------------------
/dist/css/prophet.min.css:
--------------------------------------------------------------------------------
1 | @import url(https://fonts.googleapis.com/css?family=Source+Sans+Pro);.prophet{position:fixed;font-family:'Source Sans Pro',HelveticaNeue-Light,"Helvetica Neue Light","Helvetica Neue",Helvetica,Arial,"Lucida Grande",sans-serif;margin-left:70%;transition:margin .1s cubic-bezier(.07,.99,.93,.97)}.prophet>li{margin-bottom:0;list-style-type:none;min-width:100px;font-family:Assistant,sans-serif;opacity:0;background-color:#323232;color:#fafafa;z-index:99;margin-top:20px;cursor:pointer;border-radius:2px;padding:20px;vertical-align:middle;max-width:200px;text-align:center;webkit-box-shadow:1px 1px 1px 0 rgba(0,0,0,.3);-moz-box-shadow:1px 1px 1px 0 rgba(0,0,0,.3);box-shadow:1px 1px 1px 0 rgba(0,0,0,.3);-webkit-transition:all .4s cubic-bezier(.07,.99,.93,.97);-moz-transition:all .2s cubic-bezier(.07,.99,.93,.97);-o-transition:all .2s cubic-bezier(.07,.99,.93,.97);transition:all .2s cubic-bezier(.07,.99,.93,.97)}.prophet>.prophet-message-active{margin-top:10px;margin-bottom:0;opacity:1;-webkit-transition:all .1s cubic-bezier(.07,.99,.93,.97);-moz-transition:all .1s cubic-bezier(.07,.99,.93,.97);-o-transition:all .1s cubic-bezier(.07,.99,.93,.97);transition:all .1s cubic-bezier(.07,.99,.93,.97)}@media only screen and (min-width:240px){ul.prophet{margin-left:10px}}@media only screen and (min-width:240px) and (max-width:320px){ul.prophet{margin-left:30%}}@media only screen and (min-width:320px) and (max-width:480px){ul.prophet{margin-left:35%}}@media only screen and (min-width:480px) and (max-width:600px){ul.prophet{margin-left:50%}}@media only screen and (min-width:600px) and (max-width:720px){ul.prophet{margin-left:60%}}@media only screen and (min-width:720px) and (max-width:1024px){ul.prophet{margin-left:70%}}@media only screen and (min-width:1024px){ul.prophet{margin-left:75%}}
--------------------------------------------------------------------------------
/dist/js/prophet-min.js:
--------------------------------------------------------------------------------
1 | Date.now||(Date.now=function(){return(new Date).getTime()}),Array.prototype.map||(Array.prototype.map=function(t,e){var n,i,r;if(null==this)throw new TypeError(" this is null or not defined");var o=Object(this),s=o.length>>>0;if("function"!=typeof t)throw new TypeError(t+" is not a function");for(arguments.length>1&&(n=e),i=new Array(s),r=0;r li"),n=0,i=e.length;n240&&e<320?n.style.marginLeft=.3*e+"px":e>320&&e<480?n.style.marginLeft=.35*e+"px":e>480&&e<600?n.style.marginLeft=.5*e+"px":e>600&&e<720?n.style.marginLeft=.6*e+"px":e>720&&e<1024?n.style.marginLeft=.7*e+"px":e>1024?n.style.marginLeft=.75*e+"px":e>1024&&(n.style.marginLeft=.75*e+"px")}},t.Dbg={stackTrace:function(){return console.dir(t.Stack)},presets:function(){return console.dir(t.stylePresets)}},t.parent=document.getElementsByClassName("prophet")[0],t.stylePresets=[{type:"default",backgroundColor:"#1c2e2d",color:"#FAFAFA"},{type:"success",backgroundColor:"#4daf7c",color:"#FAFAFA"},{type:"error",backgroundColor:"#D45A43",color:"#FAFAFA"}],t.config={types:function(e){e=[].concat(e);for(var n,i=0,r=e.length;i>> 0;
23 | if (typeof callback !== 'function')
24 | throw new TypeError(callback + ' is not a function');
25 | if (arguments.length > 1)
26 | T = thisArg;
27 | A = new Array(len);
28 | k = 0;
29 | while (k < len) {
30 | var kValue, mappedValue;
31 | if (k in O) {
32 | kValue = O[k];
33 | mappedValue = callback.call(T, kValue, k, O);
34 | A[k] = mappedValue;
35 | }
36 | k++;
37 | }
38 | return A;
39 | };
40 | }
41 | /*Polyfill TEXTCONTENT for IE8*/
42 | if (Object.defineProperty
43 | && Object.getOwnPropertyDescriptor
44 | && Object.getOwnPropertyDescriptor(Element.prototype, "textContent")
45 | && !Object.getOwnPropertyDescriptor(Element.prototype, "textContent").get) {
46 | (function () {
47 | var innerText = Object.getOwnPropertyDescriptor(Element.prototype, "innerText");
48 | Object.defineProperty(Element.prototype, "textContent", {
49 | get: function () {
50 | return innerText.get.call(this);
51 | },
52 | set: function (s) {
53 | return innerText.set.call(this, s);
54 | }
55 | });
56 | })();
57 | }
58 | var Message = (function () {
59 | function Message(text, options, cb) {
60 | //--- Default values ---
61 | this._text = text || "Awesome!";
62 | this._id = Message.idGen();
63 | this._type = "default";
64 | this._duration = 4000; //defaults to 4000 milliseconds
65 | this._class = " ";
66 | if (options) {
67 | this.cb = cb;
68 | if (typeof (options) === "function")
69 | this.cb = options;
70 | else if (typeof (options) === "object" && !Array.isArray(options)) {
71 | this._type = options.type || this._type;
72 | this._id = options.id || this._id;
73 | this._duration = options.duration || this._duration;
74 | this._class = options.class || this._class;
75 | }
76 | }
77 | this.cb = typeof (options) === "function" ? options : cb;
78 | Message.Stack[Message.Stack.length] = this;
79 | this.init();
80 | return this;
81 | }
82 | Message.idGen = function () {
83 | return Date.now() % 10000;
84 | };
85 | /*NEXTVER: make single clear function in future which clears a specific toast by taking an id as a param. if no id, clears all*/
86 | Message.clearAll = function () {
87 | var messages = document.querySelectorAll('ul.prophet > li');
88 | for (var i = 0, len = messages.length; i < len; i++) {
89 | messages[i].classList.remove('prophet-message-active');
90 | Message.parent.removeChild(messages[i]);
91 | }
92 | };
93 | Message.prototype.init = function () {
94 | var _this = this;
95 | this.cbFired = false;
96 | this.toast = document.createElement('li');
97 | var toast = this.toast;
98 | _a = ["message " + this._class, this._text], toast.className = _a[0], toast.textContent = _a[1];
99 | this.stylize();
100 | toast.addEventListener('click', function () {
101 | toast.classList.remove('prophet-message-active');
102 | if (_this.cb) {
103 | _this.cb(_this._id);
104 | _this.cbFired = true;
105 | }
106 | setTimeout(function () {
107 | Message.parent.removeChild(toast);
108 | }, 60);
109 | });
110 | var _a;
111 | };
112 | Message.prototype.show = function () {
113 | var _this = this;
114 | var toast = this.toast;
115 | Message.parent.appendChild(this.toast);
116 | setTimeout(function () {
117 | toast.classList.add('prophet-message-active');
118 | }, 10);
119 | setTimeout(function () {
120 | toast.classList.remove('prophet-message-active');
121 | if (!_this.cbFired)
122 | if (_this.cb)
123 | _this.cb(_this._id);
124 | setTimeout(function () {
125 | try {
126 | Message.parent.removeChild(toast);
127 | }
128 | catch (e) { }
129 | }, 30);
130 | }, this._duration);
131 | return this;
132 | };
133 | Message.prototype.stylize = function () {
134 | var foundPos = Message.Util.find(Message.stylePresets, this._type);
135 | /*NEXTVER: Make all copying loop instead of manual in next ver*/
136 | if (foundPos !== -1) {
137 | this.toast.style.backgroundColor = Message.stylePresets[foundPos].backgroundColor;
138 | this.toast.style.color = Message.stylePresets[foundPos].color;
139 | }
140 | };
141 | Message.Util = {
142 | find: function (objArr, keyToFind) {
143 | return objArr.map(function (preset) { return preset.type; }).indexOf(keyToFind);
144 | },
145 | toDash: function (prop) {
146 | return prop.replace(/([A-Z])/g, function ($1) { return "-" + $1.toLowerCase(); });
147 | },
148 | getSizes: function () {
149 | var viewportwidth;
150 | var viewportheight;
151 | // the more standards compliant browsers (mozilla/netscape/opera/IE7) use window.innerWidth and window.innerHeight
152 | if (typeof window.innerWidth != 'undefined') {
153 | viewportwidth = window.innerWidth, viewportheight = window.innerHeight;
154 | }
155 | else if (typeof document.documentElement != 'undefined' && typeof document.documentElement.clientWidth != 'undefined' && document.documentElement.clientWidth != 0) {
156 | viewportwidth = document.documentElement.clientWidth,
157 | viewportheight = document.documentElement.clientHeight;
158 | }
159 | else {
160 | viewportwidth = document.getElementsByTagName('body')[0].clientWidth, viewportheight = document.getElementsByTagName('body')[0].clientHeight;
161 | }
162 | return { width: viewportwidth, height: viewportheight };
163 | },
164 | rePosition: function () {
165 | var width = Message.Util.getSizes().width;
166 | /*NEXTVER: portrait and landscape modes*/
167 | var height = Message.Util.getSizes().height;
168 | var p = document.getElementsByClassName('prophet')[0];
169 | if (width < 240)
170 | p.style.marginLeft = "10px";
171 | else if (width > 240 && width < 320)
172 | p.style.marginLeft = 0.3 * width + "px";
173 | else if (width > 320 && width < 480)
174 | p.style.marginLeft = 0.35 * width + "px";
175 | else if (width > 480 && width < 600)
176 | p.style.marginLeft = 0.5 * width + "px";
177 | else if (width > 600 && width < 720)
178 | p.style.marginLeft = 0.6 * width + "px";
179 | else if (width > 720 && width < 1024)
180 | p.style.marginLeft = 0.7 * width + "px";
181 | else if (width > 1024)
182 | p.style.marginLeft = (0.75 * width) + "px";
183 | else if (width > 1024)
184 | p.style.marginLeft = (0.75 * width) + "px";
185 | }
186 | };
187 | Message.Dbg = {
188 | stackTrace: function () { return console.dir(Message.Stack); },
189 | presets: function () { return console.dir(Message.stylePresets); }
190 | };
191 | Message.parent = document.getElementsByClassName('prophet')[0];
192 | Message.stylePresets = [
193 | { type: "default", backgroundColor: "#1c2e2d", color: "#FAFAFA" },
194 | { type: "success", backgroundColor: "#4daf7c", color: "#FAFAFA" },
195 | { type: "error", backgroundColor: "#D45A43", color: "#FAFAFA" }
196 | ];
197 | Message.config = {
198 | types: function (newPresets) {
199 | newPresets = [].concat(newPresets);
200 | for (var i = 0, len = newPresets.length, current; i < len; i++) {
201 | var pos = Message.Util.find(Message.stylePresets, newPresets[i].type);
202 | current = newPresets[i];
203 | if (pos !== -1)
204 | for (var key in current)
205 | Message.stylePresets[pos][key] = current[key];
206 | else
207 | Message.stylePresets[Message.stylePresets.length] = current;
208 | }
209 | }
210 | };
211 | Message.Stack = [];
212 | return Message;
213 | }());
214 | //# sourceMappingURL=prophet.js.map
--------------------------------------------------------------------------------
/dist/js/prophet.js.map:
--------------------------------------------------------------------------------
1 | {"version":3,"file":"prophet.js","sourceRoot":"","sources":["prophet.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH;;wDAEwD;AACxD,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;IAAC,IAAI,CAAC,GAAG,GAAG,iBAAiB,MAAM,CAAC,IAAI,IAAI,EAAE,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,CAAC;AAAC,CAAC;AAC9E;;KAEK;AAEL,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,CAAC;IACxB,KAAK,CAAC,SAAS,CAAC,GAAG,GAAG,UAAS,QAA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SAAS,CAAC,CAAC,CAAC,CAAC,CAAC;IAClF,oBAAY,GAAyB;QACxC,EAAE,IAAI,EAAE,SAAS,EAAE,eAAe,EAAE,SAAS,EAAG,KAAK,EAAE,SAAS,EAAC;QACjE,EAAE,IAAI,EAAE,SAAS,EAAE,eAAe,EAAE,SAAS,EAAE,KAAK,EAAE,SAAS,EAAE;QACjE,EAAE,IAAI,EAAE,OAAO,EAAE,eAAe,EAAE,SAAS,EAAE,KAAK,EAAE,SAAS,EAAC;KAC7D,CAAC;IACC,cAAM,GAAY;QACrB,KAAK,YAAC,UAA+C;YACjD,UAAU,GAAG,EAAE,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC;YACnC,GAAG,CAAA,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,GAAG,GAAG,UAAU,CAAC,MAAM,EAAE,OAAO,EAAE,CAAC,GAAE,GAAG,EAAE,CAAC,EAAE,EAAC,CAAC;gBAC1D,IAAI,GAAG,GAAG,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,YAAY,EAAE,UAAU,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAA;gBACrE,OAAO,GAAG,UAAU,CAAC,CAAC,CAAC,CAAC;gBACxB,EAAE,CAAA,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC;oBAAC,GAAG,CAAA,CAAC,IAAI,GAAG,IAAI,OAAO,CAAC;wBAAC,OAAO,CAAC,YAAY,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC;gBACrF,IAAI;oBAAC,OAAO,CAAC,YAAY,CAAC,OAAO,CAAC,YAAY,CAAC,MAAM,CAAC,GAAG,OAAO,CAAC;YACrE,CAAC;QACL,CAAC;KACJ,CAAC;IACK,aAAK,GAAoB,EAAE,CAAC;IA0FvC,cAAC;AAAD,CAAC,AAxJD,IAwJC"}
--------------------------------------------------------------------------------
/gulpfile.js:
--------------------------------------------------------------------------------
1 | var gulp = require('gulp'),
2 | minify = require('gulp-minify'),
3 | cssmin = require('gulp-cssmin'),
4 | rename = require('gulp-rename');
5 |
6 |
7 |
8 | gulp.task('minify-css', function(){
9 | gulp.src('build/css/*.css')
10 | .pipe(gulp.dest('dist/css'))
11 | .pipe(cssmin())
12 | .pipe(rename({suffix:'.min'}))
13 | .pipe(gulp.dest('dist/css'))
14 |
15 | });
16 |
17 | gulp.task('minify-js', function(){
18 | gulp.src('build/js/*.js')
19 | .pipe(minify({
20 | min:'.js'
21 | }))
22 | .pipe(gulp.dest('dist/js/'))
23 | gulp.src('build/js/*.map')
24 | .pipe(gulp.dest('dist/js/'))
25 | });
26 |
27 | gulp.task('minify', ['minify-css', 'minify-js']);
--------------------------------------------------------------------------------
/img/message-click-cb.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/binarybaba/prophetjs/2ae09e9934c551c3a7f5292873cbb003ad27aefb/img/message-click-cb.gif
--------------------------------------------------------------------------------
/img/message-default-no-click.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/binarybaba/prophetjs/2ae09e9934c551c3a7f5292873cbb003ad27aefb/img/message-default-no-click.gif
--------------------------------------------------------------------------------
/img/message-error.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/binarybaba/prophetjs/2ae09e9934c551c3a7f5292873cbb003ad27aefb/img/message-error.gif
--------------------------------------------------------------------------------
/img/message-stack-up.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/binarybaba/prophetjs/2ae09e9934c551c3a7f5292873cbb003ad27aefb/img/message-stack-up.gif
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "prophetjs",
3 | "version": "1.0.0",
4 | "description": "A very lean dependency free javascript library to display toast messages on web pages.",
5 | "main": "./dist/js/prophet.js",
6 | "devDependencies": {
7 | "gulp": "^3.9.1",
8 | "gulp-cssmin": "^0.1.7",
9 | "gulp-minify": "0.0.14",
10 | "gulp-rename": "^1.2.2",
11 | "typescript": "^2.0.3"
12 | },
13 | "repository": {
14 | "type": "git",
15 | "url": "git+https://github.com/binarybaba/prophetjs.git"
16 | },
17 | "keywords": [
18 | "notification",
19 | "alert",
20 | "alertify",
21 | "jquery",
22 | "notifications",
23 | "notify",
24 | "snarl",
25 | "snarl notification",
26 | "snarl toasts",
27 | "toast",
28 | "toast notifications",
29 | "toastr",
30 | "toastr alerts",
31 | "toast message"
32 | ],
33 | "author": "Amin Mohamed Ajani",
34 | "license": "MIT",
35 | "bugs": {
36 | "url": "https://github.com/binarybaba/prophetjs/issues"
37 | },
38 | "homepage": "https://github.com/binarybaba/prophetjs#readme"
39 | }
40 |
--------------------------------------------------------------------------------