blob: c1f044073b62b7223f37ad4a1347dea8b40240f3 [file] [log] [blame]
Akron9905e2a2016-05-10 16:06:44 +02001define({
2
3 /**
4 * Create new prefix object.
5 */
6 create : function () {
7 return Object.create(this)._init();
8 },
9
10 // Initialize prefix object
11 _init : function () {
12
Akronf86eaea2016-05-13 18:02:27 +020013 this._offset = 0;
14
Akron9905e2a2016-05-10 16:06:44 +020015 this._element = document.createElement('div');
16 this._element.setAttribute('class', 'ruler');
17
18 this._slider = this._element.appendChild(
19 document.createElement('span')
20 );
21
22 this._element.appendChild(document.createElement('div'));
23
24/*
25 this._string = '';
26
27 // Add prefix span
28 this._element = document.createElement('span');
29 this._element.classList.add('pref');
30 // Connect action
31
32 if (this["onclick"] !== undefined)
33 this._element["onclick"] = this.onclick.bind(this);
34
35*/
36 return this;
37 },
38
Akronf86eaea2016-05-13 18:02:27 +020039 _initSize : function () {
40 this._height = ((this._limit / this._length) * 100);
41 this._step = (100 - this._height) / (this._length - this._limit);
42 },
43
Akron9905e2a2016-05-10 16:06:44 +020044 show : function (i) {
Akronf86eaea2016-05-13 18:02:27 +020045 this._slider.style.height = this._height + '%';
Akron9905e2a2016-05-10 16:06:44 +020046 },
47
48 length : function (i) {
49 this._length = i;
Akronf86eaea2016-05-13 18:02:27 +020050 this._initSize();
Akron9905e2a2016-05-10 16:06:44 +020051 },
52
53 limit : function (i) {
54 this._limit = i;
Akronf86eaea2016-05-13 18:02:27 +020055 this._initSize();
56 },
57
58 offset : function (off) {
59 if (off === undefined)
60 return this._offset;
61
62 this._offset = off;
63 this._slider.style.top = (this._step * off) + '%';
Akron9905e2a2016-05-10 16:06:44 +020064 },
65
66 element : function () {
67 return this._element;
68 }
69});