help.min.js
3.38 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
/**
* @package JCE
* @copyright Copyright (c) 2009-2020 Ryan Demmer. All rights reserved.
* @license GNU/GPL 2 or later - http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
* JCE is free software. This version may have been modified pursuant
* to the GNU General Public License, and as distributed it includes or
* is derivative of works licensed under the GNU General Public License or
* other free or open source software licenses.
*/
(function ($) {
var Wf = {};
Wf.Help = {
options: {
url: '',
key: [],
pattern: ''
},
init: function (options) {
var key, id, n, self = this;
this.options = $.extend(this.options, options);
$('#help-menu > li[id]').click(function (e) {
$('#help-menu').find('li').removeClass('loading').removeClass('active');
var el = this;
if (e.target.nodeName !== "LI") {
el = e.target.parentNode;
}
$(el).siblings().children('ul').addClass('hidden');
$(el).addClass('active').children('ul').removeClass('hidden');
if (!el.id && $(el).hasClass('subtopics')) {
el = $(el).find('li[id]').first();
}
self.loadItem(el);
});
$('#help-iframe').on('load', function () {
$('.loading', '#help-menu').removeClass('loading');
});
key = this.options.key;
// no key, or does not exist, click first menu item
if (!key.length || !$('#' + key.join('.')).length) {
$('#help-menu > li[id]').first().click();
} else {
$('#' + key.join('.')).click();
}
$('[data-toggle]').click(function () {
var n = this;
$('nav').toggle();
// resize frame
self.resizeFrame();
});
},
resizeFrame: function () {
var self = this,
s;
$('#help-frame').parent().css('width', function () {
if ($("#help-menu-toggle div.toggle-handle").hasClass('collapsed')) {
s = $("#help-menu-toggle").outerWidth(true);
}
return $('div.row-fluid').width() - self.getMenuSize(s) - 1;
});
},
getMenuSize: function (pos) {
if (typeof pos == 'undefined') {
pos = $('#help-menu').parent().outerWidth() + 14;
}
return pos;
},
loadItem: function (el) {
var s = '', keys, pattern;
$(el).addClass('loading');
var id = $(el).attr('id');
if (this.options.pattern) {
keys = id.split('.');
pattern = this.options.pattern;
s = pattern.replace(/\$([1-9])/g, function (a, b) {
var key = parseInt(b), key = Math.max(key - 1, 0);
return keys[key] || '';
});
// trim slashes and add slash
s = '/' + s.replace(/^\//, '').replace(/\/$/, '');
} else {
s = id;
}
$('#help-iframe').attr('src', this.options.url + s);
}
}
window.Wf = Wf;
})(jQuery);