Skip to content

Commit

Permalink
Preparing for merge with Media Previews project
Browse files Browse the repository at this point in the history
- Fixed build so that all files are compressed using yuicompressor, except pdf.js that needs to use jsmin due to pdf.js issue mozilla/pdf.js#710
- Moved from Alfresco namespace to ShareExtras namespace where apporiate
- Added copyright headers and js doc comments
- Moved pdf.js external library client side components to its own subdirectory
  • Loading branch information
loftux.peter committed Feb 15, 2012
1 parent 0bff22f commit d312790
Show file tree
Hide file tree
Showing 33 changed files with 162 additions and 86 deletions.
37 changes: 20 additions & 17 deletions Sandbox/Viewer Extension/build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@

<!-- yuicompress doesn't work with pdf.js https://github.com/mozilla/pdf.js/issues/710 -->
<!-- Using jsmin instead, not as efficient, but works -->
<!--

<path id="yuicompressor.classpath">
<fileset dir="lib">
<include name="yuicompressor-2.4.2.jar"/>
Expand All @@ -86,7 +86,7 @@
<path refid="yuicompressor.classpath"/>
</classpath>
</taskdef>
-->

<taskdef name="jsmin" classname="net.matthaynes.jsmin.JSMin_Task" classpath="${basedir}/lib/jsmin.0.2.4.jar"/>

<!-- Clean out the build and distribution directories -->
Expand Down Expand Up @@ -144,15 +144,18 @@
</fileset>
<globmapper from="alfresco/web-extension/*.xml" to="*.xml" handledirsep="true" />
</copy>
<!-- Minify JS -->

<yuicompress fromdir="${res.dir}" todir="${build.jar.dir}/META-INF" excludes="**/*-min.js" warn="${yuicompress.warn}">
<include name="extras/components/**/*.js" />
<exclude name="extras/components/**/pdf.js" />
</yuicompress>

<!-- Minify JS -->
<jsmin suffix="true" suffixvalue="-min" >
<fileset dir="${build.jar.dir}/META-INF/components/" includes="**/*.js" excludes="**/*-min.js"/>
<fileset dir="${build.jar.dir}/META-INF/components/" includes="**/pdf.js" excludes="**/*-min.js"/>
</jsmin>
<!--
<yuicompress fromdir="${res.dir}" todir="${build.jar.dir}/META-INF" excludes="**/*-min.js" warn="${yuicompress.warn}">
<include name="components/**/*.js" />
</yuicompress>
-->


</target>

<!-- Build the JAR file -->
Expand Down Expand Up @@ -192,16 +195,16 @@
<copy todir="${build.zip.dir}/${build.res.dir}">
<fileset dir="${res.dir}" includes="${build.res.includes}" excludes="${build.res.excludes}" />
</copy>
<!-- Minify JS -->
<!-- Minify JS -->

<yuicompress fromdir="${res.dir}" todir="${build.zip.dir}/${build.res.dir}" excludes="**/*-min.js" warn="${yuicompress.warn}">
<include name="extras/components/**/*.js" />
<exclude name="extras/components/**/pdf.js" />
</yuicompress>

<!-- Minify JS -->
<jsmin suffix="true" suffixvalue="-min" >
<fileset dir="${build.zip.dir}/webapps/share" includes="**/*.js" excludes="**/*-min.js"/>
<fileset dir="${build.zip.dir}/webapps/share" includes="**/pdf.js" excludes="**/*-min.js"/>
</jsmin>
<!--
<yuicompress fromdir="${res.dir}" todir="${build.zip.dir}/${build.res.dir}" excludes="**/*-min.js" warn="${yuicompress.warn}">
<include name="components/**/*.js" />
</yuicompress>
-->
</target>

<target name="build-zip-prepare">
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<#include "/org/alfresco/components/component.head.inc">
<#-- This file is part of the Share Extras PdfJs Viewer project -->
<@link rel="stylesheet" type="text/css" href="${page.url.context}/res/extras/components/preview/pdfjs/pdfviewer.css" />
<@script type="text/javascript" src="${page.url.context}/res/extras/components/preview/pdfjs/pdfviewercompatibility.js"></@script>
<@script type="text/javascript" src="${page.url.context}/res/extras/components/preview/pdfjs/pdf.js"></@script>
<script type="text/javascript">PDFJS.workerSrc = '${page.url.context}/res/extras/components/preview/pdfjs/pdf<#if DEBUG==false>-min.js<#else>.js</#if>';</script>
<@script type="text/javascript" src="${page.url.context}/res/extras/components/preview/pdfjs/pdfviewer.js"></@script>
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
<#assign el=args.htmlid?html>
<div id="controls">
<button id="previous" onclick="PDFView.page--;" oncontextmenu="return false;">
<img src="${url.context}/res/components/preview/images/go-up.svg" align="top" height="16"/>
<img src="${url.context}/res/extras/components/preview/pdfjs/images/go-up.svg" align="top" height="16"/>
${msg("button.previous")}
</button>

