firstlogin.js
4.89 KB
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
155
156
157
158
159
jQuery(function() { // Document is ready
if(jQuery("#wrapper").attr('class') != 'wizard') {// Check if we in a wizard, or on the dashboard
if(jQuery("#firstlogin").attr('id') != 'firstlogin') {// Check if we in a wizard, or on the dashboard
showForm(); // Display first login wizard, once and only once!!!
}
}
});
// Class First Login
function firstlogin(rootUrl, pluginHandle) {
this.rootUrl = rootUrl + "/";
this.ktfolderAccess = rootUrl + "/" + pluginHandle + "?action=";
this.ajaxOn = false;
}
firstlogin.prototype.showFolderTemplateTree = function() {
templateId = jQuery('#selectedTemplate').val();
this.hideFolderTemplateTrees();
jQuery('#template_' + templateId).attr('style', 'display:block'); // Show template
jQuery('#templates_' + templateId).attr('style', 'display:block'); // Show template nodes
this.showFolderTemplateNodes(templateId);
}
firstlogin.prototype.openNode = function(node_id) {
var address = this.ktfolderAccess + "getNodes&node_id="+node_id + "&firstlogin=1";
this.nodeAction("nodes_" + node_id, "node_" + node_id, address);
}
firstlogin.prototype.getNodes = function(node_id) {
var address = this.ktfolderAccess + "getNodes&node_id="+node_id;
this.nodeAction("nodes_" + node_id, "node_" + node_id, address);
};
firstlogin.prototype.openTemplate = function(templateId) {
var address = this.ktfolderAccess + "getTemplateNodes&templateId="+templateId + "&firstlogin=1";
this.nodeAction("templates_" + templateId, "template_" + templateId, address);
}
firstlogin.prototype.showFolderTemplateNodes = function(templateId) {
var address = this.ktfolderAccess + "getTemplateNodes&templateId=" + templateId + "&firstlogin=1";
getUrl(address, "templates_" + templateId);
}
firstlogin.prototype.hideFolderTemplateTrees = function() {
jQuery('.templates').each(
function() {
if(jQuery(this).attr('style') != undefined)
jQuery(this).attr('style', 'display:none');
}
);
jQuery('.template_nodes').each(
function() {
if(jQuery(this).attr('style') != undefined)
jQuery(this).attr('style', 'display:none');
}
);
}
// Template has this action. Not needed in first login wizard
firstlogin.prototype.showNodeOptions = function() {
}
/*
* Create the dialog
*/
var showForm = function() {
var holder = "<div id='firstlogin'></div>";
jQuery("#pageBody").append(holder); // Append to current dashboard
var mask = "<div id='mask'></div>";
jQuery("#firstlogin").append(mask); // Append to current dashboard
var dialog = '<div id="boxes"><div id="dialog" class="window"></div></div>';
jQuery("#firstlogin").append(dialog); // Append to current dashboard
createModal();
var address = "setup/firstlogin/index.php";
getUrl(address, "dialog"); // Pull in existing wizard
}
var createModal = function() {
//Get the tag
var id = "#dialog";
//Get the screen height and width
var maskHeight = jQuery(document).height();
var maskWidth = jQuery(window).width();
//Set heigth and width to mask to fill up the whole screen
jQuery('#mask').css({'width':maskWidth,'height':maskHeight});
//transition effect
jQuery('#mask').fadeIn(1000);
jQuery('#mask').fadeTo("slow",0.8);
//Get the window height and width
var winH = jQuery(window).height();
var winW = jQuery(window).width();
//Set the popup window to center
jQuery(id).css('top', 0);
jQuery(id).css('left', 50);
jQuery(id).css('background', 'transparent');
//transition effect
jQuery(id).fadeIn(2000);
}
// Send request and update a div
var getUrl = function (address, div) {
jQuery.ajax({
url: address,
dataType: "HTML",
type: "POST",
cache: false,
success: function(data) {
if(div != "" || div != undefined || div != 'none') {
jQuery("#"+div).empty();
jQuery("#"+div).append(data);
}
}
});
}
/*
* Close the popup
*/
firstlogin.prototype.closeFirstLogin = function () {
jQuery('#mask').remove();
jQuery('.window').remove();
}
// Node clicked
firstlogin.prototype.nodeAction = function(updateContentDiv, updateDiv, address) {
var className = jQuery("#"+updateDiv).attr('class');
state = className.split(' ');
if(state[2] == 'closed') {
getUrl(address, updateContentDiv);
jQuery("#"+updateDiv).attr('class', 'tree_icon tree_folder open'); // Replace the closed class name to open
} else {
jQuery("#"+updateContentDiv).empty(); // Empty out that tree.
jQuery("#"+updateDiv).attr('class', 'tree_icon tree_folder closed'); // Replace the opened class name to close
}
}
firstlogin.prototype.getRootUrl = function() {
return this.rootUrl;
}
firstlogin.prototype.sendFirstLoginForm = function() {
var templateId = jQuery("#selectedTemplate").val();
var action = jQuery("#step_name_templates").attr('action');
var address = this.rootUrl + "setup/firstlogin/" + action + "&templateId=" + templateId + "&Next=Next";
getUrl(address, 'dialog');
}
firstlogin.prototype.postComplete = function() {
var address = this.rootUrl + "setup/firstlogin/index.php?step_name=complete&Next=Next";
getUrl(address, "none");
}