firstlogin.js
3.32 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
// Class First Login
//TODO : Plugin path in js
var ktfolderAccess = "../../plugins/commercial/folder-templates/KTFolderTemplates.php?action=";
var ktmanageFolderAccess = "admin.php?kt_path_info=misc/adminfoldertemplatesmanagement&action=";
$(function() { // Document is ready
if($("#wrapper").attr('class') != 'wizard') {// Check if we in a wizard, or on the dashboard
showForm(); // Display first login wizard
}
});
function firstlogin(rootUrl) {
this.ktfolderAccess = rootUrl + "plugins/commercial/folder-templates/KTFolderTemplates.php?action=";
this.ktmanageFolderAccess = rootUrl + "admin.php?kt_path_info=misc/adminfoldertemplatesmanagement&action=";
this.ajaxOn = false;
}
firstlogin.prototype.showFolderTemplateTree = function(templateId) {
this.hideFolderTemplateTrees();
$('#template_' + templateId).attr('style', 'display:block'); // Show template
$('#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.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() {
$('.templates').each(
function() {
$(this).attr('style', 'display:none');
}
);
$('.template_nodes').each(
function() {
$(this).attr('style', 'display:none');
}
);
}
firstlogin.prototype.showNodeOptions = function() {
}
/*
* Create the dialog
*/
var showForm = function() {
createForm(); // Populate the form
this.win = new Ext.Window({ // create the window
applyTo : 'firstlogin',
layout : 'fit',
width : 800,
height : 500,
closeAction :'destroy',
y : 75,
shadow: false,
modal: true
});
this.win.show();
}
var createForm = function() {
var holder = "<div id='firstlogin'></div>";
$("#wrapper").append(holder); // Append to current dashboard
var address = "setup/firstlogin/index.php";
getUrl(address, "firstlogin"); // Pull in existing wizard
}
// Send request and update a div
var getUrl = function (address, div) {
$.ajax({
url: address,
dataType: "html",
type: "POST",
cache: false,
success: function(data) {
$("#"+div).empty();
$("#"+div).append(data);
}
});
}
// Node clicked
firstlogin.prototype.nodeAction = function(updateContentDiv, updateDiv, address) {
var className = $("#"+updateDiv).attr('class');
state = className.split(' ');
if(state[2] == 'closed') {
getUrl(address, updateContentDiv);
$("#"+updateDiv).attr('class', 'tree_icon tree_folder open'); // Replace the closed class name to open
} else {
$("#"+updateContentDiv).empty(); // Empty out that tree.
$("#"+updateDiv).attr('class', 'tree_icon tree_folder closed'); // Replace the opened class name to close
}
}