mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-19 15:48:04 +01:00
Rename task-focus focus-element
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
'use strict';
|
||||
|
||||
describe('taskFocus Directive', function() {
|
||||
describe('focusElement Directive', function() {
|
||||
var elementToFocus, scope;
|
||||
|
||||
beforeEach(module('habitrpg'));
|
||||
@@ -9,7 +9,7 @@ describe('taskFocus Directive', function() {
|
||||
scope = $rootScope.$new();
|
||||
|
||||
scope.focusThisLink = false;
|
||||
var element = '<input data-task-focus="focusThisLink" />';
|
||||
var element = '<input data-focus-element="focusThisLink" />';
|
||||
|
||||
elementToFocus = $compile(element)(scope);
|
||||
scope.$digest();
|
||||
@@ -25,7 +25,7 @@ describe('taskFocus Directive', function() {
|
||||
scope.$digest();
|
||||
|
||||
$timeout.flush();
|
||||
expect(document.activeElement.dataset.taskFocus).to.eql("focusThisLink");
|
||||
expect(document.activeElement.dataset.focusElement).to.eql("focusThisLink");
|
||||
expect(focusSpy).to.have.been.called;
|
||||
})
|
||||
);
|
||||
|
||||
@@ -3,18 +3,18 @@
|
||||
(function(){
|
||||
angular
|
||||
.module('habitrpg')
|
||||
.directive('taskFocus', taskFocus);
|
||||
.directive('focusElement', focusElement);
|
||||
|
||||
taskFocus.$inject = ['$timeout'];
|
||||
focusElement.$inject = ['$timeout'];
|
||||
|
||||
/**
|
||||
* Directive that places focus on the element it is applied to when the
|
||||
* expression it binds to evaluates to true.
|
||||
*/
|
||||
|
||||
function taskFocus($timeout) {
|
||||
function focusElement($timeout) {
|
||||
return function($scope, elem, attrs) {
|
||||
$scope.$watch(attrs.taskFocus, function(newVal) {
|
||||
$scope.$watch(attrs.focusElement, function(newVal) {
|
||||
if (newVal) {
|
||||
$timeout(function() {
|
||||
elem[0].focus();
|
||||
|
||||
@@ -127,7 +127,7 @@ script(type='text/ng-template', id='modals/copyChatToDo.html')
|
||||
.form-group
|
||||
input.form-control(type='text',ng-model='text', ng-model-options="{debounce: 1000}")
|
||||
.form-group
|
||||
textarea.form-control(rows='5',ng-model='notes', ng-model-options="{debounce: 1000}", task-focus='true')
|
||||
textarea.form-control(rows='5',ng-model='notes', ng-model-options="{debounce: 1000}", focus-element='true')
|
||||
|
||||
hr
|
||||
|
||||
|
||||
@@ -47,7 +47,7 @@ script(type='text/ng-template', id='modals/private-message.html')
|
||||
.modal-header
|
||||
h4=env.t('pmHeading', {name: "{{profile.profile.name}}"})
|
||||
.modal-body
|
||||
textarea.form-control(type='text',rows='5',ui-keydown='{"meta-enter":"sendPrivateMessage(profile._id, _message)"}',placeholder=env.t('needsTextPlaceholder'),ng-model='_message', task-focus='true')
|
||||
textarea.form-control(type='text',rows='5',ui-keydown='{"meta-enter":"sendPrivateMessage(profile._id, _message)"}',placeholder=env.t('needsTextPlaceholder'),ng-model='_message', focus-element='true')
|
||||
include ../formatting-help
|
||||
.modal-footer
|
||||
//- Due to a quirk in Bootstrap UI, we need to wrap this so the tooltip can
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
form.task-add(name='new{{list.type}}form', ng-hide='obj._locked', ng-submit='addTask(obj[list.type+"s"],list)', novalidate)
|
||||
textarea(rows='6', task-focus='list.bulk && list.focus', ng-model='list.newTask', placeholder='{{list.placeHolderBulk}}', ng-if='list.bulk', ui-keydown='{"meta-enter ctrl-enter":"addTask(obj[list.type+\'s\'],list)"}', required)
|
||||
input(type='text', task-focus='!list.bulk && list.focus', ng-model='list.newTask', placeholder='{{list.placeHolder}}', ng-if='!list.bulk', required)
|
||||
textarea(rows='6', focus-element='list.bulk && list.focus', ng-model='list.newTask', placeholder='{{list.placeHolderBulk}}', ng-if='list.bulk', ui-keydown='{"meta-enter ctrl-enter":"addTask(obj[list.type+\'s\'],list)"}', required)
|
||||
input(type='text', focus-element='!list.bulk && list.focus', ng-model='list.newTask', placeholder='{{list.placeHolder}}', ng-if='!list.bulk', required)
|
||||
button(type='submit', ng-disabled='new{{list.type}}form.$invalid')
|
||||
div.empty-task-notification( ng-show='new{{list.type}}form.$invalid', tooltip=env.t("emptyTask") )
|
||||
span.glyphicon.glyphicon-plus
|
||||
|
||||
Reference in New Issue
Block a user