ui-fullscreen.js 1.1 KB

1234567891011121314151617181920212223242526272829
  1. angular.module('app')
  2. .directive('uiFullscreen', ['uiLoad', '$document', '$window', function(uiLoad, $document, $window) {
  3. return {
  4. restrict: 'AC',
  5. template:'<i class="fa fa-expand fa-fw text"></i><i class="fa fa-compress fa-fw text-active"></i>',
  6. link: function(scope, el, attr) {
  7. el.addClass('hide');
  8. uiLoad.load('https://cdn.washpayer.com/npm/screenfull@4.2.0/dist/screenfull.min.js').then(function(){
  9. // disable on ie11
  10. if (screenfull.enabled && !navigator.userAgent.match(/Trident.*rv:11\./)) {
  11. el.removeClass('hide');
  12. }
  13. el.on('click', function(){
  14. var target;
  15. attr.target && ( target = $(attr.target)[0] );
  16. screenfull.toggle(target);
  17. });
  18. $document.on(screenfull.raw.fullscreenchange, function () {
  19. scope.$broadcast("fullscreenchange");
  20. if (screenfull.isFullscreen) {
  21. el.addClass('active');
  22. }else{
  23. el.removeClass('active');
  24. }
  25. });
  26. });
  27. }
  28. };
  29. }]);