PageSourceSearch

https://collectie.hetnoordbrabantsmuseum.nl/Scripts/Base/RecordSelection.js

js hetnoordbrabantsmuseum.nl collected 2026-10-02 04:27:20 UTC 5,563 bytes, 176 lines download raw bytes

1AIS.RecordSelection = function () {
2
3  var functions = {};
4
5  functions.GetSelectorsByState = function (state) { return $(document).find(".record-selector[data-selected='" + state + "']"); };
6
7  functions.SelectionCounter = function () { return $("#ais-menu-inner #ais-menu-list #menuSelection .ais-menu-item-tip-element"); };
8
9  functions.SetSelector = function (selector, state) {
10    var selectorState = $(selector).attr("data-selected");
11    if (selectorState !== state) {
12      var count = functions.GetSelectionCounter();
13      if (state === "true") {
14        functions.SetSelectionCounter(++count);
15      }
16      else {
17        if (count > 0) {
18          functions.SetSelectionCounter(--count);
19        }
20        else return;
21      }
22      $(selector).attr("data-selected", state);
23      $(selector).children(".remove-selection-button").toggle();
24      $(selector).children(".add-selection-button").toggle();
25
26    };
27  };
28
29  functions.SetSelectors = function (selectors, state) {
30    $(selectors).each(function () {
31      functions.SetSelector(this, state);
32    });
33  };
34
35  functions.SelectAll = function () {
36    $.ajax({
37      url: AIS.Helpers.ResolveUrl("results/selectall"),
38      data: {},
39      success: function (data) {
40        if (data.Success === false) {
41          if (data.Message) { AIS.Helpers.AddTempWarningUserMessage(data.Message, false); }
42        }
43        else {
44          var unchecked = functions.GetSelectorsByState("false");
45          functions.SetSelectors(unchecked, "true");
46          functions.SetSelectionCounter(data.SelectionCounter);
47        }
48      }
49    });
50  };
51
52  functions.InvertSelection = function () {
53    $.ajax({
54      url: AIS.Helpers.ResolveUrl("results/invertselection"),
55      data: {},
56      success: function (data) {
57        if (data.Success === false) {
58          if (data.Message) { AIS.Helpers.AddTempWarningUserMessage(data.Message, false); }
59        }
60        else {
61          var selectorsToCheck = functions.GetSelectorsByState("false");
62          var selectorsToUncheck = functions.GetSelectorsByState("true");
63          functions.SetSelectors(selectorsToCheck, "true");
64          functions.SetSelectors(selectorsToUncheck, "false");
65          functions.SetSelectionCounter(data.SelectionCounter);
66        }
67      }
68    });
69  };
70
71  functions.ClearSelection = function () {
72    $.ajax({
73      url: AIS.Helpers.ResolveUrl("results/clearselection"),
74      data: {},
75      success: function (data) {
76        if (data.Success === false) {
77          if (data.Message) { AIS.Helpers.AddTempWarningUserMessage(data.Message, false); }
78        }
79        else {
80          var selected = functions.GetSelectorsByState("true");
81          functions.SetSelectors(selected, "false");
82          functions.SetSelectionCounter(0);
83        }
84      }
85    });
86  };
87
88  //Toggle selection menu item specifically
89  functions.EnableSelectionMenuItem = function () {
90    var items = $("#ais-menu-item-menuSelection a");
91    items.each(function () {
92      parent = $(this).parent();
93      //parent.removeClass("disabled");
94      $(this).parent().attr("class","ais-menu-item");
95      $(this).attr("href", $(this).parent().children("input.ais-hidden-href-value").val());
96    });
97  };
98  //disable the selection button in the menu (and the mobile version)
99  functions.DisableSelectionMenuItem = function () {
100    var items = $("#ais-menu-item-menuSelection a");
101    items.each(function () {
102      var parent = $(this).parent();
103      $(this).removeAttr("href");
104      parent.removeClass("active");
105      parent.addClass("disabled");
106    });
107  };
108
109  functions.AddToSelection = function (priref, database, sitename, record) {
110    $.ajax({
111      url: AIS.Helpers.ResolveUrl("results/addtoselection"),
112      data: {
113        priref: priref,
114        database: database,
115        sitename: sitename
116      },
117      success: function (data) {
118        if (data.Success === false) {
119          if (data.Message) {
120            AIS.Helpers.AddTempWarningUserMessage(data.Message, false);
121          }
122        }
123        else {
124          functions.SetSelector(record, "true");
125        }
126      }
127    });
128  };
129
130  functions.RemoveFromSelection = function (priref, database, sitename, record) {
131    $.ajax({
132      url: AIS.Helpers.ResolveUrl("results/removefromselection"),
133      data: {
134        priref: priref,
135        database: database,
136        sitename: sitename
137      },
138      success: function (data) {
139        if (data.Success === false) {
140          if (data.Message) { AIS.Helpers.AddTempWarningUserMessage(data.Message, false); }
141        }
142        else {
143          functions.SetSelector(record, "false");
144        }
145      }
146    });
147  };
148
149  functions.SetSelectionCounter = function (counter) {
150    var elements = functions.SelectionCounter();
151    if (counter != 0) {
152      elements.each(function () {
153        $(this).html(counter);
154        $(this).addClass("ais-menu-item-tip-border");
155        functions.EnableSelectionMenuItem();
156      });
157    }
158    else {
159      elements.each(function () {
160        $(this).html("");
161        $(this).removeClass("ais-menu-item-tip-border");
162        functions.DisableSelectionMenuItem();
163      });
164    }
165  };
166
167  functions.GetSelectionCounter = function () {
168    var counterHtml = functions.SelectionCounter().html();
169
170    if (counterHtml) {
171      return parseInt(counterHtml);
172    }
173    else { return 0; }
174  };
175  return functions;
176}();

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.