This commit is contained in:
lxsang
2016-10-29 14:34:29 +02:00
parent 9244208f30
commit f729d5dd8a
2510 changed files with 57350 additions and 0 deletions

View File

@ -0,0 +1,33 @@
/*!
* 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
*/
/*.ApplicationWriterWindow application-window-content {
}*/

View File

@ -0,0 +1,461 @@
/*!
* 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(Application, Window, GUI, Dialogs, VFS, Utils) {
// jscs:disable validateQuoteMarks
'use strict';
/////////////////////////////////////////////////////////////////////////////
// LOCALES
/////////////////////////////////////////////////////////////////////////////
var _Locales = {
bg_BG : {
'Insert URL' : 'Въведи URL'
},
de_DE : {
'Insert URL' : 'URL einfügen'
},
es_ES : {
'Insert URL' : 'Insertar URL'
},
fr_FR : {
'Insert URL' : 'Insérer une URL'
},
ar_DZ : {
'Insert URL' : 'أدخل رابط'
},
it_IT : {
'Insert URL' : 'Inserisci URL'
},
ko_KR : {
'Insert URL' : '링크 삽입'
},
nl_NL : {
'Insert URL' : 'URL invoegen'
},
no_NO : {
'Insert URL' : 'Sett inn URL'
},
pl_PL : {
'Insert URL' : 'Wpisz URL'
},
ru_RU : {
'Insert URL' : 'Вставить ссылку'
},
sk_SK : {
'Insert URL' : 'Vložiť URL'
},
tr_TR : {
'Insert URL' : 'URL ekle'
},
vi_VN : {
'Insert URL' : 'Thêm URL'
}
};
function _() {
var args = Array.prototype.slice.call(arguments, 0);
args.unshift(_Locales);
return OSjs.API.__.apply(this, args);
}
/////////////////////////////////////////////////////////////////////////////
// EXPORTS
/////////////////////////////////////////////////////////////////////////////
OSjs.Applications = OSjs.Applications || {};
OSjs.Applications.ApplicationWriter = OSjs.Applications.ApplicationWriter || {};
OSjs.Applications.ApplicationWriter._ = _;
})(OSjs.Helpers.DefaultApplication, OSjs.Helpers.DefaultApplicationWindow, OSjs.GUI, OSjs.Dialogs, OSjs.VFS, OSjs.Utils);
/*!
* 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 ApplicationWriterWindow(app, metadata, scheme, file) {
/*eslint dot-notation: "off"*/
var config = OSjs.Core.getConfig();
DefaultApplicationWindow.apply(this, ['ApplicationWriterWindow', {
allow_drop: true,
icon: metadata.icon,
title: metadata.name,
width: 550,
height: 400
}, app, scheme, file]);
this.checkChangeLength = -1;
this.checkChangeInterval = null;
this.color = {
background : '#ffffff',
foreground : '#000000'
};
this.font = {
name: config.Fonts['default'],
size: 3
};
}
ApplicationWriterWindow.prototype = Object.create(DefaultApplicationWindow.prototype);
ApplicationWriterWindow.constructor = DefaultApplicationWindow.prototype;
ApplicationWriterWindow.prototype.destroy = function() {
this.checkChangeInterval = clearInterval(this.checkChangeInterval);
return DefaultApplicationWindow.prototype.destroy.apply(this, arguments);
};
ApplicationWriterWindow.prototype.init = function(wmRef, app, scheme) {
var root = DefaultApplicationWindow.prototype.init.apply(this, arguments);
var self = this;
var _ = OSjs.Applications.ApplicationWriter._;
// Load and set up scheme (GUI) here
scheme.render(this, 'WriterWindow', root, null, null, {
_: _
});
var text = scheme.find(this, 'Text');
var buttons = {
'text-bold': {
command: 'bold'
},
'text-italic': {
command: 'italic'
},
'text-underline': {
command: 'underline'
},
'text-strikethrough': {
command: 'strikeThrough'
},
'justify-left': {
command: 'justifyLeft'
},
'justify-center': {
command: 'justifyCenter'
},
'justify-right': {
command: 'justifyRight'
},
'indent': {
command: 'indent'
},
'unindent': {
command: 'outdent'
}
};
var menuEntries = {
'MenuUndo': function() {
text._call('command', ['undo', false]);
},
'MenuRedo': function() {
text._call('command', ['redo', false]);
},
'MenuCopy': function() {
text._call('command', ['copy', false]);
},
'MenuCut': function() {
text._call('command', ['cut', false]);
},
'MenuDelete': function() {
text._call('command', ['delete', false]);
},
'MenuPaste': function() {
text._call('command', ['paste', false]);
},
'MenuUnlink': function() {
text._call('command', ['unlink', false]);
},
'MenuInsertOL': function() {
text._call('command', ['insertOrderedList', false]);
},
'MenuInsertUL': function() {
text._call('command', ['insertUnorderedList', false]);
},
'MenuInsertImage': function() {
API.createDialog('File', {
filter: ['^image']
}, function(ev, button, result) {
if ( button !== 'ok' || !result ) {
return;
}
VFS.url(result, function(error, url) {
text._call('command', ['insertImage', false, url]);
});
}, self);
},
'MenuInsertLink': function() {
API.createDialog('Input', {
message: _('Insert URL'),
placeholder: 'https://os.js.org'
}, function(ev, button, result) {
if ( button !== 'ok' || !result ) {
return;
}
text._call('command', ['createLink', false, result]);
}, self);
}
};
function menuEvent(ev) {
if ( menuEntries[ev.detail.id] ) {
menuEntries[ev.detail.id]();
}
}
scheme.find(this, 'SubmenuEdit').on('select', menuEvent);
scheme.find(this, 'SubmenuInsert').on('select', menuEvent);
function getSelectionStyle() {
function _call(cmd) {
return text._call('query', [cmd]);
}
var style = {
fontName: ((_call('fontName') || '').split(',')[0]).replace(/^'/, '').replace(/'$/, ''),
fontSize: parseInt(_call('fontSize'), 10) || self.font.size,
foreColor: _call('foreColor'),
hiliteColor: _call('hiliteColor')
};
Object.keys(buttons).forEach(function(b) {
var button = buttons[b];
style[button.command] = {
button: b,
value:_call(button.command)
};
});
return style;
}
function createColorDialog(current, cb) {
self._toggleDisabled(true);
API.createDialog('Color', {
color: current
}, function(ev, button, result) {
self._toggleDisabled(false);
if ( button === 'ok' && result ) {
cb(result.hex);
}
}, self);
}
function createFontDialog(current, cb) {
self._toggleDisabled(true);
API.createDialog('Font', {
fontSize: self.font.size,
fontName: self.font.name,
minSize: 1,
maxSize: 8,
unit: 'null'
}, function(ev, button, result) {
self._toggleDisabled(false);
if ( button === 'ok' && result ) {
cb(result);
}
}, self);
}
var back = scheme.find(this, 'Background').on('click', function() {
createColorDialog(self.color.background, function(hex) {
text._call('command', ['hiliteColor', false, hex]);
self.color.background = hex;
back.set('value', hex);
});
});
var front = scheme.find(this, 'Foreground').on('click', function() {
createColorDialog(self.color.foreground, function(hex) {
text._call('command', ['foreColor', false, hex]);
self.color.foreground = hex;
front.set('value', hex);
});
});
var font = scheme.find(this, 'Font').on('click', function() {
createFontDialog(null, function(font) {
text._call('command', ['fontName', false, font.fontName]);
text._call('command', ['fontSize', false, font.fontSize]);
self.font.name = font.fontName;
self.font.size = font.fontSize;
});
});
root.querySelectorAll('gui-toolbar > gui-button').forEach(function(b) {
var id = b.getAttribute('data-id');
var button = buttons[id];
if ( button ) {
(new GUI.Element(b)).on('click', function() {
text._call('command', [button.command]);
}).on('mousedown', function(ev) {
ev.preventDefault();
});
}
});
function updateToolbar(style) {
back.set('value', style.hiliteColor);
front.set('value', style.foreColor);
if ( style.fontName ) {
font.set('label', Utils.format('{0} ({1})', style.fontName, style.fontSize.toString()));
}
}
function updateSelection() {
var style = getSelectionStyle();
updateToolbar(style);
}
back.set('value', this.color.background);
front.set('value', this.color.foreground);
font.set('label', Utils.format('{0} ({1})', this.font.name, this.font.size.toString()));
text.on('selection', function() {
updateSelection();
});
this.checkChangeInterval = setInterval(function() {
if ( self.hasChanged ) {
return;
}
if ( self.checkChangeLength < 0 ) {
self.checkChangeLength = text.get('value').length;
}
var len = text.get('value').length;
if ( len !== self.checkChangeLength ) {
self.hasChanged = true;
}
self.checkChangeLength = len;
}, 500);
return root;
};
ApplicationWriterWindow.prototype.updateFile = function(file) {
DefaultApplicationWindow.prototype.updateFile.apply(this, arguments);
try {
var el = this._scheme.find(this, 'Text');
el.$element.focus();
} catch ( e ) {}
this.checkChangeLength = -1;
};
ApplicationWriterWindow.prototype.showFile = function(file, content) {
this._scheme.find(this, 'Text').set('value', content || '');
DefaultApplicationWindow.prototype.showFile.apply(this, arguments);
};
ApplicationWriterWindow.prototype.getFileData = function() {
return this._scheme.find(this, 'Text').get('value');
};
ApplicationWriterWindow.prototype._focus = function(file, content) {
if ( DefaultApplicationWindow.prototype._focus.apply(this, arguments) ) {
this._scheme.find(this, 'Text').focus();
return true;
}
return false;
};
/////////////////////////////////////////////////////////////////////////////
// APPLICATION
/////////////////////////////////////////////////////////////////////////////
function ApplicationWriter(args, metadata) {
DefaultApplication.apply(this, ['ApplicationWriter', args, metadata, {
extension: 'odoc',
mime: 'osjs/document',
filename: 'New text file.odoc'
}]);
}
ApplicationWriter.prototype = Object.create(DefaultApplication.prototype);
ApplicationWriter.constructor = DefaultApplication;
ApplicationWriter.prototype.destroy = function() {
return DefaultApplication.prototype.destroy.apply(this, arguments);
};
ApplicationWriter.prototype.init = function(settings, metadata, scheme) {
Application.prototype.init.call(this, settings, metadata, scheme);
var file = this._getArgument('file');
this._addWindow(new ApplicationWriterWindow(this, metadata, scheme, file));
};
/////////////////////////////////////////////////////////////////////////////
// EXPORTS
/////////////////////////////////////////////////////////////////////////////
OSjs.Applications = OSjs.Applications || {};
OSjs.Applications.ApplicationWriter = OSjs.Applications.ApplicationWriter || {};
OSjs.Applications.ApplicationWriter.Class = Object.seal(ApplicationWriter);
})(OSjs.Helpers.DefaultApplication, OSjs.Helpers.DefaultApplicationWindow, OSjs.Core.Application, OSjs.Core.Window, OSjs.Utils, OSjs.API, OSjs.VFS, OSjs.GUI);

