mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-19 15:48:04 +01:00
Use $scope instead of scope in directives
This commit is contained in:
@@ -9,10 +9,10 @@
|
|||||||
function closeMenu() {
|
function closeMenu() {
|
||||||
return {
|
return {
|
||||||
restrict: 'A',
|
restrict: 'A',
|
||||||
link: function(scope, element, attrs) {
|
link: function($scope, element, attrs) {
|
||||||
element.on('click', function(event) {
|
element.on('click', function(event) {
|
||||||
scope._expandedMenu = null;
|
$scope._expandedMenu = null;
|
||||||
scope.$apply()
|
$scope.$apply()
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
|
var count = 0;
|
||||||
(function(){
|
(function(){
|
||||||
|
|
||||||
angular
|
angular
|
||||||
@@ -9,10 +10,10 @@
|
|||||||
function expandMenu() {
|
function expandMenu() {
|
||||||
return {
|
return {
|
||||||
restrict: 'A',
|
restrict: 'A',
|
||||||
link: function(scope, element, attrs) {
|
link: function($scope, element, attrs) {
|
||||||
element.on('click', function(event) {
|
element.on('click', function(event) {
|
||||||
scope._expandedMenu = (scope._expandedMenu == attrs.menu) ? null : attrs.menu;
|
$scope._expandedMenu = ($scope._expandedMenu === attrs.menu) ? null : attrs.menu;
|
||||||
scope.$apply()
|
$scope.$apply()
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,9 +12,9 @@
|
|||||||
|
|
||||||
function focusMe($timeout, $parse) {
|
function focusMe($timeout, $parse) {
|
||||||
return {
|
return {
|
||||||
link: function(scope, element, attrs) {
|
link: function($scope, element, attrs) {
|
||||||
var model = $parse(attrs.focusMe);
|
var model = $parse(attrs.focusMe);
|
||||||
scope.$watch(model, function(value) {
|
$scope.$watch(model, function(value) {
|
||||||
$timeout(function() {
|
$timeout(function() {
|
||||||
element[0].focus();
|
element[0].focus();
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -11,18 +11,18 @@
|
|||||||
];
|
];
|
||||||
|
|
||||||
function fromNow($interval, $timeout) {
|
function fromNow($interval, $timeout) {
|
||||||
return function(scope, element, attr){
|
return function($scope, element, attr){
|
||||||
var interval, timeout;
|
var interval, timeout;
|
||||||
|
|
||||||
var updateText = function(){
|
var updateText = function(){
|
||||||
element.text(moment(scope.message.timestamp).fromNow());
|
element.text(moment($scope.message.timestamp).fromNow());
|
||||||
};
|
};
|
||||||
|
|
||||||
var setupInterval = function() {
|
var setupInterval = function() {
|
||||||
if(interval) $interval.cancel(interval);
|
if(interval) $interval.cancel(interval);
|
||||||
if(timeout) $timeout.cancel(timeout);
|
if(timeout) $timeout.cancel(timeout);
|
||||||
|
|
||||||
var diff = moment().diff(scope.message.timestamp, 'minute');
|
var diff = moment().diff($scope.message.timestamp, 'minute');
|
||||||
|
|
||||||
if(diff < 60) {
|
if(diff < 60) {
|
||||||
// Update every minute
|
// Update every minute
|
||||||
@@ -37,7 +37,7 @@
|
|||||||
updateText();
|
updateText();
|
||||||
setupInterval();
|
setupInterval();
|
||||||
|
|
||||||
scope.$on('$destroy', function() {
|
$scope.$on('$destroy', function() {
|
||||||
if(interval) $interval.cancel(interval);
|
if(interval) $interval.cancel(interval);
|
||||||
if(timeout) $timeout.cancel(timeout);
|
if(timeout) $timeout.cancel(timeout);
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -19,10 +19,10 @@
|
|||||||
// main: '@', // true if it's the user's main list
|
// main: '@', // true if it's the user's main list
|
||||||
// obj: '='
|
// obj: '='
|
||||||
//},
|
//},
|
||||||
link: function(scope, element, attrs) {
|
link: function($scope, element, attrs) {
|
||||||
// $scope.obj needs to come from controllers, so we can pass by ref
|
// $scope.obj needs to come from controllers, so we can pass by ref
|
||||||
scope.main = attrs.main;
|
$scope.main = attrs.main;
|
||||||
scope.modal = attrs.modal;
|
$scope.modal = attrs.modal;
|
||||||
var dailiesView;
|
var dailiesView;
|
||||||
if(User.user.preferences.dailyDueDefaultView) {
|
if(User.user.preferences.dailyDueDefaultView) {
|
||||||
dailiesView = "remaining";
|
dailiesView = "remaining";
|
||||||
|
|||||||
@@ -15,9 +15,9 @@
|
|||||||
restrict: 'EA',
|
restrict: 'EA',
|
||||||
replace: true,
|
replace: true,
|
||||||
scope: { title: '@', content: '@', placement: '@', animation: '&', isOpen: '&' },
|
scope: { title: '@', content: '@', placement: '@', animation: '&', isOpen: '&' },
|
||||||
link: function(scope, element, attrs) {
|
link: function($scope, element, attrs) {
|
||||||
scope.$watch('content', function(value, oldValue) {
|
$scope.$watch('content', function(value, oldValue) {
|
||||||
scope.unsafeContent = $sce.trustAsHtml(scope.content);
|
$scope.unsafeContent = $sce.trustAsHtml($scope.content);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
templateUrl: 'template/popover/popover-html.html'
|
templateUrl: 'template/popover/popover-html.html'
|
||||||
|
|||||||
@@ -13,8 +13,8 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
function taskFocus($timeout) {
|
function taskFocus($timeout) {
|
||||||
return function(scope, elem, attrs) {
|
return function($scope, elem, attrs) {
|
||||||
scope.$watch(attrs.taskFocus, function(newVal) {
|
$scope.$watch(attrs.taskFocus, function(newVal) {
|
||||||
if (newVal) {
|
if (newVal) {
|
||||||
$timeout(function() {
|
$timeout(function() {
|
||||||
elem[0].focus();
|
elem[0].focus();
|
||||||
|
|||||||
@@ -6,12 +6,12 @@
|
|||||||
.directive('whenScrolled', whenScrolled);
|
.directive('whenScrolled', whenScrolled);
|
||||||
|
|
||||||
function whenScrolled() {
|
function whenScrolled() {
|
||||||
return function(scope, elm, attr) {
|
return function($scope, elm, attr) {
|
||||||
var raw = elm[0];
|
var raw = elm[0];
|
||||||
|
|
||||||
elm.bind('scroll', function() {
|
elm.bind('scroll', function() {
|
||||||
if (raw.scrollTop + raw.offsetHeight >= raw.scrollHeight) {
|
if (raw.scrollTop + raw.offsetHeight >= raw.scrollHeight) {
|
||||||
scope.$apply(attr.whenScrolled);
|
$scope.$apply(attr.whenScrolled);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user