source : SRALogoURL.js

  1. 'use strict';
  2. /**
  3. * This widget displays the SIMRacingApps Logo with the URL.
  4. * <p>
  5. * Example:
  6. * <p><b>
  7. * <sra-s-r-a-logo-u-r-l></sra-s-r-a-logo-u-r-l><br />
  8. * </b>
  9. * <img src="../widgets/SRALogoURL/icon.png" />
  10. * @ngdoc directive
  11. * @name sra-s-r-a-logo-u-r-l
  12. * @param {string} data-sra-args-value The name of the logo file. Must have a 4x1 aspect ratio and placed in the HTML root (i.e. Documents/SIMRacingApps).
  13. * @param {integer} data-sra-args-interval The interval, in milliseconds, that this widget will update from the server. Default is 1000.
  14. * @author Jeffrey Gilliam
  15. * @since 1.7
  16. * @copyright Copyright (C) 2015 - 2024 Jeffrey Gilliam
  17. * @license Apache License 2.0
  18. */
  19. define(['SIMRacingApps','css!widgets/SRALogoURL/SRALogoURL'
  20. ],function(SIMRacingApps) {
  21. var self = {
  22. name: "sraSRALogoURL",
  23. url: 'SRALogoURL',
  24. template: 'SRALogoURL.html',
  25. defaultWidth: 869,
  26. defaultHeight: 217,
  27. defaultInterval: 1000 //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. //load translations
  43. // sraDispatcher.loadTranslations(sraDispatcher.getWidgetUrl(self.url),'text',function(path) {
  44. // $scope.translations = sraDispatcher.getTranslation(path);
  45. // });
  46. }]
  47. , link: function($scope,$element,$attrs) {
  48. //copy arguments to our scope. First if using attribute, second tag, else default to something.
  49. $attrs.sraArgsData = $attrs.sraArgsData || "";
  50. $scope.value =
  51. $scope[self.name] = sraDispatcher.getTruthy($scope.sraArgsVALUE, $attrs[self.name], $attrs.sraArgsValue, "SRA-Logo-with-URL-semi-transparent.png");
  52. /** your code goes here **/
  53. /**standard code that should be in every directive **/
  54. $rootScope.$on('sraResize', sraDispatcher.resize($scope,$element,self.defaultWidth,self.defaultHeight));
  55. //register with the dispatcher
  56. $scope.names = sraDispatcher.subscribe($scope,$attrs,self.defaultInterval); //register subscriptions and options to the dispatcher
  57. /** watches go here **/
  58. }
  59. };
  60. }]);
  61. return self;
  62. });