Last active
May 25, 2022 14:12
-
-
Save jeffdrumgod/9ce3c7d64e4f925876b907aa30e40df3 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$(document).ajaxStart(function () { | |
ShowBusy(); | |
}); | |
$(document).ajaxStop(function () { | |
HideBusy(); | |
}); | |
function ShowBusy() { | |
$('#ajaxBusy').hide(); | |
$('#ajaxBusy').show(); | |
} | |
function HideBusy() { | |
$('#ajaxBusy').hide(); | |
} | |
function ScrollToTop() { | |
try { | |
$('html, body').animate({ scrollTop: 0 }, 'slow'); | |
} catch (e) { } | |
} | |
$(document).ready(function () { | |
$('#portalTree').fileTree({ | |
root: '/', script: JsNewAppFolder + '/PortalManagement/FolderContent', folderEvent: 'click', expandSpeed: 50, | |
collapseSpeed: 50, multiFolder: true | |
}, | |
function (args, url) { | |
var nodeType = args.split(':')[0]; | |
$('[id^=portalBody]').css('display', 'none'); | |
$("#configShelf").html(""); | |
switch (nodeType) { | |
case 'folder': | |
case 'file': | |
AjaxRequest('POST', url, '#portalBody', nodeType, null, null, false); | |
break; | |
case 'layout': | |
LoadLayoutView(args, nodeType); | |
break; | |
case 'shelf-templates': | |
AjaxRequest('POST', JsNewAppFolder + "/PortalManagement/GetTemplateList?type=shelfTemplate&IsSub=1", '#portalBody', nodeType, null, null, false); | |
break; | |
case 'sub-templates': | |
AjaxRequest('POST', JsNewAppFolder + "/PortalManagement/GetTemplateList?type=viewTemplate&IsSub=1", '#portalBody', nodeType, null, null, false); | |
break; | |
case 'templates': | |
AjaxRequest('POST', JsNewAppFolder + "/PortalManagement/GetTemplateList?type=viewTemplate&IsSub=0", '#portalBody', nodeType, null, null, false); | |
break; | |
case 'template': | |
LoadTemplateView(args, nodeType); | |
break; | |
case 'shelf-template': | |
LoadShelfTemplateView(args, nodeType) | |
break; | |
case 'script': | |
LoadScriptView(args, nodeType); | |
break; | |
case 'addScript': | |
argsLine = args.split(':'); | |
AjaxRequest('GET', argsLine[1].replace(/\/$/, ''), '#portalBody', nodeType); | |
break; | |
case 'addTemplate': | |
argsLine = args.split(':'); | |
AjaxRequest('POST', argsLine[1].replace(/\/$/, ''), '#portalBody', nodeType); | |
break; | |
case 'addShelfTemplate': | |
argsLine = args.split(':'); | |
AjaxRequest('POST', argsLine[1].replace(/\/$/, ''), '#portalBody', nodeType); | |
break; | |
case 'url-mapping': | |
argsLine = args.split(':'); | |
url = JsNewAppFolder + '/PortalManagement/GetUrlMappingList/?siteId=' + argsLine[1].replace(/\/$/, ''); | |
AjaxRequest('POST', url, '#portalBody', nodeType); | |
break; | |
case 'custom-view-part': | |
argsLine = args.split(':'); | |
url = JsNewAppFolder + '/PortalManagement/GetCustomPartList/?siteId=' + argsLine[1].replace(/\/$/, ''); | |
AjaxRequest('POST', url, '#portalBody', nodeType); | |
break; | |
case 'addUrlMapping': | |
argsLine = args.split(':'); | |
AjaxRequest('POST', argsLine[1].replace(/\/$/, ''), '#portalBody', nodeType); | |
break; | |
case 'file-manager-node': | |
argsLine = args.split(':'); | |
AjaxRequest('POST', argsLine[1].replace(/\/$/, ''), '#portalBody', nodeType); | |
break; | |
case 'site': | |
LoadWebSiteView(args, nodeType); | |
break; | |
case 'sites': | |
AjaxRequest('POST', JsNewAppFolder + "/PortalManagement/GetWebSiteList", '#portalBody', nodeType, null, null, false); | |
break; | |
case 'dictionary': | |
LoadWebSiteDictionary(args, nodeType); | |
break; | |
case 'file-manager': | |
case 'scripts': | |
$('#portalBody').html(''); | |
break; | |
case 'cluster': | |
argsLine = args.split(':'); | |
url = JsNewAppFolder + '/PortalManagement/ClusterAdd/?idColecao=' + argsLine[1].replace(/\/$/, ''); | |
AjaxRequest('POST', url, '#portalBody', nodeType, loadClusterStart); | |
break; | |
case 'clusterSub-add': | |
argsLine = args.split(':'); | |
url = JsNewAppFolder + '/PortalManagement/ClusterSubAdd/?clusterId=' + argsLine[1].replace(/\/$/, '') + '&clusterSubId=' + argsLine[2].replace(/\/$/, ''); | |
AjaxRequest('POST', url, '#portalBody', nodeType, loadClusterSubStart); | |
break; | |
case 'installment': | |
argsLine = args.split(':'); | |
url = JsNewAppFolder + '/PortalManagement/InstallmentAdd/?installmentId=' + argsLine[1].replace(/\/$/, ''); | |
AjaxRequest('POST', url, '#portalBody', nodeType, loadInstallmentStart); | |
break; | |
case 'installmentsku': | |
argsLine = args.split(':'); | |
url = JsNewAppFolder + '/PortalManagement/InstallmentSkuAdd/?installmentSkuId=' + argsLine[1].replace(/\/$/, ''); | |
AjaxRequest('POST', url, '#portalBody', nodeType, loadInstallmentStart); | |
break; | |
} | |
}); | |
MakeConfirmDialog(); | |
PrepareFilePikerSearchInsertFileDialog(); | |
InitDragNDrop(); | |
//$("#lnkNewDictionaryEntry").live('click', function () { AjaxRequest('POST', JsNewAppFolder + "/PortalManagement/DictionaryAdd?SiteId=" + $("#hdnWebSiteId").val(), '#portalBody', null); } ); | |
//$("#utm_source").live('change', function () { AjaxRequest('POST', JsNewAppFolder + "/PortalManagement/TemplateContent?templateId=" + $("#templateId").val() + "&utm_source=" + $("#utm_source").val(), '#portalBody', null, BindTemplateFunctions); }); | |
}); | |
function GetFormConfirmLayoutClone(url, target) { | |
$.ajax({ | |
type: 'POST', | |
url: JsNewAppFolder + url, | |
//data: null, | |
cache: false, | |
//async: async, | |
success: function (data) { | |
OpenConfirmLayoutClone(); | |
$(target).html(data); | |
}, | |
error: function (XMLHttpRequest, textStatus, errorThrown) { | |
Form_Submit_Failure(); | |
} | |
}); | |
} | |
//WebSiteTest | |
function LoadWebSiteTestView(args, nodeType) { | |
argsLine = args.split(':'); | |
AjaxRequest('POST', JsNewAppFolder + '/WebSiteTest/WebSiteTestContent?websiteId=' + argsLine[1] + '&websiteTestId=' + argsLine[2], '#portalBody', nodeType, BindSiteManagerNodeFunctions); | |
} | |
function WebSiteTestCreate_Sucess(obj) { | |
if (!HasApplicationException(obj.get_data())) { | |
ShowMessage('Teste gravado com sucesso!'); | |
ReloadFileTree(); | |
} | |
//BindTemplateFunctions(); | |
} | |
function LoadWebSiteAlternativeView(args, nodeType) { | |
argsLine = args.split(':'); | |
AjaxRequest('POST', JsNewAppFolder + '/PortalManagement/WebSiteTestVariantContent?websiteTestId=' + argsLine[1] + '&websiteId=' + argsLine[2], '#portalBody', nodeType, BindSiteManagerNodeFunctions); | |
} | |
//Fim para WebSiteTest | |
function doEditDictionaryEntry(ItemId, SiteId) { | |
AjaxRequest('POST', JsNewAppFolder + "/PortalManagement/AddDictionaryItem?ItemId=" + ItemId + "&SiteId=" + SiteId, '#portalBody', null); | |
} | |
function doSaveDictionaryItem(ItemId) { | |
var dataToPost = { | |
WebSiteId: $("#WebSiteId").val(), | |
WebSiteDictionaryItem: $("#WebSiteDictionaryItem").val(), | |
websiteDictionaryKey: $("#websiteDictionaryKey").val(), | |
websiteDictionaryValue: $("#websiteDictionaryValue").val(), | |
BindingHost: $("#BindingHost").val() | |
}; | |
AjaxRequest('POST', JsNewAppFolder + "/PortalManagement/SaveDictionaryItem?ItemId=" + ItemId, '#portalBody', null, null, dataToPost); | |
} | |
function doSaveWebsiteBinding(Host, CSSFilePath, SiteId, utm_source, ActionType) { | |
var dataToPost = { | |
Host: Host, | |
CSSFilePath: CSSFilePath, | |
SiteId: SiteId, | |
utm_source: utm_source, | |
ActionType: ActionType | |
}; | |
AjaxRequest('POST', JsNewAppFolder + "/PortalManagement/WebsiteBindingSave", '#portalBody', null, BindSiteManagerNodeFunctions, dataToPost); | |
} | |
function doEditWebSiteBinding(Host, websiteId) { | |
AjaxRequest('POST', JsNewAppFolder + "/PortalManagement/WebsiteBindingAdd?Host=" + Host + "&SiteId=" + websiteId, '#portalBody', null, BindHostAddEddit, null); | |
} | |
function doDeleteWebSiteBinding(Host, websiteId) { | |
if (Host.includes("*")) | |
ShowAlertMessage("Não é possível remover o binding padrão."); | |
else | |
AjaxRequest('POST', JsNewAppFolder + "/PortalManagement/WebsiteBindingDelete?Host=" + Host + "&SiteId=" + websiteId, '#portalBody', null, BindSiteManagerNodeFunctions, null); | |
} | |
function InitDragNDrop() { | |
// $(".draggable").draggable(); | |
// $(".droppable").droppable({ | |
// greedy: true, | |
// drop: function (event, ui) { | |
// ui.draggable.find("a").unbind("click"); | |
// doMoveLayout(ui.draggable.find("a").attr("rel"), $(this).find("a").attr("rel")); | |
// } | |
// }); | |
return true; | |
} | |
function doMoveLayout(relLayout, relFolderTo) { | |
AjaxRequest('POST', JsNewAppFolder + '/PortalManagement/LayoutMove?layoutData=' + relLayout + "&folderData=" + relFolderTo, '', 'folder', function () { ReloadFileTree(relFolderTo, relLayout); setTimeout(ReloadFileTree, 500, relFolderTo, relLayout); }, null, false); | |
} | |
function AddControlToPlaceHolder(form) { | |
if (form.controlClientName.value == '') form.controlClientName.value = form.controlType.value; | |
$('#' + $(form.placeHolderId.value).val()).append(MakeControlDivWithName($(form.placeHolderId.value).val(), form.controlType.value, form.controlId.value, form.controlClientName.value)); | |
$("#dialog-control-name").dialog('close'); | |
$("#controls").dialog('close'); | |
} | |
function RenameControlOnPlaceHolder(form) { | |
var itemToEdit = $('#' + form.controlId.value); | |
$(itemToEdit).attr('name', form.controlClientName.value); | |
$($(itemToEdit).children('#name')[0]).text(form.controlClientName.value); | |
$("#dialog-control-name").dialog('close'); | |
} | |
function RenameControlOnPlaceHolderWithAttributes(form, viewPartInstanceId) { | |
//Edson.Costa - Walmart - 26/10/2011 | |
//Seleciona o controle a ser Editado Pelo ID da ViewPartInstance | |
//Estava Ococrrendo que ao carregar pela Forma Normal Onde pega viewPartID + TimeStamp, em alguns casos havia duplicidade | |
//Ao Selecionar pelo viewPartInstaceId, somente o Controle clicado eh selecionado. | |
var itemToEdit = $("[instanceId=" + viewPartInstanceId + "]"); | |
$(itemToEdit).attr('name', form.controlClientName.value); | |
$($(itemToEdit).children('#name')[0]).text(form.controlClientName.value); | |
$("#dialog-control-name").dialog('close'); | |
} | |
function MakeControlDivWithName(conteinerId, controlName, controlId, controlClientName) { | |
var name = controlName; | |
var hrefToEditName = ''; | |
var hrefToRemove = '<a href="javascript:void(0)" onClick="RemoveControl(\'' + controlId + '\',\'' + conteinerId + '\');"><img align="middle" border="0" src="' + JsNewAppFolder + '/Content/img/DeleteContact.png"></a>'; | |
if (controlClientName != '') { | |
hrefToEditName = ' <a title="edit" id="name" href="javascript:void(0);" onclick="OpenFormToTypeControlName(\'' + controlName + '\',\'' + controlId + '\',\'#placeHolderId\',\'' + controlClientName + '\');">' + controlClientName + '</a>'; | |
} | |
return '<div id="' + controlId + '" class="fieldSelected" name="' + controlClientName + '"> ' + name + hrefToRemove + hrefToEditName + '</div>'; | |
} | |
function OpenFormToTypeControlName(controlType, controlId, placeHolderId, control) { | |
OpenFormToTypeControlName(controlType, controlId, placeHolderId, control, ""); | |
} | |
//Sobrecarreguei este método para não inteferir em outras chamadas | |
//Internamente há um tratamento para verificar se a variável esta preenchida. | |
function OpenFormToTypeControlName(controlType, controlId, placeHolderId, control, viewPartInstanceId) { | |
var form = document.getElementById('form-dialog-control-name'); | |
form.controlClientName.value = ''; | |
form.controlType.value = ''; | |
form.controlId.value = ''; | |
form.controlType.value = controlType; | |
form.controlId.value = controlId; | |
form.instanceId.value = viewPartInstanceId; | |
form.placeHolderId.value = placeHolderId; | |
if (control != null) { | |
form.controlClientName.value = $(control).text(); | |
if (form.instanceId.value != "") { | |
form.submitButton.onclick = function () { RenameControlOnPlaceHolderWithAttributes(this.form, form.instanceId.value) } | |
} | |
else | |
form.submitButton.onclick = function () { RenameControlOnPlaceHolder(this.form) } | |
form.submitButton.value = 'Rename'; | |
} else { | |
form.submitButton.value = 'Add'; | |
form.submitButton.onclick = function () { AddControlToPlaceHolder(this.form); }; | |
} | |
$("#dialog-control-name").dialog('open'); | |
} | |
function LoadLayoutView(args, nodeType) { | |
argsLine = args.split(':'); | |
AjaxRequest('POST', JsNewAppFolder + '/PortalManagement/LayoutContent?layoutId=' + argsLine[1], '#portalBody', nodeType); | |
} | |
function LoadShelfTemplateView(args, nodeType) { | |
argsLine = args.split(':'); | |
AjaxRequest('POST', JsNewAppFolder + '/PortalManagement/ShelfTemplateContent?shelfTemplateId=' + argsLine[1], '#portalBody', nodeType); | |
} | |
function LoadTemplateView(args, nodeType) { | |
argsLine = args.split(':'); | |
AjaxRequest('POST', JsNewAppFolder + '/PortalManagement/TemplateContent?templateId=' + argsLine[1], '#portalBody', nodeType); | |
} | |
function LoadWebSiteDictionary(args, nodeType) { | |
argsLine = args.split(':'); | |
AjaxRequest('POST', JsNewAppFolder + '/PortalManagement/DictionaryContentBody?SiteId=' + argsLine[1], '#portalBody', nodeType, BindDictionaryFunction); | |
} | |
function LoadClusterInfo(args, nodeType) { | |
argsLine = args.split(':'); | |
AjaxRequest('POST', JsNewAppFolder + '/PortalManagement/ClusterBody?ClusterId=' + argsLine[1], '#portalBody', nodeType, BindDictionaryFunction); | |
} | |
function LoadWebSiteView(args, nodeType) { | |
argsLine = args.split(':'); | |
AjaxRequest('POST', JsNewAppFolder + '/PortalManagement/WebSiteContent?WebSiteId=' + argsLine[1], '#portalBody', nodeType, BindSiteManagerNodeFunctions); | |
} | |
function LoadScriptView(args, nodeType) { | |
argsLine = args.split(':'); | |
AjaxRequest('POST', JsNewAppFolder + '/PortalManagement/ScriptContent?scriptId=' + argsLine[1], '#portalBody', nodeType); | |
} | |
function AjaxRequest(method, url, target, nodeType, callback, postData) { | |
AjaxRequest(method, url, target, nodeType, callback, postData, true); | |
} | |
function AjaxRequest(method, url, target, nodeType, callback, postData, async) { | |
$.ajax({ | |
type: method, | |
url: url, | |
data: postData, | |
cache: false, | |
async: async, | |
success: function (data) { | |
if (nodeType == 'file-del') { HasApplicationException(data); } | |
if (target != '') { | |
$(target).html(data); | |
$(target).css('display', 'block'); | |
} | |
switch (nodeType) { | |
case 'layout': | |
case 'folder': { BindLayoutFunctions(); break; } | |
case 'url-mapping': | |
case 'addUrlMapping': { BindUrlMappingFunctions(); break; } | |
case 'custom-view-part': { BindCustomViewPartFunctions(); break; } | |
case 'file-manager-node': { BindFileManagerNodeFunctions(); break; } | |
case 'site': { BindSiteManagerNodeFunctions(); break; } | |
case 'file': { BindFolderFunctions(); break; } | |
case 'file-del': { ReloadGrid(); break; } | |
case 'template': | |
case 'shelf-template': | |
case 'addShelfTemplate': | |
case 'addTemplate': { BindTemplateFunctions('add'); break; } | |
case 'cluster': { BindClusterFunctions(); break; } | |
case 'cluster-node': { BindClusterFunctions(); break; } | |
} | |
//acertaTamanhoTela(); | |
InitDragNDrop(); | |
if (callback != null && callback != '') | |
callback(); | |
}, | |
error: function (XMLHttpRequest, textStatus, errorThrown) { | |
$(target).html(XMLHttpRequest.responseText); | |
} | |
}); | |
} | |
function BindDictionaryFunction() { | |
$('#tabs-dictionary').tabs(); | |
} | |
function BindHostAddEddit() { | |
$('#tabs-binding').tabs(); | |
$('#tab-website').tabs(); | |
} | |
function BindFileManagerNodeFunctions() { | |
$('#tab-file-manager-up').tabs(); | |
} | |
function BindBindingFunction(obj) { | |
if (!HasApplicationException(obj.get_data())) { | |
ShowMessage('The operation was successfully'); | |
AjaxRequest('POST', JsNewAppFolder + '/PortalManagement/WebSiteContent?WebSiteId=' + argsLine[1], '#portalBody', 'site', BindSiteManagerNodeFunctions); | |
} | |
} | |
function BindSiteManagerNodeFunctions(obj) { | |
$('#tab-website').tabs(); | |
} | |
function BindUrlMappingFunctions() { | |
GenerateDatePicker(); | |
$("#tabs-folder").tabs(); | |
$("#tabs-urlmapping").tabs(); | |
} | |
function BindCustomViewPartFunctions() { | |
$("#tabs-custom-view-part").tabs(); | |
} | |
function BindTemplateFunctions(action) { | |
$("#tabs").tabs(); | |
if (action == 'view') $('#tabs').tabs('select', [1]); | |
else { | |
$('#tabs').tabs('select', [0]); | |
$("#tabs").tabs('disable', [1]); | |
} | |
} | |
function BindClusterFunctions(action) { | |
$("#tabs").tabs(); | |
if (action == 'view') $('#tabs').tabs('select', [1]); | |
else { | |
$('#tabs').tabs('select', [0]); | |
$("#tabs").tabs('disable', [1]); | |
} | |
} | |
//adição de controles no place holder | |
function AddControl(containerId) { | |
$('#placeHolderId').val(containerId); | |
AjaxRequest('POST', JsNewAppFolder + '/PortalManagement/GetSiteControls', '#controls', ''); | |
$('#controls').dialog('open'); | |
CssFixConfigShelf('controls', '90px'); | |
} | |
//editando um controle adicionado e salvo dentro de um place holder | |
function EditControl(viewInstanceId, configURL) { | |
$('#configShelf').html('loading . . . . . .'); | |
AjaxRequest('POST', JsNewAppFolder + "/" + configURL + '?viewInstanceId=' + viewInstanceId, '#configShelf', ''); | |
$('#configShelf').dialog('open'); | |
$('.ui-widget-overlay').css('z-index', '5000'); | |
CssFixConfigShelf('configShelf', '90px'); | |
} | |
function RemoveContentRow(div) { | |
$(div).remove(); | |
$("#totalRows").val($("#totalBannerContentRows").val() - 1); | |
} | |
function RemoveContentRowByName(divName) { | |
$('#' + divName).remove(); | |
$("#totalRows").val($("#totalBannerContentRows").val() - 1); | |
} | |
function BindContentDatePicker() { | |
var pathImage = JsNewAppFolder + '/Content/themes/base/images/calendar.gif'; | |
$('#dateFromPicker').datepicker({ showOn: 'button', buttonImage: pathImage, buttonImageOnly: true, dateFormat: 'dd/mm/yy' }); | |
} | |
//remoção de controles do place holder | |
function RemoveControl(controlId, conteinerId) { | |
$('#' + conteinerId).children('#' + controlId).remove(); | |
} | |
//reconstruindo o value do hidden | |
function MakeControlHidden(source) { | |
var values = ''; | |
for (i = 0; i < source.length; i++) { | |
if (values != '') values = values + '-||-'; | |
values = values + source[i]; | |
} | |
return values; | |
} | |
//prepara o array de controles antes do submit, retirando marcadore de UI | |
function HandleControlListToSubmit() { | |
placeHolders = $('.placeHolderClass'); | |
$('#coltrolIdSelectedList').val(MakeControlInputHidden(placeHolders)); | |
var arrayPlaceHolderControls = $('#coltrolIdSelectedList').val().split('-||-'); | |
RemoveTimeStamp(arrayPlaceHolderControls); | |
$('#coltrolIdSelectedList').val(MakeControlHidden(arrayPlaceHolderControls)); | |
return true; | |
} | |
function MakeControlInputHidden(placeHolders) { | |
var stringPlaceHolder = ''; | |
var stringReturn = ''; | |
for (i = 0; i < placeHolders.length; i++) { | |
stringPlaceHolder = placeHolders[i].id | |
pControls = $(placeHolders[i]).children('div'); | |
if (stringReturn != '') stringReturn += '-||-'; | |
stringReturn += stringPlaceHolder + '[:][:][:]'; | |
for (j = 0; j < pControls.length; j++) { | |
if (stringReturn != '') stringReturn += '-||-'; | |
stringReturn += stringPlaceHolder + '[:]' + $(pControls[j]).attr('id') + '[:]' + ($(pControls[j]).attr('instanceId') == null ? '' : $(pControls[j]).attr('instanceId')) + '[:]' + $(pControls[j]).attr('name'); | |
} | |
} | |
return stringReturn; | |
} | |
//remove o time stamp inserido no id do controle | |
function RemoveTimeStamp(source) { | |
var aux; | |
var controlIdWithTimeStamp; | |
var conteinerId; | |
var controlId; | |
for (i = 0; i < source.length; i++) { | |
if (source[i] != "") { | |
aux = source[i].split('[:]'); | |
conteinerId = aux[0]; | |
controlIdWithTimeStamp = aux[1]; | |
controlId = controlIdWithTimeStamp.split('TSC')[0]; | |
source[i] = conteinerId + '[:]' + controlId + '[:]' + aux[2] + '[:]' + aux[3]; | |
} | |
} | |
} | |
function BindLayoutFunctions() { | |
// OnChange "default Layout" check box state | |
$("#layoutDefault").click(function () { | |
var isChecked = $(this).attr("checked"); | |
if (isChecked) { | |
$("#complement").fadeOut('fast'); | |
// Limpa os demais campos de complemento | |
$("#startDate").attr("value", ""); | |
$("#startTime").attr("value", ""); | |
$("#endDate").attr("value", ""); | |
$("#endTime").attr("value", ""); | |
// Limpa Box de Categorias | |
var categoryLength = $("#categoryListBox")[0].options.length; | |
for (k = 0; k < categoryLength; k++) { | |
$("#categoryListBox")[0].options.remove(0); | |
} | |
// Limpa Box de Produtos | |
var productLength = $("#productListBox")[0].options.length; | |
for (k = 0; k < productLength; k++) { | |
$("#productListBox")[0].options.remove(0); | |
} | |
} | |
else { | |
$("#complement").fadeIn('fast'); | |
$("#complement").css("display", "block"); | |
} | |
}); | |
if (!$("#layoutDefault").attr("checked")) { | |
$("#complement").css("display", "block"); | |
} | |
//templateid, on change na drop de templates, guardar o templateid, | |
//para uso na recocolsulta apoós salvar. | |
$('#templates').change(function () { | |
var _originalTemplateId = $('#originalTemplate').val(); | |
var _templateId = $('#templates').val(); | |
if (_originalTemplateId != '' && _templateId != _originalTemplateId) { | |
var postData = { templateId: _templateId, originalTemplateId: _originalTemplateId }; | |
AjaxRequest('POST', JsNewAppFolder + '/PortalManagement/GetFormConfirmTemplateChange', '#dialog-confirm', '', '', postData); | |
$("#dialog-confirm").dialog('open'); | |
} | |
$('#templateId').val($('#templates').val()); | |
}) | |
GenerateDatePicker(); | |
$("#tabs-folder").tabs(); | |
$("#tabs-layout").tabs(); | |
if ($("#layoutId").attr("value") != '') { | |
$('#tabs-layout').data('disabled.tabs', []); | |
$("#tabs-layout").tabs('enable', [1]); | |
$("#tabs-layout").tabs('enable', [2]); | |
} | |
// ui: Category Picker Dialog | |
$("#category").dialog({ | |
bgiframe: true, | |
autoOpen: false, | |
height: 300, | |
zIndex: 5002, | |
modal: true, | |
buttons: { | |
Adicionar: function () { | |
var flag = false; | |
var selectedCategoryId = $("#categoryIdSelected").attr("value"); | |
var categoryItems = $("#categoryListBox option"); | |
for (categoryIndex = 0; categoryIndex < categoryItems.length; categoryIndex++) { | |
var category = categoryItems[categoryIndex]; | |
if (category.value == selectedCategoryId) | |
flag = true; | |
} | |
if (flag) { | |
ShowMessage("A categoria " + document.getElementById('categoryNameSelected').value + " já foi adicionada!"); | |
} else { | |
// adiciona o nome na lista | |
option = document.createElement('option'); | |
option.value = document.getElementById('categoryIdSelected').value; | |
option.text = document.getElementById('categoryNameSelected').value; | |
option.selected = true; | |
document.getElementById('categoryListBox').options.add(option); | |
} | |
$('#category').dialog('close'); | |
} | |
} | |
}); | |
$('#openCategory').click(function () { | |
$('#category').dialog('close'); | |
$('#categoryTree').fileTree( | |
{ | |
root: '/', | |
script: JsNewAppFolder + '/CatalogSystem/CategoryContent', | |
folderEvent: 'click', | |
expandSpeed: 50, | |
collapseSpeed: 50, | |
multiFolder: false | |
}, | |
function (args, url) { | |
} | |
); | |
$('#category').dialog('open'); | |
}); | |
//configShelfDialog | |
$("#configShelf").dialog | |
({ | |
bgiframe: true, | |
autoOpen: false, | |
zIndex: 5002, | |
width: 1200, | |
title: 'Edit Visual Control', | |
modal: true, | |
open: function (event, ui) { }, | |
close: function (event, ui) { } | |
}); | |
$("#configContent").dialog | |
({ | |
bgiframe: true, | |
autoOpen: false, | |
width: 1000, | |
height: 700, | |
zIndex: 5003, | |
title: 'Content', | |
modal: true, | |
open: function (event, ui) { $('#configContent').html('loading. . . . . . .'); }, | |
close: function (event, ui) { } | |
}); | |
//control dialog | |
$("#controls").dialog | |
({ | |
bgiframe: true, | |
autoOpen: false, | |
width: 600, | |
zIndex: 5002, | |
modal: true, | |
open: function (event, ui) { ClearCheckBox(); }, | |
buttons: | |
{ | |
Adicionar: function () { | |
var checks = document.getElementsByName('controlCheck'); | |
for (var i = 0; i < checks.length; i++) { | |
if (checks[i].checked) { | |
var valueName = checks[i].value.split('::'); | |
var controlId = valueName[0] + MakeTimeStamp(); | |
var controlName = valueName[1]; | |
OpenFormToTypeControlName(controlName, controlId, '#placeHolderId', null); | |
} | |
} | |
} | |
} | |
}); | |
//control dialog | |
$("#dialog-control-name").dialog | |
({ | |
bgiframe: true, | |
autoOpen: false, | |
width: 460, | |
zIndex: 5003, | |
modal: true, | |
open: function (event, ui) { } | |
}); | |
//limpa os checks box do dialog de adição de controles | |
function ClearCheckBox() { | |
var checks = document.getElementsByName('controlCheck'); | |
for (var i = 0; i < checks.length; i++) { | |
checks[i].checked = false; | |
} | |
} | |
//cria um selo para identificar exclusivamente cada controle | |
function MakeTimeStamp() { | |
var currentTime = new Date(); | |
return 'TSC' + currentTime.getHours() + currentTime.getMinutes() + currentTime.getSeconds() + currentTime.getMilliseconds(); | |
} | |
function MakeControlDiv(conteinerId, controlName, controlId) { | |
return '<div id="' + controlId + '" class="fieldSelected"> ' + controlName + ' <a href="javascript:void(0)" onClick="RemoveControl(\'' + controlId + '\',\'' + conteinerId + '\');"><img align="middle" border="0" src="' + JsNewAppFolder + '/Content/img/DeleteContact.png"></a></div>'; | |
} | |
//sortable | |
$(function () { | |
$('.placeHolderClass').sortable({ revert: true, scroll: false }); | |
}); | |
//product | |
$("#product").dialog({ | |
bgiframe: true, | |
autoOpen: false, | |
width: 560, | |
Zindex: 5002, | |
modal: true, | |
buttons: | |
{ | |
Adicionar: function () { | |
var flag = false; | |
var productItems = $("#productListBox")[0].options; | |
var selectedProductIds = document.getElementsByName("productCheck"); | |
var ProdutosRepetidos = new Array(); | |
for (selectedProductIndex = 0; selectedProductIndex < selectedProductIds.length; selectedProductIndex++) { | |
flag = true; | |
if (selectedProductIds[selectedProductIndex].checked) { | |
for (productIndex = 0; productIndex < productItems.length; productIndex++) { | |
var product = productItems[productIndex]; | |
if (product.value == selectedProductIds[selectedProductIndex].value.split("{|}")[0]) { | |
flag = false; | |
ProdutosRepetidos[ProdutosRepetidos.length] = selectedProductIds[selectedProductIndex].value.split("{|}")[1]; | |
} | |
} | |
if (flag) { | |
option = document.createElement('option'); | |
option.value = selectedProductIds[selectedProductIndex].value.split("{|}")[0]; | |
option.text = selectedProductIds[selectedProductIndex].value.split("{|}")[1]; | |
option.selected = true; | |
document.getElementById('productListBox').options.add(option); | |
} | |
} | |
} | |
if (ProdutosRepetidos.length == 0) { | |
//if (selectedProductIds.length == 1) | |
//ShowMessage("O Produto foi adicionado com sucesso!"); | |
//else | |
//ShowMessage("Os Produtos foram adicionados com sucesso!"); | |
} | |
else { | |
if (selectedProductIds.length - ProdutosRepetidos.length == 0) | |
ShowMessage("O(s) Produto(s) selecionado(s) já havia(m) sido adicionado(s)!"); | |
else | |
ShowMessage("O(s) produto(s) " + ProdutosRepetidos.join(", ").replace(/\,\s+(.+)$/, " e $1") + " já havia(m) sido adicionado(s). Os demais foram adicionados com sucesso."); | |
} | |
$('#product').dialog('close'); | |
} | |
} | |
}); | |
$('#openProduct').click(function () { | |
$('#product').dialog('open'); | |
}); | |
$('.vtex-button-save').click(function () { | |
ScrollToTop(); | |
}); | |
$("#brandDialog").dialog({ | |
bgiframe: true, | |
autoOpen: false, | |
width: 560, | |
Zindex: 5002, | |
modal: true, | |
buttons: | |
{ | |
Adicionar: function () { | |
var flag = false; | |
var Items = $("#brandListBox")[0].options; | |
var selectedIds = $("input[name='brandCheck']").length > 1 ? $("input[name='brandCheck']") : $("input[name='brandRadio']"); | |
var ProdutosRepetidos = new Array(); | |
selectedIds.each( | |
function () { | |
if ($(this).attr("checked")) { | |
var itemId = $(this).val().split("{|}")[0]; | |
var itemVal = $(this).val().split("{|}")[1]; | |
if ($("#brandListBox>option[value='" + itemId + "']").length == 0) | |
$("#brandListBox").append("<option value='" + itemId + "'>" + itemVal + "</option>"); | |
else | |
ProdutosRepetidos[ProdutosRepetidos.length] = itemVal; | |
} | |
} | |
); | |
if (ProdutosRepetidos.length != 0) | |
ShowMessage("A marca [" + ProdutosRepetidos.join(", ").replace(/\,\s+(.+)$/, " e $1") + "] já havia sido adicionada."); | |
$('#brandDialog').dialog('close'); | |
} | |
} | |
}); | |
$("#colletionDialog").dialog({ | |
bgiframe: true, | |
autoOpen: false, | |
width: 560, | |
Zindex: 5002, | |
modal: true, | |
buttons: | |
{ | |
Adicionar: function () { | |
var flag = false; | |
var Items = $("#productClusterListBox")[0].options; | |
var selectedIds = $("input[name='collectionCheck']").length > 1 ? $("input[name='collectionCheck']") : $("input[name='collectionRadio']"); | |
var ProdutosRepetidos = new Array(); | |
selectedIds.each( | |
function () { | |
if ($(this).attr("checked")) { | |
var itemId = $(this).val().split("{|}")[0]; | |
var itemVal = $(this).val().split("{|}")[1]; | |
if ($("#productClusterListBox>option[value='" + itemId + "']").length == 0) | |
$("#productClusterListBox").append("<option value='" + itemId + "'>" + itemVal + "</option>"); | |
else | |
ProdutosRepetidos[ProdutosRepetidos.length] = itemVal; | |
} | |
} | |
); | |
if (ProdutosRepetidos.length != 0) | |
ShowMessage("Collection [" + ProdutosRepetidos.join(", ").replace(/\,\s+(.+)$/, " e $1") + "] is alredy added."); | |
$('#colletionDialog').dialog('close'); | |
} | |
} | |
}); | |
} | |
function GenerateDatePicker() { | |
var pathImage = JsNewAppFolder + '/Content/themes/base/images/calendar.gif'; | |
$("#startDate").datepicker({ showOn: 'button', buttonImage: pathImage, buttonImageOnly: true, dateFormat: 'dd/mm/yy' }); | |
$("#startDate").datepicker('option', { dateFormat: 'dd/mm/yy' }); | |
// Muda a hora em função da Data Escolhida (startDate -> startTime) | |
$("#startDate").change(function () { | |
if ($("#startDate").attr("value").trim() == "") { | |
$("#endDate").datepicker('option', 'minDate', (new Date(1900, 1, 1))); | |
$("#startTime").attr("value", ""); | |
$("#startTime").attr("disabled", true); | |
} | |
else { | |
$("#startTime").attr("value", "00:00"); | |
$("#startTime").attr("disabled", false); | |
$("#startTime").disabled = false; | |
$("#endDate").datepicker('option', 'minDate', DateValue($("#startDate").attr("value").trim())); | |
if (($("#endDate").attr("value").trim() != "") && (DateValue($("#startDate").attr("value").trim()) > DateValue($("#endDate").attr("value").trim()))) { | |
$("#endDate").attr("value", ""); | |
$("#endTime").attr("value", ""); | |
} | |
} | |
}); | |
// - - - - - - - - - - - - - - - - - - - - | |
// Verifica formatação da hora de início | |
$("#startTime").change(function () { | |
var re = /^[0|1]\d\:[012345]\d$|^2[0123]\:[012345]\d$/; | |
var strTime = $(this).attr("value"); | |
if ((strTime != "") && (!strTime.match(re))) { | |
ShowMessage('Hora Inválida:' + strTime); | |
$(this).attr("value", $("#startDate").attr("value").trim() == "" ? "" : "00:00"); | |
} | |
}); | |
// - - - - - - - - - - - - - - - - - - - - | |
// Verifica Caracter pressionado na hora inicio | |
$("#startTime").keypress(function (e) { | |
if (!(((e.keyCode >= 48) && (e.keyCode <= 58)))) { | |
e.returnValue = false; | |
return false; | |
} | |
}); | |
$("#endDate").datepicker({ showOn: 'button', buttonImage: pathImage, buttonImageOnly: true, dateFormat: 'dd/mm/yy' }); | |
$("#endDate").datepicker('option', { dateFormat: 'dd/mm/yy' }); | |
// Muda a hora em função da Data Escolhida (endDate -> endTime) | |
$("#endDate").change(function () { | |
if ($("#endDate").attr("value").trim() == "") | |
$("#endTime").attr("value", ""); | |
else | |
$("#endTime").attr("value", "23:59"); | |
}); | |
// - - - - - - - - - - - - - - - - - - - - | |
// Verifica formatação da hora de término | |
$("#endTime").change(function () { | |
var re = /^[0|1]\d\:[012345]\d$|^2[0123]\:[012345]\d$/; | |
var strTime = $(this).attr("value"); | |
if ((strTime != "") && (!strTime.match(re))) { | |
ShowMessage('Hora Inválida:' + strTime); | |
$(this).attr("value", $("#endDate").attr("value").trim() == "" ? "" : "00:00"); | |
} | |
}); | |
// - - - - - - - - - - - - - - - - - - - - | |
// Verifica Caracter pressionado na hora inicio | |
$("#endTime").keypress(function (e) { | |
if (!(((e.keyCode >= 48) && (e.keyCode <= 58)))) { | |
e.returnValue = false; | |
return false; | |
} | |
}); | |
// Retorna um objeto Data para uma string de data válida | |
function DateValue(strDataIn) { | |
var arrDataIn = new Array() | |
arrDataIn = strDataIn.replace(/[^\d]/g, "-").split("-"); | |
if (arrDataIn.length != 3) | |
return false; | |
dtDataOut = new Date(parseInt(arrDataIn[2], 10), parseInt(arrDataIn[1], 10) - 1, parseInt(arrDataIn[0], 10)); | |
strCheckIn = parseInt(arrDataIn[0], 10) + "/" + (parseInt(arrDataIn[1], 10) - 1) + "/" + parseInt(arrDataIn[2], 10); | |
strCheckOut = parseInt(dtDataOut.getDate(), 10) + "/" + parseInt(dtDataOut.getMonth(), 10) + "/" + parseInt(dtDataOut.getFullYear(), 10); | |
if (strCheckIn != strCheckOut) | |
return false; | |
return dtDataOut; | |
} | |
} | |
//functions of pickers | |
function findElementInArray(vector, element) { | |
var retorno = false; | |
var p; | |
for (p = 0; p < vector.length; p++) { | |
if (element == vector[p]) | |
retorno = true; | |
} | |
return retorno; | |
} | |
function removeType(idSelectbox, listIds, type) { | |
//variaveis | |
var msgSucesso; var msgVazia; var arrNomesSelecionados = new Array(); | |
var selectbox = $("#" + idSelectbox); | |
// Não há elemento selecionado no selectbox | |
if (selectbox.val() == "") { | |
switch (type) { | |
// Se Removendo Categoria | |
case 'c': | |
msgVazia = "Does not exist categories to be removed!"; | |
break; | |
// Removendo Produto | |
case 'p': | |
msgVazia = "Does not exist products to be removed!"; | |
break; | |
// Removendo Marca | |
case 'm': | |
msgVazia = "Does not exist brands to be removed!"; | |
break; | |
// Removendo Coleções | |
case 'l': | |
msgVazia = "Does not exist collections to be removed!"; | |
break; | |
default: | |
} | |
// Exibe Dialog de erro | |
ShowMessage(msgVazia); | |
return (false); | |
} | |
$("#" + idSelectbox + " option:selected").each(function () { | |
arrNomesSelecionados[arrNomesSelecionados.length] = ("'" + $(this).text() + "'"); | |
$(this).remove(); | |
}); | |
// Formata mensagem de retorno da remoção | |
switch (type) { | |
case 'c': | |
msgSucesso = "Categories: " + arrNomesSelecionados.join(", ").replace(/\,\s+(.+)$/, " e $1") + " were removed!"; | |
break; | |
case 'p': | |
msgSucesso = "Products: " + arrNomesSelecionados.join(", ").replace(/\,\s+(.+)$/, " e $1") + " were removed!"; | |
break; | |
case 'm': | |
msgSucesso = "Brands: " + arrNomesSelecionados.join(", ").replace(/\,\s+(.+)$/, " e $1") + " were removed!"; | |
break; | |
case 'l': | |
msgSucesso = "Collections: " + arrNomesSelecionados.join(", ").replace(/\,\s+(.+)$/, " e $1") + " were removed!"; | |
break; | |
default: | |
} | |
ShowMessage(msgSucesso); | |
} | |
function loadCategory(obj) { | |
document.getElementById('categoryNameSelected').value = obj.name; | |
var categoryObj = obj.rel.split(':')[1]; | |
document.getElementById('categoryIdSelected').value = categoryObj.replace(/\/$/, ''); | |
} | |
function OpenDiv() { | |
$('#product').dialog('open'); | |
} | |
function doOpenDialog(strSelector) { | |
$(strSelector).dialog('open'); | |
//$(strSelector).show(); | |
} | |
function BindFolderFunctions() { | |
if ($('#tabs-folder').is(':data(dialog)')) $('#tabs-folder').dialog("destroy"); | |
$("#tabs-folder").tabs(); | |
} | |
function FolderCreate_Sucess(obj) { | |
BindFolderFunctions(); | |
if (!HasApplicationException(obj.get_data())) { | |
ReloadFileTree(); | |
ShowMessage('Folder successfully saved.'); | |
} | |
} | |
function UrlMappingCreate_Sucess(obj) { | |
if (!HasApplicationException(obj.get_data())) { | |
ShowMessage('Url successfully created.'); | |
UrlMappingBackButtonClick(); | |
} | |
} | |
function websiteDictionary_Sucess(obj) { | |
var reWebSiteId = /\sid\=[\'\"]hdnWebSiteId[\'\"].*?value\=[\'\"]([a-z0-9\-]+)[\'\"]?/i; | |
var websiteMatch = reWebSiteId.exec(obj.get_data()); | |
if (!HasApplicationException(obj.get_data())) { | |
ShowMessage('Dictonary key successfully saved.'); | |
LoadWebSiteDictionary(":" + websiteMatch[1], 'dictionary'); | |
} | |
} | |
function SaveLayoutSetting(obj) { | |
$(function () { | |
$('.placeHolderClass').sortable({ revert: true, scroll: false }); | |
}); | |
BindLayoutFunctions(); | |
$("#tabs-layout").tabs(); | |
$("#tabs-layout").tabs('select', [1]); | |
ShowMessage('Settings successfully saved.'); | |
} | |
function LayoutSaved(obj) { | |
if (!HasApplicationException(obj.get_data())) { | |
ReloadFileTree(); | |
ShowMessage('Layout successfully saved.'); | |
} | |
BindLayoutFunctions(); | |
} | |
function TemplateCreate_Sucess(obj) { | |
if (!HasApplicationException(obj.get_data())) { | |
ShowMessage('Template successfully saved.'); | |
ReloadFileTree(); | |
} | |
} | |
function WebSiteCreate_Sucess(obj) { | |
if (!HasApplicationException(obj.get_data())) { | |
ShowMessage('WebSite successfully saved.'); | |
ReloadFileTree(); | |
} | |
} | |
function ScriptCreate_Sucess(obj) { | |
if (!HasApplicationException(obj.get_data())) { | |
ShowMessage('Script successfully saved.'); | |
ReloadFileTree(); | |
} | |
BindTemplateFunctions(); | |
} | |
function HasApplicationException(textReturned) { | |
var re = /\<applicationExceptionObject\>(.*?)\<\/applicationExceptionObject\>/i; | |
var returnMessage = re.exec(textReturned); | |
if (returnMessage[1].trim() != '') { | |
try { | |
var resultObject = Sys.Serialization.JavaScriptSerializer.deserialize(returnMessage[1].trim()); | |
if (resultObject.originalMessage != 0) { | |
$('#divPortalMessage').html(resultObject.originalMessage); | |
ShowMessage(resultObject.message); | |
} | |
} catch (ex) { | |
ShowMessage(ex); | |
} | |
return true; | |
} | |
} | |
function ReloadFileTree() { | |
try { | |
$(fileTreeSelectedNode).click(); | |
if (!$(fileTreeSelectedNode).hasClass('expanded')) { | |
$(fileTreeSelectedNode).click(); | |
} | |
} catch (e) { } | |
} | |
function ReloadFileTree(folderToRel, layoutFromRel) { | |
if (folderToRel != null && layoutFromRel != null) { | |
var layoutFromQry = $('a[rel$=":' + layoutFromRel.split('/')[1].replace(/\-/g, "") + '/"]').attr("rel"); | |
$('a[rel="' + layoutFromQry + '"]').click(); | |
$('a[rel="' + folderToRel + '"]').click(); | |
$('a[rel="' + folderToRel + '"]').focus(); | |
} else { | |
try { | |
$(fileTreeSelectedNode).click(); | |
if (!$(fileTreeSelectedNode).hasClass('expanded')) { | |
$(fileTreeSelectedNode).click(); | |
} | |
} catch (e) { } | |
} | |
} | |
function Form_Submit_Failure(XMLHttpRequest, textStatus, errorThrown) { | |
var re = /\<title\>(.*?)\<\/title\>/i; | |
var mensagem = XMLHttpRequest.get_data(); | |
var mensagemSaida = re.exec(mensagem); | |
ShowMessage(mensagemSaida[1]); | |
} | |
function ShowMessage(msg) { | |
$("#mensagemUsuario").html(msg); | |
$("#mensagemUsuario").decHTML(); | |
$("#mensagemUsuario").dialog({ | |
bgiframe: true, | |
modal: true, | |
width: 500, | |
zIndex: 5020, | |
buttons: { | |
Ok: function () { | |
$(this).dialog('close'); | |
} | |
} | |
}); | |
$("#mensagemUsuario").dialog('open'); | |
} | |
function ShowAlertMessage(msg) { | |
$("#mensagemUsuario").html(msg); | |
$("#mensagemUsuario").decHTML(); | |
$("#mensagemUsuario").dialog({ | |
bgiframe: true, | |
modal: true, | |
width: 500, | |
buttons: { | |
Ok: function () { | |
ChangeAlertLevel(false); | |
$(this).dialog('close'); | |
} | |
} | |
}); | |
$("#mensagemUsuario").dialog('open'); | |
ChangeAlertLevel(true); | |
} | |
function ShowAlertMessageConfirm(msg, cb) { | |
var retorno = false; | |
$("#mensagemUsuario").html(msg); | |
$("#mensagemUsuario").decHTML(); | |
$("#mensagemUsuario").dialog({ | |
bgiframe: true, | |
modal: true, | |
width: 500, | |
buttons: { | |
'Confirmar': function () { | |
if (cb) { | |
cb(); | |
} | |
ChangeAlertLevel(false); | |
$(this).dialog('close'); | |
retorno = true; | |
}, | |
'Cancelar': function () { | |
ChangeAlertLevel(false); | |
$(this).dialog('close'); | |
} | |
} | |
}); | |
$("#mensagemUsuario").dialog('open'); | |
ChangeAlertLevel(true); | |
return retorno; | |
} | |
function EncodeHTML(text) { | |
var div = document.createElement('div'); | |
var text1 = document.createTextNode(text); | |
div.appendChild(text1); | |
return div.innerHTML; | |
}; | |
jQuery.fn.encHTML = function () { | |
return this.each(function () { | |
var me = jQuery(this); | |
var html = me.html(); | |
me.html(html.replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>')); | |
}); | |
}; | |
jQuery.fn.decHTML = function () { | |
return this.each(function () { | |
var me = jQuery(this); | |
var html = me.html(); | |
me.html(html.replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>')); | |
}); | |
}; | |
function OpenConfirmFolderDel(obj) { | |
if ($('#dialog').is(':data(dialog)')) $('#dialog').dialog("destroy"); | |
$("#dialog-confirm").dialog('open'); | |
} | |
function OpenConfirmLayoutClone(obj) { | |
if ($('#dialog').is(':data(dialog)')) $('#dialog').dialog("destroy"); | |
$("#dialog-confirm").dialog('open'); | |
} | |
function MakeConfirmDialog() { | |
if ($('#dialog').is(':data(dialog)')) $('#dialog').dialog("destroy"); | |
if ($('#dialog-confirm').is(':data(dialog)')) $('#dialog-confirm').dialog("destroy"); | |
$('#dialog-confirm').dialog({ | |
stackfix: true, | |
bgiframe: true, | |
resizable: false, | |
width: 400, | |
modal: true, | |
title: 'Atention!', | |
overlay: { | |
backgroundColor: '#000', | |
opacity: 0.5 | |
}, | |
close: function (event, ui) { | |
if ($('#templates').length > 0) { | |
if ($('#hasChanged').val() == '') { | |
$('#templates').val($('#originalTemplate').val()) | |
} | |
} | |
}, | |
open: function (event, ui) { | |
} | |
}); | |
var confirmDialog = $('#dialog-confirm'); | |
$("#dialog-confirm").html('loading. . . . . .'); | |
$("#dialog-confirm").dialog('open'); | |
if ($(confirmDialog).dialog('isOpen')) { | |
$(confirmDialog).dialog('close'); | |
} | |
} | |
function FolderDel_Sucess(obj) { | |
ReloadFileTree(); | |
ShowMessage("Folder deleted successfully."); | |
} | |
function LayoutDel_Sucess(obj) { | |
ReloadFileTree(); | |
ShowMessage("Layout deleted successfully."); | |
} | |
function LayoutClone_Sucess(obj) { | |
ReloadFileTree(); | |
ShowMessage("Layout copied successfully."); | |
} | |
function TemplateDel_Sucess(obj) { | |
ReloadFileTree(); | |
ShowMessage("Template deleted successfully."); | |
} | |
function WebSiteDel_Sucess(obj) { | |
ReloadFileTree(); | |
ShowMessage("Web-site deleted successfully."); | |
} | |
function CloseConfirmLayoutClone(form) { | |
if (form.webSiteId.value != '') { | |
$("#dialog-confirm").dialog("close"); | |
return true; | |
} | |
ShowAlertMessage('Please select the web-site!'); | |
return false; | |
} | |
function CloseConfirmDialog(form) { | |
if (form.textConfirm.value == 'yes') { | |
$("#dialog-confirm").dialog("close"); | |
return true; | |
} | |
ShowAlertMessage('Type "yes" to confirm!'); | |
return false; | |
} | |
function GetFormParameter(nameParameter, formParameterSplited) { | |
for (i = 0; i < formParameterSplited.length; i++) { | |
parameterLine = formParameterSplited[i].split('='); | |
if (parameterLine[0] == nameParameter) | |
return parameterLine[1]; | |
} | |
} | |
function HandleContentListToSubmit(form) { | |
if (MakeCustomViewPartFields()) { | |
if (ValidateFormShelfConfig(form)) { | |
contentRows = $('.divFieldSetDataRow'); | |
if (MakeContentInputHidden(contentRows, form.viewPartInstanceId.value) != 'false') { | |
form.contentList.value = MakeContentInputHidden(contentRows, form.viewPartInstanceId.value); | |
return true; | |
} else return false; | |
} else return false; | |
} else return false; | |
} | |
function MakeContentInputHidden(contents, viewPartInstanceId) { | |
var ShelfContentColletion = new Array(); | |
var stringContent = ''; | |
for (i = 0; i < contents.length; i++) { | |
if (MakeShelfContentObject(viewPartInstanceId, i, contents[i], 'object') != 'false') { | |
ShelfContentColletion[i] = MakeShelfContentObject(viewPartInstanceId, i, contents[i], 'object'); | |
} else return 'false'; | |
} | |
return Sys.Serialization.JavaScriptSerializer.serialize(ShelfContentColletion); | |
} | |
function HandleLayoutTemplateChange(form) { | |
if (form.textConfirm.value == 'yes') { | |
$('#hasChanged').val('true'); | |
$("#dialog-confirm").dialog('close'); | |
} else { | |
ShowAlertMessage('Please type yes to confirm.') | |
} | |
} | |
function removeDateToList(sender, indice) { | |
$('#' + sender).remove(); | |
$("#contentDateCount").val(parseInt($("#contentDateCount").val()) - 1); | |
} | |
function MakeShelfContentPeriods(dateList) { | |
var periodText = ""; | |
if (dateList.length > 0) { | |
for (i = 0; i < dateList.length; i++) { | |
var dateFrom = ""; | |
var dateTo = ""; | |
var onlyDateFrom = $('input[name^=dateFromList]', dateList[i]).val(); | |
var onlyHourFrom = $('input[name^=hourFromList]', dateList[i]).val(); | |
var onlyDateTo = $('input[name^=dateToList]', dateList[i]).val(); | |
var onlyHourTo = $('input[name^=hourToList]', dateList[i]).val(); | |
dateFrom = onlyDateFrom + ' ' + onlyHourFrom; | |
dateTo = onlyDateTo + ' ' + onlyHourTo; | |
if (dateFrom.trim() == "") dateFrom = "......................"; | |
if (dateTo.trim() == "") dateTo = "......................"; | |
periodText += "<b>" + (i + 1) + "</b>:" + dateFrom + "<b>-</b>" + dateTo + "<br />"; | |
} | |
} | |
return periodText; | |
} | |
function MakeShelfContentPeriodDivs(dateList) { | |
var periodDivs = ""; | |
if (dateList.length > 0) { | |
for (i = 0; i < dateList.length; i++) { | |
var dateFrom = ""; | |
var dateTo = ""; | |
var onlyDateFrom = $('input[name^=dateFromList]', dateList[i]).val(); | |
var onlyHourFrom = $('input[name^=hourFromList]', dateList[i]).val(); | |
var onlyDateTo = $('input[name^=dateToList]', dateList[i]).val(); | |
var onlyHourTo = $('input[name^=hourToList]', dateList[i]).val(); | |
dateFrom = onlyDateFrom + ' ' + onlyHourFrom; | |
dateTo = onlyDateTo + ' ' + onlyHourTo; | |
periodDivs += "<div id=\"dateTime" + i + "\" class=\"periodDateItens\" dateTimeFrom=\"" + dateFrom + "\" dateTimeTo=\"" + dateTo + "\"></div>"; | |
} | |
} | |
return periodDivs; | |
} | |
function EditContentRow(divId, indice) { | |
var viewPartInstanceId = $('#viewPartInstanceId').val(); | |
var rowData = MakeShelfContentObject(viewPartInstanceId, indice, divId, 'text'); | |
if (rowData != 'false') { | |
var contentURL = JsNewAppFolder + '/PortalManagement/GetShelfContentForm'; | |
var postData = { contentStringData: rowData }; | |
AjaxRequest('POST', contentURL, '#configContent', '', '', postData); | |
$('#ui-datepicker-div').addClass('vtex-zindex-promote'); | |
CssFixConfigShelf('configContent', '90px'); | |
$('#configContent').dialog('open'); | |
} | |
} | |
function EditContentRowByName(divName, indice) { | |
var viewPartInstanceId = $('#viewPartInstanceId').val(); | |
var div = $('#' + divName); | |
var rowData = MakeShelfContentObject(viewPartInstanceId, indice, div, 'text'); | |
if (rowData != 'false') { | |
contentURL = JsNewAppFolder + '/PortalManagement/GetShelfContentForm'; | |
var postData = { contentStringData: rowData }; | |
AjaxRequest('POST', contentURL, '#configContent', '', '', postData); | |
$('#ui-datepicker-div').addClass('vtex-zindex-promote'); | |
CssFixConfigShelf('configContent', '90px'); | |
$('#configContent').dialog('open'); | |
} | |
} | |
function ShelfAddDateToList() { | |
if ($("#dateFromShelf").attr("value").trim() != "" || $("#dateToShelf").attr("value").trim() != "") { | |
var dateFrom, hourFrom, dateTo, hourTo, i, hrefToDel, table; | |
i = $("#contentDateCount").val(); | |
hrefToDel = "<a href=\"javascript:void(0)\" class=\"IconDel\" onclick=\"removeDateToList('divDate" + i + "'," + i + ")\"> </a>"; | |
dateFrom = $("#dateFromShelf").attr("value").trim(); | |
hourFrom = $("#hourFrom").attr("value").trim(); | |
dateTo = $("#dateToShelf").attr("value").trim(); | |
hourTo = $("#hourTo").attr("value").trim(); | |
table = '<table width="100%" align="center" class="shelfDateItem">'; | |
table += '<tr><td width="15%">De:</td><td width="30%">' + MakeInputText("dateFromList-" + i, dateFrom, "vtex-datepicker") + " " + MakeInputText("hourFromList-" + i, hourFrom, "vtex-hour"); | |
table += '</td><td width="15%">Até:</td><td width="30%">' + MakeInputText("dateToList-" + i, dateTo, "vtex-datepicker") + " " + MakeInputText("hourToList-" + i, hourTo, "vtex-hour") + '</td><td width="10%">' + hrefToDel + '</td></tr>'; | |
table += '</table>'; | |
$(".ShelfContentDateList").append("<div id=\"divDate" + i + "\" dateFrom=\"" + dateFrom + "\" hourFrom =\"" + hourFrom + "\" dateTo=\"" + dateTo + "\" hourTo=\"" + hourTo + "\" class=\"shelfDateItens\">" + table + "</div>") | |
$("#contentDateCount").val(parseInt($("#contentDateCount").val()) + 1); | |
var pathImage = JsNewAppFolder + '/Content/themes/base/images/calendar.gif'; | |
$('.vtex-datepicker').datepicker({ showOn: 'both', buttonImage: pathImage, buttonImageOnly: true, dateFormat: 'dd/mm/yy' }); | |
$('.vtex-datepicker').attr('readonly', true); | |
ClearDates(); | |
} | |
} | |
function MakeInputText(name, value, css) { | |
return '<input class="' + css + '" type="text" name="' + name + '" value="' + value + '" />'; | |
} | |
function ClearDates() { | |
$("#dateFromShelf").attr("value", ""); | |
$("#hourFrom").attr("value", ""); | |
$("#dateToShelf").attr("value", ""); | |
$("#hourTo").attr("value", ""); | |
} | |
//json objects-------------------------------------------------------------------------------------- | |
function ControlContentByParameters(ViewPartInstanceId, Indice, ContentName, Partner, Campaign, Category, Brand, Source, Keyword, Periods, Active, Id) { | |
this.ViewPartInstanceId = ViewPartInstanceId; | |
this.Indice = Indice; | |
this.ContentName = ContentName; | |
this.Partner = Partner; | |
this.Campaign = Campaign; | |
this.Category = Category; | |
this.Brand = Brand; | |
this.Source = Source; | |
this.Keyword = Keyword; | |
this.Periods = Periods; | |
this.Active = Active; | |
if (Id != null) | |
this.Id = Id; | |
} | |
function ControlContent(controlContentObj) {//overload | |
this.ViewPartInstanceId = controlContentObj.ViewPartInstanceId; | |
this.Indice = controlContentObj.Indice; | |
this.ContentName = controlContentObj.ContentName; | |
this.Partner = controlContentObj.Partner; | |
this.Campaign = controlContentObj.Campaign; | |
this.Category = controlContentObj.Category; | |
this.Brand = controlContentObj.Brand; | |
this.Source = controlContentObj.Source; | |
this.Keyword = controlContentObj.Keyword; | |
this.Periods = controlContentObj.Periods; | |
this.Active = controlContentObj.Active; | |
if (controlContentObj.Id != null) | |
this.Id = controlContentObj.Id; | |
} | |
function ShelfContent(controlContentObj, aProductCluster, aQueryString) { | |
this.newMethod = ControlContent; //extend ControlContent | |
this.newMethod(controlContentObj); | |
delete this.newMethod; | |
this.ProductCluster = aProductCluster; | |
this.SearchQueryString = aQueryString; | |
} | |
function BannerContent(controlContentObj, aWidth, aHeight, aFileType, aLinkUrl, aFileName) { | |
this.newMethod = ControlContent; //extend ControlContent | |
this.newMethod(controlContentObj); | |
delete this.newMethod; | |
this.Width = aWidth; | |
this.Height = aHeight; | |
this.FileType = aFileType; | |
this.LinkUrl = aLinkUrl; | |
this.FileName = aFileName; | |
} | |
function BannerDhtmlContent(controlContentObj, bannerContent, xPosition, yPosition, timer) { | |
this.newMethod = BannerContent; //extend BannerContent | |
this.newMethod(controlContentObj, bannerContent.Width, bannerContent.Height, bannerContent.FileType, bannerContent.LinkUrl, bannerContent.FileName); | |
delete this.newMethod; | |
this.XPosition = xPosition; | |
this.YPosition = yPosition; | |
this.Timer = timer; | |
} | |
function HtmlContent(controlContentObj, aHtml, aFileName) { | |
this.newMethod = ControlContent; //extend ControlContent | |
this.newMethod(controlContentObj); | |
delete this.newMethod; | |
this.FileName = aFileName; | |
this.Html = aHtml; | |
} | |
function RealMediaContent(controlContentObj, aPosition) { | |
this.newMethod = ControlContent; //extend ControlContent | |
this.newMethod(controlContentObj); | |
delete this.newMethod; | |
this.Position = aPosition; | |
} | |
function Period(aDateFrom, aDateTo) { | |
this.From = aDateFrom; | |
this.To = aDateTo; | |
} | |
//construtor dos objetos----------------------------------------------------------------- | |
//conteudo generico | |
function MakeControlContent(viewPartInstanceId, indice, content) { | |
if ($.trim($(content).children('#contentName').children('textarea').val()) == '') { | |
ShowMessage("O nome do conteúdo é obrigatório na linha " + (indice + 1)); | |
return 'false'; | |
} | |
var controlContent = new ControlContentByParameters(viewPartInstanceId, | |
indice, | |
$(content).children('#contentName').children('textarea').val().trim(), | |
$(content).children('#partner').children('textarea').val().trim(), | |
$(content).children('#campaign').children('textarea').val().trim(), | |
$(content).children('#category').text().trim(), | |
$(content).children('#brand').text().trim(), | |
$(content).children('#source').children('textarea').val().trim(), | |
$(content).children('#keyword').children('textarea').val().trim(), | |
MakeContentPeriods($(content).children('#period')), | |
$(content).children('#active').children('input:checkbox').is(':checked'), | |
$(content).children('#id').html() | |
); | |
return controlContent; | |
} | |
function MakeBannerCommonContent(myContentObj, viewPartInstanceId, indice, content) { | |
ValidateBannerCommonContent(indice, content); | |
return new BannerContent(myContentObj, | |
$(content).children('#width').children('textarea').val().trim(), | |
$(content).children('#height').children('textarea').val().trim(), | |
$(content).children('#fileType').html().trim(), | |
$(content).children('#linkUrl').children('textarea').val().trim(), | |
$(content).children('#fileName').html().trim() | |
); | |
} | |
function MakeRealMediaCommonContent(viewPartInstanceId, indice, content) { | |
if ($(content).children('#position').children('textarea').val().trim() == '') { | |
ShowMessage("A posição é obrigatório na linha " + (indice + 1)); | |
return 'false'; | |
} | |
return $(content).children('#position').children('textarea').val().trim() | |
} | |
function ValidateBannerCommonContent(indice, content) { | |
var localWidth = $(content).children('#width').children('textarea').val().trim(); | |
if (localWidth == '') { | |
ShowMessage("A largura do banner é obrigatório na linha " + (indice + 1)); | |
} else { | |
if (isNaN(localWidth)) { | |
ShowMessage("A largura do banner não é um número válido na linha " + (indice + 1)); | |
} | |
} | |
var localHeight = $(content).children('#height').children('textarea').val().trim(); | |
if (localHeight == '') { | |
ShowMessage("A altura do banner é obrigatório na linha " + (indice + 1)); | |
} else { | |
if (isNaN(localHeight)) { | |
ShowMessage("A altura do banner não é um número válido na linha " + (indice + 1)); | |
} | |
} | |
/*var localLinkUrl = $(content).children('#linkUrl').children('textarea').val().trim(); | |
if (localLinkUrl == '') { | |
ShowMessage("A url do banner é obrigatório na linha " + (indice + 1)); | |
}*/ | |
} | |
//prateleira---------------------------------------------------------------------------------- | |
function MakeShelfContentObject(viewPartInstanceId, indice, content, returnType) { | |
var myContent = MakeControlContent(viewPartInstanceId, indice, content); | |
if (myContent != 'false') { | |
if ($(content).children('#productCluster').children('a').html() == '' && $(content).children('#queryString').children('textarea').val().trim() == '') { | |
ShowMessage("O campo consulta é obrigatório na linha linha " + (indice + 1)); | |
return 'false'; | |
} | |
var shelfContent = new ShelfContent(myContent, | |
$(content).children('#productCluster').children('a').html(), | |
$(content).children('#queryString').children('textarea').val().trim() | |
); | |
if (returnType == "text") return Sys.Serialization.JavaScriptSerializer.serialize(shelfContent); | |
if (returnType == "object") return shelfContent; | |
} else return 'false'; | |
} | |
//banner --------------------------------------------------------------------------------------------- | |
function MakeBannerContentObject(viewPartInstanceId, indice, content, returnType) { | |
var myContent = MakeControlContent(viewPartInstanceId, indice, content); | |
if (myContent != 'false') { | |
var bannerContent = MakeBannerCommonContent(myContent, viewPartInstanceId, indice, content); | |
if (returnType == "text") return Sys.Serialization.JavaScriptSerializer.serialize(bannerContent); | |
if (returnType == "object") return bannerContent; | |
} else return 'false'; | |
} | |
//banner dhtm---------------------------------------------------------------------------------------------- | |
function MakeBannerDhtmlContentObject(viewPartInstanceId, indice, content, returnType) { | |
var myContent = MakeControlContent(viewPartInstanceId, indice, content); | |
if (myContent != 'false') { | |
var bannerContent = MakeBannerCommonContent(myContent, viewPartInstanceId, indice, content); | |
if (ValidateBannerDhtmlContent(indice, content)) { | |
var bannerDhtmContent = new BannerDhtmlContent(myContent, | |
bannerContent, | |
$(content).children('#xPosition').children('textarea').val().trim(), | |
$(content).children('#yPosition').children('textarea').val().trim(), | |
$(content).children('#timer').children('textarea').val().trim() | |
); | |
if (returnType == "text") return Sys.Serialization.JavaScriptSerializer.serialize(bannerDhtmContent); | |
if (returnType == "object") return bannerDhtmContent; | |
} else return 'false'; | |
} else return 'false'; | |
} | |
function ValidateBannerDhtmlContent(indice, content) { | |
var localX = $(content).children('#xPosition').children('textarea').val().trim(); | |
if (localX == '') { | |
ShowMessage("A posição X do banner é obrigatório na linha " + (indice + 1)); | |
return false; | |
} else { | |
if (isNaN(localX)) { | |
ShowMessage("A posição X do banner não é um número válido na linha " + (indice + 1)); | |
return false; | |
} | |
} | |
var localYY = $(content).children('#yPosition').children('textarea').val().trim(); | |
if (localYY == '') { | |
ShowMessage("A posição Y do banner é obrigatório na linha " + (indice + 1)); | |
return false; | |
} else { | |
if (isNaN(localYY)) { | |
ShowMessage("A posição Y do banner não é um número válido na linha " + (indice + 1)); | |
return false; | |
} | |
} | |
var localTimer = $(content).children('#timer').children('textarea').val().trim(); | |
if (localTimer == '') { | |
ShowMessage("O Temporizador (T.) do banner é obrigatório na linha " + (indice + 1)); | |
return false; | |
} else { | |
if (isNaN(localTimer)) { | |
ShowMessage("O Temporizador (T.) do banner não é um número válido na linha " + (indice + 1)); | |
return false; | |
} | |
} | |
return true; | |
} | |
//html-------------------------------------------------------------------------------------------------------- | |
function MakeHtmlContentObject(viewPartInstanceId, indice, content, returnType) { | |
var myContent = MakeControlContent(viewPartInstanceId, indice, content); | |
if (myContent != 'false') { | |
var htmlContent = new HtmlContent(myContent, | |
unescape($(content).children('#html').children('a').attr('title').trim()), | |
$(content).children('#fileName').html().trim() | |
); | |
if (returnType == "text") return Sys.Serialization.JavaScriptSerializer.serialize(htmlContent); | |
if (returnType == "object") return htmlContent; | |
} else return 'false'; | |
} | |
//--periodos | |
function MakeContentPeriods(div) { | |
var periodDateItens = $(div).children('.periodDateItens'); | |
var Periods = new Array(); | |
var period = null; | |
for (var i = 0; i < periodDateItens.length; i++) { | |
period = new Period($(periodDateItens[i]).attr('dateTimeFrom'), $(periodDateItens[i]).attr('dateTimeTo')); | |
Periods[i] = period; | |
} | |
return Periods; | |
} | |
//---------------------------------------------------------------------------------------------------------------- | |
function EditHtmlContentRow(divId, indice) { | |
var viewPartInstanceId = $('#viewPartInstanceId').val(); | |
var rowData = MakeHtmlContentObject(viewPartInstanceId, indice, divId, 'text'); | |
if (rowData != 'false') { | |
contentURL = JsNewAppFolder + '/PortalManagement/GetHtmlContentForm'; | |
var data = { viewPartInstanceId: viewPartInstanceId, contentStringData: rowData }; | |
AjaxRequest('POST', contentURL, '#configContent', '', '', data); | |
$('#ui-datepicker-div').addClass('vtex-zindex-promote'); | |
CssFixConfigShelf('configContent', '90px'); | |
$('#configContent').dialog('open'); | |
} | |
} | |
function EditHtmlContentRowByName(divName, indice) { | |
var viewPartInstanceId = $('#viewPartInstanceId').val(); | |
var div = $('#' + divName); | |
var rowData = MakeHtmlContentObject(viewPartInstanceId, indice, div, 'text'); | |
if (rowData != 'false') { | |
contentURL = JsNewAppFolder + '/PortalManagement/GetHtmlContentForm'; | |
var data = { viewPartInstanceId: viewPartInstanceId, contentStringData: rowData }; | |
AjaxRequest('POST', contentURL, '#configContent', '', '', data); | |
$('#ui-datepicker-div').addClass('vtex-zindex-promote'); | |
CssFixConfigShelf('configContent', '90px'); | |
$('#configContent').dialog('open'); | |
} | |
} | |
function HandleHtmlContentListToSubmit(form) { | |
if (MakeCustomViewPartFields()) { | |
contentRows = $('.divFieldSetHtmlDataRow'); | |
if (MakeHtmlContentInputHidden(contentRows, form.viewPartInstanceId.value) != 'false') { | |
$('#htmlContentList').val(MakeHtmlContentInputHidden(contentRows, form.viewPartInstanceId.value)); | |
} else return false; | |
} else { | |
return false; | |
} | |
} | |
function MakeHtmlContentInputHidden(contents, viewPartInstanceId) { | |
var HtmlContentList = new Array(); | |
for (var i = 0; i < contents.length; i++) { | |
if (MakeHtmlContentObject(viewPartInstanceId, i, contents[i], 'object') != 'false') { | |
HtmlContentList[i] = MakeHtmlContentObject(viewPartInstanceId, i, contents[i], 'object'); | |
} else return 'false'; | |
} | |
return Sys.Serialization.JavaScriptSerializer.serialize(HtmlContentList); | |
} | |
function HandleBannerContentListToSubmit(form) { | |
if (MakeCustomViewPartFields()) { | |
contentRows = $('.divFieldSetBannerDataRow'); | |
if (MakeBannerContentInputHidden(contentRows, form.viewPartInstanceId.value) != 'false') { | |
$('#bannerContentList').val(MakeBannerContentInputHidden(contentRows, form.viewPartInstanceId.value)); | |
} else return false; | |
} else { | |
return false; | |
} | |
} | |
function ContainsOnlyLetters(str) { | |
var replace1 = str.replace(/[a-zA-Z]+/, ""); | |
return ((replace1 == '')); | |
} | |
function MakeCustomViewPartFields(form) { | |
if ($('#isCustomViewPart').val() == 'True') { | |
var vpCustomId = $('#customViewPartIdOut').val(); | |
var vpId = $('#viewPartIdOut').val(); | |
var isPersisted = $('#customViewPartisPersistedOut').val(); | |
var vpCustomName = $('#customViewPartNameOut').val(); | |
var vpCustomTagName = $('#customViewPartTagNameOut').val(); | |
var vpCustomType = $('#customViewPartTypeOut').val().split('||')[0].trim(); | |
if (vpCustomName.trim() == '') { | |
ShowMessage("O nome do controle customizado é obrigatório."); | |
return false; | |
} | |
if (vpCustomTagName.trim() == '') { | |
ShowMessage("O nome da tag do controle customizado é obrigatório."); | |
return false; | |
} else { | |
if (!ContainsOnlyLetters(vpCustomTagName.trim())) { | |
ShowMessage("O nome da tag do controle customizado só pode conter letras."); | |
return false; | |
} | |
} | |
$('#customViewPartId').val(vpCustomId); | |
$('#viewPartId').val(vpId); | |
$('#customViewPartName').val(vpCustomName); | |
$('#customViewPartTagName').val(vpCustomTagName); | |
$('#customViewPartTypeId').val(vpCustomType); | |
$('#customViewPartisPersisted').val(isPersisted); | |
} | |
return true; | |
} | |
function MakeBannerContentInputHidden(contents, viewPartInstanceId) { | |
var BannerContentList = new Array(); | |
for (i = 0; i < contents.length; i++) { | |
if (MakeBannerContentObject(viewPartInstanceId, i, contents[i], 'object') != 'false') { | |
BannerContentList[i] = MakeBannerContentObject(viewPartInstanceId, i, contents[i], 'object'); | |
} else return 'false'; | |
} | |
return Sys.Serialization.JavaScriptSerializer.serialize(BannerContentList); | |
} | |
function HandleBannerDhtmlContentListToSubmit(form) { | |
if (MakeCustomViewPartFields()) { | |
contentRows = $('.divFieldSetBannerDataRow'); | |
if (MakeBannerDhtmlContentInputHidden(contentRows, form.viewPartInstanceId.value) != 'false') { | |
$('#bannerContentList').val(MakeBannerDhtmlContentInputHidden(contentRows, form.viewPartInstanceId.value)); | |
} else return false; | |
} else return false; | |
} | |
function MakeBannerDhtmlContentInputHidden(contents, viewPartInstanceId) { | |
var BannerContentList = new Array(); | |
for (i = 0; i < contents.length; i++) { | |
if (MakeBannerDhtmlContentObject(viewPartInstanceId, i, contents[i], 'object') != 'false') { | |
BannerContentList[i] = MakeBannerDhtmlContentObject(viewPartInstanceId, i, contents[i], 'object'); | |
} else return 'false'; | |
} | |
return Sys.Serialization.JavaScriptSerializer.serialize(BannerContentList); | |
} | |
function EditBannerContentRowByName(divName, indice) { | |
var viewPartInstanceId = $('#viewPartInstanceId').val(); | |
var div = $('#' + divName); | |
var rowData = MakeBannerContentObject(viewPartInstanceId, indice, div, 'text'); | |
if (rowData != 'false') { | |
contentURL = JsNewAppFolder + '/PortalManagement/GetBannerContentForm'; | |
var postData = { viewPartInstanceId: viewPartInstanceId, contentStringData: rowData }; | |
AjaxRequest('POST', contentURL, '#configContent', '', '', postData); | |
$('#ui-datepicker-div').addClass('vtex-zindex-promote'); | |
CssFixConfigShelf('configContent', '90px'); | |
$('#configContent').dialog('open'); | |
} | |
} | |
function EditBannerContentRow(divId, indice) { | |
var viewPartInstanceId = $('#viewPartInstanceId').val(); | |
var rowData = MakeBannerContentObject(viewPartInstanceId, indice, divId, 'text'); | |
if (rowData != 'false') { | |
contentURL = JsNewAppFolder + '/PortalManagement/GetBannerContentForm'; | |
var postData = { viewPartInstanceId: viewPartInstanceId, contentStringData: rowData }; | |
AjaxRequest('POST', contentURL, '#configContent', '', '', postData); | |
$('#ui-datepicker-div').addClass('vtex-zindex-promote'); | |
CssFixConfigShelf('configContent', '90px'); | |
$('#configContent').dialog('open'); | |
} | |
} | |
//Dhtml | |
function EditBannerDhtmlContentRowByName(divName, indice) { | |
var viewPartInstanceId = $('#viewPartInstanceId').val(); | |
var div = $('#' + divName); | |
var rowData = MakeBannerDhtmlContentObject(viewPartInstanceId, indice, div, 'text'); | |
if (rowData != 'false') { | |
contentURL = JsNewAppFolder + '/PortalManagement/GetBannerDhtmlContentForm'; | |
var postData = { viewPartInstanceId: viewPartInstanceId, contentStringData: rowData }; | |
AjaxRequest('POST', contentURL, '#configContent', '', '', postData); | |
$('#ui-datepicker-div').addClass('vtex-zindex-promote'); | |
CssFixConfigShelf('configContent', '90px'); | |
$('#configContent').dialog('open'); | |
} | |
} | |
function EditBannerDhtmlContentRow(divId, indice) { | |
var viewPartInstanceId = $('#viewPartInstanceId').val(); | |
var rowData = MakeBannerDhtmlContentObject(viewPartInstanceId, indice, divId, 'text'); | |
if (rowData != 'false') { | |
contentURL = JsNewAppFolder + '/PortalManagement/GetBannerDhtmlContentForm'; | |
var postData = { viewPartInstanceId: viewPartInstanceId, contentStringData: rowData }; | |
AjaxRequest('POST', contentURL, '#configContent', '', '', postData); | |
$('#ui-datepicker-div').addClass('vtex-zindex-promote'); | |
CssFixConfigShelf('configContent', '90px'); | |
$('#configContent').dialog('open'); | |
} | |
} | |
//insere ou atualiza a linha na grid de conteudo de prateleira-------------------------------------------------------------------------------------------------------- | |
function SaveRowToGrid(form) { | |
if (ValidateFormShelfContent(form)) { | |
if (form['indice'].value == 'new') { | |
InsertFields(form); | |
} else { | |
UpdateFields(form); | |
} | |
$('#configContent').dialog('close'); | |
} | |
} | |
//atualiza | |
function UpdateFields(form) { | |
var contentRows = $('.divFieldSetDataRow'); | |
var divToEdit = contentRows[form['indice'].value]; | |
var collectionText = '<a class="IconView" title="' + escape($.trim(form['productClusterShelfName'].value)) + '">' + escape($.trim(form['productClusterShelf'].value)) + '</a>'; | |
$(divToEdit).children('#productCluster').html(collectionText); | |
$(divToEdit).children('#queryString').children('textarea').val(form['searchQueryString'].value); | |
MakeCommonFields(divToEdit, form, 'update'); | |
var hrefEdit = '<a title="edit" href="javascript:void(0)" class="IconEdit" onclick="EditContentRow(' + $(divToEdit)[0].id + ', ' + form['indice'].value + ');"> </a>'; | |
var hrefDel = '<a title="remove" href="javascript:void(0)" class="IconDel" onclick="RemoveContentRow(' + $(divToEdit)[0].id + ');"> </a>'; | |
$(divToEdit).children('#edit').html(hrefEdit + ' ' + hrefDel); | |
} | |
//insere | |
function InsertFields(form) { | |
var num = parseInt($('#totalRows').val()) + 1; | |
var divId = 'FieldDiv_' + num; | |
var divCopy = $('#divFieldSet').clone(true); | |
$(divCopy).addClass("divFieldSetDataRow"); | |
$(divCopy).addClass("divFieldSetShelfAnyRow"); | |
$(divCopy).id = divId; | |
var collectionText = '<a class="IconView" title="' + escape($.trim(form['productClusterShelfName'].value)) + '">' + escape($.trim(form['productClusterShelf'].value)) + '</a>'; | |
//var queryStringText = '<a class="IconView" title="' + escape(form['searchQueryString'].value) + '">' + 'Consulta' + '</a>'; | |
$(divCopy).children('#productCluster').html(collectionText); | |
$(divCopy).children('#queryString').html(MakeTextAreaField(form['searchQueryString'].value, '36')); | |
MakeCommonFields(divCopy, form, 'insert'); | |
var hrefEdit = '<a href="javascript:void(0)" class="IconEdit" onclick="EditContentRow(' + $(divCopy)[0].id + ', ' + (num - 1) + ');"> </a>'; | |
var hrefDel = '<a href="javascript:void(0)" class="IconDel" onclick="RemoveContentRow(' + $(divCopy)[0].id + ');"> </a>'; | |
$(divCopy).children('#edit').html(hrefEdit + ' ' + hrefDel); | |
if ($('#rowsContent .divFieldSetShelfAnyRow:last').length > 0) { | |
$('#rowsContent .divFieldSetShelfAnyRow:last').after(divCopy); | |
} else { | |
$('#rowsContent').append(divCopy); | |
} | |
$("#totalRows").val(num); | |
} | |
//--trata os campos em comum das peças----------------------------------------------------------------------------------------------------------------------------------------- | |
function MakeCommonFields(divCopy, form, action) { | |
var periodText = ""; | |
var periodDivs = ""; | |
var checked = false; | |
var dateRangeList = $(".shelfDateItens"); | |
periodText = MakeShelfContentPeriods(dateRangeList); | |
periodDivs = MakeShelfContentPeriodDivs(dateRangeList); | |
if (form['active'][0].checked) checked = true; | |
if (action == 'update') { | |
$(divCopy).children('#contentName').children('textarea').val(form['contentName'].value); | |
$(divCopy).children('#partner').children('textarea').val(form['partner'].value); | |
$(divCopy).children('#campaign').children('textarea').val(form['campaign'].value); | |
$(divCopy).children('#category').html(form['candidateCategory'].value); | |
$(divCopy).children('#brand').html(form['candidateBrand'].value); | |
$(divCopy).children('#source').children('textarea').val(form['source'].value); | |
$(divCopy).children('#keyword').children('textarea').val(form['keyword'].value); | |
$(divCopy).children('#period').html(periodText + periodDivs); | |
$(divCopy).children('#active').children('input:checkbox').attr('checked', checked); | |
} else { | |
$(divCopy).children('#contentName').html(MakeTextAreaField(form['contentName'].value, '18', '')); | |
$(divCopy).children('#partner').html(MakeTextAreaField(form['partner'].value, '18', '')); | |
$(divCopy).children('#campaign').html(MakeTextAreaField(form['campaign'].value, '18', '')); | |
$(divCopy).children('#category').html(form['candidateCategory'].value); | |
$(divCopy).children('#brand').html(form['candidateBrand'].value); | |
$(divCopy).children('#source').html(MakeTextAreaField(form['source'].value, '18', '')); | |
$(divCopy).children('#keyword').html(MakeTextAreaField(form['keyword'].value, '18', '')); | |
$(divCopy).children('#period').html(periodText + periodDivs); | |
$(divCopy).children('#active').html('<INPUT id="checkBoxActive" value="' + checked + '" ' + (checked == true ? 'checked="checked"' : "") + ' type="checkbox" name="checkBoxActive">'); | |
} | |
} | |
function MakeTextAreaField(value, cols, classCss) { | |
var stringReturn = '<TEXTAREA id="inputName" class="' + classCss + '" rows="3" cols="' + cols + '" name="inputName">' + value + '</TEXTAREA>'; | |
return stringReturn; | |
} | |
//--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | |
//insere ou altera uma linha no conteudo de Html | |
function SaveHtmlRowToGrid(form) { | |
if (ValidateFormHtmlContent(form)) { | |
if (form['indice'].value == 'new') { | |
InsertHtmlFields(form); | |
} else { | |
UpdateHtmlFields(form); | |
} | |
$('#configContent').dialog('close'); | |
} | |
} | |
//atualiza a linha | |
function UpdateHtmlFields(form) { | |
contentRows = $('.divFieldSetHtmlDataRow'); | |
var divToEdit = contentRows[form['indice'].value]; | |
MakeCommonFields(divToEdit, form, 'update'); | |
$(divToEdit).children('#html').html("<a class='IconView' href='javascript:void(0)' title=" + escape(form['html'].value) + ">html</a>"); | |
$(divToEdit).children('#fileName').html(form['fileNameFilePicker'].value); | |
var hrefEdit = '<a href="javascript:void(0)" title="edit" class="IconEdit" onclick="EditHtmlContentRow(' + $(divToEdit)[0].uniqueID + ', ' + form['indice'].value + ');"> </a>'; | |
var hrefDel = '<a href="javascript:void(0)" title="delete" class="IconDel" onclick="RemoveContentRow(' + $(divToEdit)[0].uniqueID + ');"> </a>'; | |
$(divToEdit).children('#edit').html(hrefEdit + ' ' + hrefDel); | |
} | |
//insere a linha | |
function InsertHtmlFields(form, period, periodDivs, active) { | |
var num = parseInt($('#totalRows').val()) + 1; | |
var divId = 'FieldDiv_' + num; | |
var divCopy = $('#divHtmlFieldSet').clone(true); | |
$(divCopy).addClass("divFieldSetHtmlDataRow"); | |
$(divCopy).addClass("divFieldSetAnyRow"); | |
$(divCopy).attr('id', divId); | |
MakeCommonFields(divCopy, form, 'insert'); | |
$(divCopy).children('#html').html("<a class='IconView' href='javascript:void(0)' title=" + escape(form['html'].value) + ">html</a>"); | |
$(divCopy).children('#fileName').html(form['fileNameFilePicker'].value); | |
var hrefEdit = '<a href="javascript:void(0)" title="edit" class="IconEdit" onclick="EditHtmlContentRow(' + $(divCopy)[0].uniqueID + ', ' + (num - 1) + ');"> </a>'; | |
var hrefDel = '<a href="javascript:void(0)" title="delete" class="IconDel" onclick="RemoveContentRow(' + $(divCopy)[0].uniqueID + ');"> </a>'; | |
$(divCopy).children('#edit').html(hrefEdit + ' ' + hrefDel); | |
//adiciona o div em primeiro, caso nenhum tenha sido adicionado, ou depois do ultimo | |
if ($('#rowsHtmlContent .divFieldSetAnyRow:last').length > 0) { | |
$('#rowsHtmlContent .divFieldSetAnyRow:last').after(divCopy); | |
} else { | |
$('#rowsHtmlContent').append(divCopy); | |
} | |
$("#totalRows").val(num); | |
} | |
//----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | |
//insere ou atualiza a linha na grid de conteudo de banner | |
function SaveBannerRowToGrid(form) { | |
if (ValidateFormBannerContent(form)) { | |
if (form['indice'].value == 'new') { | |
InsertBannerFields(form); | |
} else { | |
UpdateBannerFields(form); | |
} | |
$('#configContent').dialog('close'); | |
} | |
} | |
//atualiza | |
function UpdateBannerFields(form) { | |
contentRows = $('.divFieldSetBannerDataRow'); | |
var divToEdit = contentRows[form['indice'].value]; | |
MakeCommonFields(divToEdit, form, 'update'); | |
$(divToEdit).children('#width').children('textarea').val(form['width'].value); | |
$(divToEdit).children('#height').children('textarea').val(form['height'].value); | |
$(divToEdit).children('#fileType').html(form['fileType'].value); | |
$(divToEdit).children('#linkUrl').children('textarea').val(form['linkUrl'].value); | |
$(divToEdit).children('#fileName').html(form['fileNameFilePicker'].value); | |
var hrefEdit = '<a href="javascript:void(0)" title="edit" class="IconEdit" onclick="EditBannerContentRow(' + $(divToEdit)[0].uniqueID + ', ' + form['indice'].value + ');"> </a>'; | |
var hrefDel = '<a href="javascript:void(0)" title="delete" class="IconDel" onclick="RemoveContentRow(' + $(divToEdit)[0].uniqueID + ');"> </a>'; | |
$(divToEdit).children('#edit').html(hrefEdit + ' ' + hrefDel); | |
} | |
//insere | |
function InsertBannerFields(form) { | |
var num = parseInt($('#totalRows').val()) + 1; | |
var divId = 'FieldDiv_' + num; | |
var divCopy = $('#divBannerFieldSet').clone(true); | |
$(divCopy).addClass("divFieldSetBannerDataRow"); | |
$(divCopy).addClass("divFieldSetBannerAnyRow"); | |
$(divCopy).attr('id', divId); | |
MakeCommonFields(divCopy, form, 'insert'); | |
$(divCopy).children('#width').html(MakeTextAreaField(form['width'].value, '7', 'vtex-text-only-numbers')); | |
$(divCopy).children('#height').html(MakeTextAreaField(form['height'].value, '7', 'vtex-text-only-numbers')); | |
$(divCopy).children('#fileType').html(form['fileType'].value); | |
$(divCopy).children('#linkUrl').html(MakeTextAreaField(form['linkUrl'].value, '22')); | |
$(divCopy).children('#fileName').html(form['fileNameFilePicker'].value); | |
var hrefEdit = '<a href="javascript:void(0)" class="IconEdit" onclick="EditBannerContentRow(' + $(divCopy)[0].uniqueID + ', ' + (num - 1) + ');"> </a>'; | |
var hrefDel = '<a href="javascript:void(0)" class="IconDel" onclick="RemoveContentRow(' + $(divCopy)[0].uniqueID + ');"> </a>'; | |
$(divCopy).children('#edit').html(hrefEdit + ' ' + hrefDel); | |
//adiciona o div em primeiro caso nenhum tenha sido adicionado, ou depois do ultimo | |
if (parseInt($('#rowsBannerContent .divFieldSetBannerAnyRow:last').length) > 0) { | |
$('#rowsBannerContent .divFieldSetBannerAnyRow:last').after(divCopy); | |
} else { | |
$('#rowsBannerContent').append(divCopy); | |
} | |
$("#totalRows").val(num); | |
} | |
//-------------------------------------------------------------------------------------------------------------------------------------------------------------------- | |
//insere a linha na grid de conteudo de banner DHTL | |
function SaveBannerDhtmlRowToGrid(form) { | |
if (ValidateFormBannerContent(form)) { | |
if (form['indice'].value == 'new') { | |
InsertBannerDhtmlFields(form); | |
} else { | |
UpdateBannerDhtmlFields(form); | |
} | |
$('#configContent').dialog('close'); | |
} | |
} | |
//atualiza | |
function UpdateBannerDhtmlFields(form) { | |
contentRows = $('.divFieldSetBannerDataRow'); | |
var divToEdit = contentRows[form['indice'].value]; | |
MakeCommonFields(divToEdit, form, 'update'); | |
$(divToEdit).children('#width').children('textarea').val(form['width'].value); | |
$(divToEdit).children('#height').children('textarea').val(form['height'].value); | |
$(divToEdit).children('#fileType').html(form['fileType'].value); | |
$(divToEdit).children('#linkUrl').children('textarea').val(form['linkUrl'].value); | |
$(divToEdit).children('#fileName').html(form['fileNameFilePicker'].value); | |
$(divToEdit).children('#xPosition').children('textarea').val(form['xPosition'].value); | |
$(divToEdit).children('#yPosition').children('textarea').val(form['yPosition'].value); | |
$(divToEdit).children('#timer').children('textarea').val(form['timer'].value); | |
var hrefEdit = '<a href="javascript:void(0)" title="edit" class="IconEdit" onclick="EditBannerDhtmlContentRow(' + $(divToEdit)[0].uniqueID + ', ' + form['indice'].value + ');"> </a>'; | |
var hrefDel = '<a href="javascript:void(0)" title="delete" class="IconDel" onclick="RemoveContentRow(' + $(divToEdit)[0].uniqueID + ');"> </a>'; | |
$(divToEdit).children('#edit').html(hrefEdit + ' ' + hrefDel); | |
} | |
//insere | |
function InsertBannerDhtmlFields(form) { | |
var num = parseInt($('#totalRows').val()) + 1; | |
var divId = 'FieldDiv_' + num; | |
var divCopy = $('#divBannerFieldSet').clone(true); | |
$(divCopy).addClass("divFieldSetBannerDataRow"); | |
$(divCopy).addClass("divFieldSetBannerAnyRow"); | |
$(divCopy).attr('id', divId); | |
MakeCommonFields(divCopy, form, 'insert'); | |
$(divCopy).children('#width').html(MakeTextAreaField(form['width'].value, '5', 'vtex-text-only-numbers')); | |
$(divCopy).children('#height').html(MakeTextAreaField(form['height'].value, '5', 'vtex-text-only-numbers')); | |
$(divCopy).children('#fileType').html(form['fileType'].value); | |
$(divCopy).children('#linkUrl').html(MakeTextAreaField(form['linkUrl'].value, '18')); | |
$(divCopy).children('#fileName').html(form['fileNameFilePicker'].value); | |
$(divCopy).children('#xPosition').html(MakeTextAreaField(form['xPosition'].value, '5', 'vtex-text-only-numbers')); | |
$(divCopy).children('#yPosition').html(MakeTextAreaField(form['yPosition'].value, '5', 'vtex-text-only-numbers')); | |
$(divCopy).children('#timer').html(MakeTextAreaField(form['timer'].value, '5', 'vtex-text-only-numbers')); | |
var hrefEdit = '<a href="javascript:void(0)" class="IconEdit" onclick="EditBannerDhtmlContentRow(' + $(divCopy)[0].uniqueID + ', ' + (num - 1) + ');"> </a>'; | |
var hrefDel = '<a href="javascript:void(0)" class="IconDel" onclick="RemoveContentRow(' + $(divCopy)[0].uniqueID + ');"> </a>'; | |
$(divCopy).children('#edit').html(hrefEdit + ' ' + hrefDel); | |
//adiciona o div em primeiro caso nenhum tenha sido adicionado, ou depois do ultimo | |
if ($('#rowsBannerContent .divFieldSetBannerAnyRow:last').length > 0) { | |
$('#rowsBannerContent .divFieldSetBannerAnyRow:last').after(divCopy); | |
} else { | |
$('#rowsBannerContent').append(divCopy); | |
} | |
$("#totalRows").val(num); | |
} | |
//---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | |
function MakeHrefToViewRangeDate(date) { | |
return "<a class=\"IconView\" title='" + EncodeHTML(date) + "'>Período</a>"; | |
} | |
function OpenInsertBannerDhtmlContentForm(viewPartInstanceId) { | |
contentURL = JsNewAppFolder + '/PortalManagement/GetBannerDhtmlContentForm?viewPartInstanceId=' + viewPartInstanceId + '&contentStringData='; | |
AjaxRequest('POST', contentURL, '#configContent', ''); | |
$('#ui-datepicker-div').addClass('vtex-zindex-promote'); | |
CssFixConfigShelf('configContent', '90px'); | |
$('#configContent').dialog('open'); | |
} | |
function GetCollection(list) { | |
for (i = 0; i < list.length; i++) { | |
if (list[i].checked) return (list[i].value); | |
} | |
} | |
function OpenCollectionPicker(obj) { | |
$('#name-collection').val(''); | |
$('#id-collection').val(''); | |
$('#colletions-list').html(''); | |
$('#colletionDialog').dialog('open'); | |
} | |
//------------------------------------------------------------------------------------------------------------------------------------------------------------ | |
function WebsiteBindingEdit(com, grid) { | |
var rowId; var id; var siteId; var urlFrom; | |
siteId = $("#hdnWebSiteId").val(); | |
Host = ''; | |
if (com == "Add") { | |
AjaxRequest('POST', JsNewAppFolder + "/PortalManagement/WebsiteBindingAdd?Host=" + Host + "&SiteId=" + siteId + "&ActionType=Add", '#portalBody', null, BindHostAddEddit); | |
} | |
else { | |
if ($('.trSelected', grid).length == 0) | |
ShowAlertMessage('Select the binding to update or delete!'); | |
else { | |
$('.trSelected', grid).each(function () { | |
rowId = $(this).attr('id'); | |
id = rowId.substring(rowId.lastIndexOf('row') + 3); | |
Host = $($('#' + rowId).children('td')[2]).children('div').text(); | |
}); | |
switch (com) { | |
case 'Update': AjaxRequest('POST', JsNewAppFolder + "/PortalManagement/WebsiteBindingAdd?Host=" + Host + "&SiteId=" + siteId + "&ActionType=Edit", '#portalBody', null, BindHostAddEddit); | |
break; | |
case 'Delete': | |
if (Host.includes("*")) { | |
ShowAlertMessage('Cannot remove default binding.'); | |
} | |
else { | |
ShowAlertMessageConfirm('Are you sure you want to delete the biding [' + Host + ']?', function () { | |
AjaxRequest('POST', JsNewAppFolder + "/PortalManagement/WebsiteBindingDelete?Host=" + Host + "&SiteId=" + siteId, '#portalBody', null, BindSiteManagerNodeFunctions); // ShowMessage('Binding Removido com sucesso')); | |
}) | |
} | |
break; | |
default: ShowAlertMessage('Invalid Option!'); | |
break; | |
} | |
} | |
} | |
} | |
//------------------------------------------------------------------------------------------------------------------------------------------------------------ | |
function WebsiteDictionaryEdit(com, grid) { | |
var rowId; var id; var siteId; var urlFrom; | |
siteId = $("#hdnWebSiteId").val(); | |
Host = ''; | |
if (com == "Add") { | |
AjaxRequest('POST', JsNewAppFolder + "/PortalManagement/AddDictionaryItem?SiteId=" + siteId, '#portalBody', null, BindDictionaryFunction); | |
} | |
else { | |
if ($('.trSelected', grid).length == 0) | |
ShowAlertMessage('Select a binding to update or delete!'); | |
else { | |
$('.trSelected', grid).each(function () { | |
rowId = $(this).attr('id'); | |
id = rowId.substring(rowId.lastIndexOf('row') + 3); | |
Host = $($('#' + rowId).children('td')[2]).children('div').text(); | |
}); | |
switch (com) { | |
case 'Update': AjaxRequest('POST', JsNewAppFolder + "/PortalManagement/AddDictionaryItem?ItemId=" + id + "&SiteId=" + siteId, '#portalBody', null, BindDictionaryFunction); | |
break; | |
case 'Delete': | |
ShowAlertMessageConfirm("Are you sure?", function () { | |
AjaxRequest('POST', JsNewAppFolder + "/PortalManagement/delDictionary?ItemId=" + id + "&SiteId=" + siteId, '#portalBody', null, ShowMessage("Item deleted!"), { id: id, siteId: siteId }); | |
}); | |
break; | |
default: ShowAlertMessage('Invalid Option!'); | |
break; | |
} | |
} | |
} | |
} | |
//------------------------------------------------------------------------------------------------------------------------------------------------------------ | |
function UrlMappingMantain(com, grid) { | |
var rowId; var id; var siteId; var urlFrom; | |
if ($('.trSelected', grid).length > 0) { | |
$('.trSelected', grid).each(function () { | |
rowId = $(this).attr('id'); | |
id = rowId.substring(rowId.lastIndexOf('row') + 3); | |
siteId = 'todo'; //$($('#' + rowId).children('td')[1]).children('div').text(); | |
urlFrom = $($('#' + rowId).children('td')[2]).children('div').text(); | |
}); | |
if (com == 'Delete') { | |
ShowAlertMessageConfirm('Are you sure to delete the item "' + urlFrom + '" ?', function () { | |
AjaxRequest('POST', JsNewAppFolder + '/PortalManagement/DeleteUrlMapping?siteId=' + siteId + '&urlMappingId=' + id, '', 'addUrlMapping'); | |
$("#flex1").flexReload(); | |
}); | |
} | |
else if (com == 'Update') { | |
AjaxRequest('POST', JsNewAppFolder + '/PortalManagement/GetUrlMapping?siteId=' + siteId + '&urlMappingId=' + id, '#portalBody1', 'addUrlMapping'); | |
SwitchDivPortalBodyView(); | |
acertaTamanhoTela(); | |
} | |
} else if (com == 'Add') { | |
var siteId = $('#urlMappingSiteId').val(); | |
AjaxRequest('POST', JsNewAppFolder + '/PortalManagement/AddUrlMapping?siteId=' + siteId + '&urlMappingId=' + id, '#portalBody1', 'addUrlMapping'); | |
SwitchDivPortalBodyView(); | |
acertaTamanhoTela(); | |
} else if (com == 'Import') { | |
var siteId = $('#urlMappingSiteId').val(); | |
AjaxRequest('POST', JsNewAppFolder + '/PortalManagement/ImportUrlMapping?siteId=' + siteId + '&urlMappingId=' + id, '#portalBody1', 'addUrlMapping'); | |
SwitchDivPortalBodyView(); | |
acertaTamanhoTela(); | |
} else if (com == 'Export') { | |
window.location.href = JsNewAppFolder + '/PortalManagement/ExportUrlMappingGo/'; | |
} | |
} | |
function SwitchDivPortalBodyView() { | |
$('#portalBody').css('display', 'none'); | |
$('#portalBody1').css('display', 'block'); | |
} | |
function UrlMappingBackButtonClick() { | |
$('#portalBody1').css('display', 'none'); | |
$('#portalBody').css('display', 'block'); | |
acertaTamanhoTela(); | |
$("#flex1").flexReload(); | |
} | |
function FileManagementBackButtonClick() { | |
$('#portalBody1').css('display', 'none'); | |
$('#portalBody').css('display', 'block'); | |
$("#flex1").flexReload(); | |
} | |
//Custom View Part------------------------------------------------------------------------------------- | |
function CustomViewPartMantain(com, grid) { | |
var rowId; var id; var customViewPartId; var customViewPartName; var viewPartId; | |
var siteId = $('#customViewPartSiteId').val(); | |
if ($('.trSelected', grid).length > 0) { | |
$('.trSelected', grid).each(function () { | |
rowId = $(this).attr('id'); | |
id = rowId.substring(rowId.lastIndexOf('row') + 3); | |
viewPartId = $($('#' + rowId).children('td')[0]).children('div').text(); | |
customViewPartId = $($('#' + rowId).children('td')[1]).children('div').text(); | |
customViewPartName = $($('#' + rowId).children('td')[2]).children('div').text(); | |
}); | |
if (com == 'Delete') { | |
ShowAlertMessageConfirm('Are you sure to delete the item "' + customViewPartName + '" ?', function () { | |
var postData = { customViewPartId: customViewPartId, viewPartId: viewPartId }; | |
$('#dialog-confirm').html('aguarde......'); | |
AjaxRequest('POST', JsNewAppFolder + '/PortalManagement/GetFormConfirmDeleteCustomViewPart?siteId=' + siteId + '&customViewPartId=' + customViewPartId + '&viewPartId=' + viewPartId, '#dialog-confirm', '', '', postData); | |
$("#dialog-confirm").dialog('open'); | |
}); | |
} | |
else if (com == 'Update') { | |
AjaxRequest('POST', JsNewAppFolder + '/PortalManagement/AddCustomViewPart?siteId=' + siteId + '&customViewPartId=' + customViewPartId + '&viewPartId=' + viewPartId, '#portalBody1', 'addUrlMapping'); | |
SwitchDivPortalBodyView(); | |
acertaTamanhoTela() | |
} | |
} else { | |
if (com == 'Add') { | |
AjaxRequest('POST', JsNewAppFolder + '/PortalManagement/AddCustomViewPart?siteId=' + siteId + '&customViewPartId=&viewPartId=', '#portalBody1', 'addUrlMapping'); | |
SwitchDivPortalBodyView(); | |
acertaTamanhoTela() | |
} | |
} | |
} | |
//------------------------------------------------------------------------------------------------------ | |
//file picker------------------------------------------------------------------------------------------- | |
function PrepareFilePikerSearchInsertFileDialog() { | |
if ($('.filePikerSearchInsertFile').is(':data(dialog)')) $('.filePikerSearchInsertFile').dialog("destroy"); | |
$(".filePikerSearchInsertFile").dialog({ | |
bgiframe: true, | |
autoOpen: false, | |
height: 600, | |
width: 700, | |
zIndex: 5002, | |
modal: true, | |
stackfix: true, | |
buttons: { | |
Adicionar: function () { | |
var radios = document.getElementsByName("fileRadio"); | |
var filePickerIdentify = $("#filePickerIdentify").val(); | |
var file = GetCollection(radios); | |
var multiFile = $("#filePickerMultiFile").val(); | |
AddFileToFileList_FilePicker(file, filePickerIdentify, multiFile); | |
} | |
} | |
}); | |
} | |
function PrepareUploadFileTo_FilePicker(selector, multiFile, extensions, filePickerIdentify, requestToken) { | |
var options = { | |
file: { | |
container: $(selector), | |
image: JsNewAppFolder + '/scripts/uploadify/btn_browseForFile.png', | |
extensions: '.jpg,.png,.gif,.swf,.jpeg,.ico', | |
multiple: multiFile === 'true' | |
}, | |
save: { | |
container: $('.href-save-file') | |
}, | |
cancel: { | |
image: JsNewAppFolder + '/scripts/uploadify/cancel.png' | |
}, | |
display: { | |
container: $('#filePickerListContainer') | |
}, | |
action: { | |
token: requestToken, | |
changedFile: 0, | |
url: JsNewAppFolder + '/FilePicker/UploadFile', | |
checkUrl: JsNewAppFolder + '/FilePicker/FileExists', | |
success: function (data, textStatus, jqXHR) { | |
AddFileToFileList_FilePicker(data.fileNameInserted, filePickerIdentify, multiFile); | |
}, | |
error: function (jqXHR, textStatus, errorThrown) { | |
ShowMessage(textStatus); | |
}, | |
complete: function (jqXHR, textStatus) { | |
} | |
} | |
}; | |
var simple = new SimpleFileInput(options); | |
} | |
function OpenFileInsertFormFilePicker(viewPartInstanceId, extensions, file, filePickerIdentify, multiFile) { | |
var url = JsNewAppFolder + '/FilePicker/GetFormSearchInsertFile/'; | |
dataToPost = { extensions: extensions, viewPartInstanceId: viewPartInstanceId, file: file, filePickerIdentify: filePickerIdentify, multiFile: multiFile }; | |
ajaxRequestFilePicker('POST', url, dataToPost, '.filePikerSearchInsertFile', '', extensions, multiFile, filePickerIdentify); | |
$(".filePikerSearchInsertFile").dialog('open'); | |
CssFixConfigShelf('1', '90px'); | |
} | |
function AddFileToFileList_FilePicker(file, filePickerIdentify, multiFile) { | |
if (file != null && file.length > 0) { | |
if (AddFileToFieldHidden_FilePicker(file, filePickerIdentify, multiFile)) { | |
if (multiFile == 'True') { | |
if ($('.vtex-file-picker-file-list ul:last').length > 0) { | |
$('.vtex-file-picker-file-list ul:last').after(MakeFileList_FilePicker(file, $('#fileListLength').val(), filePickerIdentify, multiFile)); | |
} else { | |
$('.vtex-file-picker-file-list').html(MakeFileList_FilePicker(file, $('#fileListLength').val(), filePickerIdentify, multiFile)); | |
} | |
if ($('.vtex-file-picker-file-show > div:last').length > 0) { | |
$('.vtex-file-picker-file-show > div:last').after(MakeDivImageToShow_FilePicker(file, $('#fileListLength').val())); | |
} else { | |
$('.vtex-file-picker-file-show').html(MakeDivImageToShow_FilePicker(file, $('#fileListLength').val())); | |
} | |
} else { | |
$('.vtex-file-picker-file-list').html(MakeFileList_FilePicker(file, $('#fileListLength').val(), filePickerIdentify, multiFile)); | |
$('.vtex-file-picker-file-show').html(MakeDivImageToShow_FilePicker(file, $('#fileListLength').val())); | |
} | |
AddEventHandlerToMantain_FilePicker(); | |
} | |
} | |
if (multiFile != 'True') { | |
$('.filePikerSearchInsertFile').dialog('close') | |
}; | |
} | |
function RemoveFileToFileList(file, selector, filePickerIdentify) { | |
var int1 = parseInt($('#fileListLength').val()); | |
var int2 = parseInt(int1 - 1); | |
$('#fileListLength').val(int2); | |
var filePickerFileVal = $('#' + filePickerIdentify).val(); | |
var regExString = new RegExp("^" + file + ",|," + file + ",|," + file + "$|^" + file + "$", "g"); | |
filePickerFileVal = filePickerFileVal.replace(regExString, ",").replace(/^,|,$/g, ""); | |
$('#' + filePickerIdentify).val(filePickerFileVal); | |
$('#' + selector).remove(); | |
} | |
function AddFileToFieldHidden_FilePicker(file, filePickerIdentify, multiFile) { | |
$('#userMessageFilePicker').html(''); | |
if (multiFile != 'False') { | |
if ($('#' + filePickerIdentify).val() == '') { | |
$('#' + filePickerIdentify).val(file); | |
return true; | |
} | |
else { | |
if ($('#' + filePickerIdentify).val().indexOf(file) == -1) { | |
$('#' + filePickerIdentify).val($('#' + filePickerIdentify).val() + ',' + file); | |
var int1 = parseInt($('#fileListLength').val()); | |
var int2 = parseInt(int1 + 1); | |
$('#fileListLength').val(int2); | |
return true; | |
} else { | |
$('#userMessageFilePicker').html('<span class="vtex-span-alert-red">Arquivo já existe na lista <br /><br /></span>'); | |
return false; | |
} | |
} | |
} | |
else { | |
$('#' + filePickerIdentify).val(file); | |
return true; | |
} | |
} | |
function AddEventHandlerToMantain_FilePicker() { | |
$(".IconShowFile").mouseover(function () { | |
$(".effect" + $(this).attr("id")).fadeIn('fast'); | |
return false; | |
}); | |
$(".IconShowFile").mouseout(function () { | |
$(".effect" + $(this).attr("id")).fadeOut('fast'); | |
return false; | |
}); | |
} | |
function MakeFileList_FilePicker(file, i, filePickerIdentify, multiFile) { | |
var selectorName = file.replace('.', '_').replace(' ', '_') | |
var output = "" | |
output += "<ul id=\"" + selectorName + "\">"; | |
output += "<li><a id=\"" + i + "\" class=\"IconShowFile\" href=\"javascript:void(0)\"> " + MakeFileThumb_FilePicker(file) + " </a></li>"; | |
output += "<li class=\"FileText\">" + file + "</li>"; | |
output += "<li> <a onClick=\"RemoveFileToFileList('" + file + "','" + selectorName + "','" + filePickerIdentify + "');\" title=\"desvincular arquivo\" class=\"IconDel\" href=\"javascript:void(0)\"> </a></li>"; | |
output += "</ul>"; | |
return output; | |
} | |
function MakeFileThumb_FilePicker(file) { | |
if (GetFileExtension_FilePicker(file) != 'swf') { | |
return "<img width=\"30\" height=\"15\" valign=\"middle\" border=\"0\" src=\"/arquivos/" + file + "?thumbnail=true\" />"; | |
} else { | |
return MakeFlashImage_FilePicker(file, 30, 15); | |
} | |
} | |
function MakeFlashImage_FilePicker(file, width, height) { | |
var output = ""; | |
var flashId = file.replace('.', '_') + new Date().getTime(); | |
output += "<div style=\"width:" + width + ";heigth:" + height + "\" id=\"Flashi" + flashId + "\">"; | |
output += "<script type=\"text/javascript\">var so = new SWFObject(\"/arquivos/" + file + "\", \"Moviei" + flashId + "\", \"" + width + "\",\"" + height + "\", \"8\", \"transparent\"); so.addParam(\"wmode\", \"transparent\");so.addParam(\"allowScriptAccess\",\"always\"); so.write(\"Flashi" + flashId + "\");</script>"; | |
output += "</div>"; | |
return output; | |
} | |
function MakeDivImageToShow_FilePicker(file, i) { | |
var output = ""; | |
output += "<div id=\"" + file.replace('.', '_') + "\" class=\"effect" + i + "\" style=\"display:none\" >"; | |
if (GetFileExtension_FilePicker(file) != 'swf') { | |
output += "<img src=\"/arquivos/" + file + "\" />"; | |
} else { | |
output += MakeFlashImage_FilePicker(file, 300, 200); | |
} | |
output += "</div>"; | |
return output; | |
} | |
function GetFileExtension_FilePicker(file) { | |
if (file.lastIndexOf('.') > 0) { | |
return file.substring(file.lastIndexOf('.') + 1); | |
} | |
else { | |
return "noextension"; | |
} | |
} | |
function ReloadGrid() { | |
$("#flex1").flexReload(); | |
} | |
function FileManagerMantain(com, grid) { | |
var rowId; var id; var fileId; var fileName; var extension; | |
var fileType = $('#fileManagerFileType').val(); | |
var token = $('#fileUploadRequestToken').val(); | |
if ($('.trSelected', grid).length > 0) { | |
$('.trSelected', grid).each(function () { | |
rowId = $(this).attr('id'); | |
id = rowId.substring(rowId.lastIndexOf('row') + 3); | |
fileId = $($('#' + rowId).children('td')[0]).children('div').text(); | |
fileName = $($('#' + rowId).children('td')[1]).children('div').text(); | |
extension = $($('#' + rowId).children('td')[2]).children('div').text(); | |
}); | |
if (com == 'Delete') { | |
ShowAlertMessageConfirm('Are you sure to delete the item "' + fileName + '" ?', function () { | |
AjaxRequest('POST', JsNewAppFolder + '/PortalManagement/DeleteFile?fileId=' + fileId + '&fileType=' + extension, '', 'file-del'); | |
}); | |
} | |
else if (com == 'Update') { | |
AjaxRequest('POST', JsNewAppFolder + '/PortalManagement/GetFile?fileId=' + fileId + '&fileType=' + extension, '#portalBody1', 'file'); | |
SwitchDivPortalBodyView(); | |
} | |
} else { | |
if (com == 'Add') { | |
AjaxRequest('POST', JsNewAppFolder + '/PortalManagement/AddFile?fileType=' + fileType, '#portalBody1', 'file'); | |
SwitchDivPortalBodyView(); | |
} | |
} | |
} | |
function PrepareUploadFileTo_FileManger(selector, multiFile, extensions, requestToken, fileName, fileId) { | |
var options = { | |
file: { | |
container: $(selector), | |
image: JsNewAppFolder + '/scripts/uploadify/btn_browseForFile.png', | |
extensions: extensions, | |
multiple: multiFile === 'true' | |
}, | |
save: { | |
container: $('.href-save-file') | |
}, | |
cancel: { | |
image: JsNewAppFolder + '/scripts/uploadify/cancel.png' | |
}, | |
display: { | |
container: $('#filePickerListContainer') | |
}, | |
action: { | |
token: requestToken, | |
changedFileName: fileName, | |
changedFileId: fileId, | |
url: JsNewAppFolder + '/FilePicker/UploadFile', | |
checkUrl: JsNewAppFolder + '/FilePicker/FileExists?changedFileName=' + fileName, | |
success: function (data, textStatus, jqXHR) { | |
ShowMessage(data.mensagem); | |
}, | |
error: function (jqXHR, textStatus, errorThrown) { | |
ShowMessage(textStatus); | |
}, | |
complete: function (jqXHR, textStatus) { | |
} | |
} | |
}; | |
var simple = new SimpleFileInput(options); | |
$('#tabs-file').tabs(); | |
} | |
function PrepareUploadFileTo_UrlMappingImport(selector, multiFile, extensions, requestToken, fileName, fileId) { | |
var options = { | |
file: { | |
container: $(selector), | |
image: JsNewAppFolder + '/scripts/uploadify/btn_browseForFile.png', | |
extensions: extensions, | |
multiple: false | |
}, | |
save: { | |
container: $('.href-save-file') | |
}, | |
cancel: { | |
image: JsNewAppFolder + '/scripts/uploadify/cancel.png' | |
}, | |
display: { | |
container: $('#filePickerListContainer') | |
}, | |
action: { | |
token: requestToken, | |
url: JsNewAppFolder + '/PortalManagement/ImportUrlMappingGo', | |
success: function (data, textStatus, jqXHR) { | |
ShowMessage(data.mensagem); | |
UrlMappingBackButtonClick(); | |
}, | |
error: function (jqXHR, textStatus, errorThrown) { | |
ShowMessage(textStatus); | |
}, | |
complete: function (jqXHR, textStatus) { | |
} | |
} | |
}; | |
var simple = new SimpleFileInput(options); | |
$('#tabs-file').tabs(); | |
} | |
function MainPrepareShortCuts(id, button, form, action) { | |
var target = '#' + id; | |
var oReturn = false; | |
if ($(target).length > 0) { | |
shortcut.remove("Ctrl+S"); | |
shortcut.add("Ctrl+S", function () { | |
if (form == null) { | |
$(button).click(); | |
} else { | |
if (typeof (window[action]) === "function") { | |
oReturn = window[action](form); | |
if (oReturn) { | |
$(button).click(); | |
} else { | |
return false; | |
} | |
} | |
} | |
}, | |
{ | |
'type': 'keydown', | |
'propagate': false, | |
'target': document | |
}); | |
} | |
if ($(target).length > 0) { | |
document.getElementById(id).onkeydown = keypressed; | |
} | |
function keypressed(e) { | |
//get key pressed | |
var key = null; | |
var isCtrl = false; | |
if (window.event) key = event.keyCode; | |
else if (e.which) key = e.which; | |
if (key == 17) isCtrl = true; | |
//control z | |
if (isCtrl && key == 90) return true; | |
//if tab pressed | |
if (key != null && key == 9) { | |
//IE | |
if (document.selection) { | |
//get focus | |
this.focus(); | |
//get selection | |
var sel = document.selection.createRange(); | |
//insert tab | |
sel.text = "\t"; | |
} | |
//Mozilla + Netscape | |
else if (this.selectionStart || this.selectionStart == "0") { | |
//save scrollbar positions | |
var scrollY = this.scrollTop; | |
var scrollX = this.scrollLeft; | |
//get current selection | |
var start = this.selectionStart; | |
var end = this.selectionEnd; | |
//insert tab | |
this.value = this.value.substring(0, start) + "\t" + this.value.substring(end, this.value.length); | |
//move cursor back to insert point | |
this.focus(); | |
this.selectionStart = start + 1; | |
this.selectionEnd = start + 1; | |
//reset scrollbar position | |
this.scrollTop = scrollY; | |
this.scrollLeft = scrollX; | |
} | |
//time for a new browser!!! | |
else this.value += "\t"; | |
//stop the real tab press | |
return false; | |
} | |
} | |
} | |
//---------------------------------------------------------------------------------------------------------------- | |
function EditRealMediaContentRow(divId, indice) { | |
var viewPartInstanceId = $('#viewPartInstanceId').val(); | |
var rowData = MakeRealMediaContentObject(viewPartInstanceId, indice, divId, 'text'); | |
if (rowData != 'false') { | |
contentURL = JsNewAppFolder + '/PortalManagement/GetRealMediaContentForm'; | |
var data = { viewPartInstanceId: viewPartInstanceId, contentStringData: rowData }; | |
AjaxRequest('POST', contentURL, '#configContent', '', '', data); | |
$('#ui-datepicker-div').addClass('vtex-zindex-promote'); | |
CssFixConfigShelf('configContent', '90px'); | |
$('#configContent').dialog('open'); | |
} | |
} | |
function EditRealMediaContentRowByName(divName, indice) { | |
var viewPartInstanceId = $('#viewPartInstanceId').val(); | |
var div = $('#' + divName); | |
var rowData = MakeRealMediaContentObject(viewPartInstanceId, indice, div, 'text'); | |
if (rowData != 'false') { | |
contentURL = JsNewAppFolder + '/PortalManagement/GetRealMediaContentForm'; | |
var data = { viewPartInstanceId: viewPartInstanceId, contentStringData: rowData }; | |
AjaxRequest('POST', contentURL, '#configContent', '', '', data); | |
$('#ui-datepicker-div').addClass('vtex-zindex-promote'); | |
CssFixConfigShelf('configContent', '90px'); | |
$('#configContent').dialog('open'); | |
} | |
} | |
function RemoveRealMediaRowByName(divName) { | |
$('#' + divName).remove(); | |
$("#totalRows").val($("#totalBannerContentRows").val() - 1); | |
} | |
function RemoveRealMediaRow(div) { | |
$(div).remove(); | |
$("#totalRows").val($("#totalBannerContentRows").val() - 1); | |
} | |
function HandleRealMediaContentListToSubmit(form) { | |
if (MakeCustomViewPartFields()) { | |
contentRows = $('.divFieldSetHtmlDataRow'); | |
if (MakeRealMediaContentInputHidden(contentRows, form.viewPartInstanceId.value) != 'false') { | |
$('#RealMediaContentList').val(MakeRealMediaContentInputHidden(contentRows, form.viewPartInstanceId.value)); | |
} else return false; | |
} else { | |
return false; | |
} | |
} | |
function MakeRealMediaContentInputHidden(contents, viewPartInstanceId) { | |
var HtmlContentList = new Array(); | |
for (var i = 0; i < contents.length; i++) { | |
if (MakeRealMediaContentObject(viewPartInstanceId, i, contents[i], 'object') != 'false') { | |
HtmlContentList[i] = MakeRealMediaContentObject(viewPartInstanceId, i, contents[i], 'object'); | |
} else return 'false'; | |
} | |
return Sys.Serialization.JavaScriptSerializer.serialize(HtmlContentList); | |
} | |
function MakeRealMediaContentObject(viewPartInstanceId, indice, content, returnType) { | |
var myContent = MakeControlContent(viewPartInstanceId, indice, content); | |
if (myContent != 'false') { | |
var realMediaContent = new RealMediaContent(myContent, | |
MakeRealMediaCommonContent(viewPartInstanceId, indice, content) | |
); | |
if (returnType == "text") return Sys.Serialization.JavaScriptSerializer.serialize(realMediaContent); | |
if (returnType == "object") return realMediaContent; | |
} else return 'false'; | |
} | |
function SaveRealMediaRowToGrid(form) { | |
if (ValidateFormRealMedia(form)) { | |
if (form['indice'].value == 'new') { | |
InsertRealMediaFields(form); | |
} else { | |
UpdateRealMediaFields(form); | |
} | |
$('#configContent').dialog('close'); | |
} | |
} | |
//atualiza a linha | |
function UpdateRealMediaFields(form) { | |
contentRows = $('.divFieldSetHtmlDataRow'); | |
var divToEdit = contentRows[form['indice'].value]; | |
MakeCommonFields(divToEdit, form, 'update'); | |
$(divToEdit).children('#position').children('textarea').val(form['position'].value); | |
var hrefEdit = '<a href="javascript:void(0)" title="edit" class="IconEdit" onclick="EditHtmlContentRow(' + $(divToEdit)[0].uniqueID + ', ' + form['indice'].value + ');"> </a>'; | |
var hrefDel = '<a href="javascript:void(0)" title="delete" class="IconDel" onclick="RemoveContentRow(' + $(divToEdit)[0].uniqueID + ');"> </a>'; | |
$(divToEdit).children('#edit').html(hrefEdit + ' ' + hrefDel); | |
} | |
//insere a linha | |
function InsertRealMediaFields(form, period, periodDivs, active) { | |
var num = parseInt($('#totalRows').val()) + 1; | |
var divId = 'FieldDiv_' + num; | |
var divCopy = $('#divHtmlFieldSet').clone(true); | |
$(divCopy).addClass("divFieldSetHtmlDataRow"); | |
$(divCopy).addClass("divFieldSetAnyRow"); | |
$(divCopy).attr('id', divId); | |
MakeCommonFields(divCopy, form, 'insert'); | |
$(divCopy).children('#position').children('textarea').val(form['position'].value); | |
var hrefEdit = '<a href="javascript:void(0)" title="edit" class="IconEdit" onclick="EditRealMediaContentRow(' + $(divCopy)[0].uniqueID + ', ' + (num - 1) + ');"> </a>'; | |
var hrefDel = '<a href="javascript:void(0)" title="delete" class="IconDel" onclick="RemoveRealMediaRow(' + $(divCopy)[0].uniqueID + ');"> </a>'; | |
$(divCopy).children('#edit').html(hrefEdit + ' ' + hrefDel); | |
//adiciona o div em primeiro, caso nenhum tenha sido adicionado, ou depois do ultimo | |
if ($('#RealMediaRows .divFieldSetAnyRow:last').length > 0) { | |
$('#RealMediaRows .divFieldSetAnyRow:last').after(divCopy); | |
} else { | |
$('#RealMediaRows').append(divCopy); | |
} | |
$("#totalRows").val(num); | |
} | |
function checkProtocols(requiresValidationObject) { | |
if (requiresValidationObject.checked) { | |
$("#protocols").prop('selectedIndex', 1); | |
$("#cacheTypes").prop('selectedIndex', 0); | |
} | |
} | |
function SimpleFileInput(options) { | |
this.$file = options.file; | |
this.$display = options.display; | |
this.$cancel = options.cancel; | |
this.$save = options.save; | |
this.$action = options.action; | |
this.files = []; | |
this.$file.container.hide(); | |
if (this.$file.multiple) { | |
this.$file.container.attr('multiple', ''); | |
} else { | |
this.$file.container.removeAttr('multiple') | |
} | |
this.$file.container.attr('accept', this.$file.extensions); | |
this.$file.container.before('<label for="' + this.$file.container.selector.slice(1) + '"><img alt="Localizar Arquivo" border="0" src="' + this.$file.image + '" style="cursor:pointer;" /></label>'); | |
var self = this; | |
this.$file.container.change(function (e) { | |
if (!self.$file.multiple) { | |
self.files = []; | |
} | |
for (var file of e.target.files) { | |
if (self.files.findIndex(function (currentValue) { return currentValue.name === file.name }) < 0) { | |
self.files.push(file); | |
} | |
} | |
self.display(); | |
$(this).val(null); | |
}); | |
this.$save.container.click(function () { | |
self.upload(); | |
$('#tabs-file').children().find('*').each(function () { | |
if ('disabled' in $(this)) { console.log('!!!'); } | |
}); | |
}); | |
} | |
SimpleFileInput.prototype.remove = function (i) { | |
this.files.splice(i, 1); | |
this.display(); | |
} | |
SimpleFileInput.prototype.remove = function () { | |
this.files = []; | |
this.display(); | |
} | |
SimpleFileInput.prototype.display = function () { | |
this.$display.container.empty(); | |
var self = this; | |
for (var i = 0; i < this.files.length; i++) { | |
var f = this.files[i]; | |
var card = '<div class="uploadifyQueueItem">\ | |
<div class="cancel">\ | |
<a><img id="'+ this.$file.container.selector.slice(1) + '-' + i + '" src="' + this.$cancel.image + '" border="0" style="cursor:pointer;" /></a>\ | |
</div>\ | |
<span class="fileName">' + f.name + '</span>\ | |
</div>'; | |
this.$display.container.append(card); | |
$(this.$file.container.selector + '-' + i).click(function (e) { | |
e.preventDefault(); | |
self.remove(e.target.id); | |
}); | |
} | |
this.$save.container.show(); | |
} | |
SimpleFileInput.prototype.upload = async function () { | |
if (this.files.length < 1) { | |
ShowMessage("No file selected!"); | |
return; | |
} | |
var _action = this.$action; | |
var self = this; | |
for (var file of this.files) { | |
var form = new FormData(); | |
var formCheck = new FormData(); | |
if (!!this.$action.token) { | |
form.append('requestToken', this.$action.token); | |
} | |
if (!!file) { | |
form.append('FileData', file); | |
formCheck.append(file.name, file.name); | |
} | |
if (!!this.$action.hdnSelectedSKUs) { | |
form.append('hdnSelectedSKUs', this.$action.hdnSelectedSKUs); | |
} | |
if (!!this.$action.changedFileName) { | |
form.append('changedFileName', this.$action.changedFileName); | |
formCheck.append('changedFileName', this.$action.changedFileName); | |
} | |
if (!!this.$action.changedFileId) { | |
form.append('changedFileId', this.$action.changedFileId); | |
} | |
if (!!this.$action.changedFile) { | |
form.append('changedFile', this.$action.changedFile); | |
} | |
ShowBusy(); | |
try { | |
await $.ajax({ | |
type: "POST", | |
url: _action.url, | |
contentType: false, | |
processData: false, | |
data: form, | |
timeout: 50000, | |
success: function (data, textStatus, jqXHR) { | |
if (!!_action.success) { | |
_action.success(data, textStatus, jqXHR); | |
} | |
self.remove(); | |
}, | |
error: function (jqXHR, textStatus, errorThrown) { | |
if (!!_action.error) { | |
_action.error(jqXHR, textStatus, errorThrown); | |
} | |
}, | |
complete: function (jqXHR, textStatus) { | |
if (!!_action.complete) { | |
_action.complete(jqXHR, textStatus); | |
} | |
HideBusy(); | |
} | |
}); | |
} catch (e) { | |
console.error(e) | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Utilize o plugin https://github.com/kylepaulsen/ResourceOverride e faça a configuração como a imagem abaixo:
https://*.vtexcommercestable.com.br/admin/a/scripts/portalmanagementmain.js