├── .eslintrc
├── .gitattributes
├── .gitignore
├── .travis.yml
├── LICENSE
├── README.md
├── StripToastr_demo.gif
├── dist
└── ui5lab
│ └── striptoastr
│ ├── StripToastr-dbg.js
│ ├── StripToastr.js
│ ├── library-all.js
│ ├── library-dbg.js
│ ├── library-preload.json
│ └── library.js
├── gulpfile.js
├── index.html
├── karma.conf.js
├── package.json
├── src
└── ui5lab
│ └── striptoastr
│ ├── StripToastr.js
│ └── library.js
└── test
├── libraries.json
└── ui5lab
└── striptoastr
├── index.json
├── qunit
├── StripToastr.js
├── StripToastr.qunit.html
└── testsuite.qunit.html
└── sample
└── StripToastrPlayground.html
/.eslintrc:
--------------------------------------------------------------------------------
1 | {
2 | "env": {
3 | "browser": true
4 | },
5 | "globals": {
6 | "sap": true,
7 | "jQuery": true,
8 | "ok": true,
9 | "strictEqual": true,
10 | "module": true,
11 | "QUnit": true,
12 | "sinon": true
13 | },
14 | "plugins": [
15 | "eslint-plugin-openui5"
16 | ],
17 | "rules": {
18 | "block-scoped-var": 1,
19 | "brace-style": [2, "1tbs", { "allowSingleLine": true }],
20 | "camelcase": 1,
21 | "comma-spacing": 0,
22 | "complexity": [0, 11],
23 | "consistent-return": 1,
24 | "consistent-this": 2,
25 | "curly": [2, "all"],
26 | "default-case": 1,
27 | "dot-notation": 1,
28 | "eol-last": 0,
29 | "eqeqeq": 1,
30 | "strict": 1,
31 | "guard-for-in": 1,
32 | "key-spacing": [0, { "afterColon": true, "beforeColon": false }],
33 | "line-endings": 0,
34 | "max-depth": [0, 4],
35 | "max-len": [0, 80, 4],
36 | "max-nested-callbacks": [1, 3],
37 | "max-params": [0, 3],
38 | "max-statements": [0, 10],
39 | "new-cap": [1, { "capIsNew": false }],
40 | "new-parens": 2,
41 | "no-alert": 2,
42 | "no-array-constructor": 2,
43 | "no-catch-shadow": 2,
44 | "comma-dangle": "error",
45 | "no-delete-var": 2,
46 | "no-div-regex": 2,
47 | "no-empty": 2,
48 | "no-eq-null": 1,
49 | "no-extend-native": 2,
50 | "no-extra-bind": 2,
51 | "no-extra-boolean-cast": 1,
52 | "no-extra-semi": 2,
53 | "no-extra-parens": "error",
54 | "no-fallthrough": 2,
55 | "no-floating-decimal": 2,
56 | "no-implied-eval": 2,
57 | "no-irregular-whitespace": 1,
58 | "no-iterator": 2,
59 | "no-label-var": 2,
60 | "no-labels": 2,
61 | "no-lone-blocks": 2,
62 | "no-lonely-if": 1,
63 | "no-loop-func": 2,
64 | "no-mixed-spaces-and-tabs": [2, true],
65 | "no-multi-spaces": 1,
66 | "no-multi-str": 2,
67 | "no-nested-ternary": 2,
68 | "no-new": 1,
69 | "no-new-object": 2,
70 | "no-new-wrappers": 1,
71 | "no-octal": 2,
72 | "no-octal-escape": 2,
73 | "no-process-exit": 2,
74 | "no-proto": 2,
75 | "no-redeclare": 1,
76 | "no-return-assign": 2,
77 | "no-script-url": 2,
78 | "no-self-compare": 2,
79 | "no-sequences": 2,
80 | "no-shadow": 1,
81 | "no-shadow-restricted-names": 2,
82 | "no-spaced-func": 2,
83 | "no-trailing-spaces": 0,
84 | "no-undef-init": 2,
85 | "no-underscore-dangle": 0,
86 | "no-unreachable": 2,
87 | "semi-spacing": "warn",
88 | "no-unused-expressions": 2,
89 | "no-unused-vars": [2, { "vars": "all", "args": "none" }],
90 | "no-use-before-define": [1, "nofunc"],
91 | "no-warning-comments": [1, { "location": "start", "terms": ["todo", "fixme", "xxx"] }],
92 | "quotes": [1, "double", "avoid-escape"],
93 | "radix": 2,
94 | "keyword-spacing": "error",
95 | "space-infix-ops": 2,
96 | "space-unary-ops": 2,
97 | "space-unary-word-ops": 0,
98 | "valid-jsdoc": [1, { "requireReturn": false }],
99 | "wrap-iife": [2, "any"],
100 | "yoda": [2, "never"]
101 | }
102 | }
--------------------------------------------------------------------------------
/.gitattributes:
--------------------------------------------------------------------------------
1 | # Auto detect text files and perform LF normalization
2 | * text=auto
3 |
4 | # Custom for Visual Studio
5 | *.cs diff=csharp
6 |
7 | # Standard to msysgit
8 | *.doc diff=astextplain
9 | *.DOC diff=astextplain
10 | *.docx diff=astextplain
11 | *.DOCX diff=astextplain
12 | *.dot diff=astextplain
13 | *.DOT diff=astextplain
14 | *.pdf diff=astextplain
15 | *.PDF diff=astextplain
16 | *.rtf diff=astextplain
17 | *.RTF diff=astextplain
18 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # Windows image file caches
2 | Thumbs.db
3 | ehthumbs.db
4 |
5 | # Ignore npm files/folders
6 | node_modules
7 | npm-debug.log
8 |
9 | # Ignore bower folder
10 | bower_components
11 |
12 | #ignore reports
13 | reports
14 |
15 | #ignore vscode settings
16 | .vscode
--------------------------------------------------------------------------------
/.travis.yml:
--------------------------------------------------------------------------------
1 |
2 | language: node_js
3 | node_js:
4 | - "4.1"
5 |
6 | branches:
7 | only:
8 | - master
9 |
10 | before_install:
11 | - npm install -g eslint
12 | - npm install gulp -g
13 |
14 | script:
15 | - npm install
16 | - gulp test
17 |
18 | deploy:
19 | provider: pages
20 | skip_cleanup: true
21 | github_token: $GITHUB_TOKEN # Set in travis-ci.org dashboard
22 | on:
23 | branch: master
24 |
25 | notifications:
26 | email:
27 | - john.patterson@secondphase.com.au
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright (c) 2016 John Patterson
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 | StripToastr - OpenUI5 MessageStrips that Growl
2 |
3 | [](https://travis-ci.org/jasper07/StripToastr)
4 | [](https://coveralls.io/github/jasper07/StripToastr?branch=master)
5 | [](https://opensource.org/licenses/MIT)
6 | [](http://makeapullrequest.com)
7 |
8 |
9 | ===========================================
10 |
11 |
12 | Author
13 | ------
14 | John Patterson
15 | https://github.com/jasper07
16 |
17 | License
18 | -------
19 | MIT
20 |
21 | Use
22 | ---
23 |
24 | ```javascript
25 | StripToastr.notify({
26 | text: "test1"
27 | })
28 | ```
29 |
30 |
31 | Demos
32 | ----
33 |
34 | [
](https://jasper07.secondphase.com.au/StripToastr/)
35 |
36 | https://jasper07.secondphase.com.au/StripToastr/
37 |
38 |
--------------------------------------------------------------------------------
/StripToastr_demo.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jasper07/StripToastr/d3cac2a60f3a4c805d29a66671d2e96a7ec497f0/StripToastr_demo.gif
--------------------------------------------------------------------------------
/dist/ui5lab/striptoastr/StripToastr-dbg.js:
--------------------------------------------------------------------------------
1 | /**
2 | * striptoastr - Message Strips that Growl
3 | * @version v1.0.0
4 | * @link https://github.com/jasper07/StripToastr#readme
5 | * @license MIT
6 | */
7 | sap.ui.define(["sap/m/MessageStrip", "sap/m/MessageStripRenderer", "sap/ui/core/Popup", "sap/ui/layout/VerticalLayout"],
8 | function(MessageStrip, MessageStripRenderer, Popup, VerticalLayout) {
9 | "use strict";
10 | var MessageStripExt = MessageStrip.extend("MessageStripExt", {
11 | //on rerender CSS transition bindings are destroyed
12 | renderer: function(oRm, oControl) {
13 | if (oControl._bClosed) {
14 | oControl.fireClose();
15 | return;
16 | }
17 | MessageStripRenderer.render.apply(this, arguments);
18 | },
19 | onAfterRendering: function() {
20 | this.$().attr("role", "alert");
21 | },
22 | close: function() {
23 | this._bClosed = true;
24 | MessageStrip.prototype.close.apply(this, arguments);
25 | }
26 | });
27 |
28 | var StripToastr = {
29 | sContainerId: "stripToastr-container",
30 |
31 | _oSettings: {
32 | text: null,
33 | showCloseButton: true,
34 | showIcon: true,
35 | customIcon: null,
36 | type: sap.ui.core.MessageType.Information,
37 | link: null,
38 | close: null,
39 | timeOut: 5000,
40 | newestFirst: false,
41 | width: "310px",
42 | position: Popup.Dock.RightTop,
43 | anchor: document,
44 | style: "stripToastr"
45 | },
46 |
47 | /**
48 | * Gets the container that holds toasts
49 | * @param {object} oSettings optional used to create new container
50 | * @return {sap.ui.core.Popup} Popup
51 | */
52 | getContainer: function(oSettings) {
53 | var oContainer = sap.ui.getCore().byId(this.sContainerId);
54 |
55 | if (!oContainer && oSettings) {
56 | oContainer = new VerticalLayout(this.sContainerId, {
57 | width: oSettings.width
58 | });
59 |
60 | var oPopup = new Popup(oContainer);
61 | oPopup.setShadow(false);
62 | oPopup.__bAutoClose = true;
63 | oPopup.open(0, oSettings.position, oSettings.position, oSettings.anchor);
64 | }
65 |
66 | return oContainer;
67 | },
68 |
69 | /**
70 | * Creates the StripToastr instance
71 | * @param {object} oOptions has the constructor properties
72 | * @return {StripToastr} instance of the StripToastr
73 | */
74 | notify: function(oOptions) {
75 | var oSettings = jQuery.extend({}, this._oSettings, oOptions);
76 | var fnAttachClose = function(oEvent) {
77 | oEvent.getSource().setVisible(false);
78 | oEvent.getSource().destroy();
79 | var fnSomeVisible = function(oControl) {
80 | return oControl.getVisible();
81 | };
82 |
83 | if (!this.getContainer().getContent().some(fnSomeVisible)) {
84 | this.destroyContainer();
85 | }
86 |
87 | if (oSettings.close) {
88 | oSettings.close.apply(this);
89 | }
90 | }.bind(this);
91 |
92 | var oControl = new MessageStripExt({
93 | text: oSettings.text,
94 | showCloseButton: oSettings.showCloseButton,
95 | showIcon: oSettings.showIcon,
96 | customIcon: oSettings.customIcon,
97 | type: oSettings.type,
98 | link: oSettings.link,
99 | close: fnAttachClose
100 | });
101 |
102 | oControl.addStyleClass(oSettings.style);
103 |
104 | var oContainer = this.getContainer(oSettings);
105 | if (oSettings.newestFirst) {
106 | oContainer.insertContent(oControl, 0);
107 | } else {
108 | oContainer.addContent(oControl);
109 | }
110 |
111 | if (oSettings.timeOut > 0) {
112 | jQuery.sap.delayedCall(oSettings.timeOut, oControl, "close");
113 | }
114 |
115 | return oControl;
116 | },
117 |
118 | /**
119 | * Clear the container or close the instance
120 | * @param {StripToastr} oControl instance of StripToastr
121 | */
122 | clear: function(oControl) {
123 | if (!oControl) {
124 | this.clearContainer();
125 | } else {
126 | oControl.close();
127 | }
128 | },
129 |
130 | /**
131 | * Detroy the container
132 | */
133 | destroyContainer: function() {
134 | var oContainer = this.getContainer();
135 | if (oContainer) {
136 | oContainer.setVisible(false);
137 | oContainer.destroy();
138 | }
139 | },
140 |
141 | /**
142 | * Clear the container
143 | */
144 | clearContainer: function() {
145 | var oContainer = this.getContainer();
146 |
147 | if (oContainer) {
148 | var aContent = oContainer.getContent();
149 | if (aContent.length === 0) {
150 | this.destroyContainer();
151 | } else {
152 | var fnClear = function(oControl) {
153 | this.clear(oControl);
154 | }.bind(this);
155 |
156 | aContent.forEach(fnClear);
157 | }
158 | }
159 | }
160 | };
161 |
162 | return StripToastr;
163 | });
--------------------------------------------------------------------------------
/dist/ui5lab/striptoastr/StripToastr.js:
--------------------------------------------------------------------------------
1 | /**
2 | * striptoastr - Message Strips that Growl
3 | * @version v1.0.0
4 | * @link https://github.com/jasper07/StripToastr#readme
5 | * @license MIT
6 | */
7 | sap.ui.define(["sap/m/MessageStrip","sap/m/MessageStripRenderer","sap/ui/core/Popup","sap/ui/layout/VerticalLayout"],function(t,e,n,o){"use strict";var i=t.extend("MessageStripExt",{renderer:function(t,n){if(n._bClosed)return void n.fireClose();e.render.apply(this,arguments)},onAfterRendering:function(){this.$().attr("role","alert")},close:function(){this._bClosed=!0,t.prototype.close.apply(this,arguments)}});return{sContainerId:"stripToastr-container",_oSettings:{text:null,showCloseButton:!0,showIcon:!0,customIcon:null,type:sap.ui.core.MessageType.Information,link:null,close:null,timeOut:5e3,newestFirst:!1,width:"310px",position:n.Dock.RightTop,anchor:document,style:"stripToastr"},getContainer:function(t){var e=sap.ui.getCore().byId(this.sContainerId);if(!e&&t){e=new o(this.sContainerId,{width:t.width});var i=new n(e);i.setShadow(!1),i.__bAutoClose=!0,i.open(0,t.position,t.position,t.anchor)}return e},notify:function(t){var e=jQuery.extend({},this._oSettings,t),n=function(t){t.getSource().setVisible(!1),t.getSource().destroy();var n=function(t){return t.getVisible()};this.getContainer().getContent().some(n)||this.destroyContainer(),e.close&&e.close.apply(this)}.bind(this),o=new i({text:e.text,showCloseButton:e.showCloseButton,showIcon:e.showIcon,customIcon:e.customIcon,type:e.type,link:e.link,close:n});o.addStyleClass(e.style);var s=this.getContainer(e);return e.newestFirst?s.insertContent(o,0):s.addContent(o),e.timeOut>0&&jQuery.sap.delayedCall(e.timeOut,o,"close"),o},clear:function(t){t?t.close():this.clearContainer()},destroyContainer:function(){var t=this.getContainer();t&&(t.setVisible(!1),t.destroy())},clearContainer:function(){var t=this.getContainer();if(t){var e=t.getContent();if(0===e.length)this.destroyContainer();else{var n=function(t){this.clear(t)}.bind(this);e.forEach(n)}}}}});
--------------------------------------------------------------------------------
/dist/ui5lab/striptoastr/library-all.js:
--------------------------------------------------------------------------------
1 | /**
2 | * striptoastr - Message Strips that Growl
3 | * @version v1.0.0
4 | * @link https://github.com/jasper07/StripToastr#readme
5 | * @license MIT
6 | */
7 | sap.ui.define(["jquery.sap.global","sap/ui/core/library"],function(r,i){"use strict";return sap.ui.getCore().initLibrary({name:"ui5lab.striptoastr",dependencies:["sap.ui.core"],interfaces:[],controls:["ui5lab.striptoastr.StripToastr"],elements:[],noLibraryCSS:!1,version:"${version}"}),ui5lab.striptoastr});
8 | /**
9 | * striptoastr - Message Strips that Growl
10 | * @version v1.0.0
11 | * @link https://github.com/jasper07/StripToastr#readme
12 | * @license MIT
13 | */
14 | sap.ui.define(["sap/m/MessageStrip","sap/m/MessageStripRenderer","sap/ui/core/Popup","sap/ui/layout/VerticalLayout"],function(t,e,n,o){"use strict";var i=t.extend("MessageStripExt",{renderer:function(t,n){if(n._bClosed)return void n.fireClose();e.render.apply(this,arguments)},onAfterRendering:function(){this.$().attr("role","alert")},close:function(){this._bClosed=!0,t.prototype.close.apply(this,arguments)}});return{sContainerId:"stripToastr-container",_oSettings:{text:null,showCloseButton:!0,showIcon:!0,customIcon:null,type:sap.ui.core.MessageType.Information,link:null,close:null,timeOut:5e3,newestFirst:!1,width:"310px",position:n.Dock.RightTop,anchor:document,style:"stripToastr"},getContainer:function(t){var e=sap.ui.getCore().byId(this.sContainerId);if(!e&&t){e=new o(this.sContainerId,{width:t.width});var i=new n(e);i.setShadow(!1),i.__bAutoClose=!0,i.open(0,t.position,t.position,t.anchor)}return e},notify:function(t){var e=jQuery.extend({},this._oSettings,t),n=function(t){t.getSource().setVisible(!1),t.getSource().destroy();var n=function(t){return t.getVisible()};this.getContainer().getContent().some(n)||this.destroyContainer(),e.close&&e.close.apply(this)}.bind(this),o=new i({text:e.text,showCloseButton:e.showCloseButton,showIcon:e.showIcon,customIcon:e.customIcon,type:e.type,link:e.link,close:n});o.addStyleClass(e.style);var s=this.getContainer(e);return e.newestFirst?s.insertContent(o,0):s.addContent(o),e.timeOut>0&&jQuery.sap.delayedCall(e.timeOut,o,"close"),o},clear:function(t){t?t.close():this.clearContainer()},destroyContainer:function(){var t=this.getContainer();t&&(t.setVisible(!1),t.destroy())},clearContainer:function(){var t=this.getContainer();if(t){var e=t.getContent();if(0===e.length)this.destroyContainer();else{var n=function(t){this.clear(t)}.bind(this);e.forEach(n)}}}}});
--------------------------------------------------------------------------------
/dist/ui5lab/striptoastr/library-dbg.js:
--------------------------------------------------------------------------------
1 | /**
2 | * striptoastr - Message Strips that Growl
3 | * @version v1.0.0
4 | * @link https://github.com/jasper07/StripToastr#readme
5 | * @license MIT
6 | */
7 | /**
8 | * Initialization Code and shared classes of library ui5lab.striptoastr.
9 | */
10 | sap.ui.define(["jquery.sap.global", "sap/ui/core/library"],
11 | function(jQuery, library1) {
12 | "use strict";
13 |
14 |
15 | /**
16 | * UI5 library: ui5lab.striptoastr.
17 | *
18 | * @namespace
19 | * @name ui5lab.striptoastr
20 | * @public
21 | */
22 |
23 | // library dependencies
24 |
25 | // delegate further initialization of this library to the Core
26 | sap.ui.getCore().initLibrary({
27 | name: "ui5lab.striptoastr",
28 | dependencies: ["sap.ui.core"],
29 | interfaces: [],
30 | controls: [
31 | "ui5lab.striptoastr.StripToastr"
32 | ],
33 | elements: [],
34 | noLibraryCSS: false,
35 | version: "${version}"
36 | });
37 |
38 | return ui5lab.striptoastr;
39 | });
--------------------------------------------------------------------------------
/dist/ui5lab/striptoastr/library-preload.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "ui5lab.striptoastr.library-preload",
3 | "version": "2.0",
4 | "modules": {
5 | "ui5lab/striptoastr/library.js": "/**\n * striptoastr - Message Strips that Growl\n * @version v1.0.0\n * @link https://github.com/jasper07/StripToastr#readme\n * @license MIT\n */\nsap.ui.define([\"jquery.sap.global\",\"sap/ui/core/library\"],function(r,i){\"use strict\";return sap.ui.getCore().initLibrary({name:\"ui5lab.striptoastr\",dependencies:[\"sap.ui.core\"],interfaces:[],controls:[\"ui5lab.striptoastr.StripToastr\"],elements:[],noLibraryCSS:!1,version:\"${version}\"}),ui5lab.striptoastr});",
6 | "ui5lab/striptoastr/StripToastr.js": "/**\n * striptoastr - Message Strips that Growl\n * @version v1.0.0\n * @link https://github.com/jasper07/StripToastr#readme\n * @license MIT\n */\nsap.ui.define([\"sap/m/MessageStrip\",\"sap/m/MessageStripRenderer\",\"sap/ui/core/Popup\",\"sap/ui/layout/VerticalLayout\"],function(t,e,n,o){\"use strict\";var i=t.extend(\"MessageStripExt\",{renderer:function(t,n){if(n._bClosed)return void n.fireClose();e.render.apply(this,arguments)},onAfterRendering:function(){this.$().attr(\"role\",\"alert\")},close:function(){this._bClosed=!0,t.prototype.close.apply(this,arguments)}});return{sContainerId:\"stripToastr-container\",_oSettings:{text:null,showCloseButton:!0,showIcon:!0,customIcon:null,type:sap.ui.core.MessageType.Information,link:null,close:null,timeOut:5e3,newestFirst:!1,width:\"310px\",position:n.Dock.RightTop,anchor:document,style:\"stripToastr\"},getContainer:function(t){var e=sap.ui.getCore().byId(this.sContainerId);if(!e&&t){e=new o(this.sContainerId,{width:t.width});var i=new n(e);i.setShadow(!1),i.__bAutoClose=!0,i.open(0,t.position,t.position,t.anchor)}return e},notify:function(t){var e=jQuery.extend({},this._oSettings,t),n=function(t){t.getSource().setVisible(!1),t.getSource().destroy();var n=function(t){return t.getVisible()};this.getContainer().getContent().some(n)||this.destroyContainer(),e.close&&e.close.apply(this)}.bind(this),o=new i({text:e.text,showCloseButton:e.showCloseButton,showIcon:e.showIcon,customIcon:e.customIcon,type:e.type,link:e.link,close:n});o.addStyleClass(e.style);var s=this.getContainer(e);return e.newestFirst?s.insertContent(o,0):s.addContent(o),e.timeOut>0&&jQuery.sap.delayedCall(e.timeOut,o,\"close\"),o},clear:function(t){t?t.close():this.clearContainer()},destroyContainer:function(){var t=this.getContainer();t&&(t.setVisible(!1),t.destroy())},clearContainer:function(){var t=this.getContainer();if(t){var e=t.getContent();if(0===e.length)this.destroyContainer();else{var n=function(t){this.clear(t)}.bind(this);e.forEach(n)}}}}});"
7 | }
8 | }
--------------------------------------------------------------------------------
/dist/ui5lab/striptoastr/library.js:
--------------------------------------------------------------------------------
1 | /**
2 | * striptoastr - Message Strips that Growl
3 | * @version v1.0.0
4 | * @link https://github.com/jasper07/StripToastr#readme
5 | * @license MIT
6 | */
7 | sap.ui.define(["jquery.sap.global","sap/ui/core/library"],function(r,i){"use strict";return sap.ui.getCore().initLibrary({name:"ui5lab.striptoastr",dependencies:["sap.ui.core"],interfaces:[],controls:["ui5lab.striptoastr.StripToastr"],elements:[],noLibraryCSS:!1,version:"${version}"}),ui5lab.striptoastr});
--------------------------------------------------------------------------------
/gulpfile.js:
--------------------------------------------------------------------------------
1 | /* eslint-env es6, eslint-disable no-var, prefer-arrow-callback */
2 | /*eslint strict: [2, "never"]*/
3 |
4 | const gulp = require("gulp");
5 | const eslint = require("gulp-eslint");
6 | const ui5preload = require("gulp-ui5-preload");
7 | const uglify = require("gulp-uglify");
8 | const concat = require("gulp-concat");
9 | const clean = require("gulp-clean");
10 | const rename = require("gulp-rename");
11 | const header = require("gulp-header");
12 | const streamify = require("gulp-streamify");
13 | const sequence = require("run-sequence");
14 | const pkg = require("./package.json");
15 |
16 | const libNS = "ui5lab.striptoastr";
17 |
18 | const filePath = {
19 | src: "./src/" + libNS.replace(".", "/") + "/*",
20 | test: "./test/*.js",
21 | dist: "./dist/",
22 | dest: "./dist/" + libNS.replace(".", "/")
23 | };
24 |
25 | const banner = ["/**",
26 | " * <%= pkg.name %> - <%= pkg.description %>",
27 | " * @version v<%= pkg.version %>",
28 | " * @link <%= pkg.homepage %>",
29 | " * @license <%= pkg.license %>",
30 | " */",
31 | ""
32 | ].join("\n");
33 |
34 | /**
35 | * lint code
36 | * @return {Stream}
37 | */
38 | gulp.task("lint", () => {
39 | gulp.src([filePath.src])
40 | .pipe(eslint())
41 | .pipe(eslint.format())
42 | .pipe(eslint.failAfterError());
43 | });
44 |
45 | /**
46 | * Run specs once and exit
47 | * To start servers and run midway specs as well:
48 | * @return {Stream}
49 | */
50 | gulp.task("test", ["lint"], (done) => {
51 | startTests(true /*singleRun*/ , done);
52 | });
53 |
54 | /**
55 | * Run specs and wait.
56 | * Watch for file changes and re-run tests on each change
57 | */
58 | gulp.task("tdd", (done) => {
59 | startTests(false /*singleRun*/ , done);
60 | });
61 |
62 | /**
63 | * Start the tests using karma.
64 | * @param {boolean} singleRun - True means run once and end (CI), or keep running (dev)
65 | * @param {Function} done - Callback to fire when karma is done
66 | * @return {undefined}
67 | */
68 | function startTests(singleRun, done) {
69 | var Server = require("karma").Server;
70 |
71 | const karmaCompleted = (karmaResult) => {
72 | console.log("Karma completed");
73 |
74 | if (karmaResult === 1) {
75 | done("karma: tests failed with code " + karmaResult);
76 | } else {
77 | done();
78 | }
79 | }
80 |
81 | new Server({
82 | configFile: __dirname + "/karma.conf.js",
83 | singleRun: !!singleRun
84 | }, karmaCompleted).start();
85 | }
86 |
87 | /**
88 | * clean dest folder
89 | */
90 | gulp.task("clean", () => {
91 | return gulp.src(filePath.dist, {
92 | read: false
93 | }).pipe(clean());
94 | });
95 |
96 | /**
97 | * create script dbg files
98 | */
99 | gulp.task("scripts-dbg", ["lint", "clean"], () => {
100 | return gulp.src(filePath.src)
101 | .pipe(header(banner, { pkg: pkg }))
102 | .pipe(rename({ suffix: "-dbg" }))
103 | .pipe(gulp.dest(filePath.dest))
104 | .on("error", (err) => {
105 | console.error("Error in scripts-dbg task", err.toString());
106 | });
107 | });
108 |
109 | /**
110 | * create minified scripts
111 | */
112 | gulp.task("scripts-min", ["lint", "clean"], () => {
113 | const options = {
114 | preserveComments: "license"
115 | };
116 | return gulp.src(filePath.src)
117 | .pipe(header(banner, { pkg: pkg }))
118 | .pipe(streamify(uglify(options)))
119 | .pipe(gulp.dest(filePath.dest))
120 | .pipe(concat("library-all.js"))
121 | .pipe(gulp.dest(filePath.dest));
122 | });
123 |
124 | /**
125 | * create ui5 library preload json file
126 | */
127 | gulp.task("buildlibrary", ["lint", "clean", "scripts-min", "scripts-dbg"], () => {
128 | return gulp.src([filePath.dest + "/**/!(*-dbg.js|*-all.js)"])
129 | .pipe(ui5preload({ base: "dist/ui5lab/striptoastr", namespace: libNS, isLibrary: true }))
130 | .pipe(gulp.dest(filePath.dest));
131 | });
132 |
133 | /**
134 | * build task
135 | */
136 | gulp.task("build", (cb) => {
137 | sequence(["lint", "test"], "buildlibrary", cb);
138 | });
--------------------------------------------------------------------------------
/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
232 |
233 |
--------------------------------------------------------------------------------
/karma.conf.js:
--------------------------------------------------------------------------------
1 | module.exports = function(config) {
2 | "use strict";
3 | config.set({
4 |
5 | // base path that will be used to resolve all patterns (eg. files, exclude)
6 | basePath: "",
7 |
8 | // How long will Karma wait for a message from a browser before disconnecting from it (in ms).
9 | browserNoActivityTimeout: 2000000,
10 |
11 | // frameworks to use
12 | // available frameworks: https://npmjs.org/browse/keyword/karma-adapter
13 | frameworks: ["openui5", "qunit"],
14 |
15 | // list of files / patterns to load in the browser
16 | files: [
17 | { pattern: "src/ui5lab/striptoastr/**", included: false, served: true, watched: false, nocache: false },
18 | "test/ui5lab/striptoastr/qunit/StripToastr.js",
19 | { pattern: "test/ui5lab/striptoastr/qunit/**/*.*", included: false, served: true }
20 | ],
21 |
22 | // list of files to exclude
23 | exclude: [
24 | "dist/**/"
25 | ],
26 |
27 | // In case an absolute URL is used at some point of the code, a proxy configuration is required.
28 | proxies: {
29 | "/src/": "/base/src/",
30 | "/test/": "/base/test/"
31 | },
32 |
33 | // test results reporter to use
34 | // available reporters: https://npmjs.org/browse/keyword/karma-reporter
35 | reporters: ["progress", "coverage", "coveralls"],
36 |
37 | // source files, that you wanna generate coverage for
38 | // do not include tests or libraries
39 | // (these files will be instrumented by Istanbul)
40 | preprocessors: {
41 | "src/**/": ["coverage"]
42 | },
43 |
44 | // Configuration of coverage reporter
45 | // check coverage thresholds
46 | // output summary to the CLI
47 | // output lcov for coveralls
48 | coverageReporter: {
49 | check: {
50 | global: {
51 | statements: 60,
52 | branches: 60,
53 | functions: 60,
54 | lines: 60,
55 | excludes: []
56 | }
57 | },
58 | dir: "reports/coverage",
59 | subdir: function() {
60 | return "";
61 | },
62 | reporters: [{
63 | type: "text-summary"
64 | }, {
65 | type: "html",
66 | subdir: "html"
67 | }, {
68 | type: "lcovonly",
69 | subdir: "lcov"
70 | }]
71 | },
72 |
73 | // start these browsers
74 | // available browser launchers: https://npmjs.org/browse/keyword/karma-launcher
75 | browsers: ["PhantomJS_custom"], //*/ ["Chrome"],
76 |
77 | // Have phantomjs exit if a ResourceError is encountered (useful if karma exits without killing phantom)
78 | phantomjsLauncher: {
79 | exitOnResourceError: false
80 | },
81 |
82 | // you can define custom flags
83 | customLaunchers: {
84 | "PhantomJS_custom": {
85 | base: "PhantomJS",
86 | options: {
87 | viewportSize: {
88 | width: 1440,
89 | height: 900
90 | },
91 | customHeaders: {
92 | DNT: "1"
93 | },
94 | windowName: "my-window",
95 | settings: {
96 | webSecurityEnabled: false,
97 | userAgent: "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/54.0.2840.87 Safari/537.36"
98 | }
99 | },
100 | flags: ["--load-images=true", "--debug=false", "--disk-cache=false"],
101 | debug: true
102 | }
103 | },
104 |
105 | openui5: {
106 | path: "https://openui5.hana.ondemand.com/1.40.4/resources/sap-ui-core.js",
107 | useMockServer: false
108 | },
109 |
110 | // How the client should execute the test, like run in an iframe, capture the console and so on.
111 | client: {
112 | captureConsole: true,
113 | clearContext: true,
114 | useIframe: false,
115 | qunit: {
116 | showUI: true,
117 | testTimeout: 15000,
118 | autostart: false,
119 | autoload: false
120 | },
121 | openui5: {
122 | config: {
123 | // theme: "sap_belize",
124 | libs: "sap.m, ui5lab.striptoastr",
125 | // compatVersion: "edge",
126 | // frameOptions: "allow",
127 | // preload: "async",
128 | // animation: "false",
129 | debug: "false",
130 | resourceroots: {
131 | "ui5lab": "/src/ui5lab",
132 | "test.unit": "/test/ui5lab/striptoastr/qunit"
133 | }
134 | }
135 | }
136 | },
137 |
138 | // enable / disable colors in the output (reporters and logs)
139 | colors: true,
140 |
141 | // level of logging
142 | // possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG
143 | logLevel: config.LOG_ERROR,
144 |
145 | // enable / disable watching file and executing tests whenever any file changes
146 | autoWatch: false,
147 |
148 | // Continuous Integration mode
149 | // if true, Karma captures browsers, runs the tests and exits
150 | singleRun: false,
151 |
152 | // Concurrency level
153 | // how many browser should be started simultaneous
154 | concurrency: Infinity,
155 |
156 | hostname: "127.0.0.1",
157 |
158 | port: 9876
159 | });
160 | };
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "striptoastr",
3 | "version": "1.0.0",
4 | "description": "Message Strips that Growl",
5 | "main": "src/StripToastr.js",
6 | "scripts": {
7 | "test": "gulp test"
8 | },
9 | "repository": {
10 | "type": "git",
11 | "url": "git+https://github.com/jasper07/StripToastr.git"
12 | },
13 | "keywords": [
14 | "openui5",
15 | "sapui5",
16 | "growl",
17 | "toaster"
18 | ],
19 | "author": "John Patterson",
20 | "license": "MIT",
21 | "bugs": {
22 | "url": "https://github.com/jasper07/StripToastr/issues"
23 | },
24 | "homepage": "https://github.com/jasper07/StripToastr#readme",
25 | "devDependencies": {
26 | "eslint-plugin-openui5": "^0.1.0",
27 | "gulp": "^3.9.1",
28 | "gulp-clean": "^0.3.2",
29 | "gulp-concat": "^2.6.1",
30 | "gulp-eslint": "^3.0.1",
31 | "gulp-header": "^1.8.8",
32 | "gulp-rename": "^1.2.2",
33 | "gulp-streamify": "^1.0.2",
34 | "gulp-uglify": "^2.1.2",
35 | "gulp-ui5-preload": "^1.3.1",
36 | "karma": "^1.7.0",
37 | "karma-chrome-launcher": "^2.1.1",
38 | "karma-coverage": "^1.1.1",
39 | "karma-coveralls": "^1.1.2",
40 | "karma-openui5": "^0.2.2",
41 | "karma-phantomjs-launcher": "^1.0.4",
42 | "karma-qunit": "^1.2.1",
43 | "qunitjs": "^1.18.0",
44 | "run-sequence": "^1.2.2"
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/src/ui5lab/striptoastr/StripToastr.js:
--------------------------------------------------------------------------------
1 | sap.ui.define(["sap/m/MessageStrip", "sap/m/MessageStripRenderer", "sap/ui/core/Popup", "sap/ui/layout/VerticalLayout"],
2 | function(MessageStrip, MessageStripRenderer, Popup, VerticalLayout) {
3 | "use strict";
4 | var MessageStripExt = MessageStrip.extend("MessageStripExt", {
5 | //on rerender CSS transition bindings are destroyed
6 | renderer: function(oRm, oControl) {
7 | if (oControl._bClosed) {
8 | oControl.fireClose();
9 | return;
10 | }
11 | MessageStripRenderer.render.apply(this, arguments);
12 | },
13 | onAfterRendering: function() {
14 | this.$().attr("role", "alert");
15 | },
16 | close: function() {
17 | this._bClosed = true;
18 | MessageStrip.prototype.close.apply(this, arguments);
19 | }
20 | });
21 |
22 | var StripToastr = {
23 | sContainerId: "stripToastr-container",
24 |
25 | _oSettings: {
26 | text: null,
27 | showCloseButton: true,
28 | showIcon: true,
29 | customIcon: null,
30 | type: sap.ui.core.MessageType.Information,
31 | link: null,
32 | close: null,
33 | timeOut: 5000,
34 | newestFirst: false,
35 | width: "310px",
36 | position: Popup.Dock.RightTop,
37 | anchor: document,
38 | style: "stripToastr"
39 | },
40 |
41 | /**
42 | * Gets the container that holds toasts
43 | * @param {object} oSettings optional used to create new container
44 | * @return {sap.ui.core.Popup} Popup
45 | */
46 | getContainer: function(oSettings) {
47 | var oContainer = sap.ui.getCore().byId(this.sContainerId);
48 |
49 | if (!oContainer && oSettings) {
50 | oContainer = new VerticalLayout(this.sContainerId, {
51 | width: oSettings.width
52 | });
53 |
54 | var oPopup = new Popup(oContainer);
55 | oPopup.setShadow(false);
56 | oPopup.__bAutoClose = true;
57 | oPopup.open(0, oSettings.position, oSettings.position, oSettings.anchor);
58 | }
59 |
60 | return oContainer;
61 | },
62 |
63 | /**
64 | * Creates the StripToastr instance
65 | * @param {object} oOptions has the constructor properties
66 | * @return {StripToastr} instance of the StripToastr
67 | */
68 | notify: function(oOptions) {
69 | var oSettings = jQuery.extend({}, this._oSettings, oOptions);
70 | var fnAttachClose = function(oEvent) {
71 | oEvent.getSource().setVisible(false);
72 | oEvent.getSource().destroy();
73 | var fnSomeVisible = function(oControl) {
74 | return oControl.getVisible();
75 | };
76 |
77 | if (!this.getContainer().getContent().some(fnSomeVisible)) {
78 | this.destroyContainer();
79 | }
80 |
81 | if (oSettings.close) {
82 | oSettings.close.apply(this);
83 | }
84 | }.bind(this);
85 |
86 | var oControl = new MessageStripExt({
87 | text: oSettings.text,
88 | showCloseButton: oSettings.showCloseButton,
89 | showIcon: oSettings.showIcon,
90 | customIcon: oSettings.customIcon,
91 | type: oSettings.type,
92 | link: oSettings.link,
93 | close: fnAttachClose
94 | });
95 |
96 | oControl.addStyleClass(oSettings.style);
97 |
98 | var oContainer = this.getContainer(oSettings);
99 | if (oSettings.newestFirst) {
100 | oContainer.insertContent(oControl, 0);
101 | } else {
102 | oContainer.addContent(oControl);
103 | }
104 |
105 | if (oSettings.timeOut > 0) {
106 | jQuery.sap.delayedCall(oSettings.timeOut, oControl, "close");
107 | }
108 |
109 | return oControl;
110 | },
111 |
112 | /**
113 | * Clear the container or close the instance
114 | * @param {StripToastr} oControl instance of StripToastr
115 | */
116 | clear: function(oControl) {
117 | if (!oControl) {
118 | this.clearContainer();
119 | } else {
120 | oControl.close();
121 | }
122 | },
123 |
124 | /**
125 | * Detroy the container
126 | */
127 | destroyContainer: function() {
128 | var oContainer = this.getContainer();
129 | if (oContainer) {
130 | oContainer.setVisible(false);
131 | oContainer.destroy();
132 | }
133 | },
134 |
135 | /**
136 | * Clear the container
137 | */
138 | clearContainer: function() {
139 | var oContainer = this.getContainer();
140 |
141 | if (oContainer) {
142 | var aContent = oContainer.getContent();
143 | if (aContent.length === 0) {
144 | this.destroyContainer();
145 | } else {
146 | var fnClear = function(oControl) {
147 | this.clear(oControl);
148 | }.bind(this);
149 |
150 | aContent.forEach(fnClear);
151 | }
152 | }
153 | }
154 | };
155 |
156 | return StripToastr;
157 | });
--------------------------------------------------------------------------------
/src/ui5lab/striptoastr/library.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Initialization Code and shared classes of library ui5lab.striptoastr.
3 | */
4 | sap.ui.define(["jquery.sap.global", "sap/ui/core/library"],
5 | function(jQuery, library1) {
6 | "use strict";
7 |
8 |
9 | /**
10 | * UI5 library: ui5lab.striptoastr.
11 | *
12 | * @namespace
13 | * @name ui5lab.striptoastr
14 | * @public
15 | */
16 |
17 | // library dependencies
18 |
19 | // delegate further initialization of this library to the Core
20 | sap.ui.getCore().initLibrary({
21 | name: "ui5lab.striptoastr",
22 | dependencies: ["sap.ui.core"],
23 | interfaces: [],
24 | controls: [
25 | "ui5lab.striptoastr.StripToastr"
26 | ],
27 | elements: [],
28 | noLibraryCSS: false,
29 | version: "${version}"
30 | });
31 |
32 | return ui5lab.striptoastr;
33 | });
--------------------------------------------------------------------------------
/test/libraries.json:
--------------------------------------------------------------------------------
1 | {
2 | "libraries": [
3 | "ui5lab.striptoastr"
4 | ]
5 | }
--------------------------------------------------------------------------------
/test/ui5lab/striptoastr/index.json:
--------------------------------------------------------------------------------
1 | {
2 | "ui5lab.striptoastr": {
3 | "icon": "sap-icon://ui-notifications",
4 | "name": "StripToastr",
5 | "description": "Message Strips that Growl",
6 | "source": "https://github.com/jasper07/StripToastr.git",
7 | "documentation": "https://github.com/jasper07/StripToastr#readme",
8 | "demo": "https://jasper07.secondphase.com.au/StripToastr/",
9 | "version": "1.0.0",
10 | "license": "MIT",
11 | "content": {
12 | "StripToastr": {
13 | "id": "StripToastr",
14 | "name": "StripToastr",
15 | "type": "control",
16 | "version": "1.0.0",
17 | "description": "An implementation of growl toasters for ui5",
18 | "samples": [{
19 | "id": "StripToastrPlayground",
20 | "name": "StripToastr Playground",
21 | "description": "An interactive playground for StripToastr"
22 | }]
23 | }
24 | }
25 | }
26 | }
--------------------------------------------------------------------------------
/test/ui5lab/striptoastr/qunit/StripToastr.js:
--------------------------------------------------------------------------------
1 | sap.ui.require([
2 | "ui5lab/striptoastr/StripToastr",
3 | "sap/ui/thirdparty/sinon",
4 | "sap/ui/thirdparty/sinon-qunit"
5 | ], function(StripToastr) {
6 | "use strict";
7 | sinon.config.useFakeTimers = false;
8 | var oCore = sap.ui.getCore();
9 |
10 | module("StripToastr basics", {
11 | teardown: function() {
12 | StripToastr.clear();
13 | oCore.applyChanges();
14 | }
15 | });
16 |
17 | test("should be rendered and have alert role", function() {
18 | // Arrange
19 | var oToast = StripToastr.notify({ text: "test1" });
20 |
21 | oCore.applyChanges();
22 |
23 | // Assert
24 | ok(oToast, "created");
25 | equal(oToast.$().attr("role"), "alert", "The alert role is set");
26 | });
27 |
28 | test("should show the newest message first", function() {
29 | // Arrange
30 | StripToastr._oSettings.newestFirst = true;
31 |
32 | // Act
33 | var aTexts = ["test1", "test2", "test3"]
34 |
35 | aTexts.forEach(function(sText) {
36 | StripToastr.notify({ text: sText });
37 | });
38 |
39 | oCore.applyChanges();
40 |
41 | // Assert
42 | var oContent = StripToastr.getContainer().getContent();
43 | var iLast = oContent.length - 1;
44 | var iFirst = 0;
45 | equal(oContent[iFirst].getText(), aTexts[iLast], "first message equals last text");
46 | equal(oContent[iLast].getText(), aTexts[iFirst], "last message equals first text");
47 | StripToastr._oSettings.newestFirst = false;
48 | });
49 |
50 | test("should trigger callback on close", function(assert) {
51 | // Arrange
52 | var done = assert.async();
53 | var delay = 1000;
54 | var fnCloseCallBackSpy = this.spy();
55 |
56 | var oControl = StripToastr.notify({
57 | text: "test1",
58 | close: fnCloseCallBackSpy
59 | });
60 |
61 | // Act
62 | oControl.close();
63 |
64 | // Assert
65 | setTimeout(function() {
66 | equal(fnCloseCallBackSpy.callCount, 1, "Close Callback reached");
67 | done();
68 | }, delay);
69 | });
70 |
71 | module("StripToast clear messages feature", {
72 | teardown: function() {
73 | StripToastr.clear();
74 | oCore.applyChanges();
75 | }
76 | });
77 |
78 | test("should destroy container if nothing to clear", function(assert) {
79 | // Arrange
80 | var delay = 500;
81 | var done = assert.async();
82 | var oContainer = StripToastr.getContainer({
83 | position: "left bottom",
84 | anchor: document
85 | });
86 | oCore.applyChanges();
87 | ok(oContainer.$(), "Container rendered");
88 | equal(oContainer.getContent().length, 0, "Container empty");
89 |
90 | // Act
91 | StripToastr.clear();
92 | // Assert
93 | setTimeout(function() {
94 | equal(oContainer.$().length, 0, "Container DOM was destroyed");
95 | done();
96 | }, delay);
97 | });
98 |
99 | test("should clear all shown messages and then destroy container", function(assert) {
100 | // Arrange
101 | var delay = 1000;
102 | var done = assert.async();
103 | ["test1", "test2", "test3"].map(function(sText) {
104 | return StripToastr.notify({ text: sText });
105 | })
106 |
107 | oCore.applyChanges();
108 | // Act
109 | StripToastr.clear();
110 | // Assert
111 | setTimeout(function() {
112 | var oContainer = StripToastr.getContainer();
113 | equal(oContainer, undefined, "Container was destroyed also");
114 | done();
115 | }, delay);
116 |
117 | });
118 |
119 | test("should show 3 messags and clear 2nd message only", function(assert) {
120 | // Arrange
121 | var delay = 1000;
122 | var done = assert.async();
123 |
124 | var aTexts = ["test1", "test2", "test3"];
125 |
126 | var aMessages = aTexts.map(function(sText) {
127 | return StripToastr.notify({ text: sText });
128 | });
129 |
130 | oCore.applyChanges();
131 | //Act
132 | StripToastr.clear(aMessages[1]); //clear second message
133 | // Assert
134 | setTimeout(function() {
135 | var aContent = StripToastr.getContainer().getContent();
136 | var aResults = aContent.map(function(oContent) { return oContent.getText() });
137 | var aExpected = aTexts.filter(function(_, i) { return i !== 1 });
138 | equal(aContent.length, 2, "Container has 2 controls");
139 | deepEqual(aResults, aExpected, "Container is missing second message");
140 | done();
141 | }, delay);
142 |
143 | });
144 |
145 | // Positioning started failing as the calculations get adjusted by Qunit runner
146 | module("StripToastr positioning", {
147 | teardown: function() {
148 | StripToastr.destroyContainer();
149 | oCore.applyChanges();
150 | }
151 | });
152 |
153 | QUnit.skip("should show message in Top right", function(assert) {
154 | // Arrange
155 | StripToastr.notify({
156 | text: "test1",
157 | position: "right top"
158 | });
159 |
160 | oCore.applyChanges();
161 |
162 | //Act
163 | var oContainer = StripToastr.getContainer();
164 | var oDomRef = oContainer.$();
165 |
166 | // Assert
167 | equal(oDomRef.css("right"), "0px", "Right 0px");
168 | equal(oDomRef.css("top"), "0px", "Top 0px");
169 | });
170 |
171 | QUnit.skip("should show message in Top left", function(assert) {
172 | // Arrange
173 | StripToastr.notify({
174 | text: "test1",
175 | position: "left top"
176 | });
177 |
178 | oCore.applyChanges();
179 |
180 | //Act
181 | var oContainer = StripToastr.getContainer();
182 | var oDomRef = oContainer.$();
183 |
184 | // Assert
185 | equal(oDomRef.css("left"), "0px", "Left 0px");
186 | equal(oDomRef.css("top"), "0px", "Top 0px");
187 | });
188 |
189 | QUnit.skip("should show message in Bottom right", function(assert) {
190 | // Arrange
191 | StripToastr.notify({
192 | text: "test1",
193 | position: "right bottom"
194 | });
195 |
196 | oCore.applyChanges();
197 |
198 | //Act
199 | var oContainer = StripToastr.getContainer();
200 | var oDomRef = oContainer.$();
201 |
202 | // Assert
203 | var iTop = jQuery(window).height() - oDomRef.height();
204 | equal(oDomRef.css("right"), "0px", "Right 0px");
205 | equal(parseFloat(oDomRef.css("top")), iTop, "Top " + iTop + "px");
206 | });
207 |
208 | QUnit.skip("should show message in Bottom left", function(assert) {
209 | // Arrange
210 | StripToastr.notify({
211 | text: "test1",
212 | position: "left bottom"
213 | });
214 |
215 | oCore.applyChanges();
216 |
217 | //Act
218 | var oContainer = StripToastr.getContainer();
219 | var oDomRef = oContainer.$();
220 |
221 | // Assert
222 | var iTop = jQuery(window).height() - oDomRef.height();
223 | equal(oDomRef.css("left"), "0px", "Left 0px");
224 | equal(parseFloat(oDomRef.css("top")), iTop, "Top " + iTop + "px");
225 | });
226 |
227 | QUnit.skip("should show message in Center center", function(assert) {
228 | // Arrange
229 | StripToastr.notify({
230 | text: "test1",
231 | position: "center center"
232 | });
233 |
234 | oCore.applyChanges();
235 |
236 | //Act
237 | var oContainer = StripToastr.getContainer();
238 | var oDomRef = oContainer.$();
239 |
240 | // Assert
241 | var iLeft = (jQuery(window).width() - oDomRef.width()) / 2;
242 | var iTop = (jQuery(window).height() - oDomRef.height()) / 2;
243 | equal(parseFloat(oDomRef.css("left")), iLeft, "Left " + iLeft + "px");
244 | equal(parseFloat(oDomRef.css("top")), iTop, "Top " + iTop + "px");
245 | });
246 | });
--------------------------------------------------------------------------------
/test/ui5lab/striptoastr/qunit/StripToastr.qunit.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
239 |
240 |
--------------------------------------------------------------------------------