-
Notifications
You must be signed in to change notification settings - Fork 245
Isolated scope #209
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
endorama
wants to merge
24
commits into
sayanee:master
Choose a base branch
from
endorama:isolated-scope
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Isolated scope #209
Changes from all commits
Commits
Show all changes
24 commits
Select commit
Hold shift + click to select a range
3eb39c0
add NgPdfFactory
endorama 0abc968
start isolating directive scope
endorama e173b53
move template out of directive
endorama 1679591
move page next-prev to factory
endorama dc70c7c
move zoom functions to factory
endorama 740eaeb
remove change pdf functionality (temporary)
endorama 53259a0
move fit to page to factory
endorama 11d5a93
refactor fit to page to properly use factory
endorama a236c52
use url from factory
endorama b783564
directive renderPage should be private
endorama 577d3f7
remove unused options from template
endorama 240f710
defined options as properties on factory
endorama 8658b0c
use currentPage from factory
endorama 15ff712
check pdfDoc presence in renderPage
endorama e9b3b5b
move rotate to factory
endorama 4010f34
change page from controller in a sane way
endorama 68d4f3b
fix pdf left rotation
endorama b84926c
pass url to factory as a proper argument
endorama 67e41cb
directive should properly render pdf again if it changes
endorama 7404096
refactor directive hooks
endorama fa999c7
disable not implemented features
endorama a50d845
implement password callback in directive
endorama 7d6944d
implement password callback for controller
endorama 6f33d72
add example for protected pdf
endorama File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
This file contains hidden or 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,34 +1,50 @@ | ||
| app.controller('DocCtrl', function($scope) { | ||
| app.controller('DocCtrl', function($scope, NgPdfFactory) { | ||
|
|
||
| $scope.pdfName = 'Relativity: The Special and General Theory by Albert Einstein'; | ||
| $scope.pdfUrl = 'pdf/relativity.pdf'; | ||
| $scope.pdfPassword = 'test'; | ||
| $scope.scroll = 0; | ||
| $scope.loading = 'loading'; | ||
| $scope.changePdfPage = 1; | ||
|
|
||
| $scope.pdfConfig = new NgPdfFactory('pdf/relativity.pdf', { fitToPage: true }); | ||
| $scope.protectedPdfConfig = new NgPdfFactory('pdf/relativity.protected.pdf', { fitToPage: true, useCredentials: true, password: 'test' }); | ||
|
|
||
| $scope.$watch('pdfUrl', (newVal, oldVal) => { | ||
| if (newVal !== '' && newVal !== oldVal) { | ||
| $scope.pdfConfig = new NgPdfFactory(newVal, { fitToPage: true }); | ||
| } | ||
| }); | ||
|
|
||
| $scope.$watch('changePdfPage', (newVal, oldVal) => { | ||
| if (newVal !== '' && newVal !== oldVal) { | ||
| $scope.pdfConfig.goToPage(newVal) | ||
| } | ||
| }); | ||
|
|
||
| $scope.$watch(() => { return $scope.pdfConfig.currentPage }, (newVal, oldVal) => { | ||
| if (newVal !== '' && newVal !== oldVal) { | ||
| $scope.changePdfPage = newVal; | ||
| } | ||
| }); | ||
|
|
||
| $scope.getNavStyle = function(scroll) { | ||
| if(scroll > 100) return 'pdf-controls fixed'; | ||
| else return 'pdf-controls'; | ||
| } | ||
|
|
||
| $scope.onError = function(error) { | ||
| console.log(error); | ||
| } | ||
| $scope.onPdfLoadingSuccess = function() { | ||
| console.log('pdf loaded') | ||
| }; | ||
|
|
||
| $scope.onLoad = function() { | ||
| $scope.loading = ''; | ||
| } | ||
| $scope.onPdfLoadingProgress = function (progressData) { | ||
| console.log('pdf loading on progress', progressData); | ||
| }; | ||
|
|
||
| $scope.onProgress = function (progressData) { | ||
| console.log(progressData); | ||
| $scope.onPdfLoadingError = function(error) { | ||
| console.log('pdf loading error', error); | ||
| }; | ||
|
|
||
| $scope.onPassword = function (updatePasswordFn, passwordResponse) { | ||
| if (passwordResponse === PDFJS.PasswordResponses.NEED_PASSWORD) { | ||
| updatePasswordFn($scope.pdfPassword); | ||
| } else if (passwordResponse === PDFJS.PasswordResponses.INCORRECT_PASSWORD) { | ||
| console.log('Incorrect password') | ||
| } | ||
| $scope.onIncorrectPdfPassword = function () { | ||
| console.error('password is wrong!'); | ||
| }; | ||
|
|
||
| }); | ||
This file contains hidden or 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
This file contains hidden or 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tests are broken on PhantomJS with ES6 sintax, maybe we can try to update PhantomJS or use old ES5 sintax?