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

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

Complexity

Total Complexity 5
Complexity/F 1.25

Size

Lines of Code 30
Function Count 4

Duplication

Duplicated Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
wmc 5
eloc 11
c 0
b 0
f 0
dl 0
loc 30
rs 10
mnd 1
bc 1
fnc 4
bpm 0.25
cpm 1.25
noi 0
1
/**
2
 * File: external-content-admin.js
3
 */
4
(function($) {
5
6
	$.entwine('ss', function($){
7
		/**
8
		 * Name
9
		 */
10
		$('.cms-edit-form input[name=Name]').entwine({
11
			onchange: function() {
12
				this.updateTreeLabel(this.val());
13
			},
14
15
			/**
16
			 * Function: updateTreeLabel
17
			 *
18
			 * Update the tree
19
			 * (String) title
20
			 */
21
			updateTreeLabel: function(title) {
22
				var id = $('.cms-edit-form input[name=ID]').val();
23
24
				// only update immediate text element, we don't want to update all the nested ones
25
				var treeItem = $('.item:first', $('.cms-tree').find("[data-id='" + id + "']"));
26
				if (title && title != "") {
27
					treeItem.text(title);
28
				}
29
			}
30
31
		});
32
	});
33
}(jQuery));
34