source : FinishLine.js

  1. 'use strict';
  2. /**
  3. * This widget displays a start/finish line image.
  4. * It displays it initially as a horizontal image where the center is positioned so that it can be rotated to a specific X/Y coordinate.
  5. * <p>
  6. * Example:
  7. * <p><b>
  8. * <sra-track-map-finish-line></sra-track-map-finish-line><br />
  9. * </b>
  10. * <img src="../widgets/TrackMap/FinishLine/icon.png" atl="Image goes here"/>
  11. * @ngdoc directive
  12. * @name sra-track-map-finish-line
  13. * @param {integer} data-sra-args-interval The interval, in milliseconds, that this widget will update from the server. Default is 500.
  14. * @author Jeffrey Gilliam
  15. * @since 1.0
  16. * @copyright Copyright (C) 2015 - 2024 Jeffrey Gilliam
  17. * @license Apache License 2.0
  18. */
  19. define(['SIMRacingApps','css!widgets/TrackMap/FinishLine/FinishLine'],
  20. function(SIMRacingApps) {
  21. var self = {
  22. name: "sraTrackMapFinishLine",
  23. url: 'TrackMap/FinishLine',
  24. template: 'FinishLine.html',
  25. defaultWidth: 800,
  26. defaultHeight: 480,
  27. defaultInterval: 500 //initialize with the default interval
  28. };
  29. self.module = angular.module('SIMRacingApps'); //get the main module
  30. self.module.directive(self.name,
  31. ['sraDispatcher', '$filter', '$rootScope',
  32. function(sraDispatcher, $filter, $rootScope) {
  33. return {
  34. restrict: 'EA',
  35. scope: true,
  36. templateUrl: sraDispatcher.getWidgetUrl(self.url) + '/' + self.template,
  37. controller: [ '$scope', function($scope) {
  38. $scope.directiveName = self.name;
  39. $scope.defaultWidth = self.defaultWidth;
  40. $scope.defaultHeight = self.defaultHeight;
  41. $scope.defaultInterval = self.defaultInterval;
  42. }]
  43. , link: function($scope,$element,$attrs) {
  44. //copy arguments to our $scope
  45. $attrs.sraArgsData = $attrs.sraArgsData || "";
  46. $scope.value =
  47. $scope[self.name] = sraDispatcher.getTruthy($scope.sraArgsVALUE, $attrs[self.name], $attrs.sraArgsValue, "DefaultValue");
  48. //register with the dispatcher
  49. $rootScope.$on('sraResize', function() {
  50. sraDispatcher.resize($scope,$element,self.defaultWidth,self.defaultHeight);
  51. });
  52. $scope.names = sraDispatcher.subscribe($scope,$attrs,self.defaultInterval); //register subscriptions and options to the dispatcher
  53. }
  54. };
  55. }]);
  56. return self;
  57. });