1 var BaculaConfigClass = jQuery.klass({
2 show_item: function(element, show, after_finish) {
5 if (show === true && el.is(':visible') === false) {
6 el.slideDown({duration: 400, complete: after_finish});
7 } else if (show === false && el.is(':visible') === true) {
8 el.slideUp({duration: 500, complete: after_finish});
11 show_items: function(selector, show, callback) {
12 $(selector).each(function(index, el) {
16 this.show_item(el, show, cb);
19 show_new_config: function(sender, component_type, component_name, resource_type) {
20 var container = $('div.config_directives[rel="' + sender + '"]');
21 var h2 = container.find('h2');
22 var text = h2[0].getAttribute('rel');
23 text = text.replace('%component_type', component_type);
24 text = text.replace('%component_name', component_name);
25 text = text.replace('%resource_type', resource_type);
26 h2[0].textContent = text;
27 container.find('div.config_directives').show();
28 this.show_item(container, true);
29 this.scroll_to_element(container);
31 scroll_to_element: function(selector) {
32 $('html,body').animate({scrollTop: $(selector).offset().top}, 'slow');
34 get_child_container: function(sender) {
35 var child_container = $('#' + sender).closest('table').next('div');
36 return child_container;
38 get_element_sender: function(el) {
39 var element_sender = el.closest('table').prev('a');
40 return element_sender;
42 set_config_items: function(id) {
43 var child_container = this.get_child_container(id);
44 var show = !child_container.is(':visible');
45 this.show_item(child_container, show);
48 unset_config_items: function(id) {
49 var child_container = this.get_child_container(id);
50 var selector = [child_container[0].nodeName.toLowerCase(), child_container[0].className].join('.');
51 var callback = function(el) {
52 if (el.style.display === 'none' && !el.classList.contains('new_resource')) {
54 var divs = el.getElementsByTagName('DIV');
55 if (divs.length > 0) {
57 // clear by removing elements
58 while (fc.firstChild) {
59 fc.removeChild(fc.firstChild);
64 this.show_items(selector, false, callback);
66 * Send request about items only if items are invisible to avoid
67 * asking about items when they are visible already.
69 var send = !child_container.is(':visible');
72 get_loader: function(id) {
73 var loader = $('#' + id).next('img');
76 loader_start: function(id) {
77 var loader = this.get_loader(id);
80 loader_stop: function(id) {
81 var loader = this.get_loader(id);
86 var BaculaConfigOptionsClass = jQuery.klass({
88 options_container: 'directive_setting'
92 initialize: function(opts) {
93 if (opts.hasOwnProperty('options_id')) {
94 this.options_id = opts.options_id;
96 if (opts.hasOwnProperty('action_obj')) {
97 this.action_obj = opts.action_obj;
101 set_events: function() {
102 var element = document.getElementById(this.options_id);
103 var opts = element.getElementsByTagName('LI');
104 for (var i = 0; i < opts.length; i++) {
105 opts[i].addEventListener('click', function(e) {
106 var el = e.srcElement || e.target;
107 var action = el.getAttribute('rel');
108 this.do_action(action);
112 get_options: function() {
115 do_action: function(param) {
116 if (typeof(this.action_obj) === "object") {
117 this.action_obj.setCallbackParameter(param);
118 this.action_obj.dispatch();
123 var BaculaConfig = new BaculaConfigClass();