GithubHelp home page GithubHelp logo

box / viewer.js Goto Github PK

View Code? Open in Web Editor NEW
336.0 40.0 102.0 1.39 MB

A viewer for documents converted with the Box View API

License: Apache License 2.0

JavaScript 96.15% CSS 2.18% HTML 1.65% Shell 0.02%

viewer.js's Introduction

Build Status Project Status

Viewer.js

A viewer for documents converted with the Box View API.

Contents

Quick Start

Get the Source

You can find the pre-built development and production source files in the dist/ directory in this repository.

Viewer.js is available on npm and Bower:

npm install viewer
bower install viewer

All stable versions of viewer.js are hosted on CloudFlare's CDN, cdnjs. The unminified versions are available through the following URLs:

//cdnjs.cloudflare.com/ajax/libs/viewer.js/<VERSION>/crocodoc.viewer.css
//cdnjs.cloudflare.com/ajax/libs/viewer.js/<VERSION>/crocodoc.viewer.js

and the minified versions through:

//cdnjs.cloudflare.com/ajax/libs/viewer.js/<VERSION>/crocodoc.viewer.min.css
//cdnjs.cloudflare.com/ajax/libs/viewer.js/<VERSION>/crocodoc.viewer.min.js

For additional information, please see the cdnjs website.

v0.10.8

Development

Production

Loading a Simple Viewer

Crocodoc.createViewer(element, config)

Example

<link rel="stylesheet" href="crocodoc.viewer.min.css" />
<script type="text/javascript" src="jquery.min.js"></script>
<script type="text/javascript" src="crocodoc.viewer.min.js"></script>
<div class="viewer" style="height: 400px"></div>
<script type="text/javascript">
    var viewer = Crocodoc.createViewer('.viewer', {
        url: 'https://view-api.box.com/1/sessions/3c6abc0dcf35422e8353cf9c27578d5c/assets/'
    });
    viewer.load();
</script>

Logos

As per section 2.6 of our agreement of our API terms, we require that all apps using Box View with the Standard tier conspicuously display a Box logo when displaying Box View documents. We have included an approved logo within this repository. If your Box View plan permits custom branding of the viewer, please refer to Logo Options for instructions on how to build the viewer without the Box logo or with a custom logo.

Documentation

Library Methods

Crocodoc.createViewer(element, config)

Create and return a viewer instance initialized with the given parameters.

  • element the DOM element to initialize the viewer into
    • string: a query selector
    • Element: a DOM Element
    • Object: a jQuery object
  • config the configuration object

Crocodoc.addPlugin(pluginName, creatorFn)

Register a new plugin with the framework. See Plugins for more details.

  • pluginName the name of the plugin
  • creatorFn a function that creates and returns an instance of the plugin (which should be an object) when called

Viewer Config

The only required config parameter is url. All others are optional.

url (required)

The url parameter specifies the base URL where the document assets are located. Viewer.js will look for document assets (including info.json, stylesheet.css, etc) in this path.

layout

The layout parameter specifies the layout mode to use. Default Crocodoc.LAYOUT_VERTICAL. See Setting the Layout Mode for available layouts.

zoom

The zoom parameter specifies the initial zoom level to use. Default Crocodoc.ZOOM_AUTO.

Possible values:

  • Crocodoc.ZOOM_FIT_WIDTH - zooms to fit the width of the (largest) page within the viewport
  • Crocodoc.ZOOM_FIT_HEIGHT - zooms to fit the height of the (largest) page within the viewport
  • Crocodoc.ZOOM_AUTO - zooms to best fit the document within the viewport

page

The page parameter specifies the initial page number to show when the document loads. Default: 1.

enableTextSelection

The enableTextSelection parameter specifies whether or not users can select text. If true, users can select text. Default: true. Note: text selection is not supported in IE 8 see Browser Support for more information.

enableLinks

The enableLinks parameter specifies whether or not hyperlinks are enabled. If true, hyperlinks are enabled. Default: true.

enableDragging

The enableDragging parameter specifies whether or not dragging is enabled. If true, click-and-drag scrolling/panning will be enabled for this document. Default: false. NOTE: text selection is not fully supported when dragging is enabled. It is recommended that you disable text selection if you plan to enable dragging.

plugins

