Dont open edit mode when clicking on a link

This commit is contained in:
Raimund Schlüßler 2015-11-20 23:01:53 +01:00
parent 4fe15bd54b
commit d1d86a4874
3 changed files with 94 additions and 10 deletions

View file

@ -137,7 +137,11 @@ $timeout, $routeParams, SettingsModel, Loading) ->
_tasksbusinesslayer.deleteTask taskID
,500)
@_$scope.editName = () ->
@_$scope.editName = ($event) ->
if $($event.target).is('a')
return
else
console.log('open edit page')
_$location.path('/lists/'+_$scope.route.listID +
'/tasks/' + _$scope.route.taskID + '/edit/name')
@ -167,6 +171,9 @@ $timeout, $routeParams, SettingsModel, Loading) ->
@_$scope.editNote = ($event) ->
if $($event.currentTarget).is($($event.target).closest('.handler'))
if $($event.target).is('a')
return
else
_$location.path('/lists/'+_$scope.route.listID +
'/tasks/' + _$scope.route.taskID + '/edit/note')
else

View file

@ -185,6 +185,74 @@
}).call(this);
(function() {
angular.module('Tasks').directive('clickableurl', [
'$compile', function($compile) {
return {
restrict: 'A',
scope: {
clickableurl: '='
},
link: function(scope, element, attr, task) {
return scope.$watch('clickableurl', function(clickableurl) {
var a, index, link, mail_regex, match, matchs, text, url_regex, _i, _len;
if (!angular.isUndefined(clickableurl)) {
url_regex = /(?:\s|^)+(https?:\/\/)?(([\da-z\-]+\.{1})+[a-z]{2,}\.?[\.\d\/\w\-\%=&+\?~#]*)(?:\s|$)+/gi;
mail_regex = /(?:\s|^)+(([\w.!$%&'\*\+-\/=\?^`\{\|\}~#])+([@]){1}([\da-z\-]+\.{1})+[a-z]{2,}\.?)(?:\s|$)+/gi;
matchs = new Array();
while ((match = url_regex.exec(clickableurl))) {
matchs.push(match);
url_regex.lastIndex--;
}
while ((match = mail_regex.exec(clickableurl))) {
matchs.push(match);
mail_regex.lastIndex--;
}
matchs.sort(function(a, b) {
if (a.index < b.index) {
return -1;
}
if (a.index > b.index) {
return 1;
}
return 0;
});
element.empty();
index = 0;
for (_i = 0, _len = matchs.length; _i < _len; _i++) {
link = matchs[_i];
if (link.index) {
element.append(document.createTextNode(clickableurl.substring(index, link.index + 1)));
}
index = link.index + link[0].length;
text = link.index ? link[0].substring(1) : link[0];
if (link[3] === '@') {
a = $compile('<a href="mailto:' + link[1] + '"\
class="handled end-edit"></a>')(scope);
a.text(text);
element.append(a);
continue;
}
if (angular.isUndefined(link[1])) {
link[1] = 'http://';
}
a = $compile('<a href="' + link[1] + link[2] + '"\
target="_blank" class="handled end-edit"></a>')(scope);
a.text(text);
element.append(a);
}
if (index < clickableurl.length) {
return element.append(document.createTextNode(clickableurl.substring(index)));
}
}
});
}
};
}
]);
}).call(this);
(function() {
angular.module('Tasks').directive('datepicker', function() {
return {
@ -466,8 +534,13 @@
return _tasksbusinesslayer.deleteTask(taskID);
}, 500);
};
this._$scope.editName = function() {
this._$scope.editName = function($event) {
if ($($event.target).is('a')) {
} else {
console.log('open edit page');
return _$location.path('/lists/' + _$scope.route.listID + '/tasks/' + _$scope.route.taskID + '/edit/name');
}
};
this._$scope.editDueDate = function($event) {
if ($($event.currentTarget).is($($event.target).closest('.handler'))) {
@ -495,7 +568,11 @@
};
this._$scope.editNote = function($event) {
if ($($event.currentTarget).is($($event.target).closest('.handler'))) {
if ($($event.target).is('a')) {
} else {
return _$location.path('/lists/' + _$scope.route.listID + '/tasks/' + _$scope.route.taskID + '/edit/note');
}
} else {
}

View file

@ -7,7 +7,7 @@
<span class="icon detail-star" ng-class="{'high':task.priority>5,'medium':task.priority==5,'low':task.priority > 0 && task.priority < 5}"></span>
</a>
<div class="title" ng-class="{'editing':route.parameter=='name'}">
<span class="title-text handler" ng-class="{'strike-through':task.completed}" ng-click="editName()"
<span class="title-text handler" ng-class="{'strike-through':task.completed}" ng-click="editName($event)"
oc-click-focus="{selector: '#editName', timeout: 0}" ng-bind-html="task.name | linky:'_blank':{rel: 'nofollow'}"></span>
<div class="expandable-container handler">
<div class="expandingArea active">