3.0 source code

This commit is contained in:
agolybev
2015-04-28 17:59:00 +03:00
parent c69fd34bdd
commit 7b3b2248e5
16311 changed files with 1445974 additions and 3108429 deletions

View File

@@ -1,421 +1,466 @@
/**
* Copyright (c) Ascensio System SIA 2013. All rights reserved
*
* http://www.onlyoffice.com
*/
;(function(DocsAPI, window, document, undefined) {
/*
# Full #
config = {
type: 'desktop or mobile',
width: '100% by default',
height: '100% by default',
documentType: 'text' | 'spreadsheet' | 'presentation',
document: {
title: 'document title',
url: 'document url'
fileType: 'document file type',
options: <advanced options>,
key: 'key',
vkey: 'vkey',
info: {
author: 'author name',
folder: 'path to document',
created: <creation date>,
sharingSettings: [
{
user: 'user name',
permissions: <permissions>
},
...
]
},
permissions: {
edit: <can edit>,
download: <can download>,
reader: <can view in readable mode>
}
},
editorConfig: {
mode: 'view or edit',
lang: <language code>,
canCoAuthoring: <can coauthoring documents>,
canAutosave: <can autosave documents>,
canBackToFolder: <can return to folder>,
createUrl: 'create document url', // editor will add '?title={document title}&template={template name}&action=create', prevent to create a new document if empty
sharingSettingsUrl: 'document sharing settings url',
user: {
id: 'user id',
name: 'full user name'
},
recent: [
{
title: 'document title',
url: 'document url',
folder: 'path to document'
},
...
],
templates: [
{
name: 'template name',
icon: 'template icon url'
},
...
],
branding: {
logoUrl: 'header logo url', // default size 88 x 30
backgroundColor: 'header background color',
textColor: 'header text color'
}
},
events: {
'onReady': <document ready callback>,
'onBack': <back to folder callback>,
'onDocumentStateChange': <document state changed callback>,
'onSave': <save request callback>
}
}
# Embedded #
config = {
type: 'embedded',
width: '100% by default',
height: '100% by default',
documentType: 'text' | 'spreadsheet' | 'presentation',
document: {
title: 'document title',
url: 'document url',
fileType: 'document file type',
key: 'key',
vkey: 'vkey'
},
editorConfig: {
embedded: {
embedUrl: 'url',
fullscreenUrl: 'url',
saveUrl: 'url',
shareUrl: 'url',
toolbarDocked: 'top or bottom'
}
},
events: {
'onReady': <document ready callback>,
'onBack': <back to folder callback>,
'onError': <error callback>,
}
}
*/
// TODO: allow several instances on one page simultaneously
DocsAPI.DocEditor = function(placeholderId, config) {
var _self = this,
_config = config || {};
extend(_config, DocsAPI.DocEditor.defaultConfig);
var _onReady = function() {
if (_config.type === 'mobile') {
document.body.onfocus = function(e) {
setTimeout(function(){
iframe.contentWindow.focus();
_sendCommand({
command: 'resetFocus',
data: {}
})
}, 10);
};
}
window.onmouseup = function(evt) {
_processMouse(evt);
};
if (_config.editorConfig) {
_init(_config.editorConfig);
}
if (_config.document) {
_openDocument(_config.document);
}
};
var _onMessage = function(msg) {
if (msg) {
var events = _config.events || {},
handler = events[msg.event],
res;
if (msg.event === 'onRequestEditRights' && !handler) {
_applyEditRights(true, 'handler is\'n defined');
} else {
if (msg.event === 'onReady') {
_onReady();
}
if (handler) {
res = handler.call(_self, { target: _self, data: msg.data });
if (msg.event === 'onSave' && res !== false) {
_processSaveResult(true);
}
}
}
}
};
var target = document.getElementById(placeholderId),
iframe;
if (target) {
iframe = createIframe(_config);
target.parentNode && target.parentNode.replaceChild(iframe, target);
this._msgDispatcher = new MessageDispatcher(_onMessage, this);
}
/*
cmd = {
command: 'commandName',
data: <command specific data>
}
*/
var _sendCommand = function(cmd) {
if (iframe && iframe.contentWindow)
postMessage(iframe.contentWindow, cmd);
};
var _init = function(editorConfig) {
_sendCommand({
command: 'init',
data: {
config: editorConfig
}
});
};
var _openDocument = function(doc) {
_sendCommand({
command: 'openDocument',
data: {
doc: doc
}
});
};
var _showError = function(title, msg) {
_showMessage(title, msg, "error");
};
// severity could be one of: "error", "info" or "warning"
var _showMessage = function(title, msg, severity) {
if (typeof severity !== 'string') {
severity = "info";
}
_sendCommand({
command: 'showMessage',
data: {
title: title,
msg: msg,
severity: severity
}
});
};
var _applyEditRights = function(allowed, message) {
_sendCommand({
command: 'applyEditRights',
data: {
allowed: allowed,
message: message
}
});
};
var _processSaveResult = function(result, message) {
_sendCommand({
command: 'processSaveResult',
data: {
result: result,
message: message
}
});
};
var _processRightsChange = function(enabled, message) {
_sendCommand({
command: 'processRightsChange',
data: {
enabled: enabled,
message: message
}
});
};
var _processMouse = function(evt) {
var r = iframe.getBoundingClientRect();
var data = {
type: evt.type,
x: evt.x - r.left,
y: evt.y - r.top
};
_sendCommand({
command: 'processMouse',
data: data
});
};
var _serviceCommand = function(command, data) {
_sendCommand({
command: 'internalCommand',
data: {
command: command,
data: data
}
});
};
return {
showError : _showError,
showMessage : _showMessage,
applyEditRights : _applyEditRights,
processSaveResult : _processSaveResult,
processRightsChange : _processRightsChange,
serviceCommand : _serviceCommand
}
};
DocsAPI.DocEditor.defaultConfig = {
type: 'desktop',
width: '640px',
height: '480px'
};
MessageDispatcher = function(fn, scope) {
var _fn = fn,
_scope = scope || window;
var _bindEvents = function() {
if (window.addEventListener) {
window.addEventListener("message", function(msg) {
_onMessage(msg);
}, false)
}
else if (window.attachEvent) {
window.attachEvent("onmessage", function(msg) {
_onMessage(msg);
});
}
};
var _onMessage = function(msg) {
// TODO: check message origin
if (msg && window.JSON) {
try {
var msg = window.JSON.parse(msg.data);
if (_fn) {
_fn.call(_scope, msg);
}
} catch(e) {}
}
};
_bindEvents.call(this);
};
function getBasePath() {
var scripts = document.getElementsByTagName('script'),
match;
for (var i = scripts.length - 1; i >= 0; i--) {
match = scripts[i].src.match(/(.*)api\/documents\/api.js/i);
if (match) {
return match[1];
}
}
return "";
}
function getExtensionPath() {
if ("undefined" == typeof(extensionParams) || null == extensionParams["url"])
return null;
return extensionParams["url"] + "apps/";
}
function getAppPath(config) {
var extensionPath = getExtensionPath(),
path = extensionPath ? extensionPath : getBasePath(),
appMap = {
'text': 'documenteditor',
'text-pdf': 'documenteditor',
'spreadsheet': 'spreadsheeteditor',
'presentation': 'presentationeditor'
},
app;
if (typeof config.documentType === 'string') {
app = appMap[config.documentType.toLowerCase()];
}
path += (app || appMap['text']) + "/";
path += config.type === "mobile"
? "mobile"
: config.type === "embedded"
? "embed"
: "main";
path += "/index.html";
return path;
}
function getAppParameters(config) {
var params = "?_dc=0";
if (config.editorConfig && config.editorConfig.lang)
params += "&lang=" + config.editorConfig.lang;
return params;
}
function createIframe(config) {
var iframe = document.createElement("iframe");
iframe.src = getAppPath(config) + getAppParameters(config);
iframe.width = config.width;
iframe.height = config.height;
iframe.align = "top";
iframe.frameBorder = 0;
return iframe;
}
function postMessage(wnd, msg) {
if (wnd && wnd.postMessage && window.JSON) {
// TODO: specify explicit origin
wnd.postMessage(window.JSON.stringify(msg), "*");
}
}
function extend(dest, src) {
for (var prop in src) {
if (src.hasOwnProperty(prop) && typeof dest[prop] === 'undefined') {
dest[prop] = src[prop];
}
}
return dest;
}
})(window.DocsAPI = window.DocsAPI || {}, window, document);
/**
* Copyright (c) Ascensio System SIA 2013. All rights reserved
*
* http://www.onlyoffice.com
*/
;(function(DocsAPI, window, document, undefined) {
/*
# Full #
config = {
type: 'desktop or mobile',
width: '100% by default',
height: '100% by default',
documentType: 'text' | 'spreadsheet' | 'presentation',
document: {
title: 'document title',
url: 'document url'
fileType: 'document file type',
options: <advanced options>,
key: 'key',
vkey: 'vkey',
info: {
author: 'author name',
folder: 'path to document',
created: <creation date>,
sharingSettings: [
{
user: 'user name',
permissions: <permissions>
},
...
]
},
permissions: {
edit: <can edit>,
download: <can download>,
reader: <can view in readable mode>
}
},
editorConfig: {
mode: 'view or edit',
lang: <language code>,
canCoAuthoring: <can coauthoring documents>,
canAutosave: <can autosave documents>,
canBackToFolder: <can return to folder>,
createUrl: 'create document url', // editor will add '?title={document title}&template={template name}&action=create', prevent to create a new document if empty
sharingSettingsUrl: 'document sharing settings url',
callbackUrl: <url for connection between sdk and portal>,
user: {
id: 'user id',
name: 'full user name'
},
recent: [
{
title: 'document title',
url: 'document url',
folder: 'path to document'
},
...
],
templates: [
{
name: 'template name',
icon: 'template icon url'
},
...
],
branding: {
logoUrl: 'header logo url', // default size 88 x 30
backgroundColor: 'header background color',
textColor: 'header text color',
customer: 'SuperPuper',
customerAddr: 'New-York, 125f-25',
customerMail: 'support@gmail.com',
customerWww: 'www.superpuper.com',
customerInfo: 'Some info',
customerLogo: ''
}
},
events: {
'onReady': <document ready callback>,
'onBack': <back to folder callback>,
'onDocumentStateChange': <document state changed callback>,
'onSave': <save request callback>
}
}
# Embedded #
config = {
type: 'embedded',
width: '100% by default',
height: '100% by default',
documentType: 'text' | 'spreadsheet' | 'presentation',
document: {
title: 'document title',
url: 'document url',
fileType: 'document file type',
key: 'key',
vkey: 'vkey'
},
editorConfig: {
embedded: {
embedUrl: 'url',
fullscreenUrl: 'url',
saveUrl: 'url',
shareUrl: 'url',
toolbarDocked: 'top or bottom'
}
},
events: {
'onReady': <document ready callback>,
'onBack': <back to folder callback>,
'onError': <error callback>,
}
}
*/
// TODO: allow several instances on one page simultaneously
DocsAPI.DocEditor = function(placeholderId, config) {
var _self = this,
_config = config || {};
extend(_config, DocsAPI.DocEditor.defaultConfig);
extend(_config.editorConfig, DocsAPI.DocEditor.defaultConfig.editorConfig);
_config.editorConfig.canBackToFolder = !!_config.events.onBack;
var onMouseUp = function (evt) {
_processMouse(evt);
};
var _attachMouseEvents = function() {
if (window.addEventListener) {
window.addEventListener("mouseup", onMouseUp, false)
} else if (window.attachEvent) {
window.attachEvent("onmouseup", onMouseUp);
}
};
var _detachMouseEvents = function() {
if (window.removeEventListener) {
window.removeEventListener("mouseup", onMouseUp, false)
} else if (window.detachEvent) {
window.detachEvent("onmouseup", onMouseUp);
}
};
var _onReady = function() {
if (_config.type === 'mobile') {
document.body.onfocus = function(e) {
setTimeout(function(){
iframe.contentWindow.focus();
_sendCommand({
command: 'resetFocus',
data: {}
})
}, 10);
};
}
_attachMouseEvents();
if (_config.editorConfig) {
_init(_config.editorConfig);
}
if (_config.document) {
_openDocument(_config.document);
}
};
var _onMessage = function(msg) {
if (msg) {
var events = _config.events || {},
handler = events[msg.event],
res;
if (msg.event === 'onRequestEditRights' && !handler) {
_applyEditRights(true, 'handler is\'n defined');
} else {
if (msg.event === 'onReady') {
_onReady();
}
if (handler) {
res = handler.call(_self, { target: _self, data: msg.data });
if (msg.event === 'onSave' && res !== false) {
_processSaveResult(true);
}
}
}
}
};
var target = document.getElementById(placeholderId),
iframe;
if (target) {
iframe = createIframe(_config);
target.parentNode && target.parentNode.replaceChild(iframe, target);
this._msgDispatcher = new MessageDispatcher(_onMessage, this);
}
/*
cmd = {
command: 'commandName',
data: <command specific data>
}
*/
var _sendCommand = function(cmd) {
if (iframe && iframe.contentWindow)
postMessage(iframe.contentWindow, cmd);
};
var _init = function(editorConfig) {
_sendCommand({
command: 'init',
data: {
config: editorConfig
}
});
};
var _openDocument = function(doc) {
_sendCommand({
command: 'openDocument',
data: {
doc: doc
}
});
};
var _showError = function(title, msg) {
_showMessage(title, msg, "error");
};
// severity could be one of: "error", "info" or "warning"
var _showMessage = function(title, msg, severity) {
if (typeof severity !== 'string') {
severity = "info";
}
_sendCommand({
command: 'showMessage',
data: {
title: title,
msg: msg,
severity: severity
}
});
};
var _applyEditRights = function(allowed, message) {
_sendCommand({
command: 'applyEditRights',
data: {
allowed: allowed,
message: message
}
});
};
var _processSaveResult = function(result, message) {
_sendCommand({
command: 'processSaveResult',
data: {
result: result,
message: message
}
});
};
var _processRightsChange = function(enabled, message) {
_sendCommand({
command: 'processRightsChange',
data: {
enabled: enabled,
message: message
}
});
};
var _processMouse = function(evt) {
var r = iframe.getBoundingClientRect();
var data = {
type: evt.type,
x: evt.x - r.left,
y: evt.y - r.top
};
_sendCommand({
command: 'processMouse',
data: data
});
};
var _serviceCommand = function(command, data) {
_sendCommand({
command: 'internalCommand',
data: {
command: command,
data: data
}
});
};
return {
showError : _showError,
showMessage : _showMessage,
applyEditRights : _applyEditRights,
processSaveResult : _processSaveResult,
processRightsChange : _processRightsChange,
serviceCommand : _serviceCommand,
attachMouseEvents : _attachMouseEvents,
detachMouseEvents : _detachMouseEvents
}
};
DocsAPI.DocEditor.defaultConfig = {
type: 'desktop',
width: '100%',
height: '100%',
editorConfig: {
lang: 'en',
canCoAuthoring: true
}
};
DocsAPI.DocEditor.version = function() {
return '3.0b';
};
MessageDispatcher = function(fn, scope) {
var _fn = fn,
_scope = scope || window;
var _bindEvents = function() {
if (window.addEventListener) {
window.addEventListener("message", function(msg) {
_onMessage(msg);
}, false)
}
else if (window.attachEvent) {
window.attachEvent("onmessage", function(msg) {
_onMessage(msg);
});
}
};
var _onMessage = function(msg) {
// TODO: check message origin
if (msg && window.JSON) {
try {
var msg = window.JSON.parse(msg.data);
if (_fn) {
_fn.call(_scope, msg);
}
} catch(e) {}
}
};
_bindEvents.call(this);
};
function getBasePath() {
var scripts = document.getElementsByTagName('script'),
match;
for (var i = scripts.length - 1; i >= 0; i--) {
match = scripts[i].src.match(/(.*)api\/documents\/api.js/i);
if (match) {
return match[1];
}
}
return "";
}
function getExtensionPath() {
if ("undefined" == typeof(extensionParams) || null == extensionParams["url"])
return null;
return extensionParams["url"] + "apps/";
}
function getAppPath(config) {
var extensionPath = getExtensionPath(),
path = extensionPath ? extensionPath : getBasePath(),
appMap = {
'text': 'documenteditor',
'text-pdf': 'documenteditor',
'spreadsheet': 'spreadsheeteditor',
'presentation': 'presentationeditor'
},
app = appMap['text'];
if (typeof config.documentType === 'string') {
app = appMap[config.documentType.toLowerCase()];
} else
if (!!config.document && typeof config.document.fileType === 'string') {
var type = /^(?:(xls|xlsx|ods|csv|xlst|xlsy|gsheet)|(pps|ppsx|ppt|pptx|odp|pptt|ppty|gslides))$/
.exec(config.document.fileType);
if (type) {
if (typeof type[1] === 'string') app = appMap['spreadsheet']; else
if (typeof type[2] === 'string') app = appMap['presentation'];
}
}
path += app + "/";
path += config.type === "mobile"
? "mobile"
: config.type === "embedded"
? "embed"
: "main";
path += "/index.html";
return path;
}
function getAppParameters(config) {
var params = "?_dc=0";
if (config.editorConfig && config.editorConfig.lang)
params += "&lang=" + config.editorConfig.lang;
return params;
}
function createIframe(config) {
var iframe = document.createElement("iframe");
iframe.src = getAppPath(config) + getAppParameters(config);
iframe.width = config.width;
iframe.height = config.height;
iframe.align = "top";
iframe.frameBorder = 0;
return iframe;
}
function postMessage(wnd, msg) {
if (wnd && wnd.postMessage && window.JSON) {
// TODO: specify explicit origin
wnd.postMessage(window.JSON.stringify(msg), "*");
}
}
function extend(dest, src) {
for (var prop in src) {
if (src.hasOwnProperty(prop) && typeof dest[prop] === 'undefined') {
dest[prop] = src[prop];
}
}
return dest;
}
})(window.DocsAPI = window.DocsAPI || {}, window, document);

View File

@@ -1,28 +1,25 @@
<!DOCTYPE html>
<html>
<head>
<title>ONLYOFFICE Documents</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="description" content="" />
<meta name="keywords" content="" />
<style type="text/css"></style>
</head>
<body>
<script type="text/javascript" src="../../../3rdparty/extjs/ext-all.js"></script>
<script type="text/javascript" src="../../../3rdparty/jquery/jquery-1.7.1.min.js"></script>
<script type="text/javascript" src="../../../3rdparty/jquery/mousewheel/jquery.mousewheel.js"></script>
<script type="text/javascript" src="../../../3rdparty/jquery/jscrollpane/jquery.jscrollpane.min.js"></script>
<script type="text/javascript" src="../../../3rdparty/sockjs/sockjs-0.3.min.js"></script>
<script type="text/javascript" src="../../../3rdparty/underscore/underscore-min.js"></script>
<script type="text/javascript" src="../../../3rdparty/xregexp/xregexp-all-min.js"></script>
<script type="text/javascript" src="../../../sdk/Common/AllFonts.js"></script>
<script type="text/javascript" src="../../../sdk/Word/sdk-all.js"></script>
<div id="editor_sdk">
<script type="text/javascript">
var editor = new asc_docs_api("editor_sdk");
editor.SetFontsPath("../../../sdk/Fonts/");
editor.LoadFontsFromServer();
</script>
</body>
</html>
<!DOCTYPE html>
<html>
<head>
<title>ONLYOFFICE Documents</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="description" content="" />
<meta name="keywords" content="" />
<style type="text/css"></style>
</head>
<body>
<script type="text/javascript" src="../../../vendor/jquery/jquery.min.js"></script>
<script type="text/javascript" src="../../../vendor/requirejs/require.js"></script>
<script type="text/javascript" src="../../../vendor/sockjs/sockjs.min.js"></script>
<script type="text/javascript" src="../../../vendor/xregexp/xregexp-all-min.js"></script>
<script type="text/javascript" src="../../../sdk/Common/AllFonts.js"></script>
<script type="text/javascript" src="../../../sdk/Word/sdk-all.js"></script>
<div id="editor_sdk">
<script type="text/javascript">
var editor = new asc_docs_api("editor_sdk");
editor.SetFontsPath("../../../sdk/Fonts/");
editor.LoadFontsFromServer();
</script>
</body>
</html>

View File

@@ -1,224 +1,235 @@
<!DOCTYPE html>
<html>
<head>
<title>ONLYOFFICE Documents</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=IE8"/>
<meta name="description" content="" />
<meta name="keywords" content="" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=no">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-touch-fullscreen" content="yes">
<style type="text/css">
html {
height: 100%;
}
body {
height: 100%;
margin: 0;
padding: 0;
overflow: hidden;
}
#wrap {
position:absolute;
left:0;
top:0;
right:0;
bottom:0;
}
</style>
</head>
<body>
<div id="wrap">
<div id="placeholder"></div>
</div>
<script type="text/javascript" src="api.js"></script>
<script>
(function() {
// Url parameters
var urlParams = getUrlParams(),
cfg = getEditorConfig(urlParams),
doc = getDocumentData(urlParams);
// Document Editor
var docEditor = new DocsAPI.DocEditor('placeholder', {
type: urlParams['type'],
width: '100%',
height: '100%',
documentType: urlParams['doctype'],
document: doc,
editorConfig: cfg,
events: {
'onReady': onDocEditorReady,
'onBack': onBack,
'onDocumentStateChange': onDocumentStateChange,
'onRequestEditRights': onRequestEditRights,
'onSave': onDocumentSave,
'onError': onError
}
});
// Document Editor event handlers
function onDocEditorReady(event) {
if (event.target) {
//console.log('Ready! Editor: ', event.target);
}
}
function onBack(event) {
//console.log('Go back!');
}
function onDocumentStateChange(event) {
var isModified = event.data;
//console.log(isModified);
}
function onRequestEditRights(event) {
// occurs whenever the user tryes to enter edit mode
docEditor.applyEditRights(true, "Someone is editing this document right now. Please try again later.");
}
function onDocumentSave(event) {
var url = event.data;
// if you want to async save process return false
// and call api.processSaveResult when ready
}
function onError(event) {
// critical error happened
// examine event.data.errorCode and event.data.errorDescription for details
}
// helpers
function getUrlParams() {
var e,
a = /\+/g, // Regex for replacing addition symbol with a space
r = /([^&=]+)=?([^&]*)/g,
d = function (s) { return decodeURIComponent(s.replace(a, " ")); },
q = window.location.search.substring(1),
urlParams = {};
while (e = r.exec(q))
urlParams[d(e[1])] = d(e[2]);
return urlParams;
}
function getDocumentData(urlParams) {
return {
key: urlParams["key"],
url: urlParams["url"],
title: urlParams["title"],
fileType: urlParams["filetype"],
vkey: urlParams["vkey"],
permissions: {
edit: true,
download: true,
reader: true
}
};
}
function getEditorConfig(urlParams) {
return {
mode : urlParams["mode"] || 'edit',
lang : urlParams["lang"] || 'en',
canCoAuthoring : true,
canBackToFolder : true,
canCreateNew : true,
createUrl : 'http://www.example.com/create',
user: {
id: urlParams["userid"] || 'uid-901', name: urlParams["username"] || 'Hamish Mitchell'
},
recent : [
{title: 'Memory.docx', url: 'http://onlyoffice.com', folder: 'Document Editor'},
{title: 'Description.doc', url: 'http://onlyoffice.com', folder: 'Document Editor'},
{title: 'DocEditor_right.xsl', url: 'http://onlyoffice.com', folder: 'Spreadsheet Editor'},
{title: 'api.rtf', url: 'http://onlyoffice.com', folder: 'Unnamed folder'}
],
templates : [
{name: 'Contracts', icon: '../../api/documents/resources/templates/contracts.png'},
{name: 'Letter', icon: '../../api/documents/resources/templates/letter.png'},
{name: 'List', icon: '../../api/documents/resources/templates/list.png'},
{name: 'Plan', icon: '../../api/documents/resources/templates/plan.png'}
],
embedded : {
embedUrl : 'http://onlyoffice.com/embed',
fullscreenUrl : 'http://onlyoffice.com/fullscreen',
saveUrl : 'http://onlyoffice.com/download',
shareUrl : 'http://tl.com/72b4la97',
toolbarDocked : 'top'
}
};
}
// Mobile version
function isMobile(){
var prefixes = {
ios: 'i(?:Pad|Phone|Pod)(?:.*)CPU(?: iPhone)? OS ',
android: '(Android |HTC_|Silk/)',
blackberry: 'BlackBerry(?:.*)Version\/',
rimTablet: 'RIM Tablet OS ',
webos: '(?:webOS|hpwOS)\/',
bada: 'Bada\/'
},
i, prefix, match;
for (i in prefixes){
if (prefixes.hasOwnProperty(i)) {
prefix = prefixes[i];
if (navigator.userAgent.match(new RegExp('(?:'+prefix+')([^\\s;]+)')))
return true;
}
}
return false;
}
var fixSize = function() {
var wrapEl = document.getElementById('wrap');
if (wrapEl){
wrapEl.style.height = screen.availHeight + 'px';
window.scrollTo(0, -1);
wrapEl.style.height = window.innerHeight + 'px';
}
};
var fixIpadLandscapeIos7 = function() {
if (navigator.userAgent.match(/iPad;.*CPU.*OS 7_\d/i)) {
var wrapEl = document.getElementById('wrap');
if (wrapEl){
wrapEl.style.position = "fixed";
wrapEl.style.bottom = 0;
wrapEl.style.width = "100%";
}
}
};
if (isMobile()){
window.addEventListener('load', fixSize);
window.addEventListener('resize', fixSize);
fixIpadLandscapeIos7();
}
})();
</script>
</body>
</html>
<!DOCTYPE html>
<html>
<head>
<title>ONLYOFFICE Documents</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=IE8"/>
<meta name="description" content="" />
<meta name="keywords" content="" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=no">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-touch-fullscreen" content="yes">
<style type="text/css">
html {
height: 100%;
}
body {
height: 100%;
margin: 0;
padding: 0;
overflow: hidden;
}
#wrap {
position:absolute;
left:0;
top:0;
right:0;
bottom:0;
}
</style>
</head>
<body>
<div id="wrap">
<div id="placeholder"></div>
</div>
<script type="text/javascript" src="api.js"></script>
<script>
(function() {
// Url parameters
var urlParams = getUrlParams(),
cfg = getEditorConfig(urlParams),
doc = getDocumentData(urlParams);
// Document Editor
var docEditor = new DocsAPI.DocEditor('placeholder', {
type: urlParams['type'],
width: '100%',
height: '100%',
documentType: urlParams['doctype'],
document: doc,
editorConfig: cfg,
events: {
'onReady': onDocEditorReady,
'onBack': onBack,
'onDocumentStateChange': onDocumentStateChange,
'onRequestEditRights': onRequestEditRights,
'onSave': onDocumentSave,
'onError': onError
}
});
// Document Editor event handlers
function onDocEditorReady(event) {
if (event.target) {
//console.log('Ready! Editor: ', event.target);
}
}
function onBack(event) {
//console.log('Go back!');
}
function onDocumentStateChange(event) {
var isModified = event.data;
//console.log(isModified);
}
function onRequestEditRights(event) {
// occurs whenever the user tryes to enter edit mode
docEditor.applyEditRights(true, "Someone is editing this document right now. Please try again later.");
}
function onDocumentSave(event) {
var url = event.data;
// if you want to async save process return false
// and call api.processSaveResult when ready
}
function onError(event) {
// critical error happened
// examine event.data.errorCode and event.data.errorDescription for details
}
// helpers
function getUrlParams() {
var e,
a = /\+/g, // Regex for replacing addition symbol with a space
r = /([^&=]+)=?([^&]*)/g,
d = function (s) { return decodeURIComponent(s.replace(a, " ")); },
q = window.location.search.substring(1),
urlParams = {};
while (e = r.exec(q))
urlParams[d(e[1])] = d(e[2]);
return urlParams;
}
function getDocumentData(urlParams) {
return {
key: urlParams["key"],
url: urlParams["url"],
title: urlParams["title"],
fileType: urlParams["filetype"],
vkey: urlParams["vkey"],
permissions: {
edit: true,
download: true,
reader: true
}
};
}
function getEditorConfig(urlParams) {
return {
mode : urlParams["mode"] || 'edit',
lang : urlParams["lang"] || 'en',
canCoAuthoring : true,
canBackToFolder : true,
canCreateNew : true,
createUrl : 'http://www.example.com/create',
user: {
id: urlParams["userid"] || 'uid-901', name: urlParams["username"] || 'Hamish Mitchell'
},
recent : [
{title: 'Memory.docx', url: 'http://onlyoffice.com', folder: 'Document Editor'},
{title: 'Description.doc', url: 'http://onlyoffice.com', folder: 'Document Editor'},
{title: 'DocEditor_right.xsl', url: 'http://onlyoffice.com', folder: 'Spreadsheet Editor'},
{title: 'api.rtf', url: 'http://onlyoffice.com', folder: 'Unnamed folder'}
],
templates : [
{name: 'Contracts', icon: '../../api/documents/resources/templates/contracts.png'},
{name: 'Letter', icon: '../../api/documents/resources/templates/letter.png'},
{name: 'List', icon: '../../api/documents/resources/templates/list.png'},
{name: 'Plan', icon: '../../api/documents/resources/templates/plan.png'}
],
embedded : {
embedUrl : 'http://onlyoffice.com/embed',
fullscreenUrl : 'http://onlyoffice.com/fullscreen',
saveUrl : 'http://onlyoffice.com/download',
shareUrl : 'http://tl.com/72b4la97',
toolbarDocked : 'top'
}
// ,branding: {
// logoUrl: 'header logo url', // default size 88 x 30
// backgroundColor: '#ffffff',
// textColor: '#ff0000',
// customer: 'SuperPuper',
// customerAddr: 'New-York, 125f-25',
// customerMail: 'support@gmail.com',
// customerWww: 'www.superpuper.com',
// customerInfo: 'Some info',
// customerLogo: 'https://img.imgsmail.ru/r/default/portal/0.1.29/logo.png'
// }
};
}
// Mobile version
function isMobile(){
var prefixes = {
ios: 'i(?:Pad|Phone|Pod)(?:.*)CPU(?: iPhone)? OS ',
android: '(Android |HTC_|Silk/)',
blackberry: 'BlackBerry(?:.*)Version\/',
rimTablet: 'RIM Tablet OS ',
webos: '(?:webOS|hpwOS)\/',
bada: 'Bada\/'
},
i, prefix, match;
for (i in prefixes){
if (prefixes.hasOwnProperty(i)) {
prefix = prefixes[i];
if (navigator.userAgent.match(new RegExp('(?:'+prefix+')([^\\s;]+)')))
return true;
}
}
return false;
}
var fixSize = function() {
var wrapEl = document.getElementById('wrap');
if (wrapEl){
wrapEl.style.height = screen.availHeight + 'px';
window.scrollTo(0, -1);
wrapEl.style.height = window.innerHeight + 'px';
}
};
var fixIpadLandscapeIos7 = function() {
if (navigator.userAgent.match(/iPad;.*CPU.*OS 7_\d/i)) {
var wrapEl = document.getElementById('wrap');
if (wrapEl){
wrapEl.style.position = "fixed";
wrapEl.style.bottom = 0;
wrapEl.style.width = "100%";
}
}
};
if (isMobile()){
window.addEventListener('load', fixSize);
window.addEventListener('resize', fixSize);
fixIpadLandscapeIos7();
}
})();
</script>
</body>
</html>

View File

@@ -1,68 +1,68 @@
/*
* (c) Copyright Ascensio System SIA 2010-2014
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
if (Common === undefined) {
var Common = {};
}
Common.component = Common.component || {};
Common.Analytics = Common.component.Analytics = new(function () {
var _category;
return {
initialize: function (id, category) {
if (typeof id === "undefined") {
throw "Analytics: invalid id.";
}
if (typeof category === "undefined" || Object.prototype.toString.apply(category) !== "[object String]") {
throw "Analytics: invalid category type.";
}
_category = category;
$("head").append('<script type="text/javascript">' + "var _gaq = _gaq || [];" + '_gaq.push(["_setAccount", "' + id + '"]);' + '_gaq.push(["_trackPageview"]);' + "(function() {" + 'var ga = document.createElement("script"); ga.type = "text/javascript"; ga.async = true;' + 'ga.src = ("https:" == document.location.protocol ? "https://ssl" : "http://www") + ".google-analytics.com/ga.js";' + 'var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(ga, s);' + "})();" + "</script>");
},
trackEvent: function (action, label, value) {
if (typeof action !== "undefined" && Object.prototype.toString.apply(action) !== "[object String]") {
throw "Analytics: invalid action type.";
}
if (typeof label !== "undefined" && Object.prototype.toString.apply(label) !== "[object String]") {
throw "Analytics: invalid label type.";
}
if (typeof value !== "undefined" && !(Object.prototype.toString.apply(value) === "[object Number]" && isFinite(value))) {
throw "Analytics: invalid value type.";
}
if (typeof _gaq === "undefined") {
return;
}
if (_category === "undefined") {
throw "Analytics is not initialized.";
}
_gaq.push(["_trackEvent", _category, action, label, value]);
}
};
/*
* (c) Copyright Ascensio System SIA 2010-2015
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
if (Common === undefined) {
var Common = {};
}
Common.component = Common.component || {};
Common.Analytics = Common.component.Analytics = new(function () {
var _category;
return {
initialize: function (id, category) {
if (typeof id === "undefined") {
throw "Analytics: invalid id.";
}
if (typeof category === "undefined" || Object.prototype.toString.apply(category) !== "[object String]") {
throw "Analytics: invalid category type.";
}
_category = category;
$("head").append('<script type="text/javascript">' + "var _gaq = _gaq || [];" + '_gaq.push(["_setAccount", "' + id + '"]);' + '_gaq.push(["_trackPageview"]);' + "(function() {" + 'var ga = document.createElement("script"); ga.type = "text/javascript"; ga.async = true;' + 'ga.src = ("https:" == document.location.protocol ? "https://ssl" : "http://www") + ".google-analytics.com/ga.js";' + 'var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(ga, s);' + "})();" + "</script>");
},
trackEvent: function (action, label, value) {
if (typeof action !== "undefined" && Object.prototype.toString.apply(action) !== "[object String]") {
throw "Analytics: invalid action type.";
}
if (typeof label !== "undefined" && Object.prototype.toString.apply(label) !== "[object String]") {
throw "Analytics: invalid label type.";
}
if (typeof value !== "undefined" && !(Object.prototype.toString.apply(value) === "[object Number]" && isFinite(value))) {
throw "Analytics: invalid value type.";
}
if (typeof _gaq === "undefined") {
return;
}
if (_category === "undefined") {
throw "Analytics is not initialized.";
}
_gaq.push(["_trackEvent", _category, action, label, value]);
}
};
})();

View File

@@ -1,151 +1,157 @@
/*
* (c) Copyright Ascensio System SIA 2010-2014
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
if (Common === undefined) {
var Common = {};
}
Common.Gateway = new(function () {
var me = this,
$me = $(me);
var commandMap = {
"init": function (data) {
$me.trigger("init", data);
},
"openDocument": function (data) {
$me.trigger("opendocument", data);
},
"showMessage": function (data) {
$me.trigger("showmessage", data);
},
"applyEditRights": function (data) {
$me.trigger("applyeditrights", data);
},
"processSaveResult": function (data) {
$me.trigger("processsaveresult", data);
},
"processRightsChange": function (data) {
$me.trigger("processrightschange", data);
},
"processMouse": function (data) {
$me.trigger("processmouse", data);
},
"internalCommand": function (data) {
$me.trigger("internalcommand", data);
},
"resetFocus": function (data) {
$me.trigger("resetfocus", data);
}
};
var _postMessage = function (msg) {
if (window.parent && window.JSON) {
window.parent.postMessage(window.JSON.stringify(msg), "*");
}
};
var _onMessage = function (msg) {
var data = msg.data;
if (Object.prototype.toString.apply(data) !== "[object String]" || !window.JSON) {
return;
}
var cmd, handler;
try {
cmd = window.JSON.parse(data);
} catch(e) {
cmd = "";
}
if (cmd) {
handler = commandMap[cmd.command];
if (handler) {
handler.call(this, cmd.data);
}
}
};
var fn = function (e) {
_onMessage(e);
};
if (window.attachEvent) {
window.attachEvent("onmessage", fn);
} else {
window.addEventListener("message", fn, false);
}
return {
ready: function () {
_postMessage({
event: "onReady"
});
},
goBack: function () {
_postMessage({
event: "onBack"
});
},
save: function (url) {
_postMessage({
event: "onSave",
data: url
});
},
requestEditRights: function () {
_postMessage({
event: "onRequestEditRights"
});
},
reportError: function (code, description) {
_postMessage({
event: "onError",
data: {
errorCode: code,
errorDescription: description
}
});
},
setDocumentModified: function (modified) {
_postMessage({
event: "onDocumentStateChange",
data: modified
});
},
internalMessage: function (type, data) {
_postMessage({
event: "onInternalMessage",
data: {
type: type,
data: data
}
});
},
on: function (event, handler) {
var localHandler = function (event, data) {
handler.call(me, data);
};
$me.on(event, localHandler);
}
};
/*
* (c) Copyright Ascensio System SIA 2010-2015
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
if (Common === undefined) {
var Common = {};
}
Common.Gateway = new(function () {
var me = this,
$me = $(me);
var commandMap = {
"init": function (data) {
$me.trigger("init", data);
},
"openDocument": function (data) {
$me.trigger("opendocument", data);
},
"showMessage": function (data) {
$me.trigger("showmessage", data);
},
"applyEditRights": function (data) {
$me.trigger("applyeditrights", data);
},
"processSaveResult": function (data) {
$me.trigger("processsaveresult", data);
},
"processRightsChange": function (data) {
$me.trigger("processrightschange", data);
},
"processMouse": function (data) {
$me.trigger("processmouse", data);
},
"internalCommand": function (data) {
$me.trigger("internalcommand", data);
},
"resetFocus": function (data) {
$me.trigger("resetfocus", data);
}
};
var _postMessage = function (msg) {
if (window.parent && window.JSON) {
window.parent.postMessage(window.JSON.stringify(msg), "*");
}
};
var _onMessage = function (msg) {
var data = msg.data;
if (Object.prototype.toString.apply(data) !== "[object String]" || !window.JSON) {
return;
}
var cmd, handler;
try {
cmd = window.JSON.parse(data);
} catch(e) {
cmd = "";
}
if (cmd) {
handler = commandMap[cmd.command];
if (handler) {
handler.call(this, cmd.data);
}
}
};
var fn = function (e) {
_onMessage(e);
};
if (window.attachEvent) {
window.attachEvent("onmessage", fn);
} else {
window.addEventListener("message", fn, false);
}
return {
ready: function () {
_postMessage({
event: "onReady"
});
},
goBack: function (new_window) {
_postMessage({
event: "onBack",
data: (new_window == true)
});
},
save: function (url) {
_postMessage({
event: "onSave",
data: url
});
},
requestEditRights: function () {
_postMessage({
event: "onRequestEditRights"
});
},
reportError: function (code, description) {
_postMessage({
event: "onError",
data: {
errorCode: code,
errorDescription: description
}
});
},
setDocumentModified: function (modified) {
_postMessage({
event: "onDocumentStateChange",
data: modified
});
},
internalMessage: function (type, data) {
_postMessage({
event: "onInternalMessage",
data: {
type: type,
data: data
}
});
},
updateVersion: function () {
_postMessage({
event: "onOutdatedVersion"
});
},
on: function (event, handler) {
var localHandler = function (event, data) {
handler.call(me, data);
};
$me.on(event, localHandler);
}
};
})();

View File

@@ -1,81 +1,81 @@
/*
* (c) Copyright Ascensio System SIA 2010-2014
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
if (Common === undefined) {
var Common = {};
}
Common.IrregularStack = function (config) {
var _stack = [];
var _compare = function (obj1, obj2) {
if (typeof obj1 === "object" && typeof obj2 === "object" && window.JSON) {
return window.JSON.stringify(obj1) === window.JSON.stringify(obj2);
}
return obj1 === obj2;
};
config = config || {};
var _strongCompare = config.strongCompare || _compare;
var _weakCompare = config.weakCompare || _compare;
var _indexOf = function (obj, compare) {
for (var i = _stack.length - 1; i >= 0; i--) {
if (compare(_stack[i], obj)) {
return i;
}
}
return -1;
};
var _push = function (obj) {
_stack.push(obj);
};
var _pop = function (obj) {
var index = _indexOf(obj, _strongCompare);
if (index != -1) {
var removed = _stack.splice(index, 1);
return removed[0];
}
return undefined;
};
var _get = function (obj) {
var index = _indexOf(obj, _weakCompare);
if (index != -1) {
return _stack[index];
}
return undefined;
};
var _exist = function (obj) {
return ! (_indexOf(obj, _strongCompare) < 0);
};
return {
push: _push,
pop: _pop,
get: _get,
exist: _exist
};
/*
* (c) Copyright Ascensio System SIA 2010-2015
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
if (Common === undefined) {
var Common = {};
}
Common.IrregularStack = function (config) {
var _stack = [];
var _compare = function (obj1, obj2) {
if (typeof obj1 === "object" && typeof obj2 === "object" && window.JSON) {
return window.JSON.stringify(obj1) === window.JSON.stringify(obj2);
}
return obj1 === obj2;
};
config = config || {};
var _strongCompare = config.strongCompare || _compare;
var _weakCompare = config.weakCompare || _compare;
var _indexOf = function (obj, compare) {
for (var i = _stack.length - 1; i >= 0; i--) {
if (compare(_stack[i], obj)) {
return i;
}
}
return -1;
};
var _push = function (obj) {
_stack.push(obj);
};
var _pop = function (obj) {
var index = _indexOf(obj, _strongCompare);
if (index != -1) {
var removed = _stack.splice(index, 1);
return removed[0];
}
return undefined;
};
var _get = function (obj) {
var index = _indexOf(obj, _weakCompare);
if (index != -1) {
return _stack[index];
}
return undefined;
};
var _exist = function (obj) {
return ! (_indexOf(obj, _strongCompare) < 0);
};
return {
push: _push,
pop: _pop,
get: _get,
exist: _exist
};
};

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.1 KiB

View File

@@ -1,6 +1,56 @@
// Bootstrap core variables and mixins
@import "../../../../../3rdparty/bootstrap/src/less/variables.less";
@import "../../../../../3rdparty/bootstrap/src/less/mixins.less";
// Core variables and mixins
@import "../../../../../vendor/bootstrap/less/variables.less";
@icon-font-path: "../../../../../vendor/bootstrap/dist/fonts/";
@import "../../../../../vendor/bootstrap/less/mixins.less";
// Reset
@import "../../../../../vendor/bootstrap/less/normalize.less";
@import "../../../../../vendor/bootstrap/less/print.less";
// Core CSS
@import "../../../../../vendor/bootstrap/less/scaffolding.less";
@import "../../../../../vendor/bootstrap/less/type.less";
//@import "code.less";
//@import "grid.less";
//@import "tables.less";
@import "../../../../../vendor/bootstrap/less/forms.less";
@import "../../../../../vendor/bootstrap/less/buttons.less";
// Components
@import "../../../../../vendor/bootstrap/less/component-animations.less";
@import "../../../../../vendor/bootstrap/less/glyphicons.less";
//@import "dropdowns.less";
//@import "button-groups.less";
//@import "input-groups.less";
//@import "navs.less";
//@import "navbar.less";
//@import "breadcrumbs.less";
//@import "pagination.less";
//@import "pager.less";
@import "../../../../../vendor/bootstrap/less/labels.less";
//@import "badges.less";
//@import "jumbotron.less";
//@import "thumbnails.less";
@import "../../../../../vendor/bootstrap/less/alerts.less";
//@import "progress-bars.less";
//@import "media.less";
//@import "list-group.less";
//@import "panels.less";
//@import "wells.less";
//@import "close.less";
// Components w/ JavaScript
@import "../../../../../vendor/bootstrap/less/modals.less";
@import "../../../../../vendor/bootstrap/less/tooltip.less";
@import "../../../../../vendor/bootstrap/less/popovers.less";
//@import "carousel.less";
// Utility classes
@import "../../../../../vendor/bootstrap/less/utilities.less";
@import "../../../../../vendor/bootstrap/less/responsive-utilities.less";
@toolbarBorderColor: #929292;
@toolbarBorderShadowColor: #FAFAFA;
@@ -10,35 +60,23 @@
@toolbarFontSize: 12px;
@controlBtnHoverTopColor: #6180C4;
@controlBtnHoverBottomColor: #8AACF1;
@iconSpriteCommonPath: "../img/glyphicons.png";
// Global overwrite
// -------------------------
.btn-mini {
font-weight: bold;
}
.btn-primary {
.buttonBackground(@controlBtnHoverBottomColor, @controlBtnHoverTopColor);
.input-xs {
.input-size(@input-height-small - 8px; @padding-small-vertical; @padding-small-horizontal; @font-size-small; @line-height-small; @border-radius-small);
}
.embed-body {
-moz-user-select: -moz-none;
-khtml-user-select: none;
-webkit-user-select: none;
-ms-user-select: none;
user-select: none;
-moz-user-select: -moz-none;
-khtml-user-select: none;
-webkit-user-select: none;
-ms-user-select: none;
user-select: none;
font-size: 12px;
font-size: @toolbarFontSize;
overflow: hidden;
}
// Fix popover
// -------------------------
.popover.top {
margin-top: -10px;
}
// Document Viewer
// -------------------------
.viewer {
@@ -65,6 +103,7 @@
position: fixed;
font-size: @toolbarFontSize;
min-width: 340px;
z-index: 100;
#gradient > .vertical(@toolbarTopColor, @toolbarBottomColor);
&.top {
@@ -73,9 +112,9 @@
width: 100%;
height: 32px;
-webkit-box-shadow: inset 0 -1px 0 @toolbarBorderColor, inset 0 1px 0 @toolbarBorderShadowColor;
-webkit-box-shadow: inset 0 -1px 0 @toolbarBorderColor, inset 0 1px 0 @toolbarBorderShadowColor;
-moz-box-shadow: inset 0 -1px 0 @toolbarBorderColor, inset 0 1px 0 @toolbarBorderShadowColor;
box-shadow: inset 0 -1px 0 @toolbarBorderColor, inset 0 1px 0 @toolbarBorderShadowColor;
box-shadow: inset 0 -1px 0 @toolbarBorderColor, inset 0 1px 0 @toolbarBorderShadowColor;
}
&.bottom {
@@ -84,22 +123,24 @@
width: 100%;
height: 30px;
-webkit-box-shadow: inset 0 1px 0 @toolbarBorderColor, inset 0 2px 0 @toolbarBorderShadowColor;
-webkit-box-shadow: inset 0 1px 0 @toolbarBorderColor, inset 0 2px 0 @toolbarBorderShadowColor;
-moz-box-shadow: inset 0 1px 0 @toolbarBorderColor, inset 0 2px 0 @toolbarBorderShadowColor;
box-shadow: inset 0 1px 0 @toolbarBorderColor, inset 0 2px 0 @toolbarBorderShadowColor;
box-shadow: inset 0 1px 0 @toolbarBorderColor, inset 0 2px 0 @toolbarBorderShadowColor;
}
ul {
position: absolute;
list-style-type: none;
margin: 0;
padding: 0;
li {
input {
height: 14px;
font-size: @toolbarFontSize;
margin: 4px 3px 5px;
padding: 4px 0;
display: inline-block;
width: 25px;
padding: 0;
height: 25px;
margin: 3px;
text-align: center;
}
@@ -148,13 +189,13 @@ a.brand-logo {
// -------------------------
[class^="control-icon-"],
[class*=" control-icon-"] {
display: inline-block;
width: 20px;
height: 20px;
vertical-align: text-top;
background-image: url("@{iconSpriteCommonPath}");
background-repeat: no-repeat;
margin-top: -2px;
display: inline-block;
width: 20px;
height: 20px;
vertical-align: text-top;
background-image: url("@{iconSpriteCommonPath}");
background-repeat: no-repeat;
margin-top: -2px;
}
[class^="overlay-icon-"],
@@ -177,7 +218,6 @@ a.brand-logo {
.overlay-icon-zoom-in { background-position: 0 -120px; }
.overlay-icon-zoom-out { background-position: -32px -120px; }
// Control buttons
// -------------------------
.control-btn {
@@ -191,7 +231,7 @@ a.brand-logo {
background-color: transparent;
background-image: none;
border: 1px solid transparent;
.border-radius(2px);
border-radius: 2px;
margin: 4px 5px 0 0;
i {
@@ -222,13 +262,14 @@ a.brand-logo {
// Focus state for keyboard and accessibility
&:focus {
.tab-focus();
outline: none;
}
// Active state
&.active,
&:active {
color: #ffffff;
outline: 0;
outline: none;
border: 1px solid darken(@controlBtnHoverTopColor, 5%);
#gradient > .vertical(@controlBtnHoverTopColor, @controlBtnHoverBottomColor);
text-shadow: 0 1px 0 darken(@toolbarBorderColor, 20%);
@@ -250,11 +291,20 @@ a.brand-logo {
left: 50%;
ul {
padding: 0;
list-style-type: none;
margin: 0 auto;
li {
display: inline-block;
&:first-child {
margin-right: 5px;
}
&:last-child {
margin-left: 5px;
}
}
}
@@ -271,23 +321,24 @@ a.brand-logo {
border: none;
padding: 0;
line-height: 0;
outline: none;
&:hover {
[class^="overlay-icon-"],
[class*=" overlay-icon-"] {
opacity: .6;
}
}
&.active,
&:active {
[class^="overlay-icon-"],
[class*=" overlay-icon-"] {
opacity: .8;
}
}
}
[class^="overlay-icon-"],
[class*=" overlay-icon-"] {
opacity: .6;
}
}
&.active,
&:active {
[class^="overlay-icon-"],
[class*=" overlay-icon-"] {
opacity: .8;
}
}
}
}
// Error mask
// -------------------------
@@ -326,10 +377,6 @@ a.brand-logo {
padding: 14px;
}
.btn {
.border-radius(2px);
}
&.hyperlink {
.popover-content {
padding: 5px 10px;
@@ -348,25 +395,30 @@ a.brand-logo {
width: 280px;
.share-link {
margin-bottom: 5px;
.caption {
margin-top: 3px;
margin-right: 8px;
float: left;
}
.uneditable-input {
input[readonly] {
display: inline-block;
font-size: 1em;
padding: 0 4px;
margin-right: 5px;
.border-radius(0);
cursor: auto;
-moz-user-select: text;
-khtml-user-select: text;
-webkit-user-select: text;
-ms-user-select: text;
user-select: text;
border-radius: 0;
cursor: text;
background-color: #fff;
-moz-user-select: text;
-khtml-user-select: text;
-webkit-user-select: text;
-ms-user-select: text;
user-select: text;
}
.input-medium {
.input-xs {
width: 130px;
}
@@ -377,6 +429,7 @@ a.brand-logo {
.share-buttons {
ul {
width: 244px;
height: 25px;
list-style-type: none;
margin: 5px 0 0;
@@ -390,17 +443,20 @@ a.brand-logo {
&.share-mail {
float: right;
padding-right: 1px;
margin: 0;
a {
padding: 2px 8px;
min-width: 64px;
}
i {
margin-right: 5px;
.glyphicon {
margin-right: 4px;
}
}
&.share-twitter {
max-width: 100px;
max-width: 93px;
}
}
}
@@ -419,75 +475,47 @@ a.brand-logo {
}
.caption {
margin-top: 2px;
margin-right: 8px;
}
input {
display: inline-block;
font-size: 1em;
padding: 0 4px;
.border-radius(0);
border-radius: 0;
margin: 0;
margin-top: -1px;
&.input-mini {
width: 40px;
&.input-xs {
width: 50px;
}
}
textarea {
width: 228px;
width: 238px;
resize: none;
cursor: auto;
font-size: 1em;
.border-radius(0);
border-radius: 0;
}
button {
float: right;
margin: 5px 0 15px;
margin: 10px 0 15px;
width: 86px;
}
}
}
// Modal dialog
// Modals
// -------------------------
.modal.error {
.modal {
.modal-header {
padding: 5px 15px;
}
.modal-footer {
text-align: center;
}
}
// Loader
// -------------------------
.cmd-loader-body {
z-index: 20001;
width: 300px;
padding: 16px;
margin: -71px 0 0 -166px;
border: none;
background-image: none;
background-color: #787C80;
opacity: 0.8;
-webkit-border-radius: 10px;
-moz-border-radius: 10px;
border-radius: 10px;
.cmd-loader-image {
background-image: url("../img/loading.gif");
background-repeat: no-repeat;
background-position: top center;
height: 74px;
width: 100%;
}
.cmd-loader-title {
font-size: 18px;
font-weight: lighter;
color: #FFF;
text-align: center;
margin: 16px 24px 0 24px;
border-top: none;
}
}

View File

@@ -1,86 +1,99 @@
/*
* (c) Copyright Ascensio System SIA 2010-2014
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
if (Common === undefined) {
var Common = {};
}
Common.Locale = new(function () {
var l10n = {};
var _createXMLHTTPObject = function () {
var xmlhttp;
try {
xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
} catch(e) {
try {
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
} catch(E) {
xmlhttp = false;
}
}
if (!xmlhttp && typeof XMLHttpRequest != "undefined") {
xmlhttp = new XMLHttpRequest();
}
return xmlhttp;
};
var _applyLocalization = function () {
try {
for (var prop in l10n) {
var p = prop.split(".");
if (p && p.length > 2) {
var obj = window;
for (var i = 0; i < p.length - 1; ++i) {
obj = obj[p[i]];
if (obj == undefined) {
break;
}
}
if (obj) {
obj.prototype[p[p.length - 1]] = l10n[prop];
}
}
}
} catch(e) {}
};
try {
var urlParams = Ext.urlDecode(location.search.substring(1));
var xhrObj = _createXMLHTTPObject();
if (xhrObj && urlParams && urlParams.lang) {
var lang = urlParams.lang.split("-")[0];
xhrObj.open("GET", "locale/" + lang + ".json", false);
xhrObj.send("");
l10n = eval("(" + xhrObj.responseText + ")");
_applyLocalization();
}
} catch(e) {}
return {
apply: _applyLocalization
};
/*
* (c) Copyright Ascensio System SIA 2010-2015
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
if (Common === undefined) {
var Common = {};
}
Common.Locale = new(function () {
var l10n = {};
var _createXMLHTTPObject = function () {
var xmlhttp;
try {
xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
} catch(e) {
try {
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
} catch(E) {
xmlhttp = false;
}
}
if (!xmlhttp && typeof XMLHttpRequest != "undefined") {
xmlhttp = new XMLHttpRequest();
}
return xmlhttp;
};
var _applyLocalization = function () {
try {
for (var prop in l10n) {
var p = prop.split(".");
if (p && p.length > 2) {
var obj = window;
for (var i = 0; i < p.length - 1; ++i) {
if (obj[p[i]] === undefined) {
obj[p[i]] = new Object();
}
obj = obj[p[i]];
}
if (obj) {
obj[p[p.length - 1]] = l10n[prop];
}
}
}
} catch(e) {}
};
var _get = function (prop, scope) {
var res = "";
if (scope && scope.name) {
res = l10n[scope.name + "." + prop];
}
return res || (scope ? eval(scope.name).prototype[prop] : "");
};
var _getUrlParameterByName = function (name) {
name = name.replace(/[\[]/, "\\[").replace(/[\]]/, "\\]");
var regex = new RegExp("[\\?&]" + name + "=([^&#]*)"),
results = regex.exec(location.search);
return results == null ? "" : decodeURIComponent(results[1].replace(/\+/g, " "));
};
try {
var langParam = _getUrlParameterByName("lang");
var xhrObj = _createXMLHTTPObject();
if (xhrObj && langParam) {
var lang = langParam.split("-")[0];
xhrObj.open("GET", "locale/" + lang + ".json", false);
xhrObj.send("");
l10n = eval("(" + xhrObj.responseText + ")");
}
} catch(e) {}
return {
apply: _applyLocalization,
get: _get
};
})();

View File

@@ -1,35 +1,36 @@
/*
* (c) Copyright Ascensio System SIA 2010-2014
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
Ext.define("Common.store.ChatMessages", {
extend: "Ext.data.Store",
model: "Common.model.ChatMessage"
/*
* (c) Copyright Ascensio System SIA 2010-2015
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
define(["backbone", "common/main/lib/model/ChatMessage"], function (Backbone) { ! Common.Collections && (Common.Collections = {});
Common.Collections.ChatMessages = Backbone.Collection.extend({
model: Common.Models.ChatMessage
});
});

View File

@@ -0,0 +1,66 @@
/*
* (c) Copyright Ascensio System SIA 2010-2015
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
if (Common === undefined) {
var Common = {};
}
Common.Collections = Common.Collections || {};
define(["underscore", "backbone", "common/main/lib/model/Comment"], function (_, Backbone) {
Common.Collections.Comments = Backbone.Collection.extend({
model: Common.Models.Comment,
clearEditing: function () {
this.each(function (comment) {
comment.set("editText", false);
comment.set("editTextInPopover", false);
comment.set("showReply", false);
comment.set("showReplyInPopover", false);
comment.set("hideAddReply", false);
});
},
getCommentsReplysCount: function (userid) {
var cnt = 0;
this.each(function (comment) {
if (comment.get("userid") == userid) {
cnt++;
}
var rpl = comment.get("replys");
if (rpl && rpl.length > 0) {
rpl.forEach(function (reply) {
if (reply.get("userid") == userid) {
cnt++;
}
});
}
});
return cnt;
}
});
});

View File

@@ -1,35 +1,40 @@
/*
* (c) Copyright Ascensio System SIA 2010-2014
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
Ext.define("Common.store.Fonts", {
extend: "Ext.data.Store",
model: "Common.model.Font"
/*
* (c) Copyright Ascensio System SIA 2010-2015
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
if (Common === undefined) {
var Common = {};
}
Common.Collections = Common.Collections || {};
define(["backbone", "common/main/lib/model/Font"], function (Backbone) {
Common.Collections.Fonts = Backbone.Collection.extend({
model: Common.Models.Font
});
});

View File

@@ -0,0 +1,49 @@
/*
* (c) Copyright Ascensio System SIA 2010-2015
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
define(["backbone", "common/main/lib/model/User"], function (Backbone) {
Common.Collections = Common.Collections || {};
Common.Collections.Users = Backbone.Collection.extend({
model: Common.Models.User,
getOnlineCount: function () {
var count = 0;
this.each(function (user) {
user.online && count++;
});
return count;
},
findUser: function (id) {
return this.find(function (model) {
return model.get("id") == id;
});
}
});
});

View File

@@ -0,0 +1,96 @@
/*
* (c) Copyright Ascensio System SIA 2010-2015
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
if (Common === undefined) {
var Common = {};
}
define(["backbone"], function (Backbone) {
Common.UI = _.extend(Common.UI || {},
{
Keys: {
BACKSPACE: 8,
TAB: 9,
RETURN: 13,
SHIFT: 16,
CTRL: 17,
ALT: 18,
ESC: 27,
LEFT: 37,
UP: 38,
RIGHT: 39,
DOWN: 40,
DELETE: 46,
HOME: 36,
END: 35,
SPACE: 32,
PAGEUP: 33,
PAGEDOWN: 34,
INSERT: 45,
NUM_PLUS: 107,
NUM_MINUS: 109,
F1: 112,
F2: 113,
F3: 114,
F4: 115,
F5: 116,
F6: 117,
F7: 118,
F8: 119,
F9: 120,
F10: 121,
F11: 122,
F12: 123,
EQUALITY: 187,
MINUS: 189
},
BaseView: Backbone.View.extend({
isSuspendEvents: false,
initialize: function (options) {
this.options = this.options ? _({}).extend(this.options, options) : options;
},
setVisible: function (visible) {
return this[visible ? "show" : "hide"]();
},
isVisible: function () {
return $(this.el).is(":visible");
},
suspendEvents: function () {
this.isSuspendEvents = true;
},
resumeEvents: function () {
this.isSuspendEvents = false;
}
}),
getId: function (prefix) {
return _.uniqueId(prefix || "asc-gen");
}
});
});

View File

@@ -0,0 +1,315 @@
/*
* (c) Copyright Ascensio System SIA 2010-2015
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
if (Common === undefined) {
var Common = {};
}
define(["common/main/lib/component/BaseView", "common/main/lib/component/ToggleManager"], function () {
Common.UI.Button = Common.UI.BaseView.extend({
options: {
id: null,
hint: false,
enableToggle: false,
allowDepress: true,
toggleGroup: null,
cls: "",
iconCls: "",
caption: "",
menu: null,
disabled: false,
pressed: false,
split: false
},
template: _.template(["<% if (menu == null) { %>", '<button type="button" class="btn <%= cls %>" id="<%= id %>" style="<%= style %>">', '<span class="caption"><%= caption %></span>', '<% if (iconCls != "") { %>', '<span class="btn-icon <%= iconCls %>">&nbsp;</span>', "<% } %>", "</button>", "<% } else if (split == false) {%>", '<div class="btn-group" id="<%= id %>" style="<%= style %>">', '<button type="button" class="btn dropdown-toggle <%= cls %>" data-toggle="dropdown">', '<span class="caption"><%= caption %></span>', '<% if (iconCls != "") { %>', '<span class="btn-icon <%= iconCls %>">&nbsp;</span>', "<% } %>", '<span class="caret"></span>', "</button>", "</div>", "<% } else { %>", '<div class="btn-group split" id="<%= id %>" style="<%= style %>">', '<button type="button" class="btn <%= cls %>">', '<span class="caption"><%= caption %></span>', '<% if (iconCls != "") { %>', '<span class="btn-icon <%= iconCls %>">&nbsp;</span>', "<% } %>", "</button>", '<button type="button" class="btn <%= cls %> dropdown-toggle" data-toggle="dropdown">', '<span class="caret"></span>', '<span class="sr-only"></span>', "</button>", "</div>", "<% } %>"].join("")),
initialize: function (options) {
Common.UI.BaseView.prototype.initialize.call(this, options);
var me = this;
me.id = me.options.id || Common.UI.getId();
me.hint = me.options.hint;
me.enableToggle = me.options.enableToggle;
me.allowDepress = me.options.allowDepress;
me.cls = me.options.cls;
me.iconCls = me.options.iconCls;
me.menu = me.options.menu;
me.split = me.options.split;
me.toggleGroup = me.options.toggleGroup;
me.disabled = me.options.disabled;
me.pressed = me.options.pressed;
me.caption = me.options.caption;
me.template = me.options.template || me.template;
me.style = me.options.style;
me.rendered = false;
if (me.options.el) {
me.render();
}
},
render: function (parentEl) {
var me = this;
me.trigger("render:before", me);
me.cmpEl = $(me.el);
if (parentEl) {
me.setElement(parentEl, false);
if (!me.rendered) {
me.cmpEl = $(this.template({
id: me.id,
cls: me.cls,
iconCls: me.iconCls,
menu: me.menu,
split: me.split,
disabled: me.disabled,
pressed: me.pressed,
caption: me.caption,
style: me.style
}));
if (me.menu && _.isFunction(me.menu.render)) {
me.menu.render(me.cmpEl);
}
parentEl.html(me.cmpEl);
}
}
if (!me.rendered) {
var el = me.cmpEl,
isGroup = el.hasClass("btn-group"),
isSplit = el.hasClass("split");
if (me.options.hint) {
var modalParents = me.cmpEl.closest(".asc-window");
me.cmpEl.attr("data-toggle", "tooltip");
me.cmpEl.tooltip({
title: me.options.hint,
placement: me.options.hintAnchor || "cursor"
});
if (modalParents.length > 0) {
me.cmpEl.data("bs.tooltip").tip().css("z-index", parseInt(modalParents.css("z-index")) + 10);
}
}
if (_.isString(me.toggleGroup)) {
me.enableToggle = true;
}
var buttonHandler = function (e) {
if (!me.disabled && e.which == 1) {
me.doToggle();
if (me.options.hint) {
var tip = me.cmpEl.data("bs.tooltip");
if (tip) {
if (tip.dontShow === undefined) {
tip.dontShow = true;
}
tip.hide();
}
}
me.trigger("click", me, e);
}
};
var doSplitSelect = function (select, e) {
if (!select) {
var isUnderMouse = false;
_.each($("button", el), function (el) {
if ($(el).is(":hover")) {
isUnderMouse = true;
return false;
}
});
if (!isUnderMouse) {
el.removeClass("over");
$("button", el).removeClass("over");
}
}
if (!select && (me.enableToggle && me.allowDepress && me.pressed)) {
return;
}
if (select && !isSplit && (me.enableToggle && me.allowDepress && !me.pressed)) {
e.preventDefault();
return;
}
$("button:first", el).toggleClass("active", select);
$("[data-toggle^=dropdown]", el).toggleClass("active", select);
el.toggleClass("active", select);
};
var menuHandler = function (e) {
if (!me.disabled && e.which == 1) {
if (isSplit) {
if (me.options.hint) {
var tip = me.cmpEl.data("bs.tooltip");
if (tip) {
if (tip.dontShow === undefined) {
tip.dontShow = true;
}
tip.hide();
}
}
var isOpen = el.hasClass("open");
doSplitSelect(!isOpen, e);
}
}
};
var doSetActiveState = function (e, state) {
if (isSplit) {
doSplitSelect(state, e);
} else {
el.toggleClass("active", state);
$("button", el).toggleClass("active", state);
}
};
var onMouseDown = function (e) {
doSplitSelect(true, e);
$(document).on("mouseup", onMouseUp);
};
var onMouseUp = function (e) {
doSplitSelect(false, e);
$(document).off("mouseup", onMouseUp);
};
var onAfterHideMenu = function (e) {
me.cmpEl.find(".dropdown-toggle").blur();
};
if (isGroup) {
if (isSplit) {
$("[data-toggle^=dropdown]", el).on("mousedown", _.bind(menuHandler, this));
$("button", el).on("mousedown", _.bind(onMouseDown, this));
}
el.on("hide.bs.dropdown", _.bind(doSplitSelect, me, false));
el.on("show.bs.dropdown", _.bind(doSplitSelect, me, true));
el.on("hidden.bs.dropdown", _.bind(onAfterHideMenu, me));
$("button:first", el).on("click", buttonHandler);
} else {
el.on("click", buttonHandler);
}
el.on("button.internal.active", _.bind(doSetActiveState, me));
el.on("mouseover", function (e) {
if (!me.disabled) {
me.cmpEl.addClass("over");
me.trigger("mouseover", me, e);
}
});
el.on("mouseout", function (e) {
if (!me.disabled) {
me.cmpEl.removeClass("over");
me.trigger("mouseout", me, e);
}
});
Common.UI.ToggleManager.register(me);
}
me.rendered = true;
if (me.pressed) {
me.toggle(me.pressed, true);
}
if (me.disabled) {
me.setDisabled(me.disabled);
}
me.trigger("render:after", me);
return this;
},
doToggle: function () {
var me = this;
if (me.enableToggle && (me.allowDepress !== false || !me.pressed)) {
me.toggle();
}
},
toggle: function (toggle, suppressEvent) {
var state = toggle === undefined ? !this.pressed : !!toggle;
this.pressed = state;
if (this.cmpEl) {
this.cmpEl.trigger("button.internal.active", [state]);
}
if (!suppressEvent) {
this.trigger("toggle", this, state);
}
},
isActive: function () {
if (this.enableToggle) {
return this.pressed;
}
return this.cmpEl.hasClass("active");
},
setDisabled: function (disabled) {
if (this.rendered) {
var el = this.cmpEl,
isGroup = el.hasClass("btn-group");
disabled = (disabled === true);
if (disabled !== el.hasClass("disabled")) {
var decorateBtn = function (button) {
button.toggleClass("disabled", disabled);
(disabled) ? button.attr({
disabled: disabled
}) : button.removeAttr("disabled");
};
decorateBtn(el);
isGroup && decorateBtn(el.children("button"));
}
if (disabled) {
var tip = this.cmpEl.data("bs.tooltip");
if (tip) {
tip.hide();
}
}
}
this.disabled = disabled;
},
isDisabled: function () {
return this.disabled;
},
setIconCls: function (cls) {
var btnIconEl = $(this.el).find("span.btn-icon"),
oldCls = this.iconCls;
this.iconCls = cls;
btnIconEl.removeClass(oldCls);
btnIconEl.addClass(cls || "");
},
setVisible: function (visible) {
this.cmpEl.toggleClass("hidden", !visible);
},
updateHint: function (hint) {
this.options.hint = hint;
var cmpEl = this.cmpEl,
modalParents = cmpEl.closest(".asc-window");
cmpEl.attr("data-toggle", "tooltip");
cmpEl.tooltip("destroy").tooltip({
title: hint,
placement: this.options.hintAnchor || "cursor"
});
if (modalParents.length > 0) {
cmpEl.data("bs.tooltip").tip().css("z-index", parseInt(modalParents.css("z-index")) + 10);
}
},
setCaption: function (caption) {
if (this.caption != caption) {
this.caption = caption;
if (this.rendered) {
var captionNode = this.cmpEl.find("button:first > .caption").andSelf().filter("button > .caption");
if (captionNode.length > 0) {
captionNode.text(caption);
} else {
this.cmpEl.find("button:first").andSelf().filter("button").text(caption);
}
}
}
}
});
});

View File

@@ -0,0 +1,116 @@
/*
* (c) Copyright Ascensio System SIA 2010-2015
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
if (Common === undefined) {
var Common = {};
}
define(["common/main/lib/component/BaseView", "underscore"], function (base, _) {
Common.UI.CheckBox = Common.UI.BaseView.extend({
options: {
labelText: ""
},
disabled: false,
rendered: false,
indeterminate: false,
checked: false,
value: "unchecked",
template: _.template('<label class="checkbox-indeterminate"><input type="button"><%= labelText %></label>'),
initialize: function (options) {
Common.UI.BaseView.prototype.initialize.call(this, options);
var me = this,
el = $(this.el);
this.render();
if (this.options.disabled) {
this.setDisabled(this.options.disabled);
}
if (this.options.value !== undefined) {
this.setValue(this.options.value, true);
}
this.$chk.on("click", _.bind(this.onItemCheck, this));
},
render: function () {
var el = $(this.el);
el.html(this.template({
labelText: this.options.labelText
}));
this.$chk = el.find("input[type=button]");
this.$label = el.find("label");
this.rendered = true;
return this;
},
setDisabled: function (disabled) {
if (disabled !== this.disabled) {
this.$label.toggleClass("disabled", disabled);
(disabled) ? this.$chk.attr({
disabled: disabled
}) : this.$chk.removeAttr("disabled");
}
this.disabled = disabled;
},
isDisabled: function () {
return this.disabled;
},
onItemCheck: function (e) {
if (!this.disabled) {
if (this.indeterminate) {
this.indeterminate = false;
this.setValue(false);
} else {
this.setValue(!this.checked);
}
}
},
setRawValue: function (value) {
this.checked = (value === true || value === "true" || value === "1" || value === 1 || value === "checked");
this.indeterminate = (value === "indeterminate");
this.$chk.toggleClass("checked", this.checked);
this.$chk.toggleClass("indeterminate", this.indeterminate);
this.value = this.indeterminate ? "indeterminate" : (this.checked ? "checked" : "unchecked");
},
setValue: function (value, suspendchange) {
if (this.rendered) {
this.lastValue = this.value;
this.setRawValue(value);
if (suspendchange !== true && this.lastValue !== value) {
this.trigger("change", this, this.value, this.lastValue);
}
} else {
this.options.value = value;
}
},
getValue: function () {
return this.value;
},
isChecked: function () {
return this.checked;
}
});
});

View File

@@ -0,0 +1,60 @@
/*
* (c) Copyright Ascensio System SIA 2010-2015
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
if (Common === undefined) {
var Common = {};
}
define(["common/main/lib/component/Button"], function () {
Common.UI.ColorButton = Common.UI.Button.extend({
options: {
hint: false,
enableToggle: false
},
template: _.template(['<div class="btn-group" id="<%= id %>">', '<button type="button" class="btn btn-color dropdown-toggle <%= cls %>" data-toggle="dropdown" style="<%= style %>">', "<span>&nbsp;</span>", "</button>", "</div>"].join("")),
setColor: function (color) {
var border_color, clr, span = $(this.cmpEl).find("button span");
this.color = color;
if (color == "transparent") {
border_color = "#BEBEBE";
clr = color;
span.addClass("transparent");
} else {
border_color = "transparent";
clr = (typeof(color) == "object") ? "#" + color.color : "#" + color;
span.removeClass("transparent");
}
span.css({
"background-color": clr,
"border-color": border_color
});
}
});
});

View File

@@ -0,0 +1,99 @@
/*
* (c) Copyright Ascensio System SIA 2010-2015
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
if (Common === undefined) {
var Common = {};
}
define(["common/main/lib/component/BaseView"], function () {
Common.UI.ColorPalette = Common.UI.BaseView.extend({
options: {
allowReselect: true,
cls: "",
style: ""
},
template: _.template(['<div class="palette-color">', "<% _.each(colors, function(color, index) { %>", '<span class="color-item" data-color="<%= color %>" style="background-color: #<%= color %>;"></span>', "<% }) %>", "</div>"].join("")),
initialize: function (options) {
Common.UI.BaseView.prototype.initialize.call(this, options);
var me = this;
this.id = me.options.id;
this.cls = me.options.cls;
this.style = me.options.style;
this.colors = me.options.colors || [];
this.value = me.options.value;
if (me.options.el) {
me.render();
}
},
render: function (parentEl) {
var me = this;
if (!me.rendered) {
this.cmpEl = $(this.template({
id: this.id,
cls: this.cls,
style: this.style,
colors: this.colors
}));
if (parentEl) {
this.setElement(parentEl, false);
parentEl.html(this.cmpEl);
} else {
$(this.el).html(this.cmpEl);
}
} else {
this.cmpEl = $(this.el);
}
if (!me.rendered) {
var el = this.cmpEl;
el.on("click", "span.color-item", _.bind(this.itemClick, this));
}
me.rendered = true;
return this;
},
itemClick: function (e) {
var item = $(e.target);
this.select(item.attr("data-color"));
},
select: function (color, suppressEvent) {
if (this.value != color) {
var me = this;
$("span.color-item", this.cmpEl).removeClass("selected");
this.value = color;
if (color && /#?[a-fA-F0-9]{6}/.test(color)) {
color = /#?([a-fA-F0-9]{6})/.exec(color)[1].toUpperCase();
$("span[data-color=" + color + "]", this.cmpEl).addClass("selected");
if (!suppressEvent) {
me.trigger("select", me, this.value);
}
}
}
}
});
});

View File

@@ -0,0 +1,220 @@
/*
* (c) Copyright Ascensio System SIA 2010-2015
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
if (Common === undefined) {
var Common = {};
}
define(["common/main/lib/component/ComboBox"], function () {
Common.UI.BordersModel = Backbone.Model.extend({
defaults: function () {
return {
value: null,
displayValue: null,
pxValue: null,
id: Common.UI.getId(),
offsety: undefined
};
}
});
Common.UI.BordersStore = Backbone.Collection.extend({
model: Common.UI.BordersModel
});
Common.UI.ComboBorderSize = Common.UI.ComboBox.extend(_.extend({
template: _.template(['<div class="input-group combobox combo-border-size input-group-nr <%= cls %>" id="<%= id %>" style="<%= style %>">', '<div class="form-control" style="<%= style %>"></div>', '<div style="display: table-cell;"></div>', '<button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown"><span class="caret"></span></button>', '<ul class="dropdown-menu <%= menuCls %>" style="<%= menuStyle %>" role="menu">', "<% _.each(items, function(item) { %>", '<li id="<%= item.id %>" data-value="<%= item.value %>"><a tabindex="-1" type="menuitem">', "<span><%= item.displayValue %></span>", "<% if (item.offsety!==undefined) { %>", '<img src="data:image/gif;base64,R0lGODlhAQABAID/AMDAwAAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==" align="right" style="background-position: 0 -<%= item.offsety %>px;">', "<% } %>", "</a></li>", "<% }); %>", "</ul>", "</div>"].join("")),
initialize: function (options) {
Common.UI.ComboBox.prototype.initialize.call(this, _.extend({
editable: false,
store: new Common.UI.BordersStore(),
data: [{
displayValue: this.txtNoBorders,
value: 0,
pxValue: 0
},
{
displayValue: "0.5 pt",
value: 0.5,
pxValue: 0.5,
offsety: 0
},
{
displayValue: "1 pt",
value: 1,
pxValue: 1,
offsety: 20
},
{
displayValue: "1.5 pt",
value: 1.5,
pxValue: 2,
offsety: 40
},
{
displayValue: "2.25 pt",
value: 2.25,
pxValue: 3,
offsety: 60
},
{
displayValue: "3 pt",
value: 3,
pxValue: 4,
offsety: 80
},
{
displayValue: "4.5 pt",
value: 4.5,
pxValue: 5,
offsety: 100
},
{
displayValue: "6 pt",
value: 6,
pxValue: 6,
offsety: 120
}],
menuStyle: "min-width: 150px;"
},
options));
},
render: function (parentEl) {
Common.UI.ComboBox.prototype.render.call(this, parentEl);
return this;
},
itemClicked: function (e) {
var el = $(e.currentTarget).parent();
this._selectedItem = this.store.findWhere({
id: el.attr("id")
});
if (this._selectedItem) {
$(".selected", $(this.el)).removeClass("selected");
el.addClass("selected");
this.updateFormControl(this._selectedItem);
this.trigger("selected", this, _.extend({},
this._selectedItem.toJSON()), e);
e.preventDefault();
}
},
updateFormControl: function (record) {
var formcontrol = $(this.el).find(".form-control");
if (record.get("value") > 0) {
formcontrol[0].innerHTML = "";
formcontrol.removeClass("text").addClass("image");
formcontrol.css("background-position", "0 -" + record.get("offsety") + "px");
} else {
formcontrol[0].innerHTML = this.txtNoBorders;
formcontrol.removeClass("image").addClass("text");
}
},
setValue: function (value) {
this._selectedItem = (value === null || value === undefined) ? undefined : _.find(this.store.models, function (item) {
if (value < item.attributes.value + 0.01 && value > item.attributes.value - 0.01) {
return true;
}
});
$(".selected", $(this.el)).removeClass("selected");
if (this._selectedItem) {
this.updateFormControl(this._selectedItem);
$("#" + this._selectedItem.get("id"), $(this.el)).addClass("selected");
} else {
var formcontrol = $(this.el).find(".form-control");
formcontrol[0].innerHTML = "";
formcontrol.removeClass("image").addClass("text");
}
},
txtNoBorders: "No Borders"
},
Common.UI.ComboBorderSize || {}));
Common.UI.ComboBorderSizeEditable = Common.UI.ComboBox.extend(_.extend({
template: _.template(['<span class="input-group combobox combo-border-size-editable input-group-nr <%= cls %>" id="<%= id %>" style="<%= style %>">', '<input type="text" class="form-control">', '<button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown"><span class="caret"></span></button>', '<ul class="dropdown-menu <%= menuCls %>" style="<%= menuStyle %>" role="menu">', "<% _.each(items, function(item) { %>", '<li id="<%= item.id %>" data-value="<%= item.value %>"><a tabindex="-1" type="menuitem">', "<span><%= item.displayValue %></span>", "<% if (item.offsety!==undefined) { %>", '<img src="data:image/gif;base64,R0lGODlhAQABAID/AMDAwAAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==" align="right" style="background-position: 0 -<%= item.offsety %>px;">', "<% } %>", "</a></li>", "<% }); %>", "</ul>", "</span>"].join("")),
initialize: function (options) {
this.txtNoBorders = options.txtNoBorders || this.txtNoBorders;
Common.UI.ComboBox.prototype.initialize.call(this, _.extend({
editable: true,
store: new Common.UI.BordersStore(),
data: [{
displayValue: this.txtNoBorders,
value: 0,
pxValue: 0
},
{
displayValue: "0.5 pt",
value: 0.5,
pxValue: 0.5,
offsety: 0
},
{
displayValue: "1 pt",
value: 1,
pxValue: 1,
offsety: 20
},
{
displayValue: "1.5 pt",
value: 1.5,
pxValue: 2,
offsety: 40
},
{
displayValue: "2.25 pt",
value: 2.25,
pxValue: 3,
offsety: 60
},
{
displayValue: "3 pt",
value: 3,
pxValue: 4,
offsety: 80
},
{
displayValue: "4.5 pt",
value: 4.5,
pxValue: 5,
offsety: 100
},
{
displayValue: "6 pt",
value: 6,
pxValue: 6,
offsety: 120
}],
menuStyle: "min-width: 150px;"
},
options));
},
render: function (parentEl) {
Common.UI.ComboBox.prototype.render.call(this, parentEl);
return this;
},
txtNoBorders: "No Borders"
},
Common.UI.ComboBorderSizeEditable || {}));
});

View File

@@ -0,0 +1,429 @@
/*
* (c) Copyright Ascensio System SIA 2010-2015
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
if (Common === undefined) {
var Common = {};
}
define(["common/main/lib/component/BaseView", "common/main/lib/component/Scroller"], function () {
Common.UI.ComboBoxModel = Backbone.Model.extend({
defaults: function () {
return {
id: Common.UI.getId(),
value: null,
displayValue: null
};
}
});
Common.UI.ComboBoxStore = Backbone.Collection.extend({
model: Common.UI.ComboBoxModel
});
Common.UI.ComboBox = Common.UI.BaseView.extend((function () {
return {
options: {
id: null,
cls: "",
style: "",
hint: false,
editable: true,
disabled: false,
menuCls: "",
menuStyle: "",
displayField: "displayValue",
valueField: "value"
},
template: _.template(['<span class="input-group combobox <%= cls %>" id="<%= id %>" style="<%= style %>">', '<input type="text" class="form-control">', '<button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown"><span class="caret"></span></button>', '<ul class="dropdown-menu <%= menuCls %>" style="<%= menuStyle %>" role="menu">', "<% _.each(items, function(item) { %>", '<li id="<%= item.id %>" data-value="<%= item.value %>"><a tabindex="-1" type="menuitem"><%= scope.getDisplayValue(item) %></a></li>', "<% }); %>", "</ul>", "</span>"].join("")),
initialize: function (options) {
Common.UI.BaseView.prototype.initialize.call(this, options);
var me = this,
el = $(this.el);
this.id = me.options.id || Common.UI.getId();
this.cls = me.options.cls;
this.style = me.options.style;
this.menuCls = me.options.menuCls;
this.menuStyle = me.options.menuStyle;
this.template = me.options.template || me.template;
this.hint = me.options.hint;
this.editable = me.options.editable;
this.disabled = me.options.disabled;
this.store = me.options.store || new Common.UI.ComboBoxStore();
this.displayField = me.options.displayField;
this.valueField = me.options.valueField;
me.rendered = me.options.rendered || false;
this.lastValue = null;
me.store.add(me.options.data);
if (me.options.el) {
me.render();
}
},
render: function (parentEl) {
var me = this;
if (!me.rendered) {
this.cmpEl = $(this.template({
id: this.id,
cls: this.cls,
style: this.style,
menuCls: this.menuCls,
menuStyle: this.menuStyle,
items: this.store.toJSON(),
scope: me
}));
if (parentEl) {
this.setElement(parentEl, false);
parentEl.html(this.cmpEl);
} else {
$(this.el).html(this.cmpEl);
}
} else {
this.cmpEl = $(this.el);
}
if (!me.rendered) {
var el = this.cmpEl;
this._input = el.find("input");
this._button = el.find(".btn");
el.on("click", "a", _.bind(this.itemClicked, this));
el.on("mousedown", "a", _.bind(this.itemMouseDown, this));
if (this.editable) {
el.on("change", "input", _.bind(this.onInputChanged, this));
el.on("keydown", "input", _.bind(this.onInputKeyDown, this));
el.on("click", ".form-control", _.bind(this.onEditableInputClick, this));
} else {
el.on("click", ".form-control", _.bind(this.onInputClick, this));
this._input.attr("readonly", "readonly");
this._input.attr("data-can-copy", false);
}
if (me.options.hint) {
el.attr("data-toggle", "tooltip");
el.tooltip({
title: me.options.hint,
placement: me.options.hintAnchor || "cursor"
});
}
el.on("show.bs.dropdown", _.bind(me.onBeforeShowMenu, me));
el.on("shown.bs.dropdown", _.bind(me.onAfterShowMenu, me));
el.on("hide.bs.dropdown", _.bind(me.onBeforeHideMenu, me));
el.on("hidden.bs.dropdown", _.bind(me.onAfterHideMenu, me));
el.on("keydown.after.bs.dropdown", _.bind(me.onAfterKeydownMenu, me));
Common.NotificationCenter.on("menumanager:hideall", _.bind(me.closeMenu, me));
this.scroller = new Common.UI.Scroller({
el: $(".dropdown-menu", me.cmpEl),
minScrollbarLength: 40,
scrollYMarginOffset: 30,
includePadding: true
});
this.setDefaultSelection();
this.listenTo(this.store, "reset", this.onResetItems);
}
me.rendered = true;
if (me.disabled) {
me.setDisabled(me.disabled);
}
return this;
},
setData: function (data) {
this.store.reset([]);
this.store.add(data);
this.setRawValue("");
this.onResetItems();
},
openMenu: function (delay) {
var me = this;
_.delay(function () {
me.cmpEl.addClass("open");
},
delay || 0);
},
closeMenu: function () {
this.cmpEl.removeClass("open");
},
isMenuOpen: function () {
return this.cmpEl.hasClass("open");
},
onBeforeShowMenu: function (e) {
this.trigger("show:before", this, e);
if (this.options.hint) {
var tip = this.cmpEl.data("bs.tooltip");
if (tip) {
if (tip.dontShow === undefined) {
tip.dontShow = true;
}
tip.hide();
}
}
},
onAfterShowMenu: function (e) {
var $list = $(this.el).find("ul"),
$selected = $list.find("> li.selected");
if ($selected.length) {
var itemTop = $selected.position().top,
itemHeight = $selected.height(),
listHeight = $list.height();
if (itemTop < 0 || itemTop + itemHeight > listHeight) {
$list.scrollTop($list.scrollTop() + itemTop + itemHeight - (listHeight / 2));
}
}
if (this.scroller) {
this.scroller.update();
}
this.trigger("show:after", this, e);
},
onBeforeHideMenu: function (e) {
this.trigger("hide:before", this, e);
if (Common.UI.Scroller.isMouseCapture()) {
e.preventDefault();
}
},
onAfterHideMenu: function (e) {
this.cmpEl.find(".dropdown-toggle").blur();
this.trigger("hide:after", this, e);
},
onAfterKeydownMenu: function (e) {
if (e.keyCode == Common.UI.Keys.RETURN) {
$(e.target).click();
var me = this;
if (this.rendered) {
if (Common.Utils.isIE) {
this._input.trigger("change", {
onkeydown: true
});
} else {
this._input.blur();
}
}
return false;
} else {
if (e.keyCode == Common.UI.Keys.ESC && this.isMenuOpen()) {
this.closeMenu();
this.onAfterHideMenu(e);
return false;
}
}
},
onInputKeyDown: function (e) {
var me = this;
if (e.keyCode == Common.UI.Keys.ESC) {
this.closeMenu();
this.onAfterHideMenu(e);
} else {
if (e.keyCode == Common.UI.Keys.UP || e.keyCode == Common.UI.Keys.DOWN) {
if (!this.isMenuOpen()) {
this.openMenu();
}
_.delay(function () {
me._skipInputChange = true;
me.cmpEl.find("ul li:first a").focus();
},
10);
} else {
me._skipInputChange = false;
}
}
},
onInputChanged: function (e, extra) {
if (extra && extra.synthetic) {
return;
}
if (this._skipInputChange) {
this._skipInputChange = false;
return;
}
var val = $(e.target).val(),
record = {};
if (this.lastValue === val) {
if (extra && extra.onkeydown) {
this.trigger("combo:blur", this, e);
}
return;
}
record[this.valueField] = val;
this.trigger("changed:before", this, record, e);
if (e.isDefaultPrevented()) {
return;
}
var obj;
this._selectedItem = this.store.findWhere((obj = {},
obj[this.displayField] = val, obj));
if (this._selectedItem) {
record = this._selectedItem.toJSON();
$(".selected", $(this.el)).removeClass("selected");
$("#" + this._selectedItem.get("id"), $(this.el)).addClass("selected");
}
this.trigger("changed:after", this, record, e);
},
onInputClick: function (e) {
if (this._button) {
this._button.dropdown("toggle");
}
e.preventDefault();
e.stopPropagation();
},
onEditableInputClick: function (e) {
if (this.options.hint) {
var tip = this.cmpEl.data("bs.tooltip");
if (tip) {
if (tip.dontShow === undefined) {
tip.dontShow = true;
}
tip.hide();
}
}
if (this.isMenuOpen() && e.which == 1) {
e.stopPropagation();
}
},
setDefaultSelection: function () {
if (!this.rendered) {
return;
}
var val = this._input.val(),
obj;
if (val) {
this._selectedItem = this.store.findWhere((obj = {},
obj[this.displayField] = val, obj));
if (this._selectedItem) {
$(".selected", $(this.el)).removeClass("selected");
$("#" + this._selectedItem.get("id"), $(this.el)).addClass("selected");
}
}
},
setDisabled: function (disabled) {
this.disabled = disabled;
if (!this.rendered) {
return;
}
disabled ? this._input.attr("disabled", true) : this._input.removeAttr("disabled");
this.cmpEl.toggleClass("disabled", disabled);
this._button.toggleClass("disabled", disabled);
},
isDisabled: function () {
return this.disabled;
},
setRawValue: function (value) {
if (this.rendered) {
this._input.val(value).trigger("change", {
synthetic: true
});
this.lastValue = (value !== null && value !== undefined) ? value.toString() : value;
}
},
getRawValue: function () {
return this.rendered ? this._input.val() : null;
},
setValue: function (value) {
if (!this.rendered) {
return;
}
var obj;
this._selectedItem = this.store.findWhere((obj = {},
obj[this.valueField] = value, obj));
$(".selected", $(this.el)).removeClass("selected");
if (this._selectedItem) {
this.setRawValue(this._selectedItem.get(this.displayField));
$("#" + this._selectedItem.get("id"), $(this.el)).addClass("selected");
} else {
this.setRawValue(value);
}
},
getValue: function () {
if (!this.rendered) {
return null;
}
if (this._selectedItem && !_.isUndefined(this._selectedItem.get(this.valueField))) {
return this._selectedItem.get(this.valueField);
}
return this._input.val();
},
getDisplayValue: function (record) {
return Common.Utils.String.htmlEncode(record[this.displayField]);
},
getSelectedRecord: function () {
if (!this.rendered) {
return null;
}
if (this._selectedItem && !_.isUndefined(this._selectedItem.get(this.valueField))) {
return _.extend({},
this._selectedItem.toJSON());
}
return null;
},
selectRecord: function (record) {
if (!this.rendered || !record) {
return;
}
this._selectedItem = record;
$(".selected", $(this.el)).removeClass("selected");
this.setRawValue(this._selectedItem.get(this.displayField));
$("#" + this._selectedItem.get("id"), $(this.el)).addClass("selected");
},
itemClicked: function (e) {
var el = $(e.target).closest("li");
this._selectedItem = this.store.findWhere({
id: el.attr("id")
});
if (this._selectedItem) {
this.lastValue = this._selectedItem.get(this.displayField);
this._input.val(this.lastValue).trigger("change", {
synthetic: true
});
$(".selected", $(this.el)).removeClass("selected");
el.addClass("selected");
this.trigger("selected", this, _.extend({},
this._selectedItem.toJSON()), e);
e.preventDefault();
}
this._isMouseDownMenu = false;
},
itemMouseDown: function (e) {
if (e.which != 1) {
e.preventDefault();
e.stopPropagation();
return false;
}
this._isMouseDownMenu = true;
},
onResetItems: function () {
$(this.el).find("ul").html(_.template(["<% _.each(items, function(item) { %>", '<li id="<%= item.id %>" data-value="<%= item.value %>"><a tabindex="-1" type="menuitem"><%= scope.getDisplayValue(item) %></a></li>', "<% }); %>"].join(""), {
items: this.store.toJSON(),
scope: this
}));
if (!_.isUndefined(this.scroller)) {
this.scroller.destroy();
delete this.scroller;
}
this.scroller = new Common.UI.Scroller({
el: $(".dropdown-menu", this.cmpEl),
minScrollbarLength: 40,
scrollYMarginOffset: 30,
includePadding: true
});
}
};
})());
});

View File

@@ -0,0 +1,274 @@
/*
* (c) Copyright Ascensio System SIA 2010-2015
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
if (Common === undefined) {
var Common = {};
}
var FONT_TYPE_RECENT = 4;
define(["common/main/lib/component/ComboBox"], function () {
Common.UI.ComboBoxFonts = Common.UI.ComboBox.extend((function () {
var iconWidth = 302,
iconHeight = FONT_THUMBNAIL_HEIGHT || 26,
isRetina = window.devicePixelRatio > 1,
thumbCanvas = document.createElement("canvas"),
thumbContext = thumbCanvas.getContext("2d"),
thumbPath = "../../../sdk/Common/Images/fonts_thumbnail.png",
thumbPath2x = "../../../sdk/Common/Images/fonts_thumbnail@2x.png";
thumbCanvas.height = isRetina ? iconHeight * 2 : iconHeight;
thumbCanvas.width = isRetina ? iconWidth * 2 : iconWidth;
return {
template: _.template(['<div class="input-group combobox fonts <%= cls %>" id="<%= id %>" style="<%= style %>">', '<input type="text" class="form-control">', '<div style="display: table-cell;"></div>', '<button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown"><span class="caret"></span></button>', '<ul class="dropdown-menu <%= menuCls %>" style="<%= menuStyle %>" role="menu">', '<li class="divider">', "<% _.each(items, function(item) { %>", '<li id="<%= item.id %>">', '<a class="font-item" tabindex="-1" type="menuitem" style="display: block;">', '<img src="<%= scope.getImageUri(item) %>" width="<%= scope.getImageWidth() %>" height="<%= scope.getImageHeight() %>" style="vertical-align: middle;margin: 0 0 0 -10px;">', "</a>", "</li>", "<% }); %>", "</ul>", "</div>"].join("")),
initialize: function (options) {
Common.UI.ComboBox.prototype.initialize.call(this, _.extend(options, {
displayField: "name"
}));
this.recent = _.isNumber(options.recent) ? options.recent : 3;
Common.NotificationCenter.on("fonts:change", _.bind(this.onApiChangeFont, this));
Common.NotificationCenter.on("fonts:load", _.bind(this.fillFonts, this));
},
render: function (parentEl) {
var oldRawValue = null;
if (!_.isUndefined(this._input)) {
oldRawValue = this._input.val();
}
Common.UI.ComboBox.prototype.render.call(this, parentEl);
this.setRawValue(oldRawValue);
this._input.on("keyup", _.bind(this.onInputKeyUp, this));
this._input.on("keydown", _.bind(this.onInputKeyDown, this));
this.scroller.update({
alwaysVisibleY: true
});
return this;
},
onInputKeyUp: function (e) {
if (e.keyCode != Common.UI.Keys.RETURN) {
this.selectCandidate();
}
},
onInputKeyDown: function (e) {
var me = this;
if (e.keyCode == Common.UI.Keys.ESC) {
this.closeMenu();
this.onAfterHideMenu(e);
} else {
if (e.keyCode != Common.UI.Keys.RETURN && e.keyCode != Common.UI.Keys.CTRL && e.keyCode != Common.UI.Keys.SHIFT && e.keyCode != Common.UI.Keys.ALT) {
if (!this.isMenuOpen()) {
this.openMenu();
}
if (e.keyCode == Common.UI.Keys.UP || e.keyCode == Common.UI.Keys.DOWN) {
_.delay(function () {
var selected = me.cmpEl.find("ul li.selected a");
if (selected.length <= 0) {
selected = me.cmpEl.find("ul li:first a");
}
me._skipInputChange = true;
selected.focus();
},
10);
} else {
me._skipInputChange = false;
}
}
}
},
onInputChanged: function (e, extra) {
if (extra && extra.synthetic) {
return;
}
if (this._skipInputChange) {
this._skipInputChange = false;
return;
}
if (this._isMouseDownMenu) {
this._isMouseDownMenu = false;
return;
}
var val = $(e.target).val(),
record = {};
if (this.lastValue === val) {
if (extra && extra.onkeydown) {
this.trigger("combo:blur", this, e);
}
return;
}
record[this.valueField] = val;
this.trigger("changed:before", this, record, e);
if (e.isDefaultPrevented()) {
return;
}
if (this._selectedItem) {
record[this.valueField] = this._selectedItem.get(this.displayField);
this.setRawValue(record[this.valueField]);
this.trigger("selected", this, _.extend({},
this._selectedItem.toJSON()), e);
this.closeMenu();
}
this.trigger("changed:after", this, record, e);
},
getImageUri: function (opts) {
if (opts.cloneid) {
var img = $(this.el).find("ul > li#" + opts.cloneid + " img");
return img != null ? img[0].src : undefined;
}
if (isRetina) {
thumbContext.clearRect(0, 0, iconWidth * 2, iconHeight * 2);
thumbContext.drawImage(this.spriteThumbs, 0, -FONT_THUMBNAIL_HEIGHT * 2 * opts.imgidx);
} else {
thumbContext.clearRect(0, 0, iconWidth, iconHeight);
thumbContext.drawImage(this.spriteThumbs, 0, -FONT_THUMBNAIL_HEIGHT * opts.imgidx);
}
return thumbCanvas.toDataURL();
},
getImageWidth: function () {
return iconWidth;
},
getImageHeight: function () {
return iconHeight;
},
loadSprite: function (callback) {
if (callback) {
this.spriteThumbs = new Image();
this.spriteThumbs.onload = callback;
this.spriteThumbs.src = (window.devicePixelRatio > 1) ? thumbPath2x : thumbPath;
}
},
fillFonts: function (store, select) {
var me = this;
this.loadSprite(function () {
me.store.set(store.toJSON());
me.rendered = false;
me.render($(me.el));
me._fontsArray = me.store.toJSON();
if (me.recent > 0) {
me.store.on("add", me.onInsertItem, me);
me.store.on("remove", me.onRemoveItem, me);
}
});
},
onApiChangeFont: function (font) {
var name = (_.isFunction(font.get_Name) ? font.get_Name() : font.asc_getName());
if (this.getRawValue() !== name) {
var record = this.store.findWhere({
name: name
});
$(".selected", $(this.el)).removeClass("selected");
if (record) {
this.setRawValue(record.get(this.displayField));
var itemNode = $("#" + record.get("id"), $(this.el)),
menuNode = $("ul.dropdown-menu", this.cmpEl);
if (itemNode && menuNode) {
itemNode.addClass("selected");
if (this.recent <= 0) {
menuNode.scrollTop(itemNode.offset().top - menuNode.offset().top);
}
}
} else {
this.setRawValue(name);
}
}
},
itemClicked: function (e) {
var el = $(e.target).closest("li");
var record = this.store.findWhere({
id: el.attr("id")
});
if (record.get("type") != FONT_TYPE_RECENT && !this.store.findWhere({
name: record.get("name"),
type: FONT_TYPE_RECENT
})) {
var fonts = this.store.where({
type: FONT_TYPE_RECENT
});
if (! (fonts.length < this.recent)) {
this.store.remove(fonts[0]);
}
var new_record = record.clone();
new_record.set({
"type": FONT_TYPE_RECENT,
"id": Common.UI.getId(),
cloneid: record.id
});
this.store.add(new_record);
}
Common.UI.ComboBox.prototype.itemClicked.apply(this, arguments);
},
onInsertItem: function (item) {
$(this.el).find("ul").prepend(_.template(['<li id="<%= item.id %>">', '<a class="font-item" tabindex="-1" type="menuitem" style="display: block;">', '<img src="<%= scope.getImageUri(item) %>" width="<%= scope.getImageWidth() %>" height="<%= scope.getImageHeight() %>" style="vertical-align: middle;margin: 0 0 0 -10px;">', "</a>", "</li>"].join(""), {
item: item.attributes,
scope: this
}));
},
onRemoveItem: function (item, store, opts) {
$(this.el).find("ul > li#" + item.id).remove();
},
onAfterShowMenu: function (e) {
if (this.recent > 0) {
if (this.scroller && !this._scrollerIsInited) {
this.scroller.update();
this._scrollerIsInited = true;
}
$(this.el).find("ul").scrollTop(0);
this.trigger("show:after", this, e);
} else {
Common.UI.ComboBox.prototype.onAfterShowMenu.apply(this, arguments);
}
},
selectCandidate: function () {
var me = this,
inputVal = this._input.val().toLowerCase();
if (!this._fontsArray) {
this._fontsArray = this.store.toJSON();
}
var font = _.find(this._fontsArray, function (font) {
return (font[me.displayField].toLowerCase().indexOf(inputVal) == 0);
});
if (font) {
this._selectedItem = this.store.findWhere({
id: font.id
});
}
$(".selected", $(this.el)).removeClass("selected");
if (this._selectedItem) {
var itemNode = $("#" + this._selectedItem.get("id"), $(this.el)),
menuEl = $("ul[role=menu]", $(this.el));
if (itemNode.length > 0 && menuEl.length > 0) {
itemNode.addClass("selected");
var itemTop = itemNode.position().top,
menuTop = menuEl.scrollTop();
if (itemTop != 0) {
menuEl.scrollTop(menuTop + itemTop);
}
}
}
}
};
})());
});

View File

@@ -1,322 +1,332 @@
/*
* (c) Copyright Ascensio System SIA 2010-2014
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
Ext.define("Common.component.ComboDataView", {
extend: "Ext.container.Container",
requires: (["Ext.data.Model", "Ext.data.Store", "Ext.view.View", "Ext.XTemplate"]),
alias: "widget.commoncombodataview",
padding: 4,
itemWidth: 80,
itemHeight: 40,
menuHeight: 100,
menuMaxHeight: 500,
minWidth: 150,
emptyComboText: "No styles",
handleGlobalResize: false,
constructor: function (config) {
if (!config || !config.viewData || !config.itemWidth || !config.itemHeight) {
throw Error("ComboDataView creation failed: required parameters are missing.");
}
this.initConfig(config);
this.callParent(arguments);
return this;
},
initComponent: function () {
var me = this,
cfg = Ext.apply({},
me.initialConfig);
var borderSize = 0;
var paddingLeftDV = 0;
var paddingRightDV = 0;
var paddingLeftItem = 0;
var paddingRightItem = 0;
var marginRightItem = 0;
var initCSSRules = true;
var borderRule = Ext.util.CSS.getRule(".storage-combodataview");
if (borderRule) {
borderSize = parseInt(borderRule.style.borderWidth);
if (isNaN(borderSize)) {
borderSize = 0;
}
}
Ext.define("DataModel", {
extend: "Ext.data.Model",
fields: [{
name: "imageUrl"
},
{
name: "title"
},
{
name: "data"
},
{
name: "uid"
}]
});
var fieldStore = Ext.create("Ext.data.Store", {
storeId: Ext.id(),
model: (Ext.isDefined(cfg.store)) ? cfg.store.model : "DataModel",
data: cfg.viewData
});
var dataTpl = (Ext.isDefined(cfg.dataTpl)) ? cfg.dataTpl : Ext.create("Ext.XTemplate", '<tpl for=".">', '<div class="thumb-wrap">', '<img src="{imageUrl}" width="' + me.itemWidth + '" height="' + me.itemHeight + '"/>', '<tpl if="title">', '<span class="title">{title}</span>', "</tpl>", "</div>", "</tpl>");
this.dataMenu = Ext.widget("cmdmenudataviewpicker", {
width: me.width,
height: me.menuHeight,
cls: "x-dataview-combo-menu",
viewData: cfg.viewData,
dataTpl: cfg.dataTpl,
store: cfg.store,
itemWidth: me.itemWidth,
itemHeight: me.itemHeight,
constrain: false,
pickerpadding: (me.padding - 1),
listeners: {
hide: function (ct, eOpts) {
me.fireEvent("menuhide", me, ct);
}
}
});
var fieldDataView = Ext.widget("dataview", {
store: fieldStore,
tpl: dataTpl,
singleSelect: true,
trackOver: true,
style: "overflow:auto",
overItemCls: "x-item-over",
itemSelector: "div.thumb-wrap",
emptyText: '<div class="emptyText">' + me.emptyComboText + "</div>",
deferEmptyText: false,
cls: "x-view-context",
listeners: {
itemclick: function (view, record, item, index, event, eOpts) {
if (cfg.repeatedselect && view.getSelectionModel().getLastSelected() !== null && view.getSelectionModel().getLastSelected().id == record.id) {
me.fireEvent("select", me, record);
}
},
afterrender: Ext.bind(function (ct, eOpts) {
if (fieldStore.getCount() > 0) {
ct.select(fieldStore.getAt(0));
this.dataMenu.picker.selectByIndex(0);
}
},
this),
beforecontainerclick: function (view, event, eOpts) {
return false;
},
itemdblclick: function (view, record, item, index, event, eOpts) {
me.fireEvent("releasecapture", me);
}
}
});
var fieldContainer = Ext.widget("container", {
flex: 1,
height: me.height - 2 * (me.padding + borderSize),
items: [fieldDataView]
});
var btnMenu = Ext.widget("button", {
cls: "x-btn-combodataview",
height: me.height - 2 * (me.padding + borderSize),
handler: Ext.bind(function (btn, e) {
if (initCSSRules) {
me.getDataViewCSSRules();
}
var maxViewCount = Math.floor((me.getEl().getWidth()) / (me.itemWidth + paddingLeftItem + paddingRightItem));
var countRec = me.dataMenu.picker.store.getCount();
var menuRowsCount = Math.ceil(countRec / maxViewCount);
if (menuRowsCount > 1) {
var height = menuRowsCount * (me.itemHeight + 2 * marginRightItem + paddingLeftItem + paddingRightItem) + 6,
maxHeight = Math.min(me.menuMaxHeight, Ext.Element.getViewportHeight() - this.getPosition()[1] - 6);
if (height > maxHeight) {
height = maxHeight;
}
me.dataMenu.show();
me.dataMenu.setSize(me.getEl().getWidth(), height);
me.dataMenu.showBy(fieldContainer, "tl-tl", [-me.padding + borderSize, -me.padding + borderSize]);
}
},
this)
});
this.fillComboView = function (record, forceSelect, forceFill) {
if (Ext.isDefined(record)) {
var store = me.dataMenu.picker.store;
if (store) {
if (forceFill || fieldStore.find("uid", record.data.uid) < 0) {
if (initCSSRules) {
me.getDataViewCSSRules();
}
fieldStore.removeAll();
var indexRec = store.indexOf(record),
countRec = store.getCount(),
maxViewCount = Math.floor((fieldContainer.getWidth()) / (me.itemWidth + paddingLeftItem + paddingRightItem)),
newStyles = [];
if (fieldContainer.getHeight() / me.itemHeight > 2) {
maxViewCount *= Math.floor(fieldContainer.getHeight() / me.itemHeight);
}
if (indexRec < 0) {
return;
}
indexRec = Math.floor(indexRec / maxViewCount) * maxViewCount;
for (var index = indexRec, viewCount = 0; index < countRec && viewCount < maxViewCount; index++, viewCount++) {
var rec = store.getAt(index);
var obj = {};
for (var i = 0; i < rec.fields.length; i++) {
obj[rec.fields.items[i].name] = rec.data[rec.fields.items[i].name];
}
newStyles.push(obj);
}
fieldStore.add(newStyles);
}
if (forceSelect) {
var selectIndex = fieldStore.find("uid", record.data.uid);
if (selectIndex > -1) {
fieldDataView.select(fieldStore.getAt(selectIndex), false, true);
}
}
}
}
};
this.selectByIndex = function (index) {
if (index < 0) {
fieldDataView.getSelectionModel().deselectAll(false);
}
me.dataMenu.picker.selectByIndex(index, false);
};
var onMenuSelect = function (picker, record) {
me.fillComboView(record, true);
if (record) {
me.fireEvent("select", me, record);
}
};
var onSelectionChange = function (view, selections, eOpts) {
var record = selections[0];
if (record) {
me.dataMenu.picker.selectByIndex(me.dataMenu.picker.store.findExact("uid", record.get("uid")), false);
me.fireEvent("select", me, record);
}
};
var onPickerSelectionChange = function (picker, view, selections) {
me.fillComboView(selections[0], true);
};
var doResizeCmp = function (width, height) {
if (me.dataMenu) {
me.dataMenu.setWidth(width);
me.dataMenu.hide();
var picker = me.dataMenu.picker;
if (picker) {
var record = picker.getSelectedRec();
me.fillComboView(record || picker.store.getAt(0), !!record, true);
}
}
};
if (me.handleGlobalResize) {
me.on("afterrender", function (cmp) {
var innerBoxEl = cmp.getEl().down(".x-box-inner");
if (innerBoxEl) {
innerBoxEl.addCls("combodataview-auto-width");
}
},
this);
Ext.EventManager.onWindowResize(function () {
var cmpEl = me.getEl();
if (cmpEl) {
me.doLayout();
doResizeCmp(cmpEl.getWidth());
}
},
this);
} else {
me.on("resize", function (o, adjw, adjh) {
doResizeCmp(adjw, adjh);
},
this);
}
this.dataMenu.addListener("select", onMenuSelect, me);
this.dataMenu.picker.addListener("selectionchange", onPickerSelectionChange, me);
fieldDataView.addListener("selectionchange", onSelectionChange, me);
me.addEvents("select", "menuhide", "releasecapture");
me.addListener("afterrender", function () {
Ext.util.CSS.refreshCache();
var menuDataViewItemRule = Ext.util.CSS.getRule(".x-dataview-combo-menu .storage-data-view .thumb-wrap");
if (menuDataViewItemRule) {
paddingLeftItem = parseInt(menuDataViewItemRule.style.paddingLeft);
if (isNaN(paddingLeftItem)) {
paddingLeftItem = 0;
}
paddingRightItem = parseInt(menuDataViewItemRule.style.paddingRight);
if (isNaN(paddingRightItem)) {
paddingRightItem = 0;
}
marginRightItem = parseInt(menuDataViewItemRule.style.marginRight);
if (isNaN(marginRightItem)) {
marginRightItem = 0;
}
initCSSRules = false;
}
Ext.defer(function () {
me.dataMenu.showAt([-10000, -10000]);
me.fireEvent("releasecapture", me);
},
100);
},
this);
me.getDataViewCSSRules = function () {
if (me.dataMenu.picker.getEl()) {
var thumb = me.dataMenu.picker.getEl().down(".thumb-wrap");
if (thumb) {
paddingLeftItem = parseInt(thumb.getStyle("paddingLeft"));
if (isNaN(paddingLeftItem)) {
paddingLeftItem = 0;
}
paddingRightItem = parseInt(thumb.getStyle("paddingRight"));
if (isNaN(paddingRightItem)) {
paddingRightItem = 0;
}
marginRightItem = parseInt(thumb.getStyle("marginRight"));
if (isNaN(marginRightItem)) {
marginRightItem = 0;
}
initCSSRules = false;
}
}
};
Ext.apply(me, {
layout: {
type: "hbox",
align: "stretch"
},
cls: "storage-combodataview",
items: [fieldContainer, btnMenu]
},
cfg);
this.callParent(arguments);
}
/*
* (c) Copyright Ascensio System SIA 2010-2015
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
if (Common === undefined) {
var Common = {};
}
define(["common/main/lib/component/BaseView", "common/main/lib/component/DataView"], function () {
Common.UI.ComboDataView = Common.UI.BaseView.extend({
options: {
id: null,
cls: "",
style: "",
hint: false,
itemWidth: 80,
itemHeight: 40,
menuMaxHeight: 300,
enableKeyEvents: false,
beforeOpenHandler: null
},
template: _.template(['<div id="<%= id %>" class="combo-dataview <%= cls %>" style="<%= style %>">', '<div class="view"></div> ', '<div class="button"></div> ', "</div>"].join("")),
initialize: function (options) {
Common.UI.BaseView.prototype.initialize.call(this, options);
this.id = this.options.id || Common.UI.getId();
this.cls = this.options.cls;
this.style = this.options.style;
this.hint = this.options.hint;
this.store = this.options.store || new Common.UI.DataViewStore();
this.itemWidth = this.options.itemWidth;
this.itemHeight = this.options.itemHeight;
this.menuMaxHeight = this.options.menuMaxHeight;
this.beforeOpenHandler = this.options.beforeOpenHandler;
this.rootWidth = 0;
this.rootHeight = 0;
this.rendered = false;
this.fieldPicker = new Common.UI.DataView({
cls: "field-picker",
allowScrollbar: false,
itemTemplate: _.template(['<div class="style" id="<%= id %>">', '<img src="<%= imageUrl %>" width="' + this.itemWidth + '" height="' + this.itemHeight + '"/>', '<% if (typeof title !== "undefined") {%>', '<span class="title"><%= title %></span>', "<% } %>", "</div>"].join(""))
});
this.openButton = new Common.UI.Button({
cls: "open-menu",
menu: new Common.UI.Menu({
menuAlign: "tl-bl",
offset: [0, 3],
items: [{
template: _.template('<div class="menu-picker-container"></div>')
}]
})
});
this.menuPicker = new Common.UI.DataView({
cls: "menu-picker",
parentMenu: this.openButton.menu,
restoreHeight: this.menuMaxHeight,
style: "max-height: " + this.menuMaxHeight + "px;",
enableKeyEvents: this.options.enableKeyEvents,
itemTemplate: _.template(['<div class="style" id="<%= id %>">', '<img src="<%= imageUrl %>" width="' + this.itemWidth + '" height="' + this.itemHeight + '"/>', '<% if (typeof title !== "undefined") {%>', '<span class="title"><%= title %></span>', "<% } %>", "</div>"].join(""))
});
setInterval(_.bind(this.checkSize, this), 500);
if (this.options.el) {
this.render();
}
},
render: function (parentEl) {
if (!this.rendered) {
var me = this;
me.trigger("render:before", me);
me.cmpEl = $(me.el);
var templateEl = me.template({
id: me.id,
cls: me.cls,
style: me.style
});
if (parentEl) {
me.setElement(parentEl, false);
me.cmpEl = $(templateEl);
parentEl.html(me.cmpEl);
} else {
me.cmpEl.html(templateEl);
}
me.rootWidth = me.cmpEl.width();
me.rootHeight = me.cmpEl.height();
me.fieldPicker.render($(".view", me.cmpEl));
me.openButton.render($(".button", me.cmpEl));
me.menuPicker.render($(".menu-picker-container", me.cmpEl));
if (me.openButton.menu.cmpEl) {
if (me.openButton.menu.cmpEl) {
me.openButton.menu.menuAlignEl = me.cmpEl;
me.openButton.menu.cmpEl.css("min-width", me.itemWidth);
me.openButton.menu.on("show:before", _.bind(me.onBeforeShowMenu, me));
me.openButton.menu.on("show:after", _.bind(me.onAfterShowMenu, me));
me.openButton.cmpEl.on("hide.bs.dropdown", _.bind(me.onBeforeHideMenu, me));
me.openButton.cmpEl.on("hidden.bs.dropdown", _.bind(me.onAfterHideMenu, me));
}
}
if (me.options.hint) {
me.cmpEl.attr("data-toggle", "tooltip");
me.cmpEl.tooltip({
title: me.options.hint,
placement: me.options.hintAnchor || "cursor"
});
}
me.fieldPicker.on("item:select", _.bind(me.onFieldPickerSelect, me));
me.menuPicker.on("item:select", _.bind(me.onMenuPickerSelect, me));
me.fieldPicker.on("item:click", _.bind(me.onFieldPickerClick, me));
me.menuPicker.on("item:click", _.bind(me.onMenuPickerClick, me));
me.onResize();
me.rendered = true;
me.trigger("render:after", me);
}
return this;
},
checkSize: function () {
if (this.cmpEl) {
var width = this.cmpEl.width(),
height = this.cmpEl.height();
if (this.rootWidth != width || this.rootHeight != height) {
this.rootWidth = width;
this.rootHeight = height;
this.onResize();
}
}
},
onResize: function () {
if (this.openButton) {
var button = $("button", this.openButton.cmpEl);
button && button.css({
width: $(".button", this.cmpEl).width(),
height: $(".button", this.cmpEl).height()
});
this.openButton.menu.hide();
var picker = this.menuPicker;
if (picker) {
var record = picker.getSelectedRec();
if (record) {
record = record[0];
this.fillComboView(record || picker.store.at(0), !!record, true);
}
}
}
if (!this.isSuspendEvents) {
this.trigger("resize", this);
}
},
onBeforeShowMenu: function (e) {
var me = this;
if (_.isFunction(me.beforeOpenHandler)) {
me.beforeOpenHandler(me, e);
} else {
if (me.openButton.menu.cmpEl) {
var itemMargin = 0;
try {
var itemEl = $($(".dropdown-menu .dataview.inner .style", me.cmpEl)[0]);
itemMargin = itemEl ? (parseInt(itemEl.css("margin-left")) + parseInt(itemEl.css("margin-right"))) : 0;
} catch(e) {}
me.openButton.menu.cmpEl.css({
"width": Math.round((me.cmpEl.width() + (itemMargin * me.fieldPicker.store.length)) / me.itemWidth - 0.2) * (me.itemWidth + itemMargin),
"min-height": this.cmpEl.height()
});
}
}
if (me.options.hint) {
var tip = me.cmpEl.data("bs.tooltip");
if (tip) {
if (tip.dontShow === undefined) {
tip.dontShow = true;
}
tip.hide();
}
}
},
onBeforeHideMenu: function (e) {
this.trigger("hide:before", this, e);
if (Common.UI.Scroller.isMouseCapture()) {
e.preventDefault();
}
},
onAfterShowMenu: function (e) {
var me = this;
if (me.menuPicker.scroller) {
me.menuPicker.scroller.update({
includePadding: true,
suppressScrollX: true,
alwaysVisibleY: true
});
}
},
onAfterHideMenu: function (e) {
this.trigger("hide:after", this, e);
},
onFieldPickerSelect: function (picker, item, record) {},
onMenuPickerSelect: function (picker, item, record) {
if (this.disabled) {
return;
}
this.fillComboView(record, false);
if (record && !this.isSuspendEvents) {
this.trigger("select", this, record);
}
},
onFieldPickerClick: function (dataView, itemView, record) {
if (this.disabled) {
return;
}
if (!this.isSuspendEvents) {
this.trigger("click", this, record);
}
if (this.options.hint) {
var tip = this.cmpEl.data("bs.tooltip");
if (tip) {
if (tip.dontShow === undefined) {
tip.dontShow = true;
}
tip.hide();
}
}
},
onMenuPickerClick: function (dataView, itemView, record) {
if (this.disabled) {
return;
}
if (!this.isSuspendEvents) {
this.trigger("click", this, record);
}
},
setDisabled: function (disabled) {
this.disabled = disabled;
if (!this.rendered) {
return;
}
this.cmpEl.toggleClass("disabled", disabled);
$("button", this.openButton.cmpEl).toggleClass("disabled", disabled);
this.fieldPicker.setDisabled(disabled);
},
isDisabled: function () {
return this.disabled;
},
fillComboView: function (record, forceSelect, forceFill) {
if (!_.isUndefined(record) && record instanceof Backbone.Model) {
var me = this,
store = me.menuPicker.store,
fieldPickerEl = $(me.fieldPicker.el);
if (store) {
if (forceFill || !me.fieldPicker.store.findWhere({
"id": record.get("id")
})) {
if (me.itemMarginLeft === undefined) {
var div = $($(this.menuPicker.el).find(".inner > div:not(.grouped-data):not(.ps-scrollbar-x-rail):not(.ps-scrollbar-y-rail)")[0]);
if (div.length > 0) {
me.itemMarginLeft = parseInt(div.css("margin-left"));
me.itemMarginRight = parseInt(div.css("margin-right"));
me.itemPaddingLeft = parseInt(div.css("padding-left"));
me.itemPaddingRight = parseInt(div.css("padding-right"));
me.itemBorderLeft = parseInt(div.css("border-left-width"));
me.itemBorderRight = parseInt(div.css("border-right-width"));
}
}
me.fieldPicker.store.reset([]);
var indexRec = store.indexOf(record),
countRec = store.length,
maxViewCount = Math.floor((fieldPickerEl.width()) / (me.itemWidth + (me.itemMarginLeft || 0) + (me.itemMarginRight || 0) + (me.itemPaddingLeft || 0) + (me.itemPaddingRight || 0) + (me.itemBorderLeft || 0) + (me.itemBorderRight || 0))),
newStyles = [];
if (fieldPickerEl.height() / me.itemHeight > 2) {
maxViewCount *= Math.floor(fieldPickerEl.height() / me.itemHeight);
}
if (indexRec < 0) {
return;
}
indexRec = Math.floor(indexRec / maxViewCount) * maxViewCount;
for (var index = indexRec, viewCount = 0; index < countRec && viewCount < maxViewCount; index++, viewCount++) {
newStyles.push(store.at(index));
}
me.fieldPicker.store.add(newStyles);
}
if (forceSelect) {
var selectRecord = me.fieldPicker.store.findWhere({
"id": record.get("id")
});
if (selectRecord) {
me.suspendEvents();
me.fieldPicker.selectRecord(selectRecord, true);
me.resumeEvents();
}
}
}
}
},
selectByIndex: function (index) {
if (index < 0) {
this.fieldPicker.deselectAll();
}
this.menuPicker.selectByIndex(index);
},
setItemWidth: function (width) {
if (this.itemWidth != width) {
this.itemWidth = window.devicePixelRatio > 1 ? width / 2 : width;
}
},
setItemHeight: function (height) {
if (this.itemHeight != height) {
this.itemHeight = window.devicePixelRatio > 1 ? height / 2 : height;
}
}
});
});

View File

@@ -0,0 +1,506 @@
/*
* (c) Copyright Ascensio System SIA 2010-2015
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
if (Common === undefined) {
var Common = {};
}
define(["common/main/lib/component/BaseView", "common/main/lib/component/Scroller"], function () {
Common.UI.DataViewGroupModel = Backbone.Model.extend({
defaults: function () {
return {
id: Common.UI.getId(),
caption: ""
};
}
});
Common.UI.DataViewGroupStore = Backbone.Collection.extend({
model: Common.UI.DataViewGroupModel
});
Common.UI.DataViewModel = Backbone.Model.extend({
defaults: function () {
return {
id: Common.UI.getId(),
selected: false,
allowSelected: true,
value: null
};
}
});
Common.UI.DataViewStore = Backbone.Collection.extend({
model: Common.UI.DataViewModel
});
Common.UI.DataViewItem = Common.UI.BaseView.extend({
options: {},
template: _.template(['<div id="<%= id %>"><%= value %></div>'].join("")),
initialize: function (options) {
Common.UI.BaseView.prototype.initialize.call(this, options);
var me = this;
me.template = me.options.template || me.template;
me.listenTo(me.model, "change", me.render);
me.listenTo(me.model, "change:selected", me.onSelectChange);
me.listenTo(me.model, "remove", me.remove);
},
render: function () {
if (_.isUndefined(this.model.id)) {
return this;
}
var el = $(this.el);
el.html(this.template(this.model.toJSON()));
el.toggleClass("selected", this.model.get("selected") && this.model.get("allowSelected"));
el.off("click").on("click", _.bind(this.onClick, this));
el.off("dblclick").on("dblclick", _.bind(this.onDblClick, this));
if (!_.isUndefined(this.model.get("cls"))) {
el.addClass(this.model.get("cls"));
}
this.trigger("change", this, this.model);
return this;
},
remove: function () {
this.stopListening(this.model);
this.trigger("remove", this, this.model);
Common.UI.BaseView.prototype.remove.call(this);
},
onClick: function (e) {
this.trigger("click", this, this.model, e);
},
onDblClick: function (e) {
this.trigger("dblclick", this, this.model, e);
},
onSelectChange: function (model, selected) {
this.trigger("select", this, model, selected);
}
});
Common.UI.DataView = Common.UI.BaseView.extend({
options: {
multiSelect: false,
handleSelect: true,
enableKeyEvents: true,
keyMoveDirection: "both",
restoreHeight: 0,
emptyText: "",
listenStoreEvents: true,
allowScrollbar: true
},
template: _.template(['<div class="dataview inner" style="<%= style %>">', "<% _.each(groups, function(group) { %>", '<div class="grouped-data" id="<%= group.id %>">', '<div class="group-description">', "<span><b><%= group.caption %></b></span>", "</div>", '<div class="group-items-container">', "</div>", "</div>", "<% }); %>", "</div>"].join("")),
initialize: function (options) {
Common.UI.BaseView.prototype.initialize.call(this, options);
var me = this;
me.template = me.options.template || me.template;
me.store = me.options.store || new Common.UI.DataViewStore();
me.groups = me.options.groups || null;
me.itemTemplate = me.options.itemTemplate || null;
me.multiSelect = me.options.multiSelect;
me.handleSelect = me.options.handleSelect;
me.parentMenu = me.options.parentMenu;
me.enableKeyEvents = me.options.enableKeyEvents;
me.style = me.options.style || "";
me.emptyText = me.options.emptyText || "";
me.listenStoreEvents = (me.options.listenStoreEvents !== undefined) ? me.options.listenStoreEvents : true;
me.allowScrollbar = (me.options.allowScrollbar !== undefined) ? me.options.allowScrollbar : true;
me.rendered = false;
me.dataViewItems = [];
if (me.options.keyMoveDirection == "vertical") {
me.moveKeys = [Common.UI.Keys.UP, Common.UI.Keys.DOWN];
} else {
if (me.options.keyMoveDirection == "horizontal") {
me.moveKeys = [Common.UI.Keys.LEFT, Common.UI.Keys.RIGHT];
} else {
me.moveKeys = [Common.UI.Keys.UP, Common.UI.Keys.DOWN, Common.UI.Keys.LEFT, Common.UI.Keys.RIGHT];
}
}
if (me.options.el) {
me.render();
}
},
render: function (parentEl) {
var me = this;
this.trigger("render:before", this);
this.cmpEl = $(this.el);
if (parentEl) {
this.setElement(parentEl, false);
this.cmpEl = $(this.template({
groups: me.groups ? me.groups.toJSON() : null,
style: me.style
}));
parentEl.html(this.cmpEl);
} else {
this.cmpEl.html(this.template({
groups: me.groups ? me.groups.toJSON() : null,
style: me.style
}));
}
if (!this.rendered) {
if (this.listenStoreEvents) {
this.listenTo(this.store, "add", this.onAddItem);
this.listenTo(this.store, "reset", this.onResetItems);
}
this.onResetItems();
if (this.parentMenu) {
this.cmpEl.closest("li").css("height", "100%");
this.cmpEl.css("height", "100%");
this.parentMenu.on("show:after", _.bind(this.alignPosition, this));
}
if (this.enableKeyEvents && this.parentMenu && this.handleSelect) {
this.parentMenu.on("show:after", function () {
me.showLastSelected();
Common.NotificationCenter.trigger("dataview:focus");
});
this.parentMenu.on("hide:after", function () {
Common.NotificationCenter.trigger("dataview:blur");
});
}
}
if (_.isUndefined(this.scroller) && this.allowScrollbar) {
this.scroller = new Common.UI.Scroller({
el: $(this.el).find(".inner").andSelf().filter(".inner"),
useKeyboard: this.enableKeyEvents && !this.handleSelect,
minScrollbarLength: 40
});
}
var modalParents = this.cmpEl.closest(".asc-window");
if (modalParents.length > 0) {
this.tipZIndex = parseInt(modalParents.css("z-index")) + 10;
}
this.rendered = true;
this.cmpEl.on("click", function (e) {
if (/dataview/.test(e.target.className)) {
return false;
}
});
this.trigger("render:after", this);
return this;
},
setStore: function (store) {
if (store) {
this.stopListening(this.store);
this.store = store;
if (this.listenStoreEvents) {
this.listenTo(this.store, "add", this.onAddItem);
this.listenTo(this.store, "reset", this.onResetItems);
}
}
},
selectRecord: function (record, suspendEvents) {
if (!this.handleSelect) {
return;
}
if (suspendEvents) {
this.suspendEvents();
}
if (!this.multiSelect) {
_.each(this.store.where({
selected: true
}), function (rec) {
rec.set({
selected: false
});
});
if (record) {
record.set({
selected: true
});
}
} else {
if (record) {
record.set({
selected: !record.get("selected")
});
}
}
if (suspendEvents) {
this.resumeEvents();
}
},
selectByIndex: function (index, suspendEvents) {
if (this.store.length > 0 && index > -1 && index < this.store.length) {
this.selectRecord(this.store.at(index), suspendEvents);
}
},
deselectAll: function (suspendEvents) {
if (suspendEvents) {
this.suspendEvents();
}
_.each(this.store.where({
selected: true
}), function (record) {
record.set({
selected: false
});
});
if (suspendEvents) {
this.resumeEvents();
}
},
getSelectedRec: function () {
if (this.multiSelect) {
var items = [];
_.each(this.store.where({
selected: true
}), function (rec) {
items.push(rec);
});
return items;
}
return this.store.where({
selected: true
});
},
onAddItem: function (record, index, opts) {
var view = new Common.UI.DataViewItem({
template: this.itemTemplate,
model: record
});
if (view) {
var innerEl = $(this.el).find(".inner").andSelf().filter(".inner");
if (this.groups && this.groups.length > 0) {
var group = this.groups.findWhere({
id: record.get("group")
});
if (group) {
innerEl = innerEl.find("#" + group.id + " " + ".group-items-container");
}
}
if (innerEl) {
if (opts && opts.at == 0) {
innerEl.prepend(view.render().el);
} else {
innerEl.append(view.render().el);
}
innerEl.find(".empty-text").remove();
this.dataViewItems.push(view);
if (record.get("tip")) {
var view_el = $(view.el);
view_el.attr("data-toggle", "tooltip");
view_el.tooltip({
title: record.get("tip"),
placement: "cursor",
zIndex: this.tipZIndex
});
}
this.listenTo(view, "change", this.onChangeItem);
this.listenTo(view, "remove", this.onRemoveItem);
this.listenTo(view, "click", this.onClickItem);
this.listenTo(view, "dblclick", this.onDblClickItem);
this.listenTo(view, "select", this.onSelectItem);
if (!this.isSuspendEvents) {
this.trigger("item:add", this, view, record);
}
}
}
},
onResetItems: function () {
$(this.el).html(this.template({
groups: this.groups ? this.groups.toJSON() : null,
style: this.style
}));
if (!_.isUndefined(this.scroller)) {
this.scroller.destroy();
delete this.scroller;
}
if (this.store.length < 1 && this.emptyText.length > 0) {
$(this.el).find(".inner").andSelf().filter(".inner").append('<table class="empty-text"><tr><td>' + this.emptyText + "</td></tr></table>");
}
_.each(this.dataViewItems, function (item) {
this.stopListening(item);
item.stopListening(item.model);
},
this);
this.dataViewItems = [];
this.store.each(this.onAddItem, this);
if (this.allowScrollbar) {
this.scroller = new Common.UI.Scroller({
el: $(this.el).find(".inner").andSelf().filter(".inner"),
useKeyboard: this.enableKeyEvents && !this.handleSelect,
minScrollbarLength: 40
});
}
this.attachKeyEvents();
},
onChangeItem: function (view, record) {
if (!this.isSuspendEvents) {
this.trigger("item:change", this, view, record);
}
},
onRemoveItem: function (view, record) {
this.stopListening(view);
view.stopListening();
if (this.store.length < 1 && this.emptyText.length > 0) {
var el = $(this.el).find(".inner").andSelf().filter(".inner");
if (el.find(".empty-text").length <= 0) {
el.append('<table class="empty-text"><tr><td>' + this.emptyText + "</td></tr></table>");
}
}
for (var i = 0; i < this.dataViewItems.length; i++) {
if (_.isEqual(view, this.dataViewItems[i])) {
this.dataViewItems.splice(i, 1);
break;
}
}
if (!this.isSuspendEvents) {
this.trigger("item:remove", this, view, record);
}
},
onClickItem: function (view, record, e) {
if (this.disabled) {
return;
}
window._event = e;
this.selectRecord(record);
this.lastSelectedRec = undefined;
var tip = view.$el.data("bs.tooltip");
if (tip) {
tip.hide();
}
if (!this.isSuspendEvents) {
this.trigger("item:click", this, view, record, e);
}
},
onDblClickItem: function (view, record, e) {
if (this.disabled) {
return;
}
window._event = e;
this.selectRecord(record);
this.lastSelectedRec = undefined;
if (!this.isSuspendEvents) {
this.trigger("item:dblclick", this, view, record, e);
}
},
onSelectItem: function (view, record, selected) {
if (!this.isSuspendEvents) {
this.trigger(selected ? "item:select": "item:deselect", this, view, record);
}
},
scrollToRecord: function (record) {
var innerEl = $(this.el).find(".inner");
var inner_top = innerEl.offset().top;
var div = innerEl.find("#" + record.get("id"));
var div_top = div.offset().top;
if (div_top < inner_top || div_top + div.height() > inner_top + innerEl.height()) {
if (this.scroller && this.allowScrollbar) {
this.scroller.scrollTop(innerEl.scrollTop() + div_top - inner_top, 0);
} else {
innerEl.scrollTop(innerEl.scrollTop() + div_top - inner_top);
}
}
},
onKeyDown: function (e, data) {
if (this.disabled) {
return;
}
if (data === undefined) {
data = e;
}
if (_.indexOf(this.moveKeys, data.keyCode) > -1 || data.keyCode == Common.UI.Keys.RETURN) {
data.preventDefault();
data.stopPropagation();
var rec = this.getSelectedRec()[0];
if (this.lastSelectedRec === undefined) {
this.lastSelectedRec = rec;
}
if (data.keyCode == Common.UI.Keys.RETURN) {
this.lastSelectedRec = undefined;
this.trigger("item:click", this, this, rec, e);
this.trigger("item:select", this, this, rec, e);
this.trigger("entervalue", this, rec, e);
} else {
var idx = _.indexOf(this.store.models, rec);
idx = (data.keyCode == Common.UI.Keys.UP || data.keyCode == Common.UI.Keys.LEFT) ? Math.max(0, idx - 1) : Math.min(this.store.length - 1, idx + 1);
rec = this.store.at(idx);
if (rec) {
this.selectRecord(rec);
this.scrollToRecord(rec);
}
}
}
},
attachKeyEvents: function () {
if (this.enableKeyEvents && this.handleSelect) {
var el = $(this.el).find(".inner").andSelf().filter(".inner");
el.addClass("canfocused");
el.attr("tabindex", "0");
el.on((this.parentMenu) ? "dataview:keydown": "keydown", _.bind(this.onKeyDown, this));
}
},
showLastSelected: function () {
if (this.lastSelectedRec) {
this.selectRecord(this.lastSelectedRec, true);
this.scrollToRecord(this.lastSelectedRec);
this.lastSelectedRec = undefined;
}
},
setDisabled: function (disabled) {
this.disabled = disabled;
$(this.el).find(".inner").andSelf().filter(".inner").toggleClass("disabled", disabled);
},
isDisabled: function () {
return this.disabled;
},
alignPosition: function () {
var menuRoot = (this.parentMenu.cmpEl.attr("role") === "menu") ? this.parentMenu.cmpEl : this.parentMenu.cmpEl.find("[role=menu]"),
innerEl = $(this.el).find(".inner").andSelf().filter(".inner"),
docH = $(document).height(),
menuH = menuRoot.outerHeight(),
top = parseInt(menuRoot.css("top"));
if (menuH > docH) {
innerEl.css("max-height", (docH - parseInt(menuRoot.css("padding-top")) - parseInt(menuRoot.css("padding-bottom")) - 5) + "px");
if (this.allowScrollbar) {
this.scroller.update({
minScrollbarLength: 40
});
}
} else {
if (innerEl.height() < this.options.restoreHeight) {
innerEl.css("max-height", (Math.min(docH - parseInt(menuRoot.css("padding-top")) - parseInt(menuRoot.css("padding-bottom")) - 5, this.options.restoreHeight)) + "px");
menuH = menuRoot.outerHeight();
if (top + menuH > docH) {
menuRoot.css("top", 0);
}
if (this.allowScrollbar) {
this.scroller.update({
minScrollbarLength: 40
});
}
}
}
}
});
$(document).on("keydown.bs.dropdown.data-api", "[data-toggle=dropdown], [role=menu]", function (e) {
if (e.keyCode !== Common.UI.Keys.UP && e.keyCode !== Common.UI.Keys.DOWN && e.keyCode !== Common.UI.Keys.LEFT && e.keyCode !== Common.UI.Keys.RIGHT && e.keyCode !== Common.UI.Keys.RETURN) {
return;
}
_.defer(function () {
var target = $(e.target).closest(".dropdown-toggle");
target.parent().find(".inner.canfocused").trigger("dataview:keydown", e);
},
100);
});
});

View File

@@ -1,245 +0,0 @@
/*
* (c) Copyright Ascensio System SIA 2010-2014
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
Ext.define("Common.component.DataViewPicker", {
extend: "Ext.container.Container",
requires: (["Ext.data.Store", "Ext.data.Model", "Ext.view.View", "Ext.XTemplate", "Ext.container.Container", "Common.plugin.DataViewScrollPane"]),
uses: ["Common.component.GroupedDataView"],
alias: "widget.cmddataviewpicker",
layout: {
type: "fit"
},
constructor: function (config) {
if (!config || !config.viewData) {
throw Error("Common.component.DataViewPicker creation failed: required parameters are missing.");
}
this.initConfig(config);
this.callParent(arguments);
return this;
},
initComponent: function () {
var me = this,
cfg = Ext.apply({},
me.initialConfig);
me.selectedRec = null;
Ext.define("DataModel", {
extend: "Ext.data.Model",
fields: [{
name: "imageUrl"
},
{
name: "title"
},
{
name: "data"
},
{
name: "uid"
}]
});
me.store = (Ext.isDefined(cfg.store)) ? cfg.store : Ext.create("Ext.data.Store", {
storeId: Ext.id(),
model: "DataModel",
data: cfg.viewData
});
var dataTpl = (Ext.isDefined(cfg.dataTpl)) ? cfg.dataTpl : Ext.create("Ext.XTemplate", '<tpl for=".">', '<div class="thumb-wrap">', (me.itemWidth !== undefined && me.itemHeight !== undefined) ? '<img src="{imageUrl}" width="' + me.itemWidth + '" height="' + me.itemHeight + '"/>' : '<img src="{imageUrl}" />', '<tpl if="title">', '<span class="title">{title}</span>', "</tpl>", "</div>", "</tpl>");
if (me.isGroupedDataView) {
var dataListView = Ext.create("Common.component.GroupedDataView", {
store: me.store,
listeners: {
itemclick: function (view, record, htmlItem, index, event, eOpts) {
me.selectedRec = record;
me.fireEvent("select", me, record, htmlItem, index);
},
beforecontainerclick: function (view, event, eOpts) {
return false;
},
selectionchange: function (view, selections, eOpts) {
var plugin = dataListView.getPlugin("scrollpane"),
node = dataListView.getNode(selections[0]);
if (plugin && node) {
plugin.scrollToElement(node);
}
me.fireEvent("selectionchange", me, view, selections);
},
itemkeydown: function (picker, record, item, index, e, opts) {
if (e.getKey() == e.ENTER) {
picker.fireEvent("itemclick", picker, record, item, index, e, opts);
}
}
},
plugins: [{
ptype: "dataviewscrollpane",
areaSelector: ".grouped-data-view",
pluginId: "scrollpane",
settings: {
enableKeyboardNavigation: true,
keyboardSpeed: 0.001,
contentWidth: me.contentWidth
}
}]
});
} else {
var dataListView = Ext.create("Ext.view.View", {
store: me.store,
tpl: dataTpl,
singleSelect: true,
trackOver: true,
autoScroll: true,
overItemCls: "x-item-over",
itemSelector: "div.thumb-wrap",
emptyText: "",
cls: "storage-data-view",
listeners: {
itemclick: function (view, record, htmlItem, index, event, eOpts) {
me.selectedRec = record;
me.fireEvent("select", me, record, htmlItem, index);
},
beforecontainerclick: function (view, event, eOpts) {
return false;
},
selectionchange: function (view, selections, eOpts) {
me.fireEvent("selectionchange", me, view, selections);
},
itemkeydown: function (picker, record, item, index, e, opts) {
if (e.getKey() == e.ENTER) {
picker.fireEvent("itemclick", picker, record, item, index, e, opts);
}
},
itemmouseenter: function (obj, record, item, index, e, eOpts) {
me.fireEvent("itemmouseenter", me, record, item, index, e, eOpts);
},
itemmouseleave: function (obj, record, item, index, e, eOpts) {
me.fireEvent("itemmouseleave", me, record, item, index, e, eOpts);
}
},
plugins: [{
ptype: "dataviewscrollpane",
areaSelector: ".storage-data-view",
pluginId: "scrollpane",
settings: {
enableKeyboardNavigation: true,
keyboardSpeed: 0.001,
contentWidth: me.contentWidth
}
}]
});
}
me.addEvents("select", "itemmouseenter", "itemmouseleave");
if (me.handler) {
me.on("select", me.handler, me.scope, me);
}
me.getSelectedRec = function () {
return (me.isGroupedDataView) ? dataListView.getSelected() : dataListView.getSelectionModel().getSelection()[0];
};
me.selectByIndex = function (index, fireevent) {
if (dataListView.rendered) {
if (index < 0) {
dataListView.getSelectionModel().deselectAll(false);
me.selectedRec = null;
} else {
var fire = Ext.isDefined(fireevent) ? fireevent : true;
me.selectedRec = me.store.getAt(index);
dataListView.getSelectionModel().select(me.store.getAt(index), false, fire);
}
} else {
dataListView.on("afterrender", Ext.bind(function (idx) {
me.selectByIndex(idx);
},
this, [index]), {
single: true
});
}
};
me.selectGroupItem = function (group, item) {
if (!me.isGroupedDataView || !dataListView) {
return null;
}
me.selectedRec = dataListView.selectGroupItem(group, item);
return me.selectedRec;
};
me.updateScrollPane = function () {
var plugin = dataListView.getPlugin("scrollpane");
if (plugin && dataListView.getEl() && dataListView.getEl().getWidth() > 0) {
if (plugin.settings) {
plugin.settings.contentWidth = me.contentWidth;
}
plugin.updateScrollPane(dataListView.getEl().dom);
me.checkScrolls();
if (me.arrangeItems) {
me.arrangeItems.call(me);
}
}
};
me.checkScrolls = function () {
var plugin = dataListView.getPlugin("scrollpane");
if (plugin && dataListView.getEl()) {
var jspElem = me.getEl().down(".jspPane");
if (jspElem.getHeight() > 0 && me.getEl().getHeight() > 0) {
var i = 0;
var updatescroll = setInterval(function () {
if (jspElem.getHeight() > me.getEl().getHeight()) {
if (me.getEl().down(".jspVerticalBar")) {
clearInterval(updatescroll);
} else {
plugin.updateScrollPane(dataListView.getEl().dom);
clearInterval(updatescroll);
}
}
if (i++>3) {
clearInterval(updatescroll);
}
},
100);
}
}
};
me.showUpdated = function () {
me.updateScrollPane();
if (dataListView && dataListView.getEl()) {
dataListView.getEl().focus(50);
if (me.selectedRec) {
dataListView.getSelectionModel().select(me.selectedRec, false, false);
} else {
dataListView.getSelectionModel().deselectAll(false);
}
}
};
dataListView.getStore().on("datachanged", me.updateScrollPane, me, {
buffer: 10
});
dataListView.on("viewready", me.updateScrollPane, me);
me.on("resize", me.updateScrollPane, me);
me.on("afterlayout", me.updateScrollPane, me);
me.items = [dataListView];
this.callParent(arguments);
}
});

View File

@@ -0,0 +1,121 @@
/*
* (c) Copyright Ascensio System SIA 2010-2015
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
if (Common === undefined) {
var Common = {};
}
define(["common/main/lib/component/BaseView"], function () {
Common.UI.DimensionPicker = Common.UI.BaseView.extend((function () {
var me, rootEl, areaMouseCatcher, areaUnHighLighted, areaHighLighted, areaStatus, curColumns = 0,
curRows = 0;
var onMouseMove = function (event) {
me.setTableSize(Math.ceil((event.offsetX === undefined ? event.originalEvent.layerX : event.offsetX) / me.itemSize), Math.ceil((event.offsetY === undefined ? event.originalEvent.layerY : event.offsetY) / me.itemSize), event);
};
var onMouseLeave = function (event) {
me.setTableSize(0, 0, event);
};
var onHighLightedMouseClick = function (e) {
me.trigger("select", me, curColumns, curRows, e);
};
return {
options: {
itemSize: 18,
minRows: 5,
minColumns: 5,
maxRows: 20,
maxColumns: 20
},
template: _.template(['<div style="width: 100%; height: 100%;">', '<div class="dimension-picker-status">0x0</div>', '<div class="dimension-picker-observecontainer">', '<div class="dimension-picker-mousecatcher"></div>', '<div class="dimension-picker-unhighlighted"></div>', '<div class="dimension-picker-highlighted"></div>', "</div>", "</div>"].join("")),
initialize: function (options) {
Common.UI.BaseView.prototype.initialize.call(this, options);
me = this;
rootEl = $(this.el);
me.itemSize = me.options.itemSize;
me.minRows = me.options.minRows;
me.minColumns = me.options.minColumns;
me.maxRows = me.options.maxRows;
me.maxColumns = me.options.maxColumns;
this.render();
if (rootEl) {
areaMouseCatcher = rootEl.find(".dimension-picker-mousecatcher");
areaUnHighLighted = rootEl.find(".dimension-picker-unhighlighted");
areaHighLighted = rootEl.find(".dimension-picker-highlighted");
areaStatus = rootEl.find(".dimension-picker-status");
rootEl.css({
width: me.minColumns + "em"
});
areaMouseCatcher.css("z-index", 1);
areaMouseCatcher.width(me.maxColumns + "em").height(me.maxRows + "em");
areaUnHighLighted.width(me.minColumns + "em").height(me.minRows + "em");
areaStatus.html(curColumns + " x " + curRows);
areaStatus.width(areaUnHighLighted.width());
}
areaMouseCatcher.on("mousemove", onMouseMove);
areaHighLighted.on("mousemove", onMouseMove);
areaUnHighLighted.on("mousemove", onMouseMove);
areaMouseCatcher.on("mouseleave", onMouseLeave);
areaHighLighted.on("mouseleave", onMouseLeave);
areaUnHighLighted.on("mouseleave", onMouseLeave);
areaMouseCatcher.on("click", onHighLightedMouseClick);
areaHighLighted.on("click", onHighLightedMouseClick);
areaUnHighLighted.on("click", onHighLightedMouseClick);
},
render: function () {
$(this.el).html(this.template());
return this;
},
setTableSize: function (columns, rows, event) {
if (columns > this.maxColumns) {
columns = this.maxColumns;
}
if (rows > this.maxRows) {
rows = this.maxRows;
}
if (curColumns != columns || curRows != rows) {
curColumns = columns;
curRows = rows;
areaHighLighted.width(curColumns + "em").height(curRows + "em");
areaUnHighLighted.width(((curColumns < me.minColumns) ? me.minColumns : ((curColumns + 1 > me.maxColumns) ? me.maxColumns : curColumns + 1)) + "em").height(((curRows < me.minRows) ? me.minRows : ((curRows + 1 > me.maxRows) ? me.maxRows : curRows + 1)) + "em");
rootEl.width(areaUnHighLighted.width());
areaStatus.html(curColumns + " x " + curRows);
areaStatus.width(areaUnHighLighted.width());
me.trigger("change", me, curColumns, curRows, event);
}
},
getColumnsCount: function () {
return curColumns;
},
getRowsCount: function () {
return curRows;
}
};
})());
});

View File

@@ -1,235 +0,0 @@
/*
* (c) Copyright Ascensio System SIA 2010-2014
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
Ext.define("Common.component.DoubleColorPalette", {
extend: "Ext.ColorPalette",
alias: "widget.cmddoublecolorpalette",
allowReselect: true,
dyncolorscount: 12,
width: 180,
maxWidth: 180,
baseCls: "cmp-double-colorpalette",
requires: ["Common.view.ExtendedColorDialog"],
renderTpl: ['<tpl for="colors">', '<tpl if="this.isSeparator(values)"><div class="palette-color-spacer" style="width:100%;height:10px;float:left;"></div></tpl>', '<tpl if="this.isColor(values)">', '<a href="#" class="color-{.}" style="background:#{.} "hidefocus="on">', '<em><span style="background:#{.}" unselectable="on">&#160;</span></em>', "</a>", "</tpl>", '<tpl if="this.isCustom(values)">', '<a href="#" id="{id}" class="palette-color-custom {cls}" hidefocus="on">', '<em><span style="background:#FFFFFF;background-image:url({image});" unselectable="on">&#160;</span></em>', "</a>", "</tpl>", "</tpl>", {
isSeparator: function (v) {
return typeof(v) == "string" && v == "-";
},
isColor: function (v) {
return typeof(v) == "string" && (/[0-9A-F]{6}|transparent/).test(v);
},
isCustom: function (v) {
return typeof(v) == "object";
}
}],
constructor: function (config) {
this.initConfig(config);
this.callParent(arguments);
return this;
},
initComponent: function () {
this.callParent(arguments);
},
onRender: function (o) {
this.callParent(arguments);
if (this.dynamiccolors) {
var picker = o.down(".x-color-picker");
if (picker) {
var i = -1,
colors = '<div class="palette-color-spacer" style="width:100%;height:10px;float:left;"></div>';
while (++i < this.dyncolorscount) {
colors += Ext.String.format('<a href="#" class="color-dynamic-{0} dynamic-empty-color" style="background:#ffffff" color="ffffff" hidefocus="on">' + '<em><span unselectable="on">&#160;</span></em></a>', i);
}
Ext.DomHelper.insertHtml("beforeEnd", picker.dom, colors);
}
var menu = this.el.up(".x-menu");
if (menu) {
Ext.menu.Manager.menus[menu.id].addListener("beforeshow", this.updateCustomColors, this);
}
this.updateCustomColors();
}
},
afterRender: function (o) {
this.callParent(arguments);
if (this.lastvalue) {
this.select(this.lastvalue);
}
},
setCustomColor: function (color) {
color = /#?([a-fA-F0-9]{6})/.exec(color);
if (color) {
var el = this.getEl();
if (el) {
this._saveCustomColor(color[1]);
$("#" + el.id + " a." + this.selectedCls).removeClass(this.selectedCls);
var child = el.down(".dynamic-empty-color");
if (!child) {
this.updateCustomColors();
child = el.down(".color-dynamic-" + (this.dyncolorscount - 1));
}
child.removeCls("dynamic-empty-color").addCls(this.selectedCls).dom.setAttribute("color", color[1]);
child.down("span").setStyle("background-color", "#" + color[1]).setStyle("border", "none");
}
}
},
select: function (color, suppressEvent) {
var el = this.getEl();
if (el) {
$("#" + el.id + " a." + this.selectedCls).removeClass(this.selectedCls);
}
if (/#?[a-fA-F0-9]{6}/.test(color)) {
color = /#?([a-fA-F0-9]{6})/.exec(color)[1].toUpperCase();
}
if (/^[a-fA-F0-9]{6}|transparent$/.test(color) && Ext.Array.contains(this.colors, color)) {
if (!Ext.Array.contains(this.colors, this.value)) {
this.value = false;
}
this.callParent(arguments);
} else {
if (el) {
var co = el.down("#" + color) || el.down('a[color="' + color + '"]');
if (co) {
co.addCls(this.selectedCls);
this.value = color.toUpperCase();
} else {
if (el.down("a." + this.selectedCls)) {
this.value = false;
} else {
if (this.dynamiccolors) {
this.setCustomColor(color);
}
}
}
} else {
this.lastvalue = color;
}
}
},
handleClick: function (event, target) {
var me = this;
if (! (target.className.search("palette-color-custom") < 0)) {
event.stopEvent();
cmp = Ext.get(target.parentNode.id).down("a." + me.selectedCls);
if (!cmp || cmp.id != target.id) {
if (cmp) {
cmp.removeCls(me.selectedCls);
}
Ext.get(target.id).addCls(me.selectedCls);
me.value = false;
me.fireEvent("select", me, target.id);
} else {
me.fireEvent("select", me, cmp.id);
}
} else {
if (! (target.className.search("color-transparent") < 0)) {
event.stopEvent();
cmp = Ext.get(target.parentNode.id).down("a." + me.selectedCls);
if (!cmp || cmp.id != target.id) {
if (cmp) {
cmp.removeCls(me.selectedCls);
}
Ext.get(target.id).addCls(me.selectedCls);
me.value = "transparent";
}
me.fireEvent("select", me, "transparent");
} else {
if (! (target.className.search("color-dynamic") < 0)) {
if (!/dynamic-empty-color/.test(target.className)) {
var color = target.getAttribute("color");
if (color) {
me.fireEvent("select", me, color);
}
this.value = color.toUpperCase();
$("#" + this.getEl().id + " a." + me.selectedCls).removeClass(me.selectedCls);
Ext.get(target.id).addCls(me.selectedCls);
} else {
setTimeout(function () {
me.addNewColor();
Ext.menu.Manager.hideAll();
},
10);
}
} else {
var cmp = Ext.get(target.parentNode.id).down("a.palette-color-custom");
if (cmp) {
cmp.removeCls(me.selectedCls);
}
if (!/^[a-fA-F0-9]{6}$/.test(this.value) || !Ext.Array.contains(this.colors, this.value)) {
this.value = false;
}
this.callParent(arguments);
}
}
}
},
addNewColor: function () {
var me = this;
var win = Ext.widget("commonextendedcolordialog", {});
win.addListener("onmodalresult", function (mr) {
me._isdlgopen = false;
if (mr == 1) {
me.setCustomColor(win.getColor());
me.fireEvent("select", me, win.getColor());
}
},
false);
me._isdlgopen = true;
win.setColor(me.value);
win.show();
},
isDialogOpen: function () {
return this._isdlgopen == true;
},
updateCustomColors: function () {
var picker = this.getEl();
if (picker) {
var colors = localStorage["asc." + window.storagename + ".colors.custom"];
colors = colors ? colors.split(",") : [];
var i = -1,
colorEl, c = colors.length < this.dyncolorscount ? colors.length : this.dyncolorscount;
while (++i < c) {
colorEl = picker.down(".color-dynamic-" + i);
colorEl.removeCls("dynamic-empty-color").dom.setAttribute("color", colors[i]);
colorEl.down("span").setStyle("background-color", "#" + colors[i]).setStyle("border", "none");
}
}
},
_saveCustomColor: function (color) {
var colors = localStorage["asc." + window.storagename + ".colors.custom"];
colors = colors ? colors.split(",") : [];
if (colors.push(color) > this.dyncolorscount) {
colors.shift();
}
localStorage["asc." + window.storagename + ".colors.custom"] = colors.join().toUpperCase();
},
_menuBeforeShow: function () {
this.updateCustomColors();
}
});

View File

@@ -1,190 +0,0 @@
/*
* (c) Copyright Ascensio System SIA 2010-2014
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
Ext.define("Common.component.GroupedDataView", {
extend: "Ext.DataView",
alias: "widget.cmdgroupeddataview",
requires: (["Common.model.GroupItem", "Common.model.Group", "Ext.XTemplate"]),
selModel: {
enableKeyNav: false
},
tpl: new Ext.XTemplate('<tpl for=".">', '<div class="asc-grouped-data">', '<div class="group-description">', '<span class="description-text">{[values[this.fieldGroupName]]}</span>', "</div>", '<div class="group-items-container">', '<tpl for="getGroupItems">', '<div class="group-item">', '<span class="{iconcls}"></span>', "</div>", "</tpl>", "</div>", "</div>", '<div class="asc-grouped-data-selector"></div>', "</tpl>", {
compiled: true,
fieldGroupName: "groupname"
}),
itemSelector: "div.group-item",
trackOver: true,
overItemCls: "group-item-over",
cls: "grouped-data-view",
listeners: {
beforecontainerclick: function (o, e, eOpts) {
return false;
},
viewready: function () {
if (this.delayedSelection) {
this.getSelectionModel().doSingleSelect(this.delayedSelection);
this.delayedSelection = undefined;
}
}
},
constructor: function (config) {
if (config.selModel) {
config.selModel.enableKeyNav = false;
}
this.initConfig(config);
this.callParent(arguments);
return this;
},
initComponent: function () {
this.callParent(arguments);
},
updateIndexes: function (startIndex, endIndex) {
var ns = this.all.elements,
records = [],
i;
this.store.each(function (item, index, count) {
Ext.Array.insert(records, records.length, item.getGroupItems().getRange());
});
startIndex = startIndex || 0;
endIndex = endIndex || ((endIndex === 0) ? 0 : (ns.length - 1));
for (i = startIndex; i <= endIndex; i++) {
ns[i].viewIndex = i;
ns[i].viewRecordId = records[i].internalId;
if (!ns[i].boundView) {
ns[i].boundView = this.id;
}
}
},
getRecord: function (node) {
var record_out, record, i = -1,
c = this.store.getCount();
while (!record_out && ++i < c) {
record = this.store.getAt(i);
if (record) {
record_out = record.getGroupItems().data.getByKey(Ext.getDom(node).viewRecordId);
}
}
return record_out;
},
onRender: function (cmp) {
this.callParent(arguments);
var me = this;
me.el.set({
tabIndex: -1
});
me.keyNav = Ext.create("Ext.util.KeyNav", me.el, {
down: Ext.pass(me.onNavKey, [1, 1], me),
right: Ext.pass(me.onNavKey, [1, null], me),
left: Ext.pass(me.onNavKey, [-1, null], me),
up: Ext.pass(me.onNavKey, [-1, -1], me),
scope: me
});
},
onNavKey: function (step, shift) {
step = step || 1;
var selected = this.getSelectionModel().getSelection()[0],
numRecords = this.all.elements.length,
idx;
if (selected) {
if (shift) {
var info = this.getIndexInStore(selected);
step = this.getShiftedStep(info, shift);
}
idx = this.indexOf(this.getNode(selected)) + step;
} else {
idx = 0;
}
if (idx < 0) {
idx = numRecords - 1;
} else {
if (idx >= numRecords) {
idx = 0;
}
}
var record = this.getRecord(this.all.elements[idx]);
this.getSelectionModel().doSingleSelect(record);
},
getIndexInStore: function (record) {
var out = [],
group,
localindex,
groupindex = -1,
c = this.store.getCount();
while (++groupindex < c) {
group = this.store.getAt(groupindex);
localindex = group.getGroupItems().indexOf(record);
if (! (localindex < 0)) {
out = [groupindex, localindex, group.getGroupItems().getCount()];
break;
}
}
return out;
},
getShiftedStep: function (info, direct) {
var groupindex = info[0] + direct;
if (groupindex < 0) {
groupindex = this.store.getCount() - 1;
} else {
if (! (groupindex < this.store.getCount())) {
groupindex = 0;
}
}
var group = this.store.getAt(groupindex);
if (direct > 0) {
var newindex = info[1] < group.getGroupItems().getCount() ? info[1] : group.getGroupItems().getCount() - 1;
newindex += info[2] - info[1];
} else {
newindex = info[1] < group.getGroupItems().getCount() ? info[1] - group.getGroupItems().getCount() : -1;
newindex -= info[1];
}
return newindex;
},
refresh: function () {
this.callParent(arguments);
},
selectGroupItem: function (group, item) {
var record = this.store.findRecord("group", group);
if (record) {
record = record.getGroupItems().findRecord("groupitem", item);
if (!this.rendered) {
this.delayedSelection = record;
} else {
if (record) {
this.getSelectionModel().doSingleSelect(record);
}
}
}
return record;
},
getSelected: function () {
return this.delayedSelection || this.getSelectionModel().getSelection()[0];
}
});

View File

@@ -1,216 +1,218 @@
/*
* (c) Copyright Ascensio System SIA 2010-2014
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
Ext.define("Common.component.HSBColorPicker", {
extend: "Ext.Component",
alias: "widget.hsbcolorpicker",
requires: ["Common.component.util.RGBColor", "Ext.XTemplate"],
baseCls: "cmp-hsb-colorpicker",
allowEmptyColor: false,
changeSaturation: true,
showCurrentColor: true,
config: {
color: "#ff0000"
},
renderTpl: ['<div class="{baseCls}-root">', '<tpl if="showCurrentColor">', '<div class="{baseCls}-top-panel">', '<span class="{baseCls}-color-value">', '<span class="transparent-color"></span>', "</span>", '<div class="{baseCls}-color-text"></div>', "</div>", "</tpl>", "<div>", '<div class="{baseCls}-cnt-hb">', '<div class="{baseCls}-cnt-hb-arrow"></div>', "</div>", '<tpl if="changeSaturation">', '<div class="{baseCls}-cnt-root">', '<div class="{baseCls}-cnt-sat">', '<div class="{baseCls}-cnt-sat-arrow"></div>', "</div>", "</div>", "</tpl>", "</div>", '<tpl if="allowEmptyColor">', '<div class="{baseCls}-empty-color">{textNoColor}</div>', "</tpl>", "</div>"],
constructor: function (config) {
this.initConfig(config);
this.callParent(arguments);
return this;
},
initComponent: function () {
var me = this,
arrowSatBrightness, arrowHue, areaSatBrightness, areaHue, previewColor, previewTransparentColor, previewColorText, btnNoColor, hueVal = 0,
saturationVal = 100,
brightnessVal = 100;
var onUpdateColor = function (hsb, transparent) {
var rgbColor = new Common.util.RGBColor(Ext.String.format("hsb({0}, {1}, {2})", hsb.h, hsb.s, hsb.b)),
hexColor = rgbColor.toHex();
me.color = transparent ? "transparent" : hexColor;
refreshUI();
me.fireEvent("changecolor", me, me.color);
};
var refreshUI = function () {
if (previewColor && previewTransparentColor) {
if (me.color == "transparent") {
previewTransparentColor.show();
} else {
previewColor.setStyle("background-color", me.color);
previewTransparentColor.hide();
}
}
if (areaSatBrightness) {
areaSatBrightness.setStyle("background-color", new Common.util.RGBColor(Ext.String.format("hsb({0}, 100, 100)", hueVal)).toHex());
}
if (previewColorText) {
previewColorText.dom.innerHTML = (me.color == "transparent") ? me.textNoColor : me.color.toUpperCase();
}
if (arrowSatBrightness && arrowHue) {
arrowSatBrightness.setLeft(saturationVal + "%");
arrowSatBrightness.setTop(100 - brightnessVal + "%");
arrowHue.setTop(parseInt(hueVal * 100 / 360) + "%");
}
};
var onSBAreaMouseMove = function (event, element, eOpts) {
if (arrowSatBrightness && areaSatBrightness) {
var pos = [Math.max(0, Math.min(100, (parseInt((event.getX() - areaSatBrightness.getX()) / areaSatBrightness.getWidth() * 100)))), Math.max(0, Math.min(100, (parseInt((event.getY() - areaSatBrightness.getY()) / areaSatBrightness.getHeight() * 100))))];
arrowSatBrightness.setLeft(pos[0] + "%");
arrowSatBrightness.setTop(pos[1] + "%");
saturationVal = pos[0];
brightnessVal = 100 - pos[1];
onUpdateColor({
h: hueVal,
s: saturationVal,
b: brightnessVal
});
}
};
var onHueAreaMouseMove = function (event, element, eOpts) {
if (arrowHue && areaHue) {
var pos = Math.max(0, Math.min(100, (parseInt((event.getY() - areaHue.getY()) / areaHue.getHeight() * 100))));
arrowHue.setTop(pos + "%");
hueVal = parseInt(360 * pos / 100);
onUpdateColor({
h: hueVal,
s: saturationVal,
b: brightnessVal
});
}
};
var onSBAreaMouseDown = function (event, element, eOpts) {
Ext.getDoc().on("mouseup", onSBAreaMouseUp);
Ext.getDoc().on("mousemove", onSBAreaMouseMove);
};
var onSBAreaMouseUp = function (event, element, eOpts) {
Ext.getDoc().un("mouseup", onSBAreaMouseUp);
Ext.getDoc().un("mousemove", onSBAreaMouseMove);
onSBAreaMouseMove(event, element, eOpts);
};
var onHueAreaMouseDown = function (event, element, eOpts) {
Ext.getDoc().on("mouseup", onHueAreaMouseUp);
Ext.getDoc().on("mousemove", onHueAreaMouseMove);
onHueAreaMouseMove(event, element, eOpts);
};
var onHueAreaMouseUp = function (event, element, eOpts) {
Ext.getDoc().un("mouseup", onHueAreaMouseUp);
Ext.getDoc().un("mousemove", onHueAreaMouseMove);
};
var onNoColorClick = function (cnt) {
var hsbColor = new Common.util.RGBColor(me.color).toHSB();
onUpdateColor(hsbColor, true);
};
var onAfterRender = function (ct) {
var rootEl = me.getEl(),
hsbColor;
if (rootEl) {
arrowSatBrightness = rootEl.down("." + me.baseCls + "-cnt-hb-arrow");
arrowHue = rootEl.down("." + me.baseCls + "-cnt-sat-arrow");
areaSatBrightness = rootEl.down("." + me.baseCls + "-cnt-hb");
areaHue = rootEl.down("." + me.baseCls + "-cnt-sat");
previewColor = rootEl.down("." + me.baseCls + "-color-value");
previewColorText = rootEl.down("." + me.baseCls + "-color-text");
btnNoColor = rootEl.down("." + me.baseCls + "-empty-color");
if (previewColor) {
previewTransparentColor = previewColor.child(".transparent-color");
}
if (areaSatBrightness) {
areaSatBrightness.un("mousedown");
areaSatBrightness.on("mousedown", onSBAreaMouseDown, me);
}
if (areaHue) {
areaHue.un("mousedown");
areaHue.on("mousedown", onHueAreaMouseDown, me);
}
if (btnNoColor) {
btnNoColor.un("click");
btnNoColor.on("click", onNoColorClick, me);
}
if (me.color == "transparent") {
hsbColor = {
h: 0,
s: 100,
b: 100
};
} else {
hsbColor = new Common.util.RGBColor(me.color).toHSB();
}
hueVal = hsbColor.h;
saturationVal = hsbColor.s;
brightnessVal = hsbColor.b;
if (hueVal == saturationVal && hueVal == brightnessVal && hueVal == 0) {
saturationVal = 100;
}
refreshUI();
}
};
me.setColor = function (value) {
if (me.color == value) {
return;
}
var hsbColor;
if (value == "transparent") {
hsbColor = {
h: 0,
s: 100,
b: 100
};
} else {
hsbColor = new Common.util.RGBColor(value).toHSB();
}
hueVal = hsbColor.h;
saturationVal = hsbColor.s;
brightnessVal = hsbColor.b;
if (hueVal == saturationVal && hueVal == brightnessVal && hueVal == 0) {
saturationVal = 100;
}
me.color = value;
refreshUI();
};
me.on("afterrender", onAfterRender, this);
me.callParent(arguments);
this.addEvents("changecolor");
},
onRender: function (ct, position) {
var me = this;
Ext.applyIf(me.renderData, me.getTemplateArgs());
me.callParent(arguments);
},
getTemplateArgs: function () {
var me = this;
return {
allowEmptyColor: me.allowEmptyColor,
changeSaturation: me.changeSaturation,
textNoColor: me.textNoColor,
showCurrentColor: me.showCurrentColor
};
},
textNoColor: "No Color"
/*
* (c) Copyright Ascensio System SIA 2010-2015
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
if (Common === undefined) {
var Common = {};
}
define(["common/main/lib/component/BaseView", "common/main/lib/util/utils"], function () {
Common.UI.HSBColorPicker = Common.UI.BaseView.extend({
template: _.template('<div class="hsb-colorpicker">' + "<% if (this.showCurrentColor) { %>" + '<div class="top-panel">' + '<span class="color-value">' + '<span class="transparent-color"></span>' + "</span>" + '<div class="color-text"></div>' + "</div>" + "<% } %>" + "<div>" + '<div class="cnt-hb">' + '<div class="cnt-hb-arrow"></div>' + "</div>" + "<% if (this.changeSaturation) { %>" + '<div class="cnt-root">' + '<div class="cnt-sat">' + '<div class="cnt-sat-arrow"></div>' + "</div>" + "</div>" + "<% } %>" + "</div>" + "<% if (this.allowEmptyColor) { %>" + '<div class="empty-color"><%= this.textNoColor %></div>' + "<% } %>" + "</div>"),
color: "#ff0000",
options: {
allowEmptyColor: false,
changeSaturation: true,
showCurrentColor: true
},
initialize: function (options) {
Common.UI.BaseView.prototype.initialize.call(this, options);
var me = this,
el = $(this.el),
arrowSatBrightness,
arrowHue,
areaSatBrightness,
areaHue,
previewColor,
previewTransparentColor,
previewColorText,
btnNoColor,
hueVal = 0,
saturationVal = 100,
brightnessVal = 100;
me.allowEmptyColor = me.options.allowEmptyColor;
me.changeSaturation = me.options.changeSaturation;
me.showCurrentColor = me.options.showCurrentColor;
var onUpdateColor = function (hsb, transparent) {
var rgbColor = new Common.Utils.RGBColor("hsb(" + hsb.h + "," + hsb.s + "," + hsb.b + ")"),
hexColor = rgbColor.toHex();
me.color = transparent ? "transparent" : hexColor;
refreshUI();
me.trigger("changecolor", me, me.color);
};
var refreshUI = function () {
if (previewColor.length > 0 && previewTransparentColor.length > 0) {
if (me.color == "transparent") {
previewTransparentColor.show();
} else {
previewColor.css("background-color", me.color);
previewTransparentColor.hide();
}
}
if (areaSatBrightness.length > 0) {
areaSatBrightness.css("background-color", new Common.Utils.RGBColor("hsb(" + hueVal + ", 100, 100)").toHex());
}
if (previewColorText.length > 0) {
previewColorText[0].innerHTML = (me.color == "transparent") ? me.textNoColor : me.color.toUpperCase();
}
if (arrowSatBrightness.length > 0 && arrowHue.length > 0) {
arrowSatBrightness.css("left", saturationVal + "%");
arrowSatBrightness.css("top", 100 - brightnessVal + "%");
arrowHue.css("top", parseInt(hueVal * 100 / 360) + "%");
}
};
var onSBAreaMouseMove = function (event, element, eOpts) {
if (arrowSatBrightness.length > 0 && areaSatBrightness.length > 0) {
var pos = [Math.max(0, Math.min(100, (parseInt((event.pageX - areaSatBrightness.offset().left) / areaSatBrightness.width() * 100)))), Math.max(0, Math.min(100, (parseInt((event.pageY - areaSatBrightness.offset().top) / areaSatBrightness.height() * 100))))];
arrowSatBrightness.css("left", pos[0] + "%");
arrowSatBrightness.css("top", pos[1] + "%");
saturationVal = pos[0];
brightnessVal = 100 - pos[1];
onUpdateColor({
h: hueVal,
s: saturationVal,
b: brightnessVal
});
}
};
var onHueAreaMouseMove = function (event, element, eOpts) {
if (arrowHue && areaHue) {
var pos = Math.max(0, Math.min(100, (parseInt((event.pageY - areaHue.offset().top) / areaHue.height() * 100))));
arrowHue.css("top", pos + "%");
hueVal = parseInt(360 * pos / 100);
onUpdateColor({
h: hueVal,
s: saturationVal,
b: brightnessVal
});
}
};
var onSBAreaMouseDown = function (event, element, eOpts) {
$(document).on("mouseup", onSBAreaMouseUp);
$(document).on("mousemove", onSBAreaMouseMove);
};
var onSBAreaMouseUp = function (event, element, eOpts) {
$(document).off("mouseup", onSBAreaMouseUp);
$(document).off("mousemove", onSBAreaMouseMove);
onSBAreaMouseMove(event, element, eOpts);
};
var onHueAreaMouseDown = function (event, element, eOpts) {
$(document).on("mouseup", onHueAreaMouseUp);
$(document).on("mousemove", onHueAreaMouseMove);
onHueAreaMouseMove(event, element, eOpts);
};
var onHueAreaMouseUp = function (event, element, eOpts) {
$(document).off("mouseup", onHueAreaMouseUp);
$(document).off("mousemove", onHueAreaMouseMove);
};
var onNoColorClick = function (cnt) {
var hsbColor = new Common.util.RGBColor(me.color).toHSB();
onUpdateColor(hsbColor, true);
};
var onAfterRender = function (ct) {
var rootEl = $(me.el),
hsbColor;
if (rootEl) {
arrowSatBrightness = rootEl.find(".cnt-hb-arrow");
arrowHue = rootEl.find(".cnt-sat-arrow");
areaSatBrightness = rootEl.find(".cnt-hb");
areaHue = rootEl.find(".cnt-sat");
previewColor = rootEl.find(".color-value");
previewColorText = rootEl.find(".color-text");
btnNoColor = rootEl.find(".empty-color");
if (previewColor.length > 0) {
previewTransparentColor = previewColor.find(".transparent-color");
}
if (areaSatBrightness.length > 0) {
areaSatBrightness.off("mousedown");
areaSatBrightness.on("mousedown", onSBAreaMouseDown);
}
if (areaHue.length > 0) {
areaHue.off("mousedown");
areaHue.on("mousedown", onHueAreaMouseDown);
}
if (btnNoColor.length > 0) {
btnNoColor.off("click");
btnNoColor.on("click", onNoColorClick);
}
if (me.color == "transparent") {
hsbColor = {
h: 0,
s: 100,
b: 100
};
} else {
hsbColor = new Common.Utils.RGBColor(me.color).toHSB();
}
hueVal = hsbColor.h;
saturationVal = hsbColor.s;
brightnessVal = hsbColor.b;
if (hueVal == saturationVal && hueVal == brightnessVal && hueVal == 0) {
saturationVal = 100;
}
refreshUI();
}
};
me.setColor = function (value) {
if (me.color == value) {
return;
}
var hsbColor;
if (value == "transparent") {
hsbColor = {
h: 0,
s: 100,
b: 100
};
} else {
hsbColor = new Common.Utils.RGBColor(value).toHSB();
}
hueVal = hsbColor.h;
saturationVal = hsbColor.s;
brightnessVal = hsbColor.b;
if (hueVal == saturationVal && hueVal == brightnessVal && hueVal == 0) {
saturationVal = 100;
}
me.color = value;
refreshUI();
};
me.getColor = function () {
return me.color;
};
me.on("render:after", onAfterRender);
me.render();
},
render: function () {
$(this.el).html(this.template());
this.trigger("render:after", this);
return this;
},
textNoColor: "No Color"
});
});

View File

@@ -1,95 +0,0 @@
/*
* (c) Copyright Ascensio System SIA 2010-2014
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
Ext.define("Common.component.IndeterminateCheckBox", {
extend: "Ext.form.field.Checkbox",
alias: "widget.cmdindeterminatecheckbox",
value: "unchecked",
indeterminate: false,
indeterminateCls: Ext.baseCSSPrefix + "form-cb-indeterminate",
onBoxClick: function (e) {
var me = this;
if (!me.disabled && !me.readOnly) {
if (this.indeterminate) {
this.indeterminate = false;
this.setValue(false);
} else {
this.setValue(!this.checked);
}
}
},
getRawValue: function () {
return this.value;
},
getValue: function () {
return this.value;
},
setRawValue: function (value) {
var me = this,
inputEl = me.inputEl,
inputValue = me.inputValue,
checked = (value === true || value === "true" || value === "1" || value === 1 || (((Ext.isString(value) || Ext.isNumber(value)) && inputValue) ? value == inputValue : me.onRe.test(value))),
indeterminate = (value === "indeterminate");
if (inputEl) {
inputEl.dom.setAttribute("aria-checked", checked);
inputEl.dom.setAttribute("aria-indeterminate", indeterminate);
me[indeterminate ? "addCls" : "removeCls"](me.indeterminateCls);
me[checked ? "addCls" : "removeCls"](me.checkedCls);
}
me.checked = me.rawValue = checked;
me.indeterminate = indeterminate;
me.value = indeterminate ? "indeterminate" : (checked ? "checked" : "unchecked");
return checked;
},
setValue: function (checked) {
var me = this;
var setFn = function (value, suspendEvent) {
if (Ext.isArray(value)) {
me.getManager().getByName(me.name).each(function (cb) {
cb.setValue(Ext.Array.contains(value, cb.inputValue));
});
} else {
me.setRawValue(value);
if (! (Ext.isDefined(suspendEvent) && suspendEvent)) {
me.checkChange();
}
}
return me;
};
if (this.rendered) {
setFn.call(this, checked);
} else {
this.on("afterrender", Ext.bind(setFn, this, [checked, true]), {
single: true
});
}
}
});

View File

@@ -0,0 +1,265 @@
/*
* (c) Copyright Ascensio System SIA 2010-2015
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
if (Common === undefined) {
var Common = {};
}
define(["common/main/lib/component/BaseView", "common/main/lib/component/Tooltip"], function () {
Common.UI.InputField = Common.UI.BaseView.extend((function () {
return {
options: {
id: null,
cls: "",
style: "",
value: "",
type: "text",
name: "",
validation: null,
allowBlank: true,
placeHolder: "",
blankError: null,
spellcheck: false,
maskExp: "",
validateOnChange: false,
validateOnBlur: true,
disabled: false
},
template: _.template(['<div class="input-field" style="<%= style %>">', "<input ", 'type="<%= type %>" ', 'name="<%= name %>" ', 'spellcheck="<%= spellcheck %>" ', 'class="form-control <%= cls %>" ', 'placeholder="<%= placeHolder %>" ', 'value="<%= value %>"', ">", '<span class="input-error"/>', "</div>"].join("")),
initialize: function (options) {
Common.UI.BaseView.prototype.initialize.call(this, options);
var me = this,
el = $(this.el);
this.id = me.options.id || Common.UI.getId();
this.cls = me.options.cls;
this.style = me.options.style;
this.value = me.options.value;
this.type = me.options.type;
this.name = me.options.name;
this.validation = me.options.validation;
this.allowBlank = me.options.allowBlank;
this.placeHolder = me.options.placeHolder;
this.template = me.options.template || me.template;
this.editable = me.options.editable || true;
this.disabled = me.options.disabled;
this.spellcheck = me.options.spellcheck;
this.blankError = me.options.blankError || "This field is required";
this.validateOnChange = me.options.validateOnChange;
this.validateOnBlur = me.options.validateOnBlur;
me.rendered = me.options.rendered || false;
if (me.options.el) {
me.render();
}
},
render: function (parentEl) {
var me = this;
if (!me.rendered) {
this.cmpEl = $(this.template({
id: this.id,
cls: this.cls,
style: this.style,
value: this.value,
type: this.type,
name: this.name,
placeHolder: this.placeHolder,
spellcheck: this.spellcheck,
scope: me
}));
if (parentEl) {
this.setElement(parentEl, false);
parentEl.html(this.cmpEl);
} else {
$(this.el).html(this.cmpEl);
}
} else {
this.cmpEl = $(this.el);
}
if (!me.rendered) {
var el = this.cmpEl;
this._input = this.cmpEl.find("input").andSelf().filter("input");
if (this.editable) {
this._input.on("blur", _.bind(this.onInputChanged, this));
this._input.on("keypress", _.bind(this.onKeyPress, this));
this._input.on("keyup", _.bind(this.onKeyUp, this));
if (this.validateOnChange) {
this._input.on("input", _.bind(this.onInputChanging, this));
}
}
this.setEditable(this.editable);
if (this.disabled) {
this.setDisabled(this.disabled);
}
}
me.rendered = true;
return this;
},
_doChange: function (e, extra) {
if (extra && extra.synthetic) {
return;
}
var newValue = $(e.target).val(),
oldValue = this.value;
this.trigger("changed:before", this, newValue, oldValue, e);
if (e.isDefaultPrevented()) {
return;
}
this.value = newValue;
if (this.validateOnBlur) {
this.checkValidate();
}
this.trigger("changed:after", this, newValue, oldValue, e);
},
onInputChanged: function (e, extra) {
this._doChange(e, extra);
},
onInputChanging: function (e, extra) {
var newValue = $(e.target).val(),
oldValue = this.value;
if (e.isDefaultPrevented()) {
return;
}
this.value = newValue;
if (this.validateOnBlur) {
this.checkValidate();
}
this.trigger("changing", this, newValue, oldValue, e);
},
onKeyPress: function (e) {
this.trigger("keypress:before", this, e);
if (e.isDefaultPrevented()) {
return;
}
if (e.keyCode === Common.UI.Keys.RETURN) {
this._doChange(e);
} else {
if (this.options.maskExp && !_.isEmpty(this.options.maskExp.source)) {
var charCode = String.fromCharCode(e.which);
if (!this.options.maskExp.test(charCode) && !e.ctrlKey && e.keyCode !== Common.UI.Keys.DELETE && e.keyCode !== Common.UI.Keys.BACKSPACE && e.keyCode !== Common.UI.Keys.LEFT && e.keyCode !== Common.UI.Keys.RIGHT && e.keyCode !== Common.UI.Keys.HOME && e.keyCode !== Common.UI.Keys.END && e.keyCode !== Common.UI.Keys.ESC && e.keyCode !== Common.UI.Keys.INSERT) {
e.preventDefault();
e.stopPropagation();
}
}
}
this.trigger("keypress:after", this, e);
},
onKeyUp: function (e) {
this.trigger("keyup:before", this, e);
if (e.isDefaultPrevented()) {
return;
}
this.trigger("keyup:after", this, e);
},
setEditable: function (editable) {
var input = this._input;
this.editable = editable;
if (editable && input) {
input.removeAttr("readonly");
input.removeAttr("data-can-copy");
} else {
input.attr("readonly", "readonly");
input.attr("data-can-copy", false);
}
},
isEditable: function () {
return this.editable;
},
setDisabled: function (disabled) {
this.disabled = disabled;
$(this.el).toggleClass("disabled", disabled);
disabled ? this._input.attr("disabled", true) : this._input.removeAttr("disabled");
},
isDisabled: function () {
return this.disabled;
},
setValue: function (value) {
this.value = value;
if (this.rendered) {
this._input.val(value);
}
},
getValue: function () {
return this.value;
},
focus: function () {
this._input.focus();
},
checkValidate: function () {
var me = this,
errors = [];
if (!me.allowBlank && _.isEmpty(me.value)) {
errors.push(me.blankError);
}
if (_.isFunction(me.validation)) {
var res = me.validation.call(me, me.value);
if (res !== true) {
errors = _.flatten(errors.concat(res));
}
}
if (!_.isEmpty(errors)) {
me.cmpEl.addClass("error");
var errorBadge = me.cmpEl.find(".input-error"),
modalParents = errorBadge.closest(".asc-window");
errorBadge.attr("data-toggle", "tooltip");
errorBadge.removeData("bs.tooltip");
errorBadge.tooltip({
title: errors.join("\n"),
placement: "cursor"
});
if (modalParents.length > 0) {
errorBadge.data("bs.tooltip").tip().css("z-index", parseInt(modalParents.css("z-index")) + 10);
}
return errors;
} else {
me.cmpEl.removeClass("error");
}
return true;
},
showError: function (errors) {
var me = this;
if (!_.isEmpty(errors)) {
me.cmpEl.addClass("error");
var errorBadge = me.cmpEl.find(".input-error"),
modalParents = errorBadge.closest(".asc-window");
errorBadge.attr("data-toggle", "tooltip");
errorBadge.removeData("bs.tooltip");
errorBadge.tooltip({
title: errors.join("\n"),
placement: "cursor"
});
if (modalParents.length > 0) {
errorBadge.data("bs.tooltip").tip().css("z-index", parseInt(modalParents.css("z-index")) + 10);
}
} else {
me.cmpEl.removeClass("error");
}
}
};
})());
});

View File

@@ -0,0 +1,322 @@
/*
* (c) Copyright Ascensio System SIA 2010-2015
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
if (Common === undefined) {
var Common = {};
}
define(["backbone"], function () {
var BaseLayout = function (options) {
this.box = null;
this.panels = [];
_.extend(this, options || {});
};
var LayoutPanel = function () {
return {
width: null,
height: null,
resize: false,
stretch: false,
rely: false
};
};
_.extend(BaseLayout.prototype, Backbone.Events, {
initialize: function (options) {
this.$parent = this.box.parent();
this.resize = {
eventMove: _.bind(this.resizeMove, this),
eventStop: _.bind(this.resizeStop, this)
};
var panel, resizer, stretch = false;
options.items.forEach(function (item) {
item.el instanceof HTMLElement && (item.el = $(item.el));
panel = _.extend(new LayoutPanel(), item);
if (panel.stretch) {
stretch = true;
panel.rely = false;
panel.resize = false;
}
this.panels.push(panel);
if (panel.resize) {
resizer = {
isresizer: true,
minpos: panel.resize.min || 0,
maxpos: panel.resize.max || 0
};
if (!stretch) {
panel.resize.el = resizer.el = panel.el.after('<div class="layout-resizer after"></div>').next();
this.panels.push(resizer);
} else {
panel.resize.el = resizer.el = panel.el.before('<div class="layout-resizer before"></div>').prev();
this.panels.splice(this.panels.length - 1, 0, resizer);
}
panel.resize.hidden && resizer.el.hide();
}
},
this);
},
doLayout: function () {},
getElementHeight: function (el) {
return parseInt(el.css("height"));
},
getElementWidth: function (el) {
return parseInt(el.css("width"));
},
onSelectStart: function (e) {
if (e.preventDefault) {
e.preventDefault();
}
return false;
},
addHandler: function (elem, type, handler) {
if (elem.addEventListener) {
elem.addEventListener(type, handler);
} else {
if (elem.attachEvent) {
elem.attachEvent("on" + type, handler);
} else {
elem["on" + type] = handler;
}
}
},
removeHandler: function (elem, type, handler) {
if (elem.removeEventListener) {
elem.removeEventListener(type, handler);
} else {
if (elem.detachEvent) {
elem.detachEvent("on" + type, handler);
} else {
elem["on" + type] = null;
}
}
},
clearSelection: function () {
if (window.getSelection) {
var selection = window.getSelection();
if (selection.empty) {
selection.empty();
} else {
if (selection.removeAllRanges) {
selection.removeAllRanges();
}
}
} else {
if (document.selection) {
document.selection.empty();
}
}
},
resizeStart: function (e) {
this.clearSelection();
this.addHandler(window.document, "selectstart", this.onSelectStart);
$(document).on({
mousemove: this.resize.eventMove,
mouseup: this.resize.eventStop
});
var panel = e.data.panel;
this.resize.type = e.data.type;
this.resize.$el = panel.el;
this.resize.min = panel.minpos;
this.resize.$el.addClass("move");
if (e.data.type == "vertical") {
this.resize.height = parseInt(this.resize.$el.css("height"));
this.resize.max = (panel.maxpos > 0 ? panel.maxpos : this.resize.$el.parent().height() + panel.maxpos) - this.resize.height;
this.resize.inity = e.pageY - parseInt(e.currentTarget.style.top);
} else {
if (e.data.type == "horizontal") {
this.resize.width = parseInt(this.resize.$el.css("width"));
this.resize.max = (panel.maxpos > 0 ? panel.maxpos : this.resize.$el.parent().height() + panel.maxpos) - this.resize.width;
this.resize.initx = e.pageX - parseInt(e.currentTarget.style.left);
}
}
},
resizeMove: function (e) {
if (this.resize.type == "vertical") {
var prop = "top",
value = e.pageY - this.resize.inity;
} else {
if (this.resize.type == "horizontal") {
prop = "left";
value = e.pageX - this.resize.initx;
}
}
if (! (value < this.resize.min) && !(value > this.resize.max)) {
this.resize.$el[0].style[prop] = value + "px";
}
},
resizeStop: function (e) {
this.removeHandler(window.document, "selectstart", this.onSelectStart);
$(document).off({
mousemove: this.resize.eventMove,
mouseup: this.resize.eventStop
});
if (this.resize.type == "vertical") {
var prop = "height";
var value = e.pageY - this.resize.inity;
} else {
if (this.resize.type == "horizontal") {
prop = "width";
value = e.pageX - this.resize.initx;
}
}
value < this.resize.min && (value = this.resize.min);
value > this.resize.max && (value = this.resize.max);
if (this.resize.$el.hasClass("after")) {
var panel = this.resize.$el.prev();
} else {
panel = this.resize.$el.next();
value = panel.parent()[prop]() - (value + this.resize[prop]);
}
panel.css(prop, value + "px");
this.resize.$el.removeClass("move");
delete this.resize.$el;
if (this.resize.value != value) {
this.doLayout();
this.trigger("layout:resizedrag", this);
}
}
}); ! Common.UI && (Common.UI = {});
Common.UI.VBoxLayout = function (options) {
BaseLayout.apply(this, arguments);
this.initialize.apply(this, arguments);
};
Common.UI.VBoxLayout.prototype = _.extend(new BaseLayout(), {
initialize: function (options) {
BaseLayout.prototype.initialize.call(this, options);
this.panels.forEach(function (panel) { ! panel.stretch && !panel.height && (panel.height = this.getElementHeight(panel.el));
if (panel.isresizer) {
panel.el.on("mousedown", {
type: "vertical",
panel: panel
},
_.bind(this.resizeStart, this));
}
},
this);
this.doLayout.call(this);
},
doLayout: function () {
var height = 0,
stretchable, style;
this.panels.forEach(function (panel) {
if (!panel.stretch) {
style = panel.el.is(":visible");
if (style) {
height += (panel.rely !== true ? panel.height : this.getElementHeight(panel.el));
}
if (panel.resize && panel.resize.autohide !== false && panel.resize.el) {
if (style) {
panel.resize.el.show();
stretchable && (height += panel.resize.height);
} else {
panel.resize.el.hide();
stretchable && (height -= panel.resize.height);
}
}
} else {
stretchable = panel;
}
},
this);
stretchable && (stretchable.height = this.$parent.height() - height);
height = 0;
this.panels.forEach(function (panel) {
if (panel.el.is(":visible")) {
style = {
top: height
};
panel.rely !== true && (style.height = panel.height);
panel.el.css(style);
height += this.getElementHeight(panel.el);
}
},
this);
}
});
Common.UI.HBoxLayout = function (options) {
BaseLayout.apply(this, arguments);
this.initialize.apply(this, arguments);
};
Common.UI.HBoxLayout.prototype = _.extend(new BaseLayout(), {
initialize: function (options) {
BaseLayout.prototype.initialize.call(this, options);
this.panels.forEach(function (panel) { ! panel.stretch && !panel.width && (panel.width = this.getElementWidth(panel.el));
if (panel.isresizer) {
panel.el.on("mousedown", {
type: "horizontal",
panel: panel
},
_.bind(this.resizeStart, this));
}
},
this);
this.doLayout.call(this);
},
doLayout: function (event) {
var width = 0,
stretchable, style;
this.panels.forEach(function (panel) {
if (!panel.stretch) {
style = panel.el.is(":visible");
if (style) {
width += (panel.rely !== true ? panel.width : this.getElementWidth(panel.el));
}
if (panel.resize && panel.resize.autohide !== false && panel.resize.el) {
if (style) {
panel.resize.el.show();
stretchable && (width -= panel.resize.width);
} else {
panel.resize.el.hide();
stretchable && (width -= panel.resize.width);
}
}
} else {
stretchable = panel;
}
},
this);
stretchable && (stretchable.width = this.$parent.width() - width);
width = 0;
this.panels.forEach(function (panel) {
if (panel.el.is(":visible")) {
style = {
left: width
};
panel.rely !== true && (style.width = panel.width);
panel.el.css(style);
width += this.getElementWidth(panel.el);
}
},
this);
}
});
Common.UI.VBoxLayout.prototype.constructor = Common.UI.VBoxLayout;
Common.UI.HBoxLayout.prototype.constructor = Common.UI.HBoxLayout;
});

View File

@@ -0,0 +1,76 @@
/*
* (c) Copyright Ascensio System SIA 2010-2015
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
if (Common === undefined) {
var Common = {};
}
define(["common/main/lib/component/DataView"], function () {
Common.UI.ListView = Common.UI.DataView.extend((function () {
return {
options: {
handleSelect: true,
enableKeyEvents: true,
showLast: true,
keyMoveDirection: "vertical",
itemTemplate: _.template('<div id="<%= id %>" class="list-item" style=""><%= value %></div>')
},
template: _.template(['<div class="listview inner"></div>'].join("")),
onAddItem: function (record, index) {
var view = new Common.UI.DataViewItem({
template: this.itemTemplate,
model: record
});
var idx = _.indexOf(this.store.models, record);
if (view) {
var innerEl = $(this.el).find(".inner");
if (innerEl) {
var innerDivs = innerEl.find("> div");
innerEl.find(".empty-text").remove();
if (idx > 0) {
$(innerDivs.get(idx - 1)).after(view.render().el);
} else {
(innerDivs.length > 0) ? $(innerDivs[idx]).before(view.render().el) : innerEl.append(view.render().el);
}
this.dataViewItems.push(view);
this.listenTo(view, "change", this.onChangeItem);
this.listenTo(view, "remove", this.onRemoveItem);
this.listenTo(view, "click", this.onClickItem);
this.listenTo(view, "dblclick", this.onDblClickItem);
this.listenTo(view, "select", this.onSelectItem);
if (!this.isSuspendEvents) {
this.trigger("item:add", this, view, record);
}
}
}
}
};
})());
});

View File

@@ -1,143 +1,99 @@
/*
* (c) Copyright Ascensio System SIA 2010-2014
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
Ext.define("Common.component.LoadMask", {
extend: "Ext.Component",
alias: "widget.cmdloadmask",
mixins: {
floating: "Ext.util.Floating"
},
useMsg: true,
disabled: false,
baseCls: "cmd-loadmask",
config: {
title: ""
},
renderTpl: ['<div style="position:relative" class="{baseCls}-body">', "<div>", '<div class="{baseCls}-image"></div>', '<div class="{baseCls}-title"></div>', "</div>", '<div class="{baseCls}-pwd-ct">', '<div class="{baseCls}-pwd-by">POWERED BY</div>', '<div class="{baseCls}-pwd-tm">ONLYOFFICE</div>', "</div>", "</div>"],
modal: true,
width: "auto",
floating: {
shadow: false
},
focusOnToFront: false,
constructor: function (el, config) {
var me = this;
if (el.isComponent) {
me.ownerCt = el;
me.bindComponent(el);
} else {
me.ownerCt = new Ext.Component({
el: Ext.get(el),
rendered: true,
componentLayoutCounter: 1
});
me.container = el;
}
me.callParent([config]);
me.renderSelectors = {
titleEl: "." + me.baseCls + "-title"
};
},
bindComponent: function (comp) {
this.mon(comp, {
resize: this.onComponentResize,
scope: this
});
},
applyTitle: function (title) {
var me = this;
me.title = title;
if (me.rendered) {
me.titleEl.update(me.title);
var parent = me.floatParent ? me.floatParent.getTargetEl() : me.container;
var xy = me.getEl().getAlignToXY(parent, "c-c");
var pos = parent.translatePoints(xy[0], xy[1]);
if (Ext.isDefined(pos.left) || Ext.isDefined(pos.top)) {
me.setPosition(pos.left, pos.top);
}
}
},
afterRender: function () {
this.callParent(arguments);
this.container = this.floatParent.getContentTarget();
},
onComponentResize: function () {
var me = this;
if (me.rendered && me.isVisible()) {
me.toFront();
me.center();
}
},
onDisable: function () {
this.callParent(arguments);
if (this.loading) {
this.onLoad();
}
},
onBeforeLoad: function () {
var me = this,
owner = me.ownerCt || me.floatParent,
origin;
if (!this.disabled) {
if (owner.componentLayoutCounter) {
Ext.Component.prototype.show.call(me);
} else {
origin = owner.afterComponentLayout;
owner.afterComponentLayout = function () {
owner.afterComponentLayout = origin;
origin.apply(owner, arguments);
if (me.loading) {
Ext.Component.prototype.show.call(me);
}
};
}
}
},
onHide: function () {
var me = this;
me.callParent(arguments);
me.showOnParentShow = true;
},
onShow: function () {
var me = this;
me.callParent(arguments);
me.loading = true;
me.setTitle(me.title);
},
afterShow: function () {
this.callParent(arguments);
this.center();
},
onLoad: function () {
this.loading = false;
Ext.Component.prototype.hide.call(this);
}
/*
* (c) Copyright Ascensio System SIA 2010-2015
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
if (Common === undefined) {
var Common = {};
}
define(["common/main/lib/component/BaseView"], function () {
Common.UI.LoadMask = Common.UI.BaseView.extend((function () {
var ownerEl, maskeEl, loaderEl;
return {
options: {
cls: "",
style: "",
title: "Loading...",
owner: document.body
},
template: _.template(['<div id="<%= id %>" class="asc-loadmask-body <%= cls %>" role="presentation" tabindex="-1">', '<div class="asc-loadmask-image"></div>', '<div class="asc-loadmask-title"><%= title %></div>', "</div>"].join("")),
initialize: function (options) {
Common.UI.BaseView.prototype.initialize.call(this, options);
this.template = this.options.template || this.template;
this.cls = this.options.cls;
this.style = this.options.style;
this.title = this.options.title;
this.owner = this.options.owner;
},
render: function () {
return this;
},
show: function () {
if (maskeEl || loaderEl) {
return;
}
ownerEl = (this.owner instanceof Common.UI.BaseView) ? $(this.owner.el) : $(this.owner);
if (ownerEl.hasClass("masked")) {
return this;
}
var me = this;
maskeEl = $('<div class="asc-loadmask"></div>');
loaderEl = $(this.template({
id: me.id,
cls: me.cls,
style: me.style,
title: me.title
}));
ownerEl.addClass("masked");
ownerEl.append(maskeEl);
ownerEl.append(loaderEl);
loaderEl.css({
top: Math.round(ownerEl.height() / 2 - (loaderEl.height() + parseInt(loaderEl.css("padding-top")) + parseInt(loaderEl.css("padding-bottom"))) / 2) + "px",
left: Math.round(ownerEl.width() / 2 - (loaderEl.width() + parseInt(loaderEl.css("padding-left")) + parseInt(loaderEl.css("padding-right"))) / 2) + "px"
});
Common.util.Shortcuts.suspendEvents();
return this;
},
hide: function () {
ownerEl && ownerEl.removeClass("masked");
maskeEl && maskeEl.remove();
loaderEl && loaderEl.remove();
maskeEl = null;
loaderEl = null;
Common.util.Shortcuts.resumeEvents();
},
setTitle: function (title) {
this.title = title;
if (ownerEl && ownerEl.hasClass("masked") && loaderEl) {
$(".asc-loadmask-title", loaderEl).html(title);
}
}
};
})());
});

View File

@@ -0,0 +1,76 @@
/*
* (c) Copyright Ascensio System SIA 2010-2015
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
if (Common === undefined) {
var Common = {};
}
define(["common/main/lib/component/BaseView"], function () {
Common.UI.MaskedField = Common.UI.BaseView.extend({
options: {
maskExp: "",
maxLength: 999
},
initialize: function (options) {
Common.UI.BaseView.prototype.initialize.call(this, options);
var me = this,
el = $(this.el);
el.addClass("masked-field");
el.attr("maxlength", me.options.maxLength);
el.on("keypress", function (e) {
var charCode = String.fromCharCode(e.which);
if (!me.options.maskExp.test(charCode) && !e.ctrlKey && e.keyCode !== Common.UI.Keys.DELETE && e.keyCode !== Common.UI.Keys.BACKSPACE && e.keyCode !== Common.UI.Keys.LEFT && e.keyCode !== Common.UI.Keys.RIGHT && e.keyCode !== Common.UI.Keys.HOME && e.keyCode !== Common.UI.Keys.END && e.keyCode !== Common.UI.Keys.ESC && e.keyCode !== Common.UI.Keys.INSERT && e.keyCode !== Common.UI.Keys.TAB) {
if (e.keyCode == Common.UI.Keys.RETURN) {
me.trigger("changed", me, el.val());
}
e.preventDefault();
e.stopPropagation();
}
});
el.on("input", function (e) {
me.trigger("change", me, el.val());
});
el.on("blur", function (e) {
me.trigger("changed", me, el.val());
});
},
render: function () {
return this;
},
setValue: function (value) {
if (this.options.maskExp.test(value) && value.length <= this.options.maxLength) {
$(this.el).val(value);
}
},
getValue: function () {
$(this.el).val();
}
});
});

View File

@@ -0,0 +1,417 @@
/*
* (c) Copyright Ascensio System SIA 2010-2015
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
if (Common === undefined) {
var Common = {};
}
define(["common/main/lib/extend/Bootstrap", "common/main/lib/component/BaseView", "common/main/lib/component/MenuItem", "common/main/lib/component/Scroller"], function () {
Common.UI.Menu = (function () {
var manager = (function () {
var active = [],
menus = {};
return {
register: function (menu) {
menus[menu.id] = menu;
menu.on("show:after", function (m) {
active.push(m);
}).on("hide:after", function (m) {
var index = active.indexOf(m);
if (index > -1) {
active.splice(index, 1);
}
});
},
unregister: function (menu) {
var index = active.indexOf(menu);
delete menus[menu.id];
if (index > -1) {
active.splice(index, 1);
}
menu.off("show:after").off("hide:after");
},
hideAll: function () {
Common.NotificationCenter.trigger("menumanager:hideall");
if (active && active.length > 0) {
_.each(active, function (menu) {
menu.hide();
});
return true;
}
return false;
}
};
})();
return _.extend(Common.UI.BaseView.extend({
options: {
cls: "",
style: "",
itemTemplate: null,
items: [],
menuAlign: "tl-bl",
menuAlignEl: null,
offset: [0, 0]
},
template: _.template(['<ul class="dropdown-menu <%= options.cls %>" style="<%= options.style %>" role="menu"></ul>'].join("")),
initialize: function (options) {
Common.UI.BaseView.prototype.initialize.call(this, options);
var me = this;
this.id = this.options.id || Common.UI.getId();
this.itemTemplate = this.options.itemTemplate || Common.UI.MenuItem.prototype.template;
this.rendered = false;
this.items = [];
this.offset = [0, 0];
this.menuAlign = this.options.menuAlign;
this.menuAlignEl = this.options.menuAlignEl;
_.each(this.options.items, function (item) {
if (item instanceof Common.UI.MenuItem) {
me.items.push(item);
} else {
me.items.push(new Common.UI.MenuItem(_.extend({
tagName: "li",
template: me.itemTemplate
},
item)));
}
});
if (this.options.el) {
this.render();
}
manager.register(this);
},
remove: function () {
manager.unregister(this);
Common.UI.BaseView.prototype.remove.call(this);
},
render: function (parentEl) {
var me = this;
this.trigger("render:before", this);
this.cmpEl = $(this.el);
if (parentEl) {
this.setElement(parentEl, false);
if (!me.rendered) {
this.cmpEl = $(this.template({
options: me.options
}));
parentEl.append(this.cmpEl);
}
} else {
if (!me.rendered) {
this.cmpEl = this.template({
options: me.options
});
$(this.el).append(this.cmpEl);
}
}
var rootEl = this.cmpEl.parent(),
menuRoot = (rootEl.attr("role") === "menu") ? rootEl : rootEl.find("[role=menu]");
if (menuRoot) {
if (!me.rendered) {
_.each(me.items || [], function (item) {
menuRoot.append(item.render().el);
item.on("click", _.bind(me.onItemClick, me));
item.on("toggle", _.bind(me.onItemToggle, me));
});
}
menuRoot.css({
"max-height": me.options.maxHeight || "none",
position: "fixed",
right: "auto",
left: -1000,
top: -1000
});
this.parentEl = menuRoot.parent();
this.parentEl.on("show.bs.dropdown", _.bind(me.onBeforeShowMenu, me));
this.parentEl.on("shown.bs.dropdown", _.bind(me.onAfterShowMenu, me));
this.parentEl.on("hide.bs.dropdown", _.bind(me.onBeforeHideMenu, me));
this.parentEl.on("hidden.bs.dropdown", _.bind(me.onAfterHideMenu, me));
this.parentEl.on("keydown.after.bs.dropdown", _.bind(me.onAfterKeydownMenu, me));
menuRoot.on("scroll", _.bind(me.onScroll, me));
menuRoot.hover(function (e) {
me.isOver = true;
},
function (e) {
me.isOver = false;
});
}
this.rendered = true;
this.trigger("render:after", this);
return this;
},
isVisible: function () {
return this.rendered && (this.cmpEl.is(":visible"));
},
show: function () {
if (this.rendered && this.parentEl && !this.parentEl.hasClass("open")) {
this.cmpEl.dropdown("toggle");
}
},
hide: function () {
if (this.rendered && this.parentEl && this.parentEl.hasClass("open")) {
this.cmpEl.dropdown("toggle");
}
},
insertItem: function (index, item) {
var me = this,
el = this.cmpEl;
if (! (item instanceof Common.UI.MenuItem)) {
item = new Common.UI.MenuItem(_.extend({
tagName: "li",
template: me.itemTemplate
},
item));
}
if (index < 0 || index >= me.items.length) {
me.items.push(item);
} else {
me.items.splice(index, 0, item);
}
if (this.rendered) {
var menuRoot = (el.attr("role") === "menu") ? el : el.find("[role=menu]");
if (menuRoot) {
if (index < 0) {
menuRoot.append(item.render().el);
} else {
if (index === 0) {
menuRoot.prepend(item.render().el);
} else {
$("li:nth-child(" + index + ")", menuRoot).before(item.render().el);
}
}
item.on("click", _.bind(me.onItemClick, me));
item.on("toggle", _.bind(me.onItemToggle, me));
}
}
},
doLayout: function () {
if (this.options.maxHeight > 0) {
if (!this.rendered) {
this.mustLayout = true;
return;
}
var me = this,
el = this.cmpEl;
var menuRoot = (el.attr("role") === "menu") ? el : el.find("[role=menu]");
if (!menuRoot.is(":visible")) {
var pos = [menuRoot.css("left"), menuRoot.css("top")];
menuRoot.css({
left: "-1000px",
top: "-1000px",
display: "block"
});
}
var $items = menuRoot.find("li");
if ($items.height() * $items.length > this.options.maxHeight) {
var scroll = '<div class="menu-scroll top"></div>';
menuRoot.prepend(scroll);
scroll = '<div class="menu-scroll bottom"></div>';
menuRoot.append(scroll);
menuRoot.css({
"box-shadow": "none",
"overflow-y": "hidden",
"padding-top": "18px"
});
menuRoot.find("> li:last-of-type").css("margin-bottom", 18);
var addEvent = function (elem, type, fn) {
elem.addEventListener ? elem.addEventListener(type, fn, false) : elem.attachEvent("on" + type, fn);
};
var eventname = (/Firefox/i.test(navigator.userAgent)) ? "DOMMouseScroll" : "mousewheel";
addEvent(menuRoot[0], eventname, _.bind(this.onMouseWheel, this));
menuRoot.find(".menu-scroll").on("click", _.bind(this.onScrollClick, this));
}
if (pos) {
menuRoot.css({
display: "",
left: pos[0],
top: pos[1]
});
}
}
},
addItem: function (item) {
this.insertItem(-1, item);
},
removeItem: function (item) {
var me = this,
index = me.items.indexOf(item);
if (index > -1) {
me.items.splice(index, 1);
item.off("click").off("toggle");
item.remove();
}
},
removeAll: function () {
var me = this;
_.each(me.items, function (item) {
item.off("click").off("toggle");
item.remove();
});
me.items = [];
},
onBeforeShowMenu: function (e) {
if (this.mustLayout) {
delete this.mustLayout;
this.doLayout.call(this);
}
this.trigger("show:before", this, e);
this.alignPosition();
},
onAfterShowMenu: function (e) {
this.trigger("show:after", this, e);
if (this.$el.find("> ul > .menu-scroll").length) {
var el = this.$el.find("li .checked")[0];
if (el) {
var offset = el.offsetTop - this.options.maxHeight / 2;
this.scrollMenu(offset < 0 ? 0 : offset);
}
}
},
onBeforeHideMenu: function (e) {
this.trigger("hide:before", this, e);
if (Common.UI.Scroller.isMouseCapture()) {
e.preventDefault();
}
},
onAfterHideMenu: function (e) {
this.trigger("hide:after", this, e);
},
onAfterKeydownMenu: function (e) {
if (e.keyCode == Common.UI.Keys.RETURN) {
var li = $(e.target).closest("li");
if (li.length <= 0) {
li = $(e.target).parent().find("li .dataview");
}
if (li.length > 0) {
li.click();
}
} else {
if (e.keyCode == Common.UI.Keys.UP || e.keyCode == Common.UI.Keys.DOWN) {
this.fromKeyDown = true;
}
}
},
onScroll: function (item, e) {
if (this.fromKeyDown) {
var menuRoot = (this.cmpEl.attr("role") === "menu") ? this.cmpEl : this.cmpEl.find("[role=menu]");
menuRoot.find(".menu-scroll.top").css("top", menuRoot.scrollTop() + "px");
menuRoot.find(".menu-scroll.bottom").css("bottom", (-menuRoot.scrollTop()) + "px");
}
},
onItemClick: function (item, e) {
if (!item.menu) {
this.isOver = false;
}
if (item.options.stopPropagation) {
e.stopPropagation();
var me = this;
_.delay(function () {
me.$el.parent().parent().find("[data-toggle=dropdown]").focus();
},
10);
return;
}
this.trigger("item:click", this, item, e);
},
onItemToggle: function (item, state, e) {
this.trigger("item:toggle", this, item, state, e);
},
onScrollClick: function (e) {
this.scrollMenu(/top/.test(e.currentTarget.className));
return false;
},
onMouseWheel: function (e) {
this.scrollMenu(((e.detail && -e.detail) || e.wheelDelta) > 0);
},
scrollMenu: function (up) {
this.fromKeyDown = false;
var menuRoot = (this.cmpEl.attr("role") === "menu") ? this.cmpEl : this.cmpEl.find("[role=menu]"),
value = typeof(up) === "boolean" ? menuRoot.scrollTop() + (up ? -20 : 20) : up;
menuRoot.scrollTop(value);
menuRoot.find(".menu-scroll.top").css("top", menuRoot.scrollTop() + "px");
menuRoot.find(".menu-scroll.bottom").css("bottom", (-menuRoot.scrollTop()) + "px");
},
setOffset: function (offsetX, offsetY) {
this.offset[0] = _.isUndefined(offsetX) ? this.offset[0] : offsetX;
this.offset[1] = _.isUndefined(offsetY) ? this.offset[1] : offsetY;
this.alignPosition();
},
getOffset: function () {
return this.offset;
},
alignPosition: function () {
var menuRoot = (this.cmpEl.attr("role") === "menu") ? this.cmpEl : this.cmpEl.find("[role=menu]"),
menuParent = this.menuAlignEl || menuRoot.parent(),
m = this.menuAlign.match(/^([a-z]+)-([a-z]+)/),
offset = menuParent.offset(),
docW = Math.min($(document).width(), $("body").width()),
docH = $(document).height() - 10,
menuW = menuRoot.outerWidth(),
menuH = menuRoot.outerHeight(),
parentW = menuParent.outerWidth(),
parentH = menuParent.outerHeight();
var posMenu = {
"tl": [0, 0],
"bl": [0, menuH],
"tr": [menuW, 0],
"br": [menuW, menuH]
};
var posParent = {
"tl": [0, 0],
"tr": [parentW, 0],
"bl": [0, parentH],
"br": [parentW, parentH]
};
var left = offset.left - posMenu[m[1]][0] + posParent[m[2]][0] + this.offset[0];
var top = offset.top - posMenu[m[1]][1] + posParent[m[2]][1] + this.offset[1];
if (left + menuW > docW) {
if (menuParent.is("li.dropdown-submenu")) {
left = offset.left - menuW + 2;
} else {
left = docW - menuW;
}
}
if (top + menuH > docH) {
top = docH - menuH;
}
if (top < 0) {
top = 0;
}
menuRoot.css({
left: left,
top: top
});
}
}), {
Manager: (function () {
return manager;
})()
});
})();
});

View File

@@ -1,82 +0,0 @@
/*
* (c) Copyright Ascensio System SIA 2010-2014
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
Ext.define("Common.component.MenuDataViewPicker", {
extend: "Ext.menu.Menu",
alias: "widget.cmdmenudataviewpicker",
requires: ["Common.component.DataViewPicker"],
hideOnClick: true,
hideMode: "display",
constructor: function (config) {
if (!config || !config.viewData) {
throw Error("Common.component.MenuDataViewPicker creation failed: required parameters are missing.");
}
this.initConfig(config);
this.callParent(arguments);
return this;
},
initComponent: function () {
var me = this,
cfg = Ext.apply({},
me.initialConfig);
delete cfg.listeners;
Ext.apply(me, {
plain: true,
showSeparator: false,
items: Ext.applyIf({
xtype: "cmddataviewpicker",
padding: (Ext.isDefined(cfg.pickerpadding)) ? cfg.pickerpadding : "2px 4px 1px 2px",
store: cfg.store
},
cfg)
});
me.callParent(arguments);
me.picker = me.down("cmddataviewpicker");
me.relayEvents(me.picker, ["select", "itemmouseenter", "itemmouseleave"]);
if (me.hideOnClick) {
me.on("select", me.hidePickerOnSelect, me);
}
me.on("resize", function (cnt, adjWidth, adjHeight, eOpts) {
if (me.applyContentWidth && adjWidth >= 20) {
me.picker.contentWidth = adjWidth - 20;
}
me.picker.setSize(adjWidth, adjHeight);
},
this);
me.on("show", function (cnt) {
me.picker.showUpdated();
},
this);
},
hidePickerOnSelect: function (picker, columns, rows) {
Ext.menu.Manager.hideAll();
}
});

View File

@@ -0,0 +1,227 @@
/*
* (c) Copyright Ascensio System SIA 2010-2015
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
if (Common === undefined) {
var Common = {};
}
define(["common/main/lib/component/BaseView", "common/main/lib/component/ToggleManager"], function () {
Common.UI.MenuItem = Common.UI.BaseView.extend({
options: {
id: null,
cls: "",
style: "",
hint: false,
checkable: false,
checked: false,
allowDepress: false,
disabled: false,
value: null,
toggleGroup: null,
iconCls: "",
menu: null,
canFocused: true
},
tagName: "li",
template: _.template(['<a id="<%= id %>" style="<%= style %>" <% if(options.canFocused) { %> tabindex="-1" type="menuitem" <% }; if(!_.isUndefined(options.stopPropagation)) { %> data-stopPropagation="true" <% }; %> >', "<% if (!_.isEmpty(iconCls)) { %>", '<span class="menu-item-icon <%= iconCls %>"></span>', "<% } %>", "<%= caption %>", "</a>"].join("")),
initialize: function (options) {
Common.UI.BaseView.prototype.initialize.call(this, options);
var me = this,
el = $(this.el);
this.id = me.options.id || Common.UI.getId();
this.cls = me.options.cls;
this.style = me.options.style;
this.caption = me.options.caption;
this.menu = me.options.menu || null;
this.checkable = me.options.checkable;
this.checked = me.options.checked;
me.allowDepress = me.options.allowDepress;
this.disabled = me.options.disabled;
this.value = me.options.value;
this.toggleGroup = me.options.toggleGroup;
this.template = me.options.template || this.template;
this.iconCls = me.options.iconCls;
this.rendered = false;
if (this.menu !== null && !(this.menu instanceof Common.UI.Menu)) {
this.menu = new Common.UI.Menu(_.extend({},
me.options.menu));
}
if (me.options.el) {
this.render();
}
},
render: function () {
var me = this,
el = $(this.el);
me.trigger("render:before", me);
if (me.caption === "--") {
el.addClass("divider");
} else {
if (!this.rendered) {
el.off("click");
Common.UI.ToggleManager.unregister(me);
$(this.el).html(this.template({
id: me.id,
caption: me.caption,
iconCls: me.iconCls,
style: me.style,
options: me.options
}));
if (me.menu) {
el.addClass("dropdown-submenu");
me.menu.render($(this.el));
el.mouseenter(_.bind(me.menu.alignPosition, me.menu));
el.focusout(_.bind(me.onBlurItem, me));
el.hover(_.bind(me.onHoverItem, me), _.bind(me.onUnHoverItem, me));
}
var firstChild = el.children(":first");
if (this.checkable && firstChild) {
firstChild.toggleClass("checkable", this.checkable);
firstChild.toggleClass("checked", this.checked);
if (!_.isEmpty(this.iconCls)) {
firstChild.css("background-image", "none");
}
}
if (this.disabled) {
$(this.el).toggleClass("disabled", this.disabled);
}
el.on("click", _.bind(this.onItemClick, this));
el.on("mousedown", _.bind(this.onItemMouseDown, this));
Common.UI.ToggleManager.register(me);
}
}
me.cmpEl = $(this.el);
me.rendered = true;
me.trigger("render:after", me);
return this;
},
setCaption: function (caption) {
this.caption = caption;
if (this.rendered) {
this.cmpEl.find("a").contents().last()[0].textContent = Common.Utils.String.htmlEncode(caption);
}
},
setChecked: function (check, suppressEvent) {
this.toggle(check, suppressEvent);
},
isChecked: function () {
return this.checked;
},
setDisabled: function (disabled) {
this.disabled = !!disabled;
if (this.rendered) {
this.cmpEl.toggleClass("disabled", this.disabled);
}
},
isDisabled: function () {
return this.disabled;
},
toggle: function (toggle, suppressEvent) {
var state = toggle === undefined ? !this.checked : !!toggle;
if (this.checkable) {
this.checked = state;
if (this.rendered) {
var firstChild = this.cmpEl.children(":first");
if (firstChild) {
firstChild.toggleClass("checked", this.checked);
if (!_.isEmpty(this.iconCls)) {
firstChild.css("background-image", "none");
}
}
}
if (!suppressEvent) {
this.trigger("toggle", this, state);
}
}
},
onItemMouseDown: function (e) {
if (e.which != 1) {
e.preventDefault();
e.stopPropagation();
return false;
}
},
onItemClick: function (e) {
if (e.which != 1 && (e.which !== undefined || this.menu)) {
return false;
}
if (!this.disabled && (this.allowDepress || !(this.checked && this.toggleGroup))) {
this.setChecked(!this.checked);
}
if (this.menu) {
if (e.target.id == this.id) {
return false;
}
if (!this.menu.isOver) {
this.cmpEl.removeClass("over");
}
return;
}
if (!this.disabled) {
this.trigger("click", this, e);
} else {
return false;
}
},
onHoverItem: function (e) {
this._doHover(e);
},
onUnHoverItem: function (e) {
this._doUnHover(e);
},
onBlurItem: function (e) {
this._doUnHover(e);
},
_doHover: function (e) {
var me = this;
if (me.menu && !me.disabled) {
clearTimeout(me.hideMenuTimer);
me.cmpEl.trigger("show.bs.dropdown");
me.expandMenuTimer = _.delay(function () {
me.cmpEl.addClass("over");
me.cmpEl.trigger("shown.bs.dropdown");
},
200);
}
},
_doUnHover: function (e) {
var me = this;
if (me.menu && !me.disabled) {
clearTimeout(me.expandMenuTimer);
me.hideMenuTimer = _.delay(function () {
if (!me.menu.isOver) {
me.cmpEl.removeClass("over");
}
},
200);
}
}
});
});

View File

@@ -1,254 +1,463 @@
/*
* (c) Copyright Ascensio System SIA 2010-2014
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
Ext.define("Common.component.MetricSpinner", {
extend: "Ext.form.field.Spinner",
alias: "widget.commonmetricspinner",
defaultUnit: "px",
minValue: 0,
maxValue: 100,
step: 1,
textAlign: "right",
allowAuto: false,
autoText: "Auto",
mouseWheelEnabled: false,
constructor: function (config) {
var add = function (a, b, precision) {
var x = Math.pow(10, precision || 2);
return (Math.round(a * x) + Math.round(b * x)) / x;
};
var oldValue = this.minValue;
this.setValue = function (value, suspendchange) {
if (!Ext.isDefined(value) || value === "") {
this.value = "";
} else {
if (this.allowAuto && (Math.abs(parseFloat(value) + 1) < 0.0001 || value == this.autoText)) {
this.value = this.autoText;
} else {
var number = add(parseFloat(value), 0, 3);
if (!Ext.isDefined(number) || isNaN(number)) {
number = oldValue;
}
var units = this.defaultUnit;
if (Ext.isDefined(value.match)) {
var searchUnits = value.match(/(px|em|%|en|ex|pt|in|cm|mm|pc|s|ms)$/i);
if (null !== searchUnits && Ext.isDefined(searchUnits[0])) {
units = searchUnits[0].toLowerCase();
}
}
if (this.defaultUnit !== units) {
number = this._recalcUnits(number, units);
}
if (number > this.maxValue) {
number = this.maxValue;
}
if (number < this.minValue) {
number = this.minValue;
}
this.value = (number + " " + this.defaultUnit).trim();
oldValue = number;
}
}
if (suspendchange !== true) {
this.checkChange();
}
var setFn = function (value) {
this.setRawValue(value);
};
if (this.rendered) {
setFn.call(this, this.value);
} else {
this.on("afterrender", Ext.bind(setFn, this, [this.value]), {
single: true
});
}
};
this.onSpinUp = function () {
var me = this;
if (!me.readOnly) {
var val = me.step;
if (me.getValue() !== "") {
if (me.allowAuto && me.getValue() == me.autoText) {
val = me.minValue - me.step;
} else {
val = parseFloat(me.getValue());
}
if (isNaN(val)) {
val = oldValue;
}
} else {
val = me.minValue - me.step;
}
me.setValue((add(val, me.step, 3) + " " + this.defaultUnit).trim(), true);
}
};
this.onSpinDown = function () {
var me = this;
if (!me.readOnly) {
var val = me.step;
if (me.getValue() !== "") {
if (me.allowAuto && me.getValue() == me.autoText) {
val = me.minValue;
} else {
val = parseFloat(me.getValue());
}
if (isNaN(val)) {
val = oldValue;
}
if (me.allowAuto && add(val, -me.step, 3) < me.minValue) {
me.setValue(me.autoText, true);
return;
}
} else {
val = me.minValue;
}
me.setValue((add(val, -me.step, 3) + " " + this.defaultUnit).trim(), true);
}
};
this.callParent(arguments);
},
initComponent: function () {
if (!Ext.isDefined(this.value)) {
this.value = (this.minValue + " " + this.defaultUnit).trim();
}
this.on("specialkey", function (f, e) {
if (e.getKey() == e.ENTER) {
this.onEnterValue();
e.stopEvent();
}
},
this);
this.callParent(arguments);
},
setDefaultUnit: function (unit) {
if (this.defaultUnit != unit) {
var oldUnit = this.defaultUnit;
this.defaultUnit = unit;
this.setMinValue(this._recalcUnits(this.minValue, oldUnit));
this.setMaxValue(this._recalcUnits(this.maxValue, oldUnit));
this.setValue(this._recalcUnits(this.getNumberValue(), oldUnit), true);
}
},
setMinValue: function (unit) {
this.minValue = unit;
},
setMaxValue: function (unit) {
this.maxValue = unit;
},
setStep: function (step) {
this.step = step;
},
getNumberValue: function () {
if (this.allowAuto && this.value == this.autoText) {
return -1;
} else {
return parseFloat(this.value);
}
},
getUnitValue: function () {
return this.defaultUnit;
},
getValue: function () {
return this.value;
},
onEnterValue: function () {
if (Ext.isDefined(this.inputEl)) {
var val = this.inputEl.getValue();
this.setValue((val === "") ? this.value : val);
}
},
afterRender: function () {
var me = this;
this.callParent(arguments);
if (this.inputEl) {
Ext.DomHelper.applyStyles(this.inputEl, Ext.String.format("text-align:{0}", this.textAlign));
}
if (this.triggerRepeater) {
this.triggerRepeater.on("mouseup", function () {
me.checkChange();
},
this);
}
},
onBlur: function (field, eOpt) {
if (Ext.isDefined(this.inputEl)) {
var val = this.inputEl.getValue();
this.setValue((val === "") ? this.value : val);
}
},
_recalcUnits: function (value, fromUnit) {
if (fromUnit.match(/(s|ms)$/i) && this.defaultUnit.match(/(s|ms)$/i)) {
var v_out = value;
if (fromUnit == "ms") {
v_out = v_out / 1000;
}
if (this.defaultUnit == "ms") {
v_out = v_out * 1000;
}
return v_out;
}
if (fromUnit.match(/(pt|in|cm|mm|pc)$/i) === null || this.defaultUnit.match(/(pt|in|cm|mm|pc)$/i) === null) {
return value;
}
var v_out = value;
if (fromUnit == "cm") {
v_out = v_out * 10;
} else {
if (fromUnit == "pt") {
v_out = v_out * 25.4 / 72;
} else {
if (fromUnit == "in") {
v_out = v_out * 25.4;
} else {
if (fromUnit == "pc") {
v_out = v_out * 25.4 / 6;
}
}
}
}
if (this.defaultUnit == "cm") {
v_out = v_out / 10;
} else {
if (this.defaultUnit == "pt") {
v_out = parseFloat(Ext.Number.toFixed(v_out * 72 / 25.4, 3));
} else {
if (this.defaultUnit == "in") {
v_out = v_out / 25.4;
} else {
if (this.defaultUnit == "pc") {
v_out = v_out * 6 / 25.4;
}
}
}
}
return v_out;
}
/*
* (c) Copyright Ascensio System SIA 2010-2015
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
if (Common === undefined) {
var Common = {};
}
define(["common/main/lib/component/BaseView"], function () {
Common.UI.MetricSpinner = Common.UI.BaseView.extend({
options: {
minValue: 0,
maxValue: 100,
step: 1,
defaultUnit: "px",
allowAuto: false,
autoText: "Auto",
hold: true,
speed: "medium",
width: 90,
allowDecimal: true
},
disabled: false,
value: "0 px",
rendered: false,
template: '<input type="text" class="form-control">' + '<div class="spinner-buttons">' + '<button type="button" class="spinner-up"><i></i></button>' + '<button type="button" class="spinner-down"><i></i></button>' + "</div>",
initialize: function (options) {
Common.UI.BaseView.prototype.initialize.call(this, options);
var me = this,
el = $(this.el);
el.addClass("spinner");
el.on("mousedown", ".spinner-up", _.bind(this.onMouseDown, this, true));
el.on("mousedown", ".spinner-down", _.bind(this.onMouseDown, this, false));
el.on("mouseup", ".spinner-up", _.bind(this.onMouseUp, this, true));
el.on("mouseup", ".spinner-down", _.bind(this.onMouseUp, this, false));
el.on("mouseover", ".spinner-up, .spinner-down", _.bind(this.onMouseOver, this));
el.on("mouseout", ".spinner-up, .spinner-down", _.bind(this.onMouseOut, this));
el.on("keydown", ".form-control", _.bind(this.onKeyDown, this));
el.on("keyup", ".form-control", _.bind(this.onKeyUp, this));
el.on("blur", ".form-control", _.bind(this.onBlur, this));
el.on("input", ".form-control", _.bind(this.onInput, this));
if (!this.options.allowDecimal) {
el.on("keypress", ".form-control", _.bind(this.onKeyPress, this));
}
this.switches = {
count: 1,
enabled: true,
fromKeyDown: false
};
if (this.options.speed === "medium") {
this.switches.speed = 300;
} else {
if (this.options.speed === "fast") {
this.switches.speed = 100;
} else {
this.switches.speed = 500;
}
}
this.render();
if (this.options.disabled) {
this.setDisabled(this.options.disabled);
}
if (this.options.value !== undefined) {
this.value = this.options.value;
}
this.setRawValue(this.value);
if (this.options.width) {
$(this.el).width(this.options.width);
}
if (this.options.defaultValue === undefined) {
this.options.defaultValue = this.options.minValue;
}
this.oldValue = this.options.minValue;
this.lastValue = null;
},
render: function () {
var el = $(this.el);
el.html(this.template);
this.$input = el.find(".form-control");
this.rendered = true;
if (this.options.tabindex != undefined) {
this.$input.attr("tabindex", this.options.tabindex);
}
return this;
},
setDisabled: function (disabled) {
var el = $(this.el);
if (disabled !== this.disabled) {
el.find("button").toggleClass("disabled", disabled);
el.toggleClass("disabled", disabled);
(disabled) ? this.$input.attr({
disabled: disabled
}) : this.$input.removeAttr("disabled");
}
this.disabled = disabled;
},
isDisabled: function () {
return this.disabled;
},
setDefaultUnit: function (unit) {
if (this.options.defaultUnit != unit) {
var oldUnit = this.options.defaultUnit;
this.options.defaultUnit = unit;
this.setMinValue(this._recalcUnits(this.options.minValue, oldUnit));
this.setMaxValue(this._recalcUnits(this.options.maxValue, oldUnit));
this.setValue(this._recalcUnits(this.getNumberValue(), oldUnit), true);
}
},
setMinValue: function (unit) {
this.options.minValue = unit;
},
setMaxValue: function (unit) {
this.options.maxValue = unit;
},
setStep: function (step) {
this.options.step = step;
},
getNumberValue: function () {
if (this.options.allowAuto && this.value == this.options.autoText) {
return -1;
} else {
return parseFloat(this.value);
}
},
getUnitValue: function () {
return this.options.defaultUnit;
},
getValue: function () {
return this.value;
},
setRawValue: function (value) {
if (this.$input) {
this.$input.val(value);
}
},
setValue: function (value, suspendchange) {
var showError = false;
this._fromKeyDown = false;
this.lastValue = this.value;
if (typeof value === "undefined" || value === "") {
this.value = "";
} else {
if (this.options.allowAuto && (Math.abs(parseFloat(value) + 1) < 0.0001 || value == this.options.autoText)) {
this.value = this.options.autoText;
} else {
var number = this._add(parseFloat(value), 0, (this.options.allowDecimal) ? 3 : 0);
if (typeof value === "undefined" || isNaN(number)) {
number = this.oldValue;
showError = true;
}
var units = this.options.defaultUnit;
if (typeof value.match !== "undefined") {
var searchUnits = value.match(/(px|em|%|en|ex|pt|in|cm|mm|pc|s|ms)$/i);
if (null !== searchUnits && searchUnits[0] !== "undefined") {
units = searchUnits[0].toLowerCase();
}
}
if (this.options.defaultUnit !== units) {
number = this._recalcUnits(number, units);
}
if (number > this.options.maxValue) {
number = this.options.maxValue;
showError = true;
}
if (number < this.options.minValue) {
number = this.options.minValue;
showError = true;
}
this.value = (number + " " + this.options.defaultUnit).trim();
this.oldValue = number;
}
}
if (suspendchange !== true && this.lastValue !== this.value) {
this.trigger("change", this, this.value, this.lastValue);
}
if (suspendchange !== true && showError) {
this.trigger("inputerror", this, this.value);
}
if (this.rendered) {
this.setRawValue(this.value);
} else {
this.options.value = this.value;
}
},
onMouseDown: function (type, e) {
if (this.disabled) {
return;
}
if (e) {
$(e.currentTarget).addClass("active");
}
if (this.options.hold) {
this.switches.fromKeyDown = false;
this._startSpin(type, e);
}
},
onMouseUp: function (type, e) {
if (this.disabled) {
return;
}
$(e.currentTarget).removeClass("active");
if (this.options.hold) {
this._stopSpin();
} else {
this._step(type);
}
},
onMouseOver: function (e) {
if (this.disabled) {
return;
}
$(e.currentTarget).addClass("over");
},
onMouseOut: function (e) {
if (this.disabled) {
return;
}
$(e.currentTarget).removeClass("active over");
if (this.options.hold) {
this._stopSpin();
}
},
onKeyDown: function (e) {
if (this.disabled) {
return;
}
if (this.options.hold && (e.keyCode == Common.UI.Keys.UP || e.keyCode == Common.UI.Keys.DOWN)) {
e.preventDefault();
e.stopPropagation();
if (this.switches.timeout === undefined) {
this.switches.fromKeyDown = true;
this._startSpin(e.keyCode == Common.UI.Keys.UP, e);
}
} else {
if (e.keyCode == Common.UI.Keys.RETURN) {
if (this.options.defaultUnit && this.options.defaultUnit.length) {
var value = this.$input.val();
if (this.value != value) {
this.onEnterValue();
return false;
}
} else {
this.onEnterValue();
}
} else {
this._fromKeyDown = true;
}
}
},
onKeyUp: function (e) {
if (this.disabled) {
return;
}
if (e.keyCode == Common.UI.Keys.UP || e.keyCode == Common.UI.Keys.DOWN) {
e.stopPropagation();
e.preventDefault();
(this.options.hold) ? this._stopSpin() : this._step(e.keyCode == Common.UI.Keys.UP);
}
},
onKeyPress: function (e) {
if (this.disabled) {
return;
}
var charCode = String.fromCharCode(e.charCode);
if (charCode == "." || charCode == ",") {
e.preventDefault();
e.stopPropagation();
} else {
if (this.options.maskExp && !this.options.maskExp.test(charCode) && !e.ctrlKey && e.keyCode !== Common.UI.Keys.DELETE && e.keyCode !== Common.UI.Keys.BACKSPACE && e.keyCode !== Common.UI.Keys.LEFT && e.keyCode !== Common.UI.Keys.RIGHT && e.keyCode !== Common.UI.Keys.HOME && e.keyCode !== Common.UI.Keys.END && e.keyCode !== Common.UI.Keys.ESC && e.keyCode !== Common.UI.Keys.RETURN && e.keyCode !== Common.UI.Keys.INSERT && e.keyCode !== Common.UI.Keys.TAB) {
e.preventDefault();
e.stopPropagation();
}
}
},
onInput: function (e, extra) {
if (this.disabled || e.isDefaultPrevented()) {
return;
}
this.trigger("changing", this, $(e.target).val(), e);
},
onEnterValue: function () {
if (this.$input) {
var val = this.$input.val();
this.setValue((val === "") ? this.value : val);
this.trigger("entervalue", this);
}
},
onBlur: function (e) {
if (this.$input) {
var val = this.$input.val();
this.setValue((val === "") ? this.value : val);
if (this.options.hold && this.switches.fromKeyDown) {
this._stopSpin();
}
}
},
_startSpin: function (type, e) {
if (!this.disabled) {
var divisor = this.switches.count;
if (divisor === 1) {
this._step(type, true);
divisor = 1;
} else {
if (divisor < 3) {
divisor = 1.5;
} else {
if (divisor < 8) {
divisor = 2.5;
} else {
divisor = 6;
}
}
}
this.switches.timeout = setTimeout($.proxy(function () {
this._step(type, true);
this._startSpin(type);
},
this), this.switches.speed / divisor);
this.switches.count++;
}
},
_stopSpin: function (e) {
if (this.switches.timeout !== undefined) {
clearTimeout(this.switches.timeout);
this.switches.timeout = undefined;
this.switches.count = 1;
this.trigger("change", this, this.value, this.lastValue);
}
},
_increase: function (suspend) {
var me = this;
if (!me.readOnly) {
var val = me.options.step;
if (me._fromKeyDown) {
val = this.$input.val();
val = _.isEmpty(val) ? me.oldValue : parseFloat(val);
} else {
if (me.getValue() !== "") {
if (me.options.allowAuto && me.getValue() == me.options.autoText) {
val = me.options.minValue - me.options.step;
} else {
val = parseFloat(me.getValue());
}
if (isNaN(val)) {
val = this.oldValue;
}
} else {
val = me.options.defaultValue;
}
}
me.setValue((this._add(val, me.options.step, (me.options.allowDecimal) ? 3 : 0) + " " + this.options.defaultUnit).trim(), suspend);
}
},
_decrease: function (suspend) {
var me = this;
if (!me.readOnly) {
var val = me.options.step;
if (me._fromKeyDown) {
val = this.$input.val();
val = _.isEmpty(val) ? me.oldValue : parseFloat(val);
} else {
if (me.getValue() !== "") {
if (me.options.allowAuto && me.getValue() == me.options.autoText) {
val = me.options.minValue;
} else {
val = parseFloat(me.getValue());
}
if (isNaN(val)) {
val = this.oldValue;
}
if (me.options.allowAuto && this._add(val, -me.options.step, (me.options.allowDecimal) ? 3 : 0) < me.options.minValue) {
me.setValue(me.options.autoText, true);
return;
}
} else {
val = me.options.defaultValue;
}
}
me.setValue((this._add(val, -me.options.step, (me.options.allowDecimal) ? 3 : 0) + " " + this.options.defaultUnit).trim(), suspend);
}
},
_step: function (type, suspend) {
(type) ? this._increase(suspend) : this._decrease(suspend);
},
_add: function (a, b, precision) {
var x = Math.pow(10, precision || (this.options.allowDecimal) ? 2 : 0);
return (Math.round(a * x) + Math.round(b * x)) / x;
},
_recalcUnits: function (value, fromUnit) {
if (fromUnit.match(/(s|ms)$/i) && this.options.defaultUnit.match(/(s|ms)$/i)) {
var v_out = value;
if (fromUnit == "ms") {
v_out = v_out / 1000;
}
if (this.options.defaultUnit == "ms") {
v_out = v_out * 1000;
}
return v_out;
}
if (fromUnit.match(/(pt|in|cm|mm|pc)$/i) === null || this.options.defaultUnit.match(/(pt|in|cm|mm|pc)$/i) === null) {
return value;
}
var v_out = value;
if (fromUnit == "cm") {
v_out = v_out * 10;
} else {
if (fromUnit == "pt") {
v_out = v_out * 25.4 / 72;
} else {
if (fromUnit == "in") {
v_out = v_out * 25.4;
} else {
if (fromUnit == "pc") {
v_out = v_out * 25.4 / 6;
}
}
}
}
if (this.options.defaultUnit == "cm") {
v_out = v_out / 10;
} else {
if (this.options.defaultUnit == "pt") {
v_out = parseFloat((v_out * 72 / 25.4).toFixed(3));
} else {
if (this.options.defaultUnit == "in") {
v_out = v_out / 25.4;
} else {
if (this.options.defaultUnit == "pc") {
v_out = v_out * 6 / 25.4;
}
}
}
}
return v_out;
}
});
});

View File

@@ -1,182 +1,123 @@
/*
* (c) Copyright Ascensio System SIA 2010-2014
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
Ext.define("Common.component.MultiSliderGradient", {
extend: "Ext.slider.Multi",
requires: ([]),
uses: [],
alias: "widget.cmdmultislidergradient",
cls: "asc-multi-slider-gradient",
values: [0, 100],
increment: 1,
minValue: 0,
maxValue: 100,
clickRange: [1, 20],
colorValues: ["#000000", "#ffffff"],
currentThumb: 0,
initComponent: function () {
var me = this,
cfg = Ext.apply({},
me.initialConfig);
if (me.initialConfig.listeners && me.initialConfig.listeners.change) {
var f = me.initialConfig.listeners.change;
me.initialConfig.listeners.change = function (slider, newvalue, thumb) {
me.changeGradientStyle();
f.call(me, slider, newvalue, thumb);
};
}
this.styleStr = "";
if (Ext.isChrome && Ext.chromeVersion < 10 || Ext.isSafari && Ext.safariVersion < 5.1) {
this.styleStr = "-webkit-gradient(linear, left top, right top, color-stop({1}%,{0}), color-stop({3}%,{2})); /* Chrome,Safari4+ */";
} else {
if (Ext.isChrome || Ext.isSafari) {
this.styleStr = "-webkit-linear-gradient(left, {0} {1}%, {2} {3}%)";
} else {
if (Ext.isGecko) {
this.styleStr = "-moz-linear-gradient(left, {0} {1}%, {2} {3}%)";
} else {
if (Ext.isOpera && Ext.operaVersion > 11) {
this.styleStr = "-o-linear-gradient(left, {0} {1}%, {2} {3}%)";
} else {
if (Ext.isIE) {
this.styleStr = "-ms-linear-gradient(left, {0} {1}%, {2} {3}%)";
}
}
}
}
}
this.callParent(arguments);
this.addEvents("thumbclick");
this.addEvents("thumbdblclick");
},
listeners: {
afterrender: function (cmp) {
var me = this,
style = "";
if (me.thumbs) {
for (var i = 0; i < me.thumbs.length; i++) {
if (me.thumbs[i] && me.thumbs[i].tracker) {
me.thumbs[i].tracker.addListener("mousedown", Ext.bind(me.setActiveThumb, me, [i, true]), me);
me.thumbs[i].tracker.el.addListener("dblclick", function () {
me.fireEvent("thumbdblclick", me);
},
me);
}
}
me.setActiveThumb(0);
if (me.innerEl) {
if (!Ext.isEmpty(me.styleStr)) {
style = Ext.String.format(me.styleStr, me.colorValues[0], 0, me.colorValues[1], 100);
me.innerEl.setStyle("background", style);
}
if (Ext.isIE) {
style = Ext.String.format("progid:DXImageTransform.Microsoft.gradient( startColorstr={0}, endColorstr={1},GradientType=1 )", me.colorValues[0], me.colorValues[1]);
me.innerEl.setStyle("filter", style);
}
style = Ext.String.format("linear-gradient(to right, {0} {1}%, {2} {3}%)", me.colorValues[0], 0, me.colorValues[1], 100);
me.innerEl.setStyle("background", style);
}
}
}
},
setActiveThumb: function (index, fireevent) {
this.currentThumb = index;
this.thumbs[index].el.addCls("active-thumb");
for (var j = 0; j < this.thumbs.length; j++) {
if (index == j) {
continue;
}
this.thumbs[j].el.removeCls("active-thumb");
}
if (fireevent) {
this.fireEvent("thumbclick", this, index);
}
},
setColorValue: function (color, index) {
var ind = (index !== undefined) ? index : this.currentThumb;
this.colorValues[ind] = color;
this.changeGradientStyle();
},
getColorValue: function (index) {
var ind = (index !== undefined) ? index : this.currentThumb;
return this.colorValues[ind];
},
changeGradientStyle: function () {
if (this.innerEl) {
var style;
if (!Ext.isEmpty(this.styleStr)) {
style = Ext.String.format(this.styleStr, this.colorValues[0], this.getValue(0), this.colorValues[1], this.getValue(1));
this.innerEl.setStyle("background", style);
}
if (Ext.isIE) {
style = Ext.String.format("progid:DXImageTransform.Microsoft.gradient( startColorstr={0}, endColorstr={1},GradientType=1 )", this.colorValues[0], this.colorValues[1]);
this.innerEl.setStyle("filter", style);
}
style = Ext.String.format("linear-gradient(to right, {0} {1}%, {2} {3}%)", this.colorValues[0], this.getValue(0), this.colorValues[1], this.getValue(1));
this.innerEl.setStyle("background", style);
}
},
getNearest: function (local, prop) {
var me = this,
localValue = prop == "top" ? me.innerEl.getHeight() - local[prop] : local[prop],
clickValue = me.reverseValue(localValue),
nearestDistance = (me.maxValue - me.minValue) + 5,
index = 0,
nearest = null,
thumbs = me.thumbs,
i = 0,
len = thumbs.length,
thumb,
value,
dist;
for (; i < len; i++) {
thumb = me.thumbs[i];
value = thumb.value;
dist = Math.abs(value - clickValue);
if (Math.abs(dist <= nearestDistance)) {
if (me.constrainThumbs) {
var above = me.thumbs[i + 1];
var below = me.thumbs[i - 1];
if (below !== undefined && clickValue < below.value) {
continue;
}
if (above !== undefined && clickValue > above.value) {
continue;
}
}
nearest = thumb;
index = i;
nearestDistance = dist;
}
}
return nearest;
}
/*
* (c) Copyright Ascensio System SIA 2010-2015
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
if (Common === undefined) {
var Common = {};
}
define(["common/main/lib/component/Slider", "underscore"], function (base, _) {
Common.UI.MultiSliderGradient = Common.UI.MultiSlider.extend({
options: {
width: 100,
minValue: 0,
maxValue: 100,
values: [0, 100],
colorValues: ["#000000", "#ffffff"],
currentThumb: 0
},
disabled: false,
template: _.template(['<div class="slider multi-slider-gradient">', '<div class="track"></div>', "<% _.each(items, function(item) { %>", '<div class="thumb" style=""></div>', "<% }); %>", "</div>"].join("")),
initialize: function (options) {
this.styleStr = "";
if (Common.Utils.isChrome && Common.Utils.chromeVersion < 10 || Common.Utils.isSafari && Common.Utils.safariVersion < 5.1) {
this.styleStr = "-webkit-gradient(linear, left top, right top, color-stop({1}%,{0}), color-stop({3}%,{2})); /* Chrome,Safari4+ */";
} else {
if (Common.Utils.isChrome || Common.Utils.isSafari) {
this.styleStr = "-webkit-linear-gradient(left, {0} {1}%, {2} {3}%)";
} else {
if (Common.Utils.isGecko) {
this.styleStr = "-moz-linear-gradient(left, {0} {1}%, {2} {3}%)";
} else {
if (Common.Utils.isOpera && Common.Utils.operaVersion > 11) {
this.styleStr = "-o-linear-gradient(left, {0} {1}%, {2} {3}%)";
} else {
if (Common.Utils.isIE) {
this.styleStr = "-ms-linear-gradient(left, {0} {1}%, {2} {3}%)";
}
}
}
}
}
this.colorValues = this.options.colorValues;
Common.UI.MultiSlider.prototype.initialize.call(this, options);
},
render: function (parentEl) {
Common.UI.MultiSlider.prototype.render.call(this, parentEl);
var me = this,
style = "";
me.trackEl = me.cmpEl.find(".track");
for (var i = 0; i < me.thumbs.length; i++) {
me.thumbs[i].thumb.on("dblclick", null, function () {
me.trigger("thumbdblclick", me);
});
}
if (me.styleStr !== "") {
style = Common.Utils.String.format(me.styleStr, me.colorValues[0], 0, me.colorValues[1], 100);
me.trackEl.css("background", style);
}
if (Common.Utils.isIE) {
style = Common.Utils.String.format("progid:DXImageTransform.Microsoft.gradient( startColorstr={0}, endColorstr={1},GradientType=1 )", me.colorValues[0], me.colorValues[1]);
me.trackEl.css("filter", style);
}
style = Common.Utils.String.format("linear-gradient(to right, {0} {1}%, {2} {3}%)", me.colorValues[0], 0, me.colorValues[1], 100);
me.trackEl.css("background", style);
me.on("change", _.bind(me.changeGradientStyle, me));
},
setColorValue: function (color, index) {
var ind = (index !== undefined) ? index : this.currentThumb;
this.colorValues[ind] = color;
this.changeGradientStyle();
},
getColorValue: function (index) {
var ind = (index !== undefined) ? index : this.currentThumb;
return this.colorValues[ind];
},
setValue: function (index, value) {
Common.UI.MultiSlider.prototype.setValue.call(this, index, value);
this.changeGradientStyle();
},
changeGradientStyle: function () {
if (!this.rendered) {
return;
}
var style;
if (this.styleStr !== "") {
style = Common.Utils.String.format(this.styleStr, this.colorValues[0], this.getValue(0), this.colorValues[1], this.getValue(1));
this.trackEl.css("background", style);
}
if (Common.Utils.isIE) {
style = Common.Utils.String.format("progid:DXImageTransform.Microsoft.gradient( startColorstr={0}, endColorstr={1},GradientType=1 )", this.colorValues[0], this.colorValues[1]);
this.trackEl.css("filter", style);
}
style = Common.Utils.String.format("linear-gradient(to right, {0} {1}%, {2} {3}%)", this.colorValues[0], this.getValue(0), this.colorValues[1], this.getValue(1));
this.trackEl.css("background", style);
}
});
});

View File

@@ -0,0 +1,104 @@
/*
* (c) Copyright Ascensio System SIA 2010-2015
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
if (Common === undefined) {
var Common = {};
}
define(["common/main/lib/component/BaseView", "underscore"], function (base, _) {
Common.UI.RadioBox = Common.UI.BaseView.extend({
options: {
labelText: ""
},
disabled: false,
rendered: false,
template: _.template('<label class="radiobox"><input type="button" name="<%= name %>"><%= labelText %></label>'),
initialize: function (options) {
Common.UI.BaseView.prototype.initialize.call(this, options);
var me = this,
el = $(this.el);
this.name = this.options.name || Common.UI.getId();
this.render();
if (this.options.disabled) {
this.setDisabled(this.options.disabled);
}
if (this.options.checked !== undefined) {
this.setValue(this.options.checked, true);
}
this.$radio.on("click", _.bind(this.onItemCheck, this));
},
render: function () {
var el = $(this.el);
el.html(this.template({
labelText: this.options.labelText,
name: this.name
}));
this.$radio = el.find("input[type=button]");
this.rendered = true;
return this;
},
setDisabled: function (disabled) {
if (disabled !== this.disabled) {
this.$radio.toggleClass("disabled", disabled);
(disabled) ? this.$radio.attr({
disabled: disabled
}) : this.$radio.removeAttr("disabled");
}
this.disabled = disabled;
},
isDisabled: function () {
return this.disabled;
},
onItemCheck: function (e) {
if (!this.disabled) {
this.setValue(true);
}
},
setRawValue: function (value) {
var value = (value === true || value === "true" || value === "1" || value === 1);
$("input[type=button][name=" + this.name + "]").removeClass("checked");
this.$radio.toggleClass("checked", value);
},
setValue: function (value, suspendchange) {
if (this.rendered) {
var lastValue = this.$radio.hasClass("checked");
this.setRawValue(value);
if (suspendchange !== true && lastValue !== value) {
this.trigger("change", this, this.$radio.hasClass("checked"));
}
} else {
this.options.checked = value;
}
},
getValue: function () {
return this.$radio.hasClass("checked");
}
});
});

View File

@@ -0,0 +1,141 @@
/*
* (c) Copyright Ascensio System SIA 2010-2015
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
if (Common === undefined) {
var Common = {};
}
define(["jmousewheel", "perfectscrollbar", "common/main/lib/component/BaseView"], function () {
Common.UI.Scroller = (function () {
var mouseCapture;
return _.extend(Common.UI.BaseView.extend({
options: {
wheelSpeed: 20,
wheelPropagation: false,
minScrollbarLength: null,
useBothWheelAxes: false,
useKeyboard: true,
suppressScrollX: false,
suppressScrollY: false,
scrollXMarginOffset: 5,
scrollYMarginOffset: 5,
includePadding: true,
includeMargin: true,
alwaysVisibleX: false,
alwaysVisibleY: false
},
initialize: function (options) {
Common.UI.BaseView.prototype.initialize.call(this, options);
if (this.options.el) {
this.render();
}
},
render: function () {
var me = this;
me.cmpEl = $(this.el);
if (!me.rendered) {
me.cmpEl.perfectScrollbar(_.extend({},
me.options));
me.rendered = true;
this.setAlwaysVisibleX(me.options.alwaysVisibleX);
this.setAlwaysVisibleY(me.options.alwaysVisibleY);
}
return this;
},
remove: function () {
this.destroy();
Backbone.View.prototype.remove.call(this);
},
update: function (config) {
var options = this.options;
if (config) {
this.destroy();
options = _.extend(this.options, config);
this.cmpEl.perfectScrollbar(options);
} else {
this.cmpEl.perfectScrollbar("update");
}
this.setAlwaysVisibleX(options.alwaysVisibleX);
this.setAlwaysVisibleY(options.alwaysVisibleY);
var mouseDownHandler = function (e) {
mouseCapture = true;
var upHandler = function (e) {
$(document).unbind("mouseup", upHandler);
_.delay(function () {
mouseCapture = false;
},
10);
};
$(document).mouseup(upHandler);
};
$(".ps-scrollbar-x-rail, .ps-scrollbar-y-rail, .ps-scrollbar-x, .ps-scrollbar-y", this.cmpEl).off("mousedown", mouseDownHandler).on("mousedown", mouseDownHandler);
},
destroy: function () {
this.cmpEl.perfectScrollbar("destroy");
},
scrollLeft: function (pos) {
this.cmpEl.scrollLeft(pos);
this.update();
},
scrollTop: function (pos) {
this.cmpEl.scrollTop(pos);
this.update();
},
getScrollTop: function () {
return this.cmpEl.scrollTop();
},
getScrollLeft: function () {
return this.cmpEl.scrollLeft();
},
setAlwaysVisibleX: function (flag) {
if (flag) {
$(this.el).find(".ps-scrollbar-x-rail").addClass("always-visible-x");
$(this.el).find(".ps-scrollbar-x").addClass("always-visible-x");
} else {
$(this.el).find(".ps-scrollbar-x-rail").removeClass("always-visible-x");
$(this.el).find(".ps-scrollbar-x").addClass("always-visible-x");
}
},
setAlwaysVisibleY: function (flag) {
if (flag) {
$(this.el).find(".ps-scrollbar-y-rail").addClass("always-visible-y");
$(this.el).find(".ps-scrollbar-y").addClass("always-visible-y");
} else {
$(this.el).find(".ps-scrollbar-y-rail").removeClass("always-visible-y");
$(this.el).find(".ps-scrollbar-y").addClass("always-visible-y");
}
}
}), {
isMouseCapture: function () {
return mouseCapture;
}
});
})();
});

View File

@@ -1,137 +0,0 @@
/*
* (c) Copyright Ascensio System SIA 2010-2014
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
Ext.define("Common.component.SearchField", {
extend: "Ext.container.Container",
alias: "widget.commonsearchfield",
height: 22,
layout: {
type: "hbox",
align: "stretch"
},
cls: "common-searchfield",
require: ["Ext.data.Store", "Ext.button.Button", "Ext.container.Container"],
initComponent: function () {
var me = this;
me.searching = false;
me.txtSearchQuery = Ext.create("Ext.form.field.Text", {
flex: 1,
emptyText: this.emptyText,
tabIndex: this.tabIndex || -1,
listeners: {
specialkey: function (o, e) {
if (e.getKey() == e.ENTER) {
me.stopSearch();
me.startSearch();
} else {
if (e.getKey() == e.TAB) {
me.stopSearch();
me.focus();
me.blur();
}
}
},
change: function (o, e) {
me.btnClear.setVisible(!me.isValueEmpty());
},
blur: function (o, e) {
if (!me.isValueValid()) {
me.clear();
}
}
}
});
me.btnClear = Ext.create("Ext.button.Button", {
iconCls: "search-btn-clear-icon",
hidden: true,
listeners: {
click: function () {
me.searching ? me.stopSearch() : me.clear();
}
}
});
me.items = [me.txtSearchQuery, me.btnClear];
me.relayEvents(me.txtSearchQuery, ["change"]);
me.addEvents("searchstart", "searchstop", "searchclear");
me.callParent(arguments);
},
startSearch: function (suppressEvent) {
var me = this;
if (!me.searching && me.isValueValid()) {
me.searching = true;
me.btnClear.setIconCls("search-btn-start-icon").toggle(true).disable();
if (!suppressEvent) {
me.fireEvent("searchstart", me, me.getText());
}
}
},
stopSearch: function (suppressEvent) {
var me = this;
if (me.searching) {
me.searching = false;
me.btnClear.setIconCls("search-btn-clear-icon").toggle(false).enable();
if (!suppressEvent) {
me.fireEvent("searchstop", me);
}
}
},
clear: function (suppressEvent) {
var me = this;
if (!me.searching) {
me.txtSearchQuery.reset();
if (!suppressEvent) {
me.fireEvent("searchclear", me);
}
}
},
isValueValid: function () {
var value = this.txtSearchQuery.getValue();
return !Ext.isEmpty(value);
},
isValueEmpty: function () {
return this.txtSearchQuery.getValue().length == 0;
},
setText: function (text) {
this.txtSearchQuery.setValue(text);
},
getText: function () {
return this.txtSearchQuery.getValue();
},
setValue: function (text) {
this.txtSearchQuery.setValue(text);
},
getValue: function () {
return this.txtSearchQuery.getValue();
},
focus: function (selectText, delay) {
this.txtSearchQuery.focus(selectText, delay);
}
});

View File

@@ -0,0 +1,380 @@
/*
* (c) Copyright Ascensio System SIA 2010-2015
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
if (Common === undefined) {
var Common = {};
}
define(["common/main/lib/component/BaseView", "underscore"], function (base, _) {
Common.UI.SingleSlider = Common.UI.BaseView.extend({
options: {
width: 100,
minValue: 0,
maxValue: 100,
step: 1,
value: 100,
enableKeyEvents: false
},
disabled: false,
template: _.template(['<div class="slider single-slider" style="">', '<div class="track">', '<div class="track-left"></div>', '<div class="track-center""></div>', '<div class="track-right" style=""></div>', "</div>", '<div class="thumb" style=""></div>', "<% if (this.options.enableKeyEvents) { %>", '<input type="text" style="position: absolute; top:-10px; width: 1px; height: 1px;">', "<% } %>", "</div>"].join("")),
initialize: function (options) {
Common.UI.BaseView.prototype.initialize.call(this, options);
var me = this,
el = $(this.el);
me.width = me.options.width;
me.minValue = me.options.minValue;
me.maxValue = me.options.maxValue;
me.delta = 100 / (me.maxValue - me.minValue);
me.step = me.options.step;
if (me.options.el) {
me.render();
}
this.setValue(me.options.value);
},
render: function (parentEl) {
var me = this;
if (!me.rendered) {
this.cmpEl = $(this.template({}));
if (parentEl) {
this.setElement(parentEl, false);
parentEl.html(this.cmpEl);
} else {
$(this.el).html(this.cmpEl);
}
} else {
this.cmpEl = $(this.el);
}
this.cmpEl.find(".track-center").width(me.options.width - 14);
this.cmpEl.width(me.options.width);
this.thumb = this.cmpEl.find(".thumb");
var onMouseUp = function (e) {
if (me.disabled) {
return;
}
e.preventDefault();
e.stopPropagation();
var pos = Math.max(0, Math.min(100, (Math.round((e.pageX - me.cmpEl.offset().left - me._dragstart) / me.width * 100))));
me.setThumbPosition(pos);
me.lastValue = me.value;
me.value = pos / me.delta + me.minValue;
me.thumb.removeClass("active");
$(document).off("mouseup", onMouseUp);
$(document).off("mousemove", onMouseMove);
me._dragstart = undefined;
me.trigger("changecomplete", me, me.value, me.lastValue);
};
var onMouseMove = function (e) {
if (me.disabled) {
return;
}
if (me._dragstart === undefined) {
return;
}
e.preventDefault();
e.stopPropagation();
var pos = Math.max(0, Math.min(100, (Math.round((e.pageX - me.cmpEl.offset().left - me._dragstart) / me.width * 100))));
me.setThumbPosition(pos);
me.lastValue = me.value;
me.value = pos / me.delta + me.minValue;
if (Math.abs(me.value - me.lastValue) > 0.001) {
me.trigger("change", me, me.value, me.lastValue);
}
};
var onMouseDown = function (e) {
if (me.disabled) {
return;
}
me._dragstart = e.pageX - me.thumb.offset().left - 7;
me.thumb.addClass("active");
$(document).on("mouseup", onMouseUp);
$(document).on("mousemove", onMouseMove);
if (me.options.enableKeyEvents) {
setTimeout(function () {
me.input.focus();
},
10);
}
};
var onTrackMouseDown = function (e) {
if (me.disabled) {
return;
}
var pos = Math.max(0, Math.min(100, (Math.round((e.pageX - me.cmpEl.offset().left) / me.width * 100))));
me.setThumbPosition(pos);
me.lastValue = me.value;
me.value = pos / me.delta + me.minValue;
me.trigger("change", me, me.value, me.lastValue);
me.trigger("changecomplete", me, me.value, me.lastValue);
};
var updateslider;
var moveThumb = function (increase) {
me.lastValue = me.value;
me.value = Math.max(me.minValue, Math.min(me.maxValue, me.value + ((increase) ? me.step : -me.step)));
me.setThumbPosition(Math.round((me.value - me.minValue) * me.delta));
me.trigger("change", me, me.value, me.lastValue);
};
var onKeyDown = function (e) {
if (me.disabled) {
return;
}
if (e.keyCode == Common.UI.Keys.UP || e.keyCode == Common.UI.Keys.DOWN || e.keyCode == Common.UI.Keys.LEFT || e.keyCode == Common.UI.Keys.RIGHT) {
e.preventDefault();
e.stopPropagation();
el.off("keydown", "input", onKeyDown);
updateslider = setInterval(_.bind(moveThumb, me, e.keyCode == Common.UI.Keys.UP || e.keyCode == Common.UI.Keys.RIGHT), 100);
}
};
var onKeyUp = function (e) {
if (me.disabled) {
return;
}
if (e.keyCode == Common.UI.Keys.UP || e.keyCode == Common.UI.Keys.DOWN || Common.UI.Keys.LEFT || Common.UI.Keys.RIGHT) {
e.stopPropagation();
e.preventDefault();
clearInterval(updateslider);
moveThumb(e.keyCode == Common.UI.Keys.UP || e.keyCode == Common.UI.Keys.RIGHT);
el.on("keydown", "input", onKeyDown);
me.trigger("changecomplete", me, me.value, me.lastValue);
}
};
if (!me.rendered) {
var el = me.cmpEl;
el.on("mousedown", ".thumb", onMouseDown);
el.on("mousedown", ".track", onTrackMouseDown);
if (this.options.enableKeyEvents) {
el.on("keydown", "input", onKeyDown);
el.on("keyup", "input", onKeyUp);
}
}
me.rendered = true;
return this;
},
setThumbPosition: function (x) {
this.thumb.css({
left: x + "%"
});
},
setValue: function (value) {
this.lastValue = this.value;
this.value = Math.max(this.minValue, Math.min(this.maxValue, value));
this.setThumbPosition(Math.round((value - this.minValue) * this.delta));
},
getValue: function () {
return this.value;
},
setDisabled: function (disabled) {
if (disabled !== this.disabled) {
this.cmpEl.toggleClass("disabled", disabled);
}
this.disabled = disabled;
}
});
Common.UI.MultiSlider = Common.UI.BaseView.extend({
options: {
width: 100,
minValue: 0,
maxValue: 100,
values: [0, 100]
},
disabled: false,
template: _.template(['<div class="slider multi-slider">', '<div class="track">', '<div class="track-left"></div>', '<div class="track-center""></div>', '<div class="track-right" style=""></div>', "</div>", "<% _.each(items, function(item) { %>", '<div class="thumb" style=""></div>', "<% }); %>", "</div>"].join("")),
initialize: function (options) {
Common.UI.BaseView.prototype.initialize.call(this, options);
var me = this,
el = $(this.el);
me.width = me.options.width;
me.minValue = me.options.minValue;
me.maxValue = me.options.maxValue;
me.delta = 100 / (me.maxValue - me.minValue);
me.thumbs = [];
if (me.options.el) {
me.render();
}
},
render: function (parentEl) {
var me = this;
if (!me.rendered) {
this.cmpEl = $(this.template({
items: this.options.values
}));
if (parentEl) {
this.setElement(parentEl, false);
parentEl.html(this.cmpEl);
} else {
$(this.el).html(this.cmpEl);
}
} else {
this.cmpEl = $(this.el);
}
var el = this.cmpEl;
el.find(".track-center").width(me.options.width - 14);
el.width(me.options.width);
var onMouseUp = function (e) {
if (me.disabled) {
return;
}
e.preventDefault();
e.stopPropagation();
var index = e.data,
lastValue = me.thumbs[index].value,
minValue = (index - 1 < 0) ? 0 : me.thumbs[index - 1].position,
maxValue = (index + 1 < me.thumbs.length) ? me.thumbs[index + 1].position : 100,
pos = Math.max(minValue, Math.min(maxValue, (Math.round((e.pageX - me.cmpEl.offset().left - me._dragstart) / me.width * 100)))),
value = pos / me.delta + me.minValue;
me.setThumbPosition(index, pos);
me.thumbs[index].value = value;
$(document).off("mouseup", onMouseUp);
$(document).off("mousemove", onMouseMove);
me._dragstart = undefined;
me.trigger("changecomplete", me, value, lastValue);
};
var onMouseMove = function (e) {
if (me.disabled) {
return;
}
if (me._dragstart === undefined) {
return;
}
e.preventDefault();
e.stopPropagation();
var index = e.data,
lastValue = me.thumbs[index].value,
minValue = (index - 1 < 0) ? 0 : me.thumbs[index - 1].position,
maxValue = (index + 1 < me.thumbs.length) ? me.thumbs[index + 1].position : 100,
pos = Math.max(minValue, Math.min(maxValue, (Math.round((e.pageX - me.cmpEl.offset().left - me._dragstart) / me.width * 100)))),
value = pos / me.delta + me.minValue;
me.setThumbPosition(index, pos);
me.thumbs[index].value = value;
if (Math.abs(value - lastValue) > 0.001) {
me.trigger("change", me, value, lastValue);
}
};
var onMouseDown = function (e) {
if (me.disabled) {
return;
}
var index = e.data,
thumb = me.thumbs[index].thumb;
me._dragstart = e.pageX - thumb.offset().left - thumb.width() / 2;
me.setActiveThumb(index);
_.each(me.thumbs, function (item, idx) {
(index == idx) ? item.thumb.css("z-index", 500) : item.thumb.css("z-index", "");
});
$(document).on("mouseup", null, index, onMouseUp);
$(document).on("mousemove", null, index, onMouseMove);
};
var onTrackMouseDown = function (e) {
if (me.disabled) {
return;
}
var pos = Math.max(0, Math.min(100, (Math.round((e.pageX - me.cmpEl.offset().left) / me.width * 100)))),
index = findThumb(pos),
lastValue = me.thumbs[index].value,
value = pos / me.delta + me.minValue;
me.setThumbPosition(index, pos);
me.thumbs[index].value = value;
me.trigger("change", me, value, lastValue);
me.trigger("changecomplete", me, value, lastValue);
};
var findThumb = function (pos) {
var nearest = 100,
index = 0,
len = me.thumbs.length,
dist;
for (var i = 0; i < len; i++) {
dist = Math.abs(me.thumbs[i].position - pos);
if (Math.abs(dist <= nearest)) {
var above = me.thumbs[i + 1];
var below = me.thumbs[i - 1];
if (below !== undefined && pos < below.position) {
continue;
}
if (above !== undefined && pos > above.position) {
continue;
}
index = i;
nearest = dist;
}
}
return index;
};
this.$thumbs = el.find(".thumb");
_.each(this.$thumbs, function (item, index) {
var thumb = $(item);
me.thumbs.push({
thumb: thumb,
index: index
});
me.setValue(index, me.options.values[index]);
thumb.on("mousedown", null, index, onMouseDown);
});
me.setActiveThumb(0, true);
if (!me.rendered) {
el.on("mousedown", ".track", onTrackMouseDown);
}
me.rendered = true;
return this;
},
setActiveThumb: function (index, suspend) {
this.currentThumb = index;
this.$thumbs.removeClass("active");
this.thumbs[index].thumb.addClass("active");
if (suspend !== true) {
this.trigger("thumbclick", this, index);
}
},
setThumbPosition: function (index, x) {
this.thumbs[index].position = x;
this.thumbs[index].thumb.css({
left: x + "%"
});
},
setValue: function (index, value) {
this.thumbs[index].value = Math.max(this.minValue, Math.min(this.maxValue, value));
this.setThumbPosition(index, Math.round((value - this.minValue) * this.delta));
},
getValue: function (index) {
return this.thumbs[index].value;
},
getValues: function () {
var values = [];
_.each(this.thumbs, function (thumb) {
values.push(thumb.value);
});
return values;
},
setDisabled: function (disabled) {
if (disabled !== this.disabled) {
this.cmpEl.toggleClass("disabled", disabled);
}
this.disabled = disabled;
}
});
});

View File

@@ -1,106 +0,0 @@
/*
* (c) Copyright Ascensio System SIA 2010-2014
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
Ext.define("Common.component.SplitColorButton", {
extend: "Ext.button.Split",
alias: "widget.cmdsplitcolorbutton",
color: "FF0000",
colorHeight: 4,
verticalOffset: 0,
horizontalOffset: 0,
initComponent: function () {
this.addEvents("changecolor");
this.callParent(arguments);
},
afterRender: function () {
this.callParent(arguments);
this.on({
disable: function (cnt, eOpts) {
if (this.getEl()) {
var colorRect = this.getEl().down(".x-btn-color");
colorRect && colorRect.applyStyles({
"background-color": "#9c9c9c"
});
}
},
enable: function (cnt, eOpts) {
var colorRect = this.getEl().down(".x-btn-color");
if (colorRect) {
colorRect.applyStyles({
"background-color": this.color == "transparent" ? this.color : "#" + this.color
});
}
}
},
this);
var btn = this.getEl().down("button");
if (btn) {
Ext.DomHelper.append(btn, {
tag: "span",
cls: "x-btn-color"
});
var colorRect = btn.child(".x-btn-color");
colorRect.applyStyles({
position: "absolute",
left: this.verticalOffset + "px",
top: btn.getHeight() - this.colorHeight - this.horizontalOffset + "px",
"background-color": "#" + this.color
});
if (this.isDisabled()) {
colorRect.applyStyles({
"background-color": "#9c9c9c"
});
}
colorRect.setSize(btn.getWidth() - 2 * this.verticalOffset, this.colorHeight);
}
},
setColor: function (color, fire) {
this.color = color;
var colorRect = this.getEl().down(".x-btn-color");
if (colorRect) {
if (this.isDisabled()) {
colorRect.applyStyles({
"background-color": "#9c9c9c"
});
} else {
colorRect.applyStyles({
"background-color": this.color == "transparent" ? this.color : "#" + this.color
});
}
}
if (fire !== false) {
this.fireEvent("changecolor", this, color);
}
},
getColor: function () {
return this.color || null;
}
});

View File

@@ -1,102 +1,88 @@
/*
* (c) Copyright Ascensio System SIA 2010-2014
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
Ext.define("Common.component.SynchronizeTip", {
extend: "Ext.container.Container",
alias: "widget.commonsynchronizetip",
cls: "asc-synchronizetip",
requires: ["Ext.button.Button", "Ext.form.Label"],
layout: {
type: "vbox",
align: "stretch"
},
width: 240,
height: 95,
hideMode: "visibility",
constructor: function (config) {
this.initConfig(config);
this.callParent(arguments);
return this;
},
initComponent: function () {
var me = this;
me.addEvents("dontshowclick");
me.addEvents("closeclick");
var btnClose = Ext.widget("button", {
cls: "btn-close-tip",
iconCls: "icon-close-tip",
listeners: {
click: function () {
me.fireEvent("closeclick", me);
}
}
});
me.items = [{
xtype: "container",
html: '<div class="tip-arrow"></div>'
},
{
xtype: "container",
flex: 1,
style: "padding-left: 15px;",
layout: {
type: "hbox",
align: "stretch"
},
items: [{
xtype: "container",
flex: 1,
style: "margin-top: 15px;line-height: 1.2;",
html: "<div>" + me.textSynchronize + "</div>"
},
btnClose]
},
{
xtype: "container",
cls: "show-link",
items: [{
xtype: "label",
text: me.textDontShow,
listeners: {
afterrender: function (cmp) {
cmp.getEl().on("click", function (event, node) {
me.fireEvent("dontshowclick", me);
});
},
scope: this
}
}]
}];
me.callParent(arguments);
},
textDontShow: "Don't show this message again",
textSynchronize: "The document has changed. <br/>Refresh the document to see the updates."
/*
* (c) Copyright Ascensio System SIA 2010-2015
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
if (Common === undefined) {
var Common = {};
}
define(["common/main/lib/component/BaseView"], function () {
Common.UI.SynchronizeTip = Common.UI.BaseView.extend(_.extend((function () {
var tipEl;
return {
options: {
target: $(document.body)
},
template: _.template(['<div class="synch-tip-root">', '<div class="asc-synchronizetip">', '<div class="tip-arrow"></div>', "<div>", '<div style="width: 260px;"><%= scope.textSynchronize %></div>', '<div class="close"></div>', "</div>", '<div class="show-link"><label><%= scope.textDontShow %></label></div>', "</div>", "</div>"].join("")),
initialize: function (options) {
this.textSynchronize += Common.Utils.String.platformKey("Ctrl+S");
Common.UI.BaseView.prototype.initialize.call(this, options);
this.target = this.options.target;
},
render: function () {
tipEl = $(this.template({
scope: this
}));
tipEl.find(".close").on("click", _.bind(function () {
this.trigger("closeclick");
},
this));
tipEl.find(".show-link label").on("click", _.bind(function () {
this.trigger("dontshowclick");
},
this));
$(document.body).append(tipEl);
this.applyPlacement();
return this;
},
show: function () {
if (tipEl) {
this.applyPlacement();
tipEl.show();
} else {
this.render();
}
},
hide: function () {
if (tipEl) {
tipEl.hide();
}
},
applyPlacement: function () {
var showxy = this.target.offset();
tipEl.css({
top: showxy.top + this.target.height() / 2 + "px",
left: showxy.left + this.target.width() + "px"
});
},
textDontShow: "Don't show this message again",
textSynchronize: "The document has been changed by another user.<br/>Please click to save your changes and reload the updates."
};
})(), Common.UI.SynchronizeTip || {}));
});

View File

@@ -0,0 +1,97 @@
/*
* (c) Copyright Ascensio System SIA 2010-2015
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
if (Common === undefined) {
var Common = {};
}
define(["common/main/lib/component/BaseView"], function (base) {
var Tab = function (opts) {
this.active = false;
this.label = "Tab";
this.cls = "";
this.template = _.template(['<li class="<% if(active){ %>active<% } %> <% if(cls.length){%><%= cls %><%}%>" data-label="<%= label %>">', "<a><%- label %></a>", "</li>"].join(""));
this.initialize.call(this, opts);
return this;
};
_.extend(Tab.prototype, {
initialize: function (options) {
_.extend(this, options);
},
render: function () {
var el = this.template(this);
this.$el = $(el);
this.rendered = true;
this.disable(this.disabled);
return this;
},
isActive: function () {
return this.$el.hasClass("active");
},
activate: function () {
if (!this.$el.hasClass("active")) {
this.$el.addClass("active");
}
},
deactivate: function () {
this.$el.removeClass("active");
},
on: function () {
this.$el.on.apply(this, arguments);
},
disable: function (val) {
this.disabled = val;
if (this.rendered) {
if (val && !this.$el.hasClass("disabled")) {
this.$el.addClass("disabled");
} else {
this.$el.removeClass("disabled");
}
}
},
addClass: function (cls) {
if (cls.length && !this.$el.hasClass(cls)) {
this.$el.addClass(cls);
}
},
removeClass: function (cls) {
if (cls.length && this.$el.hasClass(cls)) {
this.$el.removeClass(cls);
}
},
hasClass: function (cls) {
return this.$el.hasClass(cls);
},
setCaption: function (text) {
this.$el.find("> a").text(text);
}
});
Common.UI.Tab = Tab;
});

View File

@@ -0,0 +1,494 @@
/*
* (c) Copyright Ascensio System SIA 2010-2015
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
define(["common/main/lib/component/BaseView", "common/main/lib/component/Tab"], function () {
var Events = {
bind: function () {
if (!this.o) {
this.o = $({});
}
this.o.on.apply(this.o, arguments);
},
unbind: function () {
if (this.o) {
this.o.off.apply(this.o, arguments);
}
},
trigger: function () {
if (!this.o) {
this.o = $({});
}
this.o.trigger.apply(this.o, arguments);
}
};
var StateManager = function (options) {
this.initialize.call(this, options);
};
_.extend(StateManager.prototype, Events);
StateManager.prototype.initialize = function (options) {
this.bar = options.bar;
};
StateManager.prototype.attach = function (tab) {
tab.changeState = $.proxy(function () {
this.trigger("tab:change", tab);
this.bar.$el.find("ul > li.active").removeClass("active");
tab.activate();
this.bar.trigger("tab:changed", this.bar, this.bar.tabs.indexOf(tab), tab);
},
this);
var dragHelper = new(function () {
return {
bounds: [],
drag: undefined,
calculateBounds: function () {
var me = this,
length = me.bar.tabs.length,
barBounds = me.bar.$bar.get(0).getBoundingClientRect();
if (barBounds) {
me.bounds = [];
me.scrollLeft = me.bar.$bar.scrollLeft();
me.bar.scrollX = this.scrollLeft;
for (var i = 0; i < length; ++i) {
this.bounds.push(me.bar.tabs[i].$el.get(0).getBoundingClientRect());
}
me.tabBarLeft = me.bounds[0].left;
me.tabBarRight = me.bounds[length - 1].right;
me.tabBarRight = Math.min(me.tabBarRight, barBounds.right - 1);
}
},
setAbsTabs: function () {
var me = this,
tab = null,
length = this.bounds.length;
for (var i = 0; i < length; ++i) {
tab = me.bar.tabs[i].$el;
tab.css("position", "absolute");
tab.css("left", (me.bounds[i].left - me.tabBarLeft - this.scrollLeft) + "px");
if (tab.hasClass("active")) {
tab.css("top", "1px");
} else {
tab.css("top", "0px");
}
}
},
updatePositions: function () {
this.drag.place = undefined;
var i, tabBound, center, place = -1,
next = -this.scrollLeft,
tabsCount = this.bounds.length,
dragBound = this.drag.tab.$el.get(0).getBoundingClientRect();
if (this.drag.moveX - this.drag.mouseX > 0) {
for (i = tabsCount - 1; i >= 0; --i) {
tabBound = this.bounds[i];
center = (tabBound.right + tabBound.left) * 0.5;
if (dragBound.left < center && center < dragBound.right) {
place = i;
break;
}
}
if (-1 === place) {
for (i = tabsCount - 1; i >= 0; --i) {
tabBound = dragBound;
center = (tabBound.right + tabBound.left) * 0.5;
if (this.bounds[i].left < center && center < this.bounds[i].right) {
place = i;
break;
}
}
}
} else {
for (i = 0; i < tabsCount; ++i) {
tabBound = this.bounds[i];
center = (tabBound.right + tabBound.left) * 0.5;
if (dragBound.left < center && center < dragBound.right) {
place = i;
break;
}
}
if (-1 === place) {
for (i = 0; i < tabsCount; ++i) {
tabBound = dragBound;
center = (tabBound.right + tabBound.left) * 0.5;
if (this.bounds[i].left < center && center < this.bounds[i].right) {
place = i;
break;
}
}
}
}
if (-1 !== place) {
this.drag.place = place;
for (i = 0; i < tabsCount; ++i) {
if (i === place) {
if (place < this.drag.index) {
next += this.drag.tabWidth;
}
}
if (place > this.drag.index) {
if (i === place + 1) {
next += this.drag.tabWidth;
}
}
if (i !== this.drag.index) {
this.bar.tabs[i].$el.css("left", next + "px");
} else {
if (this.drag.index === place) {
next += this.drag.tabWidth;
}
continue;
}
next += this.bounds[i].width;
}
}
},
setHook: function (e, bar, tab) {
var me = this;
function dragComplete() {
if (!_.isUndefined(me.drag)) {
me.drag.tab.$el.css("z-index", "");
var tab = null;
for (var i = me.bar.tabs.length - 1; i >= 0; --i) {
tab = me.bar.tabs[i].$el;
if (tab) {
tab.css("top", "");
tab.css("position", "");
tab.css("left", "");
}
}
if (!_.isUndefined(me.drag.place)) {
me.bar.trigger("tab:move", me.drag.index, me.drag.place);
me.bar.$bar.scrollLeft(me.scrollLeft);
me.bar.scrollX = undefined;
} else {
me.bar.trigger("tab:move", me.drag.index);
me.bar.$bar.scrollLeft(me.scrollLeft);
me.bar.scrollX = undefined;
}
me.drag = undefined;
}
}
function dragMove(e) {
if (!_.isUndefined(me.drag)) {
me.drag.moveX = e.clientX;
var leftPos = Math.max(e.clientX - me.drag.anchorX - me.tabBarLeft - me.scrollLeft, 0);
leftPos = Math.min(leftPos, me.tabBarRight - me.tabBarLeft - me.drag.tabWidth - me.scrollLeft);
me.drag.tab.$el.css("left", leftPos + "px");
me.drag.tab.$el.css("z-index", "100");
me.updatePositions();
}
}
function dragDropText(e) {
e.preventDefault();
}
if (!_.isUndefined(bar) && !_.isUndefined(tab) && bar.tabs.length > 1) {
var index = bar.tabs.indexOf(tab);
me.bar = bar;
me.drag = {
tab: tab,
index: index
};
this.calculateBounds();
this.setAbsTabs();
me.drag.moveX = e.clientX;
me.drag.mouseX = e.clientX;
me.drag.anchorX = e.clientX - this.bounds[index].left;
me.drag.tabWidth = this.bounds[index].width;
document.addEventListener("dragstart", dragDropText);
$(document).on("mousemove", dragMove);
$(document).on("mouseup", function (e) {
dragComplete(e);
$(document).off("mouseup", dragComplete);
$(document).off("mousemove", dragMove);
document.removeEventListener("dragstart", dragDropText);
});
}
}
};
});
tab.$el.on({
click: $.proxy(function () {
if (!tab.disabled && !tab.$el.hasClass("active")) {
if (tab.control == "manual") {
this.bar.trigger("tab:manual", this.bar, this.bar.tabs.indexOf(tab), tab);
} else {
tab.changeState();
}
}
},
this),
dblclick: $.proxy(function () {
this.trigger("tab:dblclick", this, this.tabs.indexOf(tab), tab);
},
this.bar),
contextmenu: $.proxy(function () {
this.trigger("tab:contextmenu", this, this.tabs.indexOf(tab), tab);
},
this.bar),
mousedown: $.proxy(function (e) {
if (this.bar.options.draggable && !_.isUndefined(dragHelper) && (3 !== e.which)) {
if (!tab.isLockTheDrag) {
dragHelper.setHook(e, this.bar, tab);
}
}
},
this)
});
};
StateManager.prototype.detach = function (tab) {
tab.$el.off();
};
Common.UI.TabBar = Common.UI.BaseView.extend({
config: {
placement: "top",
items: [],
draggable: false
},
tabs: [],
template: _.template('<ul class="nav nav-tabs <%= placement %>" />'),
initialize: function (options) {
_.extend(this.config, options);
Common.UI.BaseView.prototype.initialize.call(this, options);
this.saved = [];
},
render: function () {
this.$el.html(this.template(this.config));
this.$bar = this.$el.find("ul");
var addEvent = function (elem, type, fn) {
elem.addEventListener ? elem.addEventListener(type, fn, false) : elem.attachEvent("on" + type, fn);
};
var eventname = (/Firefox/i.test(navigator.userAgent)) ? "DOMMouseScroll" : "mousewheel";
addEvent(this.$bar[0], eventname, _.bind(this._onMouseWheel, this));
this.manager = new StateManager({
bar: this
});
this.insert(-1, this.config.items);
this.insert(-1, this.saved);
delete this.saved;
this.rendered = true;
return this;
},
_onMouseWheel: function (e) {
var hidden = this.checkInvisible(true),
forward = ((e.detail && -e.detail) || e.wheelDelta) > 0;
if (forward) {
if (hidden.last) {
this.setTabVisible("forward");
}
} else {
if (hidden.first) {
this.setTabVisible("backward");
}
}
},
add: function (tabs) {
return this.insert(-1, tabs) > 0;
},
insert: function (index, tabs) {
var count = 0;
if (tabs) {
if (! (tabs instanceof Array)) {
tabs = [tabs];
}
if (tabs.length) {
count = tabs.length;
if (this.rendered) {
var me = this,
tab;
if (index < 0 || index > me.tabs.length) {
for (var i = 0; i < tabs.length; i++) {
tab = new Common.UI.Tab(tabs[i]);
me.$bar.append(tab.render().$el);
me.tabs.push(tab);
me.manager.attach(tab);
}
} else {
for (i = tabs.length; i-->0;) {
tab = new Common.UI.Tab(tabs[i]);
if (index === 0) {
me.$bar.prepend(tab.render().$el);
me.tabs.unshift(tab);
} else {
me.$bar.find("li:nth-child(" + index + ")").before(tab.render().$el);
me.tabs.splice(index, 0, tab);
}
me.manager.attach(tab);
}
}
} else {
this.saved.push(tabs);
}
this.checkInvisible();
}
}
return count;
},
remove: function (index) {
if (index >= 0 && index < this.tabs.length) {
var tab = this.tabs.splice(index, 1)[0];
this.manager.detach(tab);
tab.$el.remove();
this.checkInvisible();
}
},
empty: function (suppress) {
var me = this;
this.tabs.forEach(function (tab) {
me.manager.detach(tab);
});
this.$bar.empty();
me.tabs = [];
this.checkInvisible(suppress);
},
setActive: function (t) {
if (t instanceof Common.UI.Tab) {
tab = t;
} else {
if (typeof t == "number") {
if (t >= 0 && t < this.tabs.length) {
var tab = this.tabs[t];
}
}
}
if (tab && tab.control != "manual" && !tab.disabled && !tab.$el.hasClass("active")) {
tab.changeState();
}
this.checkInvisible();
},
getActive: function (iselem) {
return iselem ? this.$bar.find("> li.active") : this.$bar.find("> li.active").index();
},
getAt: function (index) {
return (index >= 0 && index < this.tabs.length) ? this.tabs[index] : undefined;
},
getCount: function () {
return this.tabs.length;
},
addClass: function (cls) {
if (cls.length && !this.$bar.hasClass(cls)) {
this.$bar.addClass(cls);
}
},
removeClass: function (cls) {
if (cls.length && this.$bar.hasClass(cls)) {
this.$bar.removeClass(cls);
}
},
hasClass: function (cls) {
return this.$bar.hasClass(cls);
},
setTabVisible: function (index, suppress) {
if (index <= 0 || index == "first") {
this.$bar.scrollLeft(0);
this.checkInvisible(suppress);
} else {
if (index >= (this.tabs.length - 1) || index == "last") {
var left = this.tabs[this.tabs.length - 1].$el.position().left;
this.$bar.scrollLeft(left);
this.checkInvisible(suppress);
} else {
var rightbound = this.$bar.width();
if (index == "forward") {
var tab, right;
for (var i = 0; i < this.tabs.length; i++) {
tab = this.tabs[i].$el;
right = tab.position().left + parseInt(tab.css("width"));
if (right > rightbound) {
this.$bar.scrollLeft(this.$bar.scrollLeft() + (right - rightbound) + 20);
this.checkInvisible(suppress);
break;
}
}
} else {
if (index == "backward") {
for (i = this.tabs.length; i-->0;) {
tab = this.tabs[i].$el;
left = tab.position().left;
if (left < 0) {
this.$bar.scrollLeft(this.$bar.scrollLeft() + left - 26);
this.checkInvisible(suppress);
break;
}
}
} else {
if (typeof index == "number") {
tab = this.tabs[index].$el;
left = tab.position().left;
right = left + parseInt(tab.css("width"));
if (left < 0) {
this.$bar.scrollLeft(this.$bar.scrollLeft() + left - 26);
this.checkInvisible(suppress);
} else {
if (right > rightbound) {
this.$bar.scrollLeft(this.$bar.scrollLeft() + (right - rightbound) + 20);
this.checkInvisible(suppress);
}
}
}
}
}
}
}
},
checkInvisible: function (suppress) {
var result = {
first: !this.isTabVisible(0),
last: !this.isTabVisible(this.tabs.length - 1)
}; ! suppress && this.fireEvent("tab:invisible", this, result);
return result;
},
hasInvisible: function () {
var _left_bound_ = this.$bar.offset().left,
_right_bound_ = _left_bound_ + this.$bar.width();
for (var i = this.tabs.length; i-->0;) {
if (!this.isTabVisible(i, _left_bound_, _right_bound_)) {
return true;
}
}
return false;
},
isTabVisible: function (index) {
var leftbound = arguments[1] || this.$bar.offset().left,
rightbound = arguments[2] || (leftbound + this.$bar.width()),
left,
right,
tab,
rect;
if (index < this.tabs.length && index >= 0) {
tab = this.tabs[index].$el;
rect = tab.get(0).getBoundingClientRect();
left = rect.left;
right = rect.right;
return ! (left < leftbound) && !(right > rightbound);
}
return false;
}
});
});

View File

@@ -0,0 +1,645 @@
/*
* (c) Copyright Ascensio System SIA 2010-2015
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
if (Common === undefined) {
var Common = {};
}
define(["common/main/lib/component/BaseView"], function () {
Common.UI.CellStyler = Common.UI.BaseView.extend({
options: {
clickOffset: 10,
overwriteStyle: true,
maxBorderSize: 6,
halfBorderSize: false,
defaultBorderSize: 1,
defaultBorderColor: "#ccc"
},
template: _.template(['<div id="<%=id%>" class="tablestyler-cell" style="">', '<div class="cell-content" style="">', '<div class="content-text"></div>', "</div>", "</div>"].join("")),
initialize: function (options) {
Common.UI.BaseView.prototype.initialize.call(this, options);
var me = this,
divContent = undefined,
virtualBorderSize, virtualBorderColor, borderSize = {},
borderColor = {},
borderAlfa = {};
me.id = me.options.id || Common.UI.getId();
me.clickOffset = me.options.clickOffset;
me.overwriteStyle = me.options.overwriteStyle;
me.maxBorderSize = me.options.maxBorderSize;
me.halfBorderSize = me.options.halfBorderSize;
me.defaultBorderSize = me.options.defaultBorderSize;
me.defaultBorderColor = me.options.defaultBorderColor;
me.col = me.options.col;
me.row = me.options.row;
virtualBorderSize = me.defaultBorderSize;
virtualBorderColor = new Common.Utils.RGBColor(me.defaultBorderColor);
borderSize = {
top: virtualBorderSize,
right: virtualBorderSize,
bottom: virtualBorderSize,
left: virtualBorderSize
};
borderColor = {
top: virtualBorderColor,
right: virtualBorderColor,
bottom: virtualBorderColor,
left: virtualBorderColor
};
borderAlfa = {
top: 1,
right: 1,
bottom: 1,
left: 1
};
me.rendered = false;
var applyStyle = function () {
if (!_.isUndefined(divContent)) {
var brd = (borderSize.left > 0.1 && borderSize.left < 1) ? 1 : borderSize.left;
var drawLeftSize = Math.abs((me.halfBorderSize) ? ((brd % 2) ? brd - 1 : brd) * 0.5 : brd);
brd = (borderSize.right > 0.1 && borderSize.right < 1) ? 1 : borderSize.right;
var drawRightSize = Math.abs((me.halfBorderSize) ? ((brd % 2) ? brd + 1 : brd) * 0.5 : brd);
brd = (borderSize.top > 0.1 && borderSize.top < 1) ? 1 : borderSize.top;
var drawTopSize = Math.abs((me.halfBorderSize) ? ((brd % 2) ? brd - 1 : brd) * 0.5 : brd);
brd = (borderSize.bottom > 0.1 && borderSize.bottom < 1) ? 1 : borderSize.bottom;
var drawBottomSize = Math.abs((me.halfBorderSize) ? ((brd % 2) ? brd + 1 : brd) * 0.5 : brd);
var value = "inset " + ((drawLeftSize > 0.1 && drawLeftSize < 1) ? 1 : drawLeftSize) + "px" + " 0" + " 0 " + borderColor.left.toRGBA(borderAlfa.left) + ", " + "inset " + -1 * ((drawRightSize > 0.1 && drawRightSize < 1) ? 1 : drawRightSize) + "px" + " 0" + " 0 " + borderColor.right.toRGBA(borderAlfa.right) + ", " + "inset " + "0 " + ((drawTopSize > 0.1 && drawTopSize < 1) ? 1 : drawTopSize) + "px" + " 0 " + borderColor.top.toRGBA(borderAlfa.top) + ", " + "inset " + "0 " + -1 * ((drawBottomSize > 0.1 && drawBottomSize < 1) ? 1 : drawBottomSize) + "px" + " 0 " + borderColor.bottom.toRGBA(borderAlfa.bottom);
divContent.css("box-shadow", value);
}
};
me.on("render:after", function (cmp) {
if (this.cmpEl) {
divContent = this.cmpEl.find(".cell-content");
applyStyle();
}
this.cmpEl.on("click", function (event) {
var pos = {
x: event.pageX - me.cmpEl.offset().left,
y: event.pageY - me.cmpEl.offset().top
};
var ptInPoly = function (npol, xp, yp, x, y) {
var i, j, c = 0;
for (i = 0, j = npol - 1; i < npol; j = i++) {
if ((((yp[i] <= y) && (y < yp[j])) || ((yp[j] <= y) && (y < yp[i]))) && (x < (xp[j] - xp[i]) * (y - yp[i]) / (yp[j] - yp[i]) + xp[i])) {
c = !c;
}
}
return c;
};
var meWidth = me.cmpEl.outerWidth();
var meHeight = me.cmpEl.outerHeight();
if (ptInPoly(4, [0, meWidth, meWidth - me.clickOffset, me.clickOffset], [0, 0, me.clickOffset, me.clickOffset], pos.x, pos.y)) {
if (me.overwriteStyle) {
if (borderSize.top != virtualBorderSize || !borderColor.top.isEqual(virtualBorderColor)) {
borderSize.top = virtualBorderSize;
borderColor.top = virtualBorderColor;
borderAlfa.top = (virtualBorderSize < 1) ? 0.3 : 1;
} else {
borderSize.top = 0;
}
} else {
borderSize.top = (borderSize.top > 0) ? 0 : virtualBorderSize;
borderColor.top = virtualBorderColor;
}
me.fireEvent("borderclick", me, "t", borderSize.top, borderColor.top.toHex());
} else {
if (ptInPoly(4, [meWidth, meWidth, meWidth - me.clickOffset, meWidth - me.clickOffset], [0, meHeight, meHeight - me.clickOffset, me.clickOffset], pos.x, pos.y)) {
if (me.overwriteStyle) {
if (borderSize.right != virtualBorderSize || !borderColor.right.isEqual(virtualBorderColor)) {
borderSize.right = virtualBorderSize;
borderColor.right = virtualBorderColor;
borderAlfa.right = (virtualBorderSize < 1) ? 0.3 : 1;
} else {
borderSize.right = 0;
}
} else {
borderSize.right = (borderSize.right > 0) ? 0 : virtualBorderSize;
borderColor.right = virtualBorderColor;
}
me.fireEvent("borderclick", me, "r", borderSize.right, borderColor.right.toHex());
} else {
if (ptInPoly(4, [0, me.clickOffset, meWidth - me.clickOffset, meWidth], [meHeight, meHeight - me.clickOffset, meHeight - me.clickOffset, meHeight], pos.x, pos.y)) {
if (me.overwriteStyle) {
if (borderSize.bottom != virtualBorderSize || !borderColor.bottom.isEqual(virtualBorderColor)) {
borderSize.bottom = virtualBorderSize;
borderColor.bottom = virtualBorderColor;
borderAlfa.bottom = (virtualBorderSize < 1) ? 0.3 : 1;
} else {
borderSize.bottom = 0;
}
} else {
borderSize.bottom = (borderSize.bottom > 0) ? 0 : virtualBorderSize;
borderColor.bottom = virtualBorderColor;
}
me.fireEvent("borderclick", me, "b", borderSize.bottom, borderColor.bottom.toHex());
} else {
if (ptInPoly(4, [0, me.clickOffset, me.clickOffset, 0], [0, me.clickOffset, meHeight - me.clickOffset, meHeight], pos.x, pos.y)) {
if (me.overwriteStyle) {
if (borderSize.left != virtualBorderSize || !borderColor.left.isEqual(virtualBorderColor)) {
borderSize.left = virtualBorderSize;
borderColor.left = virtualBorderColor;
borderAlfa.left = (virtualBorderSize < 1) ? 0.3 : 1;
} else {
borderSize.left = 0;
}
} else {
borderSize.left = (borderSize.left > 0) ? 0 : virtualBorderSize;
borderColor.left = virtualBorderColor;
}
me.fireEvent("borderclick", me, "l", borderSize.left, borderColor.left.toHex());
}
}
}
}
applyStyle();
});
});
me.setBordersSize = function (borders, size) {
size = (size > this.maxBorderSize) ? this.maxBorderSize : size;
if (borders.indexOf("t") > -1) {
borderSize.top = size;
borderAlfa.top = (size < 1) ? 0.3 : 1;
}
if (borders.indexOf("r") > -1) {
borderSize.right = size;
borderAlfa.right = (size < 1) ? 0.3 : 1;
}
if (borders.indexOf("b") > -1) {
borderSize.bottom = size;
borderAlfa.bottom = (size < 1) ? 0.3 : 1;
}
if (borders.indexOf("l") > -1) {
borderSize.left = size;
borderAlfa.left = (size < 1) ? 0.3 : 1;
}
applyStyle();
};
me.setBordersColor = function (borders, color) {
var newColor = new Common.Utils.RGBColor(color);
if (borders.indexOf("t") > -1) {
borderColor.top = newColor;
}
if (borders.indexOf("r") > -1) {
borderColor.right = newColor;
}
if (borders.indexOf("b") > -1) {
borderColor.bottom = newColor;
}
if (borders.indexOf("l") > -1) {
borderColor.left = newColor;
}
applyStyle();
};
me.getBorderSize = function (border) {
switch (border) {
case "t":
return borderSize.top;
case "r":
return borderSize.right;
case "b":
return borderSize.bottom;
case "l":
return borderSize.left;
}
return null;
};
me.getBorderColor = function (border) {
switch (border) {
case "t":
return borderColor.top.toHex();
case "r":
return borderColor.right.toHex();
case "b":
return borderColor.bottom.toHex();
case "l":
return borderColor.left.toHex();
}
return null;
};
me.setVirtualBorderSize = function (size) {
virtualBorderSize = (size > this.maxBorderSize) ? this.maxBorderSize : size;
};
me.setVirtualBorderColor = function (color) {
var newColor = new Common.Utils.RGBColor(color);
if (virtualBorderColor.isEqual(newColor)) {
return;
}
virtualBorderColor = newColor;
};
me.getVirtualBorderSize = function () {
return virtualBorderSize;
};
me.getVirtualBorderColor = function () {
return virtualBorderColor.toHex();
};
if (me.options.el) {
me.render();
}
},
render: function (parentEl) {
var me = this;
this.trigger("render:before", this);
if (!me.rendered) {
this.cmpEl = $(this.template({
id: this.id
}));
if (parentEl) {
this.setElement(parentEl, false);
parentEl.html(this.cmpEl);
} else {
$(this.el).html(this.cmpEl);
}
} else {
this.cmpEl = $(this.el);
}
me.rendered = true;
this.trigger("render:after", this);
return this;
}
});
Common.UI.TableStyler = Common.UI.BaseView.extend({
options: {
width: 200,
height: 200,
rows: 2,
columns: 2,
cellPadding: 10,
tablePadding: 10,
overwriteStyle: true,
maxBorderSize: 6,
spacingMode: false,
defaultBorderSize: 1,
defaultBorderColor: "#ccc"
},
template: _.template(['<div id="<%=scope.id%>" class="table-styler" style="position: relative; width: <%=scope.width%>px; height:<%=scope.height%>px;">', '<div style="position: absolute; left: 0; top: 0; width: <%=scope.tablePadding%>px; height: <%=scope.tablePadding%>px; border-bottom: 1px dotted gray; border-right: 1px dotted gray;"></div>', '<div style="position: absolute; left: <%=scope.tablePadding%>px; top: 0; right: <%=scope.tablePadding%>px; height: <%=scope.tablePadding%>px;">', '<div id="<%=scope.id%>-table-top-border-selector" style="position: absolute; z-index: 1; height: <%=scope.tablePadding%>px; left: 0; right: 0; top: <%=scope.tablePadding * .5%>px;">', '<table width="100%" height="100%">', "<tr>", '<td id="<%=scope.id%>-table-top-border" style="height:50%; border-bottom: <%=borderSize.top%>px solid <%borderColor.top.toHex()%>;"></td>', "</tr>", "<tr>", "<td></td>", "</tr>", "</table>", "</div>", "</div>", '<div style="position: absolute; top: 0; right: 0; width: <%=scope.tablePadding%>px; height: <%=scope.tablePadding%>px; border-bottom: 1px dotted gray; border-left: 1px dotted gray;"></div>', '<div style="position: absolute; left: 0; top: <%=scope.tablePadding%>px; width: <%=scope.tablePadding%>px; height: <%=scope.height - 2 * scope.tablePadding%>px;">', '<div id="<%=scope.id%>-table-left-border-selector" style="position: absolute; z-index: 1; left: <%=scope.tablePadding * .5%>px; top: 0; bottom: 0; width: <%=scope.tablePadding%>px;">', '<table width="100%" height="100%">', "<tr>", '<td id="<%=scope.id%>-table-left-border" style="border-right: <%=borderSize.left%>px solid <%=borderColor.left.toHex()%>;"></td>', '<td width="50%"></td>', "</tr>", "</table>", "</div>", "</div>", '<div style="position: absolute; left: <%=scope.tablePadding%>px; top: <%=scope.tablePadding%>px; right: <%=scope.tablePadding%>px; bottom: <%=scope.tablePadding%>px;">', '<table cols="<%=scope.columns%>" width="100%" height="100%" style="border-collapse: inherit; border-spacing: <%= scope.spacingMode ? scope.cellPadding : 0 %>px;">', "<% for (var row = 0; row < scope.rows; row++) { %>", "<tr>", "<% for (var col = 0; col < scope.columns; col++) { %>", '<td id="<%=scope.id%>-cell-container-<%=col%>-<%=row%>" class="content-box"></td>', "<% } %>", "</tr>", "<% } %>", "</table>", "</div>", '<div style="position: absolute; right: 0; top: <%=scope.tablePadding%>px; width: <%=scope.tablePadding%>px; height: <%=scope.height - 2 * scope.tablePadding%>px;">', '<div id="<%=scope.id%>-table-right-border-selector" style="position: absolute; z-index: 1; right: <%=scope.tablePadding * .5%>px; top: 0; bottom: 0; width: <%=scope.tablePadding%>px;">', '<table width="100%" height="100%">', "<tr>", '<td id="<%=scope.id%>-table-right-border" style="border-right: <%=borderSize.right%>px solid <%=borderColor.right.toHex()%>;"></td>', '<td width="50%"></td>', "</tr>", "</table>", "</div>", "</div>", '<div style="position: absolute; left: 0; bottom: 0; width: <%=scope.tablePadding%>px; height: <%=scope.tablePadding%>px; border-top: 1pt dotted gray; border-right: 1pt dotted gray;"></div>', '<div style="position: absolute; left: <%=scope.tablePadding%>px; bottom: 0; right: <%=scope.tablePadding%>px; height: <%=scope.tablePadding%>px;">', '<div id="<%=scope.id%>-table-bottom-border-selector" style="position: absolute; z-index: 1; height: <%=scope.tablePadding%>px; left: 0; right: 0; bottom: <%=scope.tablePadding * .5%>px;">', '<table width="100%" height="100%">', "<tr>", '<td id="<%=scope.id%>-table-bottom-border" style="height:50%; border-bottom: <%=borderSize.bottom%>px solid <%=borderColor.bottom.toHex()%>;"></td>', "</tr>", "<tr>", "<td></td>", "</tr>", "</table>", "</div>", "</div>", '<div style="position: absolute; bottom: 0; right: 0; width: <%=scope.tablePadding%>px; height: <%=scope.tablePadding%>px; border-top: 1pt dotted gray; border-left: 1pt dotted gray;"></div>', "</div>"].join("")),
initialize: function (options) {
Common.UI.BaseView.prototype.initialize.call(this, options);
var me = this,
topBorder, rightBorder, bottomBorder, leftBorder, topBorderSelector, rightBorderSelector, bottomBorderSelector, leftBorderSelector, virtualBorderSize, virtualBorderColor;
me.id = me.options.id || Common.UI.getId();
me.width = me.options.width;
me.height = me.options.height;
me.rows = me.options.rows;
me.columns = me.options.columns;
me.cellPadding = me.options.cellPadding;
me.tablePadding = me.options.tablePadding;
me.overwriteStyle = me.options.overwriteStyle;
me.maxBorderSize = me.options.maxBorderSize;
me.spacingMode = me.options.spacingMode;
me.defaultBorderSize = me.options.defaultBorderSize;
me.defaultBorderColor = me.options.defaultBorderColor;
virtualBorderSize = (me.defaultBorderSize > me.maxBorderSize) ? me.maxBorderSize : me.defaultBorderSize;
virtualBorderColor = new Common.Utils.RGBColor(me.defaultBorderColor);
var borderSize = {
top: virtualBorderSize,
right: virtualBorderSize,
bottom: virtualBorderSize,
left: virtualBorderSize
};
var borderColor = {
top: virtualBorderColor,
right: virtualBorderColor,
bottom: virtualBorderColor,
left: virtualBorderColor
};
me.rendered = false;
var applyStyles = function () {
topBorder && topBorder.css("border-bottom", ((borderSize.top > 0.1 && borderSize.top < 1) ? 1 : borderSize.top) + "px solid " + borderColor.top.toRGBA((borderSize.top < 1) ? 0.2 : 1));
rightBorder && rightBorder.css("border-right", ((borderSize.right > 0.1 && borderSize.right < 1) ? 1 : borderSize.right) + "px solid " + borderColor.right.toRGBA((borderSize.right < 1) ? 0.2 : 1));
bottomBorder && bottomBorder.css("border-bottom", ((borderSize.bottom > 0.1 && borderSize.bottom < 1) ? 1 : borderSize.bottom) + "px solid " + borderColor.bottom.toRGBA((borderSize.bottom < 1) ? 0.2 : 1));
leftBorder && leftBorder.css("border-right", ((borderSize.left > 0.1 && borderSize.left < 1) ? 1 : borderSize.left) + "px solid " + borderColor.left.toRGBA((borderSize.left < 1) ? 0.2 : 1));
redraw(topBorderSelector);
redraw(rightBorderSelector);
redraw(bottomBorderSelector);
redraw(leftBorderSelector);
};
var redraw = function (el) {
return el.hide(0, function () {
$(this).show();
});
};
me.on("render:after", function (cmp) {
var meId = me.id;
topBorder = $("#" + meId + "-table-top-border");
rightBorder = $("#" + meId + "-table-right-border");
bottomBorder = $("#" + meId + "-table-bottom-border");
leftBorder = $("#" + meId + "-table-left-border");
topBorderSelector = $("#" + meId + "-table-top-border-selector");
rightBorderSelector = $("#" + meId + "-table-right-border-selector");
bottomBorderSelector = $("#" + meId + "-table-bottom-border-selector");
leftBorderSelector = $("#" + meId + "-table-left-border-selector");
topBorderSelector.on("click", function (e) {
if (me.overwriteStyle) {
if (borderSize.top != virtualBorderSize || !borderColor.top.isEqual(virtualBorderColor)) {
borderSize.top = virtualBorderSize;
borderColor.top = virtualBorderColor;
} else {
borderSize.top = 0;
}
} else {
borderSize.top = (borderSize.top > 0) ? 0 : virtualBorderSize;
borderColor.top = virtualBorderColor;
}
topBorder.css("border-bottom", ((borderSize.top > 0.1 && borderSize.top < 1) ? 1 : borderSize.top) + "px solid " + borderColor.top.toRGBA((borderSize.top < 1) ? 0.2 : 1));
redraw(topBorderSelector);
me.fireEvent("borderclick", me, "t", borderSize.top, borderColor.top.toHex());
});
rightBorderSelector.on("click", function (e) {
if (me.overwriteStyle) {
if (borderSize.right != virtualBorderSize || !borderColor.right.isEqual(virtualBorderColor)) {
borderSize.right = virtualBorderSize;
borderColor.right = virtualBorderColor;
} else {
borderSize.right = 0;
}
} else {
borderSize.right = (borderSize.right > 0) ? 0 : virtualBorderSize;
borderColor.right = virtualBorderColor;
}
rightBorder.css("border-right", ((borderSize.right > 0.1 && borderSize.right < 1) ? 1 : borderSize.right) + "px solid " + borderColor.right.toRGBA((borderSize.right < 1) ? 0.2 : 1));
redraw(rightBorderSelector);
me.fireEvent("borderclick", me, "r", borderSize.right, borderColor.right.toHex());
});
bottomBorderSelector.on("click", function (e) {
if (me.overwriteStyle) {
if (borderSize.bottom != virtualBorderSize || !borderColor.bottom.isEqual(virtualBorderColor)) {
borderSize.bottom = virtualBorderSize;
borderColor.bottom = virtualBorderColor;
} else {
borderSize.bottom = 0;
}
} else {
borderSize.bottom = (borderSize.bottom > 0) ? 0 : virtualBorderSize;
borderColor.bottom = virtualBorderColor;
}
bottomBorder.css("border-bottom", ((borderSize.bottom > 0.1 && borderSize.bottom < 1) ? 1 : borderSize.bottom) + "px solid " + borderColor.bottom.toRGBA((borderSize.bottom < 1) ? 0.2 : 1));
redraw(bottomBorderSelector);
me.fireEvent("borderclick", me, "b", borderSize.bottom, borderColor.bottom.toHex());
});
leftBorderSelector.on("click", function (e) {
if (me.overwriteStyle) {
if (borderSize.left != virtualBorderSize || !borderColor.left.isEqual(virtualBorderColor)) {
borderSize.left = virtualBorderSize;
borderColor.left = virtualBorderColor;
} else {
borderSize.left = 0;
}
} else {
borderSize.left = (borderSize.left > 0) ? 0 : virtualBorderSize;
borderColor.left = virtualBorderColor;
}
leftBorder.css("border-right", ((borderSize.left > 0.1 && borderSize.left < 1) ? 1 : borderSize.left) + "px solid " + borderColor.left.toRGBA((borderSize.left < 1) ? 0.2 : 1));
redraw(leftBorderSelector);
me.fireEvent("borderclick", me, "l", borderSize.left, borderColor.left.toHex());
});
});
me.getVirtualBorderSize = function () {
return virtualBorderSize;
};
me.getVirtualBorderColor = function () {
return virtualBorderColor.toHex();
};
me.setVirtualBorderSize = function (size) {
size = (size > me.maxBorderSize) ? me.maxBorderSize : size;
virtualBorderSize = size;
for (var row = 0; row < me.rows; row++) {
for (var col = 0; col < me.columns; col++) {
var cell = me.getCell(col, row);
cell.setVirtualBorderSize(size);
}
}
};
me.setVirtualBorderColor = function (color) {
var newColor = new Common.Utils.RGBColor(color);
if (virtualBorderColor.isEqual(newColor)) {
return;
}
virtualBorderColor = newColor;
for (var row = 0; row < me.rows; row++) {
for (var col = 0; col < me.columns; col++) {
var cell = me.getCell(col, row);
cell.setVirtualBorderColor(virtualBorderColor.toHex());
}
}
};
me.setBordersSize = function (borders, size) {
size = (size > me.maxBorderSize) ? me.maxBorderSize : size;
if (borders.indexOf("t") > -1) {
borderSize.top = size;
}
if (borders.indexOf("r") > -1) {
borderSize.right = size;
}
if (borders.indexOf("b") > -1) {
borderSize.bottom = size;
}
if (borders.indexOf("l") > -1) {
borderSize.left = size;
}
applyStyles();
};
me.setBordersColor = function (borders, color) {
var newColor = new Common.Utils.RGBColor(color);
if (borders.indexOf("t") > -1) {
borderColor.top = newColor;
}
if (borders.indexOf("r") > -1) {
borderColor.right = newColor;
}
if (borders.indexOf("b") > -1) {
borderColor.bottom = newColor;
}
if (borders.indexOf("l") > -1) {
borderColor.left = newColor;
}
applyStyles();
};
me.getBorderSize = function (border) {
switch (border) {
case "t":
return borderSize.top;
case "r":
return borderSize.right;
case "b":
return borderSize.bottom;
case "l":
return borderSize.left;
}
return null;
};
me.getBorderColor = function (border) {
switch (border) {
case "t":
return borderColor.top.toHex();
case "r":
return borderColor.right.toHex();
case "b":
return borderColor.bottom.toHex();
case "l":
return borderColor.left.toHex();
}
return null;
};
if (me.options.el) {
me.render(null, {
borderSize: borderSize,
borderColor: borderColor,
virtualBorderSize: virtualBorderSize,
virtualBorderColor: virtualBorderColor
});
}
},
render: function (parentEl) {
var me = this,
cfg = arguments[1];
this.trigger("render:before", this);
if (!me.rendered) {
this.cmpEl = $(this.template(_.extend({
scope: me
},
cfg)));
if (parentEl) {
this.setElement(parentEl, false);
this.setElement(parentEl, false);
parentEl.html(this.cmpEl);
} else {
$(this.el).html(this.cmpEl);
}
} else {
this.cmpEl = $(this.el);
}
if (!me.rendered) {
var el = this.cmpEl;
this._cells = [];
for (var row = 0; row < me.rows; row++) {
for (var col = 0; col < me.columns; col++) {
var cellStyler = new Common.UI.CellStyler({
el: $("#" + me.id + "-cell-container-" + col + "-" + row),
overwriteStyle: me.overwriteStyle,
halfBorderSize: !me.spacingMode,
defaultBorderSize: me.spacingMode ? cfg.virtualBorderSize : 0,
defaultBorderColor: cfg.virtualBorderColor.toHex(),
id: me.id + "-cell-" + col + "-" + row,
col: col,
row: row
});
this._cells.push(cellStyler);
cellStyler.on("borderclick", function (cell, type, size, color) {
var cellCol, cellRow, curCell;
if (type == "t") {
if (cell.row > 0) {
for (cellCol = 0; cellCol < me.columns; cellCol++) {
curCell = me.getCell(cellCol, cell.row - 1);
curCell.setBordersSize("b", size);
curCell.setBordersColor("b", color);
}
}
for (cellCol = 0; cellCol < me.columns; cellCol++) {
curCell = me.getCell(cellCol, cell.row);
if (cell.halfBorderSize && cell.row < 1) {
curCell.setBordersSize("t", 0);
} else {
curCell.setBordersSize("t", size);
}
curCell.setBordersColor("t", color);
}
} else {
if (type == "b") {
if (cell.row < me.rows - 1) {
for (cellCol = 0; cellCol < me.columns; cellCol++) {
curCell = me.getCell(cellCol, cell.row + 1);
curCell.setBordersSize("t", size);
curCell.setBordersColor("t", color);
}
}
for (cellCol = 0; cellCol < me.columns; cellCol++) {
curCell = me.getCell(cellCol, cell.row);
if (cell.halfBorderSize && cell.row >= me.rows - 1) {
curCell.setBordersSize("b", 0);
} else {
curCell.setBordersSize("b", size);
}
curCell.setBordersColor("b", color);
}
} else {
if (type == "l") {
if (cell.col > 0) {
for (cellRow = 0; cellRow < me.rows; cellRow++) {
curCell = me.getCell(cell.col - 1, cellRow);
curCell.setBordersSize("r", size);
curCell.setBordersColor("r", color);
}
}
for (cellRow = 0; cellRow < me.rows; cellRow++) {
curCell = me.getCell(cell.col, cellRow);
if (cell.halfBorderSize && cell.col < 1) {
curCell.setBordersSize("l", 0);
} else {
curCell.setBordersSize("l", size);
}
curCell.setBordersColor("l", color);
}
} else {
if (type == "r") {
if (cell.col < me.columns - 1) {
for (cellRow = 0; cellRow < me.rows; cellRow++) {
curCell = me.getCell(cell.col + 1, cellRow);
curCell.setBordersSize("l", size);
curCell.setBordersColor("l", color);
}
}
for (cellRow = 0; cellRow < me.rows; cellRow++) {
curCell = me.getCell(cell.col, cellRow);
if (cell.halfBorderSize && cell.col >= me.columns - 1) {
curCell.setBordersSize("r", 0);
} else {
curCell.setBordersSize("r", size);
}
curCell.setBordersColor("r", color);
}
}
}
}
}
});
}
}
}
me.rendered = true;
this.trigger("render:after", this);
return this;
},
getCell: function (col, row) {
return _.findWhere(this._cells, {
id: this.id + "-cell-" + col + "-" + row
});
}
});
});

View File

@@ -1,366 +1,361 @@
/*
* (c) Copyright Ascensio System SIA 2010-2014
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
Ext.define("Common.component.ThemeColorPalette", {
extend: "Ext.ColorPalette",
alias: "widget.cmpthemecolorpalette",
allowReselect: true,
dyncolorscount: 12,
width: 193,
maxWidth: 200,
baseCls: "cmp-theme-colorpalette",
requires: ["Common.view.ExtendedColorDialog"],
renderTpl: ['<div style="padding: 12px;">', '<tpl for="colors">', '<tpl if="this.isBlankSeparator(values)"><div class="palette-color-spacer" style="width:100%;height:8px;float:left;"></div></tpl>', '<tpl if="this.isSeparator(values)"></div><div class="palette-color-separator" style="width:100%;height:1px;float:left;border-bottom: 1px solid #E0E0E0"></div><div style="padding: 12px;"></tpl>', '<tpl if="this.isColor(values)">', '<a href="#" class="palette-color color-{.}" style="background:#{.} "hidefocus="on">', '<em><span style="background:#{.}; border: 1px solid rgba(0, 0, 0, 0.2);" unselectable="on">&#160;</span></em>', "</a>", "</tpl>", '<tpl if="this.isTransparent(values)">', '<a href="#" class="color-{.}" hidefocus="on">', '<em><span unselectable="on">&#160;</span></em>', "</a>", "</tpl>", '<tpl if="this.isCustom(values)">', '<a href="#" id="{id}" class="palette-color-custom {cls}" hidefocus="on">', '<em><span style="background:#FFFFFF;background-image:url({image});" unselectable="on">&#160;</span></em>', "</a>", "</tpl>", '<tpl if="this.isEffect(values)">', '<a href="#" effectid="{effectId}" effectvalue="{effectValue}" class="palette-color-effect color-{color}" style="background:#{color}" hidefocus="on">', '<em><span style="background:#{color}; border: 1px solid rgba(0, 0, 0, 0.2);" unselectable="on">&#160;</span></em>', "</a>", "</tpl>", '<tpl if="this.isCaption(values)"><div class="palette-color-caption" style="width:100%;float:left;font-size: 11px;">{.}</div></tpl>', "</tpl>", "</div>", {
isBlankSeparator: function (v) {
return typeof(v) == "string" && v == "-";
},
isSeparator: function (v) {
return typeof(v) == "string" && v == "--";
},
isColor: function (v) {
return typeof(v) == "string" && (/[0-9A-F]{6}/).test(v);
},
isTransparent: function (v) {
return typeof(v) == "string" && (v == "transparent");
},
isCaption: function (v) {
return (typeof(v) == "string" && v != "-" && v != "--" && !(/[0-9A-F]{6}|transparent/).test(v));
},
isEffect: function (v) {
return (typeof(v) == "object" && v.effectId !== undefined);
},
isCustom: function (v) {
return (typeof(v) == "object" && v.effectId === undefined);
}
}],
constructor: function (config) {
this.initConfig(config);
this.callParent(arguments);
return this;
},
initComponent: function () {
this.callParent(arguments);
},
onRender: function (o) {
this.callParent(arguments);
if (this.dynamiccolors) {
var picker = o.down(".x-color-picker");
if (picker) {
var i = -1,
colors = '<div class="palette-color-spacer" style="width:100%;height:8px;float:left;"></div><div style="padding: 12px;">';
while (++i < this.dyncolorscount) {
colors += Ext.String.format('<a href="#" class="color-dynamic-{0} dynamic-empty-color" style="background:#ffffff" color="" hidefocus="on">' + '<em><span unselectable="on">&#160;</span></em></a>', i);
}
colors += "</div>";
Ext.DomHelper.insertHtml("beforeEnd", picker.dom, colors);
}
}
var menu = this.el.up(".x-menu");
if (menu) {
Ext.menu.Manager.menus[menu.id].addListener("beforeshow", this.updateCustomColors, this);
}
this.updateCustomColors();
},
afterRender: function (o) {
this.callParent(arguments);
if (this.updateColorsArr) {
this.updateColors(this.updateColorsArr[0], this.updateColorsArr[1]);
}
if (this.lastvalue) {
this.select(this.lastvalue, true);
}
},
setCustomColor: function (color) {
color = /#?([a-fA-F0-9]{6})/.exec(color);
if (color) {
var el = this.getEl();
if (el) {
this._saveCustomColor(color[1]);
$("#" + el.id + " a." + this.selectedCls).removeClass(this.selectedCls);
var child = el.down(".dynamic-empty-color");
if (!child) {
this.updateCustomColors();
child = el.down(".color-dynamic-" + (this.dyncolorscount - 1));
}
child.removeCls("dynamic-empty-color").addCls(this.selectedCls).dom.setAttribute("color", color[1]);
child.down("span").setStyle("background-color", "#" + color[1]).setStyle("border", "none");
}
}
},
select: function (color, suppressEvent) {
if (!this.rendered) {
this.lastvalue = color;
return;
}
var el = this.getEl();
if (el) {
$("#" + el.id + " a." + this.selectedCls).removeClass(this.selectedCls);
}
if (typeof(color) == "object") {
var effectEl;
if (color.effectId !== undefined) {
effectEl = el.down('a[effectid="' + color.effectId + '"]');
if (effectEl) {
effectEl.addCls(this.selectedCls);
this.value = effectEl.dom.className.match(this.colorRe)[1].toUpperCase();
} else {
this.value = false;
}
} else {
if (color.effectValue !== undefined) {
effectEl = el.down('a[effectvalue="' + color.effectValue + '"].color-' + color.color.toUpperCase());
if (effectEl) {
effectEl.addCls(this.selectedCls);
this.value = effectEl.dom.className.match(this.colorRe)[1].toUpperCase();
} else {
this.value = false;
}
}
}
} else {
if (/#?[a-fA-F0-9]{6}/.test(color)) {
color = /#?([a-fA-F0-9]{6})/.exec(color)[1].toUpperCase();
this.value = color;
}
if (/^[a-fA-F0-9]{6}|transparent$/.test(color) && Ext.Array.contains(this.colors, color)) {
if (!Ext.Array.contains(this.colors, this.value)) {
this.value = false;
}
if (color != this.value || this.allowReselect) {
if (this.value) {
(this.value == "transparent") ? el.down("a.color-transparent").removeCls(this.selectedCls) : el.down("a.palette-color.color-" + this.value).removeCls(this.selectedCls);
} (color == "transparent") ? el.down("a.color-transparent").addCls(this.selectedCls) : el.down("a.palette-color.color-" + color).addCls(this.selectedCls);
this.value = color;
if (suppressEvent !== true) {
this.fireEvent("select", this, color);
}
}
} else {
if (el) {
var co = el.down("#" + color) || el.down('a[color="' + color + '"]');
if (co) {
co.addCls(this.selectedCls);
this.value = color.toUpperCase();
} else {
if (el.down("a." + this.selectedCls)) {
this.value = false;
} else {
if (this.dynamiccolors) {}
}
}
} else {
this.lastvalue = color;
}
}
}
},
handleClick: function (event, target) {
var me = this;
var color, cmp;
if (! (target.className.search("palette-color-custom") < 0)) {
event.stopEvent();
cmp = Ext.get(target.parentNode).down("a." + me.selectedCls);
if (!cmp || cmp.id != target.id) {
if (cmp) {
cmp.removeCls(me.selectedCls);
}
Ext.get(target.id).addCls(me.selectedCls);
me.value = false;
me.fireEvent("select", me, target.id);
} else {
me.fireEvent("select", me, cmp.id);
}
} else {
if (! (target.className.search("color-transparent") < 0)) {
event.stopEvent();
cmp = Ext.get(target.parentNode).down("a." + me.selectedCls);
if (!cmp || cmp.id != target.id) {
if (cmp) {
cmp.removeCls(me.selectedCls);
}
Ext.get(target).addCls(me.selectedCls);
me.value = "transparent";
}
me.fireEvent("select", me, "transparent");
} else {
if (! (target.className.search("color-dynamic") < 0)) {
if (!/dynamic-empty-color/.test(target.className)) {
color = target.getAttribute("color");
if (color) {
me.fireEvent("select", me, color);
}
this.value = color.toUpperCase();
$("#" + this.getEl().id + " a." + me.selectedCls).removeClass(me.selectedCls);
Ext.get(target).addCls(me.selectedCls);
} else {
setTimeout(function () {
me.addNewColor();
Ext.menu.Manager.hideAll();
},
10);
}
} else {
cmp = Ext.get(target.parentNode).down("a.palette-color-custom");
if (cmp) {
cmp.removeCls(me.selectedCls);
}
if (!/^[a-fA-F0-9]{6}$/.test(this.value) || !Ext.Array.contains(this.colors, this.value)) {
this.value = false;
}
if (! (target.className.search("palette-color-effect") < 0)) {
color = target.className.match(me.colorRe)[1];
var effectId = target.getAttribute("effectid");
if (color) {
me.fireEvent("select", me, {
color: color,
effectId: effectId
});
this.value = color.toUpperCase();
}
$("#" + this.getEl().id + " a." + me.selectedCls).removeClass(me.selectedCls);
Ext.get(target).addCls(me.selectedCls);
} else {
this.callParent(arguments);
}
}
}
}
},
addNewColor: function () {
var me = this;
var win = Ext.create("Common.view.ExtendedColorDialog", {});
win.addListener("onmodalresult", function (mr) {
me._isdlgopen = false;
if (mr == 1) {
me.setCustomColor(win.getColor());
me.fireEvent("select", me, win.getColor());
}
},
false);
me._isdlgopen = true;
win.setColor(me.value);
win.show();
},
isDialogOpen: function () {
return this._isdlgopen == true;
},
updateColors: function (effectcolors, standartcolors) {
if (!this.rendered) {
this.updateColorsArr = [effectcolors, (standartcolors.length == 0 && this.updateColorsArr) ? this.updateColorsArr[1] : standartcolors];
return;
}
var me = this,
el = this.getEl();
if (me.aColorElements === undefined) {
me.aColorElements = el.query("a.palette-color");
}
if (me.aEffectElements === undefined) {
me.aEffectElements = el.query("a.palette-color-effect");
}
var aEl;
var aColorIdx = 0,
aEffectIdx = 0;
for (var i = 0; i < me.colors.length; i++) {
if (typeof(me.colors[i]) == "string" && (/[0-9A-F]{6}/).test(me.colors[i])) {
if (aColorIdx >= standartcolors.length) {
continue;
}
aEl = Ext.get(me.aColorElements[aColorIdx]);
aEl.removeCls("color-" + me.colors[i]);
me.colors[i] = standartcolors[aColorIdx].toUpperCase();
aEl.addCls("color-" + me.colors[i]);
aEl.applyStyles({
background: "#" + me.colors[i]
});
aEl.down("span").applyStyles({
background: "#" + me.colors[i]
});
aColorIdx++;
} else {
if (typeof(me.colors[i]) == "object" && me.colors[i].effectId !== undefined) {
if (aEffectIdx >= effectcolors.length) {
continue;
}
aEl = Ext.get(me.aEffectElements[aEffectIdx]);
effectcolors[aEffectIdx].color = effectcolors[aEffectIdx].color.toUpperCase();
if (me.colors[i].color !== effectcolors[aEffectIdx].color) {
aEl.removeCls("color-" + me.colors[i].color);
aEl.addCls("color-" + effectcolors[aEffectIdx].color);
aEl.applyStyles({
background: "#" + effectcolors[aEffectIdx].color
});
aEl.down("span").applyStyles({
background: "#" + effectcolors[aEffectIdx].color
});
}
if (me.colors[i].effectId !== effectcolors[aEffectIdx].effectId) {
aEl.set({
effectid: effectcolors[aEffectIdx].effectId
});
}
if (me.colors[i].effectValue !== effectcolors[aEffectIdx].effectValue) {
aEl.set({
effectvalue: effectcolors[aEffectIdx].effectValue
});
}
me.colors[i] = effectcolors[aEffectIdx];
aEffectIdx++;
}
}
}
this.updateColorsArr = undefined;
},
updateCustomColors: function () {
var picker = this.getEl();
if (picker) {
var colors = localStorage["asc." + window.storagename + ".colors.custom"];
colors = colors ? colors.split(",") : [];
var i = -1,
colorEl, c = colors.length < this.dyncolorscount ? colors.length : this.dyncolorscount;
while (++i < c) {
colorEl = picker.down(".color-dynamic-" + i);
colorEl.removeCls("dynamic-empty-color").dom.setAttribute("color", colors[i]);
colorEl.down("span").setStyle("background-color", "#" + colors[i]).setStyle("border", "none");
}
}
},
_saveCustomColor: function (color) {
var colors = localStorage["asc." + window.storagename + ".colors.custom"];
colors = colors ? colors.split(",") : [];
if (colors.push(color) > this.dyncolorscount) {
colors.shift();
}
localStorage["asc." + window.storagename + ".colors.custom"] = colors.join().toUpperCase();
},
_menuBeforeShow: function () {
this.updateCustomColors();
}
/*
* (c) Copyright Ascensio System SIA 2010-2015
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
if (Common === undefined) {
var Common = {};
}
define(["common/main/lib/component/BaseView", "common/main/lib/view/ExtendedColorDialog"], function () {
Common.UI.ThemeColorPalette = Common.UI.BaseView.extend({
options: {
dynamiccolors: 10,
allowReselect: true,
value: "000000"
},
template: _.template('<div style="padding: 12px;">' + "<% var me = this; %>" + "<% $(colors).each(function(num, item) { %>" + '<% if (me.isBlankSeparator(item)) { %> <div class="palette-color-spacer" style="width:100%;height:8px;float:left;"></div>' + '<% } else if (me.isSeparator(item)) { %> </div><div class="palette-color-separator" style="width:100%;height:1px;float:left;border-bottom: 1px solid #E0E0E0"></div><div style="padding: 12px;">' + "<% } else if (me.isColor(item)) { %> " + '<a class="palette-color color-<%=item%>" style="background:#<%=item%>" hidefocus="on">' + '<em><span style="background:#<%=item%>;" unselectable="on">&#160;</span></em>' + "</a>" + "<% } else if (me.isTransparent(item)) { %>" + '<a class="color-<%=item%>" hidefocus="on">' + '<em><span unselectable="on">&#160;</span></em>' + "</a>" + "<% } else if (me.isEffect(item)) { %>" + '<a effectid="<%=item.effectId%>" effectvalue="<%=item.effectValue%>" class="palette-color-effect color-<%=item.color%>" style="background:#<%=item.color%>" hidefocus="on">' + '<em><span style="background:#<%=item.color%>;" unselectable="on">&#160;</span></em>' + "</a>" + "<% } else if (me.isCaption(item)) { %>" + '<div class="palette-color-caption" style="width:100%;float:left;font-size: 11px;"><%=item%></div>' + "<% } %>" + "<% }); %>" + "</div>" + "<% if (me.options.dynamiccolors!==undefined) { %>" + '<div class="palette-color-spacer" style="width:100%;height:8px;float:left;"></div><div style="padding: 12px;">' + "<% for (var i=0; i<me.options.dynamiccolors; i++) { %>" + '<a class="color-dynamic-<%=i%> dynamic-empty-color" style="background:#ffffff" color="" hidefocus="on">' + '<em><span unselectable="on">&#160;</span></em></a>' + "<% } %>" + "<% } %>" + "</div>"),
colorRe: /(?:^|\s)color-(.{6})(?:\s|$)/,
selectedCls: "selected",
initialize: function (options) {
Common.UI.BaseView.prototype.initialize.call(this, options);
var me = this,
el = $(this.el);
this.colors = me.options.colors || [{
color: "000000",
effectId: 1
},
{
color: "FFFFFF",
effectId: 2
},
{
color: "000000",
effectId: 3
},
{
color: "FFFFFF",
effectId: 4
},
{
color: "000000",
effectId: 5
},
{
color: "FF0000",
effectId: 1
},
{
color: "FF6600",
effectId: 1
},
{
color: "FFFF00",
effectId: 2
},
{
color: "CCFFCC",
effectId: 3
},
{
color: "008000",
effectId: 4
},
"-", "--", "-", "000000", "5301B3", "980ABD", "B2275F", "F83D26", "F86A1D", "F7AC16", "F7CA12", "FAFF44", "D6EF39"];
el.addClass("theme-colorpalette");
this.render();
if (this.options.updateColorsArr) {
this.updateColors(this.options.updateColorsArr[0], this.options.updateColorsArr[1]);
}
if (this.options.value) {
this.select(this.options.value, true);
}
this.updateCustomColors();
el.closest(".btn-group").on("show.bs.dropdown", _.bind(this.updateCustomColors, this));
el.closest(".dropdown-submenu").on("show.bs.dropdown", _.bind(this.updateCustomColors, this));
el.on("click", _.bind(this.handleClick, this));
},
render: function () {
$(this.el).html(this.template({
colors: this.colors
}));
return this;
},
isBlankSeparator: function (v) {
return typeof(v) == "string" && v == "-";
},
isSeparator: function (v) {
return typeof(v) == "string" && v == "--";
},
isColor: function (v) {
return typeof(v) == "string" && (/[0-9A-F]{6}/).test(v);
},
isTransparent: function (v) {
return typeof(v) == "string" && (v == "transparent");
},
isCaption: function (v) {
return (typeof(v) == "string" && v != "-" && v != "--" && !(/[0-9A-F]{6}|transparent/).test(v));
},
isEffect: function (v) {
return (typeof(v) == "object" && v.effectId !== undefined);
},
getColor: function () {
return this.value;
},
updateCustomColors: function () {
var el = $(this.el);
if (el) {
var colors = localStorage["asc." + window.storagename + ".colors.custom"];
colors = colors ? colors.split(",") : [];
var i = -1,
colorEl, c = colors.length < this.options.dynamiccolors ? colors.length : this.options.dynamiccolors;
while (++i < c) {
colorEl = el.find(".color-dynamic-" + i);
colorEl.removeClass("dynamic-empty-color").attr("color", colors[i]);
colorEl.find("span").css({
"background-color": "#" + colors[i]
});
}
}
},
handleClick: function (e) {
var me = this;
var target = $(e.target).closest("a");
var color, cmp;
if (target.length == 0) {
return;
}
if (target.hasClass("color-transparent")) {
$(me.el).find("a." + me.selectedCls).removeClass(me.selectedCls);
target.addClass(me.selectedCls);
me.value = "transparent";
me.trigger("select", me, "transparent");
} else {
if (! (target[0].className.search("color-dynamic") < 0)) {
if (!/dynamic-empty-color/.test(target[0].className)) {
$(me.el).find("a." + me.selectedCls).removeClass(me.selectedCls);
target.addClass(me.selectedCls);
color = target.attr("color");
if (color) {
me.trigger("select", me, color);
}
me.value = color.toUpperCase();
} else {
setTimeout(function () {
me.addNewColor();
},
10);
}
} else {
if (!/^[a-fA-F0-9]{6}$/.test(me.value) || _.indexOf(me.colors, me.value) < 0) {
me.value = false;
}
$(me.el).find("a." + me.selectedCls).removeClass(me.selectedCls);
target.addClass(me.selectedCls);
color = target[0].className.match(me.colorRe)[1];
if (target.hasClass("palette-color-effect")) {
var effectId = parseInt(target.attr("effectid"));
if (color) {
me.value = color.toUpperCase();
me.trigger("select", me, {
color: color,
effectId: effectId
});
}
} else {
if (/#?[a-fA-F0-9]{6}/.test(color)) {
color = /#?([a-fA-F0-9]{6})/.exec(color)[1].toUpperCase();
me.value = color;
me.trigger("select", me, color);
}
}
}
}
},
setCustomColor: function (color) {
var el = $(this.el);
color = /#?([a-fA-F0-9]{6})/.exec(color);
if (color) {
this.saveCustomColor(color[1]);
el.find("a." + this.selectedCls).removeClass(this.selectedCls);
var child = el.find(".dynamic-empty-color");
if (child.length == 0) {
this.updateCustomColors();
child = el.find(".color-dynamic-" + (this.options.dynamiccolors - 1));
}
child.first().removeClass("dynamic-empty-color").addClass(this.selectedCls).attr("color", color[1]);
child.first().find("span").css({
"background-color": "#" + color[1]
});
this.select(color[1], true);
}
},
saveCustomColor: function (color) {
var colors = localStorage["asc." + window.storagename + ".colors.custom"];
colors = colors ? colors.split(",") : [];
if (colors.push(color) > this.options.dynamiccolors) {
colors.shift();
}
localStorage["asc." + window.storagename + ".colors.custom"] = colors.join().toUpperCase();
},
addNewColor: function (defcolor) {
var me = this;
var win = new Common.UI.ExtendedColorDialog({});
win.on("onmodalresult", function (mr) {
me._isdlgopen = false;
if (mr == 1) {
me.setCustomColor(win.getColor());
me.fireEvent("select", me, win.getColor());
}
});
me._isdlgopen = true;
win.setColor((me.value !== undefined && me.value !== false) ? me.value : ((defcolor !== undefined) ? defcolor : "000000"));
win.show();
},
isDialogOpen: function () {
return this._isdlgopen == true;
},
select: function (color, suppressEvent) {
var el = $(this.el);
el.find("a." + this.selectedCls).removeClass(this.selectedCls);
if (typeof(color) == "object") {
var effectEl;
if (color.effectId !== undefined) {
effectEl = el.find('a[effectid="' + color.effectId + '"]').first();
if (effectEl.length > 0) {
effectEl.addClass(this.selectedCls);
this.value = effectEl[0].className.match(this.colorRe)[1].toUpperCase();
} else {
this.value = false;
}
} else {
if (color.effectValue !== undefined) {
effectEl = el.find('a[effectvalue="' + color.effectValue + '"].color-' + color.color.toUpperCase()).first();
if (effectEl.length > 0) {
effectEl.addClass(this.selectedCls);
this.value = effectEl[0].className.match(this.colorRe)[1].toUpperCase();
} else {
this.value = false;
}
}
}
} else {
if (/#?[a-fA-F0-9]{6}/.test(color)) {
color = /#?([a-fA-F0-9]{6})/.exec(color)[1].toUpperCase();
this.value = color;
}
if (/^[a-fA-F0-9]{6}|transparent$/.test(color) && _.indexOf(this.colors, color) >= 0) {
if (_.indexOf(this.colors, this.value) < 0) {
this.value = false;
}
if (color != this.value || this.options.allowReselect) {
(color == "transparent") ? el.find("a.color-transparent").addClass(this.selectedCls) : el.find("a.palette-color.color-" + color).first().addClass(this.selectedCls);
this.value = color;
if (suppressEvent !== true) {
this.fireEvent("select", this, color);
}
}
} else {
var co = el.find("#" + color).first();
if (co.length == 0) {
co = el.find('a[color="' + color + '"]').first();
}
if (co.length > 0) {
co.addClass(this.selectedCls);
this.value = color.toUpperCase();
}
}
}
},
updateColors: function (effectcolors, standartcolors) {
if (effectcolors === undefined || standartcolors === undefined) {
return;
}
var me = this,
el = $(this.el);
if (me.aColorElements === undefined) {
me.aColorElements = el.find("a.palette-color");
}
if (me.aEffectElements === undefined) {
me.aEffectElements = el.find("a.palette-color-effect");
}
var aEl;
var aColorIdx = 0,
aEffectIdx = 0;
for (var i = 0; i < me.colors.length; i++) {
if (typeof(me.colors[i]) == "string" && (/[0-9A-F]{6}/).test(me.colors[i])) {
if (aColorIdx >= standartcolors.length) {
continue;
}
aEl = $(me.aColorElements[aColorIdx]);
aEl.removeClass("color-" + me.colors[i]);
me.colors[i] = standartcolors[aColorIdx].toUpperCase();
aEl.addClass("color-" + me.colors[i]);
aEl.css({
background: "#" + me.colors[i]
});
aEl.find("span").first().css({
background: "#" + me.colors[i]
});
aColorIdx++;
} else {
if (typeof(me.colors[i]) == "object" && me.colors[i].effectId !== undefined) {
if (aEffectIdx >= effectcolors.length) {
continue;
}
aEl = $(me.aEffectElements[aEffectIdx]);
effectcolors[aEffectIdx].color = effectcolors[aEffectIdx].color.toUpperCase();
if (me.colors[i].color !== effectcolors[aEffectIdx].color) {
aEl.removeClass("color-" + me.colors[i].color);
aEl.addClass("color-" + effectcolors[aEffectIdx].color);
aEl.css({
background: "#" + effectcolors[aEffectIdx].color
});
aEl.find("span").first().css({
background: "#" + effectcolors[aEffectIdx].color
});
}
if (me.colors[i].effectId !== effectcolors[aEffectIdx].effectId) {
aEl.attr("effectid", "" + effectcolors[aEffectIdx].effectId);
}
if (me.colors[i].effectValue !== effectcolors[aEffectIdx].effectValue) {
aEl.attr("effectvalue", "" + effectcolors[aEffectIdx].effectValue);
}
me.colors[i] = effectcolors[aEffectIdx];
aEffectIdx++;
}
}
}
this.options.updateColorsArr = undefined;
},
clearSelection: function (suppressEvent) {
$(this.el).find("a." + this.selectedCls).removeClass(this.selectedCls);
this.value = undefined;
}
});
});

View File

@@ -0,0 +1,88 @@
/*
* (c) Copyright Ascensio System SIA 2010-2015
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
if (Common === undefined) {
var Common = {};
}
define(["common/main/lib/component/BaseView"], function () {
var groups = {};
function toggleGroup(cmp, state) {
var g, i, l;
if (state) {
g = groups[cmp.toggleGroup];
for (i = 0, l = g.length; i < l; i++) {
if (g[i] !== cmp) {
if (g[i].isActive) {
g[i].isActive() && g[i].toggle(false);
} else {
g[i].toggle(false);
}
}
}
}
}
Common.UI.ToggleManager = {
register: function (cmp) {
if (!cmp.toggleGroup) {
return;
}
var group = groups[cmp.toggleGroup];
if (!group) {
group = groups[cmp.toggleGroup] = [];
}
group.push(cmp);
cmp.on("toggle", toggleGroup);
},
unregister: function (cmp) {
if (!cmp.toggleGroup) {
return;
}
var group = groups[cmp.toggleGroup];
if (group) {
_.without(group, cmp);
cmp.off("toggle", toggleGroup);
}
},
getToggled: function (group) {
var g = groups[group],
i = 0,
len;
if (g) {
for (len = g.length; i < len; i++) {
if (g[i].pressed === true || g[i].checked === true) {
return g[i];
}
}
}
return null;
}
};
});

View File

@@ -0,0 +1,91 @@
/*
* (c) Copyright Ascensio System SIA 2010-2015
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
define(["tip", "backbone"], function () {
var Tooltip = function (options) {
this.$element = this.placement = undefined;
this.init.call(this, options);
};
_.extend(Tooltip.prototype, Backbone.Events, {
init: function (opts) {
this.$element = opts.owner instanceof Backbone.View ? opts.owner.$el : $(opts.owner);
this.placement = opts.placement;
if (this.$element.data("bs.tooltip")) {
this.$element.removeData("bs.tooltip");
}
this.$element.tooltip({
title: opts.title,
trigger: "manual",
placement: opts.placement,
offset: opts.offset,
cls: opts.cls,
html: opts.html,
hideonclick: opts.hideonclick
});
if (opts.hideonclick) {
var tip = this.$element.data("bs.tooltip");
tip.tip().on("click", function () {
tip.hide();
});
}
this.$element.on("shown.bs.tooltip", _.bind(this.onTipShown, this));
this.$element.on("hidden.bs.tooltip", _.bind(this.onTipHidden, this));
},
show: function (at) {
this.getBSTip().show(at);
},
hide: function () {
this.getBSTip().hide();
},
setTitle: function (title) {
var tip = this.getBSTip();
tip.options.title = title;
},
updateTitle: function () {
var tip = this.getBSTip();
tip.$tip.find(".tooltip-inner")[tip.options.html ? "html" : "text"](tip.options.title);
},
getBSTip: function () {
return this.$element.data("bs.tooltip");
},
onTipShown: function () {
this.trigger("tooltip:show", this);
},
onTipHidden: function () {
this.trigger("tooltip:hide", this);
},
isVisible: function () {
return this.getBSTip().tip().is(":visible");
}
});
Common.UI = Common.UI || {};
Common.UI.Tooltip = Tooltip;
});

View File

@@ -0,0 +1,471 @@
/*
* (c) Copyright Ascensio System SIA 2010-2015
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
if (Common === undefined) {
var Common = {};
}
define(["common/main/lib/component/BaseView"], function () {
Common.UI.Window = Common.UI.BaseView.extend(_.extend((function () {
var config = {
closable: true,
header: true,
modal: true,
width: 300,
height: "auto",
title: "Title",
alias: "Window",
cls: "",
toolclose: "close"
};
var template = '<div class="asc-window<%= modal?" modal":"" %><%= cls?" "+cls:"" %>" id="<%= id %>" style="width:<%= width %>px;">' + "<% if (header==true) { %>" + '<div class="header">' + "<% if (closable!==false) %>" + '<div class="tool close"></div>' + "<% %>" + '<span class="title"><%= title %></span> ' + "</div>" + "<% } %>" + '<div class="body"><%= tpl %></div>' + "</div>";
function _getMask() {
var mask = $(".modals-mask");
if (mask.length == 0) {
mask = $("<div class='modals-mask'>").appendTo(document.body).hide();
}
return mask;
}
function _keydown(event) {
if (!this.isLocked() && this.isVisible()) {
switch (event.keyCode) {
case Common.UI.Keys.ESC:
event.preventDefault();
event.stopPropagation();
if (this.initConfig.closable !== false) {
this.initConfig.toolclose == "hide" ? this.hide() : this.close();
}
return false;
break;
case Common.UI.Keys.RETURN:
if (this.$window.find(".btn.primary").length) {
if ((this.initConfig.onprimary || this.onPrimary).call(this) === false) {
event.preventDefault();
return false;
}
}
break;
}
}
}
function _centre() {
if (window.innerHeight == undefined) {
var main_width = document.documentElement.offsetWidth;
var main_height = document.documentElement.offsetHeight;
} else {
main_width = window.innerWidth;
main_height = window.innerHeight;
}
if (this.initConfig.height == "auto") {
var win_height = parseInt(this.$window.find(".body").css("height"));
this.initConfig.header && (win_height += parseInt(this.$window.find(".header").css("height")));
} else {
win_height = this.initConfig.height;
}
var top = Math.floor(((parseInt(main_height) - parseInt(win_height)) / 2) * 0.9);
var left = Math.floor((parseInt(main_width) - parseInt(this.initConfig.width)) / 2);
this.$window.css("left", left);
this.$window.css("top", top);
}
function _getTransformation(end) {
return {
"-webkit-transition": "0.3s opacity",
"-moz-transition": "0.3s opacity",
"-ms-transition": "0.3s opacity",
"-o-transition": "0.3s opacity",
"opacity": end
};
}
function _dragstart(event) {
if ($(event.target).hasClass("close")) {
return;
}
Common.UI.Menu.Manager.hideAll();
this.dragging.enabled = true;
this.dragging.initx = event.pageX - parseInt(this.$window.css("left"));
this.dragging.inity = event.pageY - parseInt(this.$window.css("top"));
if (window.innerHeight == undefined) {
var main_width = document.documentElement.offsetWidth;
var main_height = document.documentElement.offsetHeight;
} else {
main_width = window.innerWidth;
main_height = window.innerHeight;
}
this.dragging.maxx = main_width - parseInt(this.$window.css("width"));
this.dragging.maxy = main_height - parseInt(this.$window.css("height"));
$(document).on("mousemove", this.binding.drag);
$(document).on("mouseup", this.binding.dragStop);
this.fireEvent("drag", [this, "start"]);
}
function _mouseup() {
$(document).off("mousemove", this.binding.drag);
$(document).off("mouseup", this.binding.dragStop);
this.dragging.enabled = false;
this.fireEvent("drag", [this, "end"]);
}
function _mousemove(event) {
if (this.dragging.enabled) {
var left = event.pageX - this.dragging.initx,
top = event.pageY - this.dragging.inity;
left < 0 ? (left = 0) : left > this.dragging.maxx && (left = this.dragging.maxx);
top < 0 ? (top = 0) : top > this.dragging.maxy && (top = this.dragging.maxy);
this.$window.css({
left: left,
top: top
});
}
}
Common.UI.alert = function (options) {
var me = this.Window.prototype;
var arrBtns = {
ok: me.okButtonText,
cancel: me.cancelButtonText,
yes: me.yesButtonText,
no: me.noButtonText,
close: me.closeButtonText
};
if (!options.buttons) {
options.buttons = {};
options.buttons["ok"] = arrBtns["ok"];
} else {
if (_.isArray(options.buttons)) {
var newBtns = {};
_.each(options.buttons, function (b) {
newBtns[b] = arrBtns[b];
});
options.buttons = newBtns;
}
}
var template = '<div class="info-box">' + '<div class="icon <%= iconCls %>" />' + '<div class="text"><span><%= msg %></span></div>' + "</div>" + '<div class="footer">' + '<button class="btn normal dlg-btn primary" result="ok">OK</button>' + "<% if (_.size(buttons) > 1) %>" + '<button class="btn normal dlg-btn" result="cancel">Cancel</button>' + "<% %>" + "</div>";
var win = new Common.UI.Window({
cls: "alert",
title: options.title,
onprimary: onKeyDown,
tpl: _.template(template, options)
});
function autoSize(window) {
var text_cnt = window.getChild(".info-box");
var text = window.getChild(".info-box span");
var footer = window.getChild(".footer");
var header = window.getChild(".header");
var body = window.getChild(".body");
var icon = window.getChild(".icon");
body.css("padding-bottom", "10px");
text_cnt.height(Math.max(text.height(), icon.height()));
body.height(parseInt(text_cnt.css("height")) + parseInt(footer.css("height")));
window.setSize(text.position().left + text.width() + parseInt(text_cnt.css("padding-right")), parseInt(body.css("height")) + parseInt(header.css("height")));
}
function onBtnClick(event) {
if (options.callback) {
options.callback.call(win, event.currentTarget.attributes["result"].value);
}
win.close(true);
}
function onKeyDown(event) {
onBtnClick({
currentTarget: win.getChild(".footer .dlg-btn")[0]
});
return false;
}
win.on({
"render:after": function (obj) {
autoSize(obj);
},
show: function (obj) {
obj.getChild(".footer .dlg-btn").focus();
obj.getChild(".footer .dlg-btn").on("click", onBtnClick);
},
close: function () {
options.callback && options.callback.call(win, "close");
}
});
win.show();
};
Common.UI.warning = function (options) {
options = options || {}; ! options.title && (options.title = this.Window.prototype.textWarning);
Common.UI.alert(_.extend(options, {
iconCls: "warn"
}));
};
Common.UI.error = function (options) {
options = options || {}; ! options.title && (options.title = this.Window.prototype.textError);
Common.UI.alert(_.extend(options, {
iconCls: "error"
}));
};
Common.UI.confirm = function (options) {
options = options || {}; ! options.title && (options.title = this.Window.prototype.textConfirmation);
Common.UI.alert(_.extend(options, {
iconCls: "confirm"
}));
};
Common.UI.info = function (options) {
options = options || {}; ! options.title && (options.title = this.Window.prototype.textInformation);
Common.UI.alert(_.extend(options, {
iconCls: "info"
}));
};
return {
$window: undefined,
$lastmodal: undefined,
dragging: {
enabled: false
},
initialize: function (options) {
this.initConfig = {};
this.binding = {};
_.extend(this.initConfig, config, options || {}); ! this.initConfig.id && (this.initConfig.id = "window-" + this.cid); ! this.initConfig.tpl && (this.initConfig.tpl = "");
Common.UI.BaseView.prototype.initialize.call(this, this.initConfig);
},
render: function () {
var renderto = this.initConfig.renderTo || document.body;
$(renderto).append(_.template(template, this.initConfig));
this.$window = $("#" + this.initConfig.id);
this.binding.keydown = _.bind(_keydown, this);
if (this.initConfig.header) {
this.binding.drag = _.bind(_mousemove, this);
this.binding.dragStop = _.bind(_mouseup, this);
this.binding.dragStart = _.bind(_dragstart, this);
var doclose = function () {
if (this.$window.find(".tool.close").hasClass("disabled")) {
return;
}
if (this.initConfig.toolcallback) {
this.initConfig.toolcallback.call(this);
} else {
(this.initConfig.toolclose == "hide") ? this.hide() : this.close();
}
};
this.$window.find(".header").on("mousedown", this.binding.dragStart);
this.$window.find(".tool.close").on("click", _.bind(doclose, this));
} else {
this.$window.find(".body").css({
top: 0,
"border-radius": "5px"
});
}
if (this.initConfig.height == "auto") {
var height = parseInt(this.$window.find("> .body").css("height"));
this.initConfig.header && (height += parseInt(this.$window.find("> .header").css("height")));
this.$window.height(height);
} else {
this.$window.css("height", this.initConfig.height);
}
this.fireEvent("render:after", this);
return this;
},
show: function (x, y) {
if (this.initConfig.modal) {
var mask = _getMask();
if (this.options.animate !== false) {
var opacity = mask.css("opacity");
mask.css("opacity", 0);
mask.show();
setTimeout(function () {
mask.css(_getTransformation(opacity));
},
1);
} else {
mask.show();
}
Common.NotificationCenter.trigger("modal:show", this);
this.$lastmodal = $(".asc-window.modal:not(.dethrone):visible").first().addClass("dethrone");
}
if (!this.$window) {
this.render();
if (_.isNumber(x) && _.isNumber(y)) {
this.$window.css("left", Math.floor(x));
this.$window.css("top", Math.floor(y));
} else {
_centre.call(this);
}
} else {
if (!this.$window.is(":visible")) {
this.$window.show();
}
}
$(document).on("keydown." + this.cid, this.binding.keydown);
var me = this;
if (this.options.animate !== false) {
this.$window.css({
"-webkit-transform": "scale(0.8)",
"-moz-transform": "scale(0.8)",
"-ms-transform": "scale(0.8)",
"-o-transform": "scale(0.8)",
opacity: 0
});
setTimeout(function () {
me.$window.css({
"-webkit-transition": "0.3s opacity, 0.3s -webkit-transform",
"-webkit-transform": "scale(1)",
"-moz-transition": "0.3s opacity, 0.3s -moz-transform",
"-moz-transform": "scale(1)",
"-ms-transition": "0.3s opacity, 0.3s -ms-transform",
"-ms-transform": "scale(1)",
"-o-transition": "0.3s opacity, 0.3s -o-transform",
"-o-transform": "scale(1)",
"opacity": "1"
});
},
1);
setTimeout(function () {
me.$window.css({
"-webkit-transform": "",
"-moz-transform": "",
"-ms-transition": "",
"-ms-transform": "",
"-o-transform": ""
});
me.fireEvent("show", me);
},
350);
} else {
this.fireEvent("show", this);
}
Common.NotificationCenter.trigger("window:show");
},
close: function (suppressevent) {
$(document).off("keydown." + this.cid);
if (this.initConfig.header) {
this.$window.find(".header").off("mousedown", this.binding.dragStart);
}
if (this.initConfig.modal) {
var hide_mask = true;
if (this.$lastmodal.size() > 0) {
this.$lastmodal.removeClass("dethrone");
hide_mask = !this.$lastmodal.hasClass("modal");
}
if (hide_mask) {
var mask = $(".modals-mask");
if (this.options.animate !== false) {
var opacity = mask.css("opacity");
mask.css(_getTransformation(0));
setTimeout(function () {
mask.css("opacity", opacity);
mask.hide();
},
300);
} else {
mask.hide();
}
}
Common.NotificationCenter.trigger("modal:close", this);
}
this.$window.remove();
suppressevent !== true && this.fireEvent("close", this);
},
hide: function () {
$(document).off("keydown." + this.cid);
if (this.$window) {
if (this.initConfig.modal) {
var hide_mask = true;
if (this.$lastmodal.size() > 0) {
this.$lastmodal.removeClass("dethrone");
hide_mask = !this.$lastmodal.hasClass("modal");
}
if (hide_mask) {
var mask = $(".modals-mask");
if (this.options.animate !== false) {
var opacity = mask.css("opacity");
mask.css(_getTransformation(0));
setTimeout(function () {
mask.css("opacity", opacity);
mask.hide();
},
300);
} else {
mask.hide();
}
}
Common.NotificationCenter.trigger("modal:hide", this);
}
this.$window.hide();
this.fireEvent("hide", this);
}
},
isLocked: function () {
return this.$window.hasClass("dethrone") || (!this.options.modal && this.$window.parent().find(".asc-window.modal:visible").length);
},
getChild: function (selector) {
return selector ? this.$window.find(selector) : this.$window;
},
setWidth: function (width) {
if (width >= 0) {
var min = parseInt(this.$window.css("min-width"));
width < min && (width = min);
this.$window.width(width);
}
},
getWidth: function () {
return parseInt(this.$window.css("width"));
},
setHeight: function (height) {
if (height >= 0) {
var min = parseInt(this.$window.css("min-height"));
height < min && (height = min);
this.$window.height(height);
if (this.initConfig.header) {
height -= parseInt(this.$window.find("> .header").css("height"));
}
this.$window.find("> .body").css("height", height);
}
},
getHeight: function () {
return parseInt(this.$window.css("height"));
},
setSize: function (w, h) {
this.setWidth(w);
this.setHeight(h);
},
getSize: function () {
return [this.getWidth(), this.getHeight()];
},
setTitle: function (title) {
this.$window.find("> .header > .title").text(title);
},
getTitle: function () {
return this.$window.find("> .header > .title").text();
},
isVisible: function () {
return this.$window && this.$window.is(":visible");
},
onPrimary: function () {},
cancelButtonText: "Cancel",
okButtonText: "OK",
yesButtonText: "Yes",
noButtonText: "No",
closeButtonText: "Close",
textWarning: "Warning",
textError: "Error",
textConfirmation: "Confirmation",
textInformation: "Information"
};
})(), Common.UI.Window || {}));
});

View File

@@ -1,433 +0,0 @@
/*
* (c) Copyright Ascensio System SIA 2010-2014
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
Ext.define("Common.component.util.LanguageName", (function () {
var localLanguageName = {
54: ["af", "Afrikaans"],
1078: ["af-ZA", "Afrikaans (Suid Afrika)"],
28: ["sq", "Shqipe"],
1052: ["sq-AL", "Shqipe (Shqipëria)"],
132: ["gsw", "Elsässisch"],
1156: ["gsw-FR", "Elsässisch (Frànkrisch)"],
94: ["am", "አማርኛ"],
1118: ["am-ET", "አማርኛ (ኢትዮጵያ)"],
1: ["ar", "العربية"],
5121: ["ar-DZ", "العربية (الجزائر)"],
15361: ["ar-BH", "العربية (البحرين)"],
3073: ["ar-EG", "العربية (مصر)"],
2049: ["ar-IQ", "العربية (العراق)"],
11265: ["ar-JO", "العربية (الأردن)"],
13313: ["ar-KW", "العربية (الكويت)"],
12289: ["ar-LB", "العربية (لبنان)"],
4097: ["ar-LY", "العربية (ليبيا)"],
6145: ["ar-MA", "العربية (المملكة المغربية)"],
8193: ["ar-OM", "العربية (عمان)"],
16385: ["ar-QA", "العربية (قطر)"],
1025: ["ar-SA", "العربية (المملكة العربية السعودية)"],
10241: ["ar-SY", "العربية (سوريا)"],
7169: ["ar-TN", "العربية (تونس)"],
14337: ["ar-AE", "العربية (الإمارات العربية المتحدة)"],
9217: ["ar-YE", "العربية (اليمن)"],
43: ["hy", "Հայերեն"],
1067: ["hy-AM", "Հայերեն (Հայաստան)"],
77: ["as", "অসমীয়া"],
1101: ["as-IN", "অসমীয়া (ভাৰত)"],
44: ["az", "Azərbaycan­ılı"],
29740: ["az-Cyrl", "Азәрбајҹан дили"],
2092: ["az-Cyrl-AZ", "Азәрбајҹан (Азәрбајҹан)"],
30764: ["az-Latn", "Azərbaycan­ılı"],
1068: ["az-Latn-AZ", "Azərbaycan­ılı (Azərbaycan)"],
109: ["ba", "Башҡорт"],
1133: ["ba-RU", "Башҡорт (Россия)"],
45: ["eu", "Euskara"],
1069: ["eu-ES", "Euskara (Euskara)"],
35: ["be", "Беларускі"],
1059: ["be-BY", "Беларускі (Беларусь)"],
69: ["bn", "বাংলা"],
2117: ["bn-BD", "বাংলা (বাংলাদেশ)"],
1093: ["bn-IN", "বাংলা (ভারত)"],
30746: ["bs", "bosanski"],
25626: ["bs-Cyrl", "Босански (Ћирилица)"],
8218: ["bs-Cyrl-BA", "Босански (Босна и Херцеговина)"],
26650: ["bs-Latn", "Bosanski (Latinica)"],
5146: ["bs-Latn-BA", "Bosanski (Bosna i Hercegovina)"],
126: ["br", "Brezhoneg"],
1150: ["br-FR", "Brezhoneg (Frañs)"],
2: ["bg", "Български"],
1026: ["bg-BG", "Български (България)"],
3: ["ca", "Català"],
1027: ["ca-ES", "Català (Català)"],
30724: ["zh", "中文"],
4: ["zh-Hans", "中文(简体)"],
2052: ["zh-CN", "中文(中华人民共和国)"],
4100: ["zh-SG", "中文(新加坡)"],
31748: ["zh-Hant", "中文(繁體)"],
3076: ["zh-HK", "中文(香港特別行政區)"],
5124: ["zh-MO", "中文(澳門特別行政區)"],
1028: ["zh-TW", "中文(台灣)"],
131: ["co", "Corsu"],
1155: ["co-FR", "Corsu (France)"],
26: ["hr", "Hrvatski"],
1050: ["hr-HR", "Hrvatski (Hrvatska)"],
4122: ["hr-BA", "Hrvatski (Bosna i Hercegovina)"],
5: ["cs", "Čeština"],
1029: ["cs-CZ", "Čeština (Česká republika)"],
6: ["da", "Dansk"],
1030: ["da-DK", "Dansk (Danmark)"],
140: ["prs", "درى"],
1164: ["prs-AF", "درى (افغانستان)"],
101: ["dv", "ދިވެހިބަސް"],
1125: ["dv-MV", "ދިވެހިބަސް (ދިވެހި ރާއްޖެ)"],
19: ["nl", "Nederlands"],
2067: ["nl-BE", "Nederlands (België)"],
1043: ["nl-NL", "Nederlands (Nederland)"],
9: ["en", "English"],
3081: ["en-AU", "English (Australia)"],
10249: ["en-BZ", "English (Belize)"],
4105: ["en-CA", "English (Canada)"],
9225: ["en-029", "English (Caribbean)"],
16393: ["en-IN", "English (India)"],
6153: ["en-IE", "English (Ireland)"],
8201: ["en-JM", "English (Jamaica)"],
17417: ["en-MY", "English (Malaysia)"],
5129: ["en-NZ", "English (New Zealand)"],
13321: ["en-PH", "English (Philippines)"],
18441: ["en-SG", "English (Singapore)"],
7177: ["en-ZA", "English (South Africa)"],
11273: ["en-TT", "English (Trinidad y Tobago)"],
2057: ["en-GB", "English (United Kingdom)"],
1033: ["en-US", "English (United States)"],
12297: ["en-ZW", "English (Zimbabwe)"],
37: ["et", "Eesti"],
1061: ["et-EE", "Eesti (Eesti)"],
56: ["fo", "Føroyskt"],
1080: ["fo-FO", "Føroyskt (Føroyar)"],
100: ["fil", "Filipino"],
1124: ["fil-PH", "Filipino (Pilipinas)"],
11: ["fi", "Suomi"],
1035: ["fi-FI", "Suomi (Suomi)"],
12: ["fr", "Français"],
2060: ["fr-BE", "Français (Belgique)"],
3084: ["fr-CA", "Français (Canada)"],
1036: ["fr-FR", "Français (France)"],
5132: ["fr-LU", "Français (Luxembourg)"],
6156: ["fr-MC", "Français (Principauté de Monaco)"],
4108: ["fr-CH", "Français (Suisse)"],
98: ["fy", "Frysk"],
1122: ["fy-NL", "Frysk (Nederlân)"],
86: ["gl", "Galego"],
1110: ["gl-ES", "Galego (Galego)"],
55: ["ka", "ქართული"],
1079: ["ka-GE", "ქართული (საქართველო)"],
7: ["de", "Deutsch"],
3079: ["de-AT", "Deutsch (Österreich)"],
1031: ["de-DE", "Deutsch (Deutschland)"],
5127: ["de-LI", "Deutsch (Liechtenstein)"],
4103: ["de-LU", "Deutsch (Luxemburg)"],
2055: ["de-CH", "Deutsch (Schweiz)"],
8: ["el", "Ελληνικά"],
1032: ["el-GR", "Ελληνικά (Ελλάδα)"],
111: ["kl", "Kalaallisut"],
1135: ["kl-GL", "Kalaallisut (Kalaallit Nunaat)"],
71: ["gu", "ગુજરાતી"],
1095: ["gu-IN", "ગુજરાતી (ભારત)"],
104: ["ha", "Hausa"],
31848: ["ha-Latn", "Hausa (Latin)"],
1128: ["ha-Latn-NG", "Hausa (Nigeria)"],
13: ["he", "עברית"],
1037: ["he-IL", "עברית (ישראל)"],
57: ["hi", "हिंदी"],
1081: ["hi-IN", "हिंदी (भारत)"],
14: ["hu", "Magyar"],
1038: ["hu-HU", "Magyar (Magyarország)"],
15: ["is", "Íslenska"],
1039: ["is-IS", "Íslenska (Ísland)"],
112: ["ig", "Igbo"],
1136: ["ig-NG", "Igbo (Nigeria)"],
33: ["id", "Bahasa Indonesia"],
1057: ["id-ID", "Bahasa Indonesia (Indonesia)"],
93: ["iu", "Inuktitut"],
31837: ["iu-Latn", "Inuktitut (Qaliujaaqpait)"],
2141: ["iu-Latn-CA", "Inuktitut"],
30813: ["iu-Cans", "ᐃᓄᒃᑎᑐᑦ (ᖃᓂᐅᔮᖅᐸᐃᑦ)"],
1117: ["iu-Cans-CA", "ᐃᓄᒃᑎᑐᑦ (ᑲᓇᑕᒥ)"],
60: ["ga", "Gaeilge"],
2108: ["ga-IE", "Gaeilge (Éire)"],
52: ["xh", "isiXhosa"],
1076: ["xh-ZA", "isiXhosa (uMzantsi Afrika)"],
53: ["zu", "isiZulu"],
1077: ["zu-ZA", "isiZulu (iNingizimu Afrika)"],
16: ["it", "Italiano"],
1040: ["it-IT", "Italiano (Italia)"],
2064: ["it-CH", "Italiano (Svizzera)"],
17: ["ja", "日本語"],
1041: ["ja-JP", "日本語 (日本)"],
75: ["kn", "ಕನ್ನಡ"],
1099: ["kn-IN", "ಕನ್ನಡ (ಭಾರತ)"],
63: ["kk", "Қазақ"],
1087: ["kk-KZ", "Қазақ (Қазақстан)"],
83: ["km", "ខ្មែរ"],
1107: ["km-KH", "ខ្មែរ (កម្ពុជា)"],
134: ["qut", "K'iche"],
1158: ["qut-GT", "K'iche (Guatemala)"],
135: ["rw", "Kinyarwanda"],
1159: ["rw-RW", "Kinyarwanda (Rwanda)"],
65: ["sw", "Kiswahili"],
1089: ["sw-KE", "Kiswahili (Kenya)"],
87: ["kok", "कोंकणी"],
1111: ["kok-IN", "कोंकणी (भारत)"],
18: ["ko", "한국어"],
1042: ["ko-KR", "한국어 (대한민국)"],
64: ["ky", "Кыргыз"],
1088: ["ky-KG", "Кыргыз (Кыргызстан)"],
84: ["lo", "ລາວ"],
1108: ["lo-LA", "ລາວ (ສ.ປ.ປ. ລາວ)"],
38: ["lv", "Latviešu"],
1062: ["lv-LV", "Latviešu (Latvija)"],
39: ["lt", "Lietuvių"],
1063: ["lt-LT", "Lietuvių (Lietuva)"],
31790: ["dsb", "Dolnoserbšćina"],
2094: ["dsb-DE", "Dolnoserbšćina (Nimska)"],
110: ["lb", "Lëtzebuergesch"],
1134: ["lb-LU", "Lëtzebuergesch (Luxembourg)"],
1071: ["mk-MK", "Македонски јазик (Македонија)"],
47: ["mk", "Македонски јазик"],
62: ["ms", "Bahasa Melayu"],
2110: ["ms-BN", "Bahasa Melayu (Brunei Darussalam)"],
1086: ["ms-MY", "Bahasa Melayu (Malaysia)"],
76: ["ml", "മലയാളം"],
1100: ["ml-IN", "മലയാളം (ഭാരതം)"],
58: ["mt", "Malti"],
1082: ["mt-MT", "Malti (Malta)"],
129: ["mi", "Reo Māori"],
1153: ["mi-NZ", "Reo Māori (Aotearoa)"],
122: ["arn", "Mapudungun"],
1146: ["arn-CL", "Mapudungun (Chile)"],
78: ["mr", "मराठी"],
1102: ["mr-IN", "मराठी (भारत)"],
124: ["moh", "Kanien'kéha"],
1148: ["moh-CA", "Kanien'kéha"],
80: ["mn", "Монгол хэл"],
30800: ["mn-Cyrl", "Монгол хэл"],
1104: ["mn-MN", "Монгол хэл (Монгол улс)"],
31824: ["mn-Mong", "ᠮᠤᠨᠭᠭᠤᠯ ᠬᠡᠯᠡ"],
2128: ["mn-Mong-CN", "ᠮᠤᠨᠭᠭᠤᠯ ᠬᠡᠯᠡ (ᠪᠦᠭᠦᠳᠡ ᠨᠠᠢᠷᠠᠮᠳᠠᠬᠤ ᠳᠤᠮᠳᠠᠳᠤ ᠠᠷᠠᠳ ᠣᠯᠣᠰ)"],
97: ["ne", "नेपाली"],
1121: ["ne-NP", "नेपाली (नेपाल)"],
20: ["no", "Norsk"],
31764: ["nb", "Norsk (bokmål)"],
30740: ["nn", "Norsk (Nynorsk)"],
1044: ["nb-NO", "Norsk, bokmål (Norge)"],
2068: ["nn-NO", "Norsk, nynorsk (Noreg)"],
130: ["oc", "Occitan"],
1154: ["oc-FR", "Occitan (França)"],
72: ["or", "ଓଡ଼ିଆ"],
1096: ["or-IN", "ଓଡ଼ିଆ (ଭାରତ)"],
99: ["ps", "پښتو"],
1123: ["ps-AF", "پښتو (افغانستان)"],
41: ["fa", "فارسى"],
1065: ["fa-IR", "فارسى (ایران)"],
21: ["pl", "Polski"],
1045: ["pl-PL", "Polski (Polska)"],
22: ["pt", "Português"],
1046: ["pt-BR", "Português (Brasil)"],
2070: ["pt-PT", "Português (Portugal)"],
70: ["pa", "ਪੰਜਾਬੀ"],
1094: ["pa-IN", "ਪੰਜਾਬੀ (ਭਾਰਤ)"],
107: ["quz", "Runasimi"],
1131: ["quz-BO", "Runasimi (Qullasuyu)"],
2155: ["quz-EC", "Runasimi (Ecuador)"],
3179: ["quz-PE", "Runasimi (Piruw)"],
24: ["ro", "Română"],
1048: ["ro-RO", "Română (România)"],
23: ["rm", "Rumantsch"],
1047: ["rm-CH", "Rumantsch (Svizra)"],
25: ["ru", "Русский"],
1049: ["ru-RU", "Русский (Россия)"],
28731: ["smn", "Sämikielâ"],
31803: ["smj", "Julevusámegiella"],
59: ["se", "Davvisámegiella"],
29755: ["sms", "Sääm´ǩiõll"],
30779: ["sma", "åarjelsaemiengiele"],
9275: ["smn-FI", "Sämikielâ (Suomâ)"],
4155: ["smj-NO", "Julevusámegiella (Vuodna)"],
5179: ["smj-SE", "Julevusámegiella (Svierik)"],
3131: ["se-FI", "Davvisámegiella (Suopma)"],
1083: ["se-NO", "Davvisámegiella (Norga)"],
2107: ["se-SE", "Davvisámegiella (Ruoŧŧa)"],
8251: ["sms-FI", "Sääm´ǩiõll (Lää´ddjânnam)"],
6203: ["sma-NO", "åarjelsaemiengiele (Nöörje)"],
7227: ["sma-SE", "åarjelsaemiengiele (Sveerje)"],
79: ["sa", "संस्कृत"],
1103: ["sa-IN", "संस्कृत (भारतम्)"],
145: ["gd", "Gàidhlig"],
1169: ["gd-GB", "Gàidhlig (An Rìoghachd Aonaichte)"],
31770: ["sr", "Srpski"],
27674: ["sr-Cyrl", "Српски (Ћирилица)"],
7194: ["sr-Cyrl-BA", "Српски (Босна и Херцеговина)"],
12314: ["sr-Cyrl-ME", "Српски (Црна Гора)"],
3098: ["sr-Cyrl-CS", "Српски (Србија и Црна Гора (Претходно))"],
10266: ["sr-Cyrl-RS", "Српски (Србија)"],
28698: ["sr-Latn", "Srpski (Latinica)"],
6170: ["sr-Latn-BA", "Srpski (Bosna i Hercegovina)"],
11290: ["sr-Latn-ME", "Srpski (Crna Gora)"],
2074: ["sr-Latn-CS", "Srpski (Srbija i Crna Gora (Prethodno))"],
9242: ["sr-Latn-RS", "Srpski (Srbija)"],
108: ["nso", "Sesotho sa Leboa"],
1132: ["nso-ZA", "Sesotho sa Leboa (Afrika Borwa)"],
50: ["tn", "Setswana"],
1074: ["tn-ZA", "Setswana (Aforika Borwa)"],
91: ["si", "සිංහ"],
1115: ["si-LK", "සිංහ (ශ්රී ලංකා)"],
27: ["sk", "Slovenčina"],
1051: ["sk-SK", "Slovenčina (Slovenská republika)"],
36: ["sl", "Slovenski"],
1060: ["sl-SI", "Slovenski (Slovenija)"],
10: ["es", "Español"],
11274: ["es-AR", "Español (Argentina)"],
16394: ["es-BO", "Español (Bolivia)"],
13322: ["es-CL", "Español (Chile)"],
9226: ["es-CO", "Español (Colombia)"],
5130: ["es-CR", "Español (Costa Rica)"],
7178: ["es-DO", "Español (República Dominicana)"],
12298: ["es-EC", "Español (Ecuador)"],
17418: ["es-SV", "Español (El Salvador)"],
4106: ["es-GT", "Español (Guatemala)"],
18442: ["es-HN", "Español (Honduras)"],
2058: ["es-MX", "Español (México)"],
19466: ["es-NI", "Español (Nicaragua)"],
6154: ["es-PA", "Español (Panamá)"],
15370: ["es-PY", "Español (Paraguay)"],
10250: ["es-PE", "Español (Perú)"],
20490: ["es-PR", "Español (Puerto Rico)"],
3082: ["es-ES", "Español (España, alfabetización internacional)"],
21514: ["es-US", "Español (Estados Unidos)"],
14346: ["es-UY", "Español (Uruguay)"],
8202: ["es-VE", "Español (Republica Bolivariana de Venezuela)"],
29: ["sv", "Svenska"],
2077: ["sv-FI", "Svenska (Finland)"],
1053: ["sv-SE", "Svenska (Sverige)"],
90: ["syr", "ܣܘܪܝܝܐ"],
1114: ["syr-SY", "ܣܘܪܝܝܐ (سوريا)"],
40: ["tg", "Тоҷикӣ"],
31784: ["tg-Cyrl", "Тоҷикӣ"],
1064: ["tg-Cyrl-TJ", "Тоҷикӣ (Тоҷикистон)"],
95: ["tzm", "Tamazight"],
31839: ["tzm-Latn", "Tamazight (Latin)"],
2143: ["tzm-Latn-DZ", "Tamazight (Djazaïr)"],
73: ["ta", "தமிழ்"],
1097: ["ta-IN", "தமிழ் (இந்தியா)"],
68: ["tt", "Татар"],
1092: ["tt-RU", "Татар (Россия)"],
74: ["te", "తెలుగు"],
1098: ["te-IN", "తెలుగు (భారత దేశం)"],
30: ["th", "ไทย"],
1054: ["th-TH", "ไทย (ไทย)"],
81: ["bo", "བོད་ཡིག"],
1105: ["bo-CN", "བོད་ཡིག (ཀྲུང་ཧྭ་མི་དམངས་སྤྱི་མཐུན་རྒྱལ་ཁབ།)"],
31: ["tr", "Türkçe"],
1055: ["tr-TR", "Türkçe (Türkiye)"],
66: ["tk", "Türkmençe"],
1090: ["tk-TM", "Türkmençe (Türkmenistan)"],
34: ["uk", "Українська"],
1058: ["uk-UA", "Українська (Україна)"],
46: ["hsb", "Hornjoserbšćina"],
1070: ["hsb-DE", "Hornjoserbšćina (Němska)"],
32: ["ur", "اُردو"],
1056: ["ur-PK", "اُردو (پاکستان)"],
128: ["ug", "ئۇيغۇر يېزىقى"],
1152: ["ug-CN", "(ئۇيغۇر يېزىقى (جۇڭخۇا خەلق جۇمھۇرىيىتى"],
30787: ["uz-Cyrl", "Ўзбек"],
2115: ["uz-Cyrl-UZ", "Ўзбек (Ўзбекистон)"],
67: ["uz", "U'zbek"],
31811: ["uz-Latn", "U'zbek"],
1091: ["uz-Latn-UZ", "U'zbek (U'zbekiston Respublikasi)"],
42: ["vi", "Tiếng Việt"],
1066: ["vi-VN", "Tiếng Việt (Việt Nam)"],
82: ["cy", "Cymraeg"],
1106: ["cy-GB", "Cymraeg (y Deyrnas Unedig)"],
136: ["wo", "Wolof"],
1160: ["wo-SN", "Wolof (Sénégal)"],
133: ["sah", "Саха"],
1157: ["sah-RU", "Саха (Россия)"],
120: ["ii", "ꆈꌠꁱꂷ"],
1144: ["ii-CN", "ꆈꌠꁱꂷ (ꍏꉸꏓꂱꇭꉼꇩ)"],
106: ["yo", "Yoruba"],
1130: ["yo-NG", "Yoruba (Nigeria)"],
2129: ["bo-BT", "Tibetan, Bhutan"],
1126: ["bin-NG", "Bini, Nigeria"],
1116: ["chr-US", "Cherokee, United States"],
15369: ["en-HK", "English, Hong Kong"],
14345: ["en-ID", "English, Indonesia"],
1034: ["es-ES_tradnl", "Spanish"],
15372: ["fr-HT", "French, Haiti"],
9228: ["fr-CG", "French, Congo"],
12300: ["fr-CI", "French, Cote d'Ivoire"],
11276: ["fr-CM", "French, Cameroon"],
14348: ["fr-MA", "French, Morocco"],
13324: ["fr-ML", "French, Mali"],
8204: ["fr-RE", "French, Reunion"],
10252: ["fr-SN", "French, Senegal"],
7180: ["fr-West", "French"],
1127: ["fuv-NG", "Nigerian Fulfulde, Nigeria"],
1138: ["gaz-ET", "West Central Oromo, Ethiopia"],
1140: ["gn-PY", "Guarani, Paraguay"],
1141: ["haw-US", "Hawaiian, UnitedStates"],
1129: ["ibb-NG", "Ibibio, Nigeria"],
1137: ["kr-NG", "Kanuri, Nigeria"],
1112: ["mni", "Manipuri"],
1109: ["my-MM", "Burmese, Myanmar"],
2145: ["ne-IN", "Nepali, India"],
1145: ["pap-AN", "Papiamento, Netherlands Antilles"],
2118: ["pa-PK", "Panjabi, Pakistan"],
1165: ["plt-MG", "Plateau Malagasy, Madagascar"],
2072: ["ro-MO", "Romanian, Macao"],
2073: ["ru-MO", "Russian, Macao"],
1113: ["sd-IN", "Sindhi, India"],
2137: ["sd-PK", "Sindhi, Pakistan"],
1143: ["so-SO", "Somali, Somalia"],
1072: ["st-ZA", "Southern Sotho, South Africa"],
1139: ["ti-ER", "Tigrinya, Eritrea"],
2163: ["ti-ET", "Tigrinya, Ethiopia"],
1119: ["tmz", "Tamanaku"],
3167: ["tmz-MA", "Tamanaku, Morocco"],
1073: ["ts-ZA", "Tsonga, South Africa"],
2080: ["ur-IN", "Urdu, India"],
1075: ["ven-ZA", "South Africa"]
};
return {
alternateClassName: "Common.util.LanguageName",
singleton: true,
getLocalLanguageName: function (code) {
return localLanguageName[code] || ["", code];
}
};
} ()));

View File

@@ -1,73 +0,0 @@
/*
* (c) Copyright Ascensio System SIA 2010-2014
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
if (Common === undefined) {
var Common = {};
}
Common.MetricSettings = new(function () {
var me = this;
me.c_MetricUnits = {
cm: 0,
pt: 1
};
me.currentMetric = me.c_MetricUnits.pt;
me.metricName = ["cm", "pt"];
return {
c_MetricUnits: me.c_MetricUnits,
metricName: me.metricName,
setCurrentMetric: function (value) {
me.currentMetric = value;
},
getCurrentMetric: function () {
return me.currentMetric;
},
fnRecalcToMM: function (value) {
if (value !== null && value !== undefined) {
switch (me.currentMetric) {
case me.c_MetricUnits.cm:
return value * 10;
case me.c_MetricUnits.pt:
return value * 25.4 / 72;
}
}
return value;
},
fnRecalcFromMM: function (value) {
switch (me.currentMetric) {
case me.c_MetricUnits.cm:
return parseFloat(Ext.Number.toFixed(value / 10, 4));
case me.c_MetricUnits.pt:
return parseFloat(Ext.Number.toFixed(value * 72 / 25.4, 3));
}
return value;
}
};
})();

View File

@@ -1,196 +0,0 @@
/*
* (c) Copyright Ascensio System SIA 2010-2014
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
Ext.define("Common.component.util.RGBColor", {
alternateClassName: "Common.util.RGBColor",
constructor: function (colorString) {
this.ok = false;
if (colorString.charAt(0) == "#") {
colorString = colorString.substr(1, 6);
}
colorString = colorString.replace(/ /g, "");
colorString = colorString.toLowerCase();
var colorDefinitions = [{
re: /^rgb\((\d{1,3}),\s*(\d{1,3}),\s*(\d{1,3})\)$/,
process: function (bits) {
return [parseInt(bits[1]), parseInt(bits[2]), parseInt(bits[3])];
}
},
{
re: /^hsb\((\d{1,3}),\s*(\d{1,3}),\s*(\d{1,3})\)$/,
process: function (bits) {
var rgb = {};
var h = Math.round(bits[1]);
var s = Math.round(bits[2] * 255 / 100);
var v = Math.round(bits[3] * 255 / 100);
if (s == 0) {
rgb.r = rgb.g = rgb.b = v;
} else {
var t1 = v;
var t2 = (255 - s) * v / 255;
var t3 = (t1 - t2) * (h % 60) / 60;
if (h == 360) {
h = 0;
}
if (h < 60) {
rgb.r = t1;
rgb.b = t2;
rgb.g = t2 + t3;
} else {
if (h < 120) {
rgb.g = t1;
rgb.b = t2;
rgb.r = t1 - t3;
} else {
if (h < 180) {
rgb.g = t1;
rgb.r = t2;
rgb.b = t2 + t3;
} else {
if (h < 240) {
rgb.b = t1;
rgb.r = t2;
rgb.g = t1 - t3;
} else {
if (h < 300) {
rgb.b = t1;
rgb.g = t2;
rgb.r = t2 + t3;
} else {
if (h < 360) {
rgb.r = t1;
rgb.g = t2;
rgb.b = t1 - t3;
} else {
rgb.r = 0;
rgb.g = 0;
rgb.b = 0;
}
}
}
}
}
}
}
return [Math.round(rgb.r), Math.round(rgb.g), Math.round(rgb.b)];
}
},
{
re: /^(\w{2})(\w{2})(\w{2})$/,
process: function (bits) {
return [parseInt(bits[1], 16), parseInt(bits[2], 16), parseInt(bits[3], 16)];
}
},
{
re: /^(\w{1})(\w{1})(\w{1})$/,
process: function (bits) {
return [parseInt(bits[1] + bits[1], 16), parseInt(bits[2] + bits[2], 16), parseInt(bits[3] + bits[3], 16)];
}
}];
for (var i = 0; i < colorDefinitions.length; i++) {
var re = colorDefinitions[i].re;
var processor = colorDefinitions[i].process;
var bits = re.exec(colorString);
if (bits) {
var channels = processor(bits);
this.r = channels[0];
this.g = channels[1];
this.b = channels[2];
this.ok = true;
}
}
this.r = (this.r < 0 || isNaN(this.r)) ? 0 : ((this.r > 255) ? 255 : this.r);
this.g = (this.g < 0 || isNaN(this.g)) ? 0 : ((this.g > 255) ? 255 : this.g);
this.b = (this.b < 0 || isNaN(this.b)) ? 0 : ((this.b > 255) ? 255 : this.b);
this.isEqual = function (color) {
return ((this.r == color.r) && (this.g == color.g) && (this.b == color.b));
};
this.toRGB = function () {
return "rgb(" + this.r + ", " + this.g + ", " + this.b + ")";
};
this.toRGBA = function (alfa) {
if (alfa === undefined) {
alfa = 1;
}
return "rgba(" + this.r + ", " + this.g + ", " + this.b + ", " + alfa + ")";
};
this.toHex = function () {
var r = this.r.toString(16);
var g = this.g.toString(16);
var b = this.b.toString(16);
if (r.length == 1) {
r = "0" + r;
}
if (g.length == 1) {
g = "0" + g;
}
if (b.length == 1) {
b = "0" + b;
}
return "#" + r + g + b;
};
this.toHSB = function () {
var hsb = {
h: 0,
s: 0,
b: 0
};
var min = Math.min(this.r, this.g, this.b);
var max = Math.max(this.r, this.g, this.b);
var delta = max - min;
hsb.b = max;
hsb.s = max != 0 ? 255 * delta / max : 0;
if (hsb.s != 0) {
if (this.r == max) {
hsb.h = 0 + (this.g - this.b) / delta;
} else {
if (this.g == max) {
hsb.h = 2 + (this.b - this.r) / delta;
} else {
hsb.h = 4 + (this.r - this.g) / delta;
}
}
} else {
hsb.h = 0;
}
hsb.h *= 60;
if (hsb.h < 0) {
hsb.h += 360;
}
hsb.s *= 100 / 255;
hsb.b *= 100 / 255;
hsb.h = parseInt(hsb.h);
hsb.s = parseInt(hsb.s);
hsb.b = parseInt(hsb.b);
return hsb;
};
}
});

View File

@@ -1,278 +1,173 @@
/*
* (c) Copyright Ascensio System SIA 2010-2014
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
Ext.define("Common.controller.Chat", {
extend: "Ext.app.Controller",
views: ["ChatPanel"],
refs: [{
ref: "chatPanel",
selector: "commonchatpanel"
},
{
ref: "messageList",
selector: "#id-chat-msg"
},
{
ref: "userList",
selector: "#id-chat-users"
},
{
ref: "messageTextArea",
selector: "#id-chat-textarea"
},
{
ref: "btnSend",
selector: "#id-btn-send-msg"
}],
stores: ["Common.store.ChatMessages", "Common.store.Users"],
init: function () {
this.control({
"#id-btn-send-msg": {
afterrender: this.onBtnSendAfterRender,
click: this.onBtnSendClick
},
"#id-chat-msg": {
itemadd: this.onAddMessage
},
"#id-chat-textarea": {
keydown: this.onTextAreaKeyDown,
keyup: this.onTextAreaKeyUp
},
"#id-chat-users": {
viewready: function () {
this.onUpdateUser();
},
itemclick: this.onUserListItemClick,
itemupdate: this.onUpdateUser
},
"#view-main-menu": {
panelshow: this.onShowPanel
}
});
},
setApi: function (o) {
this.api = o;
this.api.asc_registerCallback("asc_onParticipantsChanged", Ext.bind(this.onParticipantsChanged, this));
this.api.asc_registerCallback("asc_onCoAuthoringChatReceiveMessage", Ext.bind(this.onCoAuthoringChatReceiveMessage, this));
this.api.asc_registerCallback("asc_onAuthParticipantsChanged", Ext.bind(this.onAuthParticipantsChanged, this));
this.api.asc_registerCallback("asc_onConnectionStateChanged", Ext.bind(this.onConnectionStateChanged, this));
this.api.asc_coAuthoringGetUsers();
this.api.asc_coAuthoringChatGetMessages();
return this;
},
onLaunch: function () {
Common.Gateway.on("init", Ext.bind(this.loadConfig, this));
},
loadConfig: function (data) {},
_sendMessage: function () {
var messageTextArea = this.getMessageTextArea(),
me = this;
if (messageTextArea) {
var message = Ext.String.trim(messageTextArea.getValue());
if (message.length > 0 && this.api) {
var splitString = function (string, chunkSize) {
var chunks = [];
while (string) {
if (string.length < chunkSize) {
chunks.push(string);
break;
} else {
chunks.push(string.substr(0, chunkSize));
string = string.substr(chunkSize);
}
}
return chunks;
};
var messageList = splitString(message, 2048);
Ext.each(messageList, function (message) {
me.api.asc_coAuthoringChatSendMessage(message);
});
messageTextArea.setValue("");
}
}
},
_updateUserOnline: function (user, online) {
if (user) {
user.beginEdit();
user.set("online", online);
if (user.get("color").length < 1) {
user.set("color", "#" + ("000000" + Math.floor(Math.random() * 16777215).toString(16)).substr(-6));
}
user.endEdit();
user.commit();
}
},
onBtnSendClick: function (btn, e) {
this._sendMessage();
var textarea = Ext.getCmp("id-chat-textarea");
if (textarea) {
var doSetFocus = new Ext.util.DelayedTask(function () {
this.api.asc_enableKeyEvents(false);
textarea.focus();
},
this);
doSetFocus.delay(100);
}
},
onBtnSendAfterRender: function (cmp) {
var btnEl = cmp.getEl(),
messageTextArea = this.getMessageTextArea();
if (Ext.supports.Placeholder) {
btnEl.on("mousedown", function () {
messageTextArea.emptyText = this.textEnterMessage;
messageTextArea.applyEmptyText();
},
this);
btnEl.on("mouseup", function () {
messageTextArea.emptyText = " ";
messageTextArea.applyEmptyText();
},
this);
}
},
onAddMessage: function (records, index, node) {
var messageList = this.getMessageList();
if (messageList) {
var plugin = messageList.getPlugin("scrollpane");
if (plugin && plugin.jspApi) {
var needScroll = plugin.jspApi.getPercentScrolledY() > 0.999;
if (messageList.getWidth() > 0) {
plugin.updateScrollPane();
}
if (needScroll) {
Ext.defer(function () {
var node = messageList.getNode(index);
node && plugin.scrollToElement(node, false, true);
},
100, this);
}
}
}
},
onUpdateUser: function (records, index, node) {
var userList = this.getUserList();
if (userList) {
var onlinecount = userList.getStore().getOnlineUserCount();
if (onlinecount > 10) {
onlinecount = 10;
}
userList.setHeight((onlinecount < 4) ? 70 : onlinecount * 18 + 12);
var plugin = userList.getPlugin("scrollpane");
if (plugin && userList.getEl().dom.clientWidth > 0) {
plugin.updateScrollPane();
}
}
},
onTextAreaKeyUp: function (field, event) {
if (event.getKey() == event.ENTER) {
field.emptyText = " ";
field.applyEmptyText();
}
},
onTextAreaKeyDown: function (field, event) {
if (event.getKey() == event.ENTER) {
if ((event.ctrlKey || event.metaKey) && !event.shiftKey) {
if (field.getValue().length < 1) {
field.emptyText = this.textEnterMessage;
field.applyEmptyText();
} else {
this._sendMessage();
}
event.stopEvent();
}
}
},
onUserListItemClick: function (view, record, item, index, e) {},
onParticipantsChanged: function (e) {},
onCoAuthoringChatReceiveMessage: function (messages) {
var messagesStore = this.getCommonStoreChatMessagesStore();
if (messagesStore) {
Ext.each(messages, function (item) {
messagesStore.add({
type: 0,
userid: item.user,
message: item.message,
username: item.username
});
});
}
},
onAuthParticipantsChanged: function (users) {
var userStore = this.getCommonStoreUsersStore();
if (userStore) {
var record, me = this;
Ext.each(users, function (user) {
record = userStore.add({
id: user.asc_getId(),
username: user.asc_getUserName()
})[0];
this._updateUserOnline(record, true);
},
this);
}
},
onConnectionStateChanged: function (change) {
var userStore = this.getCommonStoreUsersStore();
if (userStore) {
var record = userStore.findRecord("id", change.asc_getId());
if (!record) {
record = userStore.add({
id: change.asc_getId(),
username: change.asc_getUserName()
})[0];
}
this._updateUserOnline(userStore.findRecord("id", change.asc_getId()), change.asc_getState());
}
},
onShowPanel: function (panel, fulscreen) {
var activeStep = panel.down("container");
if (activeStep && activeStep.isXType("commonchatpanel")) {
var messageList = this.getMessageList(),
userList = this.getUserList(),
plugin;
if (messageList) {
plugin = messageList.getPlugin("scrollpane");
if (plugin) {
plugin.updateScrollPane();
plugin.jspApi.scrollToPercentY(100, true);
}
}
if (userList) {
plugin = userList.getPlugin("scrollpane");
if (plugin) {
plugin.updateScrollPane();
}
}
}
},
textEnterMessage: "Enter your message here",
capGuest: "Guest"
/*
* (c) Copyright Ascensio System SIA 2010-2015
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
define(["core", "common/main/lib/collection/Users", "common/main/lib/collection/ChatMessages", "common/main/lib/view/Chat"], function () {
Common.Controllers.Chat = Backbone.Controller.extend(_.extend({
models: [],
collections: ["Common.Collections.Users", "Common.Collections.ChatMessages"],
views: ["Common.Views.Chat"],
initialize: function () {
this.addListeners({
"Common.Views.Chat": {
"message:add": _.bind(this.onSendMessage, this)
}
});
},
events: {},
onLaunch: function () {
this.panelChat = this.createView("Common.Views.Chat", {
storeUsers: this.getApplication().getCollection("Common.Collections.Users"),
storeMessages: this.getApplication().getCollection("Common.Collections.ChatMessages")
});
},
setMode: function (mode) {
this.mode = mode;
if (this.api) {
if (this.mode.canCoAuthoring) {
this.api.asc_registerCallback("asc_onCoAuthoringChatReceiveMessage", _.bind(this.onReceiveMessage, this));
}
this.api.asc_registerCallback("asc_onAuthParticipantsChanged", _.bind(this.onUsersChanged, this));
this.api.asc_registerCallback("asc_onConnectionStateChanged", _.bind(this.onUserConnection, this));
this.api.asc_coAuthoringGetUsers();
if (this.mode.canCoAuthoring) {
this.api.asc_coAuthoringChatGetMessages();
}
}
return this;
},
setApi: function (api) {
this.api = api;
return this;
},
onUsersChanged: function (users) {
if (!this.mode.canCoAuthoring) {
var len = 0;
for (name in users) {
if (undefined !== name) {
len++;
}
}
if (len > 2 && this._isCoAuthoringStopped == undefined) {
this._isCoAuthoringStopped = true;
this.api.asc_coAuthoringDisconnect();
Common.NotificationCenter.trigger("api:disconnect");
setTimeout(_.bind(function () {
Common.UI.alert({
closable: false,
title: this.notcriticalErrorTitle,
msg: this.textUserLimit,
iconCls: "warn",
buttons: ["ok"]
});
},
this), 100);
return;
}
}
var usersStore = this.getApplication().getCollection("Common.Collections.Users");
if (usersStore) {
var arrUsers = [],
name,
user;
for (name in users) {
if (undefined !== name) {
user = users[name];
if (user) {
arrUsers.push(new Common.Models.User({
id: user.asc_getId(),
username: user.asc_getUserName(),
online: true,
color: user.asc_getColor()
}));
}
}
}
usersStore[usersStore.size() > 0 ? "add" : "reset"](arrUsers);
}
},
onUserConnection: function (change) {
var usersStore = this.getApplication().getCollection("Common.Collections.Users");
if (usersStore) {
var user = usersStore.findUser(change.asc_getId());
if (!user) {
usersStore.add(new Common.Models.User({
id: change.asc_getId(),
username: change.asc_getUserName(),
online: change.asc_getState(),
color: change.asc_getColor()
}));
} else {
user.set({
online: change.asc_getState()
});
}
}
},
onReceiveMessage: function (messages) {
var msgStore = this.getApplication().getCollection("Common.Collections.ChatMessages");
if (msgStore) {
var array = [];
messages.forEach(function (msg) {
array.push(new Common.Models.ChatMessage({
userid: msg.user,
message: msg.message,
username: msg.username
}));
});
msgStore[msgStore.size() > 0 ? "add" : "reset"](array);
}
},
onSendMessage: function (panel, text) {
if (text.length > 0) {
var splitString = function (string, chunkSize) {
var chunks = [];
while (string) {
if (string.length < chunkSize) {
chunks.push(string);
break;
} else {
chunks.push(string.substr(0, chunkSize));
string = string.substr(chunkSize);
}
}
return chunks;
};
var me = this;
splitString(text, 2048).forEach(function (message) {
me.api.asc_coAuthoringChatSendMessage(message);
});
}
},
notcriticalErrorTitle: "Warning",
textUserLimit: 'You are using ONLYOFFICE Editors free version.<br>Only two users can co-edit the document simultaneously.<br>Want more? Consider buying ONLYOFFICE Editors Pro version.<br><a href="http://www.onlyoffice.com" target="_blank">Read more</a>'
},
Common.Controllers.Chat || {}));
});

File diff suppressed because it is too large Load Diff

View File

@@ -1,341 +0,0 @@
/*
* (c) Copyright Ascensio System SIA 2010-2014
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
Ext.define("Common.controller.CommentsBase", {
extend: "Ext.app.Controller",
models: ["Common.model.Reply", "Common.model.Comment"],
stores: ["Common.store.Comments", "Common.store.Users"],
config: {
currentUserId: undefined,
currentUserName: undefined
},
timeZoneOffsetInMs: (new Date()).getTimezoneOffset() * 60000,
init: function () {},
loadConfig: function (data) {
this.setCurrentUserId(data.config.user.id);
this.setCurrentUserName(data.config.user.name);
},
setApi: function (o) {
this.api = o;
},
utcDateToString: function (date) {
if (Object.prototype.toString.call(date) === "[object Date]") {
return (date.getTime() - this.timeZoneOffsetInMs).toString();
}
return "";
},
addComment: function (comment) {
if (this.api) {
var commentVal = Ext.String.trim(comment);
if (commentVal.length > 0) {
var ascCommentData = new asc_CCommentData();
if (ascCommentData) {
ascCommentData.asc_putText(commentVal);
ascCommentData.asc_putTime(this.utcDateToString(new Date()));
ascCommentData.asc_putUserId(this.getCurrentUserId());
ascCommentData.asc_putUserName(this.getCurrentUserName());
ascCommentData.asc_putSolved(false);
this.api.asc_addComment(ascCommentData);
}
}
}
},
resolveComment: function (commentId, resolve) {
if (this.api) {
var commentsStore = this.getCommonStoreCommentsStore(),
ascCommentData = new asc_CCommentData(),
me = this;
if (commentsStore && ascCommentData) {
var currentCommentData = commentsStore.findRecord("id", commentId);
if (currentCommentData) {
ascCommentData.asc_putText(currentCommentData.get("comment"));
ascCommentData.asc_putQuoteText(currentCommentData.get("quote"));
ascCommentData.asc_putTime(this.utcDateToString(new Date(currentCommentData.get("date"))));
ascCommentData.asc_putUserId(currentCommentData.get("userid"));
ascCommentData.asc_putUserName(currentCommentData.get("username"));
ascCommentData.asc_putSolved(resolve);
currentCommentData.replys().each(function (reply) {
var addReply = new asc_CCommentData();
addReply.asc_putText(reply.get("reply"));
addReply.asc_putTime(me.utcDateToString(new Date(reply.get("date"))));
addReply.asc_putUserId(reply.get("userid"));
addReply.asc_putUserName(reply.get("username"));
ascCommentData.asc_addReply(addReply);
});
this.api.asc_changeComment(commentId, ascCommentData);
}
}
}
},
editComment: function (commentId, newComment) {
if (this.api) {
var commentVal = Ext.String.trim(newComment),
commentsStore = this.getCommonStoreCommentsStore(),
me = this;
if (commentVal.length > 0) {
var ascCommentData = new asc_CCommentData(),
currentCommentData = commentsStore.findRecord("id", commentId);
if (ascCommentData) {
ascCommentData.asc_putText(commentVal);
ascCommentData.asc_putQuoteText(currentCommentData.get("quote"));
ascCommentData.asc_putTime(this.utcDateToString(new Date(currentCommentData.get("date"))));
ascCommentData.asc_putUserId(this.getCurrentUserId());
ascCommentData.asc_putUserName(this.getCurrentUserName());
ascCommentData.asc_putSolved(currentCommentData.get("resolved"));
currentCommentData.replys().each(function (reply) {
var addReply = new asc_CCommentData();
addReply.asc_putText(reply.get("reply"));
addReply.asc_putTime(me.utcDateToString(new Date(reply.get("date"))));
addReply.asc_putUserId(reply.get("userid"));
addReply.asc_putUserName(reply.get("username"));
ascCommentData.asc_addReply(addReply);
});
this.api.asc_changeComment(commentId, ascCommentData);
}
}
}
},
deleteComment: function (commentId) {
if (this.api) {
this.api.asc_removeComment(commentId);
}
},
selectComment: function (commentId) {
if (this.api) {
this.api.asc_selectComment(commentId);
this.api.asc_showComment(commentId);
}
},
addReply: function (commentId, reply) {
if (this.api) {
var replyVal = Ext.String.trim(reply),
commentsStore = this.getCommonStoreCommentsStore(),
me = this;
if (commentsStore && reply.length > 0) {
var ascCommentData = new asc_CCommentData(),
currentCommentData = commentsStore.findRecord("id", commentId);
if (ascCommentData && currentCommentData) {
ascCommentData.asc_putText(currentCommentData.get("comment"));
ascCommentData.asc_putQuoteText(currentCommentData.get("quote"));
ascCommentData.asc_putTime(this.utcDateToString(new Date(currentCommentData.get("date"))));
ascCommentData.asc_putUserId(currentCommentData.get("userid"));
ascCommentData.asc_putUserName(currentCommentData.get("username"));
ascCommentData.asc_putSolved(currentCommentData.get("resolved"));
var appendComment = function (data) {
var addReply = new asc_CCommentData();
addReply.asc_putText(data.reply);
addReply.asc_putTime(data.date);
addReply.asc_putUserId(data.userid);
addReply.asc_putUserName(data.username);
ascCommentData.asc_addReply(addReply);
};
appendComment({
reply: replyVal,
date: this.utcDateToString(new Date()),
userid: this.getCurrentUserId(),
username: this.getCurrentUserName()
});
currentCommentData.replys().each(function (reply) {
appendComment({
reply: reply.get("reply"),
date: me.utcDateToString(new Date(reply.get("date"))),
userid: reply.get("userid"),
username: reply.get("username")
});
});
this.api.asc_changeComment(commentId, ascCommentData);
return true;
}
}
}
return false;
},
editReply: function (commentId, replyId, newReply) {
if (this.api) {
var replyVal = Ext.String.trim(newReply),
me = this,
commentsStore = this.getCommonStoreCommentsStore();
if (commentsStore && replyVal.length > 0) {
var ascCommentData = new asc_CCommentData(),
currentCommentData = commentsStore.findRecord("id", commentId);
if (ascCommentData) {
ascCommentData.asc_putText(currentCommentData.get("comment"));
ascCommentData.asc_putQuoteText(currentCommentData.get("quote"));
ascCommentData.asc_putTime(this.utcDateToString(new Date(currentCommentData.get("date"))));
ascCommentData.asc_putUserId(currentCommentData.get("userid"));
ascCommentData.asc_putUserName(currentCommentData.get("username"));
ascCommentData.asc_putSolved(currentCommentData.get("resolved"));
var appendComment = function (data) {
var addReply = new asc_CCommentData();
addReply.asc_putText(data.reply);
addReply.asc_putTime(data.date);
addReply.asc_putUserId(data.userid);
addReply.asc_putUserName(data.username);
ascCommentData.asc_addReply(addReply);
};
currentCommentData.replys().each(function (reply) {
var id = reply.get("id");
appendComment({
reply: (id == replyId) ? replyVal : reply.get("reply"),
date: me.utcDateToString(new Date(reply.get("date"))),
userid: (id == replyId) ? me.getCurrentUserId() : reply.get("userid"),
username: (id == replyId) ? me.getCurrentUserName() : reply.get("username")
});
});
this.api.asc_changeComment(commentId, ascCommentData);
}
}
}
},
deleteReply: function (commentId, replyId) {
if (this.api) {
var commentsStore = this.getCommonStoreCommentsStore(),
userStore = this.getCommonStoreCommentsStore(),
ascCommentData = new asc_CCommentData(),
me = this;
if (commentsStore && userStore && ascCommentData) {
var currentCommentData = commentsStore.findRecord("id", commentId),
user = userStore.findRecord("id", currentCommentData.get("userid"));
ascCommentData.asc_putText(currentCommentData.get("comment"));
ascCommentData.asc_putQuoteText(currentCommentData.get("quote"));
ascCommentData.asc_putTime(this.utcDateToString(new Date(currentCommentData.get("date"))));
ascCommentData.asc_putUserId(currentCommentData.get("userid"));
ascCommentData.asc_putUserName(user ? user.get("username") : "");
ascCommentData.asc_putSolved(currentCommentData.get("resolved"));
var appendComment = function (data) {
var addReply = new asc_CCommentData();
addReply.asc_putText(data.reply);
addReply.asc_putTime(data.date);
addReply.asc_putUserId(data.userid);
addReply.asc_putUserName(data.username);
ascCommentData.asc_addReply(addReply);
};
currentCommentData.replys().each(function (reply) {
if (replyId != reply.get("id")) {
var addReply = new asc_CCommentData();
addReply.asc_putText(reply.get("reply"));
addReply.asc_putTime(me.utcDateToString(new Date(reply.get("date"))));
addReply.asc_putUserId(reply.get("userid"));
addReply.asc_putUserName(reply.get("username"));
ascCommentData.asc_addReply(addReply);
}
});
this.api.asc_changeComment(commentId, ascCommentData);
}
}
},
updateHandlers: function (record, commentNode, handlers) {
var me = this,
commentId = record.get("id"),
rootNodeEl = Ext.get(commentNode);
if (Ext.isDefined(rootNodeEl)) {
var updateCommentHandler = function (clsEl, handler) {
var controlEl = rootNodeEl.down(clsEl);
if (controlEl) {
var func = Ext.bind(function (event, el) {
handler.call(el, commentId);
},
me);
controlEl.un("click");
controlEl.on("click", func);
}
};
var updateReplyHandler = function (clsEl, handler) {
var replys = rootNodeEl.down(".replys");
if (replys) {
var editElements = replys.query(clsEl);
Ext.each(editElements, function (element) {
var el = Ext.get(element),
rootReply = el.up(".reply");
if (rootReply) {
var replyId = rootReply.id.match(/\d+/g);
if (replyId != null && replyId.length > 0) {
var func = Ext.bind(function (event, el) {
handler.call(el, commentId, replyId);
},
me);
el.un("click");
el.on("click", func);
}
}
});
}
};
var updateReplyTextHandler = function (clsEl, handler) {
var replys = rootNodeEl.down(".replys");
if (replys) {
var msgElements = replys.query(clsEl);
Ext.each(msgElements, function (element) {
var controlEl = Ext.get(element);
if (controlEl) {
var func = Ext.bind(function (event, el) {
handler.call(el, commentId);
},
me);
controlEl.un("click");
controlEl.on("click", func);
}
});
}
};
updateCommentHandler(".resolve", function (commentId) {
if (handlers && handlers.onResolveComment) {
handlers.onResolveComment.call(me, commentId);
}
});
updateCommentHandler(".comment.edit", function (commentId) {
if (handlers && handlers.showEditCommentControls) {
handlers.showEditCommentControls.call(me, commentId);
}
});
updateCommentHandler(".comment.delete", function (commentId) {
me.deleteComment(commentId);
});
updateCommentHandler(".quote", function (commentId) {
me.selectComment(commentId);
});
updateCommentHandler(".comment-message", function (commentId) {
me.selectComment(commentId);
});
updateReplyTextHandler(".reply-message", function (commentId) {
me.selectComment(commentId);
});
updateReplyHandler(".edit", function (commentId, replyId) {
if (handlers && handlers.showEditReplyControls) {
handlers.showEditReplyControls.call(me, commentId, replyId);
}
});
updateReplyHandler(".delete", function (commentId, replyId) {
me.deleteReply(commentId, replyId[0]);
});
}
}
});

File diff suppressed because it is too large Load Diff

View File

@@ -1,952 +0,0 @@
/*
* (c) Copyright Ascensio System SIA 2010-2014
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
Ext.define("Common.controller.CommentsPopover", {
extend: "Common.controller.CommentsBase",
requires: ["Common.view.CommentsEditForm"],
views: ["Common.view.CommentsPopover"],
init: function () {
this.visiblePopovers = new Ext.util.MixedCollection();
this.isDocumentContentReady = false;
this.control({
"commoncommentspopover": {
afterrender: this.onAfterRenderPopover,
transformToAdd: this.onTransformToAdd
},
"commoncommentspopover > dataview": {
afterrender: this.onAfterRenderComment,
itemupdate: this.onUpdateComment,
viewready: this.onViewReadyComments
},
"commoncommentspopover textarea[action=add-reply-textarea]": {
elastic: this.onElasticAddReply,
keydown: this.onKeyDownTextArea
},
"commoncommentspopover label[action=link]": {
afterrender: this.onAfterRenderAddReply
},
"commoncommentspopover button[action=reply]": {
click: this.onBtnAddReply
},
"commoncommentspopover button[action=close]": {
click: this.onBtnCloseReply
}
});
},
config: {
movingTopLimit: -32,
movingBottomLimit: -6,
autoPopup: true,
lastPosition: {
x: 0,
y: 0
}
},
sdkViewName: "#id_main",
setConfig: function (data, api) {
this.superclass.loadConfig.call(this, data);
this.setApi(api);
this.sdkViewName = data["sdkviewname"] || this.sdkViewName;
this.setMovingTopLimit(data.movingtoplimit || -32);
this.setMovingBottomLimit(data.movingbottomlimit || -6);
this.setAutoPopup(data.autopopup || true);
},
setApi: function (o) {
this.callParent(arguments);
},
registerCallbacks: function () {
this.api.asc_registerCallback("asc_onAddComment", Ext.bind(this.onApiAddComment, this));
this.api.asc_registerCallback("asc_onShowComment", Ext.bind(this.onApiShowComment, this));
this.api.asc_registerCallback("asc_onHideComment", Ext.bind(this.onApiHideComment, this));
this.api.asc_registerCallback("asc_onUpdateCommentPosition", Ext.bind(this.onApiUpdateCommentPosition, this));
this.api.asc_registerCallback("asc_onRemoveComment", Ext.bind(this.onApiRemoveComment, this));
},
onApiAddComment: function (commentId, data) {
if (this.isDocumentContentReady && this.getAutoPopup()) {
this.api.asc_selectComment(commentId);
this.api.asc_showComment(commentId, true);
}
},
onApiShowComment: function (commentId, posX, posY, leftX, canedit) {
commentId = commentId[commentId.length - 1];
if (!Ext.isEmpty(Ext.get("id-doc-comment-" + commentId))) {
return;
}
this.setLastPosition({
x: posX,
y: posY,
lx: leftX
});
this.onApiHideComment();
var docArea = Ext.getCmp("editor_sdk");
if (docArea) {
var sdkMainView = docArea.getEl().down(this.sdkViewName);
if (sdkMainView) {
var ownerCommentEl = sdkMainView.createChild({
tag: "div",
id: "id-doc-comment-" + commentId,
cls: "comment-popover-root",
style: "top: " + posY + "px; left: " + posX + "px;"
});
if (ownerCommentEl) {
var newPopover = Ext.widget("commoncommentspopover", {
commentId: commentId,
userId: this.getCurrentUserId(),
editable: !(canedit === false),
renderTo: ownerCommentEl,
maxHeight: sdkMainView.getHeight() + this.getMovingTopLimit() + this.getMovingBottomLimit()
});
if (newPopover) {
if (posX + newPopover.getWidth() > sdkMainView.getWidth()) {
if (leftX) {
ownerCommentEl.addCls("left-sided").setLeft(leftX - newPopover.getWidth() - parseInt(ownerCommentEl.getStyle("margin-right")));
} else {
var marginLeft = parseInt(ownerCommentEl.getStyle("margin-left"));
if (marginLeft) {
ownerCommentEl.setLeft(sdkMainView.getWidth() - newPopover.getWidth() - marginLeft * 2);
}
}
}
if (posY + newPopover.getHeight() > sdkMainView.getHeight()) {
ownerCommentEl.setTop(sdkMainView.getHeight() - newPopover.getHeight());
}
newPopover.getEl().alignTo(ownerCommentEl, "tl");
newPopover.show();
this.visiblePopovers.add(commentId, newPopover);
}
}
}
}
},
onApiHideComment: function () {
if (this.visiblePopovers.length) {
this.keepIncompleteComments();
this.visiblePopovers.eachKey(function (key, widget) {
var ownerCommentEl = Ext.get("id-doc-comment-" + key);
if (ownerCommentEl) {
widget.destroy();
ownerCommentEl.remove();
}
});
this.visiblePopovers.clear();
this.editControls = undefined;
}
},
onApiRemoveComment: function (commentId) {
this.clearIncompleteComments(commentId);
var ownerCommentEl = Ext.get("id-doc-comment-" + commentId);
if (ownerCommentEl) {
var widget = this.visiblePopovers.get(commentId);
if (widget) {
widget.destroy();
ownerCommentEl.remove();
this.visiblePopovers.removeAtKey(commentId); ! this.visiblePopovers.length && (this.editControls = undefined);
}
}
},
onApiUpdateCommentPosition: function (commentId, newPosX, newPosY, leftX) {
var ownerCommentEl = Ext.get("id-doc-comment-" + commentId),
popoverCmp = this.getViewByCommentId(commentId),
docArea = Ext.getCmp("editor_sdk"),
me = this;
if (docArea && ownerCommentEl && popoverCmp) {
var sdkMainView = docArea.getEl().down(this.sdkViewName);
if (sdkMainView) {
var ownerMarginLeft = parseInt(ownerCommentEl.getStyle("margin-left")),
ownerMarginTop = parseInt(ownerCommentEl.getStyle("margin-top"));
this.setLastPosition({
x: newPosX,
y: newPosY,
lx: leftX
});
if (newPosY > 0 && newPosY < sdkMainView.getHeight()) {
if (!popoverCmp.isVisible()) {
popoverCmp.show();
var commentsList = this.getDataViewInView(popoverCmp);
if (commentsList) {
commentsList.doComponentLayout();
me.updateCommentsScrollView(commentsList, true);
}
this.fixViewSize(popoverCmp);
}
} else {
popoverCmp.hide();
}
if (popoverCmp.isVisible()) {
if (newPosX + popoverCmp.getWidth() > sdkMainView.getWidth()) {
if (leftX) {
ownerCommentEl.addCls("left-sided").setLeft(leftX - popoverCmp.getWidth() - parseInt(ownerCommentEl.getStyle("margin-right")));
} else {
ownerCommentEl.setLeft(sdkMainView.getWidth() - popoverCmp.getWidth() - ownerMarginLeft * 2);
}
} else {
ownerCommentEl.removeCls("left-sided").setLeft(newPosX);
}
var arrow = popoverCmp.getEl().down(".popover-arrow");
var arrowCt = arrow.up(".x-container");
if (newPosY + popoverCmp.getHeight() + ownerMarginTop - this.getMovingBottomLimit() > sdkMainView.getHeight() && newPosY < sdkMainView.getHeight()) {
var top = sdkMainView.getHeight() - popoverCmp.getHeight() - ownerMarginTop + this.getMovingBottomLimit();
if (newPosY - top + arrow.getHeight() + 5 + (arrow.getTop() - arrowCt.getTop()) < popoverCmp.getHeight()) {
arrowCt.setStyle("margin-top", (newPosY - top) + "px");
}
ownerCommentEl.setTop(sdkMainView.getHeight() - popoverCmp.getHeight() - ownerMarginTop + this.getMovingBottomLimit());
} else {
if (newPosY < Math.abs(ownerMarginTop + this.getMovingTopLimit())) {
ownerCommentEl.setTop(Math.abs(ownerMarginTop + this.getMovingTopLimit()));
} else {
if (!/^0/.test(arrowCt.getStyle("margin-top"))) {
arrowCt.setStyle("margin-top", 0);
}
ownerCommentEl.setTop(newPosY);
}
}
}
var popover = this.visiblePopovers.get(commentId);
if (popover) {
popover.getEl().alignTo(ownerCommentEl, "tl-tl");
}
}
}
},
onDocumentContentReady: function () {
this.isDocumentContentReady = true;
},
getViewByCommentId: function (commentId) {
return Ext.getCmp("id-popover-comments-" + commentId);
},
getViewByCmp: function (cmp) {
if (cmp) {
return cmp.findParentBy(function (obj) {
if (obj.getEl() && obj.getEl().hasCls("common-commentspopover")) {
return true;
}
});
}
return null;
},
getDataViewInView: function (view) {
if (view) {
return view.down("dataview");
}
return null;
},
fixViewSize: function (view) {
var dataview = view.down("dataview"),
link = view.down("container[action=add-reply-link-container]"),
form = view.down("container[action=add-reply-form-container]");
if (dataview) {
var dataviewEl = dataview.getEl(),
height = dataviewEl.getHeight(),
plugin = dataview.getPlugin("scrollpane");
if (plugin) {
var pane = dataviewEl.down(".jspPane");
if (pane) {
height = pane.getHeight();
}
}
if (height < view.minHeight) {
height = view.minHeight;
}
if (form && !form.isHidden()) {
height += form.getHeight();
} else {
if (link) {
height += link.getHeight();
}
}
if (height > view.maxHeight) {
height = view.maxHeight;
}
view.setHeight(height);
this.onApiUpdateCommentPosition(view.getCommentId(), this.getLastPosition().x, this.getLastPosition().y, this.getLastPosition().lx);
}
},
onAfterRenderPopover: function (cmp) {
this.fixViewSize(cmp);
},
onTransformToAdd: function (cmp) {
var me = this;
this.showEditCommentControls(cmp.commentId);
var addReplyLink = cmp.down("#id-popover-add-reply-link-" + cmp.commentId),
editForm = Ext.getCmp("controls-edit-msg-popover-" + cmp.commentId);
if (addReplyLink) {
addReplyLink.hide();
}
if (editForm) {
var buttons = editForm.query("button"),
textarea = editForm.query("textarea");
textarea && textarea[0].focus(false, 100);
Ext.each(buttons, function (button) {
if (button.action == "edit") {
button.setText(me.textAdd);
}
button.on("click", function (cmp) {
Ext.each(buttons, function (button) {
button.un("click");
});
addReplyLink && addReplyLink.show();
me.hideEditCommentControls(cmp);
if (button.action != "edit") {
me.onApiHideComment();
}
},
{
single: true
});
});
}
cmp.doLayout();
cmp.doComponentLayout();
me.fixViewSize(cmp);
},
onAfterRenderAddReply: function (cmp) {
var me = this;
cmp.getEl().on("click", function (event, node) {
me.showAddReplyControls(cmp);
});
},
onAfterRenderComment: function (cmp) {
cmp.getSelectionModel().keyNav.disable();
},
onUpdateComment: function (record, index, node) {
var me = this,
commentId = record.get("id"),
popoverView = this.getViewByCommentId(commentId);
if (popoverView) {
var commentsList = this.getDataViewInView(popoverView);
if (commentsList) {
commentsList.doComponentLayout();
me.updateHandlers(record, "id-popover-comment-" + commentId, {
onResolveComment: me.onResolveComment,
showEditCommentControls: me.showEditCommentControls,
showEditReplyControls: me.showEditReplyControls
});
var replys = record.get("replays");
if (replys) {
replys.each(function (reply) {
me.hideEditReplyControls(commentId, reply.get("id"));
});
}
if (commentsList) {
this.updateCommentsScrollView(commentsList, true);
}
}
this.fixViewSize(popoverView);
var popoverViewEl = popoverView.getEl();
if (record.get("lock")) {
popoverViewEl.addCls("lock");
var userStore = this.getCommonStoreUsersStore(),
lockUserName = me.textAnonym;
if (userStore) {
var userRec = userStore.findRecord("id", record.get("lockuserid"));
if (userRec) {
lockUserName = userRec.get("username");
}
}
var authEl = popoverViewEl.down(".lock-author");
if (authEl) {
authEl.dom.innerHTML = lockUserName;
}
} else {
popoverViewEl.removeCls("lock");
}
}
},
onViewReadyComments: function (cmp) {
var me = this,
popoverView = this.getViewByCmp(cmp),
commentsList = this.getDataViewInView(popoverView),
commentsStore = cmp.getStore();
var record = commentsStore.findRecord("id", popoverView.getCommentId());
if (record) {
me.updateHandlers(record, "id-popover-comment-" + popoverView.getCommentId(), {
onResolveComment: me.onResolveComment,
showEditCommentControls: me.showEditCommentControls,
showEditReplyControls: me.showEditReplyControls
});
}
if (commentsList) {
if (popoverView.editable) {
this.showIncompleteCommentEditControls(popoverView.getCommentId());
}
this.updateCommentsScrollView(commentsList);
this.fixViewSize(popoverView);
var popoverViewEl = popoverView.getEl();
if (record && record.get("lock")) {
popoverViewEl.addCls("lock");
var userStore = this.getCommonStoreUsersStore(),
lockUserName = me.textAnonym;
if (userStore) {
var userRec = userStore.findRecord("id", record.get("lockuserid"));
if (userRec) {
lockUserName = userRec.get("username");
}
}
var authEl = popoverViewEl.down(".lock-author");
if (authEl) {
authEl.dom.innerHTML = lockUserName;
}
} else {
popoverViewEl.removeCls("lock");
}
}
},
updateCommentsScrollView: function (dataview, scrollBegin) {
if (dataview) {
var plugin = dataview.getPlugin("scrollpane");
if (plugin) {
var popover = this.getViewByCmp(dataview);
if (popover) {
popover.doLayout();
}
plugin.updateScrollPane();
dataview.fireEvent("resize");
if (scrollBegin) {
this.scrollViewToBegin(dataview);
}
}
}
},
scrollViewToBegin: function (dataview) {
if (dataview) {
var plugin = dataview.getPlugin("scrollpane");
if (plugin) {
var doScroll = new Ext.util.DelayedTask(function () {
plugin.jspApi.scrollToPercentY(0, true);
});
doScroll.delay(100);
}
}
},
scrollViewToNode: function (dataview, node) {
if (dataview && node) {
var plugin = dataview.getPlugin("scrollpane");
if (plugin) {
var doScroll = new Ext.util.DelayedTask(function () {
plugin.scrollToElement(node, false, true);
});
doScroll.delay(100);
}
}
},
showAddReplyControls: function (cmp, msg) {
var popoverView = this.getViewByCmp(cmp),
parentCmp = cmp.up("#id-popover-comments-" + popoverView.getCommentId()),
containerEditReply = parentCmp.down("#id-popover-controls-reply-" + popoverView.getCommentId()),
linkEditReply = parentCmp.down("#id-popover-add-reply-link-" + popoverView.getCommentId()),
textarea = parentCmp.down("textarea");
if (containerEditReply && linkEditReply) {
this.hideEditControls();
this.editControls = {
action: "add-reply",
component: cmp
};
containerEditReply.show();
linkEditReply.hide();
if (textarea) {
if (msg) {
textarea.setValue(msg);
} (new Ext.util.DelayedTask(function () {
textarea.focus();
},
this)).delay(100);
}
}
this.fixViewSize(popoverView);
},
hideAddReplyControls: function (cmp) {
var popoverView = this.getViewByCmp(cmp),
parentCmp = cmp.up("#id-popover-comments-" + popoverView.getCommentId()),
containerEditReply = parentCmp.down("#id-popover-controls-reply-" + popoverView.getCommentId()),
linkEditReply = parentCmp.down("#id-popover-add-reply-link-" + popoverView.getCommentId());
if (containerEditReply && linkEditReply) {
linkEditReply.show();
containerEditReply.hide();
}
popoverView.doLayout();
popoverView.doComponentLayout();
this.fixViewSize(popoverView);
this.editControls = undefined;
},
onResolveComment: function (commentId) {
var me = this,
popoverView = this.getViewByCommentId(commentId),
menuResolve = Ext.getCmp("comments-popover-menu-resolve-" + commentId);
if (popoverView) {
var commentResolveEl = popoverView.getEl().down(".resolve");
if (commentResolveEl) {
var commentsStore = this.getCommonStoreCommentsStore();
if (commentsStore) {
var comment = commentsStore.findRecord("id", commentId);
if (comment) {
var resolved = comment.get("resolved");
if (!resolved) {
this.resolveComment(commentId, !resolved);
} else {
if (!menuResolve) {
menuResolve = Ext.widget("menu", {
id: "comments-popover-menu-resolve-" + commentId,
renderTo: Ext.getBody(),
plain: true,
minWidth: 50,
bodyCls: "menu-resolve-comment",
items: [{
text: me.textOpenAgain,
listeners: {
click: function (item, event) {
item.ownerCt.hide();
me.resolveComment(commentId, false);
}
}
}]
});
}
menuResolve.show();
menuResolve.showBy(commentResolveEl, "tr-br", [0, 5]);
}
}
}
}
}
},
showEditCommentControls: function (commentId, msg) {
var me = this,
popoverView = this.getViewByCommentId(commentId);
if (popoverView) {
var commentsList = this.getDataViewInView(popoverView);
if (commentsList) {
var commentEl = commentsList.getEl().down("#id-popover-comment-" + commentId);
if (commentEl) {
var commentMsgEl = commentEl.down(".comment-message");
if (commentMsgEl) {
var message = commentMsgEl.down(".comment"),
editControlsEl = commentEl.down(".edit-info"),
editCommentControls = Ext.getCmp("controls-edit-msg-popover-" + commentId),
commentsStore = commentsList.getStore();
if (commentsStore) {
var comment = commentsStore.findRecord("id", commentId);
if (comment) {
if (editCommentControls) {
editCommentControls.destroy();
}
if (editControlsEl) {
editControlsEl.hide();
}
if (message) {
message.setVisibilityMode(Ext.Element.DISPLAY);
message.hide();
}
this.hideEditControls();
this.editControls = {
action: "comment",
comment: commentId
};
var editForm = Ext.widget("commoncommentseditform", {
scope: this,
editId: "popover-" + commentId,
renderTo: commentMsgEl,
msgValue: msg || comment.get("comment"),
onEditHandler: this.onBtnEditComment,
onCancelHandler: this.onBtnCancelEditComment
});
commentsList.on("resize", function () {
editForm.doLayout();
},
this, {
delay: 100
});
var onElastic = function () {
me.fixViewSize(popoverView);
me.updateCommentsScrollView(commentsList);
};
if (editForm) {
var textarea = editForm.down("textarea");
if (textarea) {
textarea.on("elastic", onElastic);
(new Ext.util.DelayedTask(function () {
textarea.focus();
if (textarea.getValue()) {
textarea.selectText(textarea.getValue().length);
}
},
this)).delay(100);
}
}
onElastic();
}
}
}
}
}
}
},
hideEditCommentControls: function (commentId) {
var popoverView = this.getViewByCommentId(commentId);
if (popoverView) {
var commentsList = this.getDataViewInView(popoverView);
if (commentsList) {
var commentEl = commentsList.getEl().down("#id-popover-comment-" + commentId),
commentMsgEl = commentEl.down(".comment-message");
if (commentMsgEl) {
var message = commentMsgEl.down(".comment"),
editControlsEl = commentEl.down(".edit-info"),
editCommentControls = Ext.getCmp("controls-edit-msg-popover-" + commentId);
if (editControlsEl) {
editControlsEl.show();
}
if (editCommentControls) {
editCommentControls.hide();
}
if (message) {
message.setVisibilityMode(Ext.Element.DISPLAY);
message.show();
}
this.fixViewSize(popoverView);
this.updateCommentsScrollView(commentsList);
this.editControls = undefined;
}
}
}
},
showEditReplyControls: function (commentId, replyId, msg) {
var me = this,
popoverView = this.getViewByCommentId(commentId);
if (popoverView) {
var commentsList = this.getDataViewInView(popoverView);
if (commentsList) {
var replyEl = commentsList.getEl().down("#reply-" + replyId),
replyMsgEl = replyEl.down(".reply-message");
if (replyMsgEl) {
var message = replyMsgEl.down(".message"),
editControlsEl = replyEl.down(".edit-info"),
editReplyControls = Ext.getCmp("controls-edit-msg-popover-" + replyId);
var commentsStore = Ext.getStore("Common.store.Comments");
if (commentsStore) {
var comment = commentsStore.findRecord("id", commentId);
if (comment) {
var reply = comment.replys().findRecord("id", replyId);
if (reply) {
if (editReplyControls) {
editReplyControls.destroy();
}
if (editControlsEl) {
editControlsEl.hide();
}
if (message) {
message.setVisibilityMode(Ext.Element.DISPLAY);
message.hide();
}
this.hideEditControls();
this.editControls = {
action: "edit-reply",
comment: commentId,
reply: replyId
};
var editForm = Ext.widget("commoncommentseditform", {
scope: this,
editId: "popover-" + replyId,
renderTo: replyMsgEl,
msgValue: msg || reply.get("reply"),
onEditHandler: this.onBtnEditReply,
onCancelHandler: this.onBtnCancelEditReply
});
commentsList.on("resize", function () {
editForm.doLayout();
},
this, {
delay: 100
});
var onElastic = function () {
me.fixViewSize(popoverView);
me.updateCommentsScrollView(commentsList);
var scrollToNode = Ext.get("controls-edit-msg-popover-" + replyId);
if (scrollToNode) {
me.scrollViewToNode(commentsList, scrollToNode.dom);
}
};
if (editForm) {
var textarea = editForm.down("textarea");
if (textarea) {
textarea.on("elastic", onElastic);
(new Ext.util.DelayedTask(function () {
textarea.focus();
if (textarea.getValue()) {
textarea.selectText(textarea.getValue().length);
}
},
this)).delay(100);
}
}
onElastic();
}
}
}
}
}
}
},
hideEditReplyControls: function (commentId, replyId) {
var popoverView = this.getViewByCommentId(commentId);
if (popoverView) {
var commentsList = this.getDataViewInView(popoverView);
if (commentsList) {
var replyEl = commentsList.getEl().down("#reply-" + replyId),
replyMsgEl = replyEl.down(".reply-message");
if (replyMsgEl) {
var message = replyMsgEl.down(".message"),
editControlsEl = replyEl.down(".edit-info"),
editReplyControls = Ext.getCmp("controls-edit-msg-popover-" + replyId);
if (editControlsEl) {
editControlsEl.show();
}
if (editReplyControls) {
editReplyControls.hide();
}
if (message) {
message.setVisibilityMode(Ext.Element.DISPLAY);
message.show();
}
this.fixViewSize(popoverView);
this.updateCommentsScrollView(commentsList);
this.editControls = undefined;
}
}
}
},
makeCommentEditable: function (commentId) {
var commentPopover = Ext.ComponentQuery.query("commoncommentspopover")[0];
$("#" + commentPopover.id).find(".edit-info").show();
var addReplyLink = commentPopover.down("#id-popover-add-reply-link-" + commentId);
addReplyLink && addReplyLink.show();
commentPopover.editable = true;
commentPopover.doLayout();
commentPopover.doComponentLayout();
this.fixViewSize(commentPopover);
},
onBtnEditComment: function (cmp) {
var commentRoot = cmp.getEl().up(".comment-wrap");
if (commentRoot) {
var commentId = commentRoot.id.match(/id-popover-comment-(.+)/)[1];
var editRoot = cmp.findParentBy(function (obj) {
if (obj.getEl() && obj.getEl().hasCls("controls-edit-msg-container")) {
return true;
}
});
if (editRoot) {
var textarea = editRoot.down("textarea");
if (textarea) {
this.editComment(commentId, textarea.getValue());
}
}
var addReplyLink = Ext.getCmp("id-popover-add-reply-link-" + commentId);
addReplyLink && addReplyLink.show();
this.hideEditCommentControls(commentId);
}
},
onBtnCancelEditComment: function (cmp) {
var commentRoot = cmp.getEl().up(".comment-wrap");
if (commentRoot) {
this.hideEditCommentControls(commentRoot.id.match(/id-popover-comment-(.+)/)[1]);
}
},
onBtnEditReply: function (cmp) {
var replyRoot = cmp.getEl().up(".reply"),
commentRoot = cmp.getEl().up(".comment-wrap");
if (replyRoot && commentRoot) {
var commentId = commentRoot.id.match(/id-popover-comment-(.+)/)[1],
replyId = replyRoot.id.match(/\d+/g);
var editRoot = cmp.findParentBy(function (obj) {
if (obj.getEl() && obj.getEl().hasCls("controls-edit-msg-container")) {
return true;
}
});
if (editRoot) {
var textarea = editRoot.down("textarea");
if (textarea) {
this.editReply(commentId, replyId, textarea.getValue());
}
}
this.editControls = undefined;
}
},
onBtnCancelEditReply: function (cmp) {
var replyRoot = cmp.getEl().up(".reply"),
commentRoot = cmp.getEl().up(".comment-wrap");
if (replyRoot && commentRoot) {
this.hideEditReplyControls(commentRoot.id.match(/id-popover-comment-(.+)/)[1], replyRoot.id.match(/\d+/g));
}
},
onBtnAddReply: function (cmp) {
var popoverView = this.getViewByCmp(cmp),
commentsList = this.getDataViewInView(popoverView),
parentCmp = cmp.up("#id-popover-comments-" + popoverView.getCommentId());
if (parentCmp) {
var textarea = parentCmp.down("textarea");
if (textarea) {
if (textarea.getValue().length < 1) {
return;
}
var replyVal = Ext.String.trim(textarea.getValue());
if (this.addReply(popoverView.getCommentId(), replyVal)) {
textarea.setValue("");
this.hideAddReplyControls(cmp);
this.updateCommentsScrollView(commentsList, true);
}
}
}
},
onBtnCloseReply: function (cmp) {
var popoverView = this.getViewByCmp(cmp),
parentCmp = cmp.up("#id-popover-comments-" + popoverView.getCommentId());
if (parentCmp) {
var textarea = parentCmp.down("textarea");
if (textarea) {
textarea.setValue("");
this.hideAddReplyControls(cmp);
}
}
},
onElasticAddReply: function (cmp, width, height) {
var parent = cmp.ownerCt;
if (parent) {
var editContainer = parent.down("container");
if (editContainer && editContainer.rendered) {
var paddingTop = parseInt(parent.getEl().getStyle("padding-top")),
paddingBottom = parseInt(parent.getEl().getStyle("padding-bottom"));
parent.setHeight(height + editContainer.getHeight() + paddingTop + paddingBottom + 5);
var rootParent = parent.ownerCt;
if (rootParent) {
this.fixViewSize(rootParent);
}
}
}
},
onKeyDownTextArea: function (cmp, event) {
if (event.getKey() == event.ENTER) {
if ((event.ctrlKey || event.metaKey) && !event.shiftKey) {
var popoverView = this.getViewByCmp(cmp),
commentsList = this.getDataViewInView(popoverView),
parentCmp = cmp.up("#id-popover-comments-" + popoverView.getCommentId());
if (parentCmp) {
if (cmp.getValue().length < 1) {
return;
}
var replyVal = Ext.String.trim(cmp.getValue());
if (this.addReply(popoverView.getCommentId(), replyVal)) {
cmp.setValue("");
this.hideAddReplyControls(cmp);
this.updateCommentsScrollView(commentsList, true);
}
}
}
}
},
keepIncompleteComments: function () {
var comment_keys, text, me = this,
comment_key;
me.visiblePopovers.eachKey(function (key, widget) {
if (widget.editable) {
me.clearIncompleteComments(key);
comment_keys = [];
if (me.editControls) {
if (me.editControls.action == "comment") {
comment_key = "self";
text = $("#controls-edit-msg-popover-" + key + " textarea").filter(":visible");
} else {
if (me.editControls.action == "add-reply") {
comment_key = "reply";
text = $("#id-popover-controls-reply-" + key + " textarea").filter(":visible");
} else {
comment_key = me.editControls.reply;
text = $("#controls-edit-msg-popover-" + comment_key + " textarea").filter(":visible");
}
}
if (text && text[0] && text[0].value.length) {
comment_keys.push(comment_key);
window.sessionStorage.setItem(comment_key, text[0].value);
}
}
if (comment_keys.length) {
window.sessionStorage.setItem(key, comment_keys);
}
}
});
},
clearIncompleteComments: function (commentId) {
var comment_keys = window.sessionStorage.getItem(commentId);
if (comment_keys) {
comment_keys = comment_keys.match(/[a-zA-Z0-9-_]+/);
comment_keys.forEach(function (item) {
window.sessionStorage.removeItem(item);
});
window.sessionStorage.removeItem(commentId);
}
},
showIncompleteCommentEditControls: function (commentId) {
var me = this;
var comment_keys = window.sessionStorage.getItem(commentId),
text;
if (comment_keys) {
comment_keys = comment_keys.match(/[a-zA-Z0-9-_]+/ig);
comment_keys.forEach(function (item) {
text = window.sessionStorage.getItem(item);
if (item == "self") {
me.showEditCommentControls(commentId, text);
} else {
if (item == "reply") {
var addReplyLink = Ext.getCmp("id-popover-add-reply-link-" + commentId);
me.showAddReplyControls(addReplyLink, text);
} else {
me.showEditReplyControls(commentId, item, text);
}
}
});
}
},
hideEditControls: function () {
if (this.editControls) {
switch (this.editControls.action) {
case "comment":
this.hideEditCommentControls(this.editControls.comment);
break;
case "add-reply":
this.hideAddReplyControls(this.editControls.component);
break;
case "edit-reply":
this.hideEditReplyControls(this.editControls.comment, this.editControls.reply);
break;
}
}
},
textAnonym: "Guest",
textOpenAgain: "Open Again",
textAdd: "Add"
});

View File

@@ -0,0 +1,213 @@
/*
* (c) Copyright Ascensio System SIA 2010-2015
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
if (Common === undefined) {
var Common = {};
}
Common.Controllers = Common.Controllers || {};
define(["core", "common/main/lib/view/ExternalDiagramEditor"], function () {
Common.Controllers.ExternalDiagramEditor = Backbone.Controller.extend(_.extend((function () {
var appLang = "en",
externalEditor = null;
var createExternalEditor = function () {
externalEditor = new DocsAPI.DocEditor("id-diagram-editor-placeholder", {
width: "100%",
height: "100%",
documentType: "spreadsheet",
document: {
permissions: {
edit: true,
download: false
}
},
editorConfig: {
mode: "editdiagram",
lang: appLang,
canCoAuthoring: false,
canBackToFolder: false,
canCreateNew: false,
user: {
id: ("uid-" + Date.now()),
name: this.textAnonymous
}
},
events: {
"onReady": function () {},
"onDocumentStateChange": function () {},
"onError": function () {},
"onInternalMessage": _.bind(this.onInternalMessage, this)
}
});
Common.Gateway.on("processmouse", _.bind(this.onProcessMouse, this));
};
return {
views: ["Common.Views.ExternalDiagramEditor"],
initialize: function () {
this.addListeners({
"Common.Views.ExternalDiagramEditor": {
"setchartdata": _.bind(this.setChartData, this),
"drag": _.bind(function (o, state) {
externalEditor.serviceCommand("window:drag", state == "start");
},
this),
"show": _.bind(function (cmp) {
var h = this.diagramEditorView.getHeight();
if (window.innerHeight > h && h < 700 || window.innerHeight < h) {
h = Math.min(window.innerHeight, 700);
this.diagramEditorView.setHeight(h);
}
if (externalEditor) {
externalEditor.serviceCommand("setAppDisabled", false);
if (this.needDisableEditing && this.diagramEditorView._isExternalDocReady) {
this.onDiagrammEditingDisabled();
}
externalEditor.attachMouseEvents();
} else {
createExternalEditor.apply(this);
}
this.isExternalEditorVisible = true;
},
this),
"hide": _.bind(function (cmp) {
if (externalEditor) {
externalEditor.detachMouseEvents();
this.isExternalEditorVisible = false;
}
},
this)
}
});
},
onLaunch: function () {
this.diagramEditorView = this.createView("Common.Views.ExternalDiagramEditor", {
handler: _.bind(this.handler, this)
});
},
setApi: function (api) {
this.api = api;
this.api.asc_registerCallback("asc_onCloseChartEditor", _.bind(this.onDiagrammEditingDisabled, this));
return this;
},
handler: function (result, value) {
externalEditor.serviceCommand("queryClose", {
mr: result
});
return true;
},
setChartData: function () {
externalEditor && externalEditor.serviceCommand("setChartData", this.diagramEditorView._chartData);
this.diagramEditorView._chartData = null;
},
loadConfig: function (data) {
if (data && data.config && data.config.lang) {
appLang = data.config.lang;
}
},
onDiagrammEditingDisabled: function () {
if (!this.diagramEditorView.isVisible() || !this.diagramEditorView._isExternalDocReady) {
this.needDisableEditing = true;
return;
}
this.diagramEditorView.setControlsDisabled(true);
Common.UI.alert({
title: this.warningTitle,
msg: this.warningText,
iconCls: "warn",
buttons: ["ok"],
callback: _.bind(function (btn) {
this.setControlsDisabled(false);
this.diagramEditorView.hide();
},
this)
});
this.needDisableEditing = false;
},
onInternalMessage: function (data) {
var eventData = data.data;
if (this.diagramEditorView) {
if (eventData.type == "documentReady") {
this.diagramEditorView._isExternalDocReady = true;
this.diagramEditorView.setControlsDisabled(false);
if (this.diagramEditorView._chartData) {
externalEditor && externalEditor.serviceCommand("setChartData", this.diagramEditorView._chartData);
this.diagramEditorView._chartData = null;
}
if (this.needDisableEditing) {
this.onDiagrammEditingDisabled();
}
} else {
if (eventData.type == "shortcut") {
if (eventData.data.key == "escape") {
this.diagramEditorView.hide();
}
} else {
if (eventData.type == "canClose") {
if (eventData.data.answer === true) {
if (externalEditor) {
externalEditor.serviceCommand("setAppDisabled", true);
externalEditor.serviceCommand((eventData.data.mr == "ok") ? "getChartData" : "clearChartData");
}
this.diagramEditorView.hide();
}
} else {
if (eventData.type == "processMouse") {
if (eventData.data.event == "mouse:up") {
this.diagramEditorView.binding.dragStop();
} else {
if (eventData.data.event == "mouse:move") {
var x = parseInt(this.diagramEditorView.$window.css("left")) + eventData.data.pagex,
y = parseInt(this.diagramEditorView.$window.css("top")) + eventData.data.pagey + 34;
this.diagramEditorView.binding.drag({
pageX: x,
pageY: y
});
}
}
} else {
this.diagramEditorView.fireEvent("internalmessage", this.diagramEditorView, eventData);
}
}
}
}
}
},
onProcessMouse: function (data) {
if (data.type == "mouseup" && this.isExternalEditorVisible) {
externalEditor && externalEditor.serviceCommand("processmouse", data);
}
},
warningTitle: "Warning",
warningText: "The object is disabled because of editing by another user.",
textClose: "Close",
textAnonymous: "Anonymous"
};
})(), Common.Controllers.ExternalDiagramEditor || {}));
});

View File

@@ -1,156 +1,100 @@
/*
* (c) Copyright Ascensio System SIA 2010-2014
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
var FONT_TYPE_USERUSED = 4;
Ext.define("Common.controller.Fonts", {
extend: "Ext.app.Controller",
views: ["ComboFonts"],
refs: [{
ref: "combo",
selector: "commoncombofonts"
}],
stores: ["Common.store.Fonts"],
init: function () {
this.control({
"commoncombofonts": {
expand: function (picker) {
var combo = this.getCombo();
var plugin = combo.getPlugin("scrollpane");
if (plugin) {
var doScroll = new Ext.util.DelayedTask(function () {
var node = combo.picker.getNode(combo.lastSelection[0]);
if (node) {
plugin.scrollToElement(node, false, false);
}
});
}
doScroll.delay(10);
},
select: this._selectitem
}
});
},
setApi: function (o) {
this.api = o;
this.api.asc_registerCallback("asc_onInitEditorFonts", Ext.bind(this._onloadfonts, this));
this.api.asc_registerCallback("asc_onFontFamily", Ext.bind(this._onfontchange, this));
},
_isfontsaved: function (s, r) {
var out = r.get("type") == FONT_TYPE_USERUSED,
i = -1,
c = s.getCount(),
su,
n = r.get("name");
while (!out && ++i < c) {
su = s.getAt(i);
if (su.get("type") != FONT_TYPE_USERUSED) {
break;
}
out = su.get("name") == n;
}
return out;
},
_selectitem: function (combo, records, eOpts) {
if (combo.showlastused && !this._isfontsaved(combo.getStore(), records[0])) {
var node = combo.picker.getNode(records[0]);
var data = records[0].data;
var font = {
id: data.id,
name: data.name,
imgidx: data.imgidx,
cloneid: node.querySelector("img").id,
type: FONT_TYPE_USERUSED
};
combo.getStore().insert(0, [font]);
var separator = combo.picker.getEl().down(".used-fonts-separator");
if (!separator) {
separator = document.createElement("div");
separator.setAttribute("class", "x-menu-item-separator used-fonts-separator");
separator.setAttribute("style", "padding:0 10px;margin-left: 10px;");
node = combo.picker.getNode(combo.getStore().getAt(1));
node.parentNode.insertBefore(separator, node);
}
font = combo.getStore().getAt(5);
if (font.data.type == FONT_TYPE_USERUSED) {
combo.getStore().remove(font);
} else {
var plugin = combo.getPlugin("scrollpane");
if (plugin) {
plugin.updateScrollPane();
}
}
}
},
_onfontchange: function (fontobj) {
var combo = this.getCombo();
var name = fontobj.get_Name();
var rec = combo.store.findRecord("name", name, 0, false, false, true);
combo.clearValue();
if (rec) {
combo.select(rec);
} else {
combo.setRawValue(name);
}
},
_onloadfonts: function (fl, select) {
var farr = [];
Ext.each(fl, function (item) {
farr.push({
id: item.asc_getFontId(),
name: item.asc_getFontName(),
imgidx: item.asc_getFontThumbnail(),
type: item.asc_getFontType()
});
});
var combo = this.getCombo();
if (combo) {
combo.fillFonts(farr, select);
} else {
this.fontscash = farr;
}
window.required_downloads--;
},
loadFonts: function (select) {
if (this.api) {
var fl = this.api.get_PropertyEditorFonts();
if (fl) {
this._onloadfonts(fl, select);
}
}
},
fillFonts: function (select) {
var combo = this.getCombo();
if (combo && combo.rendered && this.fontscash) {
combo.fillFonts(this.fontscash, select);
delete this.fontscash;
}
}
/*
* (c) Copyright Ascensio System SIA 2010-2015
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
if (Common === undefined) {
var Common = {};
}
Common.Controllers = Common.Controllers || {};
define(["core", "common/main/lib/collection/Fonts"], function () {
Common.Controllers.Fonts = Backbone.Controller.extend((function () {
var FONT_TYPE_USERUSED = 4;
function isFontSaved(store, rec) {
var out = rec.get("type") == FONT_TYPE_USERUSED,
i = -1,
c = store.length,
su,
n = rec.get("name");
while (!out && ++i < c) {
su = store.at(i);
if (su.get("type") != FONT_TYPE_USERUSED) {
break;
}
out = su.get("name") == n;
}
return out;
}
function onSelectFont(combo, record) {
if (combo.showlastused && !isFontSaved(combo.store, record)) {}
}
function onApiFontChange(fontobj) {
Common.NotificationCenter.trigger("fonts:change", fontobj);
}
function onApiLoadFonts(fonts, select) {
var fontsArray = [];
_.each(fonts, function (font) {
var fontId = font.asc_getFontId();
fontsArray.push({
id: _.isEmpty(fontId) ? Common.UI.getId() : fontId,
name: font.asc_getFontName(),
imgidx: font.asc_getFontThumbnail(),
type: font.asc_getFontType()
});
});
var store = this.getCollection("Common.Collections.Fonts");
if (store) {
store.add(fontsArray);
}
Common.NotificationCenter.trigger("fonts:load", store, select);
}
return {
models: ["Common.Models.Fonts"],
collections: ["Common.Collections.Fonts"],
views: [],
initialize: function () {
Common.NotificationCenter.on("fonts:select", _.bind(onSelectFont, this));
},
onLaunch: function () {},
setApi: function (api) {
this.api = api;
this.api.asc_registerCallback("asc_onInitEditorFonts", _.bind(onApiLoadFonts, this));
this.api.asc_registerCallback("asc_onFontFamily", _.bind(onApiFontChange, this));
},
loadFonts: function (select) {
if (this.api) {
var fonts = this.api.get_PropertyEditorFonts();
if (fonts) {
onApiLoadFonts.call(this, fonts, select);
}
}
}
};
})());
});

View File

@@ -0,0 +1,44 @@
/*
* (c) Copyright Ascensio System SIA 2010-2015
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
if (Common === undefined) {
var Common = {};
}
define(["backbone"], function (Backbone) {
var NotificationCenter = function () {};
_.extend(NotificationCenter.prototype, Backbone.Events);
if (typeof Common.NotificationCenter == "undefined") {
NotificationCenter.extend = Backbone.Model.extend;
Common.NotificationCenter = new NotificationCenter();
} else {
throw ("Native Common.NotificationCenter instance already defined.");
}
});

View File

@@ -0,0 +1,335 @@
/*
* (c) Copyright Ascensio System SIA 2010-2015
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
(function () {
var resolveNamespace = function (className, root) {
var parts = className.split("."),
current = root || window;
for (var a = 0, b = parts.length; a < b; a++) {
current = current[parts[a]] || {};
}
return current;
};
var Application = function (options) {
_.extend(this, options || {});
this.eventbus = new EventBus({
application: this
});
this.createApplicationNamespace();
this.initialize.apply(this, arguments);
if (this.autoCreate !== false) {
$($.proxy(this.onReady, this));
}
};
_.extend(Application.prototype, {
nameSpace: "Application",
models: {},
collections: {},
controllers: {},
allocationMap: {
model: "Models",
collection: "Collections",
controller: "Controllers",
view: "Views"
},
createApplicationNamespace: function () {
var nameSpace = window;
if (this.nameSpace) {
if (typeof nameSpace[this.nameSpace] == "undefined") {
nameSpace[this.nameSpace] = {};
}
}
nameSpace[this.nameSpace] = this;
_.each(this.allocationMap, function (name, key) {
this[name] = this[name] || {};
},
this);
},
initialize: function () {},
onReady: function () {
this.start();
},
start: function () {
this.initializeControllers(this.controllers || {});
this.launchControllers();
this.launch.call(this);
},
getClasseRefs: function (type, classes) {
var hashMap = {},
allocationMap = this.allocationMap[type],
root = this[allocationMap];
_.each(classes, function (cls) {
hashMap[cls] = resolveNamespace(cls, (cls.indexOf(".") > -1) ? window : root);
},
this);
return hashMap;
},
initializeControllers: function (controllers) {
this.controllers = {};
_.each(controllers, function (ctrl) {
var root = (ctrl.indexOf(".") > -1) ? window : this[this.allocationMap.controller],
classReference = resolveNamespace(ctrl, root),
id = ctrl.split(".").pop();
var controller = new classReference({
id: ctrl,
application: this
});
controller.views = this.getClasseRefs("view", controller.views || []);
_.extend(this.models, this.getClasseRefs("model", controller.models || []));
_.extend(this.collections, this.getClasseRefs("collection", controller.collections || {}));
this.buildCollections();
this.controllers[ctrl] = controller;
},
this);
},
launchControllers: function () {
_.each(this.controllers, function (ctrl, id) {
ctrl.onLaunch(this);
},
this);
},
launch: function () {},
addListeners: function (listeners, controller) {
this.eventbus.addListeners(listeners, controller);
},
getController: function (name) {
return this.controllers[name];
},
getModel: function (name) {
this._modelsCache = this._modelsCache || {};
var model = this._modelsCache[name],
modelClass = this.getModelConstructor(name);
if (!model && modelClass) {
model = this.createModel(name);
this._modelsCache[name] = model;
}
return model || null;
},
getModelConstructor: function (name) {
return this.models[name];
},
createModel: function (name, options) {
var modelClass = this.getModelConstructor(name),
model = null;
if (modelClass) {
model = new modelClass(_.extend(options || {}));
}
return model;
},
getCollection: function (name) {
this._collectionsCache = this._collectionsCache || {};
var collection = this._collectionsCache[name],
collectionClass = this.getCollectionConstructor(name);
if (!collection && collectionClass) {
collection = this.createCollection(name);
this._collectionsCache[name] = collection;
}
return collection || null;
},
getCollectionConstructor: function (name) {
return this.collections[name];
},
createCollection: function (name) {
var collectionClass = this.getCollectionConstructor(name),
collection = null;
if (collectionClass) {
collection = new collectionClass();
}
return collection;
},
buildCollections: function () {
_.each(this.collections, function (collection, alias) {
this.getCollection(alias);
},
this);
}
});
if (typeof Backbone.Application == "undefined") {
Backbone.Application = Application;
Backbone.Application.extend = Backbone.Model.extend;
} else {
throw ("Native Backbone.Application instance already defined.");
}
var Controller = function (options) {
_.extend(this, options || {});
this.initialize.apply(this, arguments);
};
_.extend(Controller.prototype, {
name: null,
views: {},
models: {},
collections: {},
initialize: function (options) {},
addListeners: function (listeners) {
this.getApplication().addListeners(listeners, this);
},
onLaunch: function (application) {},
getApplication: function () {
return this.application;
},
getView: function (name) {
return this._viewsCache[name];
},
getViewConstructor: function (name) {
return this.views[name];
},
createView: function (name, options) {
var view = this.getViewConstructor(name),
viewOptions = _.extend(options || {},
{
alias: name
});
this._viewsCache = this._viewsCache || {};
this._viewsCache[name] = new view(viewOptions);
this._viewsCache[name].options = _.extend({},
viewOptions);
return this._viewsCache[name];
},
getModel: function (name) {
return this.application.getModel(name);
},
getModelConstructor: function (name) {
return this.application.getModelConstructor(name);
},
createModel: function (name, options) {
return this.application.createModel(name);
},
getCollection: function (name) {
return this.application.getCollection(name);
},
getCollectionConstructor: function (name) {
return this.application.getCollectionConstructor(name);
},
createCollection: function (name) {
return this.application.createCollection(name);
},
fireEvent: function (selector, event, args) {
this.application.eventbus.fireEvent(selector, event, args);
},
bindViewEvents: function (view, events) {
this.unbindViewEvents(view);
events = _.isFunction(events) ? events.call(this) : events;
for (var key in events) {
var method = events[key];
if (!_.isFunction(method)) {
method = this[events[key]];
}
var match = key.match(/^(\S+)\s*(.*)$/);
var eventName = match[1],
selector = match[2];
method = _.bind(method, this);
eventName += ".bindViewEvents" + view.cid;
view.$el.on(eventName, selector, method);
}
return this;
},
unbindViewEvents: function (view) {
view.$el.off(".bindViewEvents" + view.cid);
return this;
}
});
if (typeof Backbone.Controller == "undefined") {
Backbone.Controller = Controller;
Backbone.Controller.extend = Backbone.Model.extend;
} else {
throw ("Native Backbone.Controller instance already defined.");
}
var EventBus = function (options) {
var me = this;
_.extend(this, options || {});
_.extend(Backbone.View.prototype, {
alias: null,
hidden: false,
getAlias: function () {
return this.options.alias;
},
fireEvent: function (event, args) {
this.trigger.apply(this, arguments);
me.fireEvent(this.getAlias(), event, args);
},
hide: function () {
this.$el.hide();
this.hidden = true;
},
show: function () {
this.$el.show();
this.hidden = false;
}
});
};
_.extend(EventBus.prototype, {
pool: {},
addListeners: function (selectors, controller) {
this.pool[controller.id] = this.pool[controller.id] || {};
var pool = this.pool[controller.id];
if (_.isArray(selectors)) {
_.each(selectors, function (selector) {
this.addListeners(selector, controller);
},
this);
} else {
if (_.isObject(selectors)) {
_.each(selectors, function (listeners, selector) {
_.each(listeners, function (listener, event) {
pool[selector] = pool[selector] || {};
pool[selector][event] = pool[selector][event] || [];
pool[selector][event].push(listener);
},
this);
},
this);
}
}
},
fireEvent: function (selector, event, args) {
var application = this.getApplication();
_.each(this.pool, function (eventsPoolByAlias, controllerId) {
var events = eventsPoolByAlias[selector];
if (events) {
var listeners = events[event],
controller = application.getController(controllerId);
_.each(listeners, function (fn) {
fn.apply(controller, args);
});
}
},
this);
},
getApplication: function () {
return this.application;
}
});
if (typeof Backbone.EventBus == "undefined") {
Backbone.EventBus = EventBus;
} else {
throw ("Native Backbone.Application instance already defined.");
}
})();

View File

@@ -0,0 +1,375 @@
/*
* (c) Copyright Ascensio System SIA 2010-2015
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
(function (global) {
var k, _handlers = {},
_mods = {
16: false,
18: false,
17: false,
91: false
},
_scope = "all",
_MODIFIERS = {
"⇧": 16,
shift: 16,
"⌥": 18,
alt: 18,
option: 18,
"⌃": 17,
ctrl: 17,
control: 17,
"⌘": 91,
command: 91
},
_MAP = {
backspace: 8,
tab: 9,
clear: 12,
enter: 13,
"return": 13,
esc: 27,
escape: 27,
space: 32,
left: 37,
up: 38,
right: 39,
down: 40,
del: 46,
"delete": 46,
home: 36,
end: 35,
pageup: 33,
pagedown: 34,
",": 188,
".": 190,
"/": 191,
"`": 192,
"-": 189,
"=": 187,
";": 186,
"'": 222,
"[": 219,
"]": 221,
"\\": 220
},
code = function (x) {
return _MAP[x] || x.toUpperCase().charCodeAt(0);
},
_downKeys = [];
var locked;
for (k = 1; k < 20; k++) {
_MAP["f" + k] = 111 + k;
}
function index(array, item) {
var i = array.length;
while (i--) {
if (array[i] === item) {
return i;
}
}
return -1;
}
function compareArray(a1, a2) {
if (a1.length != a2.length) {
return false;
}
for (var i = 0; i < a1.length; i++) {
if (a1[i] !== a2[i]) {
return false;
}
}
return true;
}
var modifierMap = {
16: "shiftKey",
18: "altKey",
17: "ctrlKey",
91: "metaKey"
};
function updateModifierKey(event) {
for (k in _mods) {
_mods[k] = event[modifierMap[k]];
}
}
function dispatch(event) {
var key, handler, k, i, modifiersMatch, scope;
key = event.keyCode;
if (index(_downKeys, key) == -1) {
_downKeys.push(key);
}
if (key == 93 || key == 224) {
key = 91;
}
if (key in _mods) {
_mods[key] = true;
for (k in _MODIFIERS) {
if (_MODIFIERS[k] == key) {
assignKey[k] = true;
}
}
return;
}
updateModifierKey(event);
if (!assignKey.filter.call(this, event)) {
return;
}
if (! (key in _handlers)) {
return;
}
scope = getScope();
for (i = 0; i < _handlers[key].length; i++) {
handler = _handlers[key][i];
if (handler.scope == scope || handler.scope == "all") {
modifiersMatch = handler.mods.length > 0;
for (k in _mods) {
if ((!_mods[k] && index(handler.mods, +k) > -1) || (_mods[k] && index(handler.mods, +k) == -1)) {
modifiersMatch = false;
}
}
if ((handler.mods.length == 0 && !_mods[16] && !_mods[18] && !_mods[17] && !_mods[91]) || modifiersMatch) {
if (locked === true || handler.locked || handler.method(event, handler) === false) {
if (event.preventDefault) {
event.preventDefault();
} else {
event.returnValue = false;
}
if (event.stopPropagation) {
event.stopPropagation();
}
if (event.cancelBubble) {
event.cancelBubble = true;
}
}
}
}
}
}
function clearModifier(event) {
var key = event.keyCode,
k, i = index(_downKeys, key);
if (i >= 0) {
_downKeys.splice(i, 1);
}
if (key == 93 || key == 224) {
key = 91;
}
if (key in _mods) {
_mods[key] = false;
for (k in _MODIFIERS) {
if (_MODIFIERS[k] == key) {
assignKey[k] = false;
}
}
}
}
function resetModifiers() {
for (k in _mods) {
_mods[k] = false;
}
for (k in _MODIFIERS) {
assignKey[k] = false;
}
}
function assignKey(key, scope, method) {
var keys, mods;
keys = getKeys(key);
if (method === undefined) {
method = scope;
scope = "all";
}
for (var i = 0; i < keys.length; i++) {
mods = [];
key = keys[i].split("+");
if (key.length > 1) {
mods = getMods(key);
key = [key[key.length - 1]];
}
key = key[0];
key = code(key);
if (! (key in _handlers)) {
_handlers[key] = [];
}
_handlers[key].push({
shortcut: keys[i],
scope: scope,
method: method,
key: keys[i],
mods: mods
});
}
}
function unbindKey(key, scope) {
var multipleKeys, keys, mods = [],
i,
j,
obj;
multipleKeys = getKeys(key);
for (j = 0; j < multipleKeys.length; j++) {
keys = multipleKeys[j].split("+");
if (keys.length > 1) {
mods = getMods(keys);
key = keys[keys.length - 1];
}
key = code(key);
if (scope === undefined) {
scope = getScope();
}
if (!_handlers[key]) {
return;
}
for (i in _handlers[key]) {
obj = _handlers[key][i];
if (obj.scope === scope && compareArray(obj.mods, mods)) {
_handlers[key][i] = {};
}
}
}
}
function isPressed(keyCode) {
if (typeof(keyCode) == "string") {
keyCode = code(keyCode);
}
return index(_downKeys, keyCode) != -1;
}
function getPressedKeyCodes() {
return _downKeys.slice(0);
}
function filter(event) {
var tagName = (event.target || event.srcElement).tagName;
return ! (tagName == "INPUT" || tagName == "SELECT" || tagName == "TEXTAREA");
}
for (k in _MODIFIERS) {
assignKey[k] = false;
}
function setScope(scope) {
_scope = scope || "all";
}
function getScope() {
return _scope || "all";
}
function deleteScope(scope) {
var key, handlers, i;
for (key in _handlers) {
handlers = _handlers[key];
for (i = 0; i < handlers.length;) {
if (handlers[i].scope === scope) {
handlers.splice(i, 1);
} else {
i++;
}
}
}
}
function getKeys(key) {
var keys;
key = key.replace(/\s/g, "");
keys = key.split(",");
if ((keys[keys.length - 1]) == "") {
keys[keys.length - 2] += ",";
}
return keys;
}
function getMods(key) {
var mods = key.slice(0, key.length - 1);
for (var mi = 0; mi < mods.length; mi++) {
mods[mi] = _MODIFIERS[mods[mi]];
}
return mods;
}
function addEvent(object, event, method) {
if (object.addEventListener) {
object.addEventListener(event, method, false);
} else {
if (object.attachEvent) {
object.attachEvent("on" + event, function () {
method(window.event);
});
}
}
}
addEvent(document, "keydown", function (event) {
dispatch(event);
});
addEvent(document, "keyup", clearModifier);
addEvent(window, "focus", resetModifiers);
var previousKey = global.key;
function noConflict() {
var k = global.key;
global.key = previousKey;
return k;
}
function setKeyOptions(key, scope, option, value) {
var keys, mods = [],
i,
obj;
var multipleKeys = getKeys(key);
for (var j = multipleKeys.length; j--;) {
keys = multipleKeys[j].split("+");
if (keys.length > 1) {
mods = getMods(keys);
key = keys[keys.length - 1];
}
key = code(key);
if (scope === undefined) {
scope = getScope();
}
if (_handlers[key]) {
for (i in _handlers[key]) {
obj = _handlers[key][i];
if (obj.scope === scope && compareArray(obj.mods, mods)) {
_handlers[key][i][option] = value;
}
}
}
}
}
function suspend(key, scope) {
key ? setKeyOptions(key, scope, "locked", true) : (locked = true);
}
function resume(key, scope) {
key ? setKeyOptions(key, scope, "locked", false) : (locked = false);
}
global.key = assignKey;
global.key.setScope = setScope;
global.key.getScope = getScope;
global.key.deleteScope = deleteScope;
global.key.filter = filter;
global.key.isPressed = isPressed;
global.key.getPressedKeyCodes = getPressedKeyCodes;
global.key.noConflict = noConflict;
global.key.unbind = unbindKey;
global.key.suspend = suspend;
global.key.resume = resume;
if (typeof module !== "undefined") {
module.exports = key;
}
})(this);

View File

@@ -0,0 +1,96 @@
/*
* (c) Copyright Ascensio System SIA 2010-2015
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
function onDropDownKeyDown(e) {
var $this = $(this),
$parent = $this.parent(),
beforeEvent = jQuery.Event("keydown.before.bs.dropdown"),
afterEvent = jQuery.Event("keydown.after.bs.dropdown");
$parent.trigger(beforeEvent);
if (beforeEvent.isDefaultPrevented()) {
return;
}
patchDropDownKeyDown.call(this, e);
e.preventDefault();
e.stopPropagation();
$parent.trigger(afterEvent);
}
function patchDropDownKeyDown(e) {
if (!/(38|40|27)/.test(e.keyCode)) {
return;
}
var $this = $(this);
e.preventDefault();
e.stopPropagation();
if ($this.is(".disabled, :disabled")) {
return;
}
var $parent = getParent($this);
var isActive = $parent.hasClass("open");
if (!isActive || (isActive && e.keyCode == 27)) {
if (e.which == 27) {
$items = $("[role=menu] li.dropdown-submenu.over:visible", $parent);
if ($items.size()) {
$items.eq($items.size() - 1).removeClass("over");
return false;
} else {
$parent.find("[data-toggle=dropdown]").focus();
}
}
return $this.click();
}
var $items = $("[role=menu] li:not(.divider):not(.disabled):visible", $parent).find("> a");
if (!$items.length) {
return;
}
var index = $items.index($items.filter(":focus"));
if (e.keyCode == 38) {
index > 0 ? index--:(index = $items.length - 1);
} else {
if (e.keyCode == 40) {
index < $items.length - 1 ? index++:(index = 0);
}
}
if (!~index) {
index = 0;
}
$items.eq(index).focus();
}
function getParent($this) {
var selector = $this.attr("data-target");
if (!selector) {
selector = $this.attr("href");
selector = selector && /#/.test(selector) && selector.replace(/.*(?=#[^\s]*$)/, "");
}
var $parent = selector && $(selector);
return $parent && $parent.length ? $parent : $this.parent();
}
$(document).off("keydown.bs.dropdown.data-api").on("keydown.bs.dropdown.data-api", "[data-toggle=dropdown], [role=menu]", onDropDownKeyDown);

View File

@@ -1,46 +1,42 @@
/*
* (c) Copyright Ascensio System SIA 2010-2014
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
Ext.define("Common.model.ChatMessage", {
extend: "Ext.data.Model",
fields: [{
type: "int",
name: "type"
},
{
type: "string",
name: "userid"
},
{
type: "string",
name: "message"
}]
/*
* (c) Copyright Ascensio System SIA 2010-2015
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
define(["backbone"], function (Backbone) {
Common.Models = Common.Models || {};
Common.Models.ChatMessage = Backbone.Model.extend({
defaults: {
type: 0,
userid: null,
username: "",
message: ""
}
});
});

View File

@@ -1,80 +1,77 @@
/*
* (c) Copyright Ascensio System SIA 2010-2014
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
Ext.define("Common.model.Comment", {
extend: "Ext.data.Model",
fields: [{
type: "string",
name: "id"
},
{
type: "string",
name: "userid"
},
{
type: "string",
name: "username",
defaultValue: "Guest"
},
{
type: "int",
name: "date"
},
{
type: "string",
name: "quote"
},
{
type: "string",
name: "comment"
},
{
type: "boolean",
name: "resolved",
defaultValue: false
},
{
type: "boolean",
name: "lock",
defaultValue: false
},
{
type: "string",
name: "lockuserid"
}],
proxy: {
type: "memory"
},
hasMany: {
model: "Common.model.Reply",
name: "replys"
}
/*
* (c) Copyright Ascensio System SIA 2010-2015
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
if (Common === undefined) {
var Common = {};
}
Common.Models = Common.Models || {};
define(["underscore", "backbone", "common/main/lib/component/BaseView"], function (_, Backbone) {
Common.Models.Comment = Backbone.Model.extend({
defaults: {
uid: 0,
userid: 0,
username: "Guest",
date: undefined,
quote: "",
comment: "",
resolved: false,
lock: false,
lockuserid: "",
unattached: false,
id: Common.UI.getId(),
time: 0,
showReply: false,
showReplyInPopover: false,
editText: false,
editTextInPopover: false,
last: undefined,
replys: [],
hideAddReply: false,
scope: null,
hide: false,
hint: false,
dummy: undefined
}
});
Common.Models.Reply = Backbone.Model.extend({
defaults: {
time: 0,
userid: 0,
username: "Guest",
reply: "",
date: undefined,
id: Common.UI.getId(),
editText: false,
editTextInPopover: false,
scope: null
}
});
});

View File

@@ -1,42 +1,48 @@
/*
* (c) Copyright Ascensio System SIA 2010-2014
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
Ext.define("Common.model.Font", {
extend: "Ext.data.Model",
fields: ["id", "name", "cloneid", {
type: "int",
name: "imgidx"
},
{
type: "int",
name: "type"
}]
/*
* (c) Copyright Ascensio System SIA 2010-2015
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
if (Common === undefined) {
var Common = {};
}
Common.Models = Common.Models || {};
define(["backbone"], function (Backbone) {
Common.Models.Font = Backbone.Model.extend({
defaults: function () {
return {
id: Common.UI.getId(),
name: null,
cloneid: null,
imgidx: 0,
type: 0
};
}
});
});

View File

@@ -1,42 +0,0 @@
/*
* (c) Copyright Ascensio System SIA 2010-2014
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
Ext.define("Common.model.Group", {
extend: "Ext.data.Model",
fields: ["group", "groupname"],
proxy: {
type: "memory"
},
hasMany: {
model: "Common.model.GroupItem",
name: "getGroupItems"
}
});

View File

@@ -1,42 +0,0 @@
/*
* (c) Copyright Ascensio System SIA 2010-2014
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
Ext.define("Common.model.GroupItem", {
extend: "Ext.data.Model",
fields: ["group", "groupitem", "iconcls"],
proxy: {
type: "memory"
},
belongsTo: {
model: "Common.model.Group",
name: "group"
}
});

View File

@@ -1,62 +0,0 @@
/*
* (c) Copyright Ascensio System SIA 2010-2014
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
Ext.define("Common.model.Reply", {
extend: "Ext.data.Model",
fields: [{
type: "int",
name: "id"
},
{
type: "string",
name: "userid"
},
{
type: "string",
name: "username",
defaultValue: ""
},
{
type: "int",
name: "date"
},
{
type: "string",
name: "reply"
}],
proxy: {
type: "memory"
},
belongsTo: {
model: "Common.model.Comment",
name: "comment"
}
});

View File

@@ -1,53 +1,42 @@
/*
* (c) Copyright Ascensio System SIA 2010-2014
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
Ext.define("Common.model.User", {
extend: "Ext.data.Model",
fields: [{
type: "string",
name: "id",
defaultValue: ""
},
{
type: "string",
name: "username",
defaultValue: "Guest"
},
{
type: "string",
name: "color"
},
{
type: "boolean",
name: "online",
defaultValue: false
}]
/*
* (c) Copyright Ascensio System SIA 2010-2015
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
define(["backbone"], function (Backbone) {
Common.Models = Common.Models || {};
Common.Models.User = Backbone.Model.extend({
defaults: {
id: undefined,
username: "Guest",
color: "#fff",
online: false
}
});
});

View File

@@ -0,0 +1,34 @@
# HG changeset patch
# User Alexey Musinov
# Date 1415710176 -10800
# Tue Nov 11 15:49:36 2014 +0300
# Node ID 784fe548cf4cbfc0a6c96b295ae83c551ce22166
# Parent 07b43d47bcf8afe8a2dabc8a0bce8c7dab3bd498
[Common] <20> perfect-scrollbar - <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD> 'textarea' <20> 'input' <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20> <20><><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>.
diff -r 07b43d47bcf8 -r 784fe548cf4c apps/common/main/lib/mods/perfect-scrollbar.js
--- a/apps/common/main/lib/mods/perfect-scrollbar.js Mon Nov 10 19:37:33 2014 +0300
+++ b/apps/common/main/lib/mods/perfect-scrollbar.js Tue Nov 11 15:49:36 2014 +0300
@@ -313,6 +313,22 @@
var deltaX = e.deltaX * e.deltaFactor || deprecatedDeltaX,
deltaY = e.deltaY * e.deltaFactor || deprecatedDeltaY;
+ if (e && e.target && (e.target.type === 'textarea' || e.target.type === 'input')) {
+ e.stopImmediatePropagation();
+ e.preventDefault();
+
+ var scroll = $(e.target).scrollTop(), wheelDeltaY = 0;
+ if (e.originalEvent) {
+ if (e.originalEvent.wheelDelta) wheelDeltaY = e.originalEvent.wheelDelta / -40;
+ if (e.originalEvent.deltaY) wheelDeltaY = e.originalEvent.deltaY;
+ if (e.originalEvent.detail) wheelDeltaY = e.originalEvent.detail;
+ }
+
+ $(e.target).scrollTop(scroll - wheelDeltaY);
+
+ return;
+ }
+
shouldPrevent = false;
if (!settings.useBothWheelAxes) {
// deltaX will only be used for horizontal scrolling and deltaY will

View File

@@ -0,0 +1,48 @@
diff -r 5047272bb302 apps/common/main/lib/mods/perfect-scrollbar.js
--- a/apps/common/main/lib/mods/perfect-scrollbar.js Fri Sep 12 18:17:33 2014 +0400
+++ b/apps/common/main/lib/mods/perfect-scrollbar.js Fri Sep 12 18:18:56 2014 +0400
@@ -146,7 +146,12 @@
var updateScrollbarCss = function () {
$scrollbarXRail.css({left: $this.scrollLeft(), bottom: scrollbarXBottom - $this.scrollTop(), width: containerWidth, display: scrollbarXActive ? "inherit": "none"});
- $scrollbarYRail.css({top: $this.scrollTop(), right: scrollbarYRight - $this.scrollLeft(), height: containerHeight, display: scrollbarYActive ? "inherit": "none"});
+
+ if ($scrollbarYRail.hasClass('in-scrolling'))
+ $scrollbarYRail.css({/*top: $this.scrollTop(),*/ right: scrollbarYRight - $this.scrollLeft(), height: containerHeight, display: scrollbarYActive ? "inherit": "none"});
+ else
+ $scrollbarYRail.css({top: $this.scrollTop(), right: scrollbarYRight - $this.scrollLeft(), height: containerHeight, display: scrollbarYActive ? "inherit": "none"});
+
$scrollbarX.css({left: scrollbarXLeft, width: scrollbarXWidth});
$scrollbarY.css({top: scrollbarYTop, height: scrollbarYHeight});
};
@@ -229,6 +234,15 @@
currentPageY = e.pageY;
currentTop = $scrollbarY.position().top;
$scrollbarYRail.addClass('in-scrolling');
+
+ var padding = parseInt($scrollbarYRail.offsetParent().css('padding-top'));
+ var rect = $scrollbarYRail[0].getBoundingClientRect();
+ $scrollbarYRail.css({
+ position: 'fixed',
+ left: rect.left,
+ top: rect.top - padding
+ });
+
e.stopPropagation();
e.preventDefault();
});
@@ -244,6 +258,14 @@
$(document).bind('mouseup' + eventClassName, function (e) {
if ($scrollbarYRail.hasClass('in-scrolling')) {
$scrollbarYRail.removeClass('in-scrolling');
+
+ $scrollbarYRail.css({
+ position: '',
+ left: '',
+ top: ''
+ });
+
+ updateScrollbarCss();
}
});

View File

@@ -0,0 +1,103 @@
diff -r c7981f4f7e09 apps/common/main/lib/mods/perfect-scrollbar.js
--- a/apps/common/main/lib/mods/perfect-scrollbar.js Tue Oct 07 11:32:00 2014 +0400
+++ b/apps/common/main/lib/mods/perfect-scrollbar.js Wed Oct 08 11:37:27 2014 +0400
// Use margins of scrollbarYRail when calculate scrollbarYRail height (scrollbarYRailHeight) and top position
@@ -28,7 +28,8 @@
suppressScrollY: false,
scrollXMarginOffset: 0,
scrollYMarginOffset: 0,
- includePadding: false
+ includePadding: false,
+ includeMargin: true
};
var getEventClassName = (function () {
@@ -97,11 +98,12 @@
scrollbarYHeight,
scrollbarYTop,
scrollbarYRight = parseInt($scrollbarYRail.css('right'), 10),
+ scrollbarYRailHeight,
eventClassName = getEventClassName();
var updateContentScrollTop = function (currentTop, deltaY) {
var newTop = currentTop + deltaY,
- maxTop = containerHeight - scrollbarYHeight;
+ maxTop = scrollbarYRailHeight - scrollbarYHeight;
if (newTop < 0) {
scrollbarYTop = 0;
@@ -113,7 +115,7 @@
scrollbarYTop = newTop;
}
- var scrollTop = parseInt(scrollbarYTop * (contentHeight - containerHeight) / (containerHeight - scrollbarYHeight), 10);
+ var scrollTop = parseInt(scrollbarYTop * (contentHeight - containerHeight) / (scrollbarYRailHeight - scrollbarYHeight), 10);
$this.scrollTop(scrollTop);
$scrollbarXRail.css({bottom: scrollbarXBottom - scrollTop});
};
@@ -148,9 +150,9 @@
$scrollbarXRail.css({left: $this.scrollLeft(), bottom: scrollbarXBottom - $this.scrollTop(), width: containerWidth, display: scrollbarXActive ? "inherit": "none"});
if ($scrollbarYRail.hasClass('in-scrolling'))
- $scrollbarYRail.css({/*top: $this.scrollTop(),*/ right: scrollbarYRight - $this.scrollLeft(), height: containerHeight, display: scrollbarYActive ? "inherit": "none"});
+ $scrollbarYRail.css({/*top: $this.scrollTop(),*/ right: scrollbarYRight - $this.scrollLeft(), height: scrollbarYRailHeight, display: scrollbarYActive ? "inherit": "none"});
else
- $scrollbarYRail.css({top: $this.scrollTop(), right: scrollbarYRight - $this.scrollLeft(), height: containerHeight, display: scrollbarYActive ? "inherit": "none"});
+ $scrollbarYRail.css({top: $this.scrollTop(), right: scrollbarYRight - $this.scrollLeft(), height: scrollbarYRailHeight, display: scrollbarYActive ? "inherit": "none"});
$scrollbarX.css({left: scrollbarXLeft, width: scrollbarXWidth});
$scrollbarY.css({top: scrollbarYTop, height: scrollbarYHeight});
@@ -159,6 +161,7 @@
var updateBarSizeAndPosition = function () {
containerWidth = settings.includePadding ? $this.innerWidth() : $this.width();
containerHeight = settings.includePadding ? $this.innerHeight() : $this.height();
+ scrollbarYRailHeight = containerHeight - (settings.includeMargin ? (parseInt($scrollbarYRail.css('margin-top')) + parseInt($scrollbarYRail.css('margin-bottom'))): 0);
contentWidth = $this.prop('scrollWidth');
contentHeight = $this.prop('scrollHeight');
@@ -176,8 +179,8 @@
if (!settings.suppressScrollY && containerHeight + settings.scrollYMarginOffset < contentHeight) {
scrollbarYActive = true;
- scrollbarYHeight = getSettingsAdjustedThumbSize(parseInt(containerHeight * containerHeight / contentHeight, 10));
- scrollbarYTop = parseInt($this.scrollTop() * (containerHeight - scrollbarYHeight) / (contentHeight - containerHeight), 10);
+ scrollbarYHeight = getSettingsAdjustedThumbSize(parseInt(scrollbarYRailHeight * containerHeight / contentHeight, 10));
+ scrollbarYTop = parseInt($this.scrollTop() * (scrollbarYRailHeight - scrollbarYHeight) / (contentHeight - containerHeight), 10);
}
else {
scrollbarYActive = false;
@@ -186,8 +189,8 @@
$this.scrollTop(0);
}
- if (scrollbarYTop >= containerHeight - scrollbarYHeight) {
- scrollbarYTop = containerHeight - scrollbarYHeight;
+ if (scrollbarYTop >= scrollbarYRailHeight - scrollbarYHeight) {
+ scrollbarYTop = scrollbarYRailHeight - scrollbarYHeight;
}
if (scrollbarXLeft >= containerWidth - scrollbarXWidth) {
scrollbarXLeft = containerWidth - scrollbarXWidth;
@@ -235,12 +238,12 @@
currentTop = $scrollbarY.position().top;
$scrollbarYRail.addClass('in-scrolling');
- var padding = parseInt($scrollbarYRail.offsetParent().css('padding-top'));
+ var margin = parseInt($scrollbarYRail.css('margin-top'));
var rect = $scrollbarYRail[0].getBoundingClientRect();
$scrollbarYRail.css({
position: 'fixed',
left: rect.left,
- top: rect.top - padding
+ top: rect.top - margin
});
e.stopPropagation();
@@ -419,7 +422,7 @@
$scrollbarYRail.bind('click' + eventClassName, function (e) {
var halfOfScrollbarLength = parseInt(scrollbarYHeight / 2, 10),
positionTop = e.pageY - $scrollbarYRail.offset().top - halfOfScrollbarLength,
- maxPositionTop = containerHeight - scrollbarYHeight,
+ maxPositionTop = scrollbarYRailHeight - scrollbarYHeight,
positionRatio = positionTop / maxPositionTop;
if (positionRatio < 0) {

View File

@@ -0,0 +1,586 @@
/*
* (c) Copyright Ascensio System SIA 2010-2015
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
(function (factory) {
if (typeof define === "function" && define.amd) {
define(["jquery"], factory);
} else {
if (typeof exports === "object") {
factory(require("jquery"));
} else {
factory(jQuery);
}
}
} (function ($) {
var defaultSettings = {
wheelSpeed: 10,
wheelPropagation: false,
minScrollbarLength: null,
useBothWheelAxes: false,
useKeyboard: true,
suppressScrollX: false,
suppressScrollY: false,
scrollXMarginOffset: 0,
scrollYMarginOffset: 0,
includePadding: false,
includeMargin: true
};
var getEventClassName = (function () {
var incrementingId = 0;
return function () {
var id = incrementingId;
incrementingId += 1;
return ".perfect-scrollbar-" + id;
};
} ());
$.fn.perfectScrollbar = function (suppliedSettings, option) {
return this.each(function () {
var settings = $.extend(true, {},
defaultSettings),
$this = $(this);
if (typeof suppliedSettings === "object") {
$.extend(true, settings, suppliedSettings);
} else {
option = suppliedSettings;
}
if (option === "update") {
if ($this.data("perfect-scrollbar-update")) {
$this.data("perfect-scrollbar-update")();
}
return $this;
} else {
if (option === "destroy") {
if ($this.data("perfect-scrollbar-destroy")) {
$this.data("perfect-scrollbar-destroy")();
}
return $this;
}
}
if ($this.data("perfect-scrollbar")) {
return $this.data("perfect-scrollbar");
}
$this.addClass("ps-container");
var $scrollbarXRail = $("<div class='ps-scrollbar-x-rail'></div>").appendTo($this),
$scrollbarYRail = $("<div class='ps-scrollbar-y-rail'></div>").appendTo($this),
$scrollbarX = $("<div class='ps-scrollbar-x'></div>").appendTo($scrollbarXRail),
$scrollbarY = $("<div class='ps-scrollbar-y'></div>").appendTo($scrollbarYRail),
scrollbarXActive,
scrollbarYActive,
containerWidth,
containerHeight,
contentWidth,
contentHeight,
scrollbarXWidth,
scrollbarXLeft,
scrollbarXBottom = parseInt($scrollbarXRail.css("bottom"), 10),
scrollbarYHeight,
scrollbarYTop,
scrollbarYRight = parseInt($scrollbarYRail.css("right"), 10),
scrollbarYRailHeight,
eventClassName = getEventClassName();
var updateContentScrollTop = function (currentTop, deltaY) {
var newTop = currentTop + deltaY,
maxTop = scrollbarYRailHeight - scrollbarYHeight;
if (newTop < 0) {
scrollbarYTop = 0;
} else {
if (newTop > maxTop) {
scrollbarYTop = maxTop;
} else {
scrollbarYTop = newTop;
}
}
var scrollTop = parseInt(scrollbarYTop * (contentHeight - containerHeight) / (scrollbarYRailHeight - scrollbarYHeight), 10);
$this.scrollTop(scrollTop);
$scrollbarXRail.css({
bottom: scrollbarXBottom - scrollTop
});
};
var updateContentScrollLeft = function (currentLeft, deltaX) {
var newLeft = currentLeft + deltaX,
maxLeft = containerWidth - scrollbarXWidth;
if (newLeft < 0) {
scrollbarXLeft = 0;
} else {
if (newLeft > maxLeft) {
scrollbarXLeft = maxLeft;
} else {
scrollbarXLeft = newLeft;
}
}
var scrollLeft = parseInt(scrollbarXLeft * (contentWidth - containerWidth) / (containerWidth - scrollbarXWidth), 10);
$this.scrollLeft(scrollLeft);
$scrollbarYRail.css({
right: scrollbarYRight - scrollLeft
});
};
var getSettingsAdjustedThumbSize = function (thumbSize) {
if (settings.minScrollbarLength) {
thumbSize = Math.max(thumbSize, settings.minScrollbarLength);
}
return thumbSize;
};
var updateScrollbarCss = function () {
$scrollbarXRail.css({
left: $this.scrollLeft(),
bottom: scrollbarXBottom - $this.scrollTop(),
width: containerWidth,
display: scrollbarXActive ? "inherit" : "none"
});
if ($scrollbarYRail.hasClass("in-scrolling")) {
$scrollbarYRail.css({
right: scrollbarYRight - $this.scrollLeft(),
height: scrollbarYRailHeight,
display: scrollbarYActive ? "inherit" : "none"
});
} else {
$scrollbarYRail.css({
top: $this.scrollTop(),
right: scrollbarYRight - $this.scrollLeft(),
height: scrollbarYRailHeight,
display: scrollbarYActive ? "inherit" : "none"
});
}
$scrollbarX.css({
left: scrollbarXLeft,
width: scrollbarXWidth
});
$scrollbarY.css({
top: scrollbarYTop,
height: scrollbarYHeight
});
};
var updateBarSizeAndPosition = function () {
containerWidth = settings.includePadding ? $this.innerWidth() : $this.width();
containerHeight = settings.includePadding ? $this.innerHeight() : $this.height();
scrollbarYRailHeight = containerHeight - (settings.includeMargin ? (parseInt($scrollbarYRail.css("margin-top")) + parseInt($scrollbarYRail.css("margin-bottom"))) : 0);
contentWidth = $this.prop("scrollWidth");
contentHeight = $this.prop("scrollHeight");
if (!settings.suppressScrollX && containerWidth + settings.scrollXMarginOffset < contentWidth) {
scrollbarXActive = true;
scrollbarXWidth = getSettingsAdjustedThumbSize(parseInt(containerWidth * containerWidth / contentWidth, 10));
scrollbarXLeft = parseInt($this.scrollLeft() * (containerWidth - scrollbarXWidth) / (contentWidth - containerWidth), 10);
} else {
scrollbarXActive = false;
scrollbarXWidth = 0;
scrollbarXLeft = 0;
$this.scrollLeft(0);
}
if (!settings.suppressScrollY && containerHeight + settings.scrollYMarginOffset < contentHeight) {
scrollbarYActive = true;
scrollbarYHeight = getSettingsAdjustedThumbSize(parseInt(scrollbarYRailHeight * containerHeight / contentHeight, 10));
scrollbarYTop = parseInt($this.scrollTop() * (scrollbarYRailHeight - scrollbarYHeight) / (contentHeight - containerHeight), 10);
} else {
scrollbarYActive = false;
scrollbarYHeight = 0;
scrollbarYTop = 0;
$this.scrollTop(0);
}
if (scrollbarYTop >= scrollbarYRailHeight - scrollbarYHeight) {
scrollbarYTop = scrollbarYRailHeight - scrollbarYHeight;
}
if (scrollbarXLeft >= containerWidth - scrollbarXWidth) {
scrollbarXLeft = containerWidth - scrollbarXWidth;
}
updateScrollbarCss();
};
var bindMouseScrollXHandler = function () {
var currentLeft, currentPageX;
$scrollbarX.bind("mousedown" + eventClassName, function (e) {
currentPageX = e.pageX;
currentLeft = $scrollbarX.position().left;
$scrollbarXRail.addClass("in-scrolling");
e.stopPropagation();
e.preventDefault();
});
$(document).bind("mousemove" + eventClassName, function (e) {
if ($scrollbarXRail.hasClass("in-scrolling")) {
updateContentScrollLeft(currentLeft, e.pageX - currentPageX);
e.stopPropagation();
e.preventDefault();
}
});
$(document).bind("mouseup" + eventClassName, function (e) {
if ($scrollbarXRail.hasClass("in-scrolling")) {
$scrollbarXRail.removeClass("in-scrolling");
}
});
currentLeft = currentPageX = null;
};
var bindMouseScrollYHandler = function () {
var currentTop, currentPageY;
$scrollbarY.bind("mousedown" + eventClassName, function (e) {
currentPageY = e.pageY;
currentTop = $scrollbarY.position().top;
$scrollbarYRail.addClass("in-scrolling");
var margin = parseInt($scrollbarYRail.css("margin-top"));
var rect = $scrollbarYRail[0].getBoundingClientRect();
$scrollbarYRail.css({
position: "fixed",
left: rect.left,
top: rect.top - margin
});
e.stopPropagation();
e.preventDefault();
});
$(document).bind("mousemove" + eventClassName, function (e) {
if ($scrollbarYRail.hasClass("in-scrolling")) {
updateContentScrollTop(currentTop, e.pageY - currentPageY);
e.stopPropagation();
e.preventDefault();
}
});
$(document).bind("mouseup" + eventClassName, function (e) {
if ($scrollbarYRail.hasClass("in-scrolling")) {
$scrollbarYRail.removeClass("in-scrolling");
$scrollbarYRail.css({
position: "",
left: "",
top: ""
});
updateScrollbarCss();
}
});
currentTop = currentPageY = null;
};
var shouldPreventDefault = function (deltaX, deltaY) {
var scrollTop = $this.scrollTop();
if (deltaX === 0) {
if (!scrollbarYActive) {
return false;
}
if ((scrollTop === 0 && deltaY > 0) || (scrollTop >= contentHeight - containerHeight && deltaY < 0)) {
return !settings.wheelPropagation;
}
}
var scrollLeft = $this.scrollLeft();
if (deltaY === 0) {
if (!scrollbarXActive) {
return false;
}
if ((scrollLeft === 0 && deltaX < 0) || (scrollLeft >= contentWidth - containerWidth && deltaX > 0)) {
return !settings.wheelPropagation;
}
}
return true;
};
var bindMouseWheelHandler = function () {
settings.wheelSpeed /= 10;
var shouldPrevent = false;
$this.bind("mousewheel" + eventClassName, function (e, deprecatedDelta, deprecatedDeltaX, deprecatedDeltaY) {
var deltaX = e.deltaX * e.deltaFactor || deprecatedDeltaX,
deltaY = e.deltaY * e.deltaFactor || deprecatedDeltaY;
if (e && e.target && (e.target.type === "textarea" || e.target.type === "input")) {
e.stopImmediatePropagation();
e.preventDefault();
var scroll = $(e.target).scrollTop(),
wheelDeltaY = 0;
if (e.originalEvent) {
if (e.originalEvent.wheelDelta) {
wheelDeltaY = e.originalEvent.wheelDelta / -40;
}
if (e.originalEvent.deltaY) {
wheelDeltaY = e.originalEvent.deltaY;
}
if (e.originalEvent.detail) {
wheelDeltaY = e.originalEvent.detail;
}
}
$(e.target).scrollTop(scroll - wheelDeltaY);
return;
}
shouldPrevent = false;
if (!settings.useBothWheelAxes) {
$this.scrollTop($this.scrollTop() - (deltaY * settings.wheelSpeed));
$this.scrollLeft($this.scrollLeft() + (deltaX * settings.wheelSpeed));
} else {
if (scrollbarYActive && !scrollbarXActive) {
if (deltaY) {
$this.scrollTop($this.scrollTop() - (deltaY * settings.wheelSpeed));
} else {
$this.scrollTop($this.scrollTop() + (deltaX * settings.wheelSpeed));
}
shouldPrevent = true;
} else {
if (scrollbarXActive && !scrollbarYActive) {
if (deltaX) {
$this.scrollLeft($this.scrollLeft() + (deltaX * settings.wheelSpeed));
} else {
$this.scrollLeft($this.scrollLeft() - (deltaY * settings.wheelSpeed));
}
shouldPrevent = true;
}
}
}
updateBarSizeAndPosition();
shouldPrevent = (shouldPrevent || shouldPreventDefault(deltaX, deltaY));
if (shouldPrevent) {
e.stopPropagation();
e.preventDefault();
}
});
$this.bind("MozMousePixelScroll" + eventClassName, function (e) {
if (shouldPrevent) {
e.preventDefault();
}
});
};
var bindKeyboardHandler = function () {
var hovered = false;
$this.bind("mouseenter" + eventClassName, function (e) {
hovered = true;
});
$this.bind("mouseleave" + eventClassName, function (e) {
hovered = false;
});
var shouldPrevent = false;
$(document).bind("keydown" + eventClassName, function (e) {
if (!hovered || $(document.activeElement).is(":input,[contenteditable]")) {
return;
}
var deltaX = 0,
deltaY = 0;
switch (e.which) {
case 37:
deltaX = -30;
break;
case 38:
deltaY = 30;
break;
case 39:
deltaX = 30;
break;
case 40:
deltaY = -30;
break;
case 33:
deltaY = 90;
break;
case 32:
case 34:
deltaY = -90;
break;
case 35:
deltaY = -containerHeight;
break;
case 36:
deltaY = containerHeight;
break;
default:
return;
}
$this.scrollTop($this.scrollTop() - deltaY);
$this.scrollLeft($this.scrollLeft() + deltaX);
shouldPrevent = shouldPreventDefault(deltaX, deltaY);
if (shouldPrevent) {
e.preventDefault();
}
});
};
var bindRailClickHandler = function () {
var stopPropagation = function (e) {
e.stopPropagation();
};
$scrollbarY.bind("click" + eventClassName, stopPropagation);
$scrollbarYRail.bind("click" + eventClassName, function (e) {
var halfOfScrollbarLength = parseInt(scrollbarYHeight / 2, 10),
positionTop = e.pageY - $scrollbarYRail.offset().top - halfOfScrollbarLength,
maxPositionTop = scrollbarYRailHeight - scrollbarYHeight,
positionRatio = positionTop / maxPositionTop;
if (positionRatio < 0) {
positionRatio = 0;
} else {
if (positionRatio > 1) {
positionRatio = 1;
}
}
$this.scrollTop((contentHeight - containerHeight) * positionRatio);
});
$scrollbarX.bind("click" + eventClassName, stopPropagation);
$scrollbarXRail.bind("click" + eventClassName, function (e) {
var halfOfScrollbarLength = parseInt(scrollbarXWidth / 2, 10),
positionLeft = e.pageX - $scrollbarXRail.offset().left - halfOfScrollbarLength,
maxPositionLeft = containerWidth - scrollbarXWidth,
positionRatio = positionLeft / maxPositionLeft;
if (positionRatio < 0) {
positionRatio = 0;
} else {
if (positionRatio > 1) {
positionRatio = 1;
}
}
$this.scrollLeft((contentWidth - containerWidth) * positionRatio);
});
};
var bindMobileTouchHandler = function () {
var applyTouchMove = function (differenceX, differenceY) {
$this.scrollTop($this.scrollTop() - differenceY);
$this.scrollLeft($this.scrollLeft() - differenceX);
updateBarSizeAndPosition();
};
var startCoords = {},
startTime = 0,
speed = {},
breakingProcess = null,
inGlobalTouch = false;
$(window).bind("touchstart" + eventClassName, function (e) {
inGlobalTouch = true;
});
$(window).bind("touchend" + eventClassName, function (e) {
inGlobalTouch = false;
});
$this.bind("touchstart" + eventClassName, function (e) {
var touch = e.originalEvent.targetTouches[0];
startCoords.pageX = touch.pageX;
startCoords.pageY = touch.pageY;
startTime = (new Date()).getTime();
if (breakingProcess !== null) {
clearInterval(breakingProcess);
}
e.stopPropagation();
});
$this.bind("touchmove" + eventClassName, function (e) {
if (!inGlobalTouch && e.originalEvent.targetTouches.length === 1) {
var touch = e.originalEvent.targetTouches[0];
var currentCoords = {};
currentCoords.pageX = touch.pageX;
currentCoords.pageY = touch.pageY;
var differenceX = currentCoords.pageX - startCoords.pageX,
differenceY = currentCoords.pageY - startCoords.pageY;
applyTouchMove(differenceX, differenceY);
startCoords = currentCoords;
var currentTime = (new Date()).getTime();
var timeGap = currentTime - startTime;
if (timeGap > 0) {
speed.x = differenceX / timeGap;
speed.y = differenceY / timeGap;
startTime = currentTime;
}
e.preventDefault();
}
});
$this.bind("touchend" + eventClassName, function (e) {
clearInterval(breakingProcess);
breakingProcess = setInterval(function () {
if (Math.abs(speed.x) < 0.01 && Math.abs(speed.y) < 0.01) {
clearInterval(breakingProcess);
return;
}
applyTouchMove(speed.x * 30, speed.y * 30);
speed.x *= 0.8;
speed.y *= 0.8;
},
10);
});
};
var bindScrollHandler = function () {
$this.bind("scroll" + eventClassName, function (e) {
updateBarSizeAndPosition();
});
};
var destroy = function () {
$this.unbind(eventClassName);
$(window).unbind(eventClassName);
$(document).unbind(eventClassName);
$this.data("perfect-scrollbar", null);
$this.data("perfect-scrollbar-update", null);
$this.data("perfect-scrollbar-destroy", null);
$scrollbarX.remove();
$scrollbarY.remove();
$scrollbarXRail.remove();
$scrollbarYRail.remove();
$scrollbarX = $scrollbarY = containerWidth = containerHeight = contentWidth = contentHeight = scrollbarXWidth = scrollbarXLeft = scrollbarXBottom = scrollbarYHeight = scrollbarYTop = scrollbarYRight = null;
};
var ieSupport = function (version) {
$this.addClass("ie").addClass("ie" + version);
var bindHoverHandlers = function () {
var mouseenter = function () {
$(this).addClass("hover");
};
var mouseleave = function () {
$(this).removeClass("hover");
};
$this.bind("mouseenter" + eventClassName, mouseenter).bind("mouseleave" + eventClassName, mouseleave);
$scrollbarXRail.bind("mouseenter" + eventClassName, mouseenter).bind("mouseleave" + eventClassName, mouseleave);
$scrollbarYRail.bind("mouseenter" + eventClassName, mouseenter).bind("mouseleave" + eventClassName, mouseleave);
$scrollbarX.bind("mouseenter" + eventClassName, mouseenter).bind("mouseleave" + eventClassName, mouseleave);
$scrollbarY.bind("mouseenter" + eventClassName, mouseenter).bind("mouseleave" + eventClassName, mouseleave);
};
var fixIe6ScrollbarPosition = function () {
updateScrollbarCss = function () {
$scrollbarX.css({
left: scrollbarXLeft + $this.scrollLeft(),
bottom: scrollbarXBottom,
width: scrollbarXWidth
});
$scrollbarY.css({
top: scrollbarYTop + $this.scrollTop(),
right: scrollbarYRight,
height: scrollbarYHeight
});
$scrollbarX.hide().show();
$scrollbarY.hide().show();
};
};
if (version === 6) {
bindHoverHandlers();
fixIe6ScrollbarPosition();
}
};
var supportsTouch = (("ontouchstart" in window) || window.DocumentTouch && document instanceof window.DocumentTouch);
var initialize = function () {
var ieMatch = navigator.userAgent.toLowerCase().match(/(msie) ([\w.]+)/);
if (ieMatch && ieMatch[1] === "msie") {
ieSupport(parseInt(ieMatch[2], 10));
}
updateBarSizeAndPosition();
bindScrollHandler();
bindMouseScrollXHandler();
bindMouseScrollYHandler();
bindRailClickHandler();
if (supportsTouch) {
bindMobileTouchHandler();
}
if ($this.mousewheel) {
bindMouseWheelHandler();
}
if (settings.useKeyboard) {
bindKeyboardHandler();
}
$this.data("perfect-scrollbar", $this);
$this.data("perfect-scrollbar-update", updateBarSizeAndPosition);
$this.data("perfect-scrollbar-destroy", destroy);
};
initialize();
return $this;
});
};
}));

View File

@@ -1,133 +0,0 @@
/*
* (c) Copyright Ascensio System SIA 2010-2014
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
Ext.define("Common.plugin.ComboBoxScrollPane", {
extend: "Common.plugin.ScrollPane",
alias: "plugin.comboboxscrollpane",
areaSelector: ".list-ct",
init: function (comboBox) {
comboBox.on("expand", this.onExpand, this);
},
onExpand: function (comboBox) {
var me = this;
if (!me.picker) {
me.picker = comboBox.getPicker();
me.picker.on({
viewready: me.onViewReady,
resize: function () {
me.updateScrollPane();
},
beforecontainerclick: function () {
return false;
},
beforeitemmouseenter: function (picker, record, item, index, event, opts) {
if (comboBox.scrolllocked) {
return false;
}
},
scope: me
});
me.cmp.on("afterlayout", me.onViewReady, me, {
single: true
});
comboBox.on("keydown", me.onKeyDown, me);
var store = comboBox.getStore();
store.on("datachanged", me.onDataChanged, me, {
buffer: 10
});
}
},
onKeyDown: function (cmp, e, eOpts) {
var me = this;
var highlightAt = function (index) {
var boundList = me.picker,
item = boundList.all.item(index);
if (item) {
var container = Ext.getDom(boundList.getTargetEl()) || Ext.getBody().dom;
var el = item.dom,
offsets = item.getOffsetsTo(container),
top = offsets[1] + container.scrollTop,
bottom = top + el.offsetHeight,
ctClientHeight = container.clientHeight,
ctScrollTop = parseInt(container.scrollTop, 10),
ctBottom = ctScrollTop + ctClientHeight;
if (el.offsetHeight > ctClientHeight || top < ctScrollTop) {
if (me.jspApi) {
me.jspApi.scrollByY(top, false);
}
} else {
if (bottom > ctBottom) {
if (me.jspApi) {
me.jspApi.scrollByY(bottom - ctClientHeight, false);
}
}
}
}
};
switch (e.getKey()) {
case e.UP:
var boundList = me.picker,
allItems = boundList.all,
oldItem = boundList.highlightedItem,
oldItemIdx = oldItem ? boundList.indexOf(oldItem) : -1,
newItemIdx = oldItemIdx > 0 ? oldItemIdx - 1 : allItems.getCount() - 1;
highlightAt(newItemIdx);
break;
case e.DOWN:
var boundList = me.picker,
allItems = boundList.all,
oldItem = boundList.highlightedItem,
oldItemIdx = oldItem ? boundList.indexOf(oldItem) : -1,
newItemIdx = oldItemIdx < allItems.getCount() - 1 ? oldItemIdx + 1 : 0;
highlightAt(newItemIdx);
break;
case e.PAGE_UP:
case e.PAGE_DOWN:
break;
case e.HOME:
highlightAt(0);
break;
case e.END:
highlightAt(me.picker.all.getCount() - 1);
break;
}
},
onViewReady: function () {
var me = this;
me.initScrollPane(me.picker.getEl().dom);
},
onDataChanged: function () {
var me = this;
if (me.picker.getWidth() && me.picker.getHeight()) {
me.initScrollPane(me.picker.getEl().dom);
}
}
});

View File

@@ -1,104 +0,0 @@
/*
* (c) Copyright Ascensio System SIA 2010-2014
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
Ext.define("Common.plugin.DataViewScrollPane", {
extend: "Common.plugin.ScrollPane",
alias: "plugin.dataviewscrollpane",
areaSelector: ".x-component",
init: function (cmp) {
var me = this,
store;
me.callParent(arguments);
store = me.cmp.getStore();
if (store) {
store.on("datachanged", function () {
me.cmp && me.cmp.rendered && me.cmp.getWidth() > 0 && me.cmp.getHeight() > 0 && me.updateScrollPane();
},
me, {
buffer: 10
});
}
me.cmp.on("viewready", me.onViewReady, me, {
single: true
});
},
onKeyDown: function (e, eOpts) {
var me = this;
var store = me.cmp.getStore();
var highlightAt = function (index) {
var item = me.cmp.getNode(store.getAt(index)),
itemEl = Ext.create("Ext.Element", item);
if (item) {
var container = Ext.getDom(me.cmp.getTargetEl()) || Ext.getBody().dom;
var offsets = itemEl.getOffsetsTo(container),
top = offsets[1] + container.scrollTop,
bottom = top + item.offsetHeight,
ctClientHeight = container.clientHeight,
ctScrollTop = parseInt(container.scrollTop, 10),
ctBottom = ctScrollTop + ctClientHeight;
if (item.offsetHeight > ctClientHeight || top < ctScrollTop) {
if (me.jspApi) {
me.jspApi.scrollByY(top, false);
}
} else {
if (bottom > ctBottom) {
if (me.jspApi) {
me.jspApi.scrollByY(bottom - ctClientHeight, false);
}
}
}
}
};
switch (e.getKey()) {
case e.UP:
case e.DOWN:
var currItem = me.cmp.getSelectionModel().getLastSelected(),
currItemIdx = currItem ? store.indexOf(currItem) : -1;
highlightAt(currItemIdx);
break;
case e.PAGE_UP:
case e.PAGE_DOWN:
break;
case e.HOME:
me.cmp.select(0);
highlightAt(0);
break;
case e.END:
me.cmp.select(store.count() - 1);
highlightAt(store.count() - 1);
break;
}
},
onViewReady: function () {
var me = this;
me.cmp.getEl().on("keydown", me.onKeyDown, me);
}
});

View File

@@ -1,105 +0,0 @@
/*
* (c) Copyright Ascensio System SIA 2010-2014
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
Ext.define("Common.plugin.GridScrollPane", {
extend: "Common.plugin.ScrollPane",
alias: "plugin.gridscrollpane",
areaSelector: ".x-grid-view",
settings: {
enableKeyboardNavigation: true,
keyboardSpeed: 0.001
},
init: function (cmp) {
var me = this,
store;
me.callParent(arguments);
store = me.cmp.getStore();
if (store) {
store.on("datachanged", me.updateScrollPane, me, {
buffer: 10
});
}
me.cmp.on("viewready", me.onViewReady, me, {
single: true
});
},
onKeyDown: function (e, eOpts) {
var me = this;
var store = me.cmp.getStore();
var highlightAt = function (index) {
var item = me.cmp.getView().getNode(store.getAt(index)),
itemEl = Ext.create("Ext.Element", item);
if (item) {
var container = Ext.getDom(me.cmp.getTargetEl()) || Ext.getBody().dom;
var offsets = itemEl.getOffsetsTo(container),
top = offsets[1] + container.scrollTop,
bottom = top + item.offsetHeight,
ctClientHeight = container.clientHeight,
ctScrollTop = parseInt(container.scrollTop, 10),
ctBottom = ctScrollTop + ctClientHeight;
if (item.offsetHeight > ctClientHeight || top < ctScrollTop) {
if (me.jspApi) {
me.jspApi.scrollByY(top, false);
}
} else {
if (bottom > ctBottom) {
if (me.jspApi) {
me.jspApi.scrollByY(bottom - ctClientHeight, false);
}
}
}
}
};
switch (e.getKey()) {
case e.UP:
case e.DOWN:
var currItem = me.cmp.getSelectionModel().getLastSelected(),
currItemIdx = currItem ? store.indexOf(currItem) : -1;
highlightAt(currItemIdx);
break;
case e.PAGE_UP:
case e.PAGE_DOWN:
break;
case e.HOME:
highlightAt(0);
break;
case e.END:
highlightAt(store.count() - 1);
break;
}
},
onViewReady: function () {
var me = this;
me.cmp.getView().getEl().on("keydown", me.onKeyDown, me, {
stopEvent: true
});
}
});

View File

@@ -1,113 +0,0 @@
/*
* (c) Copyright Ascensio System SIA 2010-2014
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
Ext.define("Common.plugin.MenuExpand", {
extend: "Ext.AbstractPlugin",
alias: "plugin.menuexpand",
init: function (cmp) {
var me = this,
originLeave = cmp.onMouseLeave;
cmp.onMouseLeave = function (e) {
originLeave.apply(cmp, arguments);
if (cmp.parentItem) {
cmp.parentItem.menuEntered = false;
}
};
cmp.onMouseOver = me.onMouseOver;
cmp.checkItemMenuEntered = me.checkItemMenuEntered;
me.callParent(arguments);
},
checkItemMenuEntered: function () {
var me = this;
if (me.activeItem && me.activeItem.menuEntered && me.MouseOverInterval) {
clearInterval(me.MouseOverInterval);
me.MouseOverInterval = undefined;
me.activeItem.menuEntered = false;
if (me.checkeditem) {
me.checkeditem.el.removeCls(me.checkeditem.activeCls);
}
me.activeItem.el.addCls(me.activeItem.activeCls);
}
},
onMouseOver: function (e) {
var me = this,
fromEl = e.getRelatedTarget(),
mouseEnter = !me.el.contains(fromEl),
item = me.getItemFromEvent(e);
if (mouseEnter && me.parentMenu) {
me.parentMenu.setActiveItem(me.parentItem);
me.parentMenu.mouseMonitor.mouseenter();
}
if (me.disabled) {
return;
}
if (me.checkeditem && item != me.checkeditem) {
me.checkeditem.el.removeCls(me.checkeditem.activeCls);
}
if (me.checkeditem = item) {
me.checkeditem.el.addCls(me.checkeditem.activeCls);
}
if (me.activeItem && me.activeItem.menu) {
if (item && (item != me.activeItem && item != me.focusedItem) && me.MouseOverInterval === undefined) {
var counter = 0;
me.activeItem.menuEntered = false;
me.MouseOverInterval = setInterval(function () {
me.checkItemMenuEntered();
if (counter++>8) {
clearInterval(me.MouseOverInterval);
me.MouseOverInterval = undefined;
if (me.checkeditem) {
me.setActiveItem(me.checkeditem);
if (me.checkeditem.activated && me.checkeditem.expandMenu) {
me.checkeditem.expandMenu();
}
}
}
},
20);
}
} else {
if (item) {
me.setActiveItem(item);
if (item.activated && item.expandMenu) {
item.expandMenu();
}
}
}
if (mouseEnter) {
if (me.parentItem) {
me.parentItem.menuEntered = true;
}
me.fireEvent("mouseenter", me, e);
}
me.fireEvent("mouseover", me, item, e);
}
});

View File

@@ -1,158 +0,0 @@
/*
* (c) Copyright Ascensio System SIA 2010-2014
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
Ext.define("Common.plugin.ScrollPane", {
extend: "Ext.AbstractPlugin",
alias: "plugin.scrollpane",
areaSelector: ".x-panel-body",
settings: {},
init: function (cmp) {
var me = this,
origin;
me.settings = $.extend({
enableKeyboardNavigation: true,
verticalDragMinHeight: 16,
horizontalDragMinWidth: 16
},
me.settings);
origin = cmp.afterComponentLayout;
cmp.afterComponentLayout = function (width, height) {
origin.apply(cmp, arguments);
if (width > 0 && height > 0) {
me.initScrollPane();
}
};
me.callParent(arguments);
},
initScrollPane: function (domEl) {
var me = this,
children, jspCt, elem;
if (me.initializing) {
return;
}
me.initializing = true;
if (!me.area || !me.area.length) {
elem = domEl || me.cmp.getEl().dom;
me.area = $(elem).find("*").andSelf().filter(me.areaSelector).first();
}
children = me.area.children();
jspCt = children.filter("div.jspContainer");
if (children.length > 1 && jspCt.length > 0) {
jspCt.replaceWith($(".jspPane", jspCt).children());
jspCt = $();
}
if (me.jspApi && jspCt.length === 0) {
me.area.removeData("jsp");
}
me.area.jScrollPane(me.settings);
me.jspApi = me.area.data("jsp");
me.doLayout();
delete me.initializing;
elem = domEl || me.cmp.getEl().dom;
this._initSelectingScroll(elem);
if (jspCt.length) {
var thumb = jspCt.find(">.jspVerticalBar").find(">.jspTrack").find(">.jspDrag");
thumb.on("mousedown.asc", function (event) {
if (thumb[0].setCapture) {
thumb[0].setCapture();
}
me.cmp.scrolllocked = true;
$("html").bind("mouseup.asc", function (e) {
if (thumb[0].releaseCapture) {
thumb[0].releaseCapture();
}
me.cmp.scrolllocked = false;
$("html").unbind("mouseup.asc");
});
return false;
});
}
},
_initSelectingScroll: function (elem) {
var me = this;
$(elem).off("mousedown.jsp");
$(elem).on("mousedown.jsp", function (event) {
$(document).on("mousemove.jsp", _onTextSelectionScrollMouseMove);
$(document).on("mouseup.jsp", function (event) {
$(document).off("mousemove.jsp").off("mouseup.jsp");
_clearTextSelectionInterval();
});
});
var getPos = function (event, c) {
var p = c == "X" ? "Left" : "Top";
return event["page" + c] || (event["client" + c] + (document.documentElement["scroll" + p] || document.body["scroll" + p])) || 0;
};
var textSelectionInterval;
var _onTextSelectionScrollMouseMove = function (event) {
var offset = $(elem).offset().top;
var maxOffset = offset + $(elem).innerHeight();
var mouseOffset = getPos(event, "Y");
var textDragDistanceAway = mouseOffset < offset ? mouseOffset - offset : (mouseOffset > maxOffset ? mouseOffset - maxOffset : 0);
if (textDragDistanceAway == 0) {
_clearTextSelectionInterval();
} else {
if (!textSelectionInterval) {
textSelectionInterval = setInterval(function () {
me.jspApi.scrollByY(textDragDistanceAway);
},
10);
}
}
};
var _clearTextSelectionInterval = function () {
if (textSelectionInterval) {
clearInterval(textSelectionInterval);
textSelectionInterval = undefined;
}
};
},
updateScrollPane: function (domEl) {
this.initScrollPane(domEl);
if (this.area) {
this.area.attr("tabindex", "-1");
}
},
scrollToElement: function (elem, stickToTop, animate) {
var me = this;
if (me.jspApi) {
me.jspApi.scrollToElement(elem, stickToTop, animate);
}
},
doLayout: function () {
var me = this,
items = me.cmp.items;
if (items && typeof items.each === "function") {
items.each(function (item) {
item.doComponentLayout();
});
}
}
});

View File

@@ -1,121 +0,0 @@
/*
* (c) Copyright Ascensio System SIA 2010-2014
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
Ext.define("Common.plugin.TextAreaAutoHeight", {
extend: "Ext.AbstractPlugin",
alias: "plugin.textareaautoheight",
settings: {
minHeight: 32,
maxHeight: 120,
growStep: 17
},
init: function (cmp) {
this.callParent(arguments);
cmp.addEvents("elastic");
cmp.on("afterrender", this.onAfterRender, this);
cmp.on("change", this.onChange, this);
},
onAfterRender: function (cmp) {
var textareaEl = cmp.getEl().down("textarea");
if (textareaEl) {
this.initHelper(textareaEl.id);
this.elasticTextArea(textareaEl.id);
}
},
onChange: function (cmp) {
if (!this.textareaElId) {
this.textareaElId = cmp.getEl().down("textarea").id;
}
this.elasticTextArea(this.textareaElId);
},
initHelper: function (elementId) {
var getStyles = function (el, args) {
var ret = {},
total = args.length;
for (var n = 0; n < total; n++) {
ret[args[n]] = el.getStyle(args[n]);
}
return ret;
};
var applyStyles = function (el, styles) {
if (styles) {
var i = 0,
len;
el = Ext.fly(el);
if (Ext.isFunction(styles)) {
styles = styles.call();
}
if (typeof styles == "string") {
styles = styles.split(/:|;/g);
for (len = styles.length; i < len;) {
el.setStyle(styles[i++], styles[i++]);
}
} else {
if (Ext.isObject(styles)) {
el.setStyle(styles);
}
}
}
};
this.domEl = Ext.get(elementId);
this.textareaElId = elementId;
var styles = getStyles(this.domEl, ["font-size", "font-family", "font-weight", "font-style", "line-height", "letter-spacing", "padding-left", "padding-top", "padding-right", "padding-bottom"]);
this.domEl.setStyle("overflow", "hidden");
if (!this.helperEl) {
this.helperEl = Ext.DomHelper.append(this.domEl.parent(), {
id: elementId + "-textarea-elastic-helper",
tag: "div",
style: "position: absolute; top: 0; left: 0; visibility: hidden; white-space: pre-wrap; word-wrap: break-word;"
},
true);
applyStyles(this.helperEl, styles);
}
},
elasticTextArea: function (elementId) {
var me = this,
value = this.domEl.dom.value || "&nbsp;";
this.helperEl.setWidth(this.domEl.getWidth());
this.helperEl.update(value.replace(/<br \/>&nbsp;/, "<br />").replace(/<|>/g, " ").replace(/&/g, "&amp;").replace(/\n/g, "<br />"));
var textHeight = this.helperEl.getHeight();
if ((textHeight > me.settings.maxHeight) && (me.settings.maxHeight > 0)) {
textHeight = me.settings.maxHeight;
this.domEl.setStyle("overflow", "auto");
}
if ((textHeight < me.settings.minHeight) && (me.settings.minHeight > 0)) {
textHeight = me.settings.minHeight;
}
var newHeight = textHeight + me.settings.growStep;
if (me.cmp.getHeight() != newHeight) {
me.cmp.setHeight(newHeight);
me.cmp.fireEvent("elastic", me.cmp, this.domEl.getWidth(), newHeight);
}
}
});

View File

@@ -1,39 +0,0 @@
/*
* (c) Copyright Ascensio System SIA 2010-2014
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
Ext.define("Common.store.Comments", {
extend: "Ext.data.Store",
model: "Common.model.Comment",
sorters: [{
property: "date",
direction: "DESC"
}]
});

View File

@@ -1,47 +0,0 @@
/*
* (c) Copyright Ascensio System SIA 2010-2014
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
Ext.define("Common.store.Users", {
extend: "Ext.data.Store",
model: "Common.model.User",
getOnlineUserCount: function () {
var i = this.getCount(),
item,
count = 0;
while (i > 0) {
item = this.getAt(--i);
if (item.data.online) {
count++;
}
}
return count;
}
});

View File

@@ -0,0 +1,14 @@
<div id="chat-box">
<div id="chat-users">
<div id="chat-user-ct"></div>
</div>
<div id="chat-messages">
<div id="chat-message-ct"></div>
</div>
<div id="chat-options">
<div id="chat-options-ct">
<textarea id="chat-msg-text"></textarea>
<button id="chat-msg-btn-add" class="btn normal dlg-btn primary"><%=scope.textSend%></button>
</div>
</div>
</div>

View File

@@ -0,0 +1,89 @@
<% if (!hide) { %>
<div id="<%= id %>" class="user-comment-item">
<!-- comment block -->
<div class="user-name"><%=scope.getUserName(username)%></div>
<div class="user-date"><%=date%></div>
<div class="user-quote"><%=scope.getFixedQuote(quote)%></div>
<% if (!editText) { %>
<div class="user-message text-select" data-can-copy="true"><%=scope.pickLink(comment)%></div>
<% } else { %>
<div class="inner-edit-ct">
<textarea class="msg-reply"><%=comment%></textarea>
<button class="btn normal dlg-btn primary btn-inner-edit" id="id-comments-change">textEdit</button>
<button class="btn normal dlg-btn btn-inner-close">textCancel</button>
</div>
<% } %>
<!-- replys elements -->
<% if (replys.length) { %>
<div class="reply-arrow "></div>
<% _.each(replys, function (item) { %>
<div class="reply-item-ct">
<div class="user-name"><%=scope.getFixedQuote(item.get("username"))%></div>
<div class="user-date"><%=item.get("date")%></div>
<% if (!item.get("editText")) { %>
<div class="user-message text-select" data-can-copy="true"><%=scope.pickLink(item.get("reply"))%></div>
<div class="btns-reply-ct">
<div class="btn-edit" data-value="<%=item.get("id")%>"></div>
<div class="btn-delete" data-value="<%=item.get("id")%>"></div>
</div>
<% } else { %>
<div class="inner-edit-ct">
<textarea class="msg-reply textarea-fix"><%=item.get("reply")%></textarea>
<button class="btn normal dlg-btn primary btn-inner-edit btn-fix" id="id-comments-change">textEdit</button>
<button class="btn normal dlg-btn btn-inner-close">textClose</button>
</div>
<% } %>
</div>
<% }); %>
<% } %>
<!-- add reply button -->
<% if (!showReply) { %>
<% if (replys.length) { %>
<label class="user-reply" style="margin-left: 20px; margin-top: 5px;" role="presentation" tabindex="-1">textAddReply</label>
<% } else { %>
<label class="user-reply" role="presentation" tabindex="-1">textAddReply</label>
<% } %>
<% } %>
<!-- edit buttons -->
<% if (!editText && !lock) { %>
<div class="edit-ct">
<div class="btn-edit"></div>
<div class="btn-delete"></div>
<% if (resolved) { %>
<div class="resolve-ct-check" style="float:left;">
<div class="resolved"></div>
<div class="btn-resolve-check">textResolved</div>
<% } else { %>
<div class="resolve-ct" style="float:left;">
<div class="btn-resolve">textResolve</div>
<% } %>
</div>
</div>
<% } %>
<!-- reply -->
<% if (showReply) { %>
<div class="reply-ct">
<textarea class="msg-reply" placeholder="textAddReply"></textarea>
<button class="btn normal dlg-btn primary btn-reply" id="id-comments-change">textReply</button>
<button class="btn normal dlg-btn btn-close">textClose</button>
</div>
<% } %>
<% if (lock) { %>
<div class="lock-area"></div>
<div class="lock-author"><%=lockuserid%></div>
<% } %>
<% if (!last) { %>
<div class="separator-cmt"></div>
<% } %>
</div>
<% } %>

View File

@@ -0,0 +1,13 @@
<div id="comments-box">
<div id="comments-messages"/>
<div id="comments-add-link-ct">
<label id="comment-btn-new" class="btn"><%=textAddCommentToDoc%></label>
</div>
<div id="comments-new-comment-ct" style="display: none;">
<div id="comments-inner-ct">
<textarea id="comment-msg-new" placeholder="<%=textEnterCommentHint%>"/>
<button id="comment-btn-add" class="btn normal dlg-btn primary"><%=textAddComment%></button>
<button id="comment-btn-cancel" class="btn normal dlg-btn"><%=textCancel%></button>
</div>
</div>
</div>

View File

@@ -0,0 +1,94 @@
<div id="<%=id%>" class="user-comment-item">
<!-- comment block -->
<div class="user-name"><%=scope.getUserName(username)%></div>
<div class="user-date"><%=date%></div>
<% if (!editTextInPopover || hint) { %>
<div class="user-message"><%=scope.pickLink(comment)%></div>
<% } else { %>
<div class="inner-edit-ct">
<textarea class="msg-reply"><%=comment%></textarea>
<% if (hideAddReply) { %>
<button class="btn normal dlg-btn primary btn-inner-edit" id="id-comments-change-popover">textAdd</button>
<% } else { %>
<button class="btn normal dlg-btn primary btn-inner-edit" id="id-comments-change-popover">textEdit</button>
<% } %>
<button class="btn normal dlg-btn btn-inner-close">textCancel</button>
</div>
<% } %>
<!-- replys elements -->
<% if (replys.length) { %>
<div class="reply-arrow "></div>
<% _.each(replys, function (item) { %>
<div class="reply-item-ct">
<div class="user-name"><%=scope.getFixedQuote(item.get("username"))%></div>
<div class="user-date"><%=item.get("date")%></div>
<% if (!item.get("editTextInPopover")) { %>
<div class="user-message"><%=scope.pickLink(item.get("reply"))%></div>
<% if (!hint) { %>
<div class="btns-reply-ct">
<div class="btn-edit" data-value="<%=item.get("id")%>"></div>
<div class="btn-delete" data-value="<%=item.get("id")%>"></div>
</div>
<%}%>
<% } else { %>
<div class="inner-edit-ct">
<textarea class="msg-reply textarea-fix"><%=item.get("reply")%></textarea>
<button class="btn normal dlg-btn primary btn-inner-edit btn-fix" id="id-comments-change-popover">textEdit</button>
<button class="btn normal dlg-btn btn-inner-close">textClose</button>
</div>
<% } %>
</div>
<% }); %>
<% } %>
<!-- add reply button -->
<% if (!showReplyInPopover && !hideAddReply && !hint) { %>
<% if (replys.length) { %>
<label class="user-reply" style="margin-left: 20px; margin-top: 5px;" role="presentation" tabindex="-1">textAddReply</label>
<% } else { %>
<label class="user-reply" role="presentation" tabindex="-1">textAddReply</label>
<% } %>
<% } %>
<!-- edit buttons -->
<% if (!editTextInPopover && !lock && !hint) { %>
<div class="edit-ct">
<div class="btn-edit"></div>
<div class="btn-delete"></div>
<% if (resolved) { %>
<div class="resolve-ct-check" style="float:left;">
<div class="resolved"></div>
<div class="btn-resolve-check">textResolved</div>
<% } else { %>
<div class="resolve-ct" style="float:left;">
<div class="btn-resolve">textResolve</div>
<% } %>
</div>
</div>
<% } %>
<!-- reply -->
<% if (showReplyInPopover) { %>
<div class="reply-ct">
<textarea class="msg-reply" placeholder="textAddReply"></textarea>
<button class="btn normal dlg-btn primary btn-reply" id="id-comments-change-popover">textReply</button>
<button class="btn normal dlg-btn btn-close">textClose</button>
</div>
<% } %>
<!-- locked user -->
<% if (lock) { %>
<div class="lock-area" style="cursor: default;"></div>
<div class="lock-author" style="cursor: default;"><%=lockuserid%></div>
<% } %>
</div>

View File

@@ -0,0 +1,32 @@
<div class="color-box">
<div id="id-hsb-colorpicker" style="vertical-align:top;">
</div>
<div class="color-info" style="">
<div style="margin-left:15px;">
<label class="color-label"><%= txtNew %></label>
<div id="field-new-color" class="color-cnt top"></div>
<div id="field-start-color" class="color-cnt bottom"></div>
<label class="color-label"><%= txtCurrent %></label>
</div>
<div style="padding:13px 0 2px 0;">
<label class="input-label">R:</label>
<div id="extended-spin-r" class="color-spin"></div>
</div>
<div style="padding:2px 0;">
<label class="input-label">G:</label>
<div id="extended-spin-g" class="color-spin"></div>
</div>
<div style="padding:2px 0;">
<label class="input-label">B:</label>
<div id="extended-spin-b" class="color-spin"></div>
</div>
<div style="padding:11px 0 0 0;">
<label class="input-label" style="width:12px;">#:</label>
<input id="extended-text-color" type="text" role="textbox" style="width:62px; height: 22px;">
</div>
</div>
</div>
<div class="footer center">
<button class="btn normal dlg-btn primary" result="1"><%= txtAdd %></button>
<button class="btn normal dlg-btn" result="0"><%= txtCancel %></button>
</div>

View File

@@ -0,0 +1,6 @@
<div id="header-container">
<div id="header-logo"></div>
<div id="header-caption"><div><%= headerCaption %></div></div>
<div id="header-documentcaption"><%= documentCaption %></div>
<div id="header-back" style="display: <%= canBack ? 'table-cell' : 'none' %>;"><div><%= textBack %></div></div>
</div>

View File

@@ -0,0 +1,435 @@
/*
* (c) Copyright Ascensio System SIA 2010-2015
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
if (Common === undefined) {
var Common = {};
}
Common.util = Common.util || {};
Common.util.LanguageInfo = new(function () {
var localLanguageName = {
54: ["af", "Afrikaans"],
1078: ["af-ZA", "Afrikaans (Suid Afrika)"],
28: ["sq", "Shqipe"],
1052: ["sq-AL", "Shqipe (Shqipëria)"],
132: ["gsw", "Elsässisch"],
1156: ["gsw-FR", "Elsässisch (Frànkrisch)"],
94: ["am", "አማርኛ"],
1118: ["am-ET", "አማርኛ (ኢትዮጵያ)"],
1: ["ar", "العربية"],
5121: ["ar-DZ", "العربية (الجزائر)"],
15361: ["ar-BH", "العربية (البحرين)"],
3073: ["ar-EG", "العربية (مصر)"],
2049: ["ar-IQ", "العربية (العراق)"],
11265: ["ar-JO", "العربية (الأردن)"],
13313: ["ar-KW", "العربية (الكويت)"],
12289: ["ar-LB", "العربية (لبنان)"],
4097: ["ar-LY", "العربية (ليبيا)"],
6145: ["ar-MA", "العربية (المملكة المغربية)"],
8193: ["ar-OM", "العربية (عمان)"],
16385: ["ar-QA", "العربية (قطر)"],
1025: ["ar-SA", "العربية (المملكة العربية السعودية)"],
10241: ["ar-SY", "العربية (سوريا)"],
7169: ["ar-TN", "العربية (تونس)"],
14337: ["ar-AE", "العربية (الإمارات العربية المتحدة)"],
9217: ["ar-YE", "العربية (اليمن)"],
43: ["hy", "Հայերեն"],
1067: ["hy-AM", "Հայերեն (Հայաստան)"],
77: ["as", "অসমীয়া"],
1101: ["as-IN", "অসমীয়া (ভাৰত)"],
44: ["az", "Azərbaycan­ılı"],
29740: ["az-Cyrl", "Азәрбајҹан дили"],
2092: ["az-Cyrl-AZ", "Азәрбајҹан (Азәрбајҹан)"],
30764: ["az-Latn", "Azərbaycan­ılı"],
1068: ["az-Latn-AZ", "Azərbaycan­ılı (Azərbaycan)"],
109: ["ba", "Башҡорт"],
1133: ["ba-RU", "Башҡорт (Россия)"],
45: ["eu", "Euskara"],
1069: ["eu-ES", "Euskara (Euskara)"],
35: ["be", "Беларускі"],
1059: ["be-BY", "Беларускі (Беларусь)"],
69: ["bn", "বাংলা"],
2117: ["bn-BD", "বাংলা (বাংলাদেশ)"],
1093: ["bn-IN", "বাংলা (ভারত)"],
30746: ["bs", "bosanski"],
25626: ["bs-Cyrl", "Босански (Ћирилица)"],
8218: ["bs-Cyrl-BA", "Босански (Босна и Херцеговина)"],
26650: ["bs-Latn", "Bosanski (Latinica)"],
5146: ["bs-Latn-BA", "Bosanski (Bosna i Hercegovina)"],
126: ["br", "Brezhoneg"],
1150: ["br-FR", "Brezhoneg (Frañs)"],
2: ["bg", "Български"],
1026: ["bg-BG", "Български (България)"],
3: ["ca", "Català"],
1027: ["ca-ES", "Català (Català)"],
30724: ["zh", "中文"],
4: ["zh-Hans", "中文(简体)"],
2052: ["zh-CN", "中文(中华人民共和国)"],
4100: ["zh-SG", "中文(新加坡)"],
31748: ["zh-Hant", "中文(繁體)"],
3076: ["zh-HK", "中文(香港特別行政區)"],
5124: ["zh-MO", "中文(澳門特別行政區)"],
1028: ["zh-TW", "中文(台灣)"],
131: ["co", "Corsu"],
1155: ["co-FR", "Corsu (France)"],
26: ["hr", "Hrvatski"],
1050: ["hr-HR", "Hrvatski (Hrvatska)"],
4122: ["hr-BA", "Hrvatski (Bosna i Hercegovina)"],
5: ["cs", "Čeština"],
1029: ["cs-CZ", "Čeština (Česká republika)"],
6: ["da", "Dansk"],
1030: ["da-DK", "Dansk (Danmark)"],
140: ["prs", "درى"],
1164: ["prs-AF", "درى (افغانستان)"],
101: ["dv", "ދިވެހިބަސް"],
1125: ["dv-MV", "ދިވެހިބަސް (ދިވެހި ރާއްޖެ)"],
19: ["nl", "Nederlands"],
2067: ["nl-BE", "Nederlands (België)"],
1043: ["nl-NL", "Nederlands (Nederland)"],
9: ["en", "English"],
3081: ["en-AU", "English (Australia)"],
10249: ["en-BZ", "English (Belize)"],
4105: ["en-CA", "English (Canada)"],
9225: ["en-029", "English (Caribbean)"],
16393: ["en-IN", "English (India)"],
6153: ["en-IE", "English (Ireland)"],
8201: ["en-JM", "English (Jamaica)"],
17417: ["en-MY", "English (Malaysia)"],
5129: ["en-NZ", "English (New Zealand)"],
13321: ["en-PH", "English (Philippines)"],
18441: ["en-SG", "English (Singapore)"],
7177: ["en-ZA", "English (South Africa)"],
11273: ["en-TT", "English (Trinidad y Tobago)"],
2057: ["en-GB", "English (United Kingdom)"],
1033: ["en-US", "English (United States)"],
12297: ["en-ZW", "English (Zimbabwe)"],
37: ["et", "Eesti"],
1061: ["et-EE", "Eesti (Eesti)"],
56: ["fo", "Føroyskt"],
1080: ["fo-FO", "Føroyskt (Føroyar)"],
100: ["fil", "Filipino"],
1124: ["fil-PH", "Filipino (Pilipinas)"],
11: ["fi", "Suomi"],
1035: ["fi-FI", "Suomi (Suomi)"],
12: ["fr", "Français"],
2060: ["fr-BE", "Français (Belgique)"],
3084: ["fr-CA", "Français (Canada)"],
1036: ["fr-FR", "Français (France)"],
5132: ["fr-LU", "Français (Luxembourg)"],
6156: ["fr-MC", "Français (Principauté de Monaco)"],
4108: ["fr-CH", "Français (Suisse)"],
98: ["fy", "Frysk"],
1122: ["fy-NL", "Frysk (Nederlân)"],
86: ["gl", "Galego"],
1110: ["gl-ES", "Galego (Galego)"],
55: ["ka", "ქართული"],
1079: ["ka-GE", "ქართული (საქართველო)"],
7: ["de", "Deutsch"],
3079: ["de-AT", "Deutsch (Österreich)"],
1031: ["de-DE", "Deutsch (Deutschland)"],
5127: ["de-LI", "Deutsch (Liechtenstein)"],
4103: ["de-LU", "Deutsch (Luxemburg)"],
2055: ["de-CH", "Deutsch (Schweiz)"],
8: ["el", "Ελληνικά"],
1032: ["el-GR", "Ελληνικά (Ελλάδα)"],
111: ["kl", "Kalaallisut"],
1135: ["kl-GL", "Kalaallisut (Kalaallit Nunaat)"],
71: ["gu", "ગુજરાતી"],
1095: ["gu-IN", "ગુજરાતી (ભારત)"],
104: ["ha", "Hausa"],
31848: ["ha-Latn", "Hausa (Latin)"],
1128: ["ha-Latn-NG", "Hausa (Nigeria)"],
13: ["he", "עברית"],
1037: ["he-IL", "עברית (ישראל)"],
57: ["hi", "हिंदी"],
1081: ["hi-IN", "हिंदी (भारत)"],
14: ["hu", "Magyar"],
1038: ["hu-HU", "Magyar (Magyarország)"],
15: ["is", "Íslenska"],
1039: ["is-IS", "Íslenska (Ísland)"],
112: ["ig", "Igbo"],
1136: ["ig-NG", "Igbo (Nigeria)"],
33: ["id", "Bahasa Indonesia"],
1057: ["id-ID", "Bahasa Indonesia (Indonesia)"],
93: ["iu", "Inuktitut"],
31837: ["iu-Latn", "Inuktitut (Qaliujaaqpait)"],
2141: ["iu-Latn-CA", "Inuktitut"],
30813: ["iu-Cans", "ᐃᓄᒃᑎᑐᑦ (ᖃᓂᐅᔮᖅᐸᐃᑦ)"],
1117: ["iu-Cans-CA", "ᐃᓄᒃᑎᑐᑦ (ᑲᓇᑕᒥ)"],
60: ["ga", "Gaeilge"],
2108: ["ga-IE", "Gaeilge (Éire)"],
52: ["xh", "isiXhosa"],
1076: ["xh-ZA", "isiXhosa (uMzantsi Afrika)"],
53: ["zu", "isiZulu"],
1077: ["zu-ZA", "isiZulu (iNingizimu Afrika)"],
16: ["it", "Italiano"],
1040: ["it-IT", "Italiano (Italia)"],
2064: ["it-CH", "Italiano (Svizzera)"],
17: ["ja", "日本語"],
1041: ["ja-JP", "日本語 (日本)"],
75: ["kn", "ಕನ್ನಡ"],
1099: ["kn-IN", "ಕನ್ನಡ (ಭಾರತ)"],
63: ["kk", "Қазақ"],
1087: ["kk-KZ", "Қазақ (Қазақстан)"],
83: ["km", "ខ្មែរ"],
1107: ["km-KH", "ខ្មែរ (កម្ពុជា)"],
134: ["qut", "K'iche"],
1158: ["qut-GT", "K'iche (Guatemala)"],
135: ["rw", "Kinyarwanda"],
1159: ["rw-RW", "Kinyarwanda (Rwanda)"],
65: ["sw", "Kiswahili"],
1089: ["sw-KE", "Kiswahili (Kenya)"],
87: ["kok", "कोंकणी"],
1111: ["kok-IN", "कोंकणी (भारत)"],
18: ["ko", "한국어"],
1042: ["ko-KR", "한국어 (대한민국)"],
64: ["ky", "Кыргыз"],
1088: ["ky-KG", "Кыргыз (Кыргызстан)"],
84: ["lo", "ລາວ"],
1108: ["lo-LA", "ລາວ (ສ.ປ.ປ. ລາວ)"],
38: ["lv", "Latviešu"],
1062: ["lv-LV", "Latviešu (Latvija)"],
39: ["lt", "Lietuvių"],
1063: ["lt-LT", "Lietuvių (Lietuva)"],
31790: ["dsb", "Dolnoserbšćina"],
2094: ["dsb-DE", "Dolnoserbšćina (Nimska)"],
110: ["lb", "Lëtzebuergesch"],
1134: ["lb-LU", "Lëtzebuergesch (Luxembourg)"],
1071: ["mk-MK", "Македонски јазик (Македонија)"],
47: ["mk", "Македонски јазик"],
62: ["ms", "Bahasa Melayu"],
2110: ["ms-BN", "Bahasa Melayu (Brunei Darussalam)"],
1086: ["ms-MY", "Bahasa Melayu (Malaysia)"],
76: ["ml", "മലയാളം"],
1100: ["ml-IN", "മലയാളം (ഭാരതം)"],
58: ["mt", "Malti"],
1082: ["mt-MT", "Malti (Malta)"],
129: ["mi", "Reo Māori"],
1153: ["mi-NZ", "Reo Māori (Aotearoa)"],
122: ["arn", "Mapudungun"],
1146: ["arn-CL", "Mapudungun (Chile)"],
78: ["mr", "मराठी"],
1102: ["mr-IN", "मराठी (भारत)"],
124: ["moh", "Kanien'kéha"],
1148: ["moh-CA", "Kanien'kéha"],
80: ["mn", "Монгол хэл"],
30800: ["mn-Cyrl", "Монгол хэл"],
1104: ["mn-MN", "Монгол хэл (Монгол улс)"],
31824: ["mn-Mong", "ᠮᠤᠨᠭᠭᠤᠯ ᠬᠡᠯᠡ"],
2128: ["mn-Mong-CN", "ᠮᠤᠨᠭᠭᠤᠯ ᠬᠡᠯᠡ (ᠪᠦᠭᠦᠳᠡ ᠨᠠᠢᠷᠠᠮᠳᠠᠬᠤ ᠳᠤᠮᠳᠠᠳᠤ ᠠᠷᠠᠳ ᠣᠯᠣᠰ)"],
97: ["ne", "नेपाली"],
1121: ["ne-NP", "नेपाली (नेपाल)"],
20: ["no", "Norsk"],
31764: ["nb", "Norsk (bokmål)"],
30740: ["nn", "Norsk (Nynorsk)"],
1044: ["nb-NO", "Norsk, bokmål (Norge)"],
2068: ["nn-NO", "Norsk, nynorsk (Noreg)"],
130: ["oc", "Occitan"],
1154: ["oc-FR", "Occitan (França)"],
72: ["or", "ଓଡ଼ିଆ"],
1096: ["or-IN", "ଓଡ଼ିଆ (ଭାରତ)"],
99: ["ps", "پښتو"],
1123: ["ps-AF", "پښتو (افغانستان)"],
41: ["fa", "فارسى"],
1065: ["fa-IR", "فارسى (ایران)"],
21: ["pl", "Polski"],
1045: ["pl-PL", "Polski (Polska)"],
22: ["pt", "Português"],
1046: ["pt-BR", "Português (Brasil)"],
2070: ["pt-PT", "Português (Portugal)"],
70: ["pa", "ਪੰਜਾਬੀ"],
1094: ["pa-IN", "ਪੰਜਾਬੀ (ਭਾਰਤ)"],
107: ["quz", "Runasimi"],
1131: ["quz-BO", "Runasimi (Qullasuyu)"],
2155: ["quz-EC", "Runasimi (Ecuador)"],
3179: ["quz-PE", "Runasimi (Piruw)"],
24: ["ro", "Română"],
1048: ["ro-RO", "Română (România)"],
23: ["rm", "Rumantsch"],
1047: ["rm-CH", "Rumantsch (Svizra)"],
25: ["ru", "Русский"],
1049: ["ru-RU", "Русский (Россия)"],
28731: ["smn", "Sämikielâ"],
31803: ["smj", "Julevusámegiella"],
59: ["se", "Davvisámegiella"],
29755: ["sms", "Sääm´ǩiõll"],
30779: ["sma", "åarjelsaemiengiele"],
9275: ["smn-FI", "Sämikielâ (Suomâ)"],
4155: ["smj-NO", "Julevusámegiella (Vuodna)"],
5179: ["smj-SE", "Julevusámegiella (Svierik)"],
3131: ["se-FI", "Davvisámegiella (Suopma)"],
1083: ["se-NO", "Davvisámegiella (Norga)"],
2107: ["se-SE", "Davvisámegiella (Ruoŧŧa)"],
8251: ["sms-FI", "Sääm´ǩiõll (Lää´ddjânnam)"],
6203: ["sma-NO", "åarjelsaemiengiele (Nöörje)"],
7227: ["sma-SE", "åarjelsaemiengiele (Sveerje)"],
79: ["sa", "संस्कृत"],
1103: ["sa-IN", "संस्कृत (भारतम्)"],
145: ["gd", "Gàidhlig"],
1169: ["gd-GB", "Gàidhlig (An Rìoghachd Aonaichte)"],
31770: ["sr", "Srpski"],
27674: ["sr-Cyrl", "Српски (Ћирилица)"],
7194: ["sr-Cyrl-BA", "Српски (Босна и Херцеговина)"],
12314: ["sr-Cyrl-ME", "Српски (Црна Гора)"],
3098: ["sr-Cyrl-CS", "Српски (Србија и Црна Гора (Претходно))"],
10266: ["sr-Cyrl-RS", "Српски (Србија)"],
28698: ["sr-Latn", "Srpski (Latinica)"],
6170: ["sr-Latn-BA", "Srpski (Bosna i Hercegovina)"],
11290: ["sr-Latn-ME", "Srpski (Crna Gora)"],
2074: ["sr-Latn-CS", "Srpski (Srbija i Crna Gora (Prethodno))"],
9242: ["sr-Latn-RS", "Srpski (Srbija)"],
108: ["nso", "Sesotho sa Leboa"],
1132: ["nso-ZA", "Sesotho sa Leboa (Afrika Borwa)"],
50: ["tn", "Setswana"],
1074: ["tn-ZA", "Setswana (Aforika Borwa)"],
91: ["si", "සිංහ"],
1115: ["si-LK", "සිංහ (ශ්රී ලංකා)"],
27: ["sk", "Slovenčina"],
1051: ["sk-SK", "Slovenčina (Slovenská republika)"],
36: ["sl", "Slovenski"],
1060: ["sl-SI", "Slovenski (Slovenija)"],
10: ["es", "Español"],
11274: ["es-AR", "Español (Argentina)"],
16394: ["es-BO", "Español (Bolivia)"],
13322: ["es-CL", "Español (Chile)"],
9226: ["es-CO", "Español (Colombia)"],
5130: ["es-CR", "Español (Costa Rica)"],
7178: ["es-DO", "Español (República Dominicana)"],
12298: ["es-EC", "Español (Ecuador)"],
17418: ["es-SV", "Español (El Salvador)"],
4106: ["es-GT", "Español (Guatemala)"],
18442: ["es-HN", "Español (Honduras)"],
2058: ["es-MX", "Español (México)"],
19466: ["es-NI", "Español (Nicaragua)"],
6154: ["es-PA", "Español (Panamá)"],
15370: ["es-PY", "Español (Paraguay)"],
10250: ["es-PE", "Español (Perú)"],
20490: ["es-PR", "Español (Puerto Rico)"],
3082: ["es-ES", "Español (España, alfabetización internacional)"],
21514: ["es-US", "Español (Estados Unidos)"],
14346: ["es-UY", "Español (Uruguay)"],
8202: ["es-VE", "Español (Republica Bolivariana de Venezuela)"],
29: ["sv", "Svenska"],
2077: ["sv-FI", "Svenska (Finland)"],
1053: ["sv-SE", "Svenska (Sverige)"],
90: ["syr", "ܣܘܪܝܝܐ"],
1114: ["syr-SY", "ܣܘܪܝܝܐ (سوريا)"],
40: ["tg", "Тоҷикӣ"],
31784: ["tg-Cyrl", "Тоҷикӣ"],
1064: ["tg-Cyrl-TJ", "Тоҷикӣ (Тоҷикистон)"],
95: ["tzm", "Tamazight"],
31839: ["tzm-Latn", "Tamazight (Latin)"],
2143: ["tzm-Latn-DZ", "Tamazight (Djazaïr)"],
73: ["ta", "தமிழ்"],
1097: ["ta-IN", "தமிழ் (இந்தியா)"],
68: ["tt", "Татар"],
1092: ["tt-RU", "Татар (Россия)"],
74: ["te", "తెలుగు"],
1098: ["te-IN", "తెలుగు (భారత దేశం)"],
30: ["th", "ไทย"],
1054: ["th-TH", "ไทย (ไทย)"],
81: ["bo", "བོད་ཡིག"],
1105: ["bo-CN", "བོད་ཡིག (ཀྲུང་ཧྭ་མི་དམངས་སྤྱི་མཐུན་རྒྱལ་ཁབ།)"],
31: ["tr", "Türkçe"],
1055: ["tr-TR", "Türkçe (Türkiye)"],
66: ["tk", "Türkmençe"],
1090: ["tk-TM", "Türkmençe (Türkmenistan)"],
34: ["uk", "Українська"],
1058: ["uk-UA", "Українська (Україна)"],
46: ["hsb", "Hornjoserbšćina"],
1070: ["hsb-DE", "Hornjoserbšćina (Němska)"],
32: ["ur", "اُردو"],
1056: ["ur-PK", "اُردو (پاکستان)"],
128: ["ug", "ئۇيغۇر يېزىقى"],
1152: ["ug-CN", "(ئۇيغۇر يېزىقى (جۇڭخۇا خەلق جۇمھۇرىيىتى"],
30787: ["uz-Cyrl", "Ўзбек"],
2115: ["uz-Cyrl-UZ", "Ўзбек (Ўзбекистон)"],
67: ["uz", "U'zbek"],
31811: ["uz-Latn", "U'zbek"],
1091: ["uz-Latn-UZ", "U'zbek (U'zbekiston Respublikasi)"],
42: ["vi", "Tiếng Việt"],
1066: ["vi-VN", "Tiếng Việt (Việt Nam)"],
82: ["cy", "Cymraeg"],
1106: ["cy-GB", "Cymraeg (y Deyrnas Unedig)"],
136: ["wo", "Wolof"],
1160: ["wo-SN", "Wolof (Sénégal)"],
133: ["sah", "Саха"],
1157: ["sah-RU", "Саха (Россия)"],
120: ["ii", "ꆈꌠꁱꂷ"],
1144: ["ii-CN", "ꆈꌠꁱꂷ (ꍏꉸꏓꂱꇭꉼꇩ)"],
106: ["yo", "Yoruba"],
1130: ["yo-NG", "Yoruba (Nigeria)"],
2129: ["bo-BT", "Tibetan, Bhutan"],
1126: ["bin-NG", "Bini, Nigeria"],
1116: ["chr-US", "Cherokee, United States"],
15369: ["en-HK", "English, Hong Kong"],
14345: ["en-ID", "English, Indonesia"],
1034: ["es-ES_tradnl", "Spanish"],
15372: ["fr-HT", "French, Haiti"],
9228: ["fr-CG", "French, Congo"],
12300: ["fr-CI", "French, Cote d'Ivoire"],
11276: ["fr-CM", "French, Cameroon"],
14348: ["fr-MA", "French, Morocco"],
13324: ["fr-ML", "French, Mali"],
8204: ["fr-RE", "French, Reunion"],
10252: ["fr-SN", "French, Senegal"],
7180: ["fr-West", "French"],
1127: ["fuv-NG", "Nigerian Fulfulde, Nigeria"],
1138: ["gaz-ET", "West Central Oromo, Ethiopia"],
1140: ["gn-PY", "Guarani, Paraguay"],
1141: ["haw-US", "Hawaiian, UnitedStates"],
1129: ["ibb-NG", "Ibibio, Nigeria"],
1137: ["kr-NG", "Kanuri, Nigeria"],
1112: ["mni", "Manipuri"],
1109: ["my-MM", "Burmese, Myanmar"],
2145: ["ne-IN", "Nepali, India"],
1145: ["pap-AN", "Papiamento, Netherlands Antilles"],
2118: ["pa-PK", "Panjabi, Pakistan"],
1165: ["plt-MG", "Plateau Malagasy, Madagascar"],
2072: ["ro-MO", "Romanian, Macao"],
2073: ["ru-MO", "Russian, Macao"],
1113: ["sd-IN", "Sindhi, India"],
2137: ["sd-PK", "Sindhi, Pakistan"],
1143: ["so-SO", "Somali, Somalia"],
1072: ["st-ZA", "Southern Sotho, South Africa"],
1139: ["ti-ER", "Tigrinya, Eritrea"],
2163: ["ti-ET", "Tigrinya, Ethiopia"],
1119: ["tmz", "Tamanaku"],
3167: ["tmz-MA", "Tamanaku, Morocco"],
1073: ["ts-ZA", "Tsonga, South Africa"],
2080: ["ur-IN", "Urdu, India"],
1075: ["ven-ZA", "South Africa"]
};
return {
getLocalLanguageName: function (code) {
return localLanguageName[code] || ["", code];
}
};
})();

View File

@@ -0,0 +1,105 @@
/*
* (c) Copyright Ascensio System SIA 2010-2015
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
if (Common === undefined) {
var Common = {};
}
Common.util = Common.util || {};
define(["backbone", "keymaster"], function (Backbone) {
var Shortcuts = function (options) {
this.cid = _.uniqueId("shortcuts");
this.initialize.apply(this, arguments);
return this;
};
_.extend(Shortcuts.prototype, Backbone.Events, {
initialize: function () {
window.key.filter = function (event) {
return true;
};
Common.NotificationCenter.on({
"modal:show": function (e) {
window.key.suspend();
},
"modal:close": function (e) {
window.key.resume();
},
"modal:hide": function (e) {
window.key.resume();
}
});
},
delegateShortcuts: function (options) {
if (!options || !options.shortcuts) {
return;
}
this.removeShortcuts(options);
var callback, match, method, scope, shortcut, shortcutKey;
var _results = [];
for (shortcut in options.shortcuts) {
callback = options.shortcuts[shortcut];
if (!_.isFunction(callback)) {
method = options[callback];
if (!method) {
throw new Error("Method " + callback + " does not exist");
}
} else {
method = callback;
}
match = shortcut.match(/^(\S+)\s*(.*)$/);
shortcutKey = match[1];
scope = match[2].length ? match[2] : "all";
method = _.bind(method, this);
_results.push(window.key(shortcutKey, scope, method));
}
},
removeShortcuts: function (options) {
if (!options || !options.shortcuts) {
return;
}
var match, scope, shortcut, shortcutKey;
var _results = [];
for (shortcut in options.shortcuts) {
match = shortcut.match(/^(\S+)\s*(.*)$/);
shortcutKey = match[1];
scope = match[2].length ? match[2] : "all";
window.key.unbind(shortcutKey, scope);
}
},
suspendEvents: function (key, scope) {
window.key.suspend(key, scope);
},
resumeEvents: function (key, scope) {
window.key.resume(key, scope);
}
});
Shortcuts.extend = Backbone.View.extend;
Common.util.Shortcuts = new Shortcuts;
});

View File

@@ -0,0 +1,235 @@
/*
* (c) Copyright Ascensio System SIA 2010-2015
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
(function ($) {
var _superclass = $.fn.tooltip;
_superclass.prototype = $.fn.tooltip.Constructor.prototype;
$.extend($.fn.tooltip.Constructor.DEFAULTS, {
container: "body",
delay: {
show: 500
},
arrow: false
});
var Tip = function (element, options) {
this.init("tooltip", element, options);
};
Tip.prototype = $.extend({},
$.fn.tooltip.Constructor.prototype, {
constructor: Tip,
init: function () {
_superclass.prototype.init.apply(this, arguments);
if (this.options.placement == "cursor") {
if (/hover/.exec(this.options.trigger)) {
this.$element.on("mousemove.tooltip", this.options.selector, $.proxy(this.mousemove, this));
}
}
if (this.options.zIndex) {
this.tip().css("z-index", this.options.zIndex);
}
var me = this;
Common.NotificationCenter.on({
"layout:changed": function (e) {
if (!me.options.hideonclick && me.tip().is(":visible")) {
me.hide();
}
}
});
},
mousemove: function (e) {
this.targetXY = [e.clientX, e.clientY];
},
leave: function (obj) {
_superclass.prototype.leave.apply(this, arguments);
this.dontShow = undefined;
},
show: function (at) {
if (this.hasContent() && this.enabled && !this.dontShow) {
if (!this.$element.is(":visible") && this.$element.closest("[role=menu]").length > 0) {
return;
}
var $tip = this.tip();
var placement = typeof this.options.placement === "function" ? this.options.placement.call(this, $tip[0], this.$element[0]) : this.options.placement;
if (this.options.arrow === false) {
$tip.addClass("arrow-free");
}
if (this.options.cls) {
$tip.addClass(this.options.cls);
}
var placementEx = /^([a-zA-Z]+)-?([a-zA-Z]*)$/.exec(placement);
if (!at && !placementEx[2].length) {
_superclass.prototype.show.apply(this, arguments);
} else {
var e = $.Event("show.bs.tooltip");
this.$element.trigger(e);
if (e.isDefaultPrevented()) {
return;
}
this.setContent();
if (this.options.animation) {
$tip.addClass("fade");
}
$tip.detach().css({
top: 0,
left: 0,
display: "block"
});
this.options.container ? $tip.appendTo(this.options.container) : $tip.insertAfter(this.$element);
if (typeof at == "object") {
var tp = {
top: at[1] + 15,
left: at[0] + 18
};
if (tp.left + $tip.width() > window.innerWidth) {
tp.left = window.innerWidth - $tip.width() - 30;
}
$tip.offset(tp).addClass("in");
} else {
var pos = this.getPosition();
var actualWidth = $tip[0].offsetWidth,
actualHeight = $tip[0].offsetHeight;
switch (placementEx[1]) {
case "bottom":
tp = {
top: pos.top + pos.height + 10
};
break;
case "top":
tp = {
top: pos.top - actualHeight - 10
};
break;
}
switch (placementEx[2]) {
case "left":
tp.left = pos.left;
if (this.$element.outerWidth() <= 18) {
tp.left -= 4;
}
break;
case "right":
tp.left = pos.left + pos.width - actualWidth;
if (this.$element.outerWidth() <= 18) {
tp.left += 4;
}
break;
}
this.applyPlacement(tp, placementEx[1]);
this.moveArrow();
$tip.addClass(placementEx[1]).addClass(placementEx[0]);
}
this.$element.trigger("shown.bs.tooltip");
}
var self = this;
clearTimeout(self.timeout);
self.timeout = setTimeout(function () {
if (self.hoverState == "in") {
self.hide();
}
self.dontShow = false;
},
5000);
}
},
moveArrow: function () {
var $arrow = this.tip().find(".tooltip-arrow, .arrow");
var new_arrow_position = 10;
switch (this.options.placement) {
case "top-left":
case "bottom-left":
$arrow.css("left", new_arrow_position);
break;
case "top-right":
case "bottom-right":
$arrow.css("right", new_arrow_position);
break;
}
},
enter: function (obj) {
if (obj.type !== "mouseenter") {
return;
}
var $target = $(obj.target);
if ($target.is("[role=menu]") || $target.parentsUntil(obj.currentTarget, "[role=menu]").length || this.tip().is(":visible")) {
return;
}
var self = obj instanceof this.constructor ? obj : $(obj.currentTarget)[this.type](this.getDelegateOptions()).data("bs.tooltip");
clearTimeout(self.timeout);
self.hoverState = "in";
if (!self.options.delay || !self.options.delay.show) {
self.show();
} else {
self.timeout = setTimeout(function () {
if (self.hoverState == "in") {
self.show(self.options.placement == "cursor" ? self.targetXY : undefined);
}
},
self.options.delay.show);
}
},
replaceArrow: function (delta, dimension, position) {
this.options.arrow === false ? this.arrow().hide() : _superclass.prototype.replaceArrow.apply(this, arguments);
},
getCalculatedOffset: function (placement, pos, actualWidth, actualHeight) {
var out = _superclass.prototype.getCalculatedOffset.apply(this, arguments);
if (this.options.offset > 0 || this.options.offset < 0) {
switch (/(bottom|top)/.exec(placement)[1]) {
case "bottom":
out.top += this.options.offset;
break;
case "top":
out.top -= this.options.offset;
break;
}
}
return out;
}
});
var old = $.fn.tooltip;
$.fn.tooltip = function (option) {
return this.each(function () {
var $this = $(this),
data = $this.data("bs.tooltip"),
options = typeof option === "object" && option;
if (!data) {
$this.data("bs.tooltip", (data = new Tip(this, options)));
}
if (typeof option === "string") {
data[option]();
}
});
};
$.fn.tooltip.Constructor = Tip;
$.fn.tooltip.noConflict = function () {
$.fn.tooltip = old;
return this;
};
})(window.jQuery);

View File

@@ -0,0 +1,499 @@
/*
* (c) Copyright Ascensio System SIA 2010-2015
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
if (Common === undefined) {
var Common = {};
}
if (Common.Utils === undefined) {
Common.Utils = {};
}
Common.Utils = new(function () {
var userAgent = navigator.userAgent.toLowerCase(),
check = function (regex) {
return regex.test(userAgent);
},
isStrict = document.compatMode == "CSS1Compat",
version = function (is, regex) {
var m;
return (is && (m = regex.exec(userAgent))) ? parseFloat(m[1]) : 0;
},
docMode = document.documentMode,
isOpera = check(/opera/),
isOpera10_5 = isOpera && check(/version\/10\.5/),
isChrome = check(/\bchrome\b/),
isWebKit = check(/webkit/),
isSafari = !isChrome && check(/safari/),
isSafari2 = isSafari && check(/applewebkit\/4/),
isSafari3 = isSafari && check(/version\/3/),
isSafari4 = isSafari && check(/version\/4/),
isSafari5_0 = isSafari && check(/version\/5\.0/),
isSafari5 = isSafari && check(/version\/5/),
isIE = !isOpera && (check(/msie/) || check(/trident/)),
isIE7 = isIE && ((check(/msie 7/) && docMode != 8 && docMode != 9 && docMode != 10) || docMode == 7),
isIE8 = isIE && ((check(/msie 8/) && docMode != 7 && docMode != 9 && docMode != 10) || docMode == 8),
isIE9 = isIE && ((check(/msie 9/) && docMode != 7 && docMode != 8 && docMode != 10) || docMode == 9),
isIE10 = isIE && ((check(/msie 10/) && docMode != 7 && docMode != 8 && docMode != 9) || docMode == 10),
isIE11 = isIE && ((check(/trident\/7\.0/) && docMode != 7 && docMode != 8 && docMode != 9 && docMode != 10) || docMode == 11),
isIE6 = isIE && check(/msie 6/),
isGecko = !isWebKit && !isIE && check(/gecko/),
isGecko3 = isGecko && check(/rv:1\.9/),
isGecko4 = isGecko && check(/rv:2\.0/),
isGecko5 = isGecko && check(/rv:5\./),
isGecko10 = isGecko && check(/rv:10\./),
isFF3_0 = isGecko3 && check(/rv:1\.9\.0/),
isFF3_5 = isGecko3 && check(/rv:1\.9\.1/),
isFF3_6 = isGecko3 && check(/rv:1\.9\.2/),
isWindows = check(/windows|win32/),
isMac = check(/macintosh|mac os x/),
isLinux = check(/linux/),
chromeVersion = version(true, /\bchrome\/(\d+\.\d+)/),
firefoxVersion = version(true, /\bfirefox\/(\d+\.\d+)/),
ieVersion = version(isIE, /msie (\d+\.\d+)/),
operaVersion = version(isOpera, /version\/(\d+\.\d+)/),
safariVersion = version(isSafari, /version\/(\d+\.\d+)/),
webKitVersion = version(isWebKit, /webkit\/(\d+\.\d+)/),
isSecure = /^https/i.test(window.location.protocol),
emailRe = /^(mailto:)?([a-z0-9\._-]+@[a-z0-9\.-]+\.[a-z]{2,4})([a-яё0-9\._%+-=\? :&]*)/i,
ipRe = /^(((https?)|(ftps?)):\/\/)?([\-\wа-яё]*:?[\-\wа-яё]*@)?(((1[0-9]{2}|2[0-4][0-9]|25[0-5]|[1-9][0-9]|[0-9])\.){3}(1[0-9]{2}|2[0-4][0-9]|25[0-5]|[1-9][0-9]|[0-9]))(:\d+)?(\/[%\-\wа-яё]*(\.[\wа-яё]{2,})?(([\wа-яё\-\.\?\\\/+@&#;`~=%!,]*)(\.[\wа-яё]{2,})?)*)*\/?/i,
hostnameRe = /^(((https?)|(ftps?)):\/\/)?([\-\wа-яё]*:?[\-\wа-яё]*@)?(([\-\wа-яё]+\.)+[\wа-яё\-]{2,}(:\d+)?(\/[%\-\wа-яё]*(\.[\wа-яё]{2,})?(([\wа-яё\-\.\?\\\/+@&#;`~=%!,]*)(\.[\wа-яё]{2,})?)*)*\/?)/i,
localRe = /^(((https?)|(ftps?)):\/\/)([\-\wа-яё]*:?[\-\wа-яё]*@)?(([\-\wа-яё]+)(:\d+)?(\/[%\-\wа-яё]*(\.[\wа-яё]{2,})?(([\wа-яё\-\.\?\\\/+@&#;`~=%!,]*)(\.[\wа-яё]{2,})?)*)*\/?)/i,
emailStrongRe = /(mailto:)([a-z0-9\._-]+@[a-z0-9\.-]+\.[a-z]{2,4})([a-яё0-9\._%+-=\? :&]*)/ig,
ipStrongRe = /(((https?)|(ftps?)):\/\/([\-\wа-яё]*:?[\-\wа-яё]*@)?)(((1[0-9]{2}|2[0-4][0-9]|25[0-5]|[1-9][0-9]|[0-9])\.){3}(1[0-9]{2}|2[0-4][0-9]|25[0-5]|[1-9][0-9]|[0-9]))(:\d+)?(\/[%\-\wа-яё]*(\.[\wа-яё]{2,})?(([\wа-яё\-\.\?\\\/+@&#;`~=%!,]*)(\.[\wа-яё]{2,})?)*)*\/?/ig,
hostnameStrongRe = /((((https?)|(ftps?)):\/\/([\-\wа-яё]*:?[\-\wа-яё]*@)?)|(([\-\wа-яё]*:?[\-\wа-яё]*@)?www\.))((([\-\wа-яё]+\.)+[\wа-яё\-]{2,}|([\-\wа-яё]+))(:\d+)?(\/[%\-\wа-яё]*(\.[\wа-яё]{2,})?(([\wа-яё\-\.\?\\\/+@&#;`~=%!,]*)(\.[\wа-яё]{2,})?)*)*\/?)/ig;
return {
userAgent: userAgent,
isStrict: isStrict,
isIEQuirks: isIE && (!isStrict && (isIE6 || isIE7 || isIE8 || isIE9)),
isOpera: isOpera,
isOpera10_5: isOpera10_5,
isWebKit: isWebKit,
isChrome: isChrome,
isSafari: isSafari,
isSafari3: isSafari3,
isSafari4: isSafari4,
isSafari5: isSafari5,
isSafari5_0: isSafari5_0,
isSafari2: isSafari2,
isIE: isIE,
isIE6: isIE6,
isIE7: isIE7,
isIE7m: isIE6 || isIE7,
isIE7p: isIE && !isIE6,
isIE8: isIE8,
isIE8m: isIE6 || isIE7 || isIE8,
isIE8p: isIE && !(isIE6 || isIE7),
isIE9: isIE9,
isIE9m: isIE6 || isIE7 || isIE8 || isIE9,
isIE9p: isIE && !(isIE6 || isIE7 || isIE8),
isIE10: isIE10,
isIE10m: isIE6 || isIE7 || isIE8 || isIE9 || isIE10,
isIE10p: isIE && !(isIE6 || isIE7 || isIE8 || isIE9),
isIE11: isIE11,
isIE11m: isIE6 || isIE7 || isIE8 || isIE9 || isIE10 || isIE11,
isIE11p: isIE && !(isIE6 || isIE7 || isIE8 || isIE9 || isIE10),
isGecko: isGecko,
isGecko3: isGecko3,
isGecko4: isGecko4,
isGecko5: isGecko5,
isGecko10: isGecko10,
isFF3_0: isFF3_0,
isFF3_5: isFF3_5,
isFF3_6: isFF3_6,
isFF4: 4 <= firefoxVersion && firefoxVersion < 5,
isFF5: 5 <= firefoxVersion && firefoxVersion < 6,
isFF10: 10 <= firefoxVersion && firefoxVersion < 11,
isLinux: isLinux,
isWindows: isWindows,
isMac: isMac,
chromeVersion: chromeVersion,
firefoxVersion: firefoxVersion,
ieVersion: ieVersion,
operaVersion: operaVersion,
safariVersion: safariVersion,
webKitVersion: webKitVersion,
isSecure: isSecure,
emailRe: emailRe,
ipRe: ipRe,
hostnameRe: hostnameRe,
localRe: localRe,
emailStrongRe: emailStrongRe,
ipStrongRe: ipStrongRe,
hostnameStrongRe: hostnameStrongRe
};
})();
Common.Utils.ThemeColor = new(function () {
return {
ThemeValues: [6, 15, 7, 16, 0, 1, 2, 3, 4, 5],
setColors: function (colors, standart_colors) {
var i, j, item;
if (standart_colors && standart_colors.length > 0) {
var standartcolors = [];
for (i = 0; i < standart_colors.length; i++) {
item = this.getHexColor(standart_colors[i].get_r(), standart_colors[i].get_g(), standart_colors[i].get_b());
standartcolors.push(item);
}
this.standartcolors = standartcolors;
}
var effectСolors = [];
for (i = 0; i < 6; i++) {
for (j = 0; j < 10; j++) {
var idx = i + j * 6;
item = {
color: this.getHexColor(colors[idx].get_r(), colors[idx].get_g(), colors[idx].get_b()),
effectId: idx,
effectValue: this.ThemeValues[j]
};
effectСolors.push(item);
}
}
this.effectcolors = effectСolors;
},
getEffectColors: function () {
return this.effectcolors;
},
getStandartColors: function () {
return this.standartcolors;
},
getHexColor: function (r, g, b) {
r = r.toString(16);
g = g.toString(16);
b = b.toString(16);
if (r.length == 1) {
r = "0" + r;
}
if (g.length == 1) {
g = "0" + g;
}
if (b.length == 1) {
b = "0" + b;
}
return r + g + b;
},
getRgbColor: function (clr) {
var color = (typeof(clr) == "object") ? clr.color : clr;
color = color.replace(/#/, "");
if (color.length == 3) {
color = color.replace(/(.)/g, "$1$1");
}
color = parseInt(color, 16);
var c = new CAscColor();
c.put_type((typeof(clr) == "object" && clr.effectId !== undefined) ? c_oAscColor.COLOR_TYPE_SCHEME : c_oAscColor.COLOR_TYPE_SRGB);
c.put_r(color >> 16);
c.put_g((color & 65280) >> 8);
c.put_b(color & 255);
c.put_a(255);
if (clr.effectId !== undefined) {
c.put_value(clr.effectId);
}
return c;
},
colorValue2EffectId: function (clr) {
if (typeof(clr) == "object" && clr.effectValue !== undefined && this.effectcolors) {
for (var i = 0; i < this.effectcolors.length; i++) {
if (this.effectcolors[i].effectValue === clr.effectValue && clr.color.toUpperCase() === this.effectcolors[i].color.toUpperCase()) {
clr.effectId = this.effectcolors[i].effectId;
break;
}
}
}
return clr;
}
};
})();
Common.Utils.Metric = new(function () {
var me = this;
me.c_MetricUnits = {
cm: 0,
pt: 1
};
me.currentMetric = me.c_MetricUnits.pt;
me.metricName = ["cm", "pt"];
return {
c_MetricUnits: me.c_MetricUnits,
metricName: me.metricName,
setCurrentMetric: function (value) {
me.currentMetric = value;
},
getCurrentMetric: function () {
return me.currentMetric;
},
fnRecalcToMM: function (value) {
if (value !== null && value !== undefined) {
switch (me.currentMetric) {
case me.c_MetricUnits.cm:
return value * 10;
case me.c_MetricUnits.pt:
return value * 25.4 / 72;
}
}
return value;
},
fnRecalcFromMM: function (value) {
switch (me.currentMetric) {
case me.c_MetricUnits.cm:
return parseFloat((value / 10).toFixed(4));
case me.c_MetricUnits.pt:
return parseFloat((value * 72 / 25.4).toFixed(3));
}
return value;
}
};
})();
Common.Utils.RGBColor = function (colorString) {
var r, g, b;
if (colorString.charAt(0) == "#") {
colorString = colorString.substr(1, 6);
}
colorString = colorString.replace(/ /g, "");
colorString = colorString.toLowerCase();
var colorDefinitions = [{
re: /^rgb\((\d{1,3}),\s*(\d{1,3}),\s*(\d{1,3})\)$/,
process: function (bits) {
return [parseInt(bits[1]), parseInt(bits[2]), parseInt(bits[3])];
}
},
{
re: /^hsb\((\d{1,3}),\s*(\d{1,3}),\s*(\d{1,3})\)$/,
process: function (bits) {
var rgb = {};
var h = Math.round(bits[1]);
var s = Math.round(bits[2] * 255 / 100);
var v = Math.round(bits[3] * 255 / 100);
if (s == 0) {
rgb.r = rgb.g = rgb.b = v;
} else {
var t1 = v;
var t2 = (255 - s) * v / 255;
var t3 = (t1 - t2) * (h % 60) / 60;
if (h == 360) {
h = 0;
}
if (h < 60) {
rgb.r = t1;
rgb.b = t2;
rgb.g = t2 + t3;
} else {
if (h < 120) {
rgb.g = t1;
rgb.b = t2;
rgb.r = t1 - t3;
} else {
if (h < 180) {
rgb.g = t1;
rgb.r = t2;
rgb.b = t2 + t3;
} else {
if (h < 240) {
rgb.b = t1;
rgb.r = t2;
rgb.g = t1 - t3;
} else {
if (h < 300) {
rgb.b = t1;
rgb.g = t2;
rgb.r = t2 + t3;
} else {
if (h < 360) {
rgb.r = t1;
rgb.g = t2;
rgb.b = t1 - t3;
} else {
rgb.r = 0;
rgb.g = 0;
rgb.b = 0;
}
}
}
}
}
}
}
return [Math.round(rgb.r), Math.round(rgb.g), Math.round(rgb.b)];
}
},
{
re: /^(\w{2})(\w{2})(\w{2})$/,
process: function (bits) {
return [parseInt(bits[1], 16), parseInt(bits[2], 16), parseInt(bits[3], 16)];
}
},
{
re: /^(\w{1})(\w{1})(\w{1})$/,
process: function (bits) {
return [parseInt(bits[1] + bits[1], 16), parseInt(bits[2] + bits[2], 16), parseInt(bits[3] + bits[3], 16)];
}
}];
for (var i = 0; i < colorDefinitions.length; i++) {
var re = colorDefinitions[i].re;
var processor = colorDefinitions[i].process;
var bits = re.exec(colorString);
if (bits) {
var channels = processor(bits);
r = channels[0];
g = channels[1];
b = channels[2];
}
}
r = (r < 0 || isNaN(r)) ? 0 : ((r > 255) ? 255 : r);
g = (g < 0 || isNaN(g)) ? 0 : ((g > 255) ? 255 : g);
b = (b < 0 || isNaN(b)) ? 0 : ((b > 255) ? 255 : b);
var isEqual = function (color) {
return ((r == color.r) && (g == color.g) && (b == color.b));
};
var toRGB = function () {
return "rgb(" + r + ", " + g + ", " + b + ")";
};
var toRGBA = function (alfa) {
if (alfa === undefined) {
alfa = 1;
}
return "rgba(" + r + ", " + g + ", " + b + ", " + alfa + ")";
};
var toHex = function () {
var _r = r.toString(16);
var _g = g.toString(16);
var _b = b.toString(16);
if (_r.length == 1) {
_r = "0" + _r;
}
if (_g.length == 1) {
_g = "0" + _g;
}
if (_b.length == 1) {
_b = "0" + _b;
}
return "#" + _r + _g + _b;
};
var toHSB = function () {
var hsb = {
h: 0,
s: 0,
b: 0
};
var min = Math.min(r, g, b);
var max = Math.max(r, g, b);
var delta = max - min;
hsb.b = max;
hsb.s = max != 0 ? 255 * delta / max : 0;
if (hsb.s != 0) {
if (r == max) {
hsb.h = 0 + (g - b) / delta;
} else {
if (g == max) {
hsb.h = 2 + (b - r) / delta;
} else {
hsb.h = 4 + (r - g) / delta;
}
}
} else {
hsb.h = 0;
}
hsb.h *= 60;
if (hsb.h < 0) {
hsb.h += 360;
}
hsb.s *= 100 / 255;
hsb.b *= 100 / 255;
hsb.h = parseInt(hsb.h);
hsb.s = parseInt(hsb.s);
hsb.b = parseInt(hsb.b);
return hsb;
};
return {
r: r,
g: g,
b: b,
isEqual: isEqual,
toRGB: toRGB,
toRGBA: toRGBA,
toHex: toHex,
toHSB: toHSB
};
};
Common.Utils.String = new(function () {
return {
format: function (format) {
var args = _.toArray(arguments).slice(1);
return format.replace(/\{(\d+)\}/g, function (s, i) {
return args[i];
});
},
htmlEncode: function (string) {
return _.escape(string);
},
htmlDecode: function (string) {
return _.unescape(string);
},
ellipsis: function (value, len, word) {
if (value && value.length > len) {
if (word) {
var vs = value.substr(0, len - 2),
index = Math.max(vs.lastIndexOf(" "), vs.lastIndexOf("."), vs.lastIndexOf("!"), vs.lastIndexOf("?"));
if (index !== -1 && index >= (len - 15)) {
return vs.substr(0, index) + "...";
}
}
return value.substr(0, len - 3) + "...";
}
return value;
},
platformKey: function (string, template, hookFn) {
if (_.isEmpty(template)) {
template = " ({0})";
}
if (Common.Utils.isMac) {
if (_.isFunction(hookFn)) {
string = hookFn.call(this, string);
}
return Common.Utils.String.format(template, string.replace(/\+(?=\S)/g, "").replace(/Ctrl|ctrl/g, "⌘").replace(/Alt|alt/g, "⌥").replace(/Shift|shift/g, "⇧"));
}
return Common.Utils.String.format(template, string);
}
};
})();
Common.Utils.isBrowserSupported = function () {
return ! ((Common.Utils.ieVersion != 0 && Common.Utils.ieVersion < 9) || (Common.Utils.safariVersion != 0 && Common.Utils.safariVersion < 5) || (Common.Utils.firefoxVersion != 0 && Common.Utils.firefoxVersion < 4) || (Common.Utils.chromeVersion != 0 && Common.Utils.chromeVersion < 7) || (Common.Utils.operaVersion != 0 && Common.Utils.operaVersion < 10.5));
};
Common.Utils.showBrowserRestriction = function () {
var editor = (window.DE ? "Document" : window.SSE ? "Spreadsheet" : window.PE ? "Presentation" : "that");
var newDiv = document.createElement("div");
newDiv.innerHTML = '<div class="application-error-panel">' + '<div class="application-error-message-block">' + '<div class="application-error-message-inner">' + '<div class="application-error-message-title">Your browser is not supported.</div>' + '<div class="application-error-message-text">Sorry, ' + editor + " Editor is currently only supported in the latest versions of the Chrome, Firefox, Safari or Internet Explorer web browsers.</div>" + "</div>" + "</div>" + '<div class="application-error-message-auxiliary"></div>' + "</div>";
document.body.appendChild(newDiv);
$("#loading-mask").hide().remove();
$("#viewport").hide().remove();
};
String.prototype.strongMatch = function (regExp) {
if (regExp && regExp instanceof RegExp) {
var arr = this.toString().match(regExp);
return !! (arr && arr.length > 0 && arr[0].length == this.length);
}
return false;
};

View File

@@ -1,345 +1,108 @@
/*
* (c) Copyright Ascensio System SIA 2010-2014
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
Ext.define("Common.view.About", {
extend: "Ext.container.Container",
alias: "widget.commonabout",
cls: "common-about-body",
requires: ["Ext.container.Container", "Ext.form.Label"],
constructor: function (config) {
this.initConfig(config);
this.callParent(arguments);
return this;
},
initComponent: function () {
var txtVersionNum = "2.5";
var txtAscMail = "support@onlyoffice.com";
var txtAscTelNum = "+371 660-16425";
var txtAscUrl = "www.onlyoffice.com";
var txtAscName = "Ascensio System SIA";
this.items = [{
xtype: "container",
layout: {
type: "table",
columns: 1,
tableAttrs: {
style: "width: 100%;"
},
tdAttrs: {
align: "center"
}
},
items: [{
xtype: "container",
cls: "asc-about-office"
},
{
xtype: "tbspacer",
height: 5
},
{
xtype: "label",
cls: "asc-about-version",
text: this.txtVersion + txtVersionNum
},
{
xtype: "tbspacer",
height: 40
}]
},
{
xtype: "container",
layout: {
type: "table",
columns: 3,
tableAttrs: {
style: "width: 100%;"
}
},
items: [{
cellCls: "about-separator-cell",
xtype: "tbspacer",
width: "100%",
html: '<div style="width: 100%; height: 3px !important; background-color: #e1e1e1"></div>'
},
{
xtype: "label",
cls: "asc-about-header",
text: this.txtLicensor
},
{
cellCls: "about-separator-cell",
xtype: "tbspacer",
width: "100%",
html: '<div style="width: 100%; height: 3px !important; background-color: #e1e1e1"></div>'
}]
},
{
xtype: "container",
layout: {
type: "table",
columns: 1,
tableAttrs: {
style: "width: 100%;"
},
tdAttrs: {
align: "center"
}
},
items: [{
xtype: "tbspacer",
height: 20
},
{
xtype: "label",
cls: "asc-about-companyname",
text: txtAscName
},
{
xtype: "tbspacer",
height: 10
},
{
xtype: "container",
items: [{
xtype: "label",
cls: "asc-about-desc-name",
text: this.txtAddress
},
{
xtype: "label",
cls: "asc-about-desc",
text: this.txtAscAddress
}]
},
{
xtype: "tbspacer",
height: 10
},
{
xtype: "container",
items: [{
xtype: "label",
cls: "asc-about-desc-name",
text: this.txtMail
},
{
xtype: "label",
cls: "asc-about-desc",
html: Ext.String.format('<a href="mailto:{0}">{0}</a>', txtAscMail)
}]
},
{
xtype: "tbspacer",
height: 10
},
{
xtype: "container",
items: [{
xtype: "label",
cls: "asc-about-desc-name",
text: this.txtTel
},
{
xtype: "label",
cls: "asc-about-desc",
text: txtAscTelNum
}]
},
{
xtype: "tbspacer",
height: 10
},
{
xtype: "label",
cls: "asc-about-desc",
html: Ext.String.format('<a href="http://{0}" target="_blank">{0}</a>', txtAscUrl)
},
{
xtype: "tbspacer",
height: 40
}]
},
{
xtype: "container",
layout: {
type: "table",
columns: 3,
tableAttrs: {
style: "width: 100%;"
}
},
items: [{
cellCls: "about-separator-cell",
xtype: "tbspacer",
width: "100%",
html: '<div style="width: 100%; height: 3px !important; background-color: #e1e1e1"></div>'
},
{
xtype: "label",
cls: "asc-about-header",
text: this.txtLicensee
},
{
cellCls: "about-separator-cell",
xtype: "tbspacer",
width: "100%",
html: '<div style="width: 100%; height: 3px !important; background-color: #e1e1e1"></div>'
}]
},
this.cntLicenseeInfo = Ext.create("Ext.Container", {
layout: {
type: "table",
columns: 1,
tableAttrs: {
style: "width: 100%;"
},
tdAttrs: {
align: "center"
}
},
items: [{
xtype: "tbspacer",
height: 20
},
this.imgCompanyLogo = Ext.create("Ext.Container", {
html: '<img src="" />'
}), {
xtype: "tbspacer",
height: 10
},
this.lblCompanyName = Ext.create("Ext.form.Label", {
cls: "asc-about-companyname",
text: ""
}), {
xtype: "tbspacer",
height: 10
},
{
xtype: "container",
items: [{
xtype: "label",
cls: "asc-about-desc-name",
text: this.txtAddress
},
this.lblCompanyAddress = Ext.create("Ext.form.Label", {
cls: "asc-about-desc",
text: ""
})]
},
{
xtype: "tbspacer",
height: 10
},
{
xtype: "container",
items: [{
xtype: "label",
cls: "asc-about-desc-name",
text: this.txtMail
},
this.lblCompanyMail = Ext.create("Ext.form.Label", {
cls: "asc-about-desc",
text: ""
})]
},
{
xtype: "tbspacer",
height: 10
},
this.lblCompanyUrl = Ext.create("Ext.form.Label", {
cls: "asc-about-desc",
text: ""
}), {
xtype: "tbspacer",
height: 10
},
this.lblCompanyLic = Ext.create("Ext.form.Label", {
cls: "asc-about-lic",
text: ""
})]
})];
this.callParent(arguments);
this.items.items[3].hide();
this.cntLicenseeInfo.hide();
},
setLicInfo: function (data) {
if (data && typeof(data) == "object") {
this.items.items[3].show();
this.cntLicenseeInfo.show();
this.lblCompanyName.setText(data.asc_getCustomer());
var value = data.asc_getCustomerAddr();
if (value && value.length) {
this.lblCompanyAddress.setText(value);
} else {
this.cntLicenseeInfo.items.getAt(5).hide();
this.cntLicenseeInfo.items.getAt(6).hide();
}
value = data.asc_getCustomerMail();
if (value && value.length) {
this.lblCompanyMail.update(Ext.String.format('<a href="mailto:{0}">{0}</a>', value));
} else {
this.cntLicenseeInfo.items.getAt(7).hide();
this.cntLicenseeInfo.items.getAt(8).hide();
}
value = data.asc_getCustomerWww();
if (value && value.length) {
var islicense = /^label:(.+);url:(.+)/.exec(value);
if (islicense) {
href = islicense[2];
value = islicense[1];
} else {
var href = /^https?:\/\//.test(value) ? value : "http://" + value;
}
this.lblCompanyUrl.update(Ext.String.format('<a href="{0}" target="_blank">{1}</a>', href, value));
} else {
this.cntLicenseeInfo.items.getAt(9).hide();
this.cntLicenseeInfo.items.getAt(10).hide();
} (value = data.asc_getCustomerInfo()) && value.length ? this.lblCompanyLic.setText(value) : this.cntLicenseeInfo.items.getAt(11).hide();
if ((value = data.asc_getCustomerLogo()) && value.length) {
this.imgCompanyLogo.html = '<img src="' + value + '" />';
} else {
this.imgCompanyLogo.hide();
this.cntLicenseeInfo.items.getAt(2).hide();
}
} else {
this.items.items[3].hide();
this.cntLicenseeInfo.hide();
}
},
txtVersion: "Version ",
txtLicensor: "LICENSOR",
txtLicensee: "LICENSEE",
txtAddress: "address: ",
txtAscAddress: "Lubanas st. 125a-25, Riga, Latvia, EU, LV-1021",
txtMail: "email: ",
txtTel: "tel.: "
/*
* (c) Copyright Ascensio System SIA 2010-2015
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
define(["common/main/lib/component/BaseView", "common/main/lib/component/Scroller"], function () {
Common.Views.About = Common.UI.BaseView.extend(_.extend({
menu: undefined,
options: {
alias: "Common.Views.About"
},
initialize: function (options) {
Common.UI.BaseView.prototype.initialize.call(this, arguments);
this.txtVersionNum = "3.0";
this.txtAscMail = "support@onlyoffice.com";
this.txtAscTelNum = "+371 660-16425";
this.txtAscUrl = "www.onlyoffice.com";
this.txtAscName = "Ascensio System SIA";
this.template = _.template(['<table id="id-about-licensor-logo" cols="1" style="width: 100%; margin-top: 20px;">', "<tr>", '<td align="center"><div class="asc-about-office"/></td>', "</tr>", "<tr>", '<td align="center"><label class="asc-about-version">' + options.appName.toUpperCase() + "</label></td>", "</tr>", "<tr>", '<td align="center"><label class="asc-about-version">' + this.txtVersion + this.txtVersionNum + "</label></td>", "</tr>", "</table>", '<table id="id-about-licensor-info" cols="3" style="width: 100%;" class="margin-bottom">', "<tr>", '<td colspan="3" align="center" style="padding: 20px 0 10px 0;"><label class="asc-about-companyname">' + this.txtAscName + "</label></td>", "</tr>", "<tr>", '<td colspan="3" align="center" class="padding-small">', '<label class="asc-about-desc-name">' + this.txtAddress + "</label>", '<label class="asc-about-desc">' + this.txtAscAddress + "</label>", "</td>", "</tr>", "<tr>", '<td colspan="3" align="center" class="padding-small">', '<label class="asc-about-desc-name">' + this.txtMail + "</label>", '<a href="mailto:' + this.txtAscMail + '">' + this.txtAscMail + "</a>", "</td>", "</tr>", "<tr>", '<td colspan="3" align="center" class="padding-small">', '<label class="asc-about-desc-name">' + this.txtTel + "</label>", '<label class="asc-about-desc">' + this.txtAscTelNum + "</label>", "</td>", "</tr>", "<tr>", '<td colspan="3" align="center">', '<a href="http://' + this.txtAscUrl + '" target="_blank">' + this.txtAscUrl + "</a>", "</td>", "</tr>", "</table>", '<table id="id-about-licensee-info" cols="1" style="width: 100%; margin-top: 20px;" class="hidden margin-bottom"><tbody>', "<tr>", '<td align="center" class="padding-small"><div id="id-about-company-logo"/></td>', "</tr>", "<tr>", '<td align="center"><label class="asc-about-version">' + options.appName.toUpperCase() + "</label></td>", "</tr>", "<tr>", '<td align="center"><label style="padding-bottom: 29px;" class="asc-about-version">' + this.txtVersion + this.txtVersionNum + "</label></td>", "</tr>", "<tr>", '<td align="center" class="padding-small">', '<label class="asc-about-companyname" id="id-about-company-name"></label>', "</td>", "</tr>", "<tr>", '<td align="center" class="padding-small">', '<label class="asc-about-desc-name">' + this.txtAddress + "</label>", '<label class="asc-about-desc" id="id-about-company-address"></label>', "</td>", "</tr>", "<tr>", '<td align="center" class="padding-small">', '<label class="asc-about-desc-name">' + this.txtMail + "</label>", '<a href="mailto:" id="id-about-company-mail"></a>', "</td>", "</tr>", "<tr>", '<td align="center" class="padding-small">', '<a href="" target="_blank" id="id-about-company-url"></a>', "</td>", "</tr>", "<tr>", '<td align="center">', '<label class="asc-about-lic" id="id-about-company-lic"></label>', "</td>", "</tr>", "</table>", '<table id="id-about-licensor-short" cols="1" style="width: 100%; margin-top: 31px;" class="hidden"><tbody>', "<tr>", '<td style="width:50%;"><div class="separator horizontal short left"/></td>', '<td align="center"><label class="asc-about-header">' + this.txtPoweredBy + "</label></td>", '<td style="width:50%;"><div class="separator horizontal short"/></td>', "</tr>", "<tr>", '<td colspan="3" align="center" style="padding: 9px 0 10px;"><label class="asc-about-companyname">' + this.txtAscName + "</label></td>", "</tr>", "<tr>", '<td colspan="3" align="center">', '<a href="http://' + this.txtAscUrl + '" target="_blank">' + this.txtAscUrl + "</a>", "</td>", "</tr>", "</table>"].join(""));
this.menu = options.menu;
},
render: function () {
var el = $(this.el);
el.html(this.template({
scope: this
}));
el.addClass("about-dlg");
this.cntLicenseeInfo = $("#id-about-licensee-info");
this.cntLicensorInfo = $("#id-about-licensor-info");
this.divCompanyLogo = $("#id-about-company-logo");
this.lblCompanyName = $("#id-about-company-name");
this.lblCompanyAddress = $("#id-about-company-address");
this.lblCompanyMail = $("#id-about-company-mail");
this.lblCompanyUrl = $("#id-about-company-url");
this.lblCompanyLic = $("#id-about-company-lic");
if (_.isUndefined(this.scroller)) {
this.scroller = new Common.UI.Scroller({
el: $(this.el),
suppressScrollX: true
});
}
return this;
},
setLicInfo: function (data) {
if (data && typeof(data) == "object") {
$("#id-about-licensor-logo").addClass("hidden");
$("#id-about-licensor-short").removeClass("hidden");
this.cntLicensorInfo.addClass("hidden");
this.cntLicenseeInfo.removeClass("hidden");
this.cntLicensorInfo.removeClass("margin-bottom");
var value = data.customer;
value && value.length ? this.lblCompanyName.text(value) : this.lblCompanyName.parents("tr").addClass("hidden");
value = data.customerAddr;
value && value.length ? this.lblCompanyAddress.text(value) : this.lblCompanyAddress.parents("tr").addClass("hidden");
(value = data.customerMail) && value.length ? this.lblCompanyMail.attr("href", "mailto:" + value).text(value) : this.lblCompanyMail.parents("tr").addClass("hidden");
(value = data.customerWww) && value.length ? this.lblCompanyUrl.attr("href", "http://" + value).text(value) : this.lblCompanyUrl.parents("tr").addClass("hidden");
(value = data.customerInfo) && value.length ? this.lblCompanyLic.text(value) : this.lblCompanyLic.parents("tr").addClass("hidden");
(value = data.customerLogo) && value.length ? this.divCompanyLogo.html('<img src="' + value + '" />') : this.divCompanyLogo.parents("tr").addClass("hidden");
} else {
this.cntLicenseeInfo.addClass("hidden");
this.cntLicensorInfo.addClass("margin-bottom");
}
},
show: function () {
Common.UI.BaseView.prototype.show.call(this, arguments);
this.fireEvent("show", this);
},
hide: function () {
Common.UI.BaseView.prototype.hide.call(this, arguments);
this.fireEvent("hide", this);
},
txtPoweredBy: "Powered by",
txtVersion: "Version ",
txtLicensor: "LICENSOR",
txtLicensee: "LICENSEE",
txtAddress: "address: ",
txtAscAddress: "Lubanas st. 125a-25, Riga, Latvia, EU, LV-1021",
txtMail: "email: ",
txtTel: "tel.: "
},
Common.Views.About || {}));
});

View File

@@ -1,58 +0,0 @@
/*
* (c) Copyright Ascensio System SIA 2010-2014
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
Ext.define("Common.view.AbstractSettingsPanel", {
extend: "Ext.panel.Panel",
alias: "widget.commonabstractsettingspanel",
bodyPadding: "0 0 0 15px",
preventHeader: true,
constructor: function (config) {
this.controls = [];
this.callParent(arguments);
this.initConfig(config);
return this;
},
initComponent: function () {
var me = this;
this.initialHeight = this.height;
me.callParent(arguments);
},
SuspendEvents: function () {
for (var i = 0; i < this.controls.length; i++) {
this.controls[i].suspendEvents(false);
}
},
ResumeEvents: function () {
for (var i = 0; i < this.controls.length; i++) {
this.controls[i].resumeEvents();
}
}
});

View File

@@ -0,0 +1,109 @@
/*
* (c) Copyright Ascensio System SIA 2010-2015
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
define(["common/main/lib/component/Window"], function () {
Common.Views.AdvancedSettingsWindow = Common.UI.Window.extend(_.extend({
initialize: function (options) {
var _options = {};
_.extend(_options, {
height: 200,
header: true,
cls: "advanced-settings-dlg",
toggleGroup: "advanced-settings-group",
contentTemplate: "",
items: []
},
options);
this.template = options.template || ['<div class="box" style="height:' + (_options.height - 85) + 'px;">', '<div class="menu-panel">', "<% _.each(items, function(item) { %>", '<button class="btn btn-category" style="margin-bottom: 2px;" content-target="<%= item.panelId %>"><span class=""><%= item.panelCaption %></span></button>', "<% }); %>", "</div>", '<div class="separator"/>', '<div class="content-panel" >' + _options.contentTemplate + "</div>", "</div>", '<div class="separator horizontal"/>', '<div class="footer center">', '<button class="btn normal dlg-btn primary" result="ok" style="margin-right: 10px;">' + this.okButtonText + "</button>", '<button class="btn normal dlg-btn" result="cancel">' + this.cancelButtonText + "</button>", "</div>"].join("");
_options.tpl = _.template(this.template, _options);
this.handler = _options.handler;
this.toggleGroup = _options.toggleGroup;
this.contentWidth = _options.contentWidth;
Common.UI.Window.prototype.initialize.call(this, _options);
},
render: function () {
Common.UI.Window.prototype.render.call(this);
var me = this;
var $window = this.getChild();
$window.find(".dlg-btn").on("click", _.bind(this.onDlgBtnClick, this));
this.btnsCategory = [];
_.each($window.find(".btn-category"), function (item, index) {
var btnEl = $(item);
var btn = new Common.UI.Button({
el: btnEl,
enableToggle: true,
toggleGroup: me.toggleGroup,
allowDepress: false,
contentTarget: btnEl.attr("content-target")
});
btn.on("click", _.bind(me.onCategoryClick, me));
me.btnsCategory.push(btn);
});
var cnt_panel = $window.find(".content-panel");
cnt_panel.width(this.contentWidth);
$window.width($window.find(".menu-panel").width() + cnt_panel.outerWidth() + 1);
this.content_panels = $window.find(".settings-panel");
if (this.btnsCategory.length > 0) {
this.btnsCategory[0].toggle(true, true);
}
},
setHeight: function (height) {
Common.UI.Window.prototype.setHeight.call(this, height);
var $window = this.getChild();
var boxEl = $window.find(".body > .box");
boxEl.css("height", height - 85);
},
onDlgBtnClick: function (event) {
var state = event.currentTarget.attributes["result"].value;
if (this.handler && this.handler.call(this, state, (state == "ok") ? this.getSettings() : undefined)) {
return;
}
this.close();
},
onCategoryClick: function (btn, event) {
this.content_panels.filter(".active").removeClass("active");
$("#" + btn.options.contentTarget).addClass("active");
},
getSettings: function () {
return;
},
onPrimary: function () {
if (this.handler && this.handler.call(this, "ok", this.getSettings())) {
return;
}
this.close();
return false;
},
cancelButtonText: "Cancel",
okButtonText: "Ok"
},
Common.Views.AdvancedSettingsWindow || {}));
});

View File

@@ -0,0 +1,248 @@
/*
* (c) Copyright Ascensio System SIA 2010-2015
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
if (Common === undefined) {
var Common = {};
}
Common.Views = Common.Views || {};
define(["text!common/main/lib/template/Chat.template", "common/main/lib/util/utils", "common/main/lib/component/BaseView"], function (template) {
Common.Views.Chat = Common.UI.BaseView.extend(_.extend({
el: "#left-panel-chat",
template: _.template(template),
storeUsers: undefined,
storeMessages: undefined,
tplUser: ['<li id="chat-user-<%= user.get("id") %>"<% if (!user.get("online")) { %> class="offline"<% } %>>', '<div class="color" style="background-color: <%= user.get("color") %>;" >', '<label class="name"><%= scope.getUserName(user.get("username")) %></label>', "</div>", "</li>"].join(""),
templateUserList: _.template("<ul>" + "<% _.each(users, function(item) { %>" + "<%= _.template(usertpl, {user: item, scope: scope}) %>" + "<% }); %>" + "</ul>"),
tplMsg: ["<li>", '<% if (msg.get("type")==1) { %>', '<div class="message service" data-can-copy="true"><%= msg.get("message") %></div>', "<% } else { %>", '<div class="user" data-can-copy="true" style="color: <%= msg.get("usercolor") %>;"><%= scope.getUserName(msg.get("username")) %></div>', '<label class="message" data-can-copy="true"><%= msg.get("message") %></label>', "<% } %>", "</li>"].join(""),
templateMsgList: _.template("<ul>" + "<% _.each(messages, function(item) { %>" + "<%= _.template(msgtpl, {msg: item, scope: scope}) %>" + "<% }); %>" + "</ul>"),
events: {},
initialize: function (options) {
_.extend(this, options);
Common.UI.BaseView.prototype.initialize.call(this, arguments);
this.storeUsers.bind({
add: _.bind(this._onAddUser, this),
change: _.bind(this._onUsersChanged, this),
reset: _.bind(this._onResetUsers, this)
});
this.storeMessages.bind({
add: _.bind(this._onAddMessage, this),
reset: _.bind(this._onResetMessages, this)
});
},
render: function (el) {
el = el || this.el;
$(el).html(this.template({
scope: this
}));
this.panelUsers = $("#chat-users", this.el);
this.panelMessages = $("#chat-messages", this.el);
this.txtMessage = $("#chat-msg-text", this.el);
this.panelUsers.scroller = new Common.UI.Scroller({
el: $("#chat-users"),
useKeyboard: true,
minScrollbarLength: 25
});
this.panelMessages.scroller = new Common.UI.Scroller({
el: $("#chat-messages"),
includePadding: true,
useKeyboard: true,
minScrollbarLength: 40
});
$("#chat-msg-btn-add", this.el).on("click", _.bind(this._onBtnAddMessage, this));
this.txtMessage.on("keydown", _.bind(this._onKeyDown, this));
return this;
},
focus: function () {
var me = this;
_.defer(function () {
me.txtMessage.focus();
},
100);
},
_onKeyDown: function (event) {
if (event.keyCode == Common.UI.Keys.RETURN) {
if (event.ctrlKey || event.metaKey) {
this._onBtnAddMessage(event);
}
} else {
if (event.keyCode == Common.UI.Keys.ESC) {
this.hide();
}
}
},
_onAddUser: function (m, c, opts) {
if (this.panelUsers) {
this.panelUsers.find("ul").append(_.template(this.tplUser, {
user: m,
scope: this
}));
this.panelUsers.scroller.update({
minScrollbarLength: 25
});
}
},
_onUsersChanged: function (m) {
if (m.changed.online != undefined && this.panelUsers) {
this.panelUsers.find("#chat-user-" + m.get("id"))[m.changed.online ? "removeClass" : "addClass"]("offline");
this.panelUsers.scroller.update({
minScrollbarLength: 25
});
}
},
_onResetUsers: function (c, opts) {
if (this.panelUsers) {
this.panelUsers.html(this.templateUserList({
users: c.models,
usertpl: this.tplUser,
scope: this
}));
this.panelUsers.scroller.update({
minScrollbarLength: 25
});
}
},
_onAddMessage: function (m, c, opts) {
if (this.panelMessages) {
var content = this.panelMessages.find("ul");
if (content && content.length) {
this._prepareMessage(m);
content.append(_.template(this.tplMsg, {
msg: m,
scope: this
}));
this.panelMessages.scroller.update({
minScrollbarLength: 40
});
this.panelMessages.scroller.scrollTop(content.get(0).getBoundingClientRect().height);
}
}
},
_onResetMessages: function (c, opts) {
if (this.panelMessages) {
var user, color;
c.each(function (msg) {
this._prepareMessage(msg);
},
this);
this.panelMessages.html(this.templateMsgList({
messages: c.models,
msgtpl: this.tplMsg,
scope: this
}));
this.panelMessages.scroller.update({
minScrollbarLength: 40
});
}
},
_onBtnAddMessage: function (e) {
if (this.txtMessage) {
this.fireEvent("message:add", [this, this.txtMessage.val().trim()]);
this.txtMessage.val("");
this.focus();
}
},
_prepareMessage: function (m) {
var user = this.storeUsers.findUser(m.get("userid"));
m.set({
usercolor: user ? user.get("color") : "#000",
message: this._pickLink(Common.Utils.String.htmlEncode(m.get("message")))
},
{
silent: true
});
},
_pickLink: function (message) {
var arr = [],
offset,
len;
message.replace(Common.Utils.emailStrongRe, function (subStr) {
offset = arguments[arguments.length - 2];
arr.push({
start: offset,
end: subStr.length + offset,
str: '<a href="' + subStr + '">' + subStr + "</a>"
});
return "";
});
message.replace(Common.Utils.ipStrongRe, function (subStr) {
offset = arguments[arguments.length - 2];
len = subStr.length;
var elem = _.find(arr, function (item) {
return ((offset >= item.start) && (offset < item.end) || (offset <= item.start) && (offset + len > item.start));
});
if (!elem) {
arr.push({
start: offset,
end: len + offset,
str: '<a href="' + subStr + '" target="_blank" data-can-copy="true">' + subStr + "</a>"
});
}
return "";
});
message.replace(Common.Utils.hostnameStrongRe, function (subStr) {
var ref = (!/(((^https?)|(^ftp)):\/\/)/i.test(subStr)) ? ("http://" + subStr) : subStr;
offset = arguments[arguments.length - 2];
len = subStr.length;
var elem = _.find(arr, function (item) {
return ((offset >= item.start) && (offset < item.end) || (offset <= item.start) && (offset + len > item.start));
});
if (!elem) {
arr.push({
start: offset,
end: len + offset,
str: '<a href="' + ref + '" target="_blank" data-can-copy="true">' + subStr + "</a>"
});
}
return "";
});
arr = _.sortBy(arr, function (item) {
return item.start;
});
var str_res = (arr.length > 0) ? (message.substring(0, arr[0].start) + arr[0].str) : message;
for (var i = 1; i < arr.length; i++) {
str_res += (message.substring(arr[i - 1].end, arr[i].start) + arr[i].str);
}
if (arr.length > 0) {
str_res += message.substring(arr[i - 1].end, message.length);
}
return str_res;
},
getUserName: function (username) {
return Common.Utils.String.htmlEncode(username);
},
hide: function () {
Common.UI.BaseView.prototype.hide.call(this, arguments);
this.fireEvent("hide", this);
},
textSend: "Send"
},
Common.Views.Chat || {}));
});

Some files were not shown because too many files have changed in this diff Show More