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