@atlassian/atlassian-connect-js 5.3.190

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (190) hide show
  1. package/.depcheckrc.json +16 -0
  2. package/.editorconfig +9 -0
  3. package/.envrc +5 -0
  4. package/.eslintignore +12 -0
  5. package/.eslintrc +31 -0
  6. package/.husky/pre-commit +11 -0
  7. package/.lintstagedrc.js +6 -0
  8. package/.netrc +1 -0
  9. package/.npmrc-public +4 -0
  10. package/.nvmrc +1 -0
  11. package/LICENSE +3 -0
  12. package/README.md +281 -0
  13. package/bitbucket-pipelines.yml +33 -0
  14. package/build/bin/bin-helper.js +29 -0
  15. package/build/bin/npm-postinstall.js +9 -0
  16. package/build/configs/append-sourcemapping.js +13 -0
  17. package/build/configs/availabletasks.js +15 -0
  18. package/build/configs/clean.js +12 -0
  19. package/build/configs/concat.js +44 -0
  20. package/build/configs/copy.js +32 -0
  21. package/build/configs/index.js +19 -0
  22. package/build/configs/jshint.js +9 -0
  23. package/build/configs/karma.js +11 -0
  24. package/build/configs/replace.js +10 -0
  25. package/build/configs/requirejs.js +187 -0
  26. package/build/configs/saucelabs-launchers.js +30 -0
  27. package/build/configs/shell.js +24 -0
  28. package/build/configs/uglify.js +15 -0
  29. package/build/configs/watch.js +45 -0
  30. package/build/end.frag +13 -0
  31. package/build/start.frag +18 -0
  32. package/bundlesize.config.json +14 -0
  33. package/dist/connect-host.css +225 -0
  34. package/dist/connect-host.js +13908 -0
  35. package/dist/connect-host.min.css +1 -0
  36. package/dist/iframe-fedramp.js +13663 -0
  37. package/dist/iframe.js +13663 -0
  38. package/dist/legacy-text-colors.css +245 -0
  39. package/dist/surfaces.css +11 -0
  40. package/dist/themes/atlaskit-tokens_dark-future.css +6 -0
  41. package/dist/themes/atlaskit-tokens_dark.css +394 -0
  42. package/dist/themes/atlaskit-tokens_legacy-dark.css +394 -0
  43. package/dist/themes/atlaskit-tokens_legacy-light.css +394 -0
  44. package/dist/themes/atlaskit-tokens_light-future.css +6 -0
  45. package/dist/themes/atlaskit-tokens_light.css +394 -0
  46. package/dist/themes/atlaskit-tokens_shape.css +14 -0
  47. package/dist/themes/atlaskit-tokens_spacing.css +26 -0
  48. package/dist/themes/atlaskit-tokens_typography-adg3.css +25 -0
  49. package/dist/themes/atlaskit-tokens_typography-modernized.css +25 -0
  50. package/dist/themes/atlaskit-tokens_typography-refreshed.css +25 -0
  51. package/gulpfile.js +204 -0
  52. package/memleak-check/app.html +10 -0
  53. package/memleak-check/index.html +31 -0
  54. package/memleak-check/index.js +33 -0
  55. package/package.json +102 -0
  56. package/renovate.json +11 -0
  57. package/security-assistant.yml +2 -0
  58. package/spec/.eslintrc +10 -0
  59. package/spec/config/karma.base.conf.js +200 -0
  60. package/spec/config/karma.conf.js +20 -0
  61. package/spec/fixtures/base_dialog_component_tests.js +180 -0
  62. package/spec/mocks/mock_feature_flag.js +23 -0
  63. package/spec/tests/amd_spec.js +122 -0
  64. package/spec/tests/analytics_dispatcher_spec.js +429 -0
  65. package/spec/tests/analytics_performance_spec.js +41 -0
  66. package/spec/tests/button_spec.js +143 -0
  67. package/spec/tests/dialog_extension_spec.js +59 -0
  68. package/spec/tests/dialog_module_provider_spec.js +499 -0
  69. package/spec/tests/dialog_module_spec.js +395 -0
  70. package/spec/tests/dialog_spec.js +296 -0
  71. package/spec/tests/dialog_webitem_spec.js +183 -0
  72. package/spec/tests/dropdown_module_spec.js +77 -0
  73. package/spec/tests/env_module_spec.js +153 -0
  74. package/spec/tests/events_spec.js +77 -0
  75. package/spec/tests/extension_configuration_options_store_spec.js +25 -0
  76. package/spec/tests/flag_module_provider_spec.js +79 -0
  77. package/spec/tests/flag_module_spec.js +118 -0
  78. package/spec/tests/flag_spec.js +243 -0
  79. package/spec/tests/host-api_spec.js +220 -0
  80. package/spec/tests/iframe-create_spec.js +43 -0
  81. package/spec/tests/iframe_container_spec.js +19 -0
  82. package/spec/tests/iframe_spec.js +265 -0
  83. package/spec/tests/inline_dialog_spec.js +41 -0
  84. package/spec/tests/inline_dialog_webitem_spec.js +331 -0
  85. package/spec/tests/loading_indicator_spec.js +48 -0
  86. package/spec/tests/messages_module_spec.js +108 -0
  87. package/spec/tests/meta_spec.js +71 -0
  88. package/spec/tests/module_args_spec.js +52 -0
  89. package/spec/tests/observe_spec.js +73 -0
  90. package/spec/tests/public_events.spec.js +102 -0
  91. package/spec/tests/scroll_position_spec.js +109 -0
  92. package/spec/tests/theming_spec.js +594 -0
  93. package/spec/tests/util_spec.js +55 -0
  94. package/spec/tests/utils/base64_spec.js +20 -0
  95. package/spec/tests/utils/button_spec.js +11 -0
  96. package/spec/tests/utils/cookie_spec.js +19 -0
  97. package/spec/tests/utils/deprecate_spec.js +22 -0
  98. package/spec/tests/utils/dialog_spec.js +297 -0
  99. package/spec/tests/utils/host_util_spec.js +45 -0
  100. package/spec/tests/utils/iframe_spec.js +41 -0
  101. package/spec/tests/utils/jwt_spec.js +135 -0
  102. package/spec/tests/utils/url_spec.js +37 -0
  103. package/spec/tests/utils/waitUntilReadyNextTick.js +5 -0
  104. package/spec/tests/utils/webitem.js +219 -0
  105. package/spec/tests/webitem_spec.js +131 -0
  106. package/src/css/host/dialog.css +144 -0
  107. package/src/css/host/flags.css +5 -0
  108. package/src/css/host/host.css +64 -0
  109. package/src/css/host/messages.css +12 -0
  110. package/src/css/plugin/legacy-text-colors.less +55 -0
  111. package/src/css/plugin/surfaces.css +11 -0
  112. package/src/host/ACJSFrameworkAdaptor.js +44 -0
  113. package/src/host/actions/analytics_action.js +35 -0
  114. package/src/host/actions/button_actions.js +21 -0
  115. package/src/host/actions/dialog_actions.js +27 -0
  116. package/src/host/actions/dialog_extension_actions.js +25 -0
  117. package/src/host/actions/dom_event_actions.js +32 -0
  118. package/src/host/actions/dropdown_actions.js +12 -0
  119. package/src/host/actions/env_actions.js +57 -0
  120. package/src/host/actions/event_actions.js +33 -0
  121. package/src/host/actions/flag_actions.js +22 -0
  122. package/src/host/actions/iframe_actions.js +27 -0
  123. package/src/host/actions/inline_dialog_actions.js +26 -0
  124. package/src/host/actions/inline_dialog_webitem_actions.js +10 -0
  125. package/src/host/actions/jwt_actions.js +51 -0
  126. package/src/host/actions/loading_indicator_actions.js +10 -0
  127. package/src/host/actions/module_actions.js +14 -0
  128. package/src/host/actions/webitem_actions.js +29 -0
  129. package/src/host/components/button.js +112 -0
  130. package/src/host/components/dialog.js +447 -0
  131. package/src/host/components/dialog_extension.js +106 -0
  132. package/src/host/components/dialog_webitem.js +69 -0
  133. package/src/host/components/flag.js +102 -0
  134. package/src/host/components/iframe.js +130 -0
  135. package/src/host/components/iframe_container.js +38 -0
  136. package/src/host/components/inline_dialog.js +108 -0
  137. package/src/host/components/inline_dialog_webitem.js +157 -0
  138. package/src/host/components/loading_indicator.js +110 -0
  139. package/src/host/components/webitem.js +227 -0
  140. package/src/host/deprecate.js +20 -0
  141. package/src/host/dispatchers/analytics_dispatcher.js +512 -0
  142. package/src/host/dispatchers/event_dispatcher.js +46 -0
  143. package/src/host/dollar.js +8 -0
  144. package/src/host/host-api.js +325 -0
  145. package/src/host/iframe-create.js +7 -0
  146. package/src/host/index.js +108 -0
  147. package/src/host/module-providers.js +13 -0
  148. package/src/host/modules/_featureFlag.js +42 -0
  149. package/src/host/modules/_performance.js +54 -0
  150. package/src/host/modules/analytics.js +17 -0
  151. package/src/host/modules/dialog.js +496 -0
  152. package/src/host/modules/dropdown.js +255 -0
  153. package/src/host/modules/env.js +156 -0
  154. package/src/host/modules/events.js +28 -0
  155. package/src/host/modules/flag.js +170 -0
  156. package/src/host/modules/host.js +19 -0
  157. package/src/host/modules/inline-dialog.js +33 -0
  158. package/src/host/modules/messages.js +309 -0
  159. package/src/host/modules/page.js +29 -0
  160. package/src/host/modules/scroll-position.js +102 -0
  161. package/src/host/modules/theming.js +114 -0
  162. package/src/host/stores/extension_configuration_options_store.js +24 -0
  163. package/src/host/util.js +98 -0
  164. package/src/host/utils/access-narrowing-context.js +18 -0
  165. package/src/host/utils/base64.js +22 -0
  166. package/src/host/utils/button.js +10 -0
  167. package/src/host/utils/cookie.js +14 -0
  168. package/src/host/utils/dialog.js +239 -0
  169. package/src/host/utils/feature-flag.js +27 -0
  170. package/src/host/utils/iframe.js +23 -0
  171. package/src/host/utils/jwt.js +60 -0
  172. package/src/host/utils/observe.js +34 -0
  173. package/src/host/utils/removal-observer.js +30 -0
  174. package/src/host/utils/simplexdm.js +58 -0
  175. package/src/host/utils/url.js +23 -0
  176. package/src/host/utils/webitem.js +214 -0
  177. package/src/plugin/amd.js +115 -0
  178. package/src/plugin/analytics.js +84 -0
  179. package/src/plugin/deprecate.js +16 -0
  180. package/src/plugin/dialog.js +197 -0
  181. package/src/plugin/dollar.js +77 -0
  182. package/src/plugin/events-instance.js +2 -0
  183. package/src/plugin/events.js +246 -0
  184. package/src/plugin/extension_configuration_options_store.js +27 -0
  185. package/src/plugin/featureFlag.js +8 -0
  186. package/src/plugin/index.js +118 -0
  187. package/src/plugin/meta.js +14 -0
  188. package/src/plugin/public-events.js +73 -0
  189. package/src/plugin/theming.js +211 -0
  190. package/src/plugin/util.js +104 -0
@@ -0,0 +1,35 @@
1
+ import EventDispatcher from '../dispatchers/event_dispatcher';
2
+
3
+ export default {
4
+ trackDeprecatedMethodUsed(methodUsed, extension) {
5
+ EventDispatcher.dispatch('analytics-deprecated-method-used', {methodUsed, extension});
6
+ },
7
+ trackIframeBridgeStart(extension) {
8
+ EventDispatcher.dispatch('iframe-bridge-start', {extension});
9
+ },
10
+ trackExternalEvent(name, values){
11
+ EventDispatcher.dispatch('analytics-external-event-track', {
12
+ eventName: name,
13
+ values: values
14
+ });
15
+ },
16
+ trackContentResolverEvent(success, extra) {
17
+ EventDispatcher.dispatch('analytics-content-resolver-track', {
18
+ success: success,
19
+ extra: extra
20
+ })
21
+ },
22
+ trackIframePerformanceMetrics(metrics, extension) {
23
+ if(metrics && Object.getOwnPropertyNames(metrics).length > 0) {
24
+ EventDispatcher.dispatch('analytics-iframe-performance', {metrics, extension});
25
+ }
26
+ },
27
+ trackWebVitals(metrics, extension) {
28
+ if (metrics && Object.keys(metrics).length > 0) {
29
+ EventDispatcher.dispatch('analytics-web-vitals', {metrics, extension});
30
+ }
31
+ },
32
+ trackIframeClick(data) {
33
+ EventDispatcher.dispatch('analytics-track-iframe-clicked', data)
34
+ }
35
+ };
@@ -0,0 +1,21 @@
1
+ import EventDispatcher from '../dispatchers/event_dispatcher';
2
+
3
+ export default {
4
+ clicked: ($el) => {
5
+ EventDispatcher.dispatch('button-clicked', {
6
+ $el
7
+ });
8
+ },
9
+ toggle: ($el, disabled) => {
10
+ EventDispatcher.dispatch('button-toggle', {
11
+ $el,
12
+ disabled
13
+ });
14
+ },
15
+ toggleVisibility: ($el, hidden) => {
16
+ EventDispatcher.dispatch('button-toggle-visibility', {
17
+ $el,
18
+ hidden
19
+ });
20
+ }
21
+ };
@@ -0,0 +1,27 @@
1
+ import EventDispatcher from '../dispatchers/event_dispatcher';
2
+
3
+ export default {
4
+ close: (data) => {
5
+ EventDispatcher.dispatch('dialog-close', {
6
+ dialog: data.dialog,
7
+ extension: data.extension,
8
+ customData: data.customData
9
+ });
10
+ },
11
+ closeActive: (data) => {
12
+ EventDispatcher.dispatch('dialog-close-active', data);
13
+ },
14
+ clickButton: (identifier, $el, extension) => {
15
+ EventDispatcher.dispatch('dialog-button-click', {
16
+ identifier,
17
+ $el,
18
+ extension
19
+ });
20
+ },
21
+ toggleButton: (data) => {
22
+ EventDispatcher.dispatch('dialog-button-toggle', data);
23
+ },
24
+ toggleButtonVisibility: (data) => {
25
+ EventDispatcher.dispatch('dialog-button-toggle-visibility', data);
26
+ }
27
+ };
@@ -0,0 +1,25 @@
1
+ import EventDispatcher from '../dispatchers/event_dispatcher';
2
+
3
+ export default {
4
+ open: (extension, options) => {
5
+ EventDispatcher.dispatch('dialog-extension-open', {
6
+ extension: extension,
7
+ options: options
8
+ });
9
+ },
10
+ close: () => {
11
+ EventDispatcher.dispatch('dialog-close-active', {});
12
+ },
13
+ addUserButton: (options, extension) => {
14
+ EventDispatcher.dispatch('dialog-button-add', {
15
+ button: {
16
+ text: options.text,
17
+ identifier: options.identifier,
18
+ data: {
19
+ userButton: true
20
+ }
21
+ },
22
+ extension: extension
23
+ });
24
+ }
25
+ };
@@ -0,0 +1,32 @@
1
+ import EventDispatcher from '../dispatchers/event_dispatcher';
2
+ import SimpleXDM from 'simple-xdm/host';
3
+ import util from '../util';
4
+
5
+ export default {
6
+ registerKeyEvent: function(data){
7
+ SimpleXDM.registerKeyListener(data.extension_id, data.key, data.modifiers, data.callback);
8
+ EventDispatcher.dispatch('dom-event-register', data);
9
+ },
10
+ unregisterKeyEvent: function(data){
11
+ SimpleXDM.unregisterKeyListener(data.extension_id, data.key, data.modifiers, data.callback);
12
+ EventDispatcher.dispatch('dom-event-unregister', data);
13
+ },
14
+ registerWindowKeyEvent: function(data){
15
+ window.addEventListener('keydown', (event) => {
16
+ if (event.keyCode === data.keyCode) {
17
+ data.callback();
18
+ }
19
+ });
20
+ },
21
+ registerClickHandler: function(handleIframeClick) {
22
+ SimpleXDM.registerClickHandler(function (data) {
23
+ var iframe = document.getElementById(data.extension_id);
24
+ if (iframe) {
25
+ handleIframeClick(iframe, data);
26
+ }
27
+ });
28
+ },
29
+ unregisterClickHandler: function() {
30
+ SimpleXDM.unregisterClickHandler();
31
+ }
32
+ };
@@ -0,0 +1,12 @@
1
+ import EventDispatcher from '../dispatchers/event_dispatcher';
2
+
3
+ export default {
4
+ // called on action click
5
+ itemSelected: function (dropdown_id, item, extension) {
6
+ EventDispatcher.dispatch('dropdown-item-selected', {
7
+ id: dropdown_id,
8
+ item,
9
+ extension
10
+ });
11
+ }
12
+ };
@@ -0,0 +1,57 @@
1
+ import EventDispatcher from '../dispatchers/event_dispatcher';
2
+ import util from '../util';
3
+ import IframeComponent from '../components/iframe';
4
+ import $ from '../dollar';
5
+ import getBooleanFeatureFlag from '../utils/feature-flag';
6
+
7
+ EventDispatcher.register('iframe-resize', function(data) {
8
+ IframeComponent.resize(data.width, data.height, data.$el);
9
+ });
10
+
11
+ EventDispatcher.register('iframe-size-to-parent', function(data) {
12
+ var height;
13
+ var $el = util.getIframeByExtensionId(data.extensionId);
14
+ height = ($(window).height() - $el.offset().top - 1) + 'px'; //1px comes from margin given by full-size-general-page
15
+ // When in unit test (env_module_spec.js), $el.get(0).name is an empty string, breaking the test. Thus doing this check.
16
+ if($el.get(0).name.length > 0 && JSON.parse($el.get(0).name).options.moduleType === 'jiraProjectPages') {
17
+ height = '100%';
18
+ }
19
+ EventDispatcher.dispatch('iframe-resize', {
20
+ width: '100%',
21
+ height: height,
22
+ $el
23
+ });
24
+ });
25
+
26
+ EventDispatcher.register('hide-footer', function(hideFooter) {
27
+ if (hideFooter) {
28
+ $('#footer').css({ display: 'none' });
29
+ }
30
+ });
31
+
32
+
33
+ window.addEventListener('resize', function(e){
34
+ EventDispatcher.dispatch('host-window-resize', e);
35
+ }, true);
36
+
37
+ export default {
38
+ iframeResize: function(width, height, context) {
39
+ var $el;
40
+ if (context.extension_id) {
41
+ $el = util.getIframeByExtensionId(context.extension_id);
42
+ } else {
43
+ $el = context;
44
+ }
45
+
46
+ EventDispatcher.dispatch('iframe-resize', { width, height, $el, extension: context.extension });
47
+ },
48
+ sizeToParent: function(extensionId, hideFooter) {
49
+ EventDispatcher.dispatch('iframe-size-to-parent', {
50
+ hideFooter: hideFooter,
51
+ extensionId: extensionId
52
+ });
53
+ },
54
+ hideFooter: function(hideFooter) {
55
+ EventDispatcher.dispatch('hide-footer', hideFooter);
56
+ }
57
+ };
@@ -0,0 +1,33 @@
1
+ import EventDispatcher from '../dispatchers/event_dispatcher';
2
+ import SimpleXDM from 'simple-xdm/host';
3
+ import SimpleXDMUtil from 'simple-xdm/src/common/util';
4
+
5
+ export default {
6
+ targetSpecNoDialogs: (registration) => registration?.extension?.options?.moduleType !== 'dialogs',
7
+ broadcast: function(type, targetSpec, event){
8
+ SimpleXDM.dispatch(type, targetSpec, event);
9
+ EventDispatcher.dispatch('event-dispatch', {
10
+ type: type,
11
+ targetSpec: targetSpec,
12
+ event: event
13
+ });
14
+ },
15
+
16
+ broadcastPublic: function(type, event, sender){
17
+ EventDispatcher.dispatch('event-public-dispatch', {
18
+ type,
19
+ event,
20
+ sender
21
+ });
22
+
23
+ const { contextJwt, url, ...filteredOptions } = sender.options || {};
24
+ SimpleXDM.dispatch(type, {}, {
25
+ sender: {
26
+ addonKey: sender.addon_key,
27
+ key: sender.key,
28
+ options: SimpleXDMUtil.sanitizeStructuredClone(filteredOptions)
29
+ },
30
+ event: event
31
+ });
32
+ }
33
+ };
@@ -0,0 +1,22 @@
1
+ import EventDispatcher from '../dispatchers/event_dispatcher';
2
+
3
+ export default {
4
+ // called on action click
5
+ actionInvoked: function (actionId, flagId) {
6
+ EventDispatcher.dispatch('flag-action-invoked', {
7
+ id: flagId,
8
+ actionId: actionId
9
+ });
10
+ },
11
+ open: function(flagId){
12
+ EventDispatcher.dispatch('flag-open', {id: flagId});
13
+ },
14
+ //called to close a flag
15
+ close: function(flagId){
16
+ EventDispatcher.dispatch('flag-close', {id: flagId});
17
+ },
18
+ //called by AUI when closed
19
+ closed: function(flagId){
20
+ EventDispatcher.dispatch('flag-closed', {id: flagId});
21
+ }
22
+ };
@@ -0,0 +1,27 @@
1
+ import EventDispatcher from '../dispatchers/event_dispatcher';
2
+ import simpleXDM from 'simple-xdm/host';
3
+
4
+ export default {
5
+ notifyIframeCreated: function($el, extension) {
6
+ EventDispatcher.dispatch('iframe-create', {$el, extension});
7
+ },
8
+
9
+ notifyBridgeEstablished: function($el, extension){
10
+ EventDispatcher.dispatch('iframe-bridge-established', {$el, extension});
11
+ },
12
+
13
+ notifyIframeDestroyed: function(filter){
14
+ if(typeof filter === 'string') {
15
+ filter = {id: filter};
16
+ }
17
+ var extensions = simpleXDM.getExtensions(filter);
18
+ extensions.forEach((extension) => {
19
+ EventDispatcher.dispatch('iframe-destroyed', {extension});
20
+ simpleXDM.unregisterExtension({id: extension.extension_id});
21
+ }, this);
22
+ },
23
+
24
+ notifyUnloaded: function($el, extension){
25
+ EventDispatcher.dispatch('iframe-unload', {$el, extension});
26
+ }
27
+ };
@@ -0,0 +1,26 @@
1
+ import EventDispatcher from '../dispatchers/event_dispatcher';
2
+
3
+ export default {
4
+ hide: function($el){
5
+ EventDispatcher.dispatch('inline-dialog-hide', {
6
+ $el: $el
7
+ });
8
+ },
9
+ refresh: function($el){
10
+ EventDispatcher.dispatch('inline-dialog-refresh', {$el});
11
+ },
12
+ hideTriggered: function(extension_id, $el){
13
+ EventDispatcher.dispatch('inline-dialog-hidden', {extension_id, $el});
14
+ },
15
+ close: function(){
16
+ EventDispatcher.dispatch('inline-dialog-close', {
17
+ });
18
+ },
19
+ created: function(data) {
20
+ EventDispatcher.dispatch('inline-dialog-opened', {
21
+ $el: data.$el,
22
+ trigger: data.trigger,
23
+ extension: data.extension
24
+ });
25
+ }
26
+ };
@@ -0,0 +1,10 @@
1
+ import EventDispatcher from '../dispatchers/event_dispatcher';
2
+
3
+ export default {
4
+ addExtension: function(data){
5
+ EventDispatcher.dispatch('inline-dialog-extension', {
6
+ $el: data.$el,
7
+ extension: data.extension
8
+ });
9
+ }
10
+ };
@@ -0,0 +1,51 @@
1
+ import EventDispatcher from '../dispatchers/event_dispatcher';
2
+ import Util from '../util';
3
+
4
+ export default {
5
+ registerContentResolver: function(data) {
6
+ EventDispatcher.dispatch('content-resolver-register-by-extension', data);
7
+ },
8
+ requestRefreshUrl: function(data){
9
+ if(!data.resolver) {
10
+ throw Error('ACJS: No content resolver supplied');
11
+ }
12
+ var promise = data.resolver.call(null, Util.extend({classifier: 'json'}, data.extension));
13
+ promise.fail(function(promiseData, error) {
14
+ EventDispatcher.dispatch('jwt-url-refreshed-failed', {
15
+ extension: data.extension,
16
+ $container: data.$container,
17
+ errorText: error.text,
18
+ errorTraceId: error.traceId
19
+ });
20
+ });
21
+ promise.done(function (promiseData) {
22
+ var newExtensionConfiguration = {};
23
+ if(typeof promiseData === 'object') {
24
+ newExtensionConfiguration = promiseData;
25
+ } else if(typeof promiseData === 'string') {
26
+ try{
27
+ newExtensionConfiguration = JSON.parse(promiseData);
28
+ } catch(e){
29
+ console.error('ACJS: invalid response from content resolver');
30
+ }
31
+ }
32
+ data.extension.url = newExtensionConfiguration.url;
33
+ Util.extend(data.extension.options, newExtensionConfiguration.options);
34
+ EventDispatcher.dispatch('jwt-url-refreshed', {
35
+ extension: data.extension,
36
+ $container: data.$container,
37
+ url: data.extension.url
38
+ });
39
+ });
40
+ EventDispatcher.dispatch('jwt-url-refresh-request', {data});
41
+ },
42
+
43
+ setClockSkew: function(skew) {
44
+ if(typeof skew === 'number') {
45
+ EventDispatcher.dispatch('jwt-skew-set', {skew});
46
+ } else {
47
+ console.error('ACJS: invalid JWT clock skew set');
48
+ }
49
+ }
50
+
51
+ };
@@ -0,0 +1,10 @@
1
+ import EventDispatcher from '../dispatchers/event_dispatcher';
2
+
3
+ export default {
4
+ timeout($el, extension) {
5
+ EventDispatcher.dispatch('iframe-bridge-timeout', {$el, extension});
6
+ },
7
+ cancelled($el, extension) {
8
+ EventDispatcher.dispatch('iframe-bridge-cancelled', {$el, extension});
9
+ }
10
+ };
@@ -0,0 +1,14 @@
1
+ import EventDispatcher from '../dispatchers/event_dispatcher';
2
+
3
+ export default {
4
+ defineCustomModule: function(name, methods){
5
+ var data = {};
6
+ if(!methods){
7
+ data.methods = name;
8
+ } else {
9
+ data.methods = methods;
10
+ data.name = name;
11
+ }
12
+ EventDispatcher.dispatch('module-define-custom', data);
13
+ }
14
+ }
@@ -0,0 +1,29 @@
1
+ import EventDispatcher from '../dispatchers/event_dispatcher';
2
+ import WebItemComponent from '../components/webitem';
3
+
4
+ /**
5
+ * @typedef {{$target: JQuery, eventType: 'click' | 'mouseenter', extension: Object}} WebItemInvokedEventData
6
+ */
7
+ export default {
8
+ addWebItem: (potentialWebItem) => {
9
+ let webitem;
10
+ let existing = WebItemComponent.getWebItemsBySelector(potentialWebItem.selector);
11
+
12
+ if(existing) {
13
+ return false;
14
+ } else {
15
+ webitem = WebItemComponent.setWebItem(potentialWebItem);
16
+ EventDispatcher.dispatch('webitem-added', {webitem});
17
+ }
18
+
19
+ },
20
+
21
+ /**
22
+ * @param {boolean} isInlineDialog
23
+ * @param {WebItemInvokedEventData} data
24
+ */
25
+ webitemInvoked: (isInlineDialog, data) => {
26
+ const eventName = isInlineDialog ? 'inline-dialog' : 'dialog'
27
+ EventDispatcher.dispatch('webitem-invoked:' + eventName, data);
28
+ }
29
+ };
@@ -0,0 +1,112 @@
1
+ import EventDispatcher from '../dispatchers/event_dispatcher';
2
+ import $ from '../dollar';
3
+ import ButtonActions from '../actions/button_actions';
4
+ import ButtonUtils from '../utils/button';
5
+
6
+ const BUTTON_TYPES = ['primary', 'link', 'secondary'];
7
+ var buttonId = 0;
8
+
9
+ class Button {
10
+ constructor() {
11
+ this.AP_BUTTON_CLASS = 'ap-aui-button';
12
+ }
13
+
14
+ setType($button, type){
15
+ if(type && BUTTON_TYPES.indexOf(type) >= 0) {
16
+ $button.addClass('aui-button-' + type);
17
+ }
18
+ return $button;
19
+ }
20
+
21
+ setDisabled($button, disabled) {
22
+ if(typeof disabled !== 'undefined' && !$button.data('immutable')) {
23
+ $button.attr('aria-disabled', disabled);
24
+ }
25
+ return $button;
26
+ }
27
+
28
+ setHidden($button, hidden) {
29
+ if(typeof hidden !== 'undefined' && !$button.data('immutable')) {
30
+ $button.toggle(!hidden);
31
+ }
32
+ return $button;
33
+ }
34
+
35
+ _setId($button, id) {
36
+ if(!id) {
37
+ id = 'ap-button-' + buttonId;
38
+ buttonId++;
39
+ }
40
+ $button.attr('id', id);
41
+ return $button;
42
+ }
43
+
44
+ _additionalClasses($button, classes) {
45
+ if(classes) {
46
+ if(typeof classes !== 'string') {
47
+ classes = classes.join(' ');
48
+ }
49
+ $button.addClass(classes);
50
+ }
51
+ return $button;
52
+ }
53
+
54
+ getName($button) {
55
+ return $($button).data('name');
56
+ }
57
+
58
+ getText($button) {
59
+ return $($button).text();
60
+ }
61
+
62
+ getIdentifier($button) {
63
+ return $($button).data('identifier');
64
+ }
65
+
66
+ isVisible($button) {
67
+ return $($button).is(':visible');
68
+ }
69
+
70
+ isEnabled($button) {
71
+ return !($($button).attr('aria-disabled') === 'true');
72
+ }
73
+
74
+ render (options) {
75
+ var $button = $('<button />');
76
+ options = options || {};
77
+ $button.addClass('aui-button ' + this.AP_BUTTON_CLASS);
78
+ $button.text(options.text);
79
+ $button.data(options.data);
80
+ $button.data({
81
+ name: options.name || options.identifier,
82
+ identifier: options.identifier || ButtonUtils.randomIdentifier(),
83
+ immutable: options.immutable || false
84
+ });
85
+ this._additionalClasses($button, options.additionalClasses);
86
+ this.setType($button, options.type);
87
+ this.setDisabled($button, options.disabled || false);
88
+ this._setId($button, options.id);
89
+ return $button;
90
+ }
91
+ }
92
+
93
+ var ButtonComponent = new Button();
94
+ // register 1 button listener globally on dom load
95
+ $(function(){
96
+ $('body').on('click', '.' + ButtonComponent.AP_BUTTON_CLASS, function(e){
97
+ var $button = $(e.target).closest('.' + ButtonComponent.AP_BUTTON_CLASS);
98
+ if ($button.attr('aria-disabled') !== 'true') {
99
+ ButtonActions.clicked($button);
100
+ }
101
+ });
102
+ });
103
+
104
+ EventDispatcher.register('button-toggle', (data) => {
105
+ ButtonComponent.setDisabled(data.$el, data.disabled);
106
+ });
107
+
108
+ EventDispatcher.register('button-toggle-visibility', (data) => {
109
+ ButtonComponent.setHidden(data.$el, data.hidden);
110
+ });
111
+
112
+ export default ButtonComponent;