mirror of
https://github.com/lxsang/ant-http
synced 2025-07-30 04:30:30 +02:00
new init
This commit is contained in:
55
build/htdocs/dist/packages/default/Preview/combined.css
vendored
Normal file
55
build/htdocs/dist/packages/default/Preview/combined.css
vendored
Normal file
@ -0,0 +1,55 @@
|
||||
/*!
|
||||
* OS.js - JavaScript Cloud/Web Desktop Platform
|
||||
*
|
||||
* Copyright (c) 2011-2015, Anders Evenrud <andersevenrud@gmail.com>
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
|
||||
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* @author Anders Evenrud <andersevenrud@gmail.com>
|
||||
* @licence Simplified BSD License
|
||||
*/
|
||||
|
||||
.ApplicationPreviewWindow gui-container {
|
||||
overflow : hidden;
|
||||
font-size : 0;
|
||||
text-align : center;
|
||||
}
|
||||
.ApplicationPreviewWindow gui-video {
|
||||
vertical-align : middle;
|
||||
display : inline-block;
|
||||
background : #000;
|
||||
height : 100%;
|
||||
width : 100%;
|
||||
}
|
||||
|
||||
.ApplicationPreviewWindow gui-video > video {
|
||||
height : 100%;
|
||||
width : 100%;
|
||||
display : inline-block;
|
||||
}
|
||||
|
||||
.ApplicationPreviewWindow gui-image {
|
||||
width : auto;
|
||||
}
|
||||
.ApplicationPreviewWindow gui-image[data-zoom="fit"] > img {
|
||||
width : 100%;
|
||||
}
|
204
build/htdocs/dist/packages/default/Preview/combined.js
vendored
Normal file
204
build/htdocs/dist/packages/default/Preview/combined.js
vendored
Normal file
@ -0,0 +1,204 @@
|
||||
/*!
|
||||
* OS.js - JavaScript Cloud/Web Desktop Platform
|
||||
*
|
||||
* Copyright (c) 2011-2016, Anders Evenrud <andersevenrud@gmail.com>
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
|
||||
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* @author Anders Evenrud <andersevenrud@gmail.com>
|
||||
* @licence Simplified BSD License
|
||||
*/
|
||||
(function(DefaultApplication, DefaultApplicationWindow, Application, Window, Utils, API, VFS, GUI) {
|
||||
'use strict';
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// WINDOWS
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
function ApplicationPreviewWindow(app, metadata, scheme, file) {
|
||||
DefaultApplicationWindow.apply(this, ['ApplicationPreviewWindow', {
|
||||
allow_drop: true,
|
||||
icon: metadata.icon,
|
||||
title: metadata.name,
|
||||
width: 400,
|
||||
height: 200
|
||||
}, app, scheme, file]);
|
||||
|
||||
this.zoomLevel = 0;
|
||||
this.isImage = true;
|
||||
this.origWidth = 0;
|
||||
this.origHeight = 0;
|
||||
this.$view = null;
|
||||
}
|
||||
|
||||
ApplicationPreviewWindow.prototype = Object.create(DefaultApplicationWindow.prototype);
|
||||
ApplicationPreviewWindow.constructor = DefaultApplicationWindow.prototype;
|
||||
|
||||
ApplicationPreviewWindow.prototype.destroy = function() {
|
||||
this.$view = null;
|
||||
|
||||
return DefaultApplicationWindow.prototype.destroy.apply(this, arguments);
|
||||
};
|
||||
|
||||
ApplicationPreviewWindow.prototype.init = function(wm, app, scheme) {
|
||||
var self = this;
|
||||
var root = DefaultApplicationWindow.prototype.init.apply(this, arguments);
|
||||
|
||||
// Load and set up scheme (GUI) here
|
||||
scheme.render(this, 'PreviewWindow', root);
|
||||
|
||||
this._find('ZoomIn').son('click', this, this.onZoomIn);
|
||||
this._find('ZoomOut').son('click', this, this.onZoomOut);
|
||||
this._find('ZoomFit').son('click', this, this.onZoomFit);
|
||||
this._find('ZoomOriginal').son('click', this, this.onZoomOriginal);
|
||||
|
||||
var c = this._find('Content').$element;
|
||||
Utils.$bind(c, 'mousewheel', function(ev, pos) {
|
||||
if ( pos.z === 1 ) {
|
||||
self.onZoomOut();
|
||||
} else if ( pos.z === -1 ) {
|
||||
self.onZoomIn();
|
||||
}
|
||||
});
|
||||
|
||||
return root;
|
||||
};
|
||||
|
||||
ApplicationPreviewWindow.prototype.showFile = function(file, result) {
|
||||
var self = this;
|
||||
var root = this._scheme.find(this, 'Content').$element;
|
||||
Utils.$empty(root);
|
||||
|
||||
if ( result ) {
|
||||
this.zoomLevel = 0;
|
||||
|
||||
if ( file.mime.match(/^image/) ) {
|
||||
this.isImage = true;
|
||||
this.$view = this._scheme.create(self, 'gui-image', {src: result}, root, {
|
||||
onload: function() {
|
||||
self.origWidth = this.offsetWidth;
|
||||
self.origHeight = this.offsetHeight;
|
||||
self._resizeTo(this.offsetWidth, this.offsetHeight, true, false, this);
|
||||
}
|
||||
});
|
||||
} else if ( file.mime.match(/^video/) ) {
|
||||
this.isImage = false;
|
||||
this.$view = this._scheme.create(self, 'gui-video', {src: result, controls: true, autoplay: true}, root, {
|
||||
onload: function() {
|
||||
self._resizeTo(this.offsetWidth, this.offsetHeight, true, false, this);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
var toolbar = this._find('Toolbar');
|
||||
if ( toolbar ) {
|
||||
toolbar[this.isImage ? 'show' : 'hide']();
|
||||
}
|
||||
|
||||
DefaultApplicationWindow.prototype.showFile.apply(this, arguments);
|
||||
};
|
||||
|
||||
ApplicationPreviewWindow.prototype._onZoom = function(val) {
|
||||
if ( !this.isImage || !this.$view ) {
|
||||
return;
|
||||
}
|
||||
|
||||
var zoom = ['in', 'out'].indexOf(val) !== -1;
|
||||
var attr = 'zoomed';
|
||||
var w = null;
|
||||
|
||||
if ( val === 'in' ) {
|
||||
this.zoomLevel = Math.min(10, this.zoomLevel + 1);
|
||||
} else if ( val === 'out' ) {
|
||||
this.zoomLevel = Math.max(-10, this.zoomLevel - 1);
|
||||
} else {
|
||||
this.zoomLevel = 0;
|
||||
attr = val === 'fit' ? val : '';
|
||||
}
|
||||
|
||||
if ( zoom ) {
|
||||
var z = this.zoomLevel;
|
||||
if ( z === 0 ) {
|
||||
z = 1;
|
||||
w = this.origWidth;
|
||||
} else if ( z > 0 ) {
|
||||
z += 1;
|
||||
w = this.origWidth * z;
|
||||
} else if ( z < 0 ) {
|
||||
z -= 1;
|
||||
w = Math.abs(this.origWidth / z);
|
||||
}
|
||||
|
||||
this._setTitle(this.currentFile.filename + ' (' + String(z * 100) + '%)', true);
|
||||
} else {
|
||||
this._setTitle(this.currentFile.filename, true);
|
||||
}
|
||||
|
||||
this.$view.$element.setAttribute('data-zoom', attr);
|
||||
this.$view.$element.firstChild.style.width = (w === null ? 'auto' : String(w) + 'px');
|
||||
}
|
||||
|
||||
ApplicationPreviewWindow.prototype.onZoomIn = function() {
|
||||
this._onZoom('in');
|
||||
};
|
||||
|
||||
ApplicationPreviewWindow.prototype.onZoomOut = function() {
|
||||
this._onZoom('out');
|
||||
};
|
||||
|
||||
ApplicationPreviewWindow.prototype.onZoomFit = function() {
|
||||
this._onZoom('fit');
|
||||
};
|
||||
|
||||
ApplicationPreviewWindow.prototype.onZoomOriginal = function() {
|
||||
this._onZoom();
|
||||
};
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// APPLICATION
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
var ApplicationPreview = function(args, metadata) {
|
||||
DefaultApplication.apply(this, ['ApplicationPreview', args, metadata, {
|
||||
readData: false
|
||||
}]);
|
||||
};
|
||||
|
||||
ApplicationPreview.prototype = Object.create(DefaultApplication.prototype);
|
||||
ApplicationPreview.constructor = DefaultApplication;
|
||||
|
||||
ApplicationPreview.prototype.init = function(settings, metadata, scheme) {
|
||||
Application.prototype.init.call(this, settings, metadata, scheme);
|
||||
var file = this._getArgument('file');
|
||||
this._addWindow(new ApplicationPreviewWindow(this, metadata, scheme, file));
|
||||
};
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// EXPORTS
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
OSjs.Applications = OSjs.Applications || {};
|
||||
OSjs.Applications.ApplicationPreview = OSjs.Applications.ApplicationPreview || {};
|
||||
OSjs.Applications.ApplicationPreview.Class = Object.seal(ApplicationPreview);
|
||||
|
||||
})(OSjs.Helpers.DefaultApplication, OSjs.Helpers.DefaultApplicationWindow, OSjs.Core.Application, OSjs.Core.Window, OSjs.Utils, OSjs.API, OSjs.VFS, OSjs.GUI);
|
57
build/htdocs/dist/packages/default/Preview/metadata.json
vendored
Normal file
57
build/htdocs/dist/packages/default/Preview/metadata.json
vendored
Normal file
@ -0,0 +1,57 @@
|
||||
{
|
||||
"className": "ApplicationPreview",
|
||||
"name": "Preview",
|
||||
"description": "Preview image files",
|
||||
"names": {
|
||||
"bg_BG": "Преглед на изображения",
|
||||
"de_DE": "Vorschau",
|
||||
"fr_FR": "Visionneuse",
|
||||
"it_IT": "Anteprima Immagini",
|
||||
"ko_KR": "미리보기",
|
||||
"nl_NL": "Foto viewer",
|
||||
"no_NO": "Forhåndsviser",
|
||||
"pl_PL": "Podgląd",
|
||||
"ru_RU": "Просмотрщик",
|
||||
"sk_SK": "Prehliadač obrázkov",
|
||||
"tr_TR": "Önizle",
|
||||
"vi_VN": "Trình xem ảnh"
|
||||
},
|
||||
"descriptions": {
|
||||
"bg_BG": "Преглед на изображения",
|
||||
"de_DE": "Bildervorschau",
|
||||
"fr_FR": "Visionneuse de photos",
|
||||
"it_IT": "Anteprima Immagini",
|
||||
"ko_KR": "이미지 파일을 미리 봅니다",
|
||||
"nl_NL": "Foto viewer",
|
||||
"no_NO": "Forhåndsvisning av bilde-filer",
|
||||
"pl_PL": "Podgląd zdjęć",
|
||||
"ru_RU": "Просмотрщик изображений",
|
||||
"sk_SK": "Prehliadač obrázkov",
|
||||
"tr_TR": "resim dosyalarını önizle",
|
||||
"vi_VN": "Trình xem ảnh"
|
||||
},
|
||||
"mime": [
|
||||
"^image",
|
||||
"^video"
|
||||
],
|
||||
"category": "multimedia",
|
||||
"icon": "mimetypes/image.png",
|
||||
"preload": [
|
||||
{
|
||||
"type": "javascript",
|
||||
"src": "combined.js"
|
||||
},
|
||||
{
|
||||
"type": "stylesheet",
|
||||
"src": "combined.css"
|
||||
},
|
||||
{
|
||||
"src": "scheme.html",
|
||||
"type": "scheme"
|
||||
}
|
||||
],
|
||||
"type": "application",
|
||||
"path": "default/Preview",
|
||||
"build": {},
|
||||
"repo": "default"
|
||||
}
|
37
build/htdocs/dist/packages/default/Preview/scheme.html
vendored
Normal file
37
build/htdocs/dist/packages/default/Preview/scheme.html
vendored
Normal file
@ -0,0 +1,37 @@
|
||||
<application-window data-id="PreviewWindow">
|
||||
|
||||
<gui-vbox>
|
||||
<!-- MENU BAR -->
|
||||
<gui-vbox-container data-grow="0" data-shrink="1" data-basis="auto">
|
||||
<gui-menu-bar>
|
||||
|
||||
<gui-menu-bar-entry data-label="LBL_FILE">
|
||||
<gui-menu data-id="SubmenuFile">
|
||||
<gui-menu-entry data-id="MenuOpen" data-label="LBL_OPEN"></gui-menu-entry>
|
||||
<gui-menu-entry data-id="MenuClose" data-label="LBL_CLOSE"></gui-menu-entry>
|
||||
</gui-menu>
|
||||
</gui-menu-bar-entry>
|
||||
|
||||
</gui-menu-bar>
|
||||
</gui-vbox-container>
|
||||
|
||||
<!-- TOOLBAR -->
|
||||
<gui-vbox-container data-grow="0" data-shrink="1" data-basis="auto" data-id="Toolbar">
|
||||
<gui-toolbar>
|
||||
<gui-button data-id="ZoomOriginal" data-icon="stock://16x16/actions/viewmag1.png"></gui-button>
|
||||
<gui-button data-id="ZoomFit" data-icon="stock://16x16/actions/viewmagfit.png"></gui-button>
|
||||
<gui-button data-id="ZoomOut" data-icon="stock://16x16/actions/zoom-out.png"></gui-button>
|
||||
<gui-button data-id="ZoomIn" data-icon="stock://16x16/actions/zoom-in.png"></gui-button>
|
||||
</gui-toolbar>
|
||||
</gui-vbox-container>
|
||||
|
||||
<!-- CONTENT -->
|
||||
<gui-vbox-container data-grow="1" data-shrink="0" data-basis="auto" data-fill="true">
|
||||
<gui-container data-id="Content">
|
||||
</gui-container>
|
||||
</gui-vbox-container>
|
||||
|
||||
</gui-vbox>
|
||||
|
||||
|
||||
</application-window>
|
Reference in New Issue
Block a user