-
Notifications
You must be signed in to change notification settings - Fork 0
/
sample.js
42 lines (37 loc) · 1.01 KB
/
sample.js
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
function Sample($) {
var me = this,
// ordinarily we'd update the signature, but I want our past methods to still work without alteration
view = $;
me.init1 = function () {
$('#uxShowFieldset');
$.click(function () {
$('#uxFieldset');
});
$.toggle();
};
me.init2 = function () {
$('#uxShowFieldset').click(function () {
$('#uxFieldset').toggle();
})
};
// "on" is better than "click"
me.init2_method_refactor = function () {
$('#uxShowFieldset').on('click',function () {
$('#uxFieldset').toggle();
})
};
// refactor to be relative -- this refactor should be possible by adding greater precision with later tests and not refactoring existing tests
me.init2_selector_refactor = function () {
$('.fieldsetToggle:checkbox').click(function () {
$(this).nextAll('fieldset:first').toggle();
})
};
me.init3 = function () {
view.bindClick(
view.getCheckbox(),
function () {
view.toggleElement(view.getFieldset());
}
);
}
}