var scnDialogHelper = {
needsPreview: false,
setUpButtons: function () {
var a = this;
jQuery("#scn-btn-cancel").click(function () {
a.closeDialog()
});
jQuery("#scn-btn-insert").click(function () {
a.insertAction()
});
jQuery("#scn-btn-preview").click(function () {
a.previewAction()
})
},
loadShortcodeDetails: function () {
if (scnSelectedShortcodeType) {
var a = this;
jQuery.getScript(avia_framework_globals.frameworkUrl + "php/avia_shortcodes/sc/" + scnSelectedShortcodeType + ".js", function () {
a.initializeDialog()
})
}
},
initializeDialog: function () {
if (typeof scnShortcodeMeta == "undefined") jQuery("#scn-options").append("
Error loading details for shortcode: " + scnSelectedShortcodeType + "
");
else {
if (scnShortcodeMeta.disablePreview) {
jQuery("#scn-preview").remove();
jQuery("#scn-btn-preview").remove()
}
var a = scnShortcodeMeta.attributes,
b = jQuery("#scn-options-table");
for (var c in a) {
var f = "scn-value-" + a[c].id,
d = a[c].isRequired ? "scn-required" : "",
g = jQuery('
');
jQuery("").attr("for", f).attr("class", d).html(a[c].label).appendTo(g);
f = jQuery("
");
d = (d = a[c].controlType) ? d : "text-control";
switch (d) {
case "column-control":
this.createColumnControl(a[c], f, c == 0);
break;
case "icon-control":
case "color-control":
case "link-control":
case "text-control":
this.createTextControl(a[c], f, c == 0);
break
case "select-control":
this.createSelectControl(a[c], f, c == 0);
break;
case "tab-control":
this.createTabControl(a[c], f, c == 0);
break;
case "table-control":
this.createTableControl(a[c], f, c == 0);
break;
case "sidebar-tab-control":
this.createsbTabControl(a[c], f, c == 0);
break;
}
jQuery("
").append(g).append(f).appendTo(b)
}
jQuery(".scn-focus-here:first").focus()
}
},
createsbTabControl: function (a, b, c) {
new scnSBTabMaker(b, 20, c ? "scn-focus-here" : null);
b.addClass("scn-marker-sidebar-tab-control")
},
createColumnControl: function (a, b, c) {
new ScnColumnMaker(b, 5, c ? "scn-focus-here" : null);
b.addClass("scn-marker-column-control")
},
createTableControl: function (a, b, c) {
new ScnTableMaker(b, 5, c ? "scn-focus-here" : null);
b.addClass("scn-marker-table-control")
},
createTextControl: function (a, b, c) {
var f = a.validatelink ? "scn-validation-marker" : "",
d = a.isRequired ? "scn-required" : "",
g = "scn-value-" + a.id;
jQuery('').attr("id", g).attr("name", g).addClass(f).addClass(d).addClass(c ? "scn-focus-here" : "").appendTo(b);
if (a = a.help) {
jQuery(" ").appendTo(b);
jQuery("").addClass("scn-input-help").html(a).appendTo(b)
}
var h = this;
b.find("#" + g).bind("keydown focusout", function (e) {
if (e.type == "keydown" && e.which != 13 && e.which != 9 && !e.shiftKey) h.needsPreview = true;
else if (h.needsPreview && (e.type == "focusout" || e.which == 13)) {
h.previewAction(e.target);
h.needsPreview = false
}
})
},
createSelectControl: function (a, b, c) {
var f = a.validatelink ? "scn-validation-marker" : "",
d = a.isRequired ? "scn-required" : "",
g = "scn-value-" + a.id;
var selectNode = jQuery('