-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#34 Created a main viewer (for TXT and ZIP)
- Loading branch information
Showing
4 changed files
with
182 additions
and
1 deletion.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
/* | ||
* Copyright (c) 2013-2015 Jhon Klever, http://github.com/elfoxero | ||
* | ||
* Permission is hereby granted, free of charge, to any person obtaining a copy | ||
* of this software and associated documentation files (the "Software"), to | ||
* deal in the Software without restriction, including without limitation the | ||
* rights to use, copy, modify, merge, publish and distribute, subject to the | ||
* following conditions: | ||
* | ||
* The above copyright notice and this permission notice shall be included in | ||
* all copies or substantial portions of the Software. | ||
* | ||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING | ||
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS | ||
* IN THE SOFTWARE. | ||
* | ||
*/ | ||
|
||
.hide { | ||
display: none; | ||
} | ||
|
||
.shown { | ||
display: block; | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
<!-- | ||
Copyright (c) 2013-2015 Jhon Klever, http://github.com/elfoxero | ||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to | ||
deal in the Software without restriction, including without limitation the | ||
rights to use, copy, modify, merge, publish and distribute, subject to the | ||
following conditions: | ||
The above copyright notice and this permission notice shall be included in | ||
all copies or substantial portions of the Software. | ||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING | ||
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS | ||
IN THE SOFTWARE. | ||
--> | ||
<!DOCTYPE html> | ||
<html lang="en-US"> | ||
<head> | ||
<meta charset="utf-8"> | ||
<meta name="viewport" content="width=device-width, user-scalable=no"> | ||
<title>File Viewer</title> | ||
|
||
<link rel="stylesheet" href="../libraries/buildingblocks/style/headers.css"> | ||
<link rel="stylesheet" href="../libraries/buildingblocks/style/toolbars.css"> | ||
|
||
<link rel="stylesheet" href="../libraries/buildingblocks/icons/styles/action_icons.css"> | ||
|
||
<link rel="stylesheet" href="../libraries/buildingblocks/util.css"> | ||
<link rel="stylesheet" href="../libraries/buildingblocks/fonts.css"> | ||
|
||
<link rel="stylesheet" href="../libraries/buildingblocks/cross_browser.css"> | ||
|
||
<link rel="stylesheet" href="../libraries/buildingblocks/extra.css"> | ||
<link rel="stylesheet" href="../css/viewer.css"> | ||
|
||
<!-- END OF STYLES --> | ||
|
||
<link rel="prefetch" type="application/l10n" href="../locales/locales.ini" /> | ||
</head> | ||
<body> | ||
<section id="index" data-position="current" class="left-to-current"> | ||
<section id="drawer" role="region" class="skin-dark"> | ||
<header> | ||
<button id="close"><span class="icon icon-close">close</span></button> | ||
<menu type="toolbar" class="hide"><button id="save" data-l10n-id="save">Save</button></menu> | ||
<h1 id="name"></h1> | ||
</header> | ||
<article> | ||
<section class="content"></section> | ||
<div role="toolbar"></div> | ||
</article> | ||
</section> | ||
</section> | ||
|
||
<!-- START OF SCRIPTS --> | ||
|
||
<script defer src="../libraries/l10n.js"></script> | ||
|
||
<script defer src="../js/viewer.js"></script> | ||
</body> | ||
</html> |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
/* | ||
* Copyright (c) 2013-2015 Jhon Klever, http://github.com/elfoxero | ||
* | ||
* Permission is hereby granted, free of charge, to any person obtaining a copy | ||
* of this software and associated documentation files (the "Software"), to | ||
* deal in the Software without restriction, including without limitation the | ||
* rights to use, copy, modify, merge, publish and distribute, subject to the | ||
* following conditions: | ||
* | ||
* The above copyright notice and this permission notice shall be included in | ||
* all copies or substantial portions of the Software. | ||
* | ||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING | ||
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS | ||
* IN THE SOFTWARE. | ||
* | ||
*/ | ||
|
||
;+function (window, document, undefined) { | ||
var _ = window.document.webL10n.get; | ||
|
||
window.activity = null; | ||
navigator.setMessageHandler = navigator.setMessageHandler || navigator.mozSetMessageHandler; | ||
|
||
var addJs = function (src, callback) { | ||
var el = element('script', { src: src }); | ||
callback && (el.onload = callback); | ||
document.body.appendChild(el); | ||
}; | ||
|
||
var addCss = function (href) { | ||
var el = element('link', { rel: 'stylesheet', href: href }); | ||
document.querySelector('head').appendChild(el); | ||
}; | ||
|
||
window.$ = function (selector) { | ||
return document.querySelector(selector); | ||
}; | ||
|
||
window.element = function (tag, attrs) { | ||
var elem = document.createElement(tag); | ||
|
||
if (attrs) { | ||
if (typeof attrs === 'string') { | ||
elem.textContent = attrs; | ||
} else if (typeof attrs === 'object') { | ||
Object.keys(attrs).forEach(function (attr) { | ||
if (attr === 'text') { | ||
elem.textContent = attrs[attr]; | ||
} else { | ||
elem[attr] = attrs[attr]; | ||
} | ||
}); | ||
} | ||
} | ||
|
||
return elem; | ||
}; | ||
|
||
navigator.setMessageHandler('activity', function(request) { | ||
activity = request; | ||
|
||
window.activityData = activity.source.data; | ||
|
||
$('#name').textContent = activityData.filename; | ||
|
||
if (/text/ .test(activityData.type) || /javascript/ .test(activityData.type)) { | ||
// Include scripts for Text Viewer | ||
} else if (/zip/ .test(activityData.type)) { | ||
// Include scripts for ZIP Viewer | ||
} | ||
}); | ||
|
||
$('#close').onclick = function (e) { | ||
if (window.activity) { | ||
activity.postResult({saved: false}); | ||
activity = null; | ||
} | ||
}; | ||
} (window, document, undefined); |
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