1 // This file contains functions for testing the label element.
4 var withParentLabel = 1;
5 var withSiblingLabel = 2;
6 var withSibling2Label = 4;
8 // Populate dom tree and returns test data.
9 function setupLabelsTest(labelRelation, preHtml, postHtml)
11 var html = '<div id="div1"></div><div id="div2">';
15 var dataSet = createFormControlDataSet();
17 for (var name in dataSet) {
18 var data = dataSet[name];
19 var id = data.name + '1';
22 if (labelRelation & withParentLabel)
25 if (labelRelation & withSiblingLabel) {
26 data.labelId = id + 'Label1';
27 html += '<label for=' + id + ' id=' + data.labelId + '></label>';
30 if (labelRelation & withSibling2Label) {
31 data.labelId2 = id + 'Label2';
32 html += '<label for=' + id + ' id=' + data.labelId2 + '></label>';
36 var typeName = data.inputType;
37 html += '<input type=' + typeName + ' id=' + id + '>';
39 var tagName = data.tagName;
40 html += '<' + tagName + ' id=' + id + '></' + tagName + '>';
43 if (labelRelation & withParentLabel)
52 var parent = document.createElement('div');
53 parent.innerHTML = html;
54 document.body.appendChild(parent);
56 for (var name in dataSet) {
57 var data = dataSet[name];
58 data.element = document.getElementById(data.id);
64 getLabelableElementData: function (name)
66 var data = dataSet[name];
67 return data && data.element.labels ? data : null;
70 outerElement: document.getElementById('div1'),
74 function mouseMoveToLabel(labelId) {
75 var label = document.getElementById(labelId);
76 var itemHeight = Math.floor(label.offsetHeight / label.size);
78 if (window.eventSender)
79 eventSender.mouseMoveTo(label.offsetLeft + offset, label.offsetTop + offset - window.pageYOffset);