View File

@ -0,0 +1,60 @@
{
"className": "ApplicationWriter",
"name": "Writer",
"description": "Write rich text documents",
"names": {
"bg_BG": "Текст",
"de_DE": "Writer",
"fr_FR": "Traitement de texte",
"it_IT": "Editor Testi",
"ko_KR": "글쓰기",
"nl_NL": "Tekstverwerker",
"no_NO": "Writer",
"pl_PL": "Writer",
"ru_RU": "Текстовый процессор",
"sk_SK": "Writer",
"tr_TR": "Writer",
"vi_VN": "Viết"
},
"descriptions": {
"bg_BG": "Писанене на обогатен текст",
"de_DE": "Verfassen Sie Rich-Text-Dokumente",
"fr_FR": "Traitement de texte riche",
"it_IT": "Scrivi documenti di testo formattati",
"ko_KR": "리치 텍스트 문서 작성",
"nl_NL": "Tekst verwerker met opmaak",
"no_NO": "Skriv riktekst dokumenter",
"pl_PL": "Twórz dokumenty rich text",
"ru_RU": "Текстовый процессор",
"sk_SK": "Editor na tvorbu Rich-Text dokumentov",
"tr_TR": "Gelişmiş dökümanlar oluşturun",
"vi_VN": "Xem, chỉnh sửa văn bản"
},
"mime": [
"^text",
"osjs\\/document"
],
"category": "office",
"icon": "apps/libreoffice34-writer.png",
"compability": [
"richtext"
],
"preload": [
{
"type": "javascript",
"src": "combined.js"
},
{
"type": "stylesheet",
"src": "combined.css"
},
{
"src": "scheme.html",
"type": "scheme"
}
],
"type": "application",
"path": "default/Writer",
"build": {},
"repo": "default"
}

View File

@ -0,0 +1,90 @@
<application-window data-id="WriterWindow">
<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="MenuNew" data-label="LBL_NEW"></gui-menu-entry>
<gui-menu-entry data-id="MenuOpen" data-label="LBL_OPEN"></gui-menu-entry>
<gui-menu-entry data-id="MenuSave" data-label="LBL_SAVE"></gui-menu-entry>
<gui-menu-entry data-id="MenuSaveAs" data-label="LBL_SAVEAS"></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-entry data-label="LBL_EDIT">
<gui-menu data-id="SubmenuEdit">
<gui-menu-entry data-id="MenuUndo" data-label="LBL_UNDO"></gui-menu-entry>
<gui-menu-entry data-id="MenuRedo" data-label="LBL_REDO"></gui-menu-entry>
<gui-menu-entry data-id="MenuCut" data-label="LBL_CUT"></gui-menu-entry>
<gui-menu-entry data-id="MenuCopy" data-label="LBL_COPY"></gui-menu-entry>
<gui-menu-entry data-id="MenuPaste" data-label="LBL_PASTE"></gui-menu-entry>
<gui-menu-entry data-id="MenuDelete" data-label="LBL_DELETE"></gui-menu-entry>
<gui-menu-entry data-id="MenuUnlink" data-label="LBL_UNLINK"></gui-menu-entry>
</gui-menu>
</gui-menu-bar-entry>
<gui-menu-bar-entry data-label="LBL_INSERT">
<gui-menu data-id="SubmenuInsert">
<gui-menu-entry data-id="MenuInsertOL" data-label="LBL_ORDERED_LIST"></gui-menu-entry>
<gui-menu-entry data-id="MenuInsertUL" data-label="LBL_UNORDERED_LIST"></gui-menu-entry>
<gui-menu-entry data-id="MenuInsertLink" data-label="LBL_LINK"></gui-menu-entry>
<gui-menu-entry data-id="MenuInsertImage" data-label="LBL_IMAGE"></gui-menu-entry>
</gui-menu>
</gui-menu-bar-entry>
</gui-menu-bar>
</gui-vbox-container>
<!-- TOOLS -->
<gui-vbox-container data-shrink="1" data-basis="auto" data-expand="true">
<gui-toolbar>
<gui-button data-id="text-bold" data-icon="stock://actions/format-text-bold.png"></gui-button>
<gui-button data-id="text-italic" data-icon="stock://actions/format-text-italic.png"></gui-button>
<gui-button data-id="text-underline" data-icon="stock://actions/format-text-underline.png"></gui-button>
<gui-button data-id="text-strikethrough" data-icon="stock://actions/format-text-strikethrough.png"></gui-button>
<gui-toolbar-separator />
<gui-button data-id="justify-left" data-icon="stock://actions/format-justify-left.png"></gui-button>
<gui-button data-id="justify-center" data-icon="stock://actions/format-justify-center.png"></gui-button>
<gui-button data-id="justify-right" data-icon="stock://actions/format-justify-right.png"></gui-button>
<gui-toolbar-separator />
<gui-button data-id="indent" data-icon="stock://actions/gtk-indent-ltr.png"></gui-button>
<gui-button data-id="unindent" data-icon="stock://actions/gtk-unindent-ltr.png"></gui-button>
<gui-toolbar-separator />
<gui-color-box data-id="Foreground"></gui-color-box>
<gui-color-box data-id="Background"></gui-color-box>
<gui-toolbar-separator />
<gui-button data-id="Font" data-group="tool" data-tool-name="">FONT (SIZE)</gui-button>
</gui-toolbar>
</gui-vbox-container>
<!-- CONTENT -->
<gui-vbox-container data-grow="1" data-shrink="0" data-basis="auto" data-fill="true">
<gui-richtext data-id="Text"></gui-richtext>
</gui-vbox-container>
<!-- STATUSBAR -->
<!--
<gui-vbox-container data-grow="0" data-shrink="1" data-basis="auto">
<gui-statusbar data-id="Statusbar"></gui-statusbar>
</gui-vbox-container>
-->
</gui-vbox>
</application-window>