]> git.r.bdr.sh - rbdr/r.bdr.sh/blame - jekyll/js/unlimited_pizza.js
Adds new assets for dynamic headers
[rbdr/r.bdr.sh] / jekyll / js / unlimited_pizza.js
CommitLineData
0982546d
BB
1'use strict';
2
3Class("UnlimitedPizza").inherits(Widget)({
4
5 /**
6 * Gets instance, creates it if not available.
7 */
8 instance : function getInstance(config) {
9 if (!this._mainInstance) {
10 this._mainInstance = new this(config);
11 }
12 return this._mainInstance;
13 },
14
15 prototype : {
16 _loaded : false,
17
18 init : function (config) {
19 Widget.prototype.init.call(this, config)
20
21 this._bindInternalEvents();
22 },
23
24 _bindInternalEvents : function bindInternalEvents() {
25 this.bind('activate', this._onActivate.bind(this));
26 },
27
28 _onActivate : function _activate() {
29 // If this is the first time activating it... then load
30 if (!this._loaded) {
31 this._load();
32 }
33 },
34
35 /*
36 * Loads everything.
37 */
38 _load : function _load() {
39
40 // Melty cheese is our header image widget.
41 this._loadMeltyCheese();
42 },
43
44 _loadMeltyCheese : function() {
45 this.element.find('.post-image').each(function (i, headerElement) {
46
47 // Create and activate
48 this.appendChild(new UnlimitedPizza.MeltyCheese({
49 element : $(headerElement),
50 name : 'header-' + i
51 }));
52 this['header-' + i].activate();
53 }.bind(this));
54 }
55 }
56});