-
Notifications
You must be signed in to change notification settings - Fork 40
/
main.js
86 lines (71 loc) · 2.88 KB
/
main.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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
/****************************************************
* This file should load AFTER view.js or container.js, or whichever .js file that defines the onReady, onContainer and onViewer
*
* Note: This implmentation has been provided for convenience, developers are not required to use this pattern.
*
* SEE: Tile API & Development FAQ - https://community.jivesoftware.com/docs/DOC-185776
****************************************************/
var app = {
config : null,
options : null,
viewer : null,
container : (window["isAddOnConfigure"]) ? (window["isAddOnConfigure"]) : null,
resize : function() {
/*** DELAYED TO MAKE SURE DOM HAS SETTLED ***/
setTimeout(function() {
gadgets.window.adjustHeight();
gadgets.window.adjustWidth();
},200);
},
fireState : function(func,arguments,requireAllArguments) {
//console.log('****','Function',func,window[func]);
if (window[func] && typeof window[func] === "function") {
if (requireAllArguments) {
if (arguments && arguments.length > 0) {
var checkArgs = arguments.filter(
function(arg) {
return (arg !== null && arg != null && typeof arg !== "undefined" && arg !== undefined && arg != undefined);
} // end function
);
if (checkArgs.length == arguments.length) {
//console.log('****',func,'arguments check PASSED, firing...');
window[func].apply(null,arguments);
} else {
//console.log('****',func,'arguments are required NOT required, firing...');
} // end if
}
} else {
//console.log('****',func,'arguments check not required, firing...');
window[func].apply(null,arguments);
} // end if
} else {
//console.log('****',func,'not defined, ignoring...');
} // end if
}, // end function
loadUI : function() {
this.fireState("onViewer",[ this.viewer ],true);
this.fireState("onContainer",[ this.container ],true);
this.fireState("onReady",[ this.config,this.options,this.viewer,this.container ],true);
}, // end function
init: function(config,options) {
this.config = config;
this.options = options;
this.fireState("onConfig",[ this.config,this.options],true);
/*** CALLS APP FRAMEWORK AND ASKS FOR THE VIEWER TO BE PASSED BACK ***/
osapi.jive.corev3.people.getViewer().execute(gadgets.util.makeClosure(this, this.handleViewer));
/*** CALLS THE TILE FRAMEWORK TO DISCOVER WHERE IT IS LOCATED ***/
jive.tile.getContainer(gadgets.util.makeClosure(this, this.handleContainer));
}, // end function
handleViewer : function(viewer) {
this.viewer = viewer;
this.loadUI();
},
handleContainer : function(container) {
this.container = container;
this.loadUI();
}
};
jive.tile.onOpen(
function(config, options) {
app.init(config,options);
});