overleaf/services/web/public/src/directives/equals.js
Eric Mc Sween 65849456d0 Merge pull request #1925 from overleaf/as-babel-plugin-angular-annotate
Enable Angular "annotations" via Babel plugin

GitOrigin-RevId: 343610025e3ba791fb284a0b696a1ea33e125a80
2019-07-16 09:22:21 +00:00

23 lines
724 B
JavaScript

/* eslint-disable
no-undef,
*/
// TODO: This file was created by bulk-decaffeinate.
// Fix any style issues and re-enable lint.
/*
* decaffeinate suggestions:
* DS102: Remove unnecessary code created because of implicit returns
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
*/
define(['base'], App =>
App.directive('equals', () => ({
require: 'ngModel',
link(scope, elem, attrs, ctrl) {
const firstField = `#${attrs.equals}`
return elem.add(firstField).on('keyup', () =>
scope.$apply(function() {
const equal = elem.val() === $(firstField).val()
return ctrl.$setValidity('areEqual', equal)
})
)
}
})))