Commit f24ec9f2 authored by Robert Knight's avatar Robert Knight

Convert src/sidebar/directive to ES modules

This directory is likely to go away soon as part of the Angular =>
Preact migration.

Nevertheless, I used the convert-to-es-modules script on it to convert
to ES modules so we can complete that migration first.
parent ad070e9f
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
* <input ng-if="..." h-autofocus> * <input ng-if="..." h-autofocus>
* *
*/ */
function autofocusDirective() { export default function autofocusDirective() {
return { return {
restrict: 'A', restrict: 'A',
link: function($scope, $element) { link: function($scope, $element) {
...@@ -19,5 +19,3 @@ function autofocusDirective() { ...@@ -19,5 +19,3 @@ function autofocusDirective() {
}, },
}; };
} }
module.exports = autofocusDirective;
...@@ -18,7 +18,7 @@ ...@@ -18,7 +18,7 @@
*/ */
// @ngInject // @ngInject
function BrandingDirective(settings) { export default function BrandingDirective(settings) {
const _hasBranding = !!settings.branding; const _hasBranding = !!settings.branding;
// This is the list of supported property declarations // This is the list of supported property declarations
...@@ -64,5 +64,3 @@ function BrandingDirective(settings) { ...@@ -64,5 +64,3 @@ function BrandingDirective(settings) {
}, },
}; };
} }
module.exports = BrandingDirective;
...@@ -28,7 +28,7 @@ function addEventHandler($scope, element, events, handler) { ...@@ -28,7 +28,7 @@ function addEventHandler($scope, element, events, handler) {
* mouse press OR touch. * mouse press OR touch.
*/ */
// @ngInject // @ngInject
function onTouchDirective($parse) { export default function onTouchDirective($parse) {
return { return {
restrict: 'A', restrict: 'A',
link: function($scope, $element, $attrs) { link: function($scope, $element, $attrs) {
...@@ -42,5 +42,3 @@ function onTouchDirective($parse) { ...@@ -42,5 +42,3 @@ function onTouchDirective($parse) {
}, },
}; };
} }
module.exports = onTouchDirective;
...@@ -77,7 +77,7 @@ function Tooltip(rootElement) { ...@@ -77,7 +77,7 @@ function Tooltip(rootElement) {
* *
* Example: '<button aria-label="Tooltip label" h-tooltip></button>' * Example: '<button aria-label="Tooltip label" h-tooltip></button>'
*/ */
function tooltipDirective() { export default function tooltipDirective() {
if (!theTooltip) { if (!theTooltip) {
theTooltip = new Tooltip(document.body); theTooltip = new Tooltip(document.body);
} }
...@@ -108,5 +108,3 @@ function tooltipDirective() { ...@@ -108,5 +108,3 @@ function tooltipDirective() {
}, },
}; };
} }
module.exports = tooltipDirective;
module.exports = [ export default [
// ALL SUPPORTED PROPERTIES // ALL SUPPORTED PROPERTIES
{ {
settings: { appBackgroundColor: 'blue' }, settings: { appBackgroundColor: 'blue' },
......
const angular = require('angular'); import angular from 'angular';
const hBranding = require('../h-branding'); import hBranding from '../h-branding';
const fixtures = require('./h-branding-fixtures');
import fixtures from './h-branding-fixtures';
describe('BrandingDirective', function() { describe('BrandingDirective', function() {
let $compile; let $compile;
......
const angular = require('angular'); import angular from 'angular';
const hOnTouch = require('../h-on-touch'); import hOnTouch from '../h-on-touch';
const util = require('./util');
import * as util from './util';
function testComponent() { function testComponent() {
return { return {
......
const angular = require('angular'); import angular from 'angular';
const hTooltip = require('../h-tooltip'); import hTooltip from '../h-tooltip';
const util = require('./util');
import * as util from './util';
function testComponent() { function testComponent() {
return { return {
......
...@@ -16,7 +16,7 @@ function hyphenate(name) { ...@@ -16,7 +16,7 @@ function hyphenate(name) {
* Given the 'inject' function from the 'angular-mocks' module, * Given the 'inject' function from the 'angular-mocks' module,
* retrieves an instance of the specified Angular module. * retrieves an instance of the specified Angular module.
*/ */
function ngModule(inject, name) { export function ngModule(inject, name) {
let module; let module;
const helper = function(_module) { const helper = function(_module) {
module = _module; module = _module;
...@@ -87,7 +87,7 @@ function ngModule(inject, name) { ...@@ -87,7 +87,7 @@ function ngModule(inject, name) {
* The returned object has a link(scope) method which will * The returned object has a link(scope) method which will
* re-link the component with new properties. * re-link the component with new properties.
*/ */
function createDirective( export function createDirective(
document, document,
name, name,
attrs, attrs,
...@@ -172,7 +172,7 @@ function createDirective( ...@@ -172,7 +172,7 @@ function createDirective(
} }
/** Helper to dispatch a native event to a DOM element. */ /** Helper to dispatch a native event to a DOM element. */
function sendEvent(element, eventType) { export function sendEvent(element, eventType) {
const event = new Event(eventType, { bubbles: true, cancelable: true }); const event = new Event(eventType, { bubbles: true, cancelable: true });
element.dispatchEvent(event); element.dispatchEvent(event);
} }
...@@ -183,7 +183,7 @@ function sendEvent(element, eventType) { ...@@ -183,7 +183,7 @@ function sendEvent(element, eventType) {
* There are many possible ways of hiding DOM elements on a page, this just * There are many possible ways of hiding DOM elements on a page, this just
* looks for approaches that are common in our app. * looks for approaches that are common in our app.
*/ */
function isHidden(element) { export function isHidden(element) {
const style = window.getComputedStyle(element); const style = window.getComputedStyle(element);
if (style.display === 'none') { if (style.display === 'none') {
...@@ -201,10 +201,3 @@ function isHidden(element) { ...@@ -201,10 +201,3 @@ function isHidden(element) {
return false; return false;
} }
module.exports = {
createDirective: createDirective,
isHidden: isHidden,
ngModule: ngModule,
sendEvent: sendEvent,
};
const angular = require('angular'); import angular from 'angular';
const inject = angular.mock.inject; const inject = angular.mock.inject;
const windowScroll = require('../window-scroll'); import windowScroll from '../window-scroll';
describe('windowScroll', function() { describe('windowScroll', function() {
let directive = null; let directive = null;
......
function windowScrollDirective() { export default function windowScrollDirective() {
return { return {
link: function(scope, elem, attr) { link: function(scope, elem, attr) {
let active = true; let active = true;
...@@ -26,5 +26,3 @@ function windowScrollDirective() { ...@@ -26,5 +26,3 @@ function windowScrollDirective() {
}, },
}; };
} }
module.exports = windowScrollDirective;
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment