当前位置: 首页>>代码示例>>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;未经允许,请勿转载。