<button id="next" onclick="PDFView.page++;" oncontextmenu="return false;">
<img src="${url.context}/res/components/preview/images/go-down.svg" align="top" height="16"/>
<img src="${url.context}/res/extras/components/preview/pdfjs/images/go-down.svg" align="top" height="16"/>
${msg("button.next")}
</button>

Expand All @@ -21,10 +21,10 @@
<div class="separator"></div>

<button id="zoomOut" title="${msg("button.zoomout")}" onclick="PDFView.zoomOut();" oncontextmenu="return false;">
<img src="${url.context}/res/components/preview/images/zoom-out.svg" align="top" height="16"/>
<img src="${url.context}/res/extras/components/preview/pdfjs/images/zoom-out.svg" align="top" height="16"/>
</button>
<button id="zoomIn" title="${msg("button.zoomin")}" onclick="PDFView.zoomIn();" oncontextmenu="return false;">
<img src="${url.context}/res/components/preview/images/zoom-in.svg" align="top" height="16"/>
<img src="${url.context}/res/extras/components/preview/pdfjs/images/zoom-in.svg" align="top" height="16"/>
</button>

<div class="separator"></div>
Expand All @@ -45,19 +45,19 @@
<div class="separator"></div>

<button id="print" onclick="window.print();" oncontextmenu="return false;">
<img src="${url.context}/res/components/preview/images/document-print.svg" align="top" height="16"/>
<img src="${url.context}/res/extras/components/preview/pdfjs/images/document-print.svg" align="top" height="16"/>
${msg("button.print")}
</button>

<button id="download" title="${msg("button.download")}" onclick="PDFView.download();" oncontextmenu="return false;">
<img src="${url.context}/res/components/preview/images/download.svg" align="top" height="16"/>
<img src="${url.context}/res/extras/components/preview/pdfjs/images/download.svg" align="top" height="16"/>
${msg("button.download")}
</button>

<div class="separator"></div>

<button id="fullpage" title="${msg("button.fullpage")}" onclick="window.open(window.location, '_blank');" oncontextmenu="return false;">
<img src="${url.context}/res/components/preview/images/bookmark.svg" align="top" height="16"/>
<img src="${url.context}/res/extras/components/preview/pdfjs/images/bookmark.svg" align="top" height="16"/>
${msg("button.fullpage")}
</button>

Expand Down Expand Up @@ -92,10 +92,10 @@
</div>
<div id="sidebarControls">
<button id="thumbsSwitch" title="${msg("sidebar.showthumbnails")}" onclick="PDFView.switchSidebarView('thumbs')" data-selected>
<img src="${url.context}/res/components/preview/images/nav-thumbs.svg" align="top" height="16" alt="${msg("sidebar.showthumbnails.alt")}" />
<img src="${url.context}/res/extras/components/preview/pdfjs/images/nav-thumbs.svg" align="top" height="16" alt="${msg("sidebar.showthumbnails.alt")}" />
</button>
<button id="outlineSwitch" title="${msg("sidebar.showoutline")}" onclick="PDFView.switchSidebarView('outline')" disabled>
<img src="${url.context}/res/components/preview/images/nav-outline.svg" align="top" height="16" alt="${msg("sidebar.showoutline.alt")}" />
<img src="${url.context}/res/extras/components/preview/pdfjs/images/nav-outline.svg" align="top" height="16" alt="${msg("sidebar.showoutline.alt")}" />
</button>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@

<!-- Share Extras viewers -->
<#-- Extend base web-preview with common methods -->
<@script type="text/javascript" src="${page.url.context}/res/components/preview/web-preview-extend.js"></@script>
<@script type="text/javascript" src="${page.url.context}/res/components/preview/pdfviewerloader.js"></@script>
<@link rel="stylesheet" type="text/css" href="${page.url.context}/res/components/preview/pdfviewerloader.css" />
<@script type="text/javascript" src="${page.url.context}/res/components/preview/IframeView.js"></@script>
<@link rel="stylesheet" type="text/css" href="${page.url.context}/res/components/preview/IframeView.css" />
<@script type="text/javascript" src="${page.url.context}/res/extras/components/preview/web-preview-extend.js"></@script>
<@script type="text/javascript" src="${page.url.context}/res/extras/components/preview/pdfviewerloader.js"></@script>
<@link rel="stylesheet" type="text/css" href="${page.url.context}/res/extras/components/preview/pdfviewerloader.css" />
<@script type="text/javascript" src="${page.url.context}/res/extras/components/preview/IframeView.js"></@script>
<@link rel="stylesheet" type="text/css" href="${page.url.context}/res/extras/components/preview/IframeView.css" />
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -1,21 +1,30 @@
/**
* This file is part of the Share Extras pdfJS project.
* It is an extension/rewrite of of Alfresco source code
* and subject to their license.
/*
* Copyright (C) 2010-2012 Share Extras contributors
*
* This file is part of the Share Extras project.
*
* 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.
*/

/**
* This is the "IframeView" plugin used to display text files using the <iframe>
* element.
*
* Supports at least the following mime types: "plain/text".
*
* @param wp
* {Alfresco.WebPreview} The Alfresco.WebPreview instance that decides
* which plugin to use
* @param attributes
* {Object} Arbitrary attributes brought in from the <plugin> element
* This is the "IframeView" plug-in used to display file formats such as
* text and html that can render directly in the web browser.
*
* @namespace Alfresco.WebPreview.prototype.Plugins
* @class Alfresco.WebPreview.prototype.Plugins.IframeView
* @author Peter Lšfgren Loftux AB
*/

