|
38 | 38 |
|
39 | 39 | $document.on('click', function (evt) { |
40 | 40 | if ($scope.find(evt.target).length === 0) { |
41 | | - $scope.log('Color Picker: Document Hide Event'); |
| 41 | + $scope.log('Color Picker: Document Click Event'); |
42 | 42 | $scope.hide(); |
43 | 43 | } |
44 | 44 | }); |
|
74 | 74 | $scope.lightnessUpdate(); |
75 | 75 | }; |
76 | 76 |
|
77 | | - $scope.hide = function (apply) { |
| 77 | + $scope.hide = function () { |
78 | 78 | $scope.log('Color Picker: Hide Event'); |
79 | | - $scope.visible = false; |
80 | 79 |
|
81 | | - if (apply !== false) { |
| 80 | + if ($scope.visible) { |
| 81 | + $scope.visible = false; |
82 | 82 | $scope.$apply(); |
83 | 83 | } |
84 | 84 | }; |
|
339 | 339 | // HELPER FUNCTIONS |
340 | 340 | //--------------------------- |
341 | 341 | $scope.log = function () { |
342 | | - //console.log.apply(console, arguments); |
| 342 | + // console.log.apply(console, arguments); |
343 | 343 | }; |
344 | 344 |
|
345 | 345 | // taken and modified from jQuery's find |
|
363 | 363 | results = context.querySelectorAll(selector); |
364 | 364 |
|
365 | 365 | } else { |
366 | | - if ($scope.contains(context, selector)) { |
| 366 | + if (context.contains(selector)) { |
367 | 367 | results.push(selector); |
368 | 368 | } |
369 | 369 | } |
370 | 370 |
|
371 | 371 | return angular.element(results); |
372 | 372 | }; |
373 | 373 |
|
374 | | - $scope.contains = function (a, b) { |
375 | | - if (b) { |
376 | | - while ((b = b.parentNode)) { |
377 | | - if (b === a) { |
378 | | - return true; |
379 | | - } |
380 | | - } |
381 | | - } |
382 | | - |
383 | | - return false; |
384 | | - }; |
385 | | - |
386 | 374 | // taken and modified from jQuery's offset |
387 | 375 | $scope.offset = function (el) { |
388 | 376 | var docElem, win, rect, doc, elem = el[0]; |
|
426 | 414 |
|
427 | 415 |
|
428 | 416 | $scope.init(); |
| 417 | + |
| 418 | + $scope.$on('$destroy', function() { |
| 419 | + $document.off('click'); |
| 420 | + }); |
429 | 421 | } |
430 | 422 | }; |
431 | 423 | }; |
|
0 commit comments