The plugins parameter allows you to specify a map of plugin names to their respective configs. Plugin names specified in this object will be loaded when the viewer is initialized. See Plugins for more details.

Example:

{
    plugins: {
        // my-plugin will be initialized with the following config
        'my-plugin': {
            foo: 1,
            bar: 2
        }
    }
}

queryParams

The queryParams parameter allows you to specify query string parameters to append to each asset request (eg., info.json or page-1.svg). Can be an object or string. Default: null.

Examples:

// as a string
{
    queryParams: 'hello=world&foo=bar'
}

// as an object
{
    queryParams: {
        hello: 'world',
        foo: ['bar', 'baz']
    }
}

useWindowAsViewport

The useWindowAsViewport parameter allows you to specify whether to use the browser window as the viewport for the document. This is useful when the document should take up the entire browser window (e.g., on mobile devices). Use this option on mobile devices to allow the browser to auto-hide browser chrome when scrolling. Default: false.

dataProviders

The dataProviders parameter allows you override default data providers by specifying names of replacement data providers. See data providers for more info.

Example:

{
    dataProviders: {
        // page-svg data provider will be overridden by the 'my-page-svg' data provider
        'page-svg': 'my-page-svg'
    }
}

Viewer Methods

destroy()

The destroy method removes and cleans up the viewer instance.

on(name, handler)

The on method binds an event handler for the specified event name fired by the viewer object. See Event Handling for available events.

off(name[, handler])

The off method unbinds an event handler for the specified event name and handler fired by the viewer object. If handler is not given, unbinds all event handlers on this viewer object with the given name.

scrollTo(page)

The scrollTo method scrolls the viewer to the specified page. The page argument may be one of the following:

  • (number) - scroll the the specified page number
  • Crocodoc.SCROLL_PREVIOUS - scroll to the previous page
  • Crocodoc.SCROLL_NEXT - scroll to the next page

Examples

// scroll to page 2
viewer.scrollTo(2);

// scroll to the next page
viewer.scrollTo(Crocodoc.SCROLL_NEXT);

zoom(val)

The zoom method sets the current zoom level of the document. Possible values:

  • Crocodoc.ZOOM_FIT_WIDTH - zooms to fit the width of the (largest) page within the viewport
  • Crocodoc.ZOOM_FIT_HEIGHT - zooms to fit the height of the (largest) page within the viewport
  • Crocodoc.ZOOM_AUTO - zooms to best fit the document within the viewport
  • Crocodoc.ZOOM_IN - zooms in
  • Crocodoc.ZOOM_OUT - zooms out

Examples

// zoom in
viewer.zoom(Crocodoc.ZOOM_IN);

// zoom to fit width
viewer.zoom(Crocodoc.ZOOM_FIT_WIDTH);

setLayout(mode)

The setLayout method sets the layout mode. See Setting the Layout Mode for available layouts.

Examples

viewer.setLayout(Crocodoc.LAYOUT_PRESENTATION);

Event Handling

The viewer object fires several different events. You can add and remove event listeners using the on and off methods.

Example

// ready event fires when the document metadata has loaded
// and the viewer is ready to be interacted with
viewer.on('ready', function (event) {
    console.log('the viewer is ready, and the document has ' + event.data.numPages + ' pages');
});

Viewer Events

  • asseterror Triggered if any asset fails to load. Event properties:
    • error - the error message
    • resource - the url of the resource that failed to load
    • status - the http status code
  • destroy Triggered when the document viewer is purposely destroyed with the destroy method.
  • fail Triggered if the document fails to load. Event properties:
    • error - the error details
  • ready Triggered as soon as a document becomes viewable. Event properties:
    • page - the current page
    • numPages - total number of pages in the document
  • resize Triggered when the viewer is resized. Event properties:
    • width - the viewport width
    • height - the viewport height
  • scrollstart Triggered when the user starts scrolling. Event properties:
    • scrollTop - the scrollTop position of the viewport
    • scrollLeft - the scrollLeft position of the viewport
  • scrollend Triggered when the user stops scrolling (or when the content stops moving if there is a momentum effect). Event properties:
    • scrollTop - the scrollTop position of the viewport
    • scrollLeft - the scrollLeft position of the viewport
  • zoom Triggered when the zoom value changes. Event properties:
    • zoom - current zoom value
    • zoomMode - current zoom mode (string or null)
    • canZoomOut - whether the viewer is able to zoom out (boolean)
    • canZoomIn - whether the viewer is able to zoom in (boolean)

