PageSourceSearch

https://www.timmins.ca/Common/controls/ContentItemModern/scripts/DisplaySettings.js

js timmins.ca collected 2026-10-02 10:59:39 UTC 9,551 bytes, 232 lines download raw bytes

1var ContentDispSettingsModule = function (parent, contextId) {
2    var contentItemData;
3    var displayModalWindow;
4    var commons = new ContentCommon();
5    var res = commons.Resources;
6
7    var settingsCtrlSel = "#displaySettingsSection";
8    var descriptionCol = settingsCtrlSel + " #descriptionCol";
9    var modifiedField = settingsCtrlSel + " #modifiedField";
10    var userField = settingsCtrlSel + " #userField";
11    var sizeField = settingsCtrlSel + " #sizeField";
12    var ddlSortBy = settingsCtrlSel + " #ddlSortBy";
13    var ddlSortAsc = settingsCtrlSel + " #ddlSortAsc";
14    var updateSettingsBtn = settingsCtrlSel + " #updateSettingsBtn";
15    var closeSettingsBtn = settingsCtrlSel + " #closeSettingsBtn";
16    var divDescriptionContent = settingsCtrlSel + " #descriptionContent";
17    var divHTMLDescription = settingsCtrlSel + " #divHTMLDescription";
18
19    var maxDefaultSize;
20    var quill;
21
22    var displayDescriptionAdminUI = false;
23
24    var setDataInForm = function () {
25        var focusTag = modifiedField;
26
27        if (contextId > 0) {
28
29            // Get display settings
30            $.when(contentItemData.GetDispSettings(contextId)).then(function (result) {
31                var resp = result.d;
32                if (resp.RequestStatus !== null && resp.RequestStatus.RequestError) {
33                    commons.ShowErrorMessage(resp.RequestStatus.RequestErrorMessage);
34                    displayModalWindow.closeModalWindow();
35                }
36                else {
37                    resp = result.d.DataObject.Settings;
38
39                    if (resp.DisplayDescriptionAdminUI) {
40                        $(divDescriptionContent).show();
41                        displayDescriptionAdminUI = true;
42                    }
43
44                    if (resp.HideDescription)
45                        $(descriptionCol).attr("checked", "checked");
46                    else
47                        $(descriptionCol).removeAttr("checked");
48
49                    if (resp.HideLastModifiedField)
50                        $(modifiedField).attr("checked", "checked");
51                    else
52                        $(modifiedField).removeAttr("checked");
53
54                    if (resp.HideUserField)
55                        $(userField).attr("checked", resp.HideUserField ? "checked" : "");
56                    else
57                        $(userField).removeAttr("checked");
58
59                    if (resp.HideSizeField)
60                        $(sizeField).attr("checked", resp.HideSizeField ? "checked" : "");
61                    else
62                        $(sizeField).removeAttr("checked");
63
64                    $(ddlSortBy).val(resp.SortBy);
65                    var select = $(ddlSortBy);
66                    select.find("option[value='" + resp.SortBy + "']").attr('selected', 'selected');
67
68                    var selectAsc = $(ddlSortAsc);
69                    if (resp.SortAsc) {
70                        $(ddlSortAsc).val("asc");
71                        selectAsc.find("option[value='asc']").attr('selected', 'selected');
72                    }
73                    else {
74                        $(ddlSortAsc).val("desc");
75                        selectAsc.find("option[value='desc']").attr('selected', 'selected');
76                    }
77
78                    maxDefaultSize = resp.MaximumSize;
79                }
80            });
81
82            // Get instance's description.
83            $.when(contentItemData.GetFolderDetail(contextId)).then(function (result) {
84                var resp = result.d;
85
86                if (resp.RequestStatus !== null && resp.RequestStatus.RequestError) {
87                    commons.ShowErrorMessage(resp.RequestStatus.RequestErrorMessage);
88                    displayModalWindow.closeModalWindow();
89                }
90                else {
91                    // Populate Description edit control with Description value. 
92                    var descriptionHTMLEditArea = $(divHTMLDescription);
93                    descriptionHTMLEditArea.html(result.d.DataObject.Description);
94                    focusTag = divHTMLDescription;
95
96                    // Add Quill HTML editor to the description textbox. 
97                    $('<link/>
97', { rel: 'stylesheet', href: '/Common/controls/QuillHTMLEditor/quill.snow.css' }).appendTo('head');
98                    $.getScript("/Common/controls/QuillHTMLEditor/quill.min.js", function () {
99                        quill = new Quill(
100                            divHTMLDescription,
101                            {
102                                bounds: divHTMLDescription,
103                                theme: 'snow',
104                                placeholder: 'placeholder'
105                            });
106                    });
107                    $(divHTMLDescription).css("font-weight", "normal");
108                }
109
110                var parentWidth = $(".PO-wrapper").width();
111                if (parentWidth >= 525) {
112                    displayModalWindow.openModalWindow(settingsCtrlSel, "displaySettingsSection", "Display Settings", 600, 525, null, true, true, parent, this);
113                }
114                else {
115                    displayModalWindow.openModalWindow(settingsCtrlSel, "displaySettingsSection", "Display Settings", parentWidth, 450, null, true, true, parent, this);
116                }
117
118                $(focusTag).focus();
119            });
120
121            return false;
122        }
123    };
124
125    var initialise = function () {
126        contentItemData = new ContentItemData(contextId);
127        displayModalWindow = new ContentItemModalWindow(contextId);
128        setDataInForm();
129        return false;
130    };
131
132    // Update button clicked.
133    $(updateSettingsBtn).off("click");
134
135    $(updateSettingsBtn).on("click", function (e) {
136        e.preventDefault();
137        var maxSize = maxDefaultSize;
138        var sort = $(ddlSortAsc).val() === "asc" ? true : false;
139        var hideDescript = $(descriptionCol).attr("checked") === "checked" ? true : false;
140
141        var updateSettings = {
142            "HideDescription": hideDescript,
143            "HideLastModifiedField": $(modifiedField).attr("checked") === "checked" ? true : false,
144            "HideUserField": $(userField).attr("checked") === "checked" ? true : false,
145            "HideSizeField": $(sizeField).attr("checked") === "checked" ? true : false,
146            "SortBy": $(ddlSortBy).val(),
147            "SortAsc": sort,
148            "MaximumSize": maxSize,
149            "ContextId": contextId
150        };
151
152        if (contextId <= 0) {
153            commons.ShowErrorMessage(res["Invalid"]);
154        }
155        else {
156            $.when(contentItemData.UpdateDispSettings(updateSettings)).then(function (result) {
157                var resp = result.d;
158                if (resp.RequestStatus !== null && resp.RequestStatus.RequestError) {
159                    commons.ShowErrorMessage(resp.RequestStatus.RequestErrorMessage);
160                }
161                else {
162                    var htmlText = quill.root.innerHTML;
163                    $.when(contentItemData.UpdateDescription(contextId, htmlText)).then(function (result) {
164                        resp = result.d;
165
166                        if (resp.RequestStatus !== null && resp.RequestStatus.RequestError) {
167                            commons.ShowErrorMessage(resp.RequestStatus.RequestErrorMessage);
168                        }
169                        else {
170                            commons.ShowUpdateMessage(res["DisplaySettingUpdate"].format(parent.RootObject.Name));
171                            displayModalWindow.closeModalWindow();
172
173                            if (displayDescriptionAdminUI) {
174                                var descDivSelector = parent.Container + " .PO-description";
175                                var descDiv = $(descDivSelector);
176                                if (htmlText !== "Document Container" && htmlText !== "<p>Document Container</p>" && descDiv) {
177                                    descDiv.html(htmlText);
178                                }
179                                else {
180                                    descDiv.html("");
181                                }
182                            }
183
184                            parent.SetHidDescription(hideDescript);
185                            parent.initialise();
186                        }
187                    });
188                }
189            });
190        }
191        return false;
192    });
193
194
195    //Close button event
196    $(closeSettingsBtn).off("click");
197
198    $(closeSettingsBtn).on("click", function (e) {
199        e.preventDefault();
200        displayModalWindow.closeModalWindow();
201        purge(this);
202        return false;
203    });
204
205    var distroy = function () {
206        purge(this);
207    };
208
209    var purge = function purge(obj) {
210        var att = obj.attributes, ind, len, nam;
211        if (att) {
212            for (ind = att.length - 1; ind >= 0; ind -= 1) {
213                nam = att[ind].name;
214                if (typeof obj[nam] === 'function') {
215                    obj[nam] = null;
216                }
217            }
218        }
219        att = obj.childNodes;
220        if (att) {
221            len = att.length;
222            for (ind = 0; ind < len; ind += 1) {
223                purge(obj.childNodes[ind]);
224            }
225        }
226    };
227
228    return {
229        Initialise: initialise,
230        Distroy: distroy
231    };
232};

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.