Test Failed
Push — master ( 357bf5...71cdad )
by Russell
03:53
created

external-content/javascript/external-content-reload.js   A

Complexity

Total Complexity 5
Complexity/F 1

Size

Lines of Code 27
Function Count 5

Duplication

Duplicated Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
wmc 5
eloc 14
c 0
b 0
f 0
dl 0
loc 27
rs 10
mnd 0
bc 0
fnc 5
bpm 0
cpm 1
noi 0
1
;(function($) {
2
	$.entwine('ss', function($) {
3
		$('.cms-container').entwine({
4
			submitForm: function(form, button, callback, ajaxOptions) {
5
				$('.ExternalContentAdmin #cms-content-tools-CMSMain').append("<div class='cms-content-loading-overlay ui-widget-overlay-light'></div><div class='cms-content-loading-spinner'></div>");
6
7
				// Trigger the default form submission.
8
9
				this._super(form, button, callback, ajaxOptions);
10
11
				// Wait a moment before the next AJAX call, otherwise some undefined behaviour may occur.
12
13
				setTimeout(function() {
14
15
					// Update the external sources view.
16
17
					$.ajax({
18
						url: $('base').prop('href') + 'admin/external-content/updateSources'
19
					}).done(function(data) {
20
						$('#cms-content-treeview').html(data);
21
						$('.ExternalContentAdmin #cms-content-tools-CMSMain .cms-content-loading-overlay, .ExternalContentAdmin #cms-content-tools-CMSMain .cms-content-loading-spinner').remove();
22
					});
23
				}, 1000);
24
			}
25
		});
26
	});
27
}(jQuery));
28