Merge pull request #275 from glowing-bear/countWatchers
Better countWatchers, remove jQuery uses
This commit is contained in:
commit
6e88dfe963
1 changed files with 16 additions and 21 deletions
|
@ -491,24 +491,22 @@ function($rootScope,
|
|||
|
||||
weechat.controller('WeechatCtrl', ['$rootScope', '$scope', '$store', '$timeout', '$log', 'models', 'connection', function ($rootScope, $scope, $store, $timeout, $log, models, connection) {
|
||||
|
||||
// From: http://stackoverflow.com/a/18539624 by StackOverflow user "plantian"
|
||||
$rootScope.countWatchers = function () {
|
||||
var root = $(document.getElementsByTagName('body'));
|
||||
var watchers = [];
|
||||
|
||||
var f = function (element) {
|
||||
if (element.data().hasOwnProperty('$scope')) {
|
||||
angular.forEach(element.data().$scope.$$watchers, function (watcher) {
|
||||
watchers.push(watcher);
|
||||
});
|
||||
var q = [$rootScope], watchers = 0, scope;
|
||||
while (q.length > 0) {
|
||||
scope = q.pop();
|
||||
if (scope.$$watchers) {
|
||||
watchers += scope.$$watchers.length;
|
||||
}
|
||||
|
||||
angular.forEach(element.children(), function (childElement) {
|
||||
f($(childElement));
|
||||
});
|
||||
};
|
||||
|
||||
f(root);
|
||||
console.log(watchers.length);
|
||||
if (scope.$$childHead) {
|
||||
q.push(scope.$$childHead);
|
||||
}
|
||||
if (scope.$$nextSibling) {
|
||||
q.push(scope.$$nextSibling);
|
||||
}
|
||||
}
|
||||
console.log(watchers);
|
||||
};
|
||||
|
||||
|
||||
|
@ -705,7 +703,7 @@ weechat.controller('WeechatCtrl', ['$rootScope', '$scope', '$store', '$timeout',
|
|||
$scope.search = '';
|
||||
|
||||
if (!$rootScope.isMobileUi()) {
|
||||
$('#sendMessage').focus();
|
||||
document.getElementById('sendMessage').focus();
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -1217,10 +1215,7 @@ weechat.directive('inputBar', function() {
|
|||
* Returns the input element
|
||||
*/
|
||||
$scope.getInputNode = function() {
|
||||
return $element.find('#'+$scope.inputId)[0];
|
||||
};
|
||||
$scope.getForm = function() {
|
||||
return $element.find('form')[0];
|
||||
return document.querySelector('textarea#' + $scope.inputId);
|
||||
};
|
||||
|
||||
$scope.completeNick = function() {
|
||||
|
|
Loading…
Reference in a new issue