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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
// uniboard = {
// preference : function(){},
// setPreference : function(){}
// }
$(document).ready(function()
{
var tinyContainer;
var w = new wcontainer( "#ub-widget" );
var _super_modeView = w.modeView;
var _super_modeEdit = w.modeEdit;
var _super_modeSplash = w.modeSplash;
function _init()
{
w.setSplashContent( '<img src="custom_icon.png" alt="Click">' );
w.setEditContent('<textarea style="width: 100%; height: 100%;">'+(window.uniboard.preference("text") || 'Type a note here')+'</textarea>');
w.elements.containerEdit.find( "textarea" ).tinymce(
{
script_url : 'tinymcejq/tiny_mce.js',
width: w.getWidth(),
height: w.getHeight(),
plugins : "table,advhr,advimage,inlinepopups,media,searchreplace,paste,advlist",
theme : "advanced",
theme_advanced_buttons1 : "formatselect,fontselect,fontsizeselect,|,forecolor,backcolor",
theme_advanced_buttons2 : "bold,italic,underline,|,bullist,numlist,|,outdent,indent,|,justifyleft,justifycenter,justifyright,justifyfull,|,link,unlink",
theme_advanced_buttons3 : "",
theme_advanced_toolbar_location : "top",
theme_advanced_toolbar_align : "left",
theme_advanced_statusbar_location : "bottom",
theme_advanced_resizing : false,
// Drop lists for link/image/media/template dialogs
template_external_list_url : "lists/template_list.js",
external_link_list_url : "lists/link_list.js",
external_image_list_url : "lists/image_list.js",
media_external_list_url : "lists/media_list.js",
setup : function(ed)
{
ed.onKeyUp.add(function(ed, e)
{
if (window.uniboard)
{
window.uniboard.setPreference("text", ed.getContent());
}
});
ed.onExecCommand.add(function(ed, e)
{
if (window.uniboard)
{
window.uniboard.setPreference("text", ed.getContent());
}
});
},
// Replace values for the template plugin
template_replace_values : {
username : "Some User",
staffid : "991234"
}
});
w.modeView(); // init view mode
w.modeEdit(); // init edit mode
if (window.uniboard.preference("state") == 'view') // back to view mode if last state was it
w.modeView();
if (window.uniboard.preference("is_splash") == '1')
w.modeSplash(true);
w.allowResize = true;
};
w.onViewMode = function()
{
var html = this.elements.containerEdit.find( "textarea" ).val();
this.setViewContent( html );
};
w.getSize = function ()
{
return {w: this.getWidth(), h:this.getHeight()};
};
w.getWidth = function()
{
var res = 360;
if (window.uniboard && window.uniboard.preference("width"))
res = parseInt(window.uniboard.preference("width"));
return res;
};
w.getHeight = function()
{
var res = 230;
if (window.uniboard && window.uniboard.preference("height"))
res = parseInt(window.uniboard.preference("height"));
return res;
};
w.viewSize = function()
{
return this.getSize();
};
w.editSize = function()
{
return this.getSize();
};
window.onresize = function(){
if (!w.allowResize)
return;
winwidth = window.innerWidth - 46;
winheight = window.innerHeight - 45;
if(winwidth <= w.minWidth)
window.resizeTo(w.minWidth,winheight);
if(winwidth > w.maxWidth)
window.resizeTo(w.maxWidth,winheight);
if(winheight <= w.minHeight)
window.resizeTo(winwidth,w.minHeight);
if(winheight > w.maxHeight)
window.resizeTo(winwidth,w.maxHeight);
w.elements.container.width(winwidth);
w.elements.container.height(winheight);
tinyMCE.activeEditor.theme.resizeTo(winwidth, winheight-98);
if(window.uniboard)
{
window.uniboard.setPreference("width", winwidth);
window.uniboard.setPreference("height", winheight-33);
}
};
w.modeView = function()
{
if (w.allowResize)
window.uniboard.setPreference("state", "view");
return _super_modeView.call(this);
}
w.modeEdit = function()
{
if (w.allowResize)
window.uniboard.setPreference("state", "edit");
return _super_modeEdit.call(this);
}
w.modeSplash = function (enable)
{
if (enable == undefined)
enable = true;
window.uniboard.setPreference("is_splash", (w.allowResize && enable)?1:0);
return _super_modeSplash.call(this, enable);
}
_init();
});