-
Notifications
You must be signed in to change notification settings - Fork 2
/
advanced-search-dialog-builder.js
executable file
·51 lines (40 loc) · 1.65 KB
/
advanced-search-dialog-builder.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
43
44
45
46
47
48
49
50
51
define(["handlebars", "underscore", "jquery-ui"], function (Handlebars, _, jqueryUi) {
"use strict";
var leftFieldsetTemplateId = "advanced-search-person-dialog-left-fieldset-template",
rightFieldsetTemplateId = "advanced-search-person-dialog-right-fieldset-template",
dialogHolderId = "advanced-search-dialog-content",
dialogTemplateId = "advanced-search-dialog-template";
var AdvancedSearchDialogBuilder = function() {};
// PUBLIC
AdvancedSearchDialogBuilder.prototype.createDialog = function (dialogOptions) {
var dialog;
$("#" + dialogHolderId).empty().append(compileTemplate(dialogTemplateId)());
dialog = $("#" + dialogHolderId).dialog(dialogOptions);
setupSearchFields();
return dialog;
};
// PRIVATE
var setupSearchFields = function () {
setupLeftFieldset();
setupRightFieldset();
},
compileTemplate = function(templateId) {
var source = _.isString(templateId) ? $('#' + templateId).html() : $(templateId).html();
if (!source) {
console.error('Hittar inte template: ', templateId);
return;
}
return Handlebars.compile(source);
},
setupLeftFieldset = function () {
$("#advanced-search-dialog-left-fieldset").append(
compileTemplate(leftFieldsetTemplateId)({})
);
},
setupRightFieldset = function () {
$("#advanced-search-dialog-right-fieldset").append(
compileTemplate(rightFieldsetTemplateId)({})
);
};
return AdvancedSearchDialogBuilder;
});