nm3clol-express-app/public/Web_Site_Archives/scottcountyva.com-2024-05-17-16_43/scottcountyva/scottcountyva.com/-1946131557.js

1145 lines
37 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/*
The following errors were found when attempting to minify this file:
- Line 682: Parse error. Unsupported syntax: CONST
- Line 830: Parse error. IE8 (and below) will parse trailing commas in array and object literals incorrectly. If you are targeting newer versions of JS, set the appropriate language_in option.
*/
/// <reference name="MicrosoftAjax.js" />
/// <reference name="Util.js" />
/// <reference path="../../GlobalJSFunctionsDetail.js" />
/// <reference path="../LiveEdit.js" />
try {
Sys.Application.add_load(loadOrAjaxUpdate);
}
catch (ex) { }
function changePage(num, id) {
var frm = document.aspnetForm;
frm.lngNewPage.value = num;
frm.action = "/gallery.aspx?AID=" + id;
frm.submit();
}
function viewSlideShow(albumID, title) {
document.aspnetForm.action = "/gallery.aspx?AID=" + albumID + '&showSlideShow=1' + '&AN=' + title;
document.aspnetForm.submit();
}
function searchTextHookFE(ev) {
ev = (window.event ? window.event : ev);
if (ev.keyCode == 10 || ev.keyCode == 13)
photoGallerySearchFE();
}
function photoGallerySearchFE() {
var frm = document.aspnetForm;
frm.action = "/gallery.aspx?searchText=" + encodeURIComponent(frm.moduleSearch.value) + "&AID=" + frm.categoryFilter.value;
frm.submit();
}
function changeSearchPage(num, searchText, id) {
var frm = document.aspnetForm;
frm.lngNewPage.value = num;
frm.action = "/gallery.aspx?searchText= " + searchText + "&AID=" + id;
frm.submit();
}
function changeAlbumPage(num) {
var frm = document.aspnetForm;
frm.lngNewPage.value = num;
frm.action = "/gallery.aspx";
frm.submit();
}
function arrayContains(a, obj){
for(var i = 0; i < a.length; i++) {
if(a[i] == obj){
return true;
}
}
return false;
}
function vote(photoID) {
var ids = getCookieValue('PGVote');
if (ids != null) {
var photoIDs = ids.split(',');
if (arrayContains(photoIDs, photoID)) {
alert("Youve already voted.");
return false;
}
else
document.cookie = "PGVote=" + ids + "," + photoID + "; expires=12/31/2999 23:59:59";
document.getElementById("thumbs" + photoID).src = '/Common/images/PhotoGallery2/ThumbsUpChecked.png';
}
else {
document.cookie = "PGVote=" + photoID + "; expires=12/31/2999 23:59:59";
}
var frm = document.aspnetForm;
frm.PGActionFE.value = 'vote';
frm.lngPhotoID.value = photoID;
redrawContent();
}
function PGPhotoModifyDelete(albumID, action, updatePanelID, photoID) {
var ysnArchShowForce = -1, doSubmit = true;
var frmPG = document.aspnetForm;
switch (action) {
case "Link":
{
doSubmit = false;
showCopyLinkWindowUsingRelatedLink('/gallery.aspx?PID=' + photoID);
break;
}
case "Publish":
case "Unpublish":
case "Reject":
case "Submit":
frmPG.strActionFE.value = "PGItem" + action;
break;
case "Delete":
{
if (confirm("Are you sure you want to delete this item?")) {
frmPG.strActionFE.value = "PGItemDelete";
}
else
doSubmit = false;
break;
}
case 'archivePublic':
ysnArchShowForce = 1;
case 'archiveHidden':
if (ysnArchShowForce < 0) ysnArchShowForce = 0;
if (!(confirm('Are you sure you want to archive this item?'))) {
ysnArchShowForce = -1;
return;
}
frmPG.strActionFE.value = 'PGItemArchive';
frmPG.ysnArchShowForceFE.value = ysnArchShowForce;
break;
default:
{
doSubmit = false;
break;
}
}
if (doSubmit) {
frmPG.ysnSaveFE.value = 1;
frmPG.lngPGPhotoID.value = photoID;
raiseAsyncPostbackPG(updatePanelID, 0);
}
}
function PGChangeOrder(albumID, direction, updatePanelID, photoID) {
var frmPGL = document.aspnetForm;
frmPGL.strActionFE.value = "PGItemChangeOrder";
frmPGL.ysnSaveFE.value = 1;
frmPGL.lngPGPhotoID.value = photoID;
frmPGL.PGDirection.value = direction;
raiseAsyncPostbackPG(updatePanelID, 0);
}
function openEditWindowPG(albumID, photoID, isCopy, order, updatePanelID, isSubmit) {
behavior = $find('editItemBehavior');
if (behavior) {
var ifr = document.getElementById('liveEditDialog');
ifr.style.height = '530px';
var url = '/common/modules/PhotoGallery2/PhotoGallery2LiveEdit.aspx?albumID=' + albumID + '&photoID=' + photoID + '&order=' + order + '&updatePanelID=' + updatePanelID;
if (isSubmit)
url = url + '&submit=1';
if (isCopy)
ifr.src = url + '&strPage=itemCopy';
else
ifr.src = url + '&strPage=itemForm';
ifr.style.display = 'block';
behavior.show();
}
}
// Live edit related:
if (!window.PGKAMMenu) {
PGKAMMenu = function() { };
window.PGKAMMenu = PGKAMMenu;
}
function raiseAsyncPostbackPG(updatePanelID, closePopUp, type) {
if (closePopUp)
closeModalDialog('editItemBehavior');
if (type != undefined)
blockMenuSpawn = true;
PGItemHideMenu();
PGCategoryHideMenu();
if(type)
__doPostBack(updatePanelID, "");
else
__doPostBack(updatePanelID, "photo");
if(closePopUp)
location.reload(true);
}
function PGItemMouseOver(sender, event, itemID) {
if (blockMenuSpawn)
return;
var controlID;
PGKAMMenu.photoID = itemID;
controlID = 'LiveEditControl' + itemID;
var liveEditControl = $get(controlID);
var showLiveEditControls = getCookieValue('showLiveEditControls') == "true";
// Make sure previous KAMs are hidden if they need to be.
if (!showLiveEditControls) {
if (previousKAMControl)
previousKAMControl.style.display = 'none';
previousKAMControl = liveEditControl;
}
// Change z-index, for proper display.
var parentContainer = resolveLiveEditContainer(liveEditControl);
parentContainer.style.zIndex = 2;
// Move action category menu to container for category.
liveEditControl.appendChild(PGKAMMenu.elemItemMenu);
// Show tool-tip (if they are not disabled).
PGShowTooltip(controlID);
// Show KAM.
liveEditControl.style.display = 'block';
}
function PGShowTooltip(controlID) {
var liveEditControl = $get(controlID);
liveEditControl.appendChild(PGKAMMenu.elemTooltip);
if (PGKAMMenu.elemTooltip) {
if (showToolTip)
PGKAMMenu.elemTooltip.style.display = 'block';
else
PGKAMMenu.elemTooltip.style.display = 'none';
}
}
function PGItemMouseOut(sender, event) {
// Ignore when mouse leaves child controls within the live edit control.
event = (window.event ? window.event : event);
var toElement = (event.toElement ? event.toElement : event.relatedTarget);
if (!elemInsideOrEq(sender, toElement)) {
PGItemHideMenu();
}
}
function PGCategoryMouseOver(sender, event, categoryID, fromAlbumScreen) {
if (blockMenuSpawn)
return;
PGKAMMenu.albumID = categoryID;
var controlID;
if (!fromAlbumScreen)
controlID = 'LiveEditControl_' + categoryID;
else
controlID = 'LiveEditControlAlbum_' + categoryID;
var liveEditControl = $get(controlID);
var showLiveEditControls = getCookieValue('showLiveEditControls') == "true";
// Make sure previous KAMs are hidden if they need to be.
if (!showLiveEditControls) {
if (previousKAMControl)
previousKAMControl.style.display = 'none';
previousKAMControl = liveEditControl;
}
// Move action category menu to container for category.
liveEditControl.appendChild(PGKAMMenu.elemCatMenu);
// Change z-index, for proper display.
var parentContainer = resolveLiveEditContainer(liveEditControl);
parentContainer.style.zIndex = 2;
// Show tool-tip (if they are not disabled).
PGShowTooltip(controlID);
// Show KAM.
liveEditControl.style.display = 'block';
}
// Summons action menu for a category.
function PGActionsCategory(albumID, catElemID, updatePanelID, status, rights, fromAlbumScreen) {
PGKAMMenu.updatePanelID = updatePanelID;
PGKAMMenu.photoID = 0;
PGKAMMenu.albumID = albumID;
PGKAMMenu.counter = 0;
PGKAMMenu.status = status;
PGKAMMenu.rights = rights;
if (!fromAlbumScreen)
liveEditCommonCategory(
$get(catElemID),
PGKAMMenu.elemTooltip,
PGKAMMenu.elemCatMenu,
$get('LiveEditControl_' + albumID), 'PGCategoryLiveEditMoreActions');
else
liveEditCommonCategory(
$get(catElemID),
PGKAMMenu.elemTooltip,
PGKAMMenu.elemCatMenu,
$get('LiveEditControlAlbum_' + albumID), 'PGCategoryLiveEditMoreActions');
}
function PGCategoryMouseOut(sender, event) {
// Ignore when mouse leaves child controls within the live edit control.
event = (window.event ? window.event : event);
var toElement = (event.toElement ? event.toElement : event.relatedTarget);
if (!elemInsideOrEq(sender, toElement))
PGCategoryHideMenu();
}
function PGCategoryHideMenu() {
var categoryID = PGKAMMenu.albumID;
var controlID = 'LiveEditControl_' + categoryID;
var controlIDAlbum = 'LiveEditControlAlbum_' + categoryID;
var liveEditControl = $get(controlID);
var liveEditControlAlbum = $get(controlIDAlbum);
var showLiveEditControls = getCookieValue('showLiveEditControls') == "true";
if (!liveEditControl && !liveEditControlAlbum)
return;
// Change z-index, for proper display.
var parentContainer;
if (liveEditControl)
parentContainer = resolveLiveEditContainer(liveEditControl);
else
parentContainer = resolveLiveEditContainer(liveEditControlAlbum);
parentContainer.style.zIndex = 0;
// Hide action menu for category.
PGKAMMenu.elemCatMenu.style.display = 'none';
if (PGKAMMenu.elemCatMenu.parentNode) {
PGKAMMenu.elemCatMenu.parentNode.removeChild(PGKAMMenu.elemCatMenu);
PGKAMMenu.elemLiveEditBullpen.appendChild(PGKAMMenu.elemCatMenu);
}
// Hide any possibly visible tool-tip.
PGHideTooltip();
// Hide KAM unless KAMs are set to always show.
if (!showLiveEditControls) {
if (liveEditControlAlbum)
liveEditControlAlbum.style.display = 'none';
if (liveEditControl)
liveEditControl.style.display = 'none';
}
}
function PGItemHideMenu() {
var itemID = PGKAMMenu.photoID;
var controlID = 'LiveEditControl' + itemID;
var liveEditControl = $get(controlID);
var showLiveEditControls = getCookieValue('showLiveEditControls') == "true";
if (!liveEditControl)
return;
// Change z-index, for proper display.
var parentContainer = resolveLiveEditContainer(liveEditControl);
parentContainer.style.zIndex = 0;
// Hide action menu for item.
PGKAMMenu.elemItemMenu.style.display = 'none';
if (PGKAMMenu.elemItemMenu.parentNode) {
PGKAMMenu.elemItemMenu.parentNode.removeChild(PGKAMMenu.elemItemMenu);
PGKAMMenu.elemLiveEditBullpen.appendChild(PGKAMMenu.elemItemMenu);
}
// Hide any possibly visible tool-tip.
PGHideTooltip();
// Hide KAM unless KAMs are set to always show.
if (!showLiveEditControls) {
liveEditControl.style.display = 'none';
}
}
// Hides tool-tip text for a category.
function PGHideTooltip() {
if (PGKAMMenu.elemTooltip.parentNode)
PGKAMMenu.elemTooltip.parentNode.removeChild(PGKAMMenu.elemTooltip);
PGKAMMenu.elemTooltip.style.display = 'none';
}
function PGActionsInit() {
// Set up state variables (they change per item).
PGKAMMenu.updatePanelID = '';
PGKAMMenu.photoID = 0;
PGKAMMenu.albumID = 0;
PGKAMMenu.counter = 0;
PGKAMMenu.order = 0;
PGKAMMenu.status = 0;
PGKAMMenu.rights = 0;
// Get invisible bullpen (where hidden stuff is stored).
PGKAMMenu.elemLiveEditBullpen = $get('PGLiveEditBullpen');
// Set up KAM tooltip.
PGKAMMenu.elemTooltip = $get('PGLiveEditToolTip');
if (!showToolTip)
PGKAMMenu.elemTooltip.style.display = 'none';
// Set up category action menu.
PGKAMMenu.elemCatMenu = $get('PGCategoryLiveEditMoreActions');
PGKAMMenu.elemCatActionNew = $get('PGCategoryNewItem');
hookAnchorClick(PGKAMMenu.elemCatActionNew,
function(sender, eventArgs) {
PGCategoryHideMenu();
var updatePanel = (PGKAMMenu.updatePanelID + '').trim();
if (updatePanel == 'search' || updatePanel == '')
openEditWindowPG(0, 0, 1, 0, 'search');
else
openEditWindowPG(PGKAMMenu.albumID, 0, 0, 0, PGKAMMenu.updatePanelID);
});
// Set up item action menu.
PGKAMMenu.elemItemMenu = $get('PGItemLiveEditMoreActions');
PGKAMMenu.elemItemMoveHeading = $get('PGItemMoveHeading');
PGKAMMenu.elemItemActionMoveUpIcon = $get('PGItemMoveUpIcon');
PGKAMMenu.elemItemActionMoveDownIcon = $get('PGItemMoveDownIcon');
PGKAMMenu.elemItemActionModify = $get('PGItemModify');
PGKAMMenu.elemItemActionCommands = $get('PGItemCommands');
hookAnchorClick(PGKAMMenu.elemItemActionModify,
function(sender, eventArgs) {
if (!PGKAMMenu.elemItemActionModify.inactive) {
PGItemHideMenu();
openEditWindowPG(PGKAMMenu.albumID, PGKAMMenu.photoID, 0, -1, PGKAMMenu.updatePanelID);
}
});
PGKAMMenu.elemItemActionMoveUp = $get('PGItemMoveUp');
hookAnchorClick(PGKAMMenu.elemItemActionMoveUp,
function(sender, eventArgs) {
if (!PGKAMMenu.elemItemActionMoveUp.inactive) {
PGItemHideMenu();
PGChangeOrder(PGKAMMenu.albumID, 'up', PGKAMMenu.updatePanelID, PGKAMMenu.photoID);
}
});
PGKAMMenu.elemItemActionMoveDown = $get('PGItemMoveDown');
hookAnchorClick(PGKAMMenu.elemItemActionMoveDown,
function(sender, eventArgs) {
if (!PGKAMMenu.elemItemActionMoveDown.inactive) {
PGItemHideMenu();
PGChangeOrder(PGKAMMenu.albumID, 'down', PGKAMMenu.updatePanelID, PGKAMMenu.photoID);
}
});
PGKAMMenu.elemItemActionCopyLink = $get('PGItemCopyLink');
hookAnchorClick(PGKAMMenu.elemItemActionCopyLink,
function(sender, eventArgs) {
PGPhotoModifyDelete(PGKAMMenu.albumID, 'Link', PGKAMMenu.updatePanelID, PGKAMMenu.photoID);
});
PGKAMMenu.elemItemActionUnpublish = $get('PGItemUnpublish');
hookAnchorClick(PGKAMMenu.elemItemActionUnpublish,
function(sender, eventArgs) {
PGItemHideMenu();
PGPhotoModifyDelete(PGKAMMenu.albumID, 'Unpublish', PGKAMMenu.updatePanelID, PGKAMMenu.photoID);
});
PGKAMMenu.elemItemActionPublish = $get('PGItemPublish');
hookAnchorClick(PGKAMMenu.elemItemActionPublish,
function(sender, eventArgs) {
PGItemHideMenu();
PGPhotoModifyDelete(PGKAMMenu.albumID, 'Publish', PGKAMMenu.updatePanelID, PGKAMMenu.photoID);
});
PGKAMMenu.elemItemActionSubmit = $get('PGItemSubmit');
hookAnchorClick(PGKAMMenu.elemItemActionSubmit,
function(sender, eventArgs) {
PGItemHideMenu();
PGPhotoModifyDelete(PGKAMMenu.albumID, 'Submit', PGKAMMenu.updatePanelID, PGKAMMenu.photoID);
});
PGKAMMenu.elemItemActionCopy = $get('PGItemCopy');
hookAnchorClick(PGKAMMenu.elemItemActionCopy,
function(sender, eventArgs) {
PGItemHideMenu();
if (PGKAMMenu.counter > 0)
openEditWindowPG(PGKAMMenu.albumID, PGKAMMenu.photoID, 1, -1, PGKAMMenu.updatePanelID);
else
openEditWindowPG(PGKAMMenu.albumID, PGKAMMenu.photoID, 1, -1, 'search');
});
// PGKAMMenu.elemItemActionArchive = $get('PGItemArchive');
// hookAnchorClick(PGKAMMenu.elemItemActionArchive,
// function(sender, eventArgs) {
// PGItemHideMenu();
// PGPhotoModifyDelete(PGKAMMenu.albumID, 'archiveHidden', PGKAMMenu.updatePanelID, PGKAMMenu.photoID);
// });
PGKAMMenu.elemItemActionDelete = $get('PGItemDelete');
hookAnchorClick(PGKAMMenu.elemItemActionDelete,
function(sender, eventArgs) {
PGItemHideMenu();
PGPhotoModifyDelete(PGKAMMenu.albumID, 'Delete', PGKAMMenu.updatePanelID, PGKAMMenu.photoID);
});
PGKAMMenu.elemItemActionNewAnchor = $get('PGItemNewItemAnchor');
PGKAMMenu.elemItemActionNew = $get('PGItemNewItem');
hookAnchorClick(PGKAMMenu.elemItemActionNew,
function(sender, eventArgs) {
if (!PGKAMMenu.elemItemActionNew.inactive) {
PGItemHideMenu();
openEditWindowPG(PGKAMMenu.albumID, 0, 0, PGKAMMenu.order, PGKAMMenu.updatePanelID);
}
});
PGKAMMenu.elemItemActionReject = $get('PGItemReject');
hookAnchorClick(PGKAMMenu.elemItemActionReject,
function(sender, eventArgs) {
PGItemHideMenu();
PGPhotoModifyDelete(PGKAMMenu.albumID, 'Reject', PGKAMMenu.updatePanelID, PGKAMMenu.photoID);
});
}
// Summons action menu for an item.
function PGActionItems(photoID, updatePanelID, albumID, order, counter, status, rights, lastItem) {
PGKAMMenu.updatePanelID = updatePanelID;
PGKAMMenu.albumID = albumID;
PGKAMMenu.photoID = photoID;
PGKAMMenu.counter = counter;
PGKAMMenu.order = order;
PGKAMMenu.status = status;
PGKAMMenu.rights = rights;
PGKAMMenu.lastItem = lastItem;
// Determine if modify is available.
if (rights >= PUBLISHER || rights == AUTHOR && status < MIN_PUBLISHED) {
PGKAMMenu.elemItemActionModify.className = 'big modify';
PGKAMMenu.elemItemActionModify.title = '';
PGKAMMenu.elemItemActionModify.inactive = false;
}
else {
PGKAMMenu.elemItemActionModify.className = 'big modify inactive';
PGKAMMenu.elemItemActionModify.title = 'You do not have rights to modify this item.'
PGKAMMenu.elemItemActionModify.inactive = true;
}
// Determine if move is available and how it should display.
var MOVE_ACTIVE_UP = '/App_Themes/CP/Images/IconMoveUp.png';
var MOVE_ACTIVE_DOWN = '/App_Themes/CP/Images/IconMoveDown.png';
var MOVE_INACTIVE_UP = '/App_Themes/CP/Images/IconMoveUpInactive.png';
var MOVE_INACTIVE_DOWN = '/App_Themes/CP/Images/IconMoveDownInactive.png';
var moveDisplay = (rights > AUTHOR ? 'inline' : 'none')
PGKAMMenu.elemItemMoveHeading.style.display = moveDisplay;
PGKAMMenu.elemItemActionMoveUp.style.display = moveDisplay;
PGKAMMenu.elemItemActionMoveDown.style.display = moveDisplay;
var moveText;
if (rights > AUTHOR) {
if (counter < 0) {
PGKAMMenu.elemItemActionMoveUp.className = 'moveUp inactive';
PGKAMMenu.elemItemActionMoveUp.inactive = true;
PGKAMMenu.elemItemActionMoveDown.className = 'moveDown inactive';
PGKAMMenu.elemItemActionMoveDown.inactive = true;
switch (counter) {
case -2:
moveText = 'Can only move items from module page.'
break;
default: // Search Screen
moveText = 'Can\'t move items on the search page.';
break;
}
PGKAMMenu.elemItemActionMoveUpIcon.src = MOVE_INACTIVE_UP;
PGKAMMenu.elemItemActionMoveDownIcon.src = MOVE_INACTIVE_DOWN;
PGKAMMenu.elemItemActionMoveUpIcon.title = moveText;
PGKAMMenu.elemItemActionMoveUpIcon.alt = moveText;
PGKAMMenu.elemItemActionMoveDownIcon.title = moveText;
PGKAMMenu.elemItemActionMoveDownIcon.alt = moveText;
}
else {
if (counter == 1) {
moveText = 'This item is first in the list and can\'t be moved any higher.';
PGKAMMenu.elemItemActionMoveUpIcon.src = MOVE_INACTIVE_UP;
PGKAMMenu.elemItemActionMoveUp.className = 'moveUp inactive';
PGKAMMenu.elemItemActionMoveUp.alt = 'This item is first in the list and can\'t be moved any higher.';
PGKAMMenu.elemItemActionMoveUp.inactive = true;
}
else {
moveText = 'Move Up';
PGKAMMenu.elemItemActionMoveUpIcon.src = MOVE_ACTIVE_UP;
PGKAMMenu.elemItemActionMoveUp.className = 'moveUp';
PGKAMMenu.elemItemActionMoveUp.inactive = false;
}
PGKAMMenu.elemItemActionMoveUpIcon.title = moveText;
PGKAMMenu.elemItemActionMoveUpIcon.alt = moveText;
if (lastItem) {
moveText = 'This item is last in the list and can\'t be moved any lower.';
PGKAMMenu.elemItemActionMoveDownIcon.src = MOVE_INACTIVE_DOWN;
PGKAMMenu.elemItemActionMoveDown.className = 'moveDown inactive';
PGKAMMenu.elemItemActionMoveDown.inactive = true;
}
else {
moveText = 'Move Down';
PGKAMMenu.elemItemActionMoveDownIcon.src = MOVE_ACTIVE_DOWN;
PGKAMMenu.elemItemActionMoveDown.className = 'moveDown';
PGKAMMenu.elemItemActionMoveDown.inactive = false;
}
PGKAMMenu.elemItemActionMoveDownIcon.title = moveText;
PGKAMMenu.elemItemActionMoveDownIcon.alt = moveText;
}
}
// Determine visiblity of submit/reject/publish/unpublish.
PGKAMMenu.elemItemActionSubmit.style.display = 'none';
PGKAMMenu.elemItemActionReject.style.display = 'none';
PGKAMMenu.elemItemActionPublish.style.display = 'none';
PGKAMMenu.elemItemActionUnpublish.style.display = 'none';
if (rights > AUTHOR) {
if (status > MAX_DRAFT)
PGKAMMenu.elemItemActionUnpublish.style.display = '';
else
PGKAMMenu.elemItemActionPublish.style.display = '';
if (status == SUBMITTED)
PGKAMMenu.elemItemActionReject.style.display = '';
}
else if (status != SUBMITTED && status <= MAX_DRAFT)
PGKAMMenu.elemItemActionSubmit.style.display = '';
// Determine visiblity of delete/archive.
//PGKAMMenu.elemItemActionArchive.style.display = 'none';
PGKAMMenu.elemItemActionDelete.style.display = 'none';
if (rights > AUTHOR) {
// Only publisher or higher can delete.
//if (status > MAX_DRAFT)
//PGKAMMenu.elemItemActionArchive.style.display = '';
//else
PGKAMMenu.elemItemActionDelete.style.display = '';
}
else if (status <= MAX_DRAFT)
PGKAMMenu.elemItemActionDelete.style.display = '';
// Determine visiblity/behavior of new.
if (counter > 0) {
if (rights >= AUTHOR) {
PGKAMMenu.elemItemActionNew.style.display = '';
PGKAMMenu.elemItemActionNewAnchor.title = '';
PGKAMMenu.elemItemActionNewAnchor.className = 'addItem';
PGKAMMenu.elemItemActionNew.inactive = false;
}
else
PGKAMMenu.elemItemActionNew.style.display = 'none';
}
else if (counter > -2) {
PGKAMMenu.elemItemActionNew.style.display = '';
PGKAMMenu.elemItemActionNewAnchor.title = 'You cannot add item on search screen.';
PGKAMMenu.elemItemActionNewAnchor.className = 'addItem inactive';
PGKAMMenu.elemItemActionNew.inactive = true;
}
else
PGKAMMenu.elemItemActionNew.style.display = 'none';
// Apply even/odd classes.
var listItems = PGKAMMenu.elemItemActionCommands.firstChild;
var lc = 0;
while (listItems != null) {
if (listItems.nodeType == 1 && listItems.style.display != 'none')
listItems.className = (((++lc) % 2) == 0 ? 'even' : '');
listItems = listItems.nextSibling;
}
// Show menu.
liveEditCommonItem(
PGKAMMenu.elemTooltip,
PGKAMMenu.elemItemMenu,
$get('LiveEditControl' + photoID), 'PGItemLiveEditMoreActions', false);
};
function ImageRepositoryClass() {
this.loadSource = { Self: 0, Slideshow: 1, RelatedDocuments: 2, Design: 3, Content: 4, Banner: 5 };
this.$imageUploadModal = null;
this.imageID = 0;
this.options = { modalTitle: 'Images', targetID: 0, $target: null, callback: null, loadSource: this.loadSource.Content };
}
const moduleIds = Object.freeze({
PhotoGallery: 53,
NewsFlash: 1
});
function getIframeHeightInPixels(moduleId) {
if ((moduleId === moduleIds.NewsFlash && window.self !== window.top)
|| moduleId === moduleIds.PhotoGallery) {
return '475px';
} else {
return '600px';
}
}
ImageRepositoryClass.prototype.openImageUploadModal = function (options) {
var imageRepositoryInstance = window.imageRepository;
imageRepositoryInstance.options = options;
callbackfnDocumentCenter = options.callback;
var className = 'slideShowImages';
if (window.FeatureToggles.isActive("CMS.DocumentCenter.ReplaceTelerikTreeAndGridWithReact")) {
className += ' reactModal';
}
imageRepositoryInstance.$imageUploadModal = openCpModal({
title: options.modalTitle,
className: className,
isFrontEnd: false,
useIframe: true,
draggable: true,
iframeHeight: getIframeHeightInPixels(options.moduleID),
elementID: 'mvcModal2',
url: '/Admin/DocumentCenter/FolderForModal/Index?renderMode=1&loadSource=' + options.loadSource + '&requestingModuleID=' + options.moduleID
});
imageRepositoryInstance.$imageUploadModal.removeClass('newCP adminWrap cpPopOver admin');
};
ImageRepositoryClass.prototype.closeImageWidgetUploadModal = function (documentID) {
var imageRepositoryInstance = window.imageRepository;
imageRepositoryInstance.$imageUploadModal.hide();
if (documentID > 0) {
$.ajax({
url: '/ContentWidgets/ImageSave/Save?widgetID=' + imageRepositoryInstance.options.targetID + '&contentCollectionID=' + imageRepositoryInstance.options.contentCollection.ContentCollectionID,
type: 'POST',
data: { imageID: documentID },
success: function (response) {
if (response.ErrorMessage) {
alert(response.ErrorMessage);
} else {
if (imageRepositoryInstance.options.contentCollection.IsWorkingCopy || isWidgetUnderMegaMenu($('#divImage' + imageRepositoryInstance.options.targetID))) {
$('#divImage' + imageRepositoryInstance.options.targetID).html(response);
contentUpdated();
} else {
var contentContainerID = $('#divImage' + imageRepositoryInstance.options.targetID).parents('.pageContent').filter(':first').data('containerid');
ContentCollectionInstance.CurrentContentContainerIDs.push(contentContainerID);
imageRepositoryInstance.options.contentCollection.reloadContent();
}
if (!window.isRemoveSetHeights)
SetHeights();
}
}
});
}
};
ImageRepositoryClass.prototype.closeCustomWidgetImageUploadModal = function (documentID) {
var imageRepositoryInstance = window.imageRepository;
imageRepositoryInstance.$imageUploadModal.hide();
if (documentID > 0) {
var imagePath = '/ImageRepository/Document?documentID=' + documentID;
var $input = imageRepositoryInstance.options.$target.parent().find(".input1");
var $divInputImage = imageRepositoryInstance.options.$target.parent().find(".divInputImage");
var $deleteInputImage = imageRepositoryInstance.options.$target.parent().find(".deleteInputImage");
$input.val(imagePath + '|');
$divInputImage.html("<img id='imgPreview' src='" + imagePath + "'style='max-width:100%' alt=''>");
imageRepositoryInstance.options.$target.hide();
imageRepositoryInstance.options.$target = null;
$deleteInputImage.show();
}
};
;
/*
* jQuery plugin to change any button into a image repository file selector.
* ---
* Usage:
*
* $('input.imageInput').imageInput({
* onChange: function(){ ... },
* onRemove: function(){ ... },
* onInit: function() { ... },
* showPreview: false,
* moduleID: 123 // Required,
* maximumImagePreviewWidth: 200 // in px
* });
*
* Notes:
* URL is pulled from value attribute. Use your input just
* as would use any other text based field. (JE)
*
* Alternative Usage: Attributes will override property defaults. imageInput function still needs to be called on the controls.
* <input type="cpImageRepository" data-showImagePath="false" data-showPreview="true" data-caption="@Localization.InsertImage" name="image" class="imageRepository" />
*
* Terminology:
* I use "Control Wrapper" to refer to the element containing the buttons, image preview, and image path display that are the UI of this plugin.
*/
$(function () { // I wish this weren't needed, but we are somehow pulling two jQuery initializations in some places so we have to wait and bind the plugin until all of that is done :(
$.fn.imageInput = function ($) {
// Shared Stuff
'use strict';
var config = {
localization: {
expectedNextElementToBeButtonWrapperError: 'Expected next element to be button controls (.imageSelect), and it was not. Either function was called prior to initialization or button controls were moved/malformed.',
noModuleIdProvidedError: 'No module ID provided for image repository control and it is required.',
defaultModalTitle: 'Content Images',
chooseImageButton: 'Choose Image...',
modifyButton: 'Modify',
removeButton: 'Remove'
},
selector: {
imagePathDisplay: '.imagePathDisplay',
imageDocumentId: '.imageDocumentId',
imagePreview: '.imagePreview',
chooseImageButton: '.button.chooseImage',
modifyButton: '.button.modifyImage',
removeButton: '.button.removeImage',
controlWrapper: '.imageSelect'
},
markup: {
imagePathDisplay: '<span class="imagePathDisplay"></span>',
imageDocumentId: '<input type="hidden" name="ImageDocumentId" class="imageDocumentId auto update widgetOption common"/>',
imagePreview: '<img class="imagePreview" />',
button: '<a href="#button" class="button"><span></span></a>',
controlWrapper: '<span class="imageSelect"></span>'
}
};
// Stuff that relates to a particular instance of this plugin.
return function (opts) {
if (!opts.moduleID) {
throw config.localization.noModuleIdProvidedError;
}
var noop = function () {
};
var optionDefaults = {
onChange: noop,
onRemove: noop,
onInit: noop,
modalTitle: config.localization.defaultModalTitle,
showPreview: false,
maximumImagePreviewWidth: 200,
showImagePathDisplay: !opts.showPreview, // If showPreview is on then by default lets hide the path. Otherwise it should probably be on.
chooseFileText: opts.chooseFileText ? opts.chooseFileText : config.localization.chooseImageButton,
useStandardButtonStyle: false,
showRemoveButton: true,
showInput: false,
};
var $inputThisPluginIsAppliedTo = $(this);
if ($inputThisPluginIsAppliedTo.length === 0) {
return $inputThisPluginIsAppliedTo; // No elements to match.
} else if ($inputThisPluginIsAppliedTo.length > 1) { // More than one element matches - we need to recall the plugin on each element and then return.
var $setOfMatchedElements = $([]);
$inputThisPluginIsAppliedTo.each(function () {
$setOfMatchedElements.add($(this).imageInput(opts));
});
return $setOfMatchedElements;
}
var isInitialized = false;
var currentImagePath = $inputThisPluginIsAppliedTo.val();
var currentDocumentId = $inputThisPluginIsAppliedTo.data('documentid');
var options = $.extend({}, optionDefaults, opts);
var init = function () {
if ($inputThisPluginIsAppliedTo.data('caption') && !opts.chooseFileText) { // if we have an attribute setting the caption lets use it.
options.chooseFileText = $inputThisPluginIsAppliedTo.data('caption');
}
if (typeof $inputThisPluginIsAppliedTo.data('showpreview') === 'boolean' && !opts.showPreview) {
options.showPreview = $inputThisPluginIsAppliedTo.data('showpreview');
}
if (typeof $inputThisPluginIsAppliedTo.data('showimagepath') === 'boolean' && !opts.showImagePathDisplay) {
options.showImagePathDisplay = $inputThisPluginIsAppliedTo.data('showimagepath');
}
if (!options.showInput) {
$inputThisPluginIsAppliedTo.hide();
}
createButtonsAndPreviewIfTheyDoNotExist();
updateUx();
setImage(currentImagePath, currentDocumentId);
if (options.maximumImagePreviewWidth) {
getControlWrapper().find(config.selector.imagePreview).css('max-width', options.maximumImagePreviewWidth + 'px');
}
isInitialized = true;
triggerOnInit();
};
var setImage = function (path, documentId) {
var $controlWrapper = getControlWrapper();
var $imagePreview = $controlWrapper.find(config.selector.imagePreview);
if (path === '') {
removeImage();
return;
}
path = path.replace(/\\/g, "/"); // Clean up pathing - CSS doesn't like backslashes
currentDocumentId = documentId;
currentImagePath = path;
$inputThisPluginIsAppliedTo.val(currentImagePath);
$controlWrapper.find(config.selector.imagePathDisplay).text(currentImagePath);
$controlWrapper.find(config.selector.imageDocumentId).val(currentDocumentId);
$imagePreview.attr('src', currentImagePath);
if (isInitialized) { // Since this is called on initialization we probably don't want to fire an initial on change event.
triggerOnChange();
}
updateUx();
};
var removeImage = function () {
var $controlWrapper = getControlWrapper();
currentImagePath = '';
currentDocumentId = null;
$inputThisPluginIsAppliedTo.val(currentImagePath);
$controlWrapper.find(config.selector.imagePathDisplay).text(currentImagePath);
$controlWrapper.find(config.selector.imageDocumentId).val('');
$controlWrapper.find(config.selector.imagePreview).attr('src', currentImagePath);
if (isInitialized) { // Since this is called on initialization we probably don't want to fire an initial on change event.
triggerOnChange();
triggerOnRemove();
}
updateUx();
};
var createButtonsAndPreviewIfTheyDoNotExist = function () {
var nextElementIsImageSelectUx = $inputThisPluginIsAppliedTo.next().is(config.selector.controlWrapper);
if (nextElementIsImageSelectUx) {
return; // nothing to do here. We already have the image controls.
}
var $controlWrapper = $inputThisPluginIsAppliedTo.after(config.markup.controlWrapper).next();
$controlWrapper
.append($(config.markup.imagePreview))
.append($(config.markup.imagePathDisplay))
.append($(config.markup.imageDocumentId))
.append($(config.markup.button).addClass('chooseImage'))
.append($(config.markup.button).addClass('modifyImage'))
.append($(config.markup.button).addClass('removeImage'));
$controlWrapper.find('.chooseImage span').text(options.chooseFileText);
$controlWrapper.find('.modifyImage span').text(config.localization.modifyButton);
$controlWrapper.find('.removeImage span').text(config.localization.removeButton);
if (options.useStandardButtonStyle) {
$controlWrapper.find(config.selector.modifyButton)
.add($controlWrapper.find(config.selector.removeButton))
.add($controlWrapper.find(config.selector.chooseImageButton))
.each(function () {
$(this).replaceWith($('<button type="button" class="' + this.className + '">' + this.innerHTML + '</button>'));
});
}
if (!options.showRemoveButton) {
$controlWrapper.find(config.selector.removeButton).hide();
}
bindUx(); // Don't forget to bind the newly created elements!
};
var getControlWrapper = function () {
var $elementThatShouldBeButtonWrapper = $inputThisPluginIsAppliedTo.next();
if ($elementThatShouldBeButtonWrapper.is(config.selector.controlWrapper)) {
return $elementThatShouldBeButtonWrapper;
} else {
throw config.localization.expectedNextElementToBeButtonWrapperError;
}
};
var bindUx = function () {
$inputThisPluginIsAppliedTo.bind('change', inputChange);
var $buttonWrapper = getControlWrapper();
$buttonWrapper.find(config.selector.imagePathDisplay).click(chooseImageClick);
$buttonWrapper.find(config.selector.imagePreview).click(chooseImageClick);
$buttonWrapper.find(config.selector.chooseImageButton).click(chooseImageClick);
$buttonWrapper.find(config.selector.modifyButton).click(modifyImageClick);
$buttonWrapper.find(config.selector.removeButton).click(removeImageClick);
};
var inputChange = function (e, data) {
if (data && data.source !== 'imageInput' || !data) {
setImage($inputThisPluginIsAppliedTo.val());
}
};
var chooseImageClick = function (e) {
showImageRepositoryModal();
e.preventDefault();
e.stopPropagation();
return false;
};
var modifyImageClick = function (e) {
showImageRepositoryModal();
e.preventDefault();
e.stopPropagation();
return false;
};
var removeImageClick = function (e) {
removeImage();
e.preventDefault();
e.stopPropagation();
return false;
};
var showModifyAndRemoveButtons = function () {
var $controlWrapper = getControlWrapper();
if (options.showRemoveButton === true) {
$controlWrapper.find(config.selector.modifyButton)
.add($controlWrapper.find(config.selector.removeButton)).show();
} else {
$controlWrapper.find(config.selector.modifyButton).show();
}
};
var hideModifyAndRemoveButtons = function () {
var $controlWrapper = getControlWrapper();
$controlWrapper.find(config.selector.modifyButton)
.add($controlWrapper.find(config.selector.removeButton))
.hide();
};
var showChooseImageButton = function () {
getControlWrapper()
.find(config.selector.chooseImageButton)
.show();
};
var hideChooseImageButton = function () {
getControlWrapper()
.find(config.selector.chooseImageButton)
.hide();
};
var showImagePathDisplay = function () {
getControlWrapper()
.find(config.selector.imagePathDisplay)
.show();
};
var hideImagePathDisplay = function () {
getControlWrapper()
.find(config.selector.imagePathDisplay)
.hide();
};
var showImagePreview = function () {
var $controlWrapper = getControlWrapper();
var $imagePreview = $controlWrapper.find(config.selector.imagePreview);
$imagePreview.show();
};
var hideImagePreview = function () {
getControlWrapper()
.find(config.selector.imagePreview)
.hide();
};
var updateUx = function () {
var weHaveAnImage = currentImagePath !== '';
if (weHaveAnImage) {
showModifyAndRemoveButtons();
hideChooseImageButton();
if (options.showPreview) {
showImagePreview();
} else {
hideImagePreview();
}
if (options.showImagePathDisplay) {
showImagePathDisplay();
} else {
hideImagePathDisplay();
}
} else {
hideModifyAndRemoveButtons();
hideImagePreview();
hideImagePathDisplay();
showChooseImageButton();
}
$inputThisPluginIsAppliedTo.val(currentImagePath);
$inputThisPluginIsAppliedTo.data('documentid', currentDocumentId);
};
var triggerOnInit = function () {
options.onInit();
};
var triggerOnChange = function () {
$inputThisPluginIsAppliedTo.trigger('change', [{source: 'imageInput'}]);
options.onChange(currentImagePath, currentDocumentId);
};
var triggerOnRemove = function () {
$inputThisPluginIsAppliedTo.trigger('change', [{source: 'imageInput'}]);
options.onChange();
options.onRemove();
};
var showImageRepositoryModal = function () {
var imageRepositoryOptions = {
loadSource: window.imageRepository.loadSource.Content,
callback: function (documentId) {
$.ajax({
url: '/ImageRepository/Source',
type: 'POST',
data: {imageID: documentId},
success: function (response) {
if (response.ErrorMessage) {
alert(response.ErrorMessage);
} else { // Response contains the selected path.
setImage(response, documentId);
}
}
});
window.imageRepository.$imageUploadModal.hide();
},
modalTitle: options.modalTitle,
moduleID: options.moduleID
};
window.imageRepository.openImageUploadModal(imageRepositoryOptions);
};
init();
$inputThisPluginIsAppliedTo.setImage = setImage;
$inputThisPluginIsAppliedTo.removeImage = removeImage;
return $inputThisPluginIsAppliedTo;
};
}($);
});