Created
September 17, 2015 12:29
-
-
Save mhartington/edab9c2d790741ab0b2c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
angular.module('sfViewCtrlDirective', []) | |
.directive('open', OpenDirective); | |
function OpenDirective() { | |
return { | |
restrict: 'A', | |
link: function($scope, $element, $attr) { | |
console.log('device is ready'); | |
$element.on('click', function() { | |
SafariViewController.isAvailable(function(available) { | |
if (available) { | |
SafariViewController.show({ | |
'url': $attr.open, | |
'enterReaderModeIfAvailable': false | |
}, | |
function(msg) { | |
console.log("All good"); | |
}, | |
function(msg) { | |
alert("There appears to have been an error"); | |
}) | |
} else { | |
// potentially powered by InAppBrowser because that clobbers window.open | |
window.open($attr.open, '_blank', 'location=yes'); | |
} | |
}) | |
}); | |
}; | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment