-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathCurrentWebFont.js
37 lines (31 loc) · 1.01 KB
/
CurrentWebFont.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
define([
'specimenTools/_BaseWidget'
], function(
Parent
) {
"use strict";
/*jshint esnext:true*/
/**
* Wigets that sets the `element.style` for the currently selected
* font.
*
* Note that in conjunction with the DOM attribute `contenteditable="true"`
* or a `<textarea>` element a simple tool for typing the current font
* is created.
*/
function CurrentWebFont(container, pubSub, webFontProvider, options) {
Parent.call(this, options);
this._container = container;
this._webFontProvider = webFontProvider;
this._pubSub = pubSub;
this._pubSub.subscribe('activateFont', this._onActivateFont.bind(this));
}
var _p = CurrentWebFont.prototype = Object.create(Parent.prototype);
_p.constructor = CurrentWebFont;
CurrentWebFont.defaultOptions = {
};
_p._onActivateFont = function(fontIndex) {
this._webFontProvider.setStyleOfElement(fontIndex, this._container);
};
return CurrentWebFont;
});