$(function() { ListingEditor.register('premiumService', { fields: ["service_level"], show: function(callback, cancelCallback) { var context = this; var editor = $$("div.editor"); var listing = ListingEditor.workingListing(); $("

Upgrade Listing

").appendTo(editor); var premiumRadioButtons = [ $$("input", { name: "service_level", type: "radio", id: "premium_0", value: "0" }), $$("input", { name: "service_level", type: "radio", id: "premium_1", value: "1" }), $$("input", { name: "service_level", type: "radio", id: "premium_2", value: "2" }), $$("input", { name: "service_level", type: "radio", id: "premium_3", value: "3" }) ]; var table = $("
"); editor.append(table); table = table.find("tbody"); var setActive = function(col) { table.find('td').removeClass('selected'); table.find('tr').each(function() { $(this).find('td').eq(col + 1).addClass('selected'); premiumRadioButtons[col].checked = true; }); }; var getSelectedValue = function(items) { for (var i = 0; i < items.length; i++) { if (items[i].attr('checked')) { return i; } } } table.append("FreeStandardPlusPremium"); table.append("Standard Infoyesyesyesyes"); table.append("Categories3366"); table.append("yesyesyes"); table.append("Featured listing yesyes"); table.append("yes"); table.append("Advert Freeyes"); table.append("Free$99/yr$195/yr$550/yr"); table.append($$("tr.buttons", $$("td"), $$("td", premiumRadioButtons[0]), $$("td", premiumRadioButtons[1]), $$("td", premiumRadioButtons[2]), $$("td", premiumRadioButtons[3]))); premiumRadioButtons[listing.service_level || 0].attr('checked', true) setActive(listing.service_level || 0); table.find('a').click(function (event) { return zoomClick(this, event); }); table.find('a').mouseover(function (){ zoomPreload(this); }); table.find('tr').each(function() { $(this).find('td').not(':first').css('cursor', 'pointer').each(function(g) { var f = g; $(this).click(function() { setActive(f); premiumRadioButtons[f].attr('checked', true); }); }); }); editor.append(EditorFormatter.dialogButtons(function() { ListingEditor.updateSubmission('service_level', parseInt(getSelectedValue(premiumRadioButtons))); ModalPopup.hide(); $('#premiumService').effect('highlight', {}, 200); if (callback) callback(); }, function () { ModalPopup.hide(); if (cancelCallback) cancelCallback(); })); EditorFormatter.applyData(editor); ModalPopup.show(editor); }, refresh: function() { var listing = ListingEditor.workingListing(); //if (ListingEditor.options['mode'] == 'approve'){ $("#premiumService a").text(["Upgrade", "Standard", "Plus", "Premium"][listing.service_level || 0]); //} } }); });