1 var BaculaConfigClass = jQuery.klass({
2 show_item: function(element, show) {
5 if (show === true && el.is(':visible') === false) {
6 el.slideDown({duration: 400});
7 } else if (show === false && el.is(':visible') === true) {
8 el.slideUp({duration: 500});
11 show_items: function(selector, show) {
12 $(selector).each(function(index, el) {
13 this.show_item(el, show);
16 show_new_config: function(sender, component_type, component_name, resource_type) {
17 var container = $('div.config_directives[rel="' + sender + '"]');
18 var h2 = container.find('h2');
19 var text = h2[0].getAttribute('rel');
20 text = text.replace('%component_type', component_type);
21 text = text.replace('%component_name', component_name);
22 text = text.replace('%resource_type', resource_type);
23 h2[0].textContent = text;
24 container.find('div.config_directives').show();
25 this.show_item(container, true);
26 this.scroll_to_element(container);
28 scroll_to_element: function(selector) {
29 $('html,body').animate({scrollTop: $(selector).offset().top}, 'slow');
31 get_child_container: function(sender) {
32 var child_container = $('#' + sender).closest('table').next('div');
33 return child_container;
35 get_element_sender: function(el) {
36 var element_sender = el.closest('table').prev('a');
37 return element_sender;
39 set_config_items(id) {
40 var child_container = this.get_child_container(id);
41 var show = !child_container.is(':visible');
42 this.show_item(child_container, show);
45 unset_config_items: function(id) {
46 var child_container = this.get_child_container(id);
47 var selector = [child_container[0].nodeName.toLowerCase(), child_container[0].className].join('.');
48 this.show_items(selector, false);
50 * Send request about items only if items are invisible to avoid
51 * asking about items when they are visible already.
53 var send = !child_container.is(':visible');
56 get_loader: function(id) {
57 var loader = $('#' + id).next('img');
60 loader_start: function(id) {
61 var loader = this.get_loader(id);
64 loader_stop: function(id) {
65 var loader = this.get_loader(id);
70 var BaculaConfigOptionsClass = jQuery.klass({
72 options_container: 'directive_setting'
76 initialize: function(opts) {
77 if (opts.hasOwnProperty('options_id')) {
78 this.options_id = opts.options_id;
80 if (opts.hasOwnProperty('action_obj')) {
81 this.action_obj = opts.action_obj;
85 set_events: function() {
86 var element = document.getElementById(this.options_id);
87 var opts = element.getElementsByTagName('LI');
88 for (var i = 0; i < opts.length; i++) {
89 opts[i].addEventListener('click', function(e) {
90 var el = e.srcElement || e.target;
91 var action = el.getAttribute('rel');
92 this.do_action(action);
96 get_options: function() {
99 do_action: function(param) {
100 if (typeof(this.action_obj) === "object") {
101 this.action_obj.setCallbackParameter(param);
102 this.action_obj.dispatch();
107 var BaculaConfig = new BaculaConfigClass();