├── .editorconfig
├── .gitignore
├── .jshintrc
├── API-README.md
├── CHANGELOG.md
├── CONTRIBUTING.md
├── LICENSE
├── README.md
├── bower.json
├── dist
├── view-file-ng.css
├── view-file-ng.js
├── view-file-ng.min.css
└── view-file-ng.min.js
├── gulpfile.js
├── jsdoc.conf.json
├── karma.conf.js
├── less
└── view-file-ng.less
├── package-lock.json
├── package.json
├── src
├── friendly-json.controller.js
├── friendly-json.directive.js
├── friendly-json.html
├── friendly-xml.controller.js
├── friendly-xml.directive.js
├── include-safe.directive.js
├── modal.service.js
├── show-file.modal.html
├── view-file.controller.js
├── view-file.directive.js
├── view-file.html
├── view-file.module.js
└── view-object.directive.js
└── test
├── .jshintrc
├── helpers.js
└── spec
└── d3-cloud.js
/.editorconfig:
--------------------------------------------------------------------------------
1 | # http://editorconfig.org
2 | root = true
3 |
4 | [*]
5 | indent_style = space
6 | indent_size = 2
7 | end_of_line = lf
8 | charset = utf-8
9 | trim_trailing_whitespace = true
10 | insert_final_newline = true
11 |
12 | [*.md]
13 | trim_trailing_whitespace = false
14 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | node_modules
2 | .tmp
3 | bower_components
4 | npm-debug.log
5 | *.map
6 | .DS_Store
7 | Thumbs.db
8 | build/
9 | .publish/
10 | docs/
11 | out/
--------------------------------------------------------------------------------
/.jshintrc:
--------------------------------------------------------------------------------
1 | {
2 | "browser": true,
3 | "camelcase": true,
4 | "curly": true,
5 | "eqeqeq": true,
6 | "immed": true,
7 | "indent": 2,
8 | "latedef": "nofunc",
9 | "newcap": true,
10 | "quotmark": "single",
11 | "undef": true,
12 | "unused": "vars",
13 | "strict": true,
14 | "trailing": true,
15 | "globals": {
16 | "console": false,
17 | "angular": false,
18 | "google": false,
19 | "$": false,
20 | "_": false,
21 | "d3": false
22 | }
23 | }
24 |
25 |
--------------------------------------------------------------------------------
/API-README.md:
--------------------------------------------------------------------------------
1 | # view.file
2 | Angular directive for previewing files.
3 |
4 | Click components on the right for details.
5 |
--------------------------------------------------------------------------------
/CHANGELOG.md:
--------------------------------------------------------------------------------
1 | # Change Log
2 |
3 | ## [0.1.5](https://github.com/grtjn/view-file-ng/tree/0.1.5) (2019-04-26)
4 | [Full Changelog](https://github.com/grtjn/view-file-ng/compare/0.1.4...0.1.5)
5 |
6 | **Fixed bugs:**
7 |
8 | - Friendly-json prints strings in arrays badly if preceded by an object [\#23](https://github.com/grtjn/view-file-ng/issues/23)
9 |
10 | **Closed issues:**
11 |
12 | - Revert to master json-explorer [\#22](https://github.com/grtjn/view-file-ng/issues/22)
13 |
14 | ## [0.1.4](https://github.com/grtjn/view-file-ng/tree/0.1.4) (2017-12-04)
15 | [Full Changelog](https://github.com/grtjn/view-file-ng/compare/0.1.3...0.1.4)
16 |
17 | **Fixed bugs:**
18 |
19 | - ng-json-explorer not working with angular 1.6+ [\#20](https://github.com/grtjn/view-file-ng/issues/20)
20 |
21 | ## [0.1.3](https://github.com/grtjn/view-file-ng/tree/0.1.3) (2017-06-26)
22 | [Full Changelog](https://github.com/grtjn/view-file-ng/compare/0.1.2...0.1.3)
23 |
24 | **Fixed bugs:**
25 |
26 | - ng-json-explorer broken [\#16](https://github.com/grtjn/view-file-ng/issues/16)
27 |
28 | ## [0.1.2](https://github.com/grtjn/view-file-ng/tree/0.1.2) (2017-02-06)
29 | [Full Changelog](https://github.com/grtjn/view-file-ng/compare/0.1.1...0.1.2)
30 |
31 | **Fixed bugs:**
32 |
33 | - vkbeautify-wrapper no longer exists [\#12](https://github.com/grtjn/view-file-ng/issues/12)
34 |
35 | ## [0.1.1](https://github.com/grtjn/view-file-ng/tree/0.1.1) (2016-11-29)
36 | [Full Changelog](https://github.com/grtjn/view-file-ng/compare/0.1.0...0.1.1)
37 |
38 | **Implemented enhancements:**
39 |
40 | - Improve \(delayed\) loading of content [\#8](https://github.com/grtjn/view-file-ng/issues/8)
41 | - Allow showing data loaded upfront [\#6](https://github.com/grtjn/view-file-ng/issues/6)
42 | - Allow template overrides for all directives [\#4](https://github.com/grtjn/view-file-ng/issues/4)
43 |
44 | **Fixed bugs:**
45 |
46 | - Transclude in view-object not working [\#11](https://github.com/grtjn/view-file-ng/issues/11)
47 | - Unused whitespace below audio player [\#10](https://github.com/grtjn/view-file-ng/issues/10)
48 | - Using view-file in slush-marklogic-node dashboard theme looks bad [\#9](https://github.com/grtjn/view-file-ng/issues/9)
49 |
50 | ## [0.1.0](https://github.com/grtjn/view-file-ng/tree/0.1.0) (2016-09-06)
51 | **Fixed bugs:**
52 |
53 | - Fix file viewer overlap issue.. [\#2](https://github.com/grtjn/view-file-ng/issues/2)
54 |
55 |
56 |
57 | \* *This Change Log was automatically generated by [github_changelog_generator](https://github.com/skywinder/Github-Changelog-Generator)*
--------------------------------------------------------------------------------
/CONTRIBUTING.md:
--------------------------------------------------------------------------------
1 | # Contributing to view-file-ng
2 |
3 | view-file-ng welcomes new contributors. This document will guide you
4 | through the process.
5 |
6 | - [Question or Problem?](#question)
7 | - [Issues and Bugs](#issue)
8 | - [Feature Requests](#feature)
9 | - [Submission Guidelines](#submit)
10 |
11 | ## Got a Question or Problem?
12 |
13 | If you have questions about how to use view-file-ng, check our documentation on the [Wiki][wiki]. Alternatively, check [Stack Overflow][stack] to see if it has been answered there, and post your question there if not. Please tag it with AngularJS.
14 |
15 | ## Found an Issue?
16 |
17 | If you find a bug in the source code or a mistake in the documentation, you can help us by
18 | submitting an issue to our [GitHub Issue Tracker][issue tracker]. Even better you can submit a Pull Request
19 | with a fix for the issue you filed.
20 |
21 | ## Want a Feature?
22 |
23 | You can request a new feature by submitting an issue to our [GitHub Issue Tracker][issue tracker]. If you
24 | would like to implement a new feature then first create a new issue and discuss it with one of our
25 | project maintainers.
26 |
27 | ## Submission Guidelines
28 |
29 | ### Submitting an Issue
30 |
31 | Before you submit your issue search the archive, maybe your question was already answered.
32 |
33 | If your issue appears to be a bug, and hasn't been reported, open a new issue.
34 | Help us to maximize the effort we can spend fixing issues and adding new
35 | features, by not reporting duplicate issues. Providing the following information will increase the
36 | chances of your issue being dealt with quickly:
37 |
38 | * **Overview of the Issue** - if an error is being thrown a stack trace helps
39 | * **Motivation for or Use Case** - explain why this is a bug for you
40 | * **view-file-ng Version** - is it a named version or from our master branch
41 | * **Browser** - Chrome, FireFox, Safari? details help
42 | * **Suggest a Fix** - if you can't fix the bug yourself, perhaps you can point to what might be
43 | causing the problem (line of code or commit)
44 |
45 | ### Submitting a Pull Request
46 |
47 | #### Fork view-file-ng
48 |
49 | Fork the project [on GitHub](https://github.com/grtjn/view-file-ng/fork) and clone
50 | your copy.
51 |
52 | ```sh
53 | $ git clone git@github.com:username/view-file-ng.git
54 | $ cd view-file-ng
55 | $ git remote add upstream git://github.com/grtjn/view-file-ng.git
56 | ```
57 |
58 | All bug fixes and new features go into the master branch.
59 |
60 | We ask that you open an issue in the [issue tracker][] and get agreement from
61 | at least one of the project maintainers before you start coding.
62 |
63 | Nothing is more frustrating than seeing your hard work go to waste because
64 | your vision does not align with that of a project maintainer.
65 |
66 | #### Create a branch for your changes
67 |
68 | Okay, so you have decided to fix something. Create a feature branch
69 | and start hacking:
70 |
71 | ```sh
72 | $ git checkout -b my-feature-branch -t origin/master
73 | ```
74 |
75 | #### Formatting code
76 |
77 | We use [.editorconfig][] to configure our editors for proper code formatting. If you don't
78 | use a tool that supports editorconfig be sure to configure your editor to use the settings
79 | equivalent to our .editorconfig file.
80 |
81 | #### Commit your changes
82 |
83 | Make sure git knows your name and email address:
84 |
85 | ```sh
86 | $ git config --global user.name "J. Random User"
87 | $ git config --global user.email "j.random.user@example.com"
88 | ```
89 |
90 | Writing good commit logs is important. A commit log should describe what
91 | changed and why. Follow these guidelines when writing one:
92 |
93 | 1. The first line should be 50 characters or less and contain a short
94 | description of the change including the Issue number prefixed by a hash (#).
95 | 2. Keep the second line blank.
96 | 3. Wrap all other lines at 72 columns.
97 |
98 | A good commit log looks like this:
99 |
100 | ```
101 | Fixing Issue #123: make the whatchamajigger work in MarkLogic 8
102 |
103 | Body of commit message is a few lines of text, explaining things
104 | in more detail, possibly giving some background about the issue
105 | being fixed, etc etc.
106 |
107 | The body of the commit message can be several paragraphs, and
108 | please do proper word-wrap and keep columns shorter than about
109 | 72 characters or so. That way `git log` will show things
110 | nicely even when it is indented.
111 | ```
112 |
113 | The header line should be meaningful; it is what other people see when they
114 | run `git shortlog` or `git log --oneline`.
115 |
116 | #### Rebase your repo
117 |
118 | Use `git rebase` (not `git merge`) to sync your work from time to time.
119 |
120 | ```sh
121 | $ git fetch upstream
122 | $ git rebase upstream/master
123 | ```
124 |
125 | #### Push your changes
126 |
127 | ```sh
128 | $ git push origin my-feature-branch
129 | ```
130 |
131 | #### Submit the pull request
132 |
133 | Go to https://github.com/username/view-file-ng and select your feature branch. Click
134 | the 'Pull Request' button and fill out the form.
135 |
136 | Pull requests are usually reviewed within a few days. If you get comments
137 | that need to be to addressed, apply your changes in a separate commit and push that to your
138 | feature branch. Post a comment in the pull request afterwards; GitHub does
139 | not send out notifications when you add commits to existing pull requests.
140 |
141 | That's it! Thank you for your contribution!
142 |
143 | #### After your pull request is merged
144 |
145 | After your pull request is merged, you can safely delete your branch and pull the changes
146 | from the main (upstream) repository:
147 |
148 | * Delete the remote branch on GitHub either through the GitHub web UI or your local shell as follows:
149 |
150 | ```shell
151 | git push origin --delete my-feature-branch
152 | ```
153 |
154 | * Check out the master branch:
155 |
156 | ```shell
157 | git checkout master -f
158 | ```
159 |
160 | * Delete the local branch:
161 |
162 | ```shell
163 | git branch -D my-feature-branch
164 | ```
165 |
166 | * Update your master with the latest upstream version:
167 |
168 | ```shell
169 | git pull --ff upstream master
170 | ```
171 |
172 | [wiki]: https://github.com/grtjn/view-file-ng/wiki
173 | [stack]: http://stackoverflow.com/questions/tagged/angularjs
174 | [issue tracker]: https://github.com/grtjn/view-file-ng/issues
175 | [.editorconfig]: http://editorconfig.org/
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | Apache License
2 | Version 2.0, January 2004
3 | http://www.apache.org/licenses/
4 |
5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6 |
7 | 1. Definitions.
8 |
9 | "License" shall mean the terms and conditions for use, reproduction,
10 | and distribution as defined by Sections 1 through 9 of this document.
11 |
12 | "Licensor" shall mean the copyright owner or entity authorized by
13 | the copyright owner that is granting the License.
14 |
15 | "Legal Entity" shall mean the union of the acting entity and all
16 | other entities that control, are controlled by, or are under common
17 | control with that entity. For the purposes of this definition,
18 | "control" means (i) the power, direct or indirect, to cause the
19 | direction or management of such entity, whether by contract or
20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the
21 | outstanding shares, or (iii) beneficial ownership of such entity.
22 |
23 | "You" (or "Your") shall mean an individual or Legal Entity
24 | exercising permissions granted by this License.
25 |
26 | "Source" form shall mean the preferred form for making modifications,
27 | including but not limited to software source code, documentation
28 | source, and configuration files.
29 |
30 | "Object" form shall mean any form resulting from mechanical
31 | transformation or translation of a Source form, including but
32 | not limited to compiled object code, generated documentation,
33 | and conversions to other media types.
34 |
35 | "Work" shall mean the work of authorship, whether in Source or
36 | Object form, made available under the License, as indicated by a
37 | copyright notice that is included in or attached to the work
38 | (an example is provided in the Appendix below).
39 |
40 | "Derivative Works" shall mean any work, whether in Source or Object
41 | form, that is based on (or derived from) the Work and for which the
42 | editorial revisions, annotations, elaborations, or other modifications
43 | represent, as a whole, an original work of authorship. For the purposes
44 | of this License, Derivative Works shall not include works that remain
45 | separable from, or merely link (or bind by name) to the interfaces of,
46 | the Work and Derivative Works thereof.
47 |
48 | "Contribution" shall mean any work of authorship, including
49 | the original version of the Work and any modifications or additions
50 | to that Work or Derivative Works thereof, that is intentionally
51 | submitted to Licensor for inclusion in the Work by the copyright owner
52 | or by an individual or Legal Entity authorized to submit on behalf of
53 | the copyright owner. For the purposes of this definition, "submitted"
54 | means any form of electronic, verbal, or written communication sent
55 | to the Licensor or its representatives, including but not limited to
56 | communication on electronic mailing lists, source code control systems,
57 | and issue tracking systems that are managed by, or on behalf of, the
58 | Licensor for the purpose of discussing and improving the Work, but
59 | excluding communication that is conspicuously marked or otherwise
60 | designated in writing by the copyright owner as "Not a Contribution."
61 |
62 | "Contributor" shall mean Licensor and any individual or Legal Entity
63 | on behalf of whom a Contribution has been received by Licensor and
64 | subsequently incorporated within the Work.
65 |
66 | 2. Grant of Copyright License. Subject to the terms and conditions of
67 | this License, each Contributor hereby grants to You a perpetual,
68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69 | copyright license to reproduce, prepare Derivative Works of,
70 | publicly display, publicly perform, sublicense, and distribute the
71 | Work and such Derivative Works in Source or Object form.
72 |
73 | 3. Grant of Patent License. Subject to the terms and conditions of
74 | this License, each Contributor hereby grants to You a perpetual,
75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76 | (except as stated in this section) patent license to make, have made,
77 | use, offer to sell, sell, import, and otherwise transfer the Work,
78 | where such license applies only to those patent claims licensable
79 | by such Contributor that are necessarily infringed by their
80 | Contribution(s) alone or by combination of their Contribution(s)
81 | with the Work to which such Contribution(s) was submitted. If You
82 | institute patent litigation against any entity (including a
83 | cross-claim or counterclaim in a lawsuit) alleging that the Work
84 | or a Contribution incorporated within the Work constitutes direct
85 | or contributory patent infringement, then any patent licenses
86 | granted to You under this License for that Work shall terminate
87 | as of the date such litigation is filed.
88 |
89 | 4. Redistribution. You may reproduce and distribute copies of the
90 | Work or Derivative Works thereof in any medium, with or without
91 | modifications, and in Source or Object form, provided that You
92 | meet the following conditions:
93 |
94 | (a) You must give any other recipients of the Work or
95 | Derivative Works a copy of this License; and
96 |
97 | (b) You must cause any modified files to carry prominent notices
98 | stating that You changed the files; and
99 |
100 | (c) You must retain, in the Source form of any Derivative Works
101 | that You distribute, all copyright, patent, trademark, and
102 | attribution notices from the Source form of the Work,
103 | excluding those notices that do not pertain to any part of
104 | the Derivative Works; and
105 |
106 | (d) If the Work includes a "NOTICE" text file as part of its
107 | distribution, then any Derivative Works that You distribute must
108 | include a readable copy of the attribution notices contained
109 | within such NOTICE file, excluding those notices that do not
110 | pertain to any part of the Derivative Works, in at least one
111 | of the following places: within a NOTICE text file distributed
112 | as part of the Derivative Works; within the Source form or
113 | documentation, if provided along with the Derivative Works; or,
114 | within a display generated by the Derivative Works, if and
115 | wherever such third-party notices normally appear. The contents
116 | of the NOTICE file are for informational purposes only and
117 | do not modify the License. You may add Your own attribution
118 | notices within Derivative Works that You distribute, alongside
119 | or as an addendum to the NOTICE text from the Work, provided
120 | that such additional attribution notices cannot be construed
121 | as modifying the License.
122 |
123 | You may add Your own copyright statement to Your modifications and
124 | may provide additional or different license terms and conditions
125 | for use, reproduction, or distribution of Your modifications, or
126 | for any such Derivative Works as a whole, provided Your use,
127 | reproduction, and distribution of the Work otherwise complies with
128 | the conditions stated in this License.
129 |
130 | 5. Submission of Contributions. Unless You explicitly state otherwise,
131 | any Contribution intentionally submitted for inclusion in the Work
132 | by You to the Licensor shall be under the terms and conditions of
133 | this License, without any additional terms or conditions.
134 | Notwithstanding the above, nothing herein shall supersede or modify
135 | the terms of any separate license agreement you may have executed
136 | with Licensor regarding such Contributions.
137 |
138 | 6. Trademarks. This License does not grant permission to use the trade
139 | names, trademarks, service marks, or product names of the Licensor,
140 | except as required for reasonable and customary use in describing the
141 | origin of the Work and reproducing the content of the NOTICE file.
142 |
143 | 7. Disclaimer of Warranty. Unless required by applicable law or
144 | agreed to in writing, Licensor provides the Work (and each
145 | Contributor provides its Contributions) on an "AS IS" BASIS,
146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147 | implied, including, without limitation, any warranties or conditions
148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149 | PARTICULAR PURPOSE. You are solely responsible for determining the
150 | appropriateness of using or redistributing the Work and assume any
151 | risks associated with Your exercise of permissions under this License.
152 |
153 | 8. Limitation of Liability. In no event and under no legal theory,
154 | whether in tort (including negligence), contract, or otherwise,
155 | unless required by applicable law (such as deliberate and grossly
156 | negligent acts) or agreed to in writing, shall any Contributor be
157 | liable to You for damages, including any direct, indirect, special,
158 | incidental, or consequential damages of any character arising as a
159 | result of this License or out of the use or inability to use the
160 | Work (including but not limited to damages for loss of goodwill,
161 | work stoppage, computer failure or malfunction, or any and all
162 | other commercial damages or losses), even if such Contributor
163 | has been advised of the possibility of such damages.
164 |
165 | 9. Accepting Warranty or Additional Liability. While redistributing
166 | the Work or Derivative Works thereof, You may choose to offer,
167 | and charge a fee for, acceptance of support, warranty, indemnity,
168 | or other liability obligations and/or rights consistent with this
169 | License. However, in accepting such obligations, You may act only
170 | on Your own behalf and on Your sole responsibility, not on behalf
171 | of any other Contributor, and only if You agree to indemnify,
172 | defend, and hold each Contributor harmless for any liability
173 | incurred by, or claims asserted against, such Contributor by reason
174 | of your accepting any such warranty or additional liability.
175 |
176 | END OF TERMS AND CONDITIONS
177 |
178 | APPENDIX: How to apply the Apache License to your work.
179 |
180 | To apply the Apache License to your work, attach the following
181 | boilerplate notice, with the fields enclosed by brackets "{}"
182 | replaced with your own identifying information. (Don't include
183 | the brackets!) The text should be enclosed in the appropriate
184 | comment syntax for the file format. We also recommend that a
185 | file or class name and description of purpose be included on the
186 | same "printed page" as the copyright notice for easier
187 | identification within third-party archives.
188 |
189 | Copyright {yyyy} {name of copyright owner}
190 |
191 | Licensed under the Apache License, Version 2.0 (the "License");
192 | you may not use this file except in compliance with the License.
193 | You may obtain a copy of the License at
194 |
195 | http://www.apache.org/licenses/LICENSE-2.0
196 |
197 | Unless required by applicable law or agreed to in writing, software
198 | distributed under the License is distributed on an "AS IS" BASIS,
199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200 | See the License for the specific language governing permissions and
201 | limitations under the License.
202 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # view-file-ng
2 | Angular directive for previewing files.
3 |
4 | Docs and examples available here: http://grtjn.github.io/view-file-ng
5 |
--------------------------------------------------------------------------------
/bower.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "view-file-ng",
3 | "version": "0.1.5",
4 | "description": "Angular directive for previewing files",
5 | "main": [
6 | "dist/view-file-ng.js",
7 | "dist/view-file-ng.css"
8 | ],
9 | "dependencies": {
10 | "angular": ">=1.4.0",
11 | "angular-x2js": "*",
12 | "bootstrap": "~3.3.5",
13 | "font-awesome": "^4.6.3",
14 | "angular-highlightjs": "^0.6.1",
15 | "ng-json-explorer": "*",
16 | "vkbeautify": "*",
17 | "angular-sanitize": ">=1.4.0",
18 | "videogular": "^1.4.4",
19 | "videogular-controls": "^1.4.4",
20 | "videogular-themes-default": "^1.4.4",
21 | "angular-recursion": "^1.0.5"
22 | },
23 | "overrides": {
24 | "highlightjs": {
25 | "main": [
26 | "highlight.pack.js",
27 | "styles/github.css"
28 | ]
29 | },
30 | "vkbeautify": {
31 | "main": [
32 | "vkbeautify.js"
33 | ]
34 | }
35 | },
36 | "devDependencies": {
37 | "angular-mocks": ">1.2.14"
38 | },
39 | "moduleType": [
40 | "globals"
41 | ],
42 | "authors": [
43 | "grtjn"
44 | ],
45 | "homepage": "http://grtjn.github.io/view-file-ng/",
46 | "repository": {
47 | "type": "git",
48 | "url": "git://github.com/grtjn/view-file-ng.git"
49 | },
50 | "keywords": [
51 | "angular",
52 | "angularjs",
53 | "view",
54 | "file",
55 | "highlightjs",
56 | "json-explorer",
57 | "videogular",
58 | "x2js",
59 | "marklogic"
60 | ],
61 | "license": "Apache-2.0",
62 | "ignore": [
63 | "**/.*",
64 | "node_modules",
65 | "bower_components",
66 | ".tmp",
67 | "build",
68 | "test",
69 | "coverage",
70 | "gulpfile.js",
71 | "karma.conf.js",
72 | "package.json"
73 | ],
74 | "resolutions": {
75 | "angular": ">=1.4.0"
76 | }
77 | }
78 |
--------------------------------------------------------------------------------
/dist/view-file-ng.css:
--------------------------------------------------------------------------------
1 | .view-file {
2 | padding: 0;
3 | }
4 | .view-file .viewer-wrapper {
5 | height: 600px;
6 | }
7 | .view-file .viewer-wrapper .loading {
8 | position: absolute;
9 | }
10 | .view-file .viewer-wrapper .viewer {
11 | position: absolute;
12 | width: 100%;
13 | background-color: inherit;
14 | padding: 0;
15 | overflow: hidden;
16 | max-height: 600px;
17 | }
18 | .view-file .viewer-wrapper .viewer hljs pre,
19 | .view-file .viewer-wrapper .viewer .hljs pre {
20 | overflow: scroll;
21 | max-height: 600px;
22 | }
23 | .view-file .viewer-wrapper .viewer view-object object {
24 | height: 575px;
25 | width: 100%;
26 | }
27 | .view-file .viewer-wrapper .viewer videogular.audio {
28 | height: 50px;
29 | }
30 | .view-file .source {
31 | display: block;
32 | padding: 9.5px;
33 | margin: 0;
34 | font-size: 13px;
35 | line-height: 1.42857143;
36 | word-break: break-all;
37 | word-wrap: break-word;
38 | color: #333333;
39 | background-color: #f5f5f5;
40 | border: 1px solid #ccc;
41 | border-radius: 4px;
42 | overflow: scroll;
43 | max-height: 600px;
44 | }
45 | .view-file .dl-horizontal {
46 | margin: 0;
47 | }
48 | .view-file .dl-horizontal dt {
49 | width: 100px;
50 | text-align: left;
51 | }
52 | .view-file .dl-horizontal dd {
53 | margin-left: 20px;
54 | }
55 | .view-file .dl-horizontal .dl-horizontal {
56 | margin-bottom: 0;
57 | }
58 | .view-file.audio .viewer-wrapper {
59 | height: 71px;
60 | }
61 | .modal-body .viewer-wrapper {
62 | padding: 0;
63 | }
64 |
--------------------------------------------------------------------------------
/dist/view-file-ng.js:
--------------------------------------------------------------------------------
1 | (function() {
2 | 'use strict';
3 |
4 | angular.module('view.file', [
5 | 'view.file.tpls',
6 | 'cb.x2js',
7 | 'com.2fdevs.videogular',
8 | 'com.2fdevs.videogular.plugins.controls',
9 | 'hljs',
10 | 'ngJsonExplorer',
11 | 'ngSanitize',
12 | 'RecursionHelper'
13 | ]);
14 |
15 | }());
16 |
17 | (function () {
18 | 'use strict';
19 |
20 | angular.module('view.file')
21 | .controller('FriendlyJsonCtrl', FriendlyJsonCtrl);
22 |
23 | FriendlyJsonCtrl.$inject = ['$scope', '$sce', '$templateCache', '$http'];
24 |
25 | function FriendlyJsonCtrl($scope, $sce, $templateCache, $http) {
26 | var ctrl = this;
27 | ctrl.trustUri = function(uri) {
28 | $sce.trustAsResourceUrl(uri);
29 | };
30 | ctrl.load = function(uri) {
31 | var json = $templateCache.get(uri);
32 |
33 | if (!json) {
34 | $http.get(uri, {
35 | cache: $templateCache,
36 | transformResponse: function(data, headersGetter) {
37 | // Return the raw string, so $http doesn't parse it
38 | // if it's json.
39 | return data;
40 | }
41 | }).then(function (response) {
42 | $scope.loading = false;
43 | $scope.json = JSON.parse(response.data);
44 | });
45 | } else if (angular.isArray(json)) {
46 | $scope.loading = false;
47 | $scope.json = JSON.parse(json[1]);
48 | } else {
49 | json.then(function(response) {
50 | $scope.json = JSON.parse(response.data);
51 | });
52 | }
53 | };
54 | }
55 | }());
56 |
57 | /**
58 | * @ngdoc directive
59 | * @memberOf 'view.file'
60 | * @name friendly-json
61 | * @description
62 | * Angular directive for rendering nested JSON structures in a user-friendly way.
63 | *
64 | * @attr {String} json Optional. JSON contents to be rendered. Do not use together with uri.
65 | * @attr {String} template Optional. Url of HTML template to use for this directive.
66 | * @attr {String} uri Optional. Url of JSON file to be rendered. Url must be trusted upfront.
67 | *
68 | * @example
69 | *
70 | *
71 | * or
72 | *
73 | *
74 | */
75 |
76 | (function () {
77 |
78 | 'use strict';
79 |
80 | angular.module('view.file')
81 | .directive('friendlyJson', friendlyJsonDirective)
82 | .filter('isObject', function() {
83 | return function(val) {
84 | return angular.isObject(val);
85 | };
86 | })
87 | .filter('isArray', function() {
88 | return function(val) {
89 | return angular.isArray(val);
90 | };
91 | })
92 | .filter('isFunction', function() {
93 | return function(val) {
94 | return angular.isFunction(val);
95 | };
96 | });
97 |
98 | friendlyJsonDirective.$inject = ['RecursionHelper'];
99 |
100 | function friendlyJsonDirective(RecursionHelper) {
101 | return {
102 | restrict: 'E',
103 | controller: 'FriendlyJsonCtrl',
104 | controllerAs: 'ctrl',
105 | scope: {
106 | uri: '=?',
107 | json: '=?'
108 | },
109 | templateUrl: template,
110 | compile: function(element) {
111 | // Use the compile function from the RecursionHelper,
112 | // And return the linking function(s) which it returns
113 | return RecursionHelper.compile(element, function ($scope, $elem, $attrs, ctrl) {
114 | $scope.loading = true;
115 |
116 | $scope.$watch('uri', function(newUri) {
117 | if (newUri) {
118 | ctrl.load(newUri);
119 | }
120 | });
121 | });
122 | }
123 | };
124 |
125 | function template(element, attrs) {
126 | var url;
127 |
128 | if (attrs.template) {
129 | url = attrs.template;
130 | } else {
131 | url = '/view-file-ng/friendly-json.html';
132 | }
133 |
134 | return url;
135 | }
136 | }
137 |
138 | }());
139 |
140 | (function () {
141 | 'use strict';
142 |
143 | angular.module('view.file')
144 | .controller('FriendlyXmlCtrl', FriendlyXmlCtrl);
145 |
146 | FriendlyXmlCtrl.$inject = ['$scope', '$sce', '$templateCache', '$http', 'x2js'];
147 |
148 | function FriendlyXmlCtrl($scope, $sce, $templateCache, $http, x2js) {
149 | var ctrl = this;
150 |
151 | ctrl.trustUri = function(uri) {
152 | $sce.trustAsResourceUrl(uri);
153 | };
154 |
155 | ctrl.load = function(uri) {
156 | var xml = $templateCache.get(uri);
157 |
158 | if (!xml) {
159 | $http.get(uri, {
160 | cache: $templateCache,
161 | transformResponse: function(data, headersGetter) {
162 | // Return the raw string, so $http doesn't parse it
163 | // if it's json.
164 | return data;
165 | }
166 | }).then(function (response) {
167 | $scope.loading = false;
168 | ctrl.parse(response.data);
169 | });
170 | } else if (angular.isArray(xml)){
171 | $scope.loading = false;
172 | ctrl.parse(xml[1]);
173 | } else {
174 | xml.then(function(response) {
175 | $scope.loading = false;
176 | ctrl.parse(response.data);
177 | });
178 | }
179 | };
180 |
181 | ctrl.parse = function(xml) {
182 | /* jshint camelcase: false */
183 | /* jscs: disable requireCamelCaseOrUpperCaseIdentifiers*/
184 | $scope.json = x2js.xml_str2json(xml);
185 | /* jscs: enable requireCamelCaseOrUpperCaseIdentifiers*/
186 | /* jshint camelcase: true */
187 | };
188 | }
189 | }());
190 |
191 | /**
192 | * @ngdoc directive
193 | * @memberOf 'view.file'
194 | * @name friendly-xml
195 | * @description
196 | * Angular directive for rendering nested JSON structures in a user-friendly way.
197 | *
198 | * @attr {String} template Optional. Url of HTML template to use for this directive.
199 | * @attr {String} uri Optional. Url of XML file to be rendered. Url must be trusted upfront.
200 | * @attr {String} xml Optional. XML contents to be rendered. Do not use together with uri.
201 | *
202 | * @example
203 | *
204 | *
205 | * or
206 | *
207 | *
208 | */
209 |
210 | (function () {
211 |
212 | 'use strict';
213 |
214 | angular.module('view.file')
215 | .directive('friendlyXml', friendlyXmlDirective);
216 |
217 | friendlyXmlDirective.$inject = ['RecursionHelper'];
218 |
219 | function friendlyXmlDirective(RecursionHelper) {
220 | return {
221 | restrict: 'E',
222 | controller: 'FriendlyXmlCtrl',
223 | controllerAs: 'ctrl',
224 | scope: {
225 | uri: '=?',
226 | xml: '=?'
227 | },
228 | templateUrl: template,
229 | compile: function(element) {
230 | // Use the compile function from the RecursionHelper,
231 | // And return the linking function(s) which it returns
232 | return RecursionHelper.compile(element, function ($scope, $elem, $attrs, ctrl) {
233 | $scope.loading = true;
234 |
235 | $scope.$watch('uri', function(newUri) {
236 | if (newUri) {
237 | ctrl.load(newUri);
238 | }
239 | });
240 |
241 | $scope.$watch('xml', function(newXML) {
242 | if (newXML) {
243 | ctrl.parse(newXML);
244 | }
245 | });
246 | });
247 | }
248 | };
249 |
250 | function template(element, attrs) {
251 | var url;
252 |
253 | if (attrs.template) {
254 | url = attrs.template;
255 | } else {
256 | url = '/view-file-ng/friendly-json.html';
257 | }
258 |
259 | return url;
260 | }
261 | }
262 |
263 | }());
264 |
265 | /**
266 | * @ngdoc directive
267 | * @memberOf 'view.file'
268 | * @name include-safe
269 | * @description
270 | * Angular attribute directive for including sanitized HTML from url.
271 | *
272 | * @attr {String} include-safe Required. Url of HTML file to be inserted.
273 | *
274 | * @example
275 | *
Loading..
276 | */
277 |
278 | (function () {
279 |
280 | 'use strict';
281 |
282 | angular.module('view.file')
283 | .directive('includeSafe', includeSafeDirective);
284 |
285 | includeSafeDirective.$inject = ['$http', '$sanitize'];
286 |
287 | function includeSafeDirective($http, $sanitize) {
288 | // directive factory creates a link function
289 | return function(scope, element, attrs) {
290 | scope.$watch(
291 | function(scope) {
292 | // watch the 'compile' expression for changes
293 | return scope.$eval(attrs.includeSafe);
294 | },
295 | function(value) {
296 | $http.get(value).then(function(response) {
297 | var html = response.data;
298 | // when the 'compile' expression changes
299 | // assign it into the current DOM
300 | element.html($sanitize(html));
301 | });
302 | }
303 | );
304 | };
305 | }
306 |
307 |
308 | }());
309 |
310 | /**
311 | * @ngdoc service
312 | * @memberOf 'view.file'
313 | * @name ModalService
314 | * @param {service} $uibModal angular-bootstrap modal service
315 | * @description
316 | * Angular helper service displaying, and handling modal overlays. Wraps around $uibModal.
317 | */
318 |
319 | (function () {
320 | 'use strict';
321 |
322 | angular.module('view.file')
323 | .service('ModalService', ['$uibModal', ModalService]);
324 |
325 | function ModalService($modal) {
326 |
327 | var service = {
328 | show: showModal
329 | };
330 |
331 | return service;
332 |
333 | /**
334 | * Show a modal for given template, title, and data.
335 | * @memberof ModalService
336 | * @param {String} template Required. Url of modal template.
337 | * @param {String} title Optional. Title for modal overlay.
338 | * @param {Object} ctrl Optional. Object with data and callbacks for use on modal. For instance link to parent Ctrl.
339 | * @param {function} validate Optional. Callback function to validate input before closing modal. Expected to return an Array of Strings.
340 | * @param {Object} modalOptions Optional. Additional modal options.
341 | * @returns {Promise} result Promise for updated ctrl if ok was selected, or null if cancel.
342 | */
343 | function showModal(template, title, ctrl, validate, modalOptions) {
344 | return $modal.open(
345 | angular.extend({
346 | templateUrl: template+'',
347 | controller: ['$scope', '$uibModalInstance', 'title', 'ctrl', 'validate', function ($scope, $modalInstance, title, ctrl, validate) {
348 | $scope.title = title;
349 | $scope.ctrl = ctrl;
350 | $scope.alerts = [];
351 | $scope.ok = function () {
352 | if (validate) {
353 | $scope.alerts = validate($scope);
354 | }
355 | if ($scope.alerts.length === 0) {
356 | $modalInstance.close($scope.ctrl);
357 | }
358 | };
359 | $scope.cancel = function () {
360 | $modalInstance.dismiss('cancel');
361 | };
362 | }],
363 | size: 'lg',
364 | resolve: {
365 | title: function () {
366 | return title;
367 | },
368 | ctrl: function () {
369 | return ctrl;
370 | },
371 | validate: function () {
372 | return validate || function($s) {
373 | var errors = [];
374 | if ($s.form) {
375 | angular.forEach($s.form.$error, function(err, key) {
376 | angular.forEach(err, function(e, index) {
377 | errors.push(key + ': ' + (e.$name || index));
378 | });
379 | });
380 | }
381 | return errors;
382 | };
383 | }
384 | }
385 | }, modalOptions)
386 | ).result;
387 | }
388 | }
389 | }());
390 |
391 | (function () {
392 | 'use strict';
393 |
394 | angular.module('view.file')
395 | .controller('ViewFileCtrl', ViewFileCtrl);
396 |
397 | ViewFileCtrl.$inject = ['$scope', '$sce', '$templateCache', '$http', 'ModalService'];
398 |
399 | function ViewFileCtrl($scope, $sce, $templateCache, $http, modal) {
400 | var ctrl = this;
401 | ctrl.trustUri = function(uri) {
402 | $sce.trustAsResourceUrl(uri);
403 | };
404 | ctrl.loadHljs = function(uri) {
405 | $scope.loading = !$templateCache.get(uri);
406 |
407 | if ($scope.loading) {
408 | $http.get(uri, {
409 | cache: $templateCache,
410 | transformResponse: function(data, headersGetter) {
411 | // Return the raw string, so $http doesn't parse it
412 | // if it's json.
413 | return data;
414 | }
415 | }).then(function (result) {
416 | $scope.loading = false;
417 | $scope.hljsUri = uri;
418 | });
419 | } else {
420 | $scope.hljsUri = uri;
421 | }
422 | };
423 | ctrl.showModal = function() {
424 | if ($scope.allowModal) {
425 | modal.show('/view-file-ng/show-file.modal.html', null, $scope);
426 | }
427 | };
428 | ctrl.toggleCode = function() {
429 | $scope.showCode = !$scope.showCode;
430 | };
431 | }
432 | }());
433 |
434 | /**
435 | * @ngdoc directive
436 | * @memberOf 'view.file'
437 | * @name view-file
438 | * @description
439 | * Angular directive for viewing files. Leverages a.o. highlightjs, json-explorer, sanitize, videogular, x2js.
440 | *
441 | * @attr {String} data Optional. Data of file to be viewed. Do not use together with uri.
442 | * @attr {String} uri Optional. Url of file to be viewed.
443 | * @attr {String} content-type Required. Mime-type of file to be viewed.
444 | * @attr {Boolean} allow-modal Optional. Allow opening of file in modal overlay. Default: true.
445 | * @attr {Boolean} controls Optional. Show controls on left. Default: true if download-uri or allow-modal.
446 | * @attr {String} download-uri Optional. Url of file for download purpose. Default: null.
447 | * @attr {String} file-name Optional. Filename for display. Default: uri portion after last /.
448 | * @attr {Boolean} show-code Optional. Show raw code initially for JSON, HTML, Text, and XML. Default: false.
449 | * @attr {String} template Optional. Url of HTML template to use for this directive.
450 | * @attr {Boolean} trust-uri Optional. Apply trustAsResourceUrl on uri (not recommended). Default: false.
451 | *
452 | * @example
453 | *
456 | *
457 | *
458 | * or
459 | *
460 | *
463 | *
464 | */
465 |
466 | (function () {
467 |
468 | 'use strict';
469 |
470 | angular.module('view.file')
471 | .directive('viewFile', viewFileDirective);
472 |
473 | function viewFileDirective() {
474 |
475 | function isTrue(b, def) {
476 | if (b !== undefined) {
477 | return b === true || b === 'true';
478 | } else {
479 | return def;
480 | }
481 | }
482 |
483 | function getFileType(contentType) {
484 | var type = 'other';
485 | if (/\/[x]?html/.test(contentType)) {
486 | type = 'html';
487 | } else if (/[\+\/]json$/.test(contentType)) {
488 | type = 'json';
489 | } else if (/[\+\/]xml$/.test(contentType)) {
490 | type = 'xml';
491 | } else if (/^(audio|image|text|video|xml)\//.test(contentType)) {
492 | type = contentType.split('/')[0];
493 | } else if (/^application\//.test(contentType)) {
494 | // TODO
495 | }
496 | return type;
497 | }
498 |
499 | return {
500 | restrict: 'E',
501 | controller: 'ViewFileCtrl',
502 | controllerAs: 'ctrl',
503 | scope: {
504 | data: '=?',
505 | uri: '=?',
506 | contentType: '=',
507 | _allowModal: '@allowModal',
508 | _controls: '@controls',
509 | downloadUri: '=?',
510 | fileName: '=?',
511 | _showCode: '@showCode',
512 | _trustUri: '@trustUri'
513 | },
514 | templateUrl: template,
515 | link: function ($scope, $elem, $attrs, ctrl) {
516 |
517 | $scope.allowModal = isTrue($scope._allowModal, true);
518 | $scope.controls = isTrue($scope._controls, $scope.allowModal || !!$scope.downloadUri);
519 | $scope.showCode = isTrue($scope._showCode, false);
520 | $scope.trustUri = isTrue($scope._trustUri, false);
521 |
522 | if ($attrs.uri) {
523 | $scope.loading = true;
524 | $scope.$watch('uri', function(newUri) {
525 | if (newUri) {
526 | $scope.fileName = $scope.fileName || newUri.split('/').pop();
527 | $scope.fileType = getFileType($scope.contentType);
528 |
529 | if ($scope.trustUri) {
530 | ctrl.trustUri(newUri);
531 | }
532 | if ($scope.fileType === 'xml') {
533 | ctrl.loadHljs(newUri);
534 | } else {
535 | $scope.loading = false;
536 | }
537 | }
538 | });
539 | } else {
540 | $scope.loading = false;
541 | $scope.fileType = getFileType($scope.contentType);
542 | }
543 | }
544 | };
545 |
546 | function template(element, attrs) {
547 | var url;
548 |
549 | if (attrs.template) {
550 | url = attrs.template;
551 | } else {
552 | url = '/view-file-ng/view-file.html';
553 | }
554 |
555 | return url;
556 | }
557 | }
558 |
559 | }());
560 |
561 | /**
562 | * @ngdoc directive
563 | * @memberOf 'view.file'
564 | * @name view-object
565 | * @description
566 | * Angular directive for including HTML object tag dynamically.
567 | *
568 | * @attr {String} data Required. Url of file to be viewed. Url must be trusted upfront.
569 | * @attr {String} type Optional. Mime-type of file to be viewed.
570 | * @attr {String} height Optional. Height value to be applied to object tag.
571 | * @attr {String} width Optional. Width value to be applied to object tag.
572 | *
573 | * @example
574 | *
575 | */
576 |
577 | (function () {
578 | 'use strict';
579 |
580 | angular.module('view.file')
581 | .directive('viewObject', ['$compile', function($compile) {
582 | return {
583 | restrict: 'E',
584 | link: function(scope, element, attrs) {
585 | // prepare object tag attributes
586 | var data = ' data="' + scope.$eval(attrs.data) + '"';
587 | var type = attrs.type ? (' type="' + scope.$eval(attrs.type) + '"') : '';
588 | var height = attrs.height ? (' height="' + scope.$eval(attrs.height) + '"') : '';
589 | var width = attrs.width ? (' width="' + scope.$eval(attrs.width) + '"') : '';
590 |
591 | // tried transclude before, but that didn't seem to work..
592 | var innerHtml = element.html();
593 | element.html('');
594 | $compile(element.contents())(scope);
595 | }
596 | };
597 | }]);
598 |
599 | }());
600 | (function(module) {
601 | try {
602 | module = angular.module('view.file.tpls');
603 | } catch (e) {
604 | module = angular.module('view.file.tpls', []);
605 | }
606 | module.run(['$templateCache', function($templateCache) {
607 | $templateCache.put('/view-file-ng/friendly-json.html',
608 | '