mirror of
https://github.com/documize/community.git
synced 2025-08-07 22:45:24 +02:00
Add waitToDisappear helper and minor cleanup
This commit is contained in:
parent
81ecb75391
commit
78e22379dc
4 changed files with 36 additions and 13 deletions
|
@ -4,8 +4,8 @@ import config from '../../config/environment';
|
|||
import './stub-session';
|
||||
import './stub-audit';
|
||||
import './user-login';
|
||||
import './allow-anonymous-access';
|
||||
import './wait-to-appear';
|
||||
import './wait-to-disappear';
|
||||
import './stub-user-notification';
|
||||
|
||||
export default function startApp(attrs) {
|
||||
|
|
|
@ -1,19 +1,18 @@
|
|||
import Ember from 'ember';
|
||||
import miscUtil from 'documize/utils/misc';
|
||||
|
||||
const userNotification = Ember.Component.extend({
|
||||
notifications: [],
|
||||
|
||||
didInsertElement() {
|
||||
// this.eventBus.subscribe('notifyUser', this, 'showNotification');
|
||||
this.eventBus.subscribe('notifyUser', this, 'notifyHandler');
|
||||
},
|
||||
|
||||
willDestroyElement() {
|
||||
// this.eventBus.unsubscribe('notifyUser');
|
||||
this.eventBus.unsubscribe('notifyUser');
|
||||
},
|
||||
|
||||
showNotification(msg) {
|
||||
// console.log(msg);
|
||||
return msg;
|
||||
}
|
||||
});
|
||||
|
||||
|
|
|
@ -5,14 +5,15 @@ function isVisible(selector) {
|
|||
}
|
||||
|
||||
function checkVisibility(selector, interval, resolve, visibility) {
|
||||
if (isVisible(selector) === visibility) {
|
||||
resolve($(selector));
|
||||
} else {
|
||||
console.log('waiting for visibility');
|
||||
Ember.run.later(null, function() {
|
||||
checkVisibility(selector, interval, resolve, visibility);
|
||||
}, interval);
|
||||
}
|
||||
if (isVisible(selector) === visibility) {
|
||||
console.log("found in appear");
|
||||
resolve($(selector));
|
||||
} else {
|
||||
Ember.run.later(null, function() {
|
||||
console.log("waiting in appear");
|
||||
checkVisibility(selector, interval, resolve, visibility);
|
||||
}, interval);
|
||||
}
|
||||
}
|
||||
|
||||
export default Ember.Test.registerAsyncHelper('waitToAppear', function(app, selector, interval = 200) {
|
||||
|
|
23
app/tests/helpers/wait-to-disappear.js
Normal file
23
app/tests/helpers/wait-to-disappear.js
Normal file
|
@ -0,0 +1,23 @@
|
|||
import Ember from 'ember';
|
||||
|
||||
function isVisible(selector) {
|
||||
return $(selector).length > 0;
|
||||
}
|
||||
|
||||
function checkVisibility(selector, interval, resolve, visibility) {
|
||||
if (isVisible(selector) === visibility) {
|
||||
console.log("found");
|
||||
resolve($(selector));
|
||||
} else {
|
||||
Ember.run.later(null, function() {
|
||||
console.log("waiting");
|
||||
checkVisibility(selector, interval, resolve, visibility);
|
||||
}, interval);
|
||||
}
|
||||
}
|
||||
|
||||
export default Ember.Test.registerAsyncHelper('waitToDisappear', function(app, selector, interval = 200) {
|
||||
return new Ember.RSVP.Promise(function(resolve) {
|
||||
checkVisibility(selector, interval, resolve, false);
|
||||
});
|
||||
});
|
Loading…
Add table
Add a link
Reference in a new issue