forked from ding2/ting_search
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathting_search_extendform.js
82 lines (69 loc) · 2.18 KB
/
ting_search_extendform.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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
(function($) {
$(document).ready(function() {
Drupal.setSelectedLabel();
Drupal.extendedQueryDisplay();
});
$.TingExtendedForm = {};
$.TingExtendedForm.showExtended = false;
Drupal.behaviors.clearExtendForm = {
attach:function(context, settings) {
$('#extend-form-clear', context).click(function() {
$("#edit-creator").val('');
$("#edit-title").val('');
$("#edit-subject").val('');
$("#edit-search-block-form--2").val('');
return false;
});
}
};
Drupal.behaviors.readyExtendedForm = {
// If there's no 'Show advanced search' link, set display: block.
attach: function(context, settings) {
$('#extend-form', context).ready(function() {
if (!$('#extend-form-show')) {
$("#search-extend-form").addClass('extend-form-show');
}
});
}
};
Drupal.behaviors.clearExtendForm = {
attach:function(context, settings) {
$('#extend-form-clear', context).click(function() {
$("#edit-creator").val('');
$("#edit-title").val('');
$("#edit-subject").val('');
$("#edit-search-block-form--2").val('');
return false;
});
}
};
Drupal.behaviors.toggleSort = {
attach: function(context, settings) {
$('#edit-sort').change(function() {
$('#ting-search-sort-form').trigger("submit");
});
}
};
Drupal.setSelectedLabel = function() {
$('.form-item-size').find('label').removeClass('labelSelected');
$('input[name=size]').filter(':checked').parent().find('label').addClass('labelSelected');
};
Drupal.extendedQueryDisplay = function() {
var queryText = $("input").filter("[name='search_block_form']").val()
var parts = [];
if (queryText) {
parts.push(queryText);
}
var val;
var label;
$('#edit-advanced .form-item').each(function (i, elem) {
if ((val = $('input', elem).val()) && (label = $('label', elem).text())) {
parts.push(label + " = " + val);
console.dir(parts);
}
});
if (parts.length > 0) {
$('#search-query-string').text(parts.join(Drupal.t(" AND ")));
}
};
} (jQuery));