Page Events

  • pagefocus Triggered whenever a new page is scrolled into view. Event properties:
    • page - page number
    • numPages - total number of pages in the document
    • visiblePages - an array of page numbers that are currently (fully or partially) visible in the viewport
  • pageload Triggered whenever a page is loaded. Event properties:
    • page - page number
  • pageunload Triggered whenever a page is unloaded to improve performance. Event properties:
    • page - page number
  • pagefail Triggered if a page fails to load. Event properties:
    • error - the error details
    • page - page number of the failed page

Setting the Layout Mode

Built-in Layout Modes

You can set a layout initially via the configuration object:

var viewer = Crocodoc.createViewer('.viewer', {
    url: 'https://view-api.box.com/1/sessions/<session_id>/assets/',
    layout: Crocodoc.LAYOUT_HORIZONTAL
});

Or via the setLayout method:

viewer.setLayout(Crocodoc.LAYOUT_PRESENTATION);

The currently supported layouts are:

  • Crocodoc.LAYOUT_VERTICAL Pages are scrolled vertically and arranged into one or more columns depending upon the current zoom.
  • Crocodoc.LAYOUT_VERTICAL_SINGLE_COLUMN Pages are scrolled vertically and arranged into a single column even when zoomed out.
  • Crocodoc.LAYOUT_HORIZONTAL Pages within the viewer are horizontally and arranged into a single row.
  • Crocodoc.LAYOUT_PRESENTATION One page is shown at a time with no scrolling. Custom transitions may be used to switch between pages.
  • Crocodoc.LAYOUT_PRESENTATION_TWO_PAGE Two pages are shown at a time, side by side, with no scrolling. Custom transitions may be used to switch between pages.

Other Layout Modes

The above list are the modes that are included as part of the bundled viewer.js library. Here are some other layout modes that can be included alongside the library to add new layout functionality:

  • 'vertical-two-page' Behaves like Crocodoc.LAYOUT_PRESENTATION_TWO_PAGE for zooming and Crocodoc.LAYOUT_VERTICAL for scrolling (gist).
  • 'presentation-vertical' Behaves like Crocodoc.LAYOUT_PRESENTATION for page layout (e.g., one page visible at a time) and Crocodoc.LAYOUT_VERTICAL for zooming (gist).
  • [Your layout here!] - if you have a layout you'd like to contribute, create a gist like the examples above, and we'd be happy to include it.

Styling Pages

