當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript app_events.on函數代碼示例

本文整理匯總了TypeScript中app/core/app_events.on函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript on函數的具體用法?TypeScript on怎麽用?TypeScript on使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了on函數的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: init

  init() {
    this.$rootScope.onAppEvent(
      'alert-error',
      (e, alert) => {
        this.set(alert[0], alert[1], 'error', 12000);
      },
      this.$rootScope
    );

    this.$rootScope.onAppEvent(
      'alert-warning',
      (e, alert) => {
        this.set(alert[0], alert[1], 'warning', 5000);
      },
      this.$rootScope
    );

    this.$rootScope.onAppEvent(
      'alert-success',
      (e, alert) => {
        this.set(alert[0], alert[1], 'success', 3000);
      },
      this.$rootScope
    );

    appEvents.on('alert-warning', options => this.set(options[0], options[1], 'warning', 5000));
    appEvents.on('alert-success', options => this.set(options[0], options[1], 'success', 3000));
    appEvents.on('alert-error', options => this.set(options[0], options[1], 'error', 7000));
    appEvents.on('confirm-modal', this.showConfirmModal.bind(this));
  }
開發者ID:GPegel,項目名稱:grafana,代碼行數:30,代碼來源:alert_srv.ts

示例2: constructor

  /** @ngInject **/
  constructor($scope, private $timeout) {
    this.onRequestErrorEventListener = this.onRequestError.bind(this);
    this.onRequestResponseEventListener = this.onRequestResponse.bind(this);

    appEvents.on('ds-request-response', this.onRequestResponseEventListener);
    appEvents.on('ds-request-error', this.onRequestErrorEventListener);
    $scope.$on('$destroy',  this.removeEventsListeners.bind(this));
  }
開發者ID:casaria,項目名稱:grafana-trillium-src-fork,代碼行數:9,代碼來源:query_troubleshooter.ts

示例3: constructor

  /** @ngInject */
  constructor($scope, private $location, private $timeout, private searchSrv: SearchSrv) {
    appEvents.on('show-dash-search', this.openSearch.bind(this), $scope);
    appEvents.on('hide-dash-search', this.closeSearch.bind(this), $scope);

    this.initialFolderFilterTitle = 'All';
    this.getTags = this.getTags.bind(this);
    this.onTagSelect = this.onTagSelect.bind(this);
  }
開發者ID:GPegel,項目名稱:grafana,代碼行數:9,代碼來源:search.ts

示例4:

    link: (scope, elem, attrs) => {
      let lastPos = 0;

      appEvents.on(
        'dash-scroll',
        evt => {
          if (evt.restore) {
            elem[0].scrollTop = lastPos;
            return;
          }

          lastPos = elem[0].scrollTop;

          if (evt.animate) {
            elem.animate({ scrollTop: evt.pos }, 500);
          } else {
            elem[0].scrollTop = evt.pos;
          }
        },
        scope
      );

      scope.$on('$routeChangeSuccess', () => {
        lastPos = 0;
        elem[0].scrollTop = 0;
        // Focus page to enable scrolling by keyboard
        elem[0].focus({ preventScroll: true });
      });

      elem[0].tabIndex = -1;
      // Focus page to enable scrolling by keyboard
      elem[0].focus({ preventScroll: true });
    },
開發者ID:ArcticSnowman,項目名稱:grafana,代碼行數:33,代碼來源:page_scroll.ts

示例5: function

    link: function(scope, elem, attrs) {
      let scrollbar = new PerfectScrollbar(elem[0], {
        wheelPropagation: true,
        wheelSpeed: 3,
      });
      let lastPos = 0;

      appEvents.on(
        'dash-scroll',
        evt => {
          if (evt.restore) {
            elem[0].scrollTop = lastPos;
            return;
          }

          lastPos = elem[0].scrollTop;

          if (evt.animate) {
            elem.animate({ scrollTop: evt.pos }, 500);
          } else {
            elem[0].scrollTop = evt.pos;
          }
        },
        scope
      );

      scope.$on('$routeChangeSuccess', () => {
        lastPos = 0;
        elem[0].scrollTop = 0;
      });

      scope.$on('$destroy', () => {
        scrollbar.destroy();
      });
    },
開發者ID:ilgizar,項目名稱:grafana,代碼行數:35,代碼來源:scroll.ts

示例6: function

    link: function(scope, elem, attrs) {
      let scrollbar = new PerfectScrollbar(elem[0]);

      appEvents.on(
        'smooth-scroll-top',
        () => {
          elem.animate(
            {
              scrollTop: 0,
            },
            500
          );
        },
        scope
      );

      scope.$on('$routeChangeSuccess', () => {
        elem[0].scrollTop = 0;
      });

      scope.$on('$routeUpdate', () => {
        elem[0].scrollTop = 0;
      });

      scope.$on('$destroy', () => {
        scrollbar.destroy();
      });
    },
開發者ID:xiequanqin,項目名稱:grafana,代碼行數:28,代碼來源:scroll.ts

示例7: function

    link: function(scope, elem, attrs) {
      let lastPos = 0;

      appEvents.on(
        'dash-scroll',
        evt => {
          if (evt.restore) {
            elem[0].scrollTop = lastPos;
            return;
          }

          lastPos = elem[0].scrollTop;

          if (evt.animate) {
            elem.animate({ scrollTop: evt.pos }, 500);
          } else {
            elem[0].scrollTop = evt.pos;
          }
        },
        scope
      );

      scope.$on('$routeChangeSuccess', () => {
        lastPos = 0;
        elem[0].scrollTop = 0;
        elem[0].focus();
      });

      elem[0].tabIndex = -1;
      elem[0].focus();
    },
開發者ID:knoguchi,項目名稱:grafana,代碼行數:31,代碼來源:page_scroll.ts

示例8: parseInt

    $scope.init = () => {
      contextSrv.sidemenu = false;
      appEvents.emit('toggle-sidemenu-hidden');

      const params = $location.search();
      panelId = parseInt(params.panelId, 10);

      appEvents.on('dashboard-initialized', $scope.initPanelScope);

      // if no uid, redirect to new route based on slug
      if (!($routeParams.type === 'script' || $routeParams.type === 'snapshot') && !$routeParams.uid) {
        backendSrv.getDashboardBySlug($routeParams.slug).then(res => {
          if (res) {
            const url = locationUtil.stripBaseFromUrl(res.meta.url.replace('/d/', '/d-solo/'));
            $location.path(url).replace();
          }
        });
        return;
      }

      dashboardLoaderSrv.loadDashboard($routeParams.type, $routeParams.slug, $routeParams.uid).then(result => {
        result.meta.soloMode = true;
        $scope.initDashboard(result, $scope);
      });
    };
開發者ID:acedrew,項目名稱:grafana,代碼行數:25,代碼來源:solo_panel_ctrl.ts

示例9: constructor

  /** @ngInject */
  constructor($scope, private $http, private backendSrv, private $rootScope) {
    this.dashboards = [];

    backendSrv.get(`/api/plugins/${this.plugin.id}/dashboards`).then(dashboards => {
      this.dashboards = dashboards;
    });

    appEvents.on('dashboard-list-import-all', this.importAll.bind(this), $scope);
  }
開發者ID:21hub,項目名稱:grafana,代碼行數:10,代碼來源:import_list.ts

示例10: init

  init() {
    this.$rootScope.$on('$routeUpdate', (evt, data) => {
      const angularUrl = this.$location.url();
      const state = store.getState();
      if (state.location.url !== angularUrl) {
        store.dispatch(
          updateLocation({
            path: this.$location.path(),
            query: this.$location.search(),
            routeParams: this.$route.current.params,
          })
        );
      }
    });

    this.$rootScope.$on('$routeChangeSuccess', (evt, data) => {
      store.dispatch(
        updateLocation({
          path: this.$location.path(),
          query: this.$location.search(),
          routeParams: this.$route.current.params,
        })
      );
    });

    // Listen for changes in redux location -> update angular location
    store.subscribe(() => {
      const state = store.getState();
      const angularUrl = this.$location.url();
      const url = locationUtil.stripBaseFromUrl(state.location.url);
      if (angularUrl !== url) {
        this.$timeout(() => {
          this.$location.url(url);
          // some state changes should not trigger new browser history
          if (state.location.replace) {
            this.$location.replace();
          }
        });
        console.log('store updating angular $location.url', url);
      }
    });

    appEvents.on('location-change', (payload: any) => {
      const urlWithoutBase = locationUtil.stripBaseFromUrl(payload.href);
      if (this.fullPageReloadRoutes.indexOf(urlWithoutBase) > -1) {
        this.$window.location.href = payload.href;
        return;
      }

      this.$timeout(() => {
        // A hack to use timeout when we're changing things (in this case the url) from outside of Angular.
        this.$location.url(urlWithoutBase);
      });
    });
  }
開發者ID:grafana,項目名稱:grafana,代碼行數:55,代碼來源:bridge_srv.ts


注:本文中的app/core/app_events.on函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。