Alfresco.WebPreview.prototype.Plugins.IframeView = function(wp, attributes)
{
this.wp = wp;
Expand Down Expand Up @@ -57,7 +66,7 @@ Alfresco.WebPreview.prototype.Plugins.IframeView.prototype = {
},

/**
* Display the node.
* Display the node using in iframe.
*
* @method display
* @public
Expand Down
Original file line number Diff line number Diff line change
@@ -1,21 +1,33 @@
/**
* This file is part of the Share Extras pdfJS project.
* It is an extension/rewrite of of Alfresco source code
* and subject to their license.
/*
* Copyright (C) 2010-2012 Share Extras contributors
*
* This file is part of the Share Extras project.
*
* 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.
*/

/**
* This is the "PdfViewer" plugin used to display text files using the <iframe>
* element.
*
* Supports at least the following mime types: "plain/text".
* This is the "PdfViewer" plugin that renders pdf file using
* third party pdf.js library, or as fallback any pdf viewer plugin
* installed in the browser
*
* @param wp
* {Alfresco.WebPreview} The Alfresco.WebPreview instance that decides
* which plugin to use
* @param attributes
* {Object} Arbitrary attributes brought in from the <plugin> element
* Supports the following mime types: "application/pdf".
*
* @namespace Alfresco.WebPreview.prototype.Plugins
* @class Alfresco.WebPreview.prototype.Plugins.PdfViewer
* @author Peter Lšfgren Loftux AB
*/

Alfresco.WebPreview.prototype.Plugins.PdfViewer = function(wp, attributes)
{
this.wp = wp;
Expand All @@ -39,15 +51,43 @@ Alfresco.WebPreview.prototype.Plugins.PdfViewer.prototype = {
* @default null
*/
src : null,
// If html5 canvas is supported
/**
* Sets if canvas is supported and pdf.js can be used.
* Internal only.
*
* @property canvassuport
* @type Boolean
* @default false
*/
canvassupport : false,
// If pdf plugin is installed
/**
* Sets if there is a pdf plugin installed
* Internal only.
*
* @property pdfplugininstalled
* @type Boolean
* @default false
*/
pdfplugininstalled : false,
// Force the plugin used, mostly for developer use
// Valid options are pdfjs or plugin
/**
* Force the use of selected plugin
* Valid options
* pdfjs - use the pdf.js library
* plugin - use the browser plugin
*
* @property forceplugin
* @type String
* @default null
*/
forceplugin : null,
// Skip test, use together with forceplugin
// If browser tests are skipped, then it will try to load regardless
/**
* Skipbrowser test, mostly for developer to force test loading
* Valid options "true" "false" as String
*
* @property forceplugin
* @type String
* @default null
*/
skipbrowsertest : null
},

Expand Down Expand Up @@ -193,6 +233,12 @@ Alfresco.WebPreview.prototype.Plugins.PdfViewer.prototype = {

},

/**
* Detect PDF plugin in IE
*
* @method _detectPdfPluginIE
* @private
*/
_detectPdfPluginIE : function PdfViewer_detectPDFPluginIE()
{
// TODO: Add more known pdf plugins
Expand Down
Original file line number Diff line number Diff line change
@@ -1,28 +1,46 @@
/**
* This file is part of the Share Extras pdfJS project.
* It is an extension/rewrite of of Alfresco source code
* and subject to their license.
/*
* Copyright (C) 2010-2012 Share Extras contributors
*
* This file is part of the Share Extras project.
*
* 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.
*/

/**
* This is an extension point for comment methods and properties used by viewers
* in the extension project.
*
* This is an extension that augments Alfresco.WebPreview
* with functions and properties that can be used by all viewers.
*
* @namespace ShareExtras
* @class ShareExtras.ViewerExtension
* @author Peter Lšfgren Loftux AB
*/

(function()
{

if (typeof Alfresco.ViewerExtension == "undefined" || !Alfresco.ViewerExtension)
if (typeof ShareExtras == "undefined" || !ShareExtras)
{
ShareExtras = {};
}
if (typeof ShareExtras.ViewerExtension == "undefined" || !ShareExtras.ViewerExtension)
{
Alfresco.ViewerExtension = {};
ShareExtras.ViewerExtension = {};
}

Alfresco.ViewerExtension.prototype = {
ShareExtras.ViewerExtension.prototype = {
/**
* Will find a previewer and set it up if one existed
* Set up the available preview size
*
* @method resolvePreviewer
* @method setupPreviewSize
* @return {integer} size in pixels that preview div is set to
* @public
*/
Expand Down Expand Up @@ -67,5 +85,5 @@

}

YAHOO.lang.augmentProto(Alfresco.WebPreview, Alfresco.ViewerExtension);
YAHOO.lang.augmentProto(Alfresco.WebPreview, ShareExtras.ViewerExtension);
})();

0 comments on commit d312790

Please # to comment.