PageSourceSearch

https://www.boonton.org/common/modules/LiveEdit.js

js boonton.org collected 2026-10-03 00:10:34 UTC 14,605 bytes, 433 lines download raw bytes

1/// <reference name="MicrosoftAjax.js" />
2/// <reference name="Util.js" />
3/// <reference path="../GlobalJSFunctionsDetail.js" />
4
5var loadOrAjaxUpdate = function() {
6	// Allow menu spawning after an AJAX request completes.
7	blockMenuSpawn = false;
8
9	// Update cookie caches.
10	showAddDetails = getCookieValue('showAddDetails');
11	showToolTip = getCookieValue('showToolTip');
12	showLiveEditControls = getCookieValue('showLiveEditControls');
13	previousKAMControl = null;
14
15	// Force boolean, handle NULL cookies.
16	showAddDetails = (showAddDetails == null ? false : (showAddDetails == 'true'));
17	showLiveEditControls = (showLiveEditControls == null ? false : (showLiveEditControls == 'true'));
18	showToolTip = (showToolTip == null ? true : (showToolTip == 'true'));
19}
20
21// Constants below are documented in the enumerations
22// present in the CivicPlus.CMS.Library.Common.Enums namespace.
23
24// See this page a good resource on JScript intellisense.
25// http://skysanders.net/subtext/archive/2010/02/22/visual-studio-javascript-intellisense-uncovered.aspx
26
27// Status range constants. A status that falls within a range belongs to that range.
28// e.g. SUBMITTED is 14, therefore is a DRAFT-type status code.
29var MIN_DRAFT = 10;
30var MAX_DRAFT = 19;
31var MIN_PUBLISHED = 20;
32var MAX_PUBLISHED = 40;
33var MIN_DELETED = 0;
34var MAX_DELETED = 9;
35
36// Specific status constants.
37var DRAFT = 10;
38var DRAFT_EXPIRED = 11;
39var DRAFT_PENDING = 12;
40var PUBLISHED = 40;
41var PUBLISHED_EXPIRED = 20;
42var PUBLISHED_PENDING = 21;
43var SUBMITTED = 14;
44var REJECTED = 13;
45
46// Rights constants.
47var VIEW = 1; // Public
48var READONLY = 2; // Admin Interface
49var AUTHOR = 3;
50var PUBLISHER = 4;
51var OWNER = 5;
52
53var showToolTip = false;
54var previousKAMControl = null;
55
56// Fade-out for live edit menus.
57function liveEditHideMenu(elem, callback) {
58	elem.style.display = 'none';
59	callback();
60	return;
61	/*
62		// Uncomment to introduce fade effect.
63		// Method only called in Alert Center currently.
64		// Would need to be retroactively added to other modules.
65
66		if (elem.style.display == 'none')
67			callback();
68		else {
69			var elemParentJQ = $(elem.parentNode);
70		
71			elemParentJQ.fadeOut(300, 'linear', function () {
72				elem.style.display = 'none';
73				elemParentJQ.fadeTo(1);
74				callback();
75			});
76		}
77	*/
78}
79
80function cancelFE(needsConfirm) {
81	if (!confirm("You will discard any unsaved changes. Do you want to proceed?"))
82		return;
83	window.parent.closeModalDialog('editItemBehavior');
84	return false;
85}
86
87function redrawContent(closeModal) {
88	if (closeModal)
89		closeModalDialog('editItemBehavior');
90	window.location = window.location.href;
91}
92
93function raiseAsyncPostback(updatePanelID, itemID, closePopUp) {
94	if (closePopUp)
95		closeModalDialog('editItemBehavior');
96	__doPostBack(updatePanelID, itemID);
97}
98
99function showHideAdditionalDetails(id, minHeight, maxHeight) {
100	var item = document.getElementById(id);
101	if (item.style.display == 'block') {
102		item.style.display = 'none';
103		document.getElementById("a_" + id).innerHTML = '&#9658;&nbsp;Show Additional Details';
104
105		showAddDetails = false;
106		document.cookie = "showAddDetails=false; path=/";
107
108		window.parent.changeModalDialogHeight(minHeight, 'false');
109	}
110	else {
111		item.style.display = 'block';
112		document.getElementById("a_" + id).innerHTML = '&#9660;&nbsp;Hide Additional Details';
113
114		showAddDetails = true;
115		document.cookie = "showAddDetails=true; path=/";
116
117		window.parent.changeModalDialogHeight(maxHeight, 'true');
118	}
119}
120
121function SaveAndSendFE(title, startDate) {
122	document.getElementById('AutoNotifyMe').style.display = 'block';
123	document.getElementById('itemcontent').style.display = 'none';
124
125	var curDate = new Date();
126	if(startDate != '')
127		var startDate = new Date(startDate);
128	if (startDate > curDate) {
129		document.getElementById('pending').style.visibility = 'visible';
130		document.getElementById('noPending').style.visibility = 'hidden';
131	}
132	else {
133		document.getElementById('pending').style.visibility = 'hidden';
134		document.getElementById('noPending').style.visibility = 'visible';
135	}
136
137	if (document.getElementById('ShowSMS').value == "0") {
138        document.getElementById('txtMsgMobileLabel').style.visibility = 'hidden';
139        document.getElementById('txtMsgMobile').style.visibility = 'hidden';
140        document.getElementById('txtMsgMobileCounter').style.visibility = 'hidden';
141    }
142	else {
143	    var elem = document.getElementById(title);
144	    if (elem) {
145	        document.getElementById('txtMsgMobile').value = elem.value;
146	    }
147	}
148	var height = 350;
149	window.parent.changeModalDialogHeight(height, '');
150	return false;
151}
152
153function cancelFE(needsConfirm) {
154	if (!confirm("You will discard any unsaved changes. Do you want to proceed?"))
155		return;
156	window.parent.closeModalDialog('editItemBehavior');
157	return false;
158}
159
160function CancelSaveAndSendFE(height) {
161	document.getElementById('AutoNotifyMe').style.display = 'none';
162	document.getElementById('itemcontent').style.display = 'block';
163	//window.parent.changeModalDialogHeight(height, '');
164	window.parent.setModalClassForEditItemBehavior('liveEdit', '');
165	return false;
166}
167//this is a temp fix for calendar because kyle has moved the code to modal.css file and now he is going reference
168// each modal by its own name - AK
169function CancelSaveAndSendCalendarFE(height) {
170	document.getElementById('AutoNotifyMe').style.display = 'none';
171	document.getElementById('itemcontent').style.display = 'block';
172	//window.parent.changeModalDialogHeight(height, '');
173	window.parent.setModalClassForEditItemBehavior('liveEdit calendar', '');
174	return false;
175}
176
177function publishItemFE(ysnSend, ysnSendAtStart, ysnSendBeforeDays, frmBAF, from, ItemId, updatePanelID, draftPublish) {
178	if (frmBAF.ysnSaveFE == undefined) {
179		var tempElem = document.createElement('input');
180		tempElem.name = 'ysnSaveFE';
181		tempElem.defaultValue = 1;
182		tempElem.value = 1;
183		tempElem.setAttribute('hidden', true);
184		frmBAF.appendChild(tempElem);
185	}
186	else
187		frmBAF.ysnSaveFE.value = 1;
188
189	if (frmBAF.ysnSend == undefined) {
190		var tempElem = document.createElement('input');
191		tempElem.name = 'ysnSend';
192		tempElem.defaultValue = ysnSend;
193		tempElem.value = ysnSend;
194		tempElem.setAttribute('hidden', true);
195		frmBAF.appendChild(tempElem);
196	}
197	else
198		frmBAF.ysnSend.value = ysnSend;
199
200	if (frmBAF.ysnSendAtStart == undefined) {
201		var tempElem = document.createElement('input');
202		tempElem.name = 'ysnSendAtStart';
203		tempElem.defaultValue = ysnSendAtStart;
204		tempElem.value = ysnSendAtStart;
205		tempElem.setAttribute('hidden', true);
206		frmBAF.appendChild(tempElem);
207	}
208	else
209		frmBAF.ysnSendAtStart.value = ysnSendAtStart;
210
211	if (frmBAF.ysnSendBeforeDays == undefined) {
212		var tempElem = document.createElement('input');
213		tempElem.name = 'ysnSendBeforeDays';
214		tempElem.defaultValue = ysnSendBeforeDays;
215		tempElem.value = ysnSendBeforeDays;
216		tempElem.setAttribute('hidden', true);
217		frmBAF.appendChild(tempElem);
218	}
219	else
220		frmBAF.ysnSendBeforeDays.value = ysnSendBeforeDays;
221
222	switch (from) {
223		case 'civicalerts':
224			if (frmBAF.curPage && frmBAF.curPage.value == 'CivicAlertForm') {
225				if (draftPublish)
226					window.parent.document.getElementsByName('strActionFE')[0].value = "CivicAlertItemPublish";
227				else {
228					frmBAF.ysnPublishDetail.value = 1;
229					frmBAF.submit();
230				}
231			}
232			else
233				frmBAF.strActionFE.value = "CivicAlertItemSave";
234			break;
235		case 'blog':
236		case 'blogs':
237			if (frmBAF.curPage && frmBAF.curPage.value == 'BlogItemForm') {
238				if (draftPublish)
239					window.parent.document.getElementsByName('strActionFE')[0].value = 'BlogItemPublish';
240				else
241					frmBAF.strActionFE.value = 'BlogItemPublish';
242			}
243			else
244				frmBAF.strActionFE.value = 'BlogItemSave';
245			break;
246		case 'calendar':
247			__doPostBack('ctl00$btnPublishFE', 'OnClick');
248			return true;
249			break;
250	}
251	if (from != 'calendar' && from != 'civicalerts')
252		window.parent.raiseAsyncPostback(updatePanelID, ItemId, 1);
253}
254
255function createAndSetNewModifiedToggleIfNeeded(frmMain, frmFQF) {
256    if (!frmFQF.newModifiedToggle.checked) {
257        return; // don't create a field for the toggle if it isn't even enabled.
258    }
259    var input = document.createElement("input");
260
261    input.setAttribute("type", "hidden");
262    input.setAttribute("name", "newModifiedToggle");
263    input.setAttribute("value", frmFQF.newModifiedToggle.value);
264
265    frmMain.appendChild(input);
266}
267
268function sendEmailFE(frmFQP, ysnRadioButtonSelected, from, ItemId, UpdatePanelId, draftPublish) {
269	var frmFQF;
270	var frmEmail;
271	var tempSMSComments;
272	var tempComments;
273	if (frmFQP == 'frmBlogItemForm' || frmFQP == 'frmAlertInfo') {
274		frmFQF = document.getElementById(frmFQP);
275		frmEmail = document.getElementById(frmFQP);
276	}
277	else if (from == 'calendar') {
278		frmFQF = document.aspnetForm;
279		frmEmail = document.getElementById(frmFQP);
280	}
281	else {
282		frmFQF = window.parent.document.getElementById(frmFQP);
283		frmEmail = document.frmSendEmail;
284	}
285
286	//createAndSetNewModifiedToggleIfNeeded(frmFQP, frmFQF);
287    
288	if (frmFQF.txtSMSComments == undefined) {
289		tempSMSComments = document.createElement('input');
290		tempSMSComments.name = 'txtSMSComments';
291		tempSMSComments.setAttribute('hidden', true);
292	}
293	if (frmFQF.txtComments == undefined) {
294		tempComments = document.createElement('input');
295		tempComments.name = 'txtComments';
296		tempComments.setAttribute('hidden', true);
297	}
298	if (document.getElementById('txtMsgMobile')) {
299		if (frmFQF.txtComments != undefined)
300			frmFQF.txtSMSComments.value = document.getElementById('txtMsgMobile').value;
301		else {
302			tempSMSComments.value = document.getElementById('txtMsgMobile').value;
303			tempSMSComments.defaultValue = document.getElementById('txtMsgMobile').value;
304			frmFQF.appendChild(tempSMSComments);
305		}
306	}
307	var send;
308	if (!ysnRadioButtonSelected)
309		publishItemFE(false, false, false, frmFQF, from,ItemId, UpdatePanelId, draftPublish);
310	else {
311		for (var i = 0; i < frmEmail.one.length; i++) {
312			if (frmEmail.one[i].checked) {
313				send = frmEmail.one[i].value;
314			}
315		}
316		if (send == "Send") {
317			if (frmFQF.txtComments != undefined)
318				frmFQF.txtComments.value = frmEmail.txtMsgComments.value;
319			else {
320				tempComments.value = frmEmail.txtMsgComments.value;
321				tempComments.defaultValue = frmEmail.txtMsgComments.value;
322				frmFQF.appendChild(tempComments);
323			}	
324			publishItemFE(true, false, false, frmFQF, from, ItemId, UpdatePanelId, draftPublish);
325		}
326		else if (send == "SendAtStart") {
327			frmFQF.txtComments.value = frmEmail.txtMsgComments.value;
328			publishItemFE(false, true, false, frmFQF, from, ItemId, UpdatePanelId, draftPublish);
329		}
330		else if (send == "SendBeforeDays") {
331			var userValue = frmEmail.numDays.value;
332			if (validNumber(userValue)) {
333				frmFQF.txtComments.value = frmEmail.txtMsgComments.value;
334				frmFQF.intSendBeforeDays.value = frmEmail.numDays.value;
335				publishItemFE(false, false, true, frmFQF, from, ItemId, UpdatePanelId, draftPublish);
336			}
337			else if (userValue == '') {
338				alert('The number of days before the event was not specified.');
339			}
340			else {
341				alert('An invalid value was entered for the number of days. Please enter a valid value.');
342			}
343		}
344		else {
345			alert('A send time must be selected.');
346			return false;
347	}
348}
349	return true;
350}
351
352// ==== NEW CODE BELOW =====
353// TODO: Document what this stuff does. Arguments, methods, etc.
354
355// Method exists for MSIE. Finds container to apply z-index changes to.
356function resolveLiveEditContainer(liveEditControlElem) {
357	var parentContainer = liveEditControlElem.parentNode;
358
359	if (parentContainer) {
360		if (parentContainer.parentNode && parentContainer.parentNode.tagName == 'TD' && parentContainer.parentNode.parentNode && parentContainer.parentNode.parentNode.tagName == 'TR') {
361			parentContainer = parentContainer.parentNode.parentNode;
362		}
363	}
364
365	return parentContainer;
366}
367
368// Semi-replaces moreActionsCategory()
369function liveEditCommonCategory(catElem, toolTipElem, menuElem, liveEditControlElem, insideDiv) {
370	if (catElem)
371		catElem.style.zIndex = 2;
372
373	liveEditCommonItem(toolTipElem, menuElem, liveEditControlElem,insideDiv,true);
374}
375function findPos(obj) {
376	var curleft = curtop = 0;
377	if (obj.offsetParent) {
378		do {
379			curleft += obj.offsetLeft;
380			curtop += obj.offsetTop;
381		} while (obj = obj.offsetParent);
382	}
383	return curleft;
384}
385// Semi-replaces moreActions()
386function liveEditCommonItem(toolTipElem, menuElem, liveEditControlElem, insideDiv, isCategoryMenu) {
387	// logic for shifting the KAM menus to left if there isn't space on the right side.
388	var moreActionsDiv = document.getElementById(insideDiv);
389	var hasMoveClass = liveEditControlElem.className.indexOf('move') > -1;
390	//get the element distance from right
391	var leftpos = findPos(liveEditControlElem.parentNode);
392	if (isCategoryMenu) {
393		if (document.body.scrollWidth - leftpos < 132) {
394			liveEditControlElem.className = liveEditControlElem.className.replace(/liveEditControl/, 'liveEditControl flipH');
395			moreActionsDiv.style.left = moreActionsDiv.style.width - 31 + 'px';
396		}
397		else {
398			liveEditControlElem.className = liveEditControlElem.className.replace(/liveEditControl flipH/, 'liveEditControl');
399			moreActionsDiv.style.left = '0px';
400		}
401	}
402	else {
403		if (document.body.scrollWidth - leftpos < 327) {
404			liveEditControlElem.className = liveEditControlElem.className.replace(/liveEditControl/, 'liveEditControl flipH');
405			moreActionsDiv.style.left = moreActionsDiv.style.width - (!hasMoveClass ? 234 : 281) + 'px';
406		}
407		else {
408			liveEditControlElem.className = liveEditControlElem.className.replace(/liveEditControl flipH/, 'liveEditControl');
409			moreActionsDiv.style.left = '0px';
410		}
411	}
412	//	logic for shifting the KAM menus to left if there isn't space on the right side ends
413
414	if (window.showToolTip) {
415		if (window.toolTipElem)
416			toolTipElem.style.display = 'none';
417		showToolTip = false;
418		document.cookie = "showToolTip=false; path=/";
419	}
420
421	if (menuElem.style.display == 'none') {
422		// HACK: Fix for Z-Index Issue in MSIE.
423		liveEditControlElem.style.position = 'relative';
424		liveEditControlElem.style.position = 'absolute';
425		liveEditControlElem.style.width = '400px';
426		menuElem.style.display = 'block';
427	}
428	else
429		menuElem.style.display = 'none';
430
431	liveEditControlElem.appendChild(menuElem);
432	liveEditControlElem.appendChild(toolTipElem);
433}

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.