ISCitiesEdit = { IsInitFirst: false, DataForForm: { }, Init: function () { }, Edit: function (Id, action) { if ($('.edit-popup.cities').length == 0) $('body').append($('
', { 'class': 'edit-popup cities', style: 'min-height: 300px;' })); if (action == 'add') $('.edit-popup.cities').addClass('add'); if ($('.edit-popup.cities #CitiesRegionId').length) ISCitiesEdit.EditInit(); else $.ajax({ url: "/ajax/editcities?v=" + ISCommon.GetV(), data: { Id: Id }, cache: true, success: function (d) { $('.edit-popup.cities').html(d.View); ISCitiesEdit.EditInit(); } }); }, EditInit: function () { $('.edit-popup.cities').show(); var newWidth = ($("#container").width() < 700) ? $("#container").width() : 700; $('.edit-popup.cities').css({ top: $(window).scrollTop(), width: newWidth, marginLeft: 0 - (newWidth / 2) }); $('.edit-popup.cities').show(); $('.edit-popup.cities .close-icon').unbind('click'); $('.edit-popup.cities .close-icon').click(function () { $('.edit-popup.cities').hide(); return false; }); $('.edit-popup.cities #CitiesRegionId').val($('.edit-popup.calendar #RegionId').val()); $('.edit-popup.cities select').not(".ex").chosen(); $('.edit-popup.cities #CitiesRegionId').trigger("liszt:updated"); $('.edit-popup.cities a.button').unbind('click'); $('.edit-popup.cities a.button').click(function () { ISCitiesEdit.Save(); return false; }); }, SaveLock: false, Save: function () { if (!ISCitiesEdit.SaveLock) { if (ISCitiesEdit.Validate()) { ISCitiesEdit.SaveLock = true; $.ajax({ type: "post", url: "/ajax/savecities?v=" + ISCommon.GetV() + '&g=' + ISCommon.GetGuid(), data: $(".edit-popup.cities form.edit-form").serialize(), cache: true, success: function (d) { ISCitiesEdit.SaveLock = false; if (d.result == 'yes') { if (ISCommon.Guid == '') ISCommon.SetGuid(d.guid); $('.edit-popup.cities').hide(); if ($('.edit-popup.cities').hasClass('add')) { $('.edit-popup.cities').removeClass('add'); $('.edit-popup.calendar #RegionId').val(d.RegionId).trigger("liszt:updated"); $('.edit-popup.calendar #CityId').prepend($('