How to use evt - 10 common examples

To help you get started, we’ve selected a few evt examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github mozilla-b2g / gaia / apps / email / js / sync.js View on Github external
function finishSync() {
        evt.emit('cronSyncStop', accountsResults.accountIds);

        // Mark this accountId set as no longer waiting.
        var accountKey = makeAccountKey(accountsResults.accountIds);
        waitingOnCron[accountKey] = false;
        var stillWaiting = Object.keys(waitingOnCron).some(function(key) {
          return !!waitingOnCron[key];
        });

        if (!hasBeenVisible && !stillWaiting) {
          var msg = 'mail sync complete, closing mail app';
          if (typeof plog === 'function') {
            plog(msg);
          } else {
            console.log(msg);
          }
github mozilla-b2g / gaia / apps / email / js / app_messages.js View on Github external
if (document.hidden) {
        appSelf.latest('self', function(app) {
          app.launch();
        });
      }

      this.emitWhenListener('notification', data);
    }
  });

  if ('mozSetMessageHandler' in navigator) {
    navigator.mozSetMessageHandler(
        'activity', appMessages.onActivityRequest.bind(appMessages));
    navigator.mozSetMessageHandler(
        'notification', appMessages.onNotification.bind(appMessages));
    evt.on(
        'notification', appMessages.onNotification.bind(appMessages));

    // Do not listen for navigator.mozSetMessageHandler('request-sync')
    // type, that is only done in the back end's cronsync for now.
  } else {
    console.warn('Activity support disabled!');
  }

  return appMessages;
});
github mozilla-b2g / gaia / apps / email / js / cards / message_list.js View on Github external
this.msgVScroll.on('messagesComplete', function(newEmailCount) {
        this.onNewMail(newEmailCount);

        // Inform that content is ready. There could actually be a small delay
        // with vScroll.updateDataBind from rendering the final display, but it
        // is small enough that it is not worth trying to break apart the design
        // to accommodate this metrics signal.
        if (!this._emittedContentEvents) {
          evt.emit('metrics:contentDone');
          this._emittedContentEvents = true;
        }
      }.bind(this));
github mozilla-b2g / gaia / apps / email / js / cards / message_list.js View on Github external
onFolderShown: function() {
      var model = this.model,
          account = model.account,
          foldersSlice = model.foldersSlice;

      // The extra checks here are to allow for lazy startup when we might have
      // a card instance but not a full model available. Once the model is
      // available though, this method will get called again, so the event
      // emitting is still correctly done in the lazy startup case.
      if (!document.hidden && account && foldersSlice && this.curFolder) {
        var inboxFolder = foldersSlice.getFirstFolderWithType('inbox');
        if (inboxFolder === this.curFolder) {
          evt.emit('inboxShown', account.id);
        }

        // If user tapped in search box on message_list before the JS for the
        // card is attached, then treat that as the signal to go to search. Only
        // do this when first starting up though.
        if (document.activeElement === this.searchTextTease) {
          this.onSearchButton();
        }
      }
    },
github mozilla-b2g / gaia / apps / email / js / cards / message_reader.js View on Github external
enableReply: function() {
      var btn = this.querySelector('.msg-reply-btn');
      btn.removeAttribute('aria-disabled');

      // Inform that content is ready. Done here because reply is only enabled
      // once the full body is available.
      if (!this._emittedContentEvents) {
        evt.emit('metrics:contentDone');
        this._emittedContentEvents = true;
      }
    },
github mozilla-b2g / gaia / apps / email / js / cards / setup_done.js View on Github external
onShowMail: function() {
      // Nuke this card
      evt.emit('showLatestAccount');
    },
github mozilla-b2g / gaia / apps / email / js / cards / compose.js View on Github external
this.composer.finishCompositionSendMessage(function(sendInfo) {
        evt.emit('uiDataOperationStop', this._dataIdSendEmail);

        // Card could have been destroyed in the meantime,
        // via an app card reset (not a _selfClosed case),
        // so do not bother with the rest of this work if
        // that was the case.
        if (!this.composer) {
          return;
        }

        if (activity) {
          // Just mention the action completed, but do not give
          // specifics, to maintain some privacy.
          activity.postResult('complete');
          activity = null;
        }
github mozilla-b2g / gaia / apps / email / js / mail_common.js View on Github external
_emitStartupEvents: function(skipEmitContentEvents) {
    if (!this._startupEventsEmitted) {
      if (startupCacheEventsSent) {
        // Cache already loaded, so at this point the content shown is wired
        // to event handlers.
        window.dispatchEvent(new CustomEvent('moz-content-interactive'));
      } else {
        // Cache was not used, so only now is the chrome dom loaded.
        window.dispatchEvent(new CustomEvent('moz-chrome-dom-loaded'));
      }
      window.dispatchEvent(new CustomEvent('moz-chrome-interactive'));

      // If a card that has a simple static content DOM, content is complete.
      // Otherwise, like message_list, need backend data to call complete.
      if (!skipEmitContentEvents) {
        evt.emit('metrics:contentDone');
      }

      this._startupEventsEmitted = true;
    }
  },
github leanote / desktop-app / node_modules / note.js View on Github external
fixNoteContentForSend: function(content) {
		if(!content) {
			return content;
		}

		// console.log(Evt.localUrl + '/api/file/getImage');
		// console.log(content);
		var reg = new RegExp(Evt.getImageLocalUrlPrefix(), 'g');
		content = content.replace(reg, Evt.leanoteUrl + '/api/file/getImage');

		var reg2 = new RegExp(Evt.getAttachLocalUrlPrefix(), 'g');
		content = content.replace(reg2, Evt.leanoteUrl + '/api/file/getAttach');

		var reg3 = new RegExp(Evt.getAllAttachsLocalUrlPrefix(), 'g');
		content = content.replace(reg3, Evt.leanoteUrl + '/api/file/getAllAttachs');

		return content;
	},
github leanote / desktop-app / node_modules / api.js View on Github external
needle.post(this.getUrl('auth/login', {macAddr: macAddr}), {email: email, pwd: pwd}, {timeout: 10000}, function(error, response) {
			me.checkError(error, response);
			if(error) {
				return callback && callback(false);
			}
			
			// needle.get('http://localhost/phpinfo.php?email=xx', {emai: email, pwd: pwd}, function(error, response) {
			var ret = response.body;
			// 登录成功, 保存token
			// console.log('login ret');
			// console.log(ret);
			if(Common.isOk(ret)) {
				ret.Pwd = Common.md5(pwd, ret.UserId);
				ret['Host'] = Evt.leanoteUrl;
				// User.setCurUser(ret);
				callback && callback(ret);
			} else {
				// console.log('log failed');
				callback && callback(false);
			}
		});
	},