Last active
August 29, 2015 14:04
-
-
Save lakenen/e230550bbf6fc050eb67 to your computer and use it in GitHub Desktop.
Offset first page in viewer.js LAYOUT_PRESENTATION_TWO_PAGE
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
Crocodoc.addDataProvider('page-offset', function (scope) { | |
return { | |
get: function (type, key) { | |
var $p, dp = scope.getDataProvider(type); | |
if (type === 'metadata') { | |
$p = dp.get(type); | |
return $p.then(function (data) { | |
data.numpages += 1; | |
var page, | |
exceptions = data.dimensions.exceptions, | |
newExceptions = {}; | |
for (page in exceptions) { | |
newExceptions[parseInt(page, 10) + 1] = exceptions[page]; | |
} | |
data.dimensions.exceptions = newExceptions; | |
return data; | |
}).promise({ | |
abort: $p.abort | |
}); | |
} else if (type === 'page-svg' || type === 'page-text') { | |
key -= 1; | |
if (key === 0) { | |
return $.Deferred().resolve('').promise({ | |
abort: function () {} | |
}); | |
} | |
return dp.get(type, key); | |
} else if (type === 'page-img') { | |
key -= 1; | |
if (key === 0) { | |
return $.Deferred().resolve(new Image()).promise({ | |
abort: function () {} | |
}); | |
} | |
return dp.get(type, key); | |
} | |
} | |
}; | |
}); |
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
.crocodoc-page:first-child { | |
visibility: hidden !important; | |
} |
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
var viewer = Crocodoc.createViewer('.container', { | |
url: '...', | |
dataProviders: { | |
metadata: 'page-offset', | |
'page-svg': 'page-offset', | |
'page-text': 'page-offset', | |
'page-img': 'page-offset' | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment