88 lines
2.6 KiB
TypeScript
88 lines
2.6 KiB
TypeScript
/*
|
|
This program is free software: you can redistribute it and/or modify
|
|
it under the terms of the GNU General Public License as published by
|
|
the Free Software Foundation, either version 3 of the License, or
|
|
(at your option) any later version.
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
GNU General Public License for more details.
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
*/
|
|
|
|
import {Globals} from './domain/globals';
|
|
import {Layout} from './domain/layout';
|
|
import {Uhr} from './uhr';
|
|
import {WidgetPrototype} from './widget/widget-prototype';
|
|
import {autodetectThemes} from './theme-autodetector';
|
|
|
|
declare namespace Fritteli {
|
|
interface Fritteli {
|
|
uhr: Uhr;
|
|
}
|
|
|
|
interface Uhr {
|
|
register: (layout: Layout) => void;
|
|
}
|
|
}
|
|
declare namespace $ {
|
|
const fritteli: Fritteli.Fritteli;
|
|
const widget: JQueryUI.Widget;
|
|
}
|
|
|
|
// First things first: discover included themes and register them
|
|
autodetectThemes();
|
|
|
|
const widgetPrototype: WidgetPrototype = {
|
|
options: {
|
|
width: '100%',
|
|
status: 'on',
|
|
language: 'de_CH',
|
|
theme: Globals.getFirstTheme().styleClass,
|
|
force: false,
|
|
controls: true,
|
|
cookiePath: undefined,
|
|
autoresize: true,
|
|
mode: 'normal'
|
|
},
|
|
start: function (): void {
|
|
this._fritteliUhrInstance.start();
|
|
},
|
|
stop: function (): void {
|
|
this._fritteliUhrInstance.stop();
|
|
},
|
|
toggle: function (): void {
|
|
this._fritteliUhrInstance.toggle();
|
|
},
|
|
language: function (key: string): void {
|
|
this._fritteliUhrInstance.setLayout(key);
|
|
},
|
|
theme: function (styleClass: string): void {
|
|
this._fritteliUhrInstance.setTheme(styleClass);
|
|
},
|
|
time: function (time: Date): void {
|
|
this._fritteliUhrInstance.setTime(time);
|
|
},
|
|
mode: function (mode: string): void {
|
|
this._fritteliUhrInstance.setMode(mode);
|
|
},
|
|
width: function (width: string): void {
|
|
this._fritteliUhrInstance.setWidth(width);
|
|
},
|
|
// constructor method
|
|
_create: function (): void {
|
|
this._fritteliUhrInstance = new Uhr(this);
|
|
},
|
|
// destructor method
|
|
_destroy: function (): void {
|
|
this._fritteliUhrInstance.destroy();
|
|
},
|
|
_fritteliUhrInstance: null
|
|
};
|
|
$.widget('fritteli.uhr', widgetPrototype);
|
|
|
|
$.fritteli.uhr.register = Globals.registerLayout;
|