.crocodoc-page and .crocodoc-page-content classes can be used to style pages, but there are some important restrictions:

  • .crocodoc-page: padding should be used to adjust page spacing (don't use margin for this)
  • .crocodoc-page: background should be transparent - use .crocodoc-page-content for changing the background of pages (including adding a background-image, such as a loading indicator)

Examples:

.crocodoc-page {
    /* 40px spacing around all sides of every page */
    padding: 40px;
}
.crocodoc-page {
    /* 40px spacing around the left and right sides of every page */
    padding: 0 40px;
}

/* the following can be used in a layout with pages that are side-by-side to remove spacing in the middle (e.g., custom layout 'vertical-two-page') */
.crocodoc-page {
    padding: 20px;
}
.crocodoc-page:nth-child(even) {
    padding-left: 0;
}
.crocodoc-page:nth-child(odd) {
    padding-right: 0;
}

/* add a box-shadow to pages */
.crocodoc-page-content {
    box-shadow: 1px 1px 2px #000;
}

/* change the background color of pages */
.crocodoc-page-content {
    background-color: papayawhip;
}

/* add a spinner image to loading pages */
.crocodoc-page-loading .crocodoc-page-content {
    background: #FFF url('../images/spinner.gif') center center no-repeat;
}

/* mirror all pages horizontally (?!) */
.crocodoc-page-content {
    -webkit-transform: scale(-1, 1);
    -ms-transform: scale(-1, 1);
    transform: scale(-1, 1);
}

Presentation Transitions

With viewer.js in presentation (Crocodoc.LAYOUT_PRESENTATION) layout mode, it is possible to add custom page transitions using pure CSS. The viewer automatically applies CSS classes to the pages appropriately so that you can write CSS that will affect the current, previous, and next pages, as well as all pages before and after the current page.

To see some examples, look at the CSS files in "presentations" example included with this repo.

The classes available are:

  • .crocodoc-current-page: the current page
  • .crocodoc-preceding-page: the last "current" page (i.e. the page that had the crocodoc-current-page class before the most recent pagefocus event)
  • .crocodoc-page-prev: the previous page
  • .crocodoc-page-next: the next page
  • .crocodoc-page-before: any page before the current page (including the previous page)
  • .crocodoc-page-after: any page after the current page (including the next page)

Realtime Page Streaming

The Box View API conversion pipeline is optimized to minimize time to view the first page of a document. This means that a session can be created and a document can be viewed as soon as page 1 (and some metadata) is finished converting. It is now possible to use viewer.js to view documents as soon as the first page is ready by using the realtime plugin. This plugin makes a connection to the Box View API's realtime channel (a link to which is provided in the urls parameter of the session creation response), which streams updates about the conversion progress of a document.

Plugins

Plugins are reusable components that can hook into viewer.js instances to add functionality. Plugins are initialized when a viewer instance is created and have their own configuration options.

See /plugins for some plugin examples.

Example:

// add a plugin that tracks how long a user was on each page
Crocodoc.addPlugin('analytics', function (scope) {
    var currentPage,
        startTime,
        config;

    function track(page) {
        var elapsed,
            now = Date.now();
        if (currentPage) {
            elapsed = now - startTime;
            if (typeof config.ontrack === 'function') {
                config.ontrack(currentPage, elapsed / 1000);
            }
        }
        startTime = now;
        currentPage = page;
    }

    return {
        // the messages property tells the viewer which messages this 
        // plugin is interested in
        messages: ['pagefocus'],

        // this onmessage method is called when a message listed above 
        // is broadcast within the viewer instance
        onmessage: function (name, data) {
            // in this case, we are only listening for one message type,
            // so we don't need to do any checking against the name value
            track(data.page);
        },

        // init is called when the viewer is initialized, and the plugin
        // config is passed as a parameter
        init: function (pluginConfig) {
            config = pluginConfig;
        }
    };
});

// When creating the viewer, just include analytics in the plugins config
var viewer = Crocodoc.createViewer('.viewer', {
    url: '/path/to/assets',
    plugins: {
        // config for the analytics plugin
        analytics: {
            ontrack: function (page, seconds) {
                console.log(seconds + 's spent on page ' + page);
            }
        }
    }
});

Data Providers

See the JS architecture overview for information about data providers.

Text Documents

As of v0.10.0, viewer.js supports rendering text-based documents converted by the Box View API. This functionality is in beta until further notice, and many of the page-related API methods, events, and configuration properties in viewer.js will not have any affect on text documents. The viewer will automatically switch into text-based document mode when you provide it with a URL that points to a text document converted with the View API.

Syntax Highlighting

Many source code formats will be converted to HTML for use with viewer.js such that you can enable syntax highlighting. To enable syntax highlighting, simply include a Pygments-compatible CSS stylesheet in the page with your viewer. The Box View iframe viewer uses a stylesheet similar to this one.

Browser Support

Viewer.js is supported in all modern desktop and mobile browsers. It will fall back to raster images in older browsers that do not support SVG.

NOTE: raster fall-back requires that .png representations have already been generated for the converted document.

Contributing

See CONTRIBUTING.md.

Getting Started with the Code

Dev Dependencies

To install the development dependencies, you'll need node and npm. Most node installs come with npm pre-packaged.

Once you have npm, you'll need to install grunt-cli:

npm install -g grunt-cli

Then go to the viewer.js directory and run:

npm install

That's it! You should be setup with development dependencies and ready to go.

Git Hooks

Viewer.js comes with a pre-commit git hook that runs the unit tests before allowing a commit. This is a useful way to make sure you don't accidentally commit code that breaks unit tests. To install the git hook, just run:

./install-githooks.sh

Grunt

  • grunt test - runs jshint and qunit tests against the code
  • grunt doc - runs test and jsdoc to generate documentation in doc/
  • grunt (alias for grunt default) - runs test and concat to build the following files:
    • dist/crocodoc.viewer.js
    • dist/crocodoc.viewer.css
  • grunt build - runs default as well as cssmin and uglify to build the following compressed files (in addition to the files built in grunt default):
    • dist/crocodoc.viewer.min.js
    • dist/crocodoc.viewer.min.css
  • grunt serve - runs a static webserver for viewing examples and qunit tests
    • defaults to port 9000
    • examples: http://localhost:9000/examples
    • tests: http://localhost:9000/test

Logo Options

There is an additional option that can be specified when running grunt tasks: --no-logo. If this flag is added, logos will not be embedded into the resulting CSS file (dist/crocodoc.viewer(.min).css).

If you would like to replace the Box logo with your own, you can simply replace src/images/logo.png and src/images/[email protected] with your own logos. Running grunt or grunt build will embed the images into the resulting CSS files.

NOTE: Make sure you are allowed to remove logos before building with this option. For more information, see Logos above.

For more information about the code, see the JS architecture overview

Common Issues

I did everything right! Why am I seeing a blank screen?

  1. If you don't see any errors in the JavaScript console, your viewer's container element might have a height of 0px. Viewer.js does not force a height on its container element, so that needs to be set by the developer (whether it's a percent or explicit pixel value doesn't matter):

    <div class="viewer" style="height: 560px"></div>
  2. Are you loading assets from a file:// URL? Many browsers' security policies block these requests, so viewer.js is unable to load assets. To resolve this issue, you can run a local server using grunt serve (see Getting Started with the Code) or save your assets to some remote server for testing.

  3. If you are loading the assets from your own server, but the viewer is on a different origin (hostname), then you must include a CORS HTTP header with the served asset files. The quickest fix is to add the HTTP response header Access-Control-Allow-Origin: * (but you will almost certainly want to be more specific than *, or else to restrict access to your asset files in some other way).

  4. IE 8 and 9 have a bug in the XHR/XDR implementation that causes requests to HTTPS domains to fail if they originate from an HTTP domain (with the error: "Access Denied"). If your domain is running on HTTP, Box View API URLs will fail on IE 8 and 9. At the moment, the View API only responds on HTTPS, so we have no workaround for this issue other than to recommend that you use SSL on your site.

Change Log

See CHANGELOG.md.

Copyright and License

Copyright 2014 Box, Inc. All rights reserved.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

viewer.js's People

Contributors

acolchagoff avatar andrecardoso avatar codyebberson avatar flyingfisch avatar klaascuvelier avatar lakenen avatar mikebeaton avatar nzakas avatar priyajeet avatar seanrose avatar silvamerica avatar spl avatar tonyjin avatar yvesmh avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

viewer.js's Issues

npm install fails when cloned as git submodule

The npm install fails as follows:

> [email protected] postinstall /home/docmunch/dox/vendor/box/viewer.js
> cp git-hooks/* .git/hooks/

cp: accessing ‘.git/hooks/’: Not a directory

npm ERR! [email protected] postinstall: `cp git-hooks/* .git/hooks/`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] postinstall script.
npm ERR! This is most likely a problem with the crocodoc-viewer package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     cp git-hooks/* .git/hooks/
npm ERR! You can get their info via:
npm ERR!     npm owner ls crocodoc-viewer
npm ERR! There is likely additional logging output above.
npm ERR! System Linux 3.11.0-12-generic
npm ERR! command "/usr/bin/node" "/usr/bin/npm" "install"
npm ERR! cwd /home/docmunch/dox/vendor/box/viewer.js
npm ERR! node -v v0.10.25
npm ERR! npm -v 1.3.24
npm ERR! code ELIFECYCLE
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR!     /home/docmunch/dox/vendor/box/viewer.js/npm-debug.log
npm ERR! not ok code 0

In a submodule, .git is not a directory but a text file with a gitdir reference.

(I realize that this does not mean the installation was unsuccessful. But the postinstall script should probably take into account that .git is not always an available directory.)

Two-pages Fit Width

Hi! I'm givig to user the option of watch the document in two-pages mode and it works fine, but viewer's viewport doesn't fits to page's viewport, producing an horizontal overflow, which is not solved by Crocodoc.ZOOM_FIT_WIDTH function. Only after window resize event, which logically changes page width, this function provides the expected result (In our project, when window resize is fired, automatically throws fit-width function).
Could you help me?
Thanks!

Using the realtime plugin properly

I'm experimenting with the realtime plugin, but it doesn't appear to be needed or doing much in my case. I'm wondering if it's due to the way I'm using it.

  1. I upload a doc and poll until the doc is done (which is required according to the documentation: “Sessions can only be created for documents that have a status of done.”).
  2. I then create a session. This happens pretty quickly.
  3. I then load the viewer.js with the session ID from the session creation.
  4. I do see the realtimecomplete event fired, but I never see a realtimeupdate.

I can't load viewer.js until I have a session ID, and I can't create a session until the document is done. What am I missing?

Insert advertisement banner between pages

Hi all,

I want to add some image banners for advertising.
Example:

  • page 3
  • banner ads
  • page 4

How can I do that.

I have read the document but no idea to custom.

Regards

Images don't display in iOS 6.1

I've just ran into a bug - the Box View viewer / viewer.js does not work
with iOS 6. When viewing a presentation with images, the images do not show
up - it seems that it's using some SVG feature that iOS 6 doesn't support.

You can reproduce this bug by going to https://developers.box.com/view/ on
an iOS 6 device, or in the iOS 6 Simulator, and paging down in your demo
slideshow until you get to the screenshots that should appear (starting
from page 5).

Until this issue is fixed it would also be great to clarify the Mobile Safari support, as this appears to be a known issue (after contacting Box support) but is not made explicit anywhere I could see.

Boxes become perforated on conversion

When converting the PDF below (actual file sent to @lakenen) the boxes on the first slide are perforated. This is not in the actual PDF pages. Pages 2 and 3 with same box formats appear to work well.

Hidden document viewer does not load pages in Firefox

We're seeing issues with viewer.js in Firefox where the document does not load when the containing element starts off as hidden.

Here's a jsbin example that works in Chrome and Safari but not in Firefox.
http://jsbin.com/xezafoko/1/edit

It shows a tabbed page where each tab contains a document viewer. The 2nd hidden tab starts to load but then stops and none of the pages are loaded.

Pinch In/Out in mobile

Hi, I've succesfuly implemented and customized viewer.js in a responsive template, adding Draggable option. I can swipe between the pages, but I would like to zoom in / out in pinch event of mobile. I ask you if exists a plugin which solve this. The precarious solution I found is catching this event and throw zoom method, but I would like to get a better solution. Alternatively, I could develop and publish it but I would need your help.

Thanks!

Links don't work in IE 8 or lower

I'm not sure if we will fix this or not. At the moment, we disable links in browsers that don't support CSS transforms, because auto-scaling is very difficult to do correctly without them.

Javascript syntax issue on docviewer JS

Not sure if the syntax error is originating in this project directly, or in how docviewer is served up, but our viewer is broken today with:

Uncaught SyntaxError: Unexpected token ; static.view-api.box.com/scripts/docviewer.f5903fb711e2.js:4

Uncaught ReferenceError: init is not defined view-api.box.com/1/sessions/5764aad5d0a6453499b72ccd80c4de88/view?theme=dark:46

Single page layout in 'presentation-two-page' layout mode for first page of document

Are you able to create an option to set the first page of a document set in ‘presentation-two-page’ layout as a single page?
The problem is nearly all brochures are created as spreads and by having the first two pages as a spread and not the first page as a single page it throws off the flow of spreads for the entire document i.e. page 3 is in a spread with page 4, instead of with page 2.

Signed urls

How do we do signed urls with the url parameter?

e.g.,

url : "https://s3.amazonaws.com/my-bucket/BoxDocs/"

I had talked to Sean Rose about this about a year ago. If this doesn't exist, can a param be added to Crocodoc.createViewer, e.g., signature: "?token=asdf", to append the signature to all the urls in my "BoxDocs" directory?

Links in MS Office files

Are there plans to support links in MS Office documents? I created a test pptx file with an internal and external link but they don't appear to be recognized as links by viewer.js

Unable to load assets from local filesystem

XMLHttpRequest returns status 0 for requests made to the local filesystem. The ajax code in viewer.js considers this a failure, thus preventing an local assets from being loaded in the viewer.

Non-link URLs are not clickable

This could possibly be solved on the conversion end, or possibly within viewer.js, but URLs embedded in documents that were not actual links in the original document are not clickable in viewer.js. Many PDF viewers will try to be smarter about this and turn them into links if they look like URLs, and I think we could probably do something similar in the conversion process.

Showing one page at a time with LAYOUT_VERTICAL_SINGLE_COLUMN auto zoom behavior

Is there a way to have viewer.js operate in the PRESENTATION layout (show only one page at a time) while maintaining the auto-zoom behavior of LAYOUT_VERTICAL_SINGLE_COLUMN (don't try to squish the current page into the viewport if it is wider than it is tall, but still adjust dynamically when the viewport becomes very small).

Phrased another way, I'm trying to figure out how to stick with the LAYOUT_VERTICAL_SINGLE_COLUMN layout except only show one page at a time. So far I don't see a direct way of doing this. Am I missing something?

Implementing a "Fullscreen" option

Hi, do you have any examples or recommendations if we want to use this primarily with "LAYOUT_PRESENTATION" and we want to give users a "Fullscreen" button?

White area under page content

I'm seeing a white area under each page that is misaligned with the page itself. On portrait pages, it appears as an extra horizontal bar on the top and bottom; on landscape page, it's on the left and right sides.

See screenshot below:
screen shot 2014-05-19 at 2 45 49 pm

Errors inside 'ready' callback are silenced

Once instantiating a viewer, this code will fail silently without raising any error visible in the browser console - this cost us a few hours of time that would have been saved had we seen it in the console. It seems to be swallowed inside viewer.js.

            docviewer.on('ready', function (e) {
                my_undefined_var.foo();
            });

Thanks!

Two-Pages Scrolling

Hi! Our client is suggesting us to enable scrolling between pages in Two Pages mode. As you know, this view is only provided in presentation mode.
Plan to provide this functionality?
Thanks!

IE 10 Text Layer Font Issue

Text Layers in IE 10 do not render fonts properly when a viewer is, then destroyed, then created for the same document.

Use “session ID” in realtime documentation

In the documentation for the realtime plugin, I think you should use the term “session ID” instead of <uuid> to identify what should be passed to the url parameter. That would be a bit more clear than “the Box View realtime URL received when requesting a session” (here). I have not seen <uuid> anywhere, but I was able to confirm that it wasthe session ID by seeing the duplication in the Example 201 Response of the POST /sessions documentation.

Centering broken if Bootstrap css loaded

Bootstrap 3's css forces box-sizing:border-box on all elements, and this conflicts with the updatePageMargins calculations for margins on pages (at least for presentation layout), leading to pages that are off-center.

While this is not really the fault of viewer.js, Bootstrap is so common (and forcing border-box is also common) that it could be worthwhile to explicitly set box-sizing in viewer css to something like:

.crocodoc-viewer * {
    -webkit-box-sizing: initial;
    -moz-box-sizing: initial;
    box-sizing: initial;
}

...or update the updatePageMargins calculations (no longer need to calculate padding on each page) and explicitly set box-sizing:border-box.

Handle large (1000+ page) documents better

Currently, we generate the DOM objects for all pages at init, but we could be smarter about loading only a small subset of these pages, then adding more (and removing some) as necessary.

Need layout for horizontal thumbnails

We wanted to create a thumbnail experience similar to the thumbnail example, but with the thumbnails on the bottom of the screen. Using the built-in horizontal layout didn't work as it forces the current slide to be on the left edge of the scroller. Instead we wanted to center the current slide only if it wasn't in view, otherwise the thumbnail viewer shouldn't scroll on its own.

No 'Access-Control-Allow-Origin' header for signed urls (AWS S3 vs. Cloudfront)

CORS Issue (Subdomain related?)

I'm getting the following CORS issue. No idea why this is, unless the subdomain is conflicting. I simply followed the guide on here, created a session, pass the session URL as the URL to createViewer and get this. Any ideas?

XMLHttpRequest cannot load https://view-api.box.com/1/sessions/33a698bb3f004870bd57b37b48d81cbf/view/info.json. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'https://subdomain.mysite.co' is therefore not allowed access. demo.knowledgehound.co/#/results:1
Failed to load resource: the server responded with a status of 404 (NOT FOUND)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.