2018-10-25 16:51:20 +02:00
|
|
|
/* eslint-disable
|
|
|
|
no-return-assign,
|
|
|
|
no-undef,
|
|
|
|
*/
|
|
|
|
// TODO: This file was created by bulk-decaffeinate.
|
|
|
|
// Fix any style issues and re-enable lint.
|
2018-10-25 16:50:16 +02:00
|
|
|
/*
|
|
|
|
* decaffeinate suggestions:
|
|
|
|
* DS102: Remove unnecessary code created because of implicit returns
|
|
|
|
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
|
|
|
|
*/
|
2018-11-21 11:08:53 +01:00
|
|
|
'use strict';
|
2018-10-25 16:50:16 +02:00
|
|
|
|
|
|
|
Application.Directives.directive('fileread', [ () =>
|
|
|
|
({
|
2018-10-25 16:51:20 +02:00
|
|
|
scope: {
|
|
|
|
fileread: '='
|
|
|
|
},
|
|
|
|
|
|
|
|
link (scope, element, attributes) {
|
|
|
|
return element.bind('change', changeEvent =>
|
|
|
|
scope.$apply(() => scope.fileread = changeEvent.target.files[0])
|
2018-11-21 11:08:53 +01:00
|
|
|
);
|
2018-10-25 16:51:20 +02:00
|
|
|
}
|
2018-10-25 16:50:16 +02:00
|
|
|
})
|
|
|
|
|
2018-11-21 11:08:53 +01:00
|
|
|
]);
|
2018-10-25 16:50:16 +02:00
|
|
|
|
|
|
|
// This `bsHolder` angular directive is a workaround for
|
|
|
|
// an incompatability between angular and the holder.js
|
|
|
|
// image placeholder library.
|
|
|
|
//
|
|
|
|
// To use, simply define `bs-holder` on any element
|
|
|
|
Application.Directives.directive('bsHolder', [ () =>
|
|
|
|
({
|
2018-10-25 16:51:20 +02:00
|
|
|
link (scope, element, attrs) {
|
|
|
|
Holder.addTheme('icon', { background: 'white', foreground: '#e9e9e9', size: 80, font: 'FontAwesome' })
|
|
|
|
.addTheme('icon-xs', { background: 'white', foreground: '#e0e0e0', size: 20, font: 'FontAwesome' })
|
|
|
|
.addTheme('icon-black-xs', { background: 'black', foreground: 'white', size: 20, font: 'FontAwesome' })
|
|
|
|
.addTheme('avatar', { background: '#eeeeee', foreground: '#555555', size: 16, font: 'FontAwesome' })
|
2018-11-21 11:08:53 +01:00
|
|
|
.run(element[0]);
|
2018-10-25 16:51:20 +02:00
|
|
|
}
|
2018-10-25 16:50:16 +02:00
|
|
|
})
|
|
|
|
|
2018-11-21 11:08:53 +01:00
|
|
|
]);
|
2015-05-05 03:10:25 +02:00
|
|
|
|
2018-10-25 16:50:16 +02:00
|
|
|
Application.Directives.directive('match', [ () =>
|
|
|
|
({
|
2018-10-25 16:51:20 +02:00
|
|
|
require: 'ngModel',
|
|
|
|
restrict: 'A',
|
|
|
|
scope: {
|
|
|
|
match: '='
|
|
|
|
},
|
|
|
|
link (scope, elem, attrs, ctrl) {
|
|
|
|
return scope.$watch(() => (ctrl.$pristine && angular.isUndefined(ctrl.$modelValue)) || (scope.match === ctrl.$modelValue)
|
2018-11-21 11:08:53 +01:00
|
|
|
, currentValue => ctrl.$setValidity('match', currentValue));
|
2018-10-25 16:51:20 +02:00
|
|
|
}
|
2018-10-25 16:50:16 +02:00
|
|
|
})
|
|
|
|
|
2018-11-21 11:08:53 +01:00
|
|
|
]);
|
2018-10-25 16:50:16 +02:00
|
|
|
|
|
|
|
Application.Directives.directive('publishProject', [ () =>
|
|
|
|
({
|
2018-10-25 16:51:20 +02:00
|
|
|
restrict: 'A',
|
|
|
|
link (scope, elem, attrs, ctrl) {
|
|
|
|
return elem.bind('click', function ($event) {
|
|
|
|
if ($event) {
|
2018-11-21 11:08:53 +01:00
|
|
|
$event.preventDefault();
|
|
|
|
$event.stopPropagation();
|
2018-10-25 16:51:20 +02:00
|
|
|
}
|
2018-10-25 16:50:16 +02:00
|
|
|
|
2018-11-21 11:08:53 +01:00
|
|
|
if (elem.attr('disabled')) { return; }
|
|
|
|
const input = angular.element('<input name="project[state]" type="hidden" value="published">');
|
|
|
|
const form = angular.element('form');
|
|
|
|
form.append(input);
|
|
|
|
form.triggerHandler('submit');
|
|
|
|
return form[0].submit();
|
|
|
|
});
|
2018-10-25 16:51:20 +02:00
|
|
|
}
|
2018-10-25 16:50:16 +02:00
|
|
|
})
|
|
|
|
|
2018-11-21 11:08:53 +01:00
|
|
|
]);
|
2015-05-05 03:10:25 +02:00
|
|
|
|
2018-11-20 16:25:15 +01:00
|
|
|
Application.Directives.directive('disableAnimation', ['$animate', ($animate) =>
|
2018-10-25 16:50:16 +02:00
|
|
|
({
|
2018-10-25 16:51:20 +02:00
|
|
|
restrict: 'A',
|
|
|
|
link (scope, elem, attrs) {
|
2018-11-27 13:57:41 +01:00
|
|
|
return attrs.$observe('disableAnimation', value => $animate.enabled(elem, !value));
|
2018-10-25 16:50:16 +02:00
|
|
|
}
|
|
|
|
})
|
2018-11-21 11:08:53 +01:00
|
|
|
]);
|
2016-03-23 18:39:41 +01:00
|
|
|
|
2018-11-21 09:42:26 +01:00
|
|
|
/**
|
|
|
|
* Isolate a form's scope from its parent : no nested validation
|
|
|
|
*/
|
2018-10-25 16:50:16 +02:00
|
|
|
Application.Directives.directive('isolateForm', [ () =>
|
|
|
|
({
|
2016-03-23 18:39:41 +01:00
|
|
|
restrict: 'A',
|
2018-10-25 16:50:16 +02:00
|
|
|
require: '?form',
|
2018-10-25 16:51:20 +02:00
|
|
|
link (scope, elm, attrs, ctrl) {
|
2018-11-21 11:08:53 +01:00
|
|
|
if (!ctrl) { return; }
|
2018-10-25 16:50:16 +02:00
|
|
|
|
|
|
|
// Do a copy of the controller
|
2018-11-21 11:08:53 +01:00
|
|
|
const ctrlCopy = {};
|
|
|
|
angular.copy(ctrl, ctrlCopy);
|
2018-10-25 16:50:16 +02:00
|
|
|
|
|
|
|
// Get the form's parent
|
2018-11-21 11:08:53 +01:00
|
|
|
const parent = elm.parent().controller('form');
|
2018-10-25 16:50:16 +02:00
|
|
|
// Remove parent link to the controller
|
2018-11-21 11:08:53 +01:00
|
|
|
parent.$removeControl(ctrl);
|
2018-10-25 16:50:16 +02:00
|
|
|
|
|
|
|
// Replace form controller with a "isolated form"
|
|
|
|
const isolatedFormCtrl = {
|
2018-10-25 16:51:20 +02:00
|
|
|
$setValidity (validationToken, isValid, control) {
|
2018-11-21 11:08:53 +01:00
|
|
|
ctrlCopy.$setValidity(validationToken, isValid, control);
|
|
|
|
return parent.$setValidity(validationToken, true, ctrl);
|
2018-10-25 16:50:16 +02:00
|
|
|
},
|
2016-03-23 18:39:41 +01:00
|
|
|
|
2018-10-25 16:51:20 +02:00
|
|
|
$setDirty () {
|
2018-11-21 11:08:53 +01:00
|
|
|
elm.removeClass('ng-pristine').addClass('ng-dirty');
|
|
|
|
ctrl.$dirty = true;
|
|
|
|
return ctrl.$pristine = false;
|
2018-10-25 16:50:16 +02:00
|
|
|
}
|
2018-11-21 11:08:53 +01:00
|
|
|
};
|
2016-03-23 18:39:41 +01:00
|
|
|
|
2018-11-21 11:08:53 +01:00
|
|
|
return angular.extend(ctrl, isolatedFormCtrl);
|
2018-10-25 16:50:16 +02:00
|
|
|
}
|
2016-03-23 18:39:41 +01:00
|
|
|
|
2018-10-25 16:50:16 +02:00
|
|
|
})
|
|
|
|
|
2018-11-21 11:08:53 +01:00
|
|
|
]);
|