menuTemplateInjectV = function(data) { var widgetId = data.widgetId; var dataJsonArray = data.dataJsonArray; var menuType = data.menuType; var html = menuRecursionRender(dataJsonArray); $("#" + widgetId).html(html); $("#" + widgetId).menu({ mode: menuType, position: { my: "left top", at: "right-5 top+5" } }); }; menuRecursionRender = function(dataJsonArray) { var html = ''; return html; }; formTemplateInjectV = function(data) { var id = data.id; var dataJsonArray = data.dataJsonArray; var theme = localStorage.getItem("jqwidget-theme"); var componentTheme = localStorage.getItem("jqwidget-component-theme"); $.each(dataJsonArray, function(index, jsonObject) { var inputType = jsonObject["inputType"]; var name = jsonObject["name"]; var value = jsonObject["value"]; // alert("name:" + name + ", value:" + value); // alert("value != undefined: " + (value != undefined)); // if( value != undefined ) { // alert("value == null: " + (value == null)); if( value == null ) { value = ""; } // } if( inputType == "hidden" ) { if( value != undefined ) { $("#" + id + "-form-model-original-" + name).val(value); $("#" + id + "-form-model-" + name).val(value); } } else { if( inputType == "read-only" ) { $("#" + id + "-form-model-" + name).prop("readonly", true); if( value != undefined ) { $("#" + id + "-form-model-original-" + name).val(value); $("#" + id + "-form-model-" + name).val(value); } var setInputStyleJsonObjectFunction = data.setInputStyleJsonObjectFunction; if( setInputStyleJsonObjectFunction != undefined && setInputStyleJsonObjectFunction != null ) { var inputStyleJsonObject = setInputStyleJsonObjectFunction(jsonObject); if( inputStyleJsonObject != undefined && inputStyleJsonObject != null ) { $("#" + id + "-form-model-" + name).css(inputStyleJsonObject); } } } else if( inputType == "string" ) { $("#" + id + "-form-model-" + name).prop("readonly", false); // alert("name:" + name + ", value:" + value); if( value != undefined ) { $("#" + id + "-form-model-original-" + name).val(value); $("#" + id + "-form-model-" + name).val(value); } var setInputStyleJsonObjectFunction = data.setInputStyleJsonObjectFunction; if( setInputStyleJsonObjectFunction != undefined && setInputStyleJsonObjectFunction != null ) { var inputStyleJsonObject = setInputStyleJsonObjectFunction(jsonObject); if( inputStyleJsonObject != undefined && inputStyleJsonObject != null ) { $("#" + id + "-form-model-" + name).css(inputStyleJsonObject); } } } else if( inputType == "large-string" ) { if( value != undefined ) { $("#" + id + "-form-model-original-" + name).val(value); $("#" + id + "-form-model-" + name).val(value); } var setInputStyleJsonObjectFunction = data.setInputStyleJsonObjectFunction; if( setInputStyleJsonObjectFunction != undefined && setInputStyleJsonObjectFunction != null ) { var inputStyleJsonObject = setInputStyleJsonObjectFunction(jsonObject); if( inputStyleJsonObject != undefined && inputStyleJsonObject != null ) { $("#" + id + "-form-model-" + name).css(inputStyleJsonObject); } } } else if( inputType == "password" ) { if( value != undefined ) { $("#" + id + "-form-model-original-" + name).val(value); $("#" + id + "-form-model-" + name).val(value); } var setInputStyleJsonObjectFunction = data.setInputStyleJsonObjectFunction; if( setInputStyleJsonObjectFunction != undefined && setInputStyleJsonObjectFunction != null ) { var inputStyleJsonObject = setInputStyleJsonObjectFunction(jsonObject); if( inputStyleJsonObject != undefined && inputStyleJsonObject != null ) { $("#" + id + "-form-model-" + name).css(inputStyleJsonObject); } } } else if( inputType == "select" ) { var selectTemplateInjectVDataFunction = data.selectTemplateInjectVDataFunction; if( selectTemplateInjectVDataFunction != undefined && selectTemplateInjectVDataFunction != null ) { var templateInjectVDataJsonObject = selectTemplateInjectVDataFunction(jsonObject); if( templateInjectVDataJsonObject != undefined && templateInjectVDataJsonObject != null ) { var selectId = id + "-form-model-" + name + "-select"; var renderFunction = templateInjectVDataJsonObject.renderFunction; if( renderFunction != undefined && renderFunction != null ) { var html = renderFunction(id, selectId, jsonObject); $("#" + id + "-form-model-" + name + "-div").html(html); } var eventFunction = templateInjectVDataJsonObject.eventFunction; if( eventFunction != undefined && eventFunction != null ) { eventFunction(id, selectId, jsonObject); } var setInputStyleJsonObjectFunction = templateInjectVDataJsonObject.setInputStyleJsonObjectFunction; if( setInputStyleJsonObjectFunction != undefined && setInputStyleJsonObjectFunction != null ) { var inputStyleJsonObject = setInputStyleJsonObjectFunction(id, selectId, jsonObject); if( inputStyleJsonObject != undefined && inputStyleJsonObject != null ) { $("#" + id + "-form-model-" + name + "-div").css(inputStyleJsonObject); } } } } if( value != undefined ) { $("#" + id + "-form-model-original-" + name).val(value); $("#" + id + "-form-model-" + name + "-select").val(value); } } else if( inputType == "jqx-combobox" ) { if( value != undefined ) { $("#" + id + "-form-model-original-" + name).val(value); } var jqxComboBoxTemplateInjectVDataFunction = data.jqxComboBoxTemplateInjectVDataFunction; if( jqxComboBoxTemplateInjectVDataFunction != undefined && jqxComboBoxTemplateInjectVDataFunction != null ) { var templateInjectVDataJsonObject = jqxComboBoxTemplateInjectVDataFunction(jsonObject); if( templateInjectVDataJsonObject != undefined && templateInjectVDataJsonObject != null ) { var widgetId = id + "-form-model-" + name; var getJqxComboBoxSourceFunction = templateInjectVDataJsonObject.getJqxComboBoxSourceFunction; if( getJqxComboBoxSourceFunction != undefined && getJqxComboBoxSourceFunction != null ) { var source = getJqxComboBoxSourceFunction(jsonObject); if( source != undefined && source != null ) { var setJqxComboBoxStyleJsonObjectFunction = templateInjectVDataJsonObject.setJqxComboBoxStyleJsonObjectFunction; if( setJqxComboBoxStyleJsonObjectFunction != undefined && setJqxComboBoxStyleJsonObjectFunction != null ) { var jqxComboBoxStyleJsonObject = setJqxComboBoxStyleJsonObjectFunction(jsonObject, source); if( jqxComboBoxStyleJsonObject != undefined && jqxComboBoxStyleJsonObject != null ) { $("#" + widgetId).jqxComboBox(jqxComboBoxStyleJsonObject); } } else { $("#" + widgetId).jqxComboBox({ theme: theme, source: source, multiSelect: false, displayMember: "label", valueMember: "value" }); } } var jqxComboBoxEventFunction = templateInjectVDataJsonObject.jqxComboBoxEventFunction; if( jqxComboBoxEventFunction != undefined && jqxComboBoxEventFunction != null ) { jqxComboBoxEventFunction(jsonObject); } } } } } else if( inputType == "selection-button" ) { if( value != undefined ) { $("#" + id + "-form-model-original-" + name).val(value); } var selectionButtonTemplateInjectVDataFunction = data.selectionButtonTemplateInjectVDataFunction; if( selectionButtonTemplateInjectVDataFunction != undefined && selectionButtonTemplateInjectVDataFunction != null ) { var injectVDataJsonObject = selectionButtonTemplateInjectVDataFunction(); if( injectVDataJsonObject != undefined && injectVDataJsonObject != null ) { var modelJsonArrayFunction = injectVDataJsonObject.modelJsonArrayFunction; if( modelJsonArrayFunction != undefined && modelJsonArrayFunction != null ) { var multiselect = jsonObject["multiselect"]; var modelJsonArray = modelJsonArrayFunction(jsonObject); var html = ''; $.each(modelJsonArray, function(indexV, jsonObjectV) { var labelV = jsonObjectV["label"]; var valueV = jsonObjectV["value"]; var buttonIdV = id + "-form-model-" + name + "-button-" + indexV; html += ''; html += ' '; }); html += ''; $("#" + id + "-form-model-" + name + "-div").html(html); setSelectionButtonValueFunction(data, jsonObject, value); var clickedStyleJsonObjectFunction = injectVDataJsonObject.clickedStyleJsonObjectFunction; var unclickStyleJsonObjectFunction = injectVDataJsonObject.unclickStyleJsonObjectFunction; var eventFunction = injectVDataJsonObject.eventFunction; $.each(modelJsonArray, function(indexV, jsonObjectV) { var buttonIdV = id + "-form-model-" + name + "-button-" + indexV; $("#" + buttonIdV).click(function(event) { event.preventDefault(); var clickedV = $(this).attr("clicked"); var valueV = $(this).attr("val"); var clickedBoolean = clickedV == "N"; if( clickedV == "Y" ) { $(this).attr("clicked", "N"); if( unclickStyleJsonObjectFunction != undefined && unclickStyleJsonObjectFunction != null ) { var styleJsonObject = unclickStyleJsonObjectFunction(jsonObject, jsonObjectV); $(this).css(styleJsonObject); } } else { if( multiselect ) { $(this).attr("clicked", "Y"); if( clickedStyleJsonObjectFunction != undefined && clickedStyleJsonObjectFunction != null ) { var styleJsonObject = clickedStyleJsonObjectFunction(jsonObject, jsonObjectV); $(this).css(styleJsonObject); } } else { $.each(modelJsonArray, function(indexVV, jsonObjectVV) { var buttonIdVV = id + "-form-model-" + name + "-button-" + indexVV; $("#" + buttonIdVV).attr("clicked", "N"); if( unclickStyleJsonObjectFunction != undefined && unclickStyleJsonObjectFunction != null ) { var styleJsonObject = unclickStyleJsonObjectFunction(jsonObject, jsonObjectV); $("#" + buttonIdVV).css(styleJsonObject); } }); $(this).attr("clicked", "Y"); if( clickedStyleJsonObjectFunction != undefined && clickedStyleJsonObjectFunction != null ) { var styleJsonObject = clickedStyleJsonObjectFunction(jsonObject, jsonObjectV); $(this).css(styleJsonObject); } } } if( eventFunction != undefined && eventFunction != null ) { eventFunction(jsonObject, clickedBoolean, valueV); } return false; }); }); // end each } } } } else if( inputType == "integer" ) { var jqxNumberInputWidth = jsonObject["width"]; var jqxNumberInputHeight = jsonObject["height"]; var jqxNumberInputSpinButton = jsonObject["spinbutton"]; $("#" + id + "-form-model-" + name).jqxNumberInput({ width: jqxNumberInputWidth + "px", height: jqxNumberInputHeight + "px", digits: 1, decimalDigits: 0, symbol: "", theme: theme, spinButtons: jqxNumberInputSpinButton }); if( value != undefined ) { $("#" + id + "-form-model-" + name).val(parseInt(value)); } } else if( inputType == "positive-integer" ) { var jqxNumberInputWidth = jsonObject["width"]; var jqxNumberInputHeight = jsonObject["height"]; var jqxNumberInputSpinButton = jsonObject["spinbutton"]; $("#" + id + "-form-model-" + name).jqxNumberInput({ width: jqxNumberInputWidth + "px", height: jqxNumberInputHeight + "px", min: 0, digits: 1, decimalDigits: 0, symbol: "", theme: theme, spinButtons: jqxNumberInputSpinButton }); } else if( inputType == "number" ) { var jqxNumberInputWidth = jsonObject["width"]; var jqxNumberInputHeight = jsonObject["height"]; var jqxNumberInputSpinButton = jsonObject["spinbutton"]; var jqxNumberInputDigit = jsonObject["digit"]; var jqxNumberInputDecimalDigit = jsonObject["decimaldigit"]; $("#" + id + "-form-model-" + name).jqxNumberInput({ width: jqxNumberInputWidth + "px", height: jqxNumberInputHeight + "px", digits: jqxNumberInputDigit, decimalDigits: jqxNumberInputDecimalDigit, symbol: "", theme: theme, spinButtons: jqxNumberInputSpinButton }); } else if( inputType == "positive-number" ) { var jqxNumberInputWidth = jsonObject["width"]; var jqxNumberInputHeight = jsonObject["height"]; var jqxNumberInputSpinButton = jsonObject["spinbutton"]; var jqxNumberInputDigit = jsonObject["digit"]; var jqxNumberInputDecimalDigit = jsonObject["decimaldigit"]; $("#" + id + "-form-model-" + name).jqxNumberInput({ width: jqxNumberInputWidth + "px", height: jqxNumberInputHeight + "px", min: 0, digits: jqxNumberInputDigit, decimalDigits: jqxNumberInputDecimalDigit, symbol: "", theme: theme, spinButtons: jqxNumberInputSpinButton }); } else if( inputType == "currency" ) { var jqxNumberInputWidth = jsonObject["width"]; var jqxNumberInputHeight = jsonObject["height"]; var jqxNumberInputSpinButton = jsonObject["spinbutton"]; var jqxNumberInputDigit = jsonObject["digit"]; var jqxNumberInputDecimalDigit = jsonObject["decimaldigit"]; var jqxNumberInputSymbol = jsonObject["symbol"]; $("#" + id + "-form-model-" + name).jqxNumberInput({ width: jqxNumberInputWidth + "px", height: jqxNumberInputHeight + "px", min: 0, digits: jqxNumberInputDigit, decimalDigits: jqxNumberInputDecimalDigit, symbol: jqxNumberInputSymbol, theme: theme, spinButtons: jqxNumberInputSpinButton }); } else if( inputType == "date" ) { var datePickerLocale = jsonObject["locale"]; var datePickerFormat = jsonObject["format"]; if( !$("#" + id + "-form-model-" + name).is(":visible") || $("#" + id + "-form-model-" + name).html() == "" ) { $("#" + id + "-form-model-" + name).datepicker({ changeMonth: true, changeYear: true }); } if( datePickerLocale != undefined ) { $("#" + id + "-form-model-" + name).datepicker("option", $.datepicker.regional[datePickerLocale]); } if( datePickerFormat != undefined ) { $("#" + id + "-form-model-" + name).datepicker("option", "dateFormat", datePickerFormat); } $("#" + id + "-form-model-" + name).val(value); var setInputStyleJsonObjectFunction = data.setInputStyleJsonObjectFunction; if( setInputStyleJsonObjectFunction != undefined && setInputStyleJsonObjectFunction != null ) { var inputStyleJsonObject = setInputStyleJsonObjectFunction(jsonObject); if( inputStyleJsonObject != undefined && inputStyleJsonObject != null ) { $("#" + id + "-form-model-" + name).css(inputStyleJsonObject); } } } else if( inputType == "time" ) { $("#" + id + "-form-model-" + name).val(value); var setInputStyleJsonObjectFunction = data.setInputStyleJsonObjectFunction; if( setInputStyleJsonObjectFunction != undefined && setInputStyleJsonObjectFunction != null ) { var inputStyleJsonObject = setInputStyleJsonObjectFunction(jsonObject); if( inputStyleJsonObject != undefined && inputStyleJsonObject != null ) { $("#" + id + "-form-model-" + name).css(inputStyleJsonObject); } } } else if( inputType == "date-time" ) { var renderDateTimeFunction = data.renderDateTimeFunction; var html = renderDateTimeFunction(jsonObject); $("#" + id + "-form-model-" + name + "-div").html(html); var setInputStyleJsonObjectFunction = data.setInputStyleJsonObjectFunction; if( setInputStyleJsonObjectFunction != undefined && setInputStyleJsonObjectFunction != null ) { var inputStyleJsonObject = setInputStyleJsonObjectFunction(jsonObject); if( inputStyleJsonObject != undefined && inputStyleJsonObject != null ) { $("#" + id + "-form-model-" + name + "-div").css(inputStyleJsonObject); } } } else if( inputType == "color" ) { $("#" + id + "-form-model-" + name).ColorPicker({ livePreview: true, onSubmit: function(hsb, hex, rgb, element) { $(element).val("#" + hex); $(this).val("#" + hex); $(element).ColorPickerHide(); $(this).css({"background-color": "#" + hex}); }, onBeforeShow: function () { $(this).ColorPickerSetColor(this.value); } }); } else if( inputType == "upload" ) { var widgetType = jsonObject["widgetType"]; var multipleFile = jsonObject["multipleFile"]; var buttonText = jsonObject["buttonText"]; var dataJsonObject = jsonObject["dataJsonObject"]; var uploadUrl = data.uploadUrl; uploadTemplateInjectV({ "id": id + "-form-model-" + name, "widgetType": widgetType, "multipleFile": multipleFile, "buttonText": buttonText, "url": uploadUrl, "dataJsonObject": dataJsonObject, "setButtonStyleJsonObjectFunction": function() { var setUploadButtonStyleJsonObjectFunction = data.setUploadButtonStyleJsonObjectFunction; if( setUploadButtonStyleJsonObjectFunction != undefined && setUploadButtonStyleJsonObjectFunction != null ) { return setUploadButtonStyleJsonObjectFunction(); } }, "setJqueryButtonStyleJsonObjectFunction": function() { var setUploadJqueryButtonStyleJsonObjectFunction = data.setUploadJqueryButtonStyleJsonObjectFunction; if( setUploadJqueryButtonStyleJsonObjectFunction != undefined && setUploadJqueryButtonStyleJsonObjectFunction != null ) { return setUploadJqueryButtonStyleJsonObjectFunction(); } }, "renderInitUploadResultFunction": function(id) { var renderInitUploadResultFunction = data.renderInitUploadResultFunction; if( renderInitUploadResultFunction != undefined && renderInitUploadResultFunction != null ) { return renderInitUploadResultFunction(id); } }, "initUploadResultEventFunction": function(id) { var initUploadResultEventFunction = data.initUploadResultEventFunction; if( initUploadResultEventFunction != undefined && initUploadResultEventFunction != null ) { initUploadResultEventFunction(id); } }, "renderUploadResultFunction": function(id, e, d) { var renderUploadResultFunction = data.renderUploadResultFunction; if( renderUploadResultFunction != undefined && renderUploadResultFunction != null ) { return renderUploadResultFunction(id, e, d); } }, "uploadResultEventFunction": function(id, e, d) { var uploadResultEventFunction = data.uploadResultEventFunction; if( uploadResultEventFunction != undefined && uploadResultEventFunction != null ) { uploadResultEventFunction(id, e, d); } }, "uploadProgressallFunction": function(id, e, d) { var uploadProgressallFunction = data.uploadProgressallFunction; if( uploadProgressallFunction != undefined && uploadProgressallFunction != null ) { uploadProgressallFunction(id, e, d); } } }); var setInputStyleJsonObjectFunction = data.setInputStyleJsonObjectFunction; if( setInputStyleJsonObjectFunction != undefined && setInputStyleJsonObjectFunction != null ) { var inputStyleJsonObject = setInputStyleJsonObjectFunction(jsonObject); if( inputStyleJsonObject != undefined && inputStyleJsonObject != null ) { $("#" + id + "-form-model-" + name + "-upload-td").css(inputStyleJsonObject); } } } else if( inputType == "tree" ) { var treeTemplateInjectVDataFunction = data.treeTemplateInjectVDataFunction; if( treeTemplateInjectVDataFunction != undefined && treeTemplateInjectVDataFunction != null ) { var treeTemplateInjectVDataJsonObject = treeTemplateInjectVDataFunction(jsonObject); if( treeTemplateInjectVDataJsonObject != undefined && treeTemplateInjectVDataJsonObject != null ) { var widgetId = id + "-form-model-" + name; var clearSelectionButtonId = id + "-form-model-" + name + "-button"; var treeId = id + "-form-model-" + name + "-tree"; var renderClearTreeSelectionButtonFunction = treeTemplateInjectVDataJsonObject["renderClearTreeSelectionButtonFunction"]; if( renderClearTreeSelectionButtonFunction != undefined && renderClearTreeSelectionButtonFunction != null ) { renderClearTreeSelectionButtonFunction(widgetId, clearSelectionButtonId, treeId); } var clearTreeSelectionButtonEventFunction = treeTemplateInjectVDataJsonObject["clearTreeSelectionButtonEventFunction"]; if( clearTreeSelectionButtonEventFunction != undefined && clearTreeSelectionButtonEventFunction != null ) { clearTreeSelectionButtonEventFunction(widgetId, clearSelectionButtonId, treeId); } treeTemplateInjectVDataJsonObject["id"] = widgetId; if( value != undefined ) { treeTemplateInjectVDataJsonObject["value"] = value; } var selectTreeNodeEventFunction = treeTemplateInjectVDataJsonObject.selectTreeNodeEventFunction; treeTemplateInjectVDataJsonObject["selectTreeNodeEventFunction"] = function(selectedValue) { if( selectTreeNodeEventFunction != undefined && selectTreeNodeEventFunction != null ) { selectTreeNodeEventFunction(selectedValue); } setTreeValue({ "id": widgetId, "value": selectedValue }); }; treeTemplateInjectV(treeTemplateInjectVDataJsonObject); } } } else if( inputType == "user-defined-form-setup" ) { var userDefinedFormSetupTemplateInjectVDataFunction = data.userDefinedFormSetupTemplateInjectVDataFunction; if( userDefinedFormSetupTemplateInjectVDataFunction != undefined && userDefinedFormSetupTemplateInjectVDataFunction != null ) { var userDefinedFormSetupTemplateInjectVDataJsonObject = userDefinedFormSetupTemplateInjectVDataFunction(jsonObject); if( userDefinedFormSetupTemplateInjectVDataJsonObject != undefined && userDefinedFormSetupTemplateInjectVDataJsonObject != null ) { var templateUrl = userDefinedFormSetupTemplateInjectVDataJsonObject["templateUrl"]; if( templateUrl != undefined && templateUrl != null ) { var widgetId = id + "-form-model-" + name; $.ajax({ url: templateUrl, data: { "id": widgetId }, type: "post", async: false, dataType: "html", success: function(data) { var html = removeSpaceFunction(data); $("#" + widgetId + "-div").html(html); userDefinedFormSetupTemplateInjectVDataJsonObject["id"] = widgetId; userDefinedFormSetupTemplateInjectV(userDefinedFormSetupTemplateInjectVDataJsonObject); } }); } } } } else if( inputType == "string-tab" ) { var tabJsonArray = jsonObject["tabArray"]; if( tabJsonArray != undefined && tabJsonArray != null ) { var renderTabFunction = data.renderTabFunction; if( renderTabFunction != undefined && renderTabFunction != null ) { var tabId = id + "-form-model-" + name + "-tab-div"; $.each(tabJsonArray, function(index, tabJsonObject) { tabJsonObject["tabItemDivId"] = id + "-form-model-" + name + "-tab-item-div-" + index; }); var html = renderTabFunction(id, tabId, jsonObject, tabJsonArray); $("#" + id + "-form-model-" + name + "-div").html(html); $.each(tabJsonArray, function(index, tabJsonObject) { var tabItemDivId = tabJsonObject["tabItemDivId"]; var inputTextId = id + "-form-model-" + name + "-tab-item-input-text-" + index; tabJsonObject["inputTextId"] = inputTextId; var html = ''; $("#"+ tabItemDivId).html(html); var valueJsonArray = value; if( valueJsonArray.length > index ) { $("#"+ inputTextId).val(valueJsonArray[index]); } }); var tabEventFunction = data.tabEventFunction; if( tabEventFunction != undefined && tabEventFunction != null ) { tabEventFunction(id, tabId, jsonObject, tabJsonArray); } } } } else if( inputType == "editor-tab" ) { // alert(name); var tabJsonArray = jsonObject["tabArray"]; // alert(tabJsonArray); if( tabJsonArray != undefined && tabJsonArray != null ) { var renderTabFunction = data.renderTabFunction; // alert(renderTabFunction); if( renderTabFunction != undefined && renderTabFunction != null ) { var tabId = id + "-form-model-" + name + "-tab-div"; if( $("#" + tabId).html() != undefined ) { $.each(tabJsonArray, function(index, tabJsonObject) { var editorId = id + "-form-model-" + name + "-tab-item-input-text-" + index; // alert($("#" + editorId).val()); $("#" + editorId).jqxEditor("destroy"); // $("#" + editorId).html(undefined); // alert("destroy called: " + editorId); }); // $("#" + id + "-form-model-" + name + "-div").html(undefined); } // if( $("#" + tabId).html() == undefined ) { $.each(tabJsonArray, function(index, tabJsonObject) { tabJsonObject["tabItemDivId"] = id + "-form-model-" + name + "-tab-item-div-" + index; }); var html = renderTabFunction(id, tabId, jsonObject, tabJsonArray); $("#" + id + "-form-model-" + name + "-div").html(html); var width = jsonObject["width"]; var height = jsonObject["height"]; $.each(tabJsonArray, function(index, tabJsonObject) { var tabItemDivId = tabJsonObject["tabItemDivId"]; var editorId = id + "-form-model-" + name + "-tab-item-input-text-" + index; tabJsonObject["editorId"] = editorId; var editorValue = tabJsonObject["value"]; if( editorValue == undefined || editorValue == null ) { editorValue = ""; } var html = '
' + editorValue + '
'; $("#"+ tabItemDivId).html(html); var insertTableTitle = jsonObject["insertTableTitle"]; var insertImageTitle = jsonObject["insertImageTitle"]; var insertLinkTitle = jsonObject["insertLinkTitle"]; if( insertTableTitle == undefined || insertTableTitle == null ) { insertTableTitle = "Insert Table"; } if( insertImageTitle == undefined || insertImageTitle == null ) { insertImageTitle = "Insert Image"; } if( insertLinkTitle == undefined || insertLinkTitle == null ) { insertLinkTitle = "Insert Link"; } // alert("editorId: " + editorId); var editorWidth = (parseInt(width.substring(0, width.length - 2)) - 0); var editorHeight = (parseInt(height.substring(0, height.length - 2)) - 0); if( index == 1 ) { // editorWidth = 400; // editorHeight = 300; } $("#" + editorId).jqxEditor({ theme: componentTheme, width: parseInt(editorWidth), height: parseInt(editorHeight), pasteMode: "html", tools: "bold italic underline | format font size | color background | left center right | outdent indent | ul ol | table | image-new | link-new | clean | html", createCommand: function(commandName) { switch( commandName ) { case "table": return { type: "button", tooltip: insertTableTitle, init: function(widget) { widget.jqxButton({ height: 25, width: 25 }); var renderEditorTabTableButtonFunction = data.renderEditorTabTableButtonFunction; if( renderEditorTabTableButtonFunction != undefined && renderEditorTabTableButtonFunction != null ) { var html = renderEditorTabTableButtonFunction(); if( html != undefined && html != null ) { widget.html(html); } } else { widget.html("Table"); } }, refresh: function(widget, style) { }, action: function(widget, editor) { var editorTabTableActionEventFunction = data.editorTabTableActionEventFunction; if( editorTabTableActionEventFunction != undefined && editorTabTableActionEventFunction != null ) { editorTabTableActionEventFunction(id, name, index, editorId, widget, editor); } } }; // cases table case "image-new": return { type: "button", tooltip: insertImageTitle, init: function (widget) { widget.jqxButton({ height: 25, width: 25 }); var renderEditorTabImageButtonFunction = data.renderEditorTabImageButtonFunction; if( renderEditorTabImageButtonFunction != undefined && renderEditorTabImageButtonFunction != null ) { var html = renderEditorTabImageButtonFunction(); if( html != undefined && html != null ) { widget.html(html); } } else { widget.html("Image"); } }, refresh: function (widget, style) { }, action: function (widget, editor) { var editorTabImageActionEventFunction = data.editorTabImageActionEventFunction; if( editorTabImageActionEventFunction != undefined && editorTabImageActionEventFunction != null ) { editorTabImageActionEventFunction(id, name, index, editorId, widget, editor); } } // end action }; // cases image-new case "link-new": return { type: "button", tooltip: insertLinkTitle, init: function (widget) { widget.jqxButton({ height: 25, width: 25 }); var renderEditorTabLinkButtonFunction = data.renderEditorTabLinkButtonFunction; if( renderEditorTabLinkButtonFunction != undefined && renderEditorTabLinkButtonFunction != null ) { var html = renderEditorTabLinkButtonFunction(); if( html != undefined && html != null ) { widget.html(html); } } else { widget.html("Image"); } }, refresh: function (widget, style) { }, action: function (widget, editor) { var editorTabLinkActionEventFunction = data.editorTabLinkActionEventFunction; if( editorTabLinkActionEventFunction != undefined && editorTabLinkActionEventFunction != null ) { editorTabLinkActionEventFunction(id, name, index, editorId, widget, editor); } } // end action }; // cases link-new } // end switch } }); // end jqxeditor // $("#" + editorId + "TextArea").css({ // width: (parseInt(width.substring(0, width.length - 2)) - 20) + "px", // height: (parseInt(height.substring(0, height.length - 2)) - 20) + "px" // }); // $("#" + editorId).css({ // width: editorWidth + "px", // height: editorHeight + "px" // }); // alert("html: " + $("#" + editorId).html()); }); var tabEventFunction = data.tabEventFunction; if( tabEventFunction != undefined && tabEventFunction != null ) { tabEventFunction(id, tabId, jsonObject, tabJsonArray); } // } else { // already created jqxeditor /* $.each(tabJsonArray, function(index, tabJsonObject) { var editorId = id + "-form-model-" + name + "-tab-item-input-text-" + index; var editorValue = tabJsonObject["value"]; alert("editorValue: " + editorValue); if( editorValue == null ) { editorValue = ""; } // alert($("#" + editorId).html()); $("#" + editorId).jqxEditor("val", editorValue); $("#" + editorId).val(editorValue); $("#" + editorId + "TextArea").html(editorValue); // alert($("#" + editorId).html()); tabJsonObject["editorId"] = editorId; }); } */ } } var setInputStyleJsonObjectFunction = data.setInputStyleJsonObjectFunction; if( setInputStyleJsonObjectFunction != undefined && setInputStyleJsonObjectFunction != null ) { var inputStyleJsonObject = setInputStyleJsonObjectFunction(jsonObject); if( inputStyleJsonObject != undefined && inputStyleJsonObject != null ) { $("#" + id + "-form-model-" + name + "-div").css(inputStyleJsonObject); } } } else if( inputType == "user-define" ) { $("#" + id + "-form-model-original-" + name).val(value); var widgetId = id + "-form-model-" + name + "-widget"; var renderWidgetFunction = data.renderWidgetFunction; if( renderWidgetFunction != undefined && renderWidgetFunction != null ) { var html = renderWidgetFunction(id, widgetId, jsonObject); $("#" + id + "-form-model-" + name + "-div").html(html); } var widgetEventFunction = data.widgetEventFunction; if( widgetEventFunction != undefined && widgetEventFunction != null ) { widgetEventFunction(id, widgetId, jsonObject); } var setWidgetValueFunction = data.setWidgetValueFunction; if( setWidgetValueFunction != undefined && setWidgetValueFunction != null ) { setWidgetValueFunction(id, widgetId, jsonObject); } var setInputStyleJsonObjectFunction = data.setInputStyleJsonObjectFunction; if( setInputStyleJsonObjectFunction != undefined && setInputStyleJsonObjectFunction != null ) { var inputStyleJsonObject = setInputStyleJsonObjectFunction(jsonObject); if( inputStyleJsonObject != undefined && inputStyleJsonObject != null ) { $("#" + id + "-form-model-" + name + "-div").css(inputStyleJsonObject); } } } // end if: inputType } // end if: inputType != "hidden" if( inputType != "hidden" ) { var setLabelTdStyleJsonObjectFunction = data.setLabelTdStyleJsonObjectFunction; if( setLabelTdStyleJsonObjectFunction != undefined && setLabelTdStyleJsonObjectFunction != null ) { var labelTdStyleJsonObject = setLabelTdStyleJsonObjectFunction(jsonObject); if( labelTdStyleJsonObject != undefined && labelTdStyleJsonObject != null ) { $("#" + id + "-form-label-td-" + name).css(labelTdStyleJsonObject); } } var setLabelTdSpanStyleJsonObjectFunction = data.setLabelTdSpanStyleJsonObjectFunction; if( setLabelTdSpanStyleJsonObjectFunction != undefined && setLabelTdSpanStyleJsonObjectFunction != null ) { var labelTdSpanStyleJsonObject = setLabelTdSpanStyleJsonObjectFunction(jsonObject); if( labelTdSpanStyleJsonObject != undefined && labelTdSpanStyleJsonObject != null ) { $("#" + id + "-form-label-span-" + name).css(labelTdSpanStyleJsonObject); } } var setModelTdStyleJsonObjectFunction = data.setModelTdStyleJsonObjectFunction; if( setModelTdStyleJsonObjectFunction != undefined && setModelTdStyleJsonObjectFunction != null ) { var modelTdStyleJsonObject = setModelTdStyleJsonObjectFunction(jsonObject); if( modelTdStyleJsonObject != undefined && modelTdStyleJsonObject != null ) { $("#" + id + "-form-model-td-" + name).css(modelTdStyleJsonObject); } } } }); var setButtonTdStyleJsonObjectFunction = data.setButtonTdStyleJsonObjectFunction; if( setButtonTdStyleJsonObjectFunction != undefined && setButtonTdStyleJsonObjectFunction != null ) { var buttonTdStyleJsonObject = setButtonTdStyleJsonObjectFunction(); if( buttonTdStyleJsonObject != undefined && buttonTdStyleJsonObject != null ) { $("#" + id + "-form-button-td").css(buttonTdStyleJsonObject); } } var submitButtonText = data.submitButtonText; if( submitButtonText != undefined && submitButtonText != null ) { $("#" + id + "-submit-button").html(submitButtonText); } var resetButtonText = data.resetButtonText; if( resetButtonText != undefined && resetButtonText != null ) { $("#" + id + "-reset-button").html(resetButtonText); } var clearButtonText = data.clearButtonText; if( clearButtonText != undefined && clearButtonText != null ) { $("#" + id + "-clear-button").html(clearButtonText); } var cancelButtonText = data.cancelButtonText; if( cancelButtonText != undefined && cancelButtonText != null ) { $("#" + id + "-cancel-button").html(cancelButtonText); } var buttonWidgetType = data.buttonWidgetType; if( buttonWidgetType != undefined && buttonWidgetType != null ) { if( buttonWidgetType == "html-button" ) { var setButtonStyleJsonObjectFunction = data.setButtonStyleJsonObjectFunction; if( setButtonStyleJsonObjectFunction != undefined && setButtonStyleJsonObjectFunction != null ) { var submitButtonStyleJsonObject = setButtonStyleJsonObjectFunction("submit-button"); if( submitButtonStyleJsonObject != undefined && submitButtonStyleJsonObject != null ) { $("#" + id + "-submit-button").css(submitButtonStyleJsonObject); } var resetButtonStyleJsonObject = setButtonStyleJsonObjectFunction("reset-button"); if( resetButtonStyleJsonObject != undefined && resetButtonStyleJsonObject != null ) { $("#" + id + "-reset-button").css(resetButtonStyleJsonObject); } var clearButtonStyleJsonObject = setButtonStyleJsonObjectFunction("clear-button"); if( clearButtonStyleJsonObject != undefined && clearButtonStyleJsonObject != null ) { $("#" + id + "-clear-button").css(clearButtonStyleJsonObject); } var cancelButtonStyleJsonObject = setButtonStyleJsonObjectFunction("cancel-button"); if( cancelButtonStyleJsonObject != undefined && cancelButtonStyleJsonObject != null ) { $("#" + id + "-cancel-button").css(cancelButtonStyleJsonObject); } } } else if( buttonWidgetType == "jquery-button" ) { var setButtonStyleJsonObjectFunction = data.setButtonStyleJsonObjectFunction; if( setButtonStyleJsonObjectFunction != undefined && setButtonStyleJsonObjectFunction != null ) { var submitButtonStyleJsonObject = setButtonStyleJsonObjectFunction("submit-button"); if( submitButtonStyleJsonObject != undefined && submitButtonStyleJsonObject != null ) { $("#" + id + "-submit-button").css(submitButtonStyleJsonObject); } var resetButtonStyleJsonObject = setButtonStyleJsonObjectFunction("reset-button"); if( resetButtonStyleJsonObject != undefined && resetButtonStyleJsonObject != null ) { $("#" + id + "-reset-button").css(resetButtonStyleJsonObject); } var clearButtonStyleJsonObject = setButtonStyleJsonObjectFunction("clear-button"); if( clearButtonStyleJsonObject != undefined && clearButtonStyleJsonObject != null ) { $("#" + id + "-clear-button").css(clearButtonStyleJsonObject); } var cancelButtonStyleJsonObject = setButtonStyleJsonObjectFunction("cancel-button"); if( cancelButtonStyleJsonObject != undefined && cancelButtonStyleJsonObject != null ) { $("#" + id + "-cancel-button").css(cancelButtonStyleJsonObject); } } var setJqueryButtonStyleJsonObjectFunction = data.setJqueryButtonStyleJsonObjectFunction; if( setJqueryButtonStyleJsonObjectFunction != undefined && setJqueryButtonStyleJsonObjectFunction != null ) { var submitButtonStyleJsonObject = setJqueryButtonStyleJsonObjectFunction("submit-button"); if( submitButtonStyleJsonObject != undefined && submitButtonStyleJsonObject != null ) { $("#" + id + "-submit-button").button(submitButtonStyleJsonObject); } var resetButtonStyleJsonObject = setJqueryButtonStyleJsonObjectFunction("reset-button"); if( resetButtonStyleJsonObject != undefined && resetButtonStyleJsonObject != null ) { $("#" + id + "-reset-button").button(resetButtonStyleJsonObject); } var clearButtonStyleJsonObject = setJqueryButtonStyleJsonObjectFunction("clear-button"); if( clearButtonStyleJsonObject != undefined && clearButtonStyleJsonObject != null ) { $("#" + id + "-clear-button").button(clearButtonStyleJsonObject); } var cancelButtonStyleJsonObject = setJqueryButtonStyleJsonObjectFunction("cancel-button"); if( cancelButtonStyleJsonObject != undefined && cancelButtonStyleJsonObject != null ) { $("#" + id + "-cancel-button").button(cancelButtonStyleJsonObject); } } else { $("#" + id + "-submit-button").button(); $("#" + id + "-reset-button").button(); $("#" + id + "-clear-button").button(); $("#" + id + "-cancel-button").button(); } } } $("#" + id + "-reset-button").click(function(event) { event.preventDefault(); resetFormDataFunction(data); return false; }); $("#" + id + "-clear-button").click(function(event) { event.preventDefault(); clearFormDataFunction(data); return false; }); var submitButtonEventFunction = data.submitButtonEventFunction; if( submitButtonEventFunction != undefined && submitButtonEventFunction != null ) { $("#" + id + "-submit-button").unbind(); $("#" + id + "-submit-button").click(function(event) { event.preventDefault(); var formDataJsonArray = getFormDataJsonArray(data); submitButtonEventFunction(formDataJsonArray); return false; }); } var cancelButtonEventFunction = data.cancelButtonEventFunction; if( cancelButtonEventFunction != undefined && cancelButtonEventFunction != null ) { $("#" + id + "-cancel-button").unbind("click"); $("#" + id + "-cancel-button").click(function(event) { event.preventDefault(); cancelButtonEventFunction(); return false; }); } }; setSelectionButtonValueFunction = function(data, jsonObject, value) { var id = data.id; var name = jsonObject["name"]; var multiselect = jsonObject["multiselect"]; var selectionButtonTemplateInjectVDataFunction = data.selectionButtonTemplateInjectVDataFunction; if( selectionButtonTemplateInjectVDataFunction != undefined && selectionButtonTemplateInjectVDataFunction != null ) { var injectVDataJsonObject = selectionButtonTemplateInjectVDataFunction(); if( injectVDataJsonObject != undefined && injectVDataJsonObject != null ) { var modelJsonArrayFunction = injectVDataJsonObject.modelJsonArrayFunction; if( modelJsonArrayFunction != undefined && modelJsonArrayFunction != null ) { var modelJsonArray = modelJsonArrayFunction(jsonObject); var valueArray = []; if( multiselect ) { if( value != undefined && value != null && value != "-div" ) { valueArray = value.split(","); } } else { if( value != undefined && value != null && value != "-div" ) { valueArray.push(value); } } var clickedStyleJsonObjectFunction = injectVDataJsonObject.clickedStyleJsonObjectFunction; var unclickStyleJsonObjectFunction = injectVDataJsonObject.unclickStyleJsonObjectFunction; $.each(modelJsonArray, function(indexV, jsonObjectV) { var valueV = jsonObjectV["value"]; var found = false; $.each(valueArray, function(indexVV, valueVV) { if( valueV == valueVV ) { $("#" + id + "-form-model-" + name + "-button-" + indexV).attr("clicked", "Y"); if( clickedStyleJsonObjectFunction != undefined && clickedStyleJsonObjectFunction != null ) { var styleJsonObject = clickedStyleJsonObjectFunction(jsonObject, jsonObjectV); $("#" + id + "-form-model-" + name + "-button-" + indexV).css(styleJsonObject); } found = true; return false; } }); if( !found ) { $("#" + id + "-form-model-" + name + "-button-" + indexV).attr("clicked", "N"); if( unclickStyleJsonObjectFunction != undefined && unclickStyleJsonObjectFunction != null ) { var styleJsonObject = unclickStyleJsonObjectFunction(jsonObject, jsonObjectV); $("#" + id + "-form-model-" + name + "-button-" + indexV).css(styleJsonObject); } } }); // end each } } } }; resetFormDataFunction = function(data) { var id = data.id; var dataJsonArray = data.dataJsonArray; $.each(dataJsonArray, function(index, jsonObject) { var inputType = jsonObject["inputType"]; var name = jsonObject["name"]; var value = $("#" + id + "-form-model-original-" + name).val(); if( inputType == "hidden" || inputType == "read-only" || inputType == "string" ) { $("#" + id + "-form-model-" + name).val(value); } else if( inputType == "select" ) { $("#" + id + "-form-model-" + name + "-select").val(value); } else if( inputType == "jqx-combobox" ) { } else if( inputType == "selection-button" ) { setSelectionButtonValueFunction(data, jsonObject, value); } }); }; clearFormDataFunction = function(data) { var id = data.id; var dataJsonArray = data.dataJsonArray; $.each(dataJsonArray, function(index, jsonObject) { var inputType = jsonObject["inputType"]; var name = jsonObject["name"]; if( inputType == "hidden" || inputType == "read-only" || inputType == "string" ) { $("#" + id + "-form-model-" + name).val(""); } else if( inputType == "select" ) { $("#" + id + "-form-model-" + name + "-select").val(""); } else if( inputType == "jqx-combobox" ) { } else if( inputType == "selection-button" ) { setSelectionButtonValueFunction(data, jsonObject, ""); } }); }; getFormDataJsonArray = function(data) { var id = data.id; var dataJsonArray = data.dataJsonArray; var formDataJsonArray = []; if( dataJsonArray != undefined && dataJsonArray != null ) { $.each(dataJsonArray, function(index, jsonObject) { var inputType = jsonObject["inputType"]; var name = jsonObject["name"]; var value = null; if( inputType == "hidden" || inputType == "read-only" ) { value = $("#" + id + "-form-model-original-" + name).val(); } else if( inputType == "string" ) { value = $("#" + id + "-form-model-" + name).val(); } else if( inputType == "large-string" ) { value = $("#" + id + "-form-model-" + name).val(); } else if( inputType == "select" ) { value = $("#" + id + "-form-model-" + name + "-select").val(); } else if( inputType == "jqx-combobox" ) { var selectedItemJsonArray = $("#" + id + "-form-model-" + name).jqxComboBox("getSelectedItems"); $.each(selectedItemJsonArray, function(index, jsonObject) { if( index == 0 ) { value = jsonObject["value"]; } else { value += "," + jsonObject["value"]; } }); } else if( inputType == "selection-button" ) { var multiselect = jsonObject["multiselect"]; var count = $("#" + id + "-form-model-" + name + "-button-count").val(); if( count != "" ) { var countInt = parseInt(count); var valueJsonArray = []; var selectionCount = 0; for( var indexV = 0; indexV < countInt; indexV++ ) { var clicked = $("#" + id + "-form-model-" + name + "-button-" + indexV).attr("clicked"); if( clicked == "Y" ) { value = $("#" + id + "-form-model-" + name + "-button-" + indexV).attr("val"); valueJsonArray.push(value); selectionCount = selectionCount + 1; } if( !multiselect && selectionCount == 1 ) { break; } } value = valueJsonArray; } } else if( inputType == "date" ) { value = $("#" + id + "-form-model-" + name).val(); } else if( inputType == "time" ) { value = $("#" + id + "-form-model-" + name).val(); } else if( inputType == "string-tab" ) { var tabJsonArray = jsonObject["tabArray"]; var valueJsonArray = []; $.each(tabJsonArray, function(index, tabJsonObject) { var inputTextId = id + "-form-model-" + name + "-tab-item-input-text-" + index; var tabValue = $("#" + inputTextId).val(); tabValue = tabValue == "" ? null : tabValue; valueJsonArray.push(tabValue); }); value = valueJsonArray; } else if( inputType == "tree" ) { value = getTreeValue({ "id": id + "-form-model-" + name }); } else if( inputType == "editor-tab" ) { var tabValueJsonArray = []; var tabJsonArray = jsonObject["tabArray"]; if( tabJsonArray != undefined && tabJsonArray != null ) { $.each(tabJsonArray, function(index, tabJsonObject) { var tabName = tabJsonObject["name"]; var tabEditorId = tabJsonObject["editorId"]; var tabEditorValue = $("#" + tabEditorId).jqxEditor("val"); // alert(tabEditorValue); var tabValueJsonObject = { "name": tabName, "value": tabEditorValue }; tabValueJsonArray.push(tabValueJsonObject); }); } value = tabValueJsonArray.length == 0 ? null : JSON.stringify(tabValueJsonArray); } else if( inputType == "user-defined-form-setup" ) { var widgetId = id + "-form-model-" + name; value = getUserDefinedFormSetupDataJsonArray(widgetId); } else if( inputType == "user-define" ) { var getWidgetValueFunction = data.getWidgetValueFunction; if( getWidgetValueFunction != undefined && getWidgetValueFunction != null ) { value = getWidgetValueFunction(id, jsonObject); } } var jsonObjectV = { "name": name, "value": value == "" ? null : value }; formDataJsonArray.push(jsonObjectV); }); } return formDataJsonArray; }; getTableDataJsonArray = function(data) { var id = data.id; var dataJsonArrayString = $("#" + id + "-model-json-array").val(); var dataJsonArray = null; if( dataJsonArrayString != undefined && dataJsonArrayString != null && dataJsonArrayString != "" ) { dataJsonArray = $.parseJSON(dataJsonArrayString); } var getSettedValueDataJsonObjectFunction = data.getSettedValueDataJsonObjectFunction; if( dataJsonArray != null ) { $.each(dataJsonArray, function(index, dataJsonObject) { if( getSettedValueDataJsonObjectFunction != undefined && getSettedValueDataJsonObjectFunction != null ) { var updatedDataJsonObject = getSettedValueDataJsonObjectFunction(index, dataJsonObject); dataJsonArray[index] = updatedDataJsonObject; } }); } return dataJsonArray; }; listTemplateInjectV = function(data) { var id = data.id; var dataJsonArray = data.dataJsonArray; var renderEmptyEntityFunction = data.renderEmptyEntityFunction; var renderEntityFunction = data.renderEntityFunction; var setModelDivStyleJsonObjectFunction = data.setModelDivStyleJsonObjectFunction; var setModelTdStyleJsonObjectFunction = data.setModelTdStyleJsonObjectFunction; var entityEventFunction = data.entityEventFunction; var dataCount = dataJsonArray.length; if( dataCount == 0 ) { var html = renderEmptyEntityFunction(); $("#" + id + "-list-model-empty-div").html(html); } else { for( var i = 0; i < dataCount; i++ ) { var jsonObject = dataJsonArray[i]; var html = renderEntityFunction(id, i, jsonObject); $("#" + id + "-list-model-div-" + i).html(html); var modelDivStyleJsonObject = setModelDivStyleJsonObjectFunction(id, i, jsonObject); if( modelDivStyleJsonObject != undefined ) { $("#" + id + "-list-model-div-" + i).css(modelDivStyleJsonObject); } var modelTdStyleJsonObject = setModelTdStyleJsonObjectFunction(id, i, jsonObject); if( modelTdStyleJsonObject != undefined ) { $("#" + id + "-list-model-td-" + i).css(modelTdStyleJsonObject); } entityEventFunction(id, i, jsonObject); } } }; pathMapperTemplateInjectV = function(data) { var id = data.id; var dataJsonArray = data.dataJsonArray; if( dataJsonArray != undefined && dataJsonArray != null ) { var renderLabelSpanFunction = data.renderLabelSpanFunction; var setLabelSpanStyleJsonObjectFunction = data.setLabelSpanStyleJsonObjectFunction; var labelLinkEventFunction = data.labelLinkEventFunction; var separatorImageStyleJsonObjectFunction = data.separatorImageStyleJsonObjectFunction; $.each(dataJsonArray, function(index, dataJsonObject) { if( renderLabelSpanFunction != undefined && renderLabelSpanFunction != null ) { var html = renderLabelSpanFunction(index, dataJsonObject); $("#" + id + "-label-span-" + index).html(html); // alert($("#" + id + "-label-span-" + index).html()); } if( setLabelSpanStyleJsonObjectFunction != undefined && setLabelSpanStyleJsonObjectFunction != null ) { var labelSpanStyleJsonObject = setLabelSpanStyleJsonObjectFunction(index, dataJsonObject); if( labelSpanStyleJsonObject != undefined && labelSpanStyleJsonObject != null ) { $("#" + id + "-label-span-" + index).css(labelSpanStyleJsonObject); } } if( labelLinkEventFunction != undefined && labelLinkEventFunction != null ) { var linkId = id + "-a-" + index; labelLinkEventFunction(linkId, index, dataJsonObject); } if( separatorImageStyleJsonObjectFunction != undefined && separatorImageStyleJsonObjectFunction != null ) { var separatorImageStyleJsonObject = separatorImageStyleJsonObjectFunction(index, dataJsonObject); if( separatorImageStyleJsonObject != undefined && separatorImageStyleJsonObject != null ) { $("#" + id + "-separator-img-" + index).css(separatorImageStyleJsonObject); } } }); } }; tableTemplateInjectV = function(data) { var id = data.id; var dataJsonArray = data.dataJsonArray; if( dataJsonArray != undefined && dataJsonArray != null && dataJsonArray != "" ) { $("#" + id + "-model-json-array").val(JSON.stringify(dataJsonArray)); } var dataCount = dataJsonArray.length; if( dataCount == 0 ) { var renderEmptyEntityFunction = data.renderEmptyEntityFunction; if( renderEmptyEntityFunction != undefined && renderEmptyEntityFunction != null ) { var html = renderEmptyEntityFunction(); $("#" + id + "-model-empty-div").html(html); } } else { var selectionBoolean = data.selection; var masterDetailsButtonBoolean = data.masterDetailsButton; if( selectionBoolean == undefined || selectionBoolean == null ) { selectionBoolean = false; } if( masterDetailsButtonBoolean == undefined || masterDetailsButtonBoolean == null ) { masterDetailsButtonBoolean = false; } var headerSettingJsonArray = data.headerSettingJsonArray; var renderHeaderEntityFunction = data.renderHeaderEntityFunction; var setHeaderTrStyleJsonObjectFunction = data.setHeaderTrStyleJsonObjectFunction; var setHeaderTdStyleJsonObjectFunction = data.setHeaderTdStyleJsonObjectFunction; var setHeaderTdSpanStyleJsonObjectFunction = data.setHeaderTdSpanStyleJsonObjectFunction; var lastIndex = headerSettingJsonArray.length - 1; $.each(headerSettingJsonArray, function(rowIndex, jsonObject) { if( setHeaderTrStyleJsonObjectFunction != undefined && setHeaderTrStyleJsonObjectFunction != null ) { var trStyleJsonObject = setHeaderTrStyleJsonObjectFunction(rowIndex); if( trStyleJsonObject != undefined && trStyleJsonObject != null ) { $("#" + id + "-header-tr-" + rowIndex).css(trStyleJsonObject); } } var colIndex = 0; if( masterDetailsButtonBoolean ) { if( rowIndex == lastIndex ) { if( setHeaderTdStyleJsonObjectFunction != undefined && setHeaderTdStyleJsonObjectFunction != null ) { var tdStyleJsonObject = setHeaderTdStyleJsonObjectFunction(0, 0); if( tdStyleJsonObject != undefined && tdStyleJsonObject != null ) { $("#" + id + "-header-td-0-" + colIndex).css(tdStyleJsonObject); } } colIndex = colIndex + 1; } } if( selectionBoolean ) { if( rowIndex == lastIndex ) { if( setHeaderTdStyleJsonObjectFunction != undefined && setHeaderTdStyleJsonObjectFunction != null ) { var tdStyleJsonObject = setHeaderTdStyleJsonObjectFunction(0, 0); if( tdStyleJsonObject != undefined && tdStyleJsonObject != null ) { $("#" + id + "-header-td-0-" + colIndex).css(tdStyleJsonObject); } } $("#" + id + "-header-td-checkbox").click(function(event) { var checked = $(this).prop("checked"); if( checked ) { $("[id|='" + id + "-model-td-checkbox']").prop("checked", true); } else { $("[id|='" + id + "-model-td-checkbox']").prop("checked", false); } }); colIndex = colIndex + 1; } } var headerRowEntitySettingJsonArray = jsonObject["entitySettingJsonArray"]; $.each(headerRowEntitySettingJsonArray, function(headerRowEntitySettingIndex, headerRowEntitySettingJsonObject) { var colSpan = headerRowEntitySettingJsonObject["colSpan"]; if( rowIndex < lastIndex ) { if( renderHeaderEntityFunction != undefined && renderHeaderEntityFunction != null ) { var html = renderHeaderEntityFunction(rowIndex, colIndex); $("#" + id + "-header-td-span-" + rowIndex + "-" + colIndex).html(html); } if( setHeaderTdSpanStyleJsonObjectFunction != undefined && setHeaderTdSpanStyleJsonObjectFunction != null ) { var tdSpanStyleJsonObject = setHeaderTdSpanStyleJsonObjectFunction(rowIndex, colIndex); if( tdSpanStyleJsonObject != undefined && tdSpanStyleJsonObject != null ) { $("#" + id + "-header-td-span-" + rowIndex + "-" + colIndex).css(tdSpanStyleJsonObject); } } if( setHeaderTdStyleJsonObjectFunction != undefined && setHeaderTdStyleJsonObjectFunction != null ) { var tdStyleJsonObject = setHeaderTdStyleJsonObjectFunction(rowIndex, colIndex); if( tdStyleJsonObject != undefined && tdStyleJsonObject != null ) { $("#" + id + "-header-td-" + rowIndex + "-" + colIndex).css(tdStyleJsonObject); } } } else { if( renderHeaderEntityFunction != undefined && renderHeaderEntityFunction != null ) { var html = renderHeaderEntityFunction(rowIndex, colIndex); $("#" + id + "-header-td-sorting-link-span-" + rowIndex + "-" + colIndex).html(html); } if( setHeaderTdSpanStyleJsonObjectFunction != undefined && setHeaderTdSpanStyleJsonObjectFunction != null ) { var tdSpanStyleJsonObject = setHeaderTdSpanStyleJsonObjectFunction(rowIndex, colIndex); if( tdSpanStyleJsonObject != undefined && tdSpanStyleJsonObject != null ) { $("#" + id + "-header-td-sorting-link-span-" + rowIndex + "-" + colIndex).css(tdSpanStyleJsonObject); } } var sorting = data.sorting; if( sorting != undefined && sorting != null && sorting ) { var headerTdSortingLinkEventFunction = data.headerTdSortingLinkEventFunction; if( headerTdSortingLinkEventFunction != undefined && headerTdSortingLinkEventFunction != null ) { var linkId = id + "-header-td-sorting-link-" + rowIndex + "-" + colIndex; headerTdSortingLinkEventFunction(linkId, rowIndex, colIndex); } } if( setHeaderTdStyleJsonObjectFunction != undefined && setHeaderTdStyleJsonObjectFunction != null ) { var tdStyleJsonObject = setHeaderTdStyleJsonObjectFunction(rowIndex, colIndex); if( tdStyleJsonObject != undefined && tdStyleJsonObject != null ) { $("#" + id + "-header-td-" + rowIndex + "-" + colIndex).css(tdStyleJsonObject); } } } colIndex = colIndex + parseInt(colSpan); }); }); var contentColumnCount = data.contentColumnCount; var renderContentMasterDetailsTdImgDivFunction = data.renderContentMasterDetailsTdImgDivFunction; var setContentMasterDetailsTdDivStyleJsonObjectFunction = data.setContentMasterDetailsTdDivStyleJsonObjectFunction; var setContentMasterDetailsTdStyleJsonObjectFunction = data.setContentMasterDetailsTdStyleJsonObjectFunction; var setContentMasterDetailsTrStyleJsonObjectFunction = data.setContentMasterDetailsTrStyleJsonObjectFunction; var contentMasterDetailsTdImgDivEventFunction = data.contentMasterDetailsTdImgDivEventFunction; var renderContentEntityFunction = data.renderContentEntityFunction; var contentEntityEventFunction = data.contentEntityEventFunction; var setContentTrHighlightStyleJsonObjectFunction = data.setContentTrHighlightStyleJsonObjectFunction; var setContentTrNormalStyleJsonObjectFunction = data.setContentTrNormalStyleJsonObjectFunction; var setContentTdStyleJsonObjectFunction = data.setContentTdStyleJsonObjectFunction; var setContentTdDivStyleJsonObjectFunction = data.setContentTdDivStyleJsonObjectFunction; var masterDetailsBoolean = data.masterDetails; if( masterDetailsBoolean == undefined || masterDetailsBoolean == null ) { masterDetailsBoolean = false; } $.each(dataJsonArray, function(rowIndex, dataJsonObject) { if( masterDetailsBoolean ) { var contentMasterDetailsInjectVDataFunction = data.contentMasterDetailsInjectVDataFunction; if( contentMasterDetailsInjectVDataFunction != undefined && contentMasterDetailsInjectVDataFunction != null ) { var trId = id + "-model-master-details-tr-" + rowIndex; var tdId = id + "-model-master-details-td-" + rowIndex; var divId = id + "-model-master-details-td-div-" + rowIndex; var injectVDataJsonObject = contentMasterDetailsInjectVDataFunction(id, trId, tdId, divId); var renderTdImgDivFunction = injectVDataJsonObject.renderTdImgDivFunction; if( renderTdImgDivFunction != undefined && renderTdImgDivFunction != null ) { var html = renderTdImgDivFunction(rowIndex, dataJsonObject); $("#" + id + "-model-td-master-details-img-div-" + rowIndex).html(html); } var setTdDivStyleJsonObjectFunction = injectVDataJsonObject.setTdDivStyleJsonObjectFunction; if( setTdDivStyleJsonObjectFunction != undefined && setTdDivStyleJsonObjectFunction != null ) { var tdDivStyleJsonObject = setTdDivStyleJsonObjectFunction(); $("#" + divId).css(tdDivStyleJsonObject); } var setTdStyleJsonObjectFunction = injectVDataJsonObject.setTdStyleJsonObjectFunction; if( setTdStyleJsonObjectFunction != undefined && setTdStyleJsonObjectFunction != null ) { var tdStyleJsonObject = setTdStyleJsonObjectFunction(); $("#" + tdId).css(tdStyleJsonObject); } var setTrStyleJsonObjectFunction = injectVDataJsonObject.setTrStyleJsonObjectFunction; if( setTrStyleJsonObjectFunction != undefined && setTrStyleJsonObjectFunction != null ) { var trStyleJsonObject = setTrStyleJsonObjectFunction(); $("#" + trId).css(trStyleJsonObject); } $("#" + divId).css({"display": "none"}); $("#" + tdId).css({"display": "none"}); var tdImgDivEventFunction = injectVDataJsonObject.tdImgDivEventFunction; if( tdImgDivEventFunction != undefined && tdImgDivEventFunction != null ) { tdImgDivEventFunction(rowIndex, dataJsonObject); } } } if( selectionBoolean ) { $("#" + id + "-model-td-checkbox-" + rowIndex).click(function(event) { alert("model-td-checkbox clicked"); }); } for( var colIndex = 0; colIndex < parseInt(contentColumnCount); colIndex++ ) { if( renderContentEntityFunction != undefined && renderContentEntityFunction != null ) { var html = renderContentEntityFunction(id, rowIndex, colIndex, dataJsonObject); $("#" + id + "-model-td-div-" + rowIndex + "-" + colIndex).html(html); } if( contentEntityEventFunction != undefined && contentEntityEventFunction != null ) { contentEntityEventFunction(id, rowIndex, colIndex, dataJsonObject); } if( setContentTdDivStyleJsonObjectFunction != undefined && setContentTdDivStyleJsonObjectFunction != null ) { var tdDivStyleJsonObject = setContentTdDivStyleJsonObjectFunction(rowIndex, colIndex, dataJsonObject); if( tdDivStyleJsonObject != undefined && tdDivStyleJsonObject != null ) { $("#" + id + "-model-td-div-" + rowIndex + "-" + colIndex).css(tdDivStyleJsonObject); } } if( setContentTdStyleJsonObjectFunction != undefined && setContentTdStyleJsonObjectFunction != null ) { var tdStyleJsonObject = setContentTdStyleJsonObjectFunction(rowIndex, colIndex, dataJsonObject); if( tdStyleJsonObject != undefined && tdStyleJsonObject != null ) { $("#" + id + "-model-td-" + rowIndex + "-" + colIndex).css(tdStyleJsonObject); } } } if( setContentTrNormalStyleJsonObjectFunction != undefined && setContentTrNormalStyleJsonObjectFunction != null ) { var contentTrStyleJsonObject = setContentTrNormalStyleJsonObjectFunction(rowIndex, dataJsonObject); if( contentTrStyleJsonObject != undefined && contentTrStyleJsonObject != null ) { $("#" + id + "-model-tr-" + rowIndex).css(contentTrStyleJsonObject); } if( setContentTrHighlightStyleJsonObjectFunction != undefined && setContentTrHighlightStyleJsonObjectFunction != null ) { $("#" + id + "-model-tr-" + rowIndex).mouseover(function(event) { event.preventDefault(); var contentTrStyleJsonObject = setContentTrHighlightStyleJsonObjectFunction(rowIndex, dataJsonObject); if( contentTrStyleJsonObject != undefined && contentTrStyleJsonObject != null ) { $(this).css(contentTrStyleJsonObject); } }); $("#" + id + "-model-tr-" + rowIndex).mouseout(function(event) { event.preventDefault(); var contentTrStyleJsonObject = setContentTrNormalStyleJsonObjectFunction(rowIndex, dataJsonObject); if( contentTrStyleJsonObject != undefined && contentTrStyleJsonObject != null ) { $(this).css(contentTrStyleJsonObject); } }); } } }); var footerSettingJsonArray = data.footerSettingJsonArray; if( footerSettingJsonArray != undefined && footerSettingJsonArray != null ) { var renderFooterEntityFunction = data.renderFooterEntityFunction; var setFooterTrStyleJsonObjectFunction = data.setFooterTrStyleJsonObjectFunction; var setFooterTdStyleJsonObjectFunction = data.setFooterTdStyleJsonObjectFunction; var setFooterTdSpanStyleJsonObjectFunction = data.setFooterTdSpanStyleJsonObjectFunction; $.each(footerSettingJsonArray, function(rowIndex, jsonObject) { if( setFooterTrStyleJsonObjectFunction != undefined && setFooterTrStyleJsonObjectFunction != null ) { var footerTrStyleJsonObject = setFooterTrStyleJsonObjectFunction(); if( footerTrStyleJsonObject != undefined && footerTrStyleJsonObject != null ) { $("#" + id + "-footer-tr-" + rowIndex).css(footerTrStyleJsonObject); } } var colIndex = 0; if( rowIndex == lastIndex ) { if( masterDetailsBoolean ) { if( setFooterTdStyleJsonObjectFunction != undefined && setFooterTdStyleJsonObjectFunction != null ) { var tdStyleJsonObject = setFooterTdStyleJsonObjectFunction(0, colIndex); if( tdStyleJsonObject != undefined && tdStyleJsonObject != null ) { $("#" + id + "-footer-td-0-" + colIndex).css(tdStyleJsonObject); } } colIndex = 1; } if( selectionBoolean ) { if( setFooterTdStyleJsonObjectFunction != undefined && setFooterTdStyleJsonObjectFunction != null ) { var tdStyleJsonObject = setFooterTdStyleJsonObjectFunction(0, colIndex); if( tdStyleJsonObject != undefined && tdStyleJsonObject != null ) { $("#" + id + "-footer-td-0-" + colIndex).css(tdStyleJsonObject); } } colIndex = 1; } } var footerRowEntitySettingJsonArray = jsonObject["entitySettingJsonArray"]; $.each(footerRowEntitySettingJsonArray, function(footerRowEntitySettingIndex, footerRowEntitySettingJsonObject) { var colSpan = footerRowEntitySettingJsonObject["colSpan"]; if( renderFooterEntityFunction != undefined && renderFooterEntityFunction != null ) { var html = renderFooterEntityFunction(rowIndex, colIndex); $("#" + id + "-footer-td-span-" + rowIndex + "-" + colIndex).html(html); } if( setFooterTdSpanStyleJsonObjectFunction != undefined && setFooterTdSpanStyleJsonObjectFunction != null ) { var tdSpanStyleJsonObject = setFooterTdSpanStyleJsonObjectFunction(rowIndex, colIndex); if( tdSpanStyleJsonObject != undefined && tdSpanStyleJsonObject != null ) { $("#" + id + "-footer-td-span-" + rowIndex + "-" + colIndex).css(tdSpanStyleJsonObject); } } if( setFooterTdStyleJsonObjectFunction != undefined && setFooterTdStyleJsonObjectFunction != null ) { var tdStyleJsonObject = setFooterTdStyleJsonObjectFunction(rowIndex, colIndex); if( tdStyleJsonObject != undefined && tdStyleJsonObject != null ) { $("#" + id + "-footer-td-" + rowIndex + "-" + colIndex).css(tdStyleJsonObject); } } colIndex = colIndex + parseInt(colSpan); }); }); } var pagingBoolean = data.paging; if( pagingBoolean == undefined || pagingBoolean == null ) { pagingBoolean = false; } if( pagingBoolean ) { var renderFirstPageButtonFunction = data.renderFirstPageButtonFunction; var firstPageButtonEventFunction = data.firstPageButtonEventFunction; var renderPreviousPageButtonFunction = data.renderPreviousPageButtonFunction; var previousPageButtonEventFunction = data.previousPageButtonEventFunction; var renderPageSelectionFunction = data.renderPageSelectionFunction; var pageSelectionEventFunction = data.pageSelectionEventFunction; var renderNextPageButtonFunction = data.renderNextPageButtonFunction; var nextPageButtonEventFunction = data.nextPageButtonEventFunction; var renderLastPageButtonFunction = data.renderLastPageButtonFunction; var lastPageButtonEventFunction = data.lastPageButtonEventFunction; var firstPageButtonHtml = renderFirstPageButtonFunction(id); $("#" + id + "-page-first-div").html(firstPageButtonHtml); firstPageButtonEventFunction(id); var previousPageButtonHtml = renderPreviousPageButtonFunction(id); $("#" + id + "-page-previous-div").html(previousPageButtonHtml); previousPageButtonEventFunction(id); var pageSelectionButtonHtml = renderPageSelectionFunction(id); $("#" + id + "-page-selection-div").html(pageSelectionButtonHtml); pageSelectionEventFunction(id); var nextPageButtonHtml = renderNextPageButtonFunction(id); $("#" + id + "-page-next-div").html(nextPageButtonHtml); nextPageButtonEventFunction(id); var lastPageButtonHtml = renderLastPageButtonFunction(id); $("#" + id + "-page-last-div").html(lastPageButtonHtml); lastPageButtonEventFunction(id); } } // end if }; getTableSelectedDataJsonArray = function(id) { var jsonArray = []; var modelCount = $("#" + id + "-model-count").val(); var modelFieldCount = $("#" + id + "-model-field-count").val(); for( var i = 0; i < parseInt(modelCount); i++ ) { var checked = $("#" + id + "-model-td-checkbox-" + i).prop("checked"); if( checked ) { var jsonObject = {}; for( var j = 0; j < parseInt(modelFieldCount); j++ ) { var key = $("#" + id + "-model-" + i + "-" + j).attr("key"); var value = $("#" + id + "-model-" + i + "-" + j).val(); jsonObject[key] = value; } jsonArray.push(jsonObject); } } return jsonArray; }; treeTemplateInjectV = function(data) { var id = data.id; var templateUrl = data.templateUrl; var value = data.value; var width = data.width; var height = data.height; var getDataJsonArrayFunction = data.getDataJsonArrayFunction; var getJqxTreeSourceFunction = data.getJqxTreeSourceFunction; var getCoSelectedItemIdJsonArrayFunction = data.getCoSelectedItemIdJsonArrayFunction; var expandedTreeNodeEventFunction = data.expandedTreeNodeEventFunction; var selectTreeNodeEventFunction = data.selectTreeNodeEventFunction; var rightClickTreeNodeEventFunction = data.rightClickTreeNodeEventFunction; if( id != undefined && id != null ) { if( templateUrl != undefined && templateUrl != null ) { $.ajax({ url: templateUrl, data: { "id": id }, type: "post", async: false, dataType: "html", success: function(htmlData) { var html = removeSpaceFunction(htmlData); $("#" + id).html(html); $("#" + id + "-expand-boolean").val("1"); } }); } if( getDataJsonArrayFunction != undefined && getDataJsonArrayFunction != null && getJqxTreeSourceFunction != undefined && getJqxTreeSourceFunction != null ) { var dataJsonArray = getDataJsonArrayFunction(); setTreeDataJsonArray({ "id": id, "value": dataJsonArray }); var itemIdPrefix = id + "-tree-item-"; setItemIdPrefix({ "id": id, "value": itemIdPrefix }); var dataJsonArray = getDataJsonArrayFunction({ "id": id }); var sourceData = getJqxTreeSourceFunction(itemIdPrefix, dataJsonArray); // alert("init tree id: " + "#" + id + "-tree"); // alert("init source: " + JSON.stringify(sourceData)); var dataSource = { datatype: "json", datafields: [ { name: "id" }, { name: "icon" }, { name: "parentId" }, { name: "label" }, { name: "value" } ], id: "id", icon: "icon", localdata: sourceData }; var dataAdapter = new $.jqx.dataAdapter(dataSource); dataAdapter.dataBind(); var source = dataAdapter.getRecordsHierarchy("id", "parentId", "items", [{ name: "label", map: "label"}]); var theme = localStorage.getItem("jqwidget-theme"); $("#" + id + "-tree").jqxTree({ theme: theme, source: source, width: width, height: height }); $("#" + id + "-tree").on("expand", function(event) { if( expandedTreeNodeEventFunction != undefined && expandedTreeNodeEventFunction != null ) { var expandBoolean = $("#" + id + "-expand-boolean").val(); if( expandBoolean == "1" ) { expandBoolean = true; } else { expandBoolean = false; } var dataJsonArray = getDataJsonArrayFunction({ "id": id }); var loaderItem = expandedTreeNodeEventFunction(id + "-tree", expandBoolean, dataJsonArray, event); if( loaderItem != null ) { var dataJsonArray = getDataJsonArrayFunction(); setTreeDataJsonArray({ "id": id, "value": dataJsonArray }); var itemIdPrefix = getItemIdPrefix({ "id": id }); var dataJsonArray = getTreeDataJsonArray({ "id": id }); var sourceData = getJqxTreeSourceFunction(itemIdPrefix, dataJsonArray); var dataSource = { datatype: "json", datafields: [ { name: "id" }, { name: "icon" }, { name: "parentId" }, { name: "label" }, { name: "value" } ], id: "id", icon: "icon", localdata: sourceData }; var dataAdapter = new $.jqx.dataAdapter(dataSource); dataAdapter.dataBind(); var source = dataAdapter.getRecordsHierarchy("id", "parentId", "items", [{ name: "label", map: "label"}]); var $element = $(event.args.element); $("#" + id + "-tree").jqxTree("addTo", source, $element); $("#" + id + "-tree").jqxTree("removeItem", loaderItem.element); } } }); $("#" + id + "-tree").on("select", function(event) { // alert("select function"); var jsonObject = $("#" + id + "-tree").jqxTree("getItem", event.args.element); var value = jsonObject["value"]; setTreeValue({ "id": id, "value": value }); if( selectTreeNodeEventFunction != undefined && selectTreeNodeEventFunction != null ) { selectTreeNodeEventFunction(value); } }); $("#" + id + "-tree").on("mousedown", "li", function(event) { var target = $(event.target).parents("li:first")[0]; $("#" + id + "-tree").jqxTree("selectItem", target); var isRightClick = isMouseRightClickFunction(event); if( isRightClick ) { if( rightClickTreeNodeEventFunction != undefined && rightClickTreeNodeEventFunction != null ) { rightClickTreeNodeEventFunction(id + "-tree", event); } return false; } }); if( value != undefined && value != null ) { $("#" + id + "-expand-boolean").val("0"); $("#" + id + "-tree").jqxTree("expandAll"); $("#" + id + "-expand-boolean").val("1"); if( getCoSelectedItemIdJsonArrayFunction != undefined && getCoSelectedItemIdJsonArrayFunction != null ) { var dataJsonArray = getTreeDataJsonArray({ "id": id }); var coSelectedItemIdJsonArray = getCoSelectedItemIdJsonArrayFunction(itemIdPrefix, value, dataJsonArray); $.each(coSelectedItemIdJsonArray, function(index, coSelectedItemId) { $("#" + id + "-tree").jqxTree("collapseItem", $("#" + coSelectedItemId)[0]); }); $("#" + id + "-tree").jqxTree("selectItem", $("#" + itemIdPrefix + value)[0]); setTreeValue({ "id": id, "value": value }); } } } } }; refreshTree = function(data) { var theme = localStorage.getItem("jqwidget-theme"); var id = data.id; var getDataJsonArrayFunction = data.getDataJsonArrayFunction; var getJqxTreeSourceFunction = data.getJqxTreeSourceFunction; if( getDataJsonArrayFunction != undefined && getDataJsonArrayFunction != null && getJqxTreeSourceFunction != undefined && getJqxTreeSourceFunction != null ) { // alert("refresh id: " + "#" + id + "-tree"); // alert("refresh source: " + JSON.stringify(source)); $("#" + id + "-tree").jqxTree("clear"); var dataJsonArray = getDataJsonArrayFunction({ "id": id }); var itemIdPrefix = id + "-tree-item-"; var sourceData = getJqxTreeSourceFunction(itemIdPrefix, dataJsonArray); var dataSource = { datatype: "json", datafields: [ { name: "id" }, { name: "icon" }, { name: "parentId" }, { name: "label" }, { name: "value" } ], id: "id", icon: "icon", localdata: sourceData }; var dataAdapter = new $.jqx.dataAdapter(dataSource); dataAdapter.dataBind(); var source = dataAdapter.getRecordsHierarchy("id", "parentId", "items", [{ name: "label", map: "label"}]); $("#" + id + "-tree").jqxTree({ theme: theme, source: source }); } }; getItemIdPrefix = function(data) { var id = data.id; var value = $("#" + id + "-item-id-prefix").val(); return value; }; setItemIdPrefix = function(data) { var id = data.id; var value = data.value; $("#" + id + "-item-id-prefix").val(value); }; getTreeValue = function(data) { var id = data.id; var value = $("#" + id + "-selectedNode").val(); return value; }; setTreeValue = function(data) { var id = data.id; var value = data.value; $("#" + id + "-selectedNode").val(value); }; getTreeDataJsonArray = function(data) { var id = data.id; var value = $("#" + id + "-data-json-array").val(); if( value != undefined && value != "" ) { return $.parseJSON(value); } else { return null; } }; setTreeDataJsonArray = function(data) { var id = data.id; var value = data.value; if( value != undefined && value != null ) { $("#" + id + "-data-json-array").val(JSON.stringify(value)); } else { $("#" + id + "-data-json-array").val(""); } }; clearTreeSelection = function(data) { var id = data.id; $("#" + id + "-tree").jqxTree("selectItem", null); setTreeValue({ "id": id, "value": null }); }; colorPickerTemplateInjectV = function(data) { var id = data.id; var value = data.value; if( value == undefined || value == null ) { value = "aaaaaa"; } var theme = localStorage.getItem("jqwidget-theme"); $("#" + id + "-color-div").jqxColorPicker({ "color": value, "colorMode": "hue", "width": 220, "height": 220 }); $("#" + id + "-dropdown-div").jqxDropDownButton({ "theme": theme, "width": 150, "height": 22 }); $("#" + id + "-dropdown-div").jqxDropDownButton("setContent", getTextElementByColor(new $.jqx.color({ hex: value }))); }; getTextElementByColor = function(color) { if (color == 'transparent' || color.hex == "") { return $("
transparent
"); } var element = $("
#" + color.hex + "
"); var nThreshold = 105; var bgDelta = (color.r * 0.299) + (color.g * 0.587) + (color.b * 0.114); var foreColor = (255 - bgDelta < nThreshold) ? 'Black' : 'White'; element.css('color', foreColor); element.css('background', "#" + color.hex); element.addClass('jqx-rc-all'); return element; }; getColorPickerValue = function(data) { var id = data.id; var color = $("#" + id + "-color-div").jqxColorPicker("getColor"); return color.hex.toLowerCase(); }; setColorPickerValue = function(data) { var id = data.id; var value = data.value; $("#" + id + "-color-div").jqxColorPicker("setColor", value); }; uploadTemplateInjectV = function(data) { var id = data.id; var widgetType = data.widgetType; var multipleFile = data.multipleFile; var url = data.url; var dataJsonObject = data.dataJsonObject; var renderInitUploadResultFunction = data.renderInitUploadResultFunction; var initUploadResultEventFunction = data.initUploadResultEventFunction; var renderUploadResultFunction = data.renderUploadResultFunction; var uploadResultEventFunction = data.uploadResultEventFunction; var uploadProgressallFunction = data.uploadProgressallFunction; if( widgetType == "link" ) { var renderLinkContentFunction = data.renderLinkContentFunction; var html = renderLinkContentFunction(id); $("#" + id + "-upload-link").html(html); } else if( widgetType == "html-button" ) { var uploadButtonText = data.uploadButtonText; $("#" + id + "-upload-button").html(uploadButtonText); var setButtonStyleJsonObjectFunction = data.setButtonStyleJsonObjectFunction; if( setButtonStyleJsonObjectFunction != undefined && setButtonStyleJsonObjectFunction != null ) { var buttonStyleJsonObject = setButtonStyleJsonObjectFunction(); if( buttonStyleJsonObject != undefined && buttonStyleJsonObject != null ) { $("#" + id + "-upload-button").css(buttonStyleJsonObject); } } } else if( widgetType == "jquery-button" ) { var buttonText = data.buttonText; $("#" + id + "-upload-button").html(buttonText); var setButtonStyleJsonObjectFunction = data.setButtonStyleJsonObjectFunction; if( setButtonStyleJsonObjectFunction != undefined && setButtonStyleJsonObjectFunction != null ) { var buttonStyleJsonObject = setButtonStyleJsonObjectFunction(); if( buttonStyleJsonObject != undefined && buttonStyleJsonObject != null ) { $("#" + id + "-upload-button").css(buttonStyleJsonObject); } } var setJqueryButtonStyleJsonObjectFunction = data.setJqueryButtonStyleJsonObjectFunction; if( setJqueryButtonStyleJsonObjectFunction != undefined && setJqueryButtonStyleJsonObjectFunction != null ) { var jqueryButtonStyleJsonObject = setJqueryButtonStyleJsonObjectFunction(); $("#" + id + "-upload-button").button(jqueryButtonStyleJsonObject); } $("#" + id + "-upload-button").click(function(event) { event.preventDefault(); $("#" + id + "-upload-file").trigger("click"); return false; }); } if( multipleFile ) { $("#" + id + "-upload-file").attr("multiple", "true"); } var html = renderInitUploadResultFunction(id); $("#" + id + "-upload-result-div").html(html); initUploadResultEventFunction(id); $("#" + id + "-upload-file").fileupload({ url: url, dataType: "text", formData: dataJsonObject, done: function(e, data) { var resultStatus = data.result; // alert(resultStatus); // alert(resultJsonArray); var html = renderUploadResultFunction(id, e, data); $("#" + id + "-upload-result-div").html(html); uploadResultEventFunction(id, e, data); }, progressall: function(e, data) { // alert(data.loaded + "/" + data.total); uploadProgressallFunction(id, e, data); } }); }; userDefinedFormSetupTemplateInjectV = function(data) { var id = data.id; var messageJsonObject = data.message; if( messageJsonObject != undefined && messageJsonObject != null ) { var nameMessage = messageJsonObject["name"]; if( nameMessage != undefined && nameMessage != null ) { $("#" + id + "-name-table-header-td-span").html(nameMessage); } var labelMessageKeyMessage = messageJsonObject["labelMessageKey"]; if( labelMessageKeyMessage != undefined && labelMessageKeyMessage != null ) { $("#" + id + "-label-message-key-table-header-td-span").html(labelMessageKeyMessage); } var typeMessage = messageJsonObject["type"]; if( typeMessage != undefined && typeMessage != null ) { $("#" + id + "-type-table-header-td-span").html(typeMessage); } var optionMessage = messageJsonObject["option"]; if( optionMessage != undefined && optionMessage != null ) { $("#" + id + "-option-table-header-td-span").html(optionMessage); } var rangeMessage = messageJsonObject["range"]; if( rangeMessage != undefined && rangeMessage != null ) { $("#" + id + "-range-table-header-td-span").html(rangeMessage); } var isnullMessage = messageJsonObject["isnull"]; if( isnullMessage != undefined && isnullMessage != null ) { $("#" + id + "-isnull-table-header-td-span").html(isnullMessage); } var defaultValueMessage = messageJsonObject["defaultValue"]; if( defaultValueMessage != undefined && defaultValueMessage != null ) { $("#" + id + "-default-value-table-header-td-span").html(defaultValueMessage); } var clearButtonMessage = messageJsonObject["clearButton"]; if( clearButtonMessage != undefined && clearButtonMessage != null ) { $("#" + id + "-clear-button-0").html(clearButtonMessage); } var addButtonMessage = messageJsonObject["addButton"]; if( addButtonMessage != undefined && addButtonMessage != null ) { $("#" + id + "-add-button-0").html(addButtonMessage); } } else { $("#" + id + "-name-table-header-td-span").html("name"); $("#" + id + "-label-message-key-table-header-td-span").html("label message key"); $("#" + id + "-type-table-header-td-span").html("type"); $("#" + id + "-option-table-header-td-span").html("option"); $("#" + id + "-range-table-header-td-span").html("range"); $("#" + id + "-isnull-table-header-td-span").html("is null"); $("#" + id + "-default-value-table-header-td-span").html("default value"); $("#" + id + "-clear-button-0").html("clear"); $("#" + id + "-add-button-0").html("add"); } var setTableHeaderTdStyleJsonObjectFunction = data.setTableHeaderTdStyleJsonObjectFunction; if( setTableHeaderTdStyleJsonObjectFunction != undefined && setTableHeaderTdStyleJsonObjectFunction != null ) { var nameTableHeaderTdStyleJsonObject = setTableHeaderTdStyleJsonObjectFunction(null, null, "name"); if( nameTableHeaderTdStyleJsonObject != undefined && nameTableHeaderTdStyleJsonObject != null ) { $("#" + id + "-name-table-header-td").css(nameTableHeaderTdStyleJsonObject); } var labelMessageKeyTableHeaderTdStyleJsonObject = setTableHeaderTdStyleJsonObjectFunction(null, null, "labelMessageKey"); if( labelMessageKeyTableHeaderTdStyleJsonObject != undefined && labelMessageKeyTableHeaderTdStyleJsonObject != null ) { $("#" + id + "-label-message-key-table-header-td").css(labelMessageKeyTableHeaderTdStyleJsonObject); } var typeTableHeaderTdStyleJsonObject = setTableHeaderTdStyleJsonObjectFunction(null, null, "type"); if( typeTableHeaderTdStyleJsonObject != undefined && typeTableHeaderTdStyleJsonObject != null ) { $("#" + id + "-type-table-header-td").css(typeTableHeaderTdStyleJsonObject); } var optionTableHeaderTdStyleJsonObject = setTableHeaderTdStyleJsonObjectFunction(null, null, "option"); if( optionTableHeaderTdStyleJsonObject != undefined && optionTableHeaderTdStyleJsonObject != null ) { $("#" + id + "-option-table-header-td").css(optionTableHeaderTdStyleJsonObject); } var rangeTableHeaderTdStyleJsonObject = setTableHeaderTdStyleJsonObjectFunction(null, null, "range"); if( rangeTableHeaderTdStyleJsonObject != undefined && rangeTableHeaderTdStyleJsonObject != null ) { $("#" + id + "-range-table-header-td").css(rangeTableHeaderTdStyleJsonObject); } var isnullTableHeaderTdStyleJsonObject = setTableHeaderTdStyleJsonObjectFunction(null, null, "isnull"); if( isnullTableHeaderTdStyleJsonObject != undefined && isnullTableHeaderTdStyleJsonObject != null ) { $("#" + id + "-isnull-table-header-td").css(isnullTableHeaderTdStyleJsonObject); } var defaultValueTableHeaderTdStyleJsonObject = setTableHeaderTdStyleJsonObjectFunction(null, null, "defaultValue"); if( defaultValueTableHeaderTdStyleJsonObject != undefined && defaultValueTableHeaderTdStyleJsonObject != null ) { $("#" + id + "-default-value-table-header-td").css(defaultValueTableHeaderTdStyleJsonObject); } var operationTableHeaderTdStyleJsonObject = setTableHeaderTdStyleJsonObjectFunction(null, null, "operation"); if( operationTableHeaderTdStyleJsonObject != undefined && operationTableHeaderTdStyleJsonObject != null ) { $("#" + id + "-operation-table-header-td").css(operationTableHeaderTdStyleJsonObject); } } else { $("#" + id + "-name-table-header-td").css({ "border": "1px solid #aaaaaa" }); $("#" + id + "-label-message-key-table-header-td").css({ "border": "1px solid #aaaaaa" }); $("#" + id + "-type-table-header-td").css({ "border": "1px solid #aaaaaa" }); $("#" + id + "-option-table-header-td").css({ "border": "1px solid #aaaaaa" }); $("#" + id + "-range-table-header-td").css({ "border": "1px solid #aaaaaa" }); $("#" + id + "-isnull-table-header-td").css({ "border": "1px solid #aaaaaa" }); $("#" + id + "-default-value-table-header-td").css({ "border": "1px solid #aaaaaa" }); $("#" + id + "-operation-table-header-td").css({ "border": "1px solid #aaaaaa" }); } var setTableHeaderTdSpanStyleJsonObjectFunction = data.setTableHeaderTdSpanStyleJsonObjectFunction; if( setTableHeaderTdSpanStyleJsonObjectFunction != undefined && setTableHeaderTdSpanStyleJsonObjectFunction != null ) { var nameTableHeaderTdSpanStyleJsonObject = setTableHeaderTdSpanStyleJsonObjectFunction(null, null, "name"); if( nameTableHeaderTdSpanStyleJsonObject != undefined && nameTableHeaderTdSpanStyleJsonObject != null ) { $("#" + id + "-name-table-header-td-span").css(nameTableHeaderTdSpanStyleJsonObject); } var labelMessageKeyTableHeaderTdSpanStyleJsonObject = setTableHeaderTdSpanStyleJsonObjectFunction(null, null, "labelMessageKey"); if( labelMessageKeyTableHeaderTdSpanStyleJsonObject != undefined && labelMessageKeyTableHeaderTdSpanStyleJsonObject != null ) { $("#" + id + "-label-message-key-table-header-td-span").css(labelMessageKeyTableHeaderTdSpanStyleJsonObject); } var typeTableHeaderTdSpanStyleJsonObject = setTableHeaderTdSpanStyleJsonObjectFunction(null, null, "type"); if( typeTableHeaderTdSpanStyleJsonObject != undefined && typeTableHeaderTdSpanStyleJsonObject != null ) { $("#" + id + "-type-table-header-td-span").css(typeTableHeaderTdSpanStyleJsonObject); } var optionTableHeaderTdSpanStyleJsonObject = setTableHeaderTdSpanStyleJsonObjectFunction(null, null, "option"); if( optionTableHeaderTdSpanStyleJsonObject != undefined && optionTableHeaderTdSpanStyleJsonObject != null ) { $("#" + id + "-option-table-header-td-span").css(optionTableHeaderTdSpanStyleJsonObject); } var rangeTableHeaderTdSpanStyleJsonObject = setTableHeaderTdSpanStyleJsonObjectFunction(null, null, "range"); if( rangeTableHeaderTdSpanStyleJsonObject != undefined && rangeTableHeaderTdSpanStyleJsonObject != null ) { $("#" + id + "-range-table-header-td-span").css(rangeTableHeaderTdSpanStyleJsonObject); } var isnullTableHeaderTdSpanStyleJsonObject = setTableHeaderTdSpanStyleJsonObjectFunction(null, null, "isnull"); if( isnullTableHeaderTdSpanStyleJsonObject != undefined && isnullTableHeaderTdSpanStyleJsonObject != null ) { $("#" + id + "-isnull-table-header-td-span").css(isnullTableHeaderTdSpanStyleJsonObject); } var defaultValueTableHeaderTdSpanStyleJsonObject = setTableHeaderTdSpanStyleJsonObjectFunction(null, null, "defaultValue"); if( defaultValueTableHeaderTdSpanStyleJsonObject != undefined && defaultValueTableHeaderTdSpanStyleJsonObject != null ) { $("#" + id + "-default-value-table-header-td-span").css(defaultValueTableHeaderTdSpanStyleJsonObject); } var operationTableHeaderTdSpanStyleJsonObject = setTableHeaderTdSpanStyleJsonObjectFunction(null, null, "operation"); if( operationTableHeaderTdSpanStyleJsonObject != undefined && operationTableHeaderTdSpanStyleJsonObject != null ) { $("#" + id + "-operation-table-header-td-span").css(operationTableHeaderTdSpanStyleJsonObject); } } else { $("#" + id + "-name-table-header-td-span").css({ "font-family": "Arial,PMingLiU,sans-serif", "font-style": "normal", "font-size": "12px" }); $("#" + id + "-label-message-key-table-header-td-span").css({ "font-family": "Arial,PMingLiU,sans-serif", "font-style": "normal", "font-size": "12px" }); $("#" + id + "-type-table-header-td-span").css({ "font-family": "Arial,PMingLiU,sans-serif", "font-style": "normal", "font-size": "12px" }); $("#" + id + "-option-table-header-td-span").css({ "font-family": "Arial,PMingLiU,sans-serif", "font-style": "normal", "font-size": "12px" }); $("#" + id + "-range-table-header-td-span").css({ "font-family": "Arial,PMingLiU,sans-serif", "font-style": "normal", "font-size": "12px" }); $("#" + id + "-isnull-table-header-td-span").css({ "font-family": "Arial,PMingLiU,sans-serif", "font-style": "normal", "font-size": "12px" }); $("#" + id + "-default-value-table-header-td-span").css({ "font-family": "Arial,PMingLiU,sans-serif", "font-style": "normal", "font-size": "12px" }); $("#" + id + "-operation-table-header-td-span").css({ "font-family": "Arial,PMingLiU,sans-serif", "font-style": "normal", "font-size": "12px" }); } var setTableContentTdStyleJsonObjectFunction = data.setTableContentTdStyleJsonObjectFunction; if( setTableContentTdStyleJsonObjectFunction != undefined && setTableContentTdStyleJsonObjectFunction != null ) { var index = 0; var nameTableContentTdStyleJsonObject = setTableContentTdStyleJsonObjectFunction(index, null, null, "name"); if( nameTableContentTdStyleJsonObject != undefined && nameTableContentTdStyleJsonObject != null ) { $("#" + id + "-name-table-content-td-" + index).css(nameTableContentTdStyleJsonObject); } var labelMessageKeyTableContentTdStyleJsonObject = setTableContentTdStyleJsonObjectFunction(index, null, null, "labelMessageKey"); if( labelMessageKeyTableContentTdStyleJsonObject != undefined && labelMessageKeyTableContentTdStyleJsonObject != null ) { $("#" + id + "-label-message-key-table-content-td-" + index).css(labelMessageKeyTableContentTdStyleJsonObject); } var typeTableContentTdStyleJsonObject = setTableContentTdStyleJsonObjectFunction(index, null, null, "type"); if( typeTableContentTdStyleJsonObject != undefined && typeTableContentTdStyleJsonObject != null ) { $("#" + id + "-type-table-content-td-" + index).css(typeTableContentTdStyleJsonObject); } var optionTableContentTdStyleJsonObject = setTableContentTdStyleJsonObjectFunction(index, null, null, "option"); if( optionTableContentTdStyleJsonObject != undefined && optionTableContentTdStyleJsonObject != null ) { $("#" + id + "-option-table-content-td-" + index).css(optionTableContentTdStyleJsonObject); } var rangeTableContentTdStyleJsonObject = setTableContentTdStyleJsonObjectFunction(index, null, null, "range"); if( rangeTableContentTdStyleJsonObject != undefined && rangeTableContentTdStyleJsonObject != null ) { $("#" + id + "-range-table-content-td-" + index).css(rangeTableContentTdStyleJsonObject); } var isnullTableContentTdStyleJsonObject = setTableContentTdStyleJsonObjectFunction(index, null, null, "isnull"); if( isnullTableContentTdStyleJsonObject != undefined && isnullTableContentTdStyleJsonObject != null ) { $("#" + id + "-isnull-table-content-td-" + index).css(isnullTableContentTdStyleJsonObject); } var defaultValueTableContentTdStyleJsonObject = setTableContentTdStyleJsonObjectFunction(index, null, null, "defaultValue"); if( defaultValueTableContentTdStyleJsonObject != undefined && defaultValueTableContentTdStyleJsonObject != null ) { $("#" + id + "-default-value-table-content-td-" + index).css(defaultValueTableContentTdStyleJsonObject); } var clearOperationTableContentTdStyleJsonObject = setTableContentTdStyleJsonObjectFunction(index, null, null, "clear-operation"); if( clearOperationTableContentTdStyleJsonObject != undefined && clearOperationTableContentTdStyleJsonObject != null ) { $("#" + id + "-clear-operation-table-content-td-" + index).css(clearOperationTableContentTdStyleJsonObject); } var addOperationTableContentTdStyleJsonObject = setTableContentTdStyleJsonObjectFunction(index, null, null, "add-operation"); if( addOperationTableContentTdStyleJsonObject != undefined && addOperationTableContentTdStyleJsonObject != null ) { $("#" + id + "-add-operation-table-content-td-" + index).css(addOperationTableContentTdStyleJsonObject); } } else { $("#" + id + "-name-table-content-td-0").css({ "border": "1px solid #aaaaaa" }); $("#" + id + "-label-message-key-table-content-td-0").css({ "border": "1px solid #aaaaaa" }); $("#" + id + "-type-table-content-td-0").css({ "border": "1px solid #aaaaaa" }); $("#" + id + "-option-table-content-td-0").css({ "border": "1px solid #aaaaaa" }); $("#" + id + "-range-table-content-td-0").css({ "border": "1px solid #aaaaaa" }); $("#" + id + "-isnull-table-content-td-0").css({ "border": "1px solid #aaaaaa" }); $("#" + id + "-default-value-table-content-td-0").css({ "border": "1px solid #aaaaaa" }); $("#" + id + "-clear-operation-table-content-td-0").css({ "border": "1px solid #aaaaaa" }); $("#" + id + "-add-operation-table-content-td-0").css({ "border": "1px solid #aaaaaa" }); } var setTableContentTdInputStyleJsonObjectFunction = data.setTableContentTdInputStyleJsonObjectFunction; if( setTableContentTdInputStyleJsonObjectFunction != undefined && setTableContentTdInputStyleJsonObjectFunction != null ) { var index = 0; var nameTableContentTdInputStyleJsonObject = setTableContentTdInputStyleJsonObjectFunction(index, null, null, "name"); if( nameTableContentTdInputStyleJsonObject != undefined && nameTableContentTdInputStyleJsonObject != null ) { $("#" + id + "-name-input-text-" + index).css(nameTableContentTdInputStyleJsonObject); } var labelMessageKeyTableContentTdInputStyleJsonObject = setTableContentTdInputStyleJsonObjectFunction(index, null, null, "labelMessageKey"); if( labelMessageKeyTableContentTdInputStyleJsonObject != undefined && labelMessageKeyTableContentTdInputStyleJsonObject != null ) { $("#" + id + "-label-message-key-input-text-" + index).css(labelMessageKeyTableContentTdInputStyleJsonObject); } var typeTableContentTdInputStyleJsonObject = setTableContentTdInputStyleJsonObjectFunction(index, null, null, "type"); if( typeTableContentTdInputStyleJsonObject != undefined && typeTableContentTdInputStyleJsonObject != null ) { $("#" + id + "-type-select-div-" + index).css(typeTableContentTdInputStyleJsonObject); } var optionTableContentTdInputStyleJsonObject = setTableContentTdInputStyleJsonObjectFunction(index, null, null, "option"); if( optionTableContentTdInputStyleJsonObject != undefined && optionTableContentTdInputStyleJsonObject != null ) { $("#" + id + "-option-div-" + index).css(optionTableContentTdInputStyleJsonObject); } var rangeTableContentTdInputStyleJsonObject = setTableContentTdInputStyleJsonObjectFunction(index, null, null, "range"); if( rangeTableContentTdInputStyleJsonObject != undefined && rangeTableContentTdInputStyleJsonObject != null ) { $("#" + id + "-range-div-" + index).css(rangeTableContentTdInputStyleJsonObject); } var isnullTableContentTdInputStyleJsonObject = setTableContentTdInputStyleJsonObjectFunction(index, null, null, "isnull"); if( isnullTableContentTdInputStyleJsonObject != undefined && isnullTableContentTdInputStyleJsonObject != null ) { $("#" + id + "-isnull-input-checkbox-" + index).css(isnullTableContentTdInputStyleJsonObject); } var defaultValueTableContentTdInputStyleJsonObject = setTableContentTdInputStyleJsonObjectFunction(index, null, null, "defaultValue"); if( defaultValueTableContentTdInputStyleJsonObject != undefined && defaultValueTableContentTdInputStyleJsonObject != null ) { $("#" + id + "-default-value-input-text-" + index).css(defaultValueTableContentTdInputStyleJsonObject); } } else { var index = 0; setDefaultTableContentTdInputStyleSubFunction("user-defined-form", id, index); } var typeSelectId = id + "-type-select-0"; var typeSelectHtml = renderTypeSelectHtmlSubFunction(data, typeSelectId); $("#" + id + "-type-select-div-0").html(typeSelectHtml); typeSelectEventSubFunction(data, 0, typeSelectId); var rangeHtml = renderRangeHtmlSubFunction(data, 0); $("#" + id + "-range-div-0").html(rangeHtml); rangeEventSubFunction(data, 0); $("#" + id + "-option-div-0").fadeOut(); $("#" + id + "-range-div-0").fadeOut(); $("#" + id + "-default-value-input-text-0").fadeIn(); var setTableContentTdButtonStyleJsonObjectFunction = data.setTableContentTdButtonStyleJsonObjectFunction; if( setTableContentTdButtonStyleJsonObjectFunction != undefined && setTableContentTdButtonStyleJsonObjectFunction != null ) { var index = 0; var tableContentTdAddButtonStyleJsonObject = setTableContentTdButtonStyleJsonObjectFunction(index, null, null, "add-button"); if( tableContentTdAddButtonStyleJsonObject != undefined && tableContentTdAddButtonStyleJsonObject != null ) { $("#" + id + "-add-button-" + index).css(tableContentTdAddButtonStyleJsonObject); } } else { $("#" + id + "-add-button-0").css({ "height": "26px", "font-size": "12px" }); } var buttonWidgetType = data.buttonWidgetType; if( buttonWidgetType != undefined && buttonWidgetType != null ) { var index = 0; if( buttonWidgetType == "jquery-button" ) { var setJqueryButtonStyleJsonObjectFunction = data.setJqueryButtonStyleJsonObjectFunction; if( setJqueryButtonStyleJsonObjectFunction != undefined && setJqueryButtonStyleJsonObjectFunction != null ) { var jqueryButtonStyleJsonObject = setJqueryButtonStyleJsonObjectFunction(index, "add-button"); $("#" + id + "-add-button-" + index).button(jqueryButtonStyleJsonObject); } else { $("#" + id + "-add-button-" + index).button(); } } } $("#" + id + "-add-button-0").click(function(event) { event.preventDefault(); var templatePathJsonObject = data.templatePath; if( templatePathJsonObject != undefined && templatePathJsonObject != null ) { var formAddFieldTemplatePath = templatePathJsonObject["formAddField"]; if( formAddFieldTemplatePath != undefined && formAddFieldTemplatePath != null ) { var index = $("#" + id + "-field-count").val(); $.ajax({ url: formAddFieldTemplatePath, data: { "id": id, "index": index }, type: "post", async: false, dataType: "html", success: function(dataV) { var html = removeSpaceFunction(dataV); $("#" + id + "-table").append(html); var index = $("#" + id + "-field-count").val(); $("#" + id + "-field-count").val(parseInt(index) + 1); var messageJsonObject = data.message; if( messageJsonObject != undefined && messageJsonObject != null ) { var clearButtonMessage = messageJsonObject["clearButton"]; if( clearButtonMessage != undefined && clearButtonMessage != null ) { $("#" + id + "-clear-button-" + index).html(clearButtonMessage); } var removeButtonMessage = messageJsonObject["removeButton"]; if( removeButtonMessage != undefined && removeButtonMessage != null ) { $("#" + id + "-remove-button-" + index).html(removeButtonMessage); } } else { $("#" + id + "-clear-button-" + index).html("clear"); $("#" + id + "-remove-button-" + index).html("remove"); } var setTableContentTdStyleJsonObjectFunction = data.setTableContentTdStyleJsonObjectFunction; if( setTableContentTdStyleJsonObjectFunction != undefined && setTableContentTdStyleJsonObjectFunction != null ) { var nameTableContentTdStyleJsonObject = setTableContentTdStyleJsonObjectFunction(index, null, null, "name"); if( nameTableContentTdStyleJsonObject != undefined && nameTableContentTdStyleJsonObject != null ) { $("#" + id + "-name-table-content-td-" + index).css(nameTableContentTdStyleJsonObject); } var labelMessageKeyTableContentTdStyleJsonObject = setTableContentTdStyleJsonObjectFunction(index, null, null, "labelMessageKey"); if( labelMessageKeyTableContentTdStyleJsonObject != undefined && labelMessageKeyTableContentTdStyleJsonObject != null ) { $("#" + id + "-label-message-key-table-content-td-" + index).css(labelMessageKeyTableContentTdStyleJsonObject); } var typeTableContentTdStyleJsonObject = setTableContentTdStyleJsonObjectFunction(index, null, null, "type"); if( typeTableContentTdStyleJsonObject != undefined && typeTableContentTdStyleJsonObject != null ) { $("#" + id + "-type-table-content-td-" + index).css(typeTableContentTdStyleJsonObject); } var optionTableContentTdStyleJsonObject = setTableContentTdStyleJsonObjectFunction(index, null, null, "option"); if( optionTableContentTdStyleJsonObject != undefined && optionTableContentTdStyleJsonObject != null ) { $("#" + id + "-option-table-content-td-" + index).css(optionTableContentTdStyleJsonObject); } var rangeTableContentTdStyleJsonObject = setTableContentTdStyleJsonObjectFunction(index, null, null, "range"); if( rangeTableContentTdStyleJsonObject != undefined && rangeTableContentTdStyleJsonObject != null ) { $("#" + id + "-range-table-content-td-" + index).css(rangeTableContentTdStyleJsonObject); } var isnullTableContentTdStyleJsonObject = setTableContentTdStyleJsonObjectFunction(index, null, null, "isnull"); if( isnullTableContentTdStyleJsonObject != undefined && isnullTableContentTdStyleJsonObject != null ) { $("#" + id + "-isnull-table-content-td-" + index).css(isnullTableContentTdStyleJsonObject); } var defaultValueTableContentTdStyleJsonObject = setTableContentTdStyleJsonObjectFunction(index, null, null, "defaultValue"); if( defaultValueTableContentTdStyleJsonObject != undefined && defaultValueTableContentTdStyleJsonObject != null ) { $("#" + id + "-default-value-table-content-td-" + index).css(defaultValueTableContentTdStyleJsonObject); } var operationTableContentTdStyleJsonObject = setTableContentTdStyleJsonObjectFunction(index, null, null, "operation"); if( operationTableContentTdStyleJsonObject != undefined && operationTableContentTdStyleJsonObject != null ) { $("#" + id + "-operation-table-content-td-" + index).css(operationTableContentTdStyleJsonObject); } } else { $("#" + id + "-name-table-content-td-" + index).css({ "border": "1px solid #aaaaaa" }); $("#" + id + "-label-message-key-table-content-td-" + index).css({ "border": "1px solid #aaaaaa" }); $("#" + id + "-type-table-content-td-" + index).css({ "border": "1px solid #aaaaaa" }); $("#" + id + "-option-table-content-td-" + index).css({ "border": "1px solid #aaaaaa" }); $("#" + id + "-range-table-content-td-" + index).css({ "border": "1px solid #aaaaaa" }); $("#" + id + "-isnull-table-content-td-" + index).css({ "border": "1px solid #aaaaaa" }); $("#" + id + "-default-value-table-content-td-" + index).css({ "border": "1px solid #aaaaaa" }); $("#" + id + "-clear-operation-table-content-td-" + index).css({ "border": "1px solid #aaaaaa" }); $("#" + id + "-remove-operation-table-content-td-" + index).css({ "border": "1px solid #aaaaaa" }); } var setTableContentTdInputStyleJsonObjectFunction = data.setTableContentTdInputStyleJsonObjectFunction; if( setTableContentTdInputStyleJsonObjectFunction != undefined && setTableContentTdInputStyleJsonObjectFunction != null ) { var nameTableContentTdInputStyleJsonObject = setTableContentTdInputStyleJsonObjectFunction(index, null, null, "name"); if( nameTableContentTdInputStyleJsonObject != undefined && nameTableContentTdInputStyleJsonObject != null ) { $("#" + id + "-name-input-text-" + index).css(nameTableContentTdInputStyleJsonObject); } var labelMessageKeyTableContentTdInputStyleJsonObject = setTableContentTdInputStyleJsonObjectFunction(index, null, null, "labelMessageKey"); if( labelMessageKeyTableContentTdInputStyleJsonObject != undefined && labelMessageKeyTableContentTdInputStyleJsonObject != null ) { $("#" + id + "-label-message-key-input-text-" + index).css(labelMessageKeyTableContentTdInputStyleJsonObject); } var typeTableContentTdInputStyleJsonObject = setTableContentTdInputStyleJsonObjectFunction(index, null, null, "type"); if( typeTableContentTdInputStyleJsonObject != undefined && typeTableContentTdInputStyleJsonObject != null ) { $("#" + id + "-type-select-div-" + index).css(typeTableContentTdInputStyleJsonObject); } var optionTableContentTdInputStyleJsonObject = setTableContentTdInputStyleJsonObjectFunction(index, null, null, "option"); if( optionTableContentTdInputStyleJsonObject != undefined && optionTableContentTdInputStyleJsonObject != null ) { $("#" + id + "-option-div-" + index).css(optionTableContentTdInputStyleJsonObject); } var rangeTableContentTdInputStyleJsonObject = setTableContentTdInputStyleJsonObjectFunction(index, null, null, "range"); if( rangeTableContentTdInputStyleJsonObject != undefined && rangeTableContentTdInputStyleJsonObject != null ) { $("#" + id + "-range-div-" + index).css(rangeTableContentTdInputStyleJsonObject); } var isnullTableContentTdInputStyleJsonObject = setTableContentTdInputStyleJsonObjectFunction(index, null, null, "isnull"); if( isnullTableContentTdInputStyleJsonObject != undefined && isnullTableContentTdInputStyleJsonObject != null ) { $("#" + id + "-isnull-input-checkbox-" + index).css(isnullTableContentTdInputStyleJsonObject); } var defaultValueTableContentTdInputStyleJsonObject = setTableContentTdInputStyleJsonObjectFunction(index, null, null, "defaultValue"); if( defaultValueTableContentTdInputStyleJsonObject != undefined && defaultValueTableContentTdInputStyleJsonObject != null ) { $("#" + id + "-default-value-input-text-" + index).css(defaultValueTableContentTdInputStyleJsonObject); } } else { setDefaultTableContentTdInputStyleSubFunction("user-defined-form", id, index); } var typeSelectId = id + "-type-select-" + index; var typeSelectHtml = renderTypeSelectHtmlSubFunction(data, typeSelectId); $("#" + id + "-type-select-div-" + index).html(typeSelectHtml); typeSelectEventSubFunction(data, index, typeSelectId); var setTableContentTdButtonStyleJsonObjectFunction = data.setTableContentTdButtonStyleJsonObjectFunction; if( setTableContentTdButtonStyleJsonObjectFunction != undefined && setTableContentTdButtonStyleJsonObjectFunction != null ) { var tableContentTdAddButtonStyleJsonObject = setTableContentTdButtonStyleJsonObjectFunction(index, null, null, "clear-button"); if( tableContentTdAddButtonStyleJsonObject != undefined && tableContentTdAddButtonStyleJsonObject != null ) { $("#" + id + "-clear-button-" + index).css(tableContentTdAddButtonStyleJsonObject); } } else { $("#" + id + "-clear-button-" + index).css({ "height": "26px", "font-size": "12px" }); } var buttonWidgetType = data.buttonWidgetType; if( buttonWidgetType != undefined && buttonWidgetType != null ) { if( buttonWidgetType == "jquery-button" ) { var setJqueryButtonStyleJsonObjectFunction = data.setJqueryButtonStyleJsonObjectFunction; if( setJqueryButtonStyleJsonObjectFunction != undefined && setJqueryButtonStyleJsonObjectFunction != null ) { var jqueryButtonStyleJsonObject = setJqueryButtonStyleJsonObjectFunction(index, null, null, "clear-button"); $("#" + id + "-clear-button-" + index).button(jqueryButtonStyleJsonObject); } else { $("#" + id + "-clear-button-" + index).button(); } } } $("#" + id + "-clear-button-" + index).click(function(event) { event.preventDefault(); $("#" + id + "-name-input-text-" + index).val(""); $("#" + id + "-label-message-key-input-text-" + index).val(""); $("#" + id + "-isnull-input-checkbox-" + index).prop("checked", true); $("#" + id + "-default-value-input-text-" + index).val(""); return false; }); if( setTableContentTdButtonStyleJsonObjectFunction != undefined && setTableContentTdButtonStyleJsonObjectFunction != null ) { var tableContentTdAddButtonStyleJsonObject = setTableContentTdButtonStyleJsonObjectFunction(index, null, null, "remove-button"); if( tableContentTdAddButtonStyleJsonObject != undefined && tableContentTdAddButtonStyleJsonObject != null ) { $("#" + id + "-remove-button-" + index).css(tableContentTdAddButtonStyleJsonObject); } } else { $("#" + id + "-remove-button-" + index).css({ "height": "26px", "font-size": "12px" }); } if( buttonWidgetType != undefined && buttonWidgetType != null ) { if( buttonWidgetType == "jquery-button" ) { var setJqueryButtonStyleJsonObjectFunction = data.setJqueryButtonStyleJsonObjectFunction; if( setJqueryButtonStyleJsonObjectFunction != undefined && setJqueryButtonStyleJsonObjectFunction != null ) { var jqueryButtonStyleJsonObject = setJqueryButtonStyleJsonObjectFunction(index, null, null, "remove-button"); $("#" + id + "-remove-button-" + index).button(jqueryButtonStyleJsonObject); } else { $("#" + id + "-remove-button-" + index).button(); } } } $("#" + id + "-remove-button-" + index).click(function(event) { event.preventDefault(); $("#" + id + "-clear-button-" + index).unbind("click"); $("#" + id + "-remove-button-" + index).unbind("click"); $("#" + id + "-table-content-tr-" + index).remove(); return false; }); } }); } } return false; }); var setTableContentTdButtonStyleJsonObjectFunction = data.setTableContentTdButtonStyleJsonObjectFunction; if( setTableContentTdButtonStyleJsonObjectFunction != undefined && setTableContentTdButtonStyleJsonObjectFunction != null ) { var index = 0; var tableContentTdAddButtonStyleJsonObject = setTableContentTdButtonStyleJsonObjectFunction(index, null, null, "clear-button"); if( tableContentTdAddButtonStyleJsonObject != undefined && tableContentTdAddButtonStyleJsonObject != null ) { $("#" + id + "-clear-button-" + index).css(tableContentTdAddButtonStyleJsonObject); } } else { $("#" + id + "-clear-button-0").css({ "height": "26px", "font-size": "12px" }); } if( buttonWidgetType != undefined && buttonWidgetType != null ) { var index = 0; if( buttonWidgetType == "jquery-button" ) { var setJqueryButtonStyleJsonObjectFunction = data.setJqueryButtonStyleJsonObjectFunction; if( setJqueryButtonStyleJsonObjectFunction != undefined && setJqueryButtonStyleJsonObjectFunction != null ) { var jqueryButtonStyleJsonObject = setJqueryButtonStyleJsonObjectFunction(index, null, null, "clear-button"); $("#" + id + "-clear-button-" + index).button(jqueryButtonStyleJsonObject); } else { $("#" + id + "-clear-button-" + index).button(); } } } $("#" + id + "-clear-button-0").click(function(event) { event.preventDefault(); var index = $("#" + id + "-field-count").val(); $("#" + id + "-name-input-text-" + index).val(""); $("#" + id + "-label-message-key-input-text-" + index).val(""); $("#" + id + "-isnull-input-checkbox-" + index).prop("checked", true); $("#" + id + "-default-value-input-text-" + index).val(""); return false; }); }; setDefaultTableContentTdInputStyleSubFunction = function(category, id, index) { if( category == "user-defined-form" ) { $("#" + id + "-name-input-text-" + index).css({ "width": "120px", "font-family": "Arial,PMingLiU,sans-serif", "font-style": "normal", "font-size": "12px" }); $("#" + id + "-label-message-key-input-text-" + index).css({ "width": "120px", "font-family": "Arial,PMingLiU,sans-serif", "font-style": "normal", "font-size": "12px" }); $("#" + id + "-type-select-div-" + index).css({ }); $("#" + id + "-option-div-" + index).css({ }); $("#" + id + "-range-div-" + index).css({ }); $("#" + id + "-isnull-input-checkbox-" + index).css({ }); $("#" + id + "-default-value-input-text-" + index).css({ "width": "100px", "font-family": "Arial,PMingLiU,sans-serif", "font-style": "normal", "font-size": "12px" }); } else if( category == "user-defined-option" ) { $("#" + id + "-label-message-key-input-text-" + index).css({ "width": "120px", "font-family": "Arial,PMingLiU,sans-serif", "font-style": "normal", "font-size": "12px" }); $("#" + id + "-value-input-text-" + index).css({ "width": "120px", "font-family": "Arial,PMingLiU,sans-serif", "font-style": "normal", "font-size": "12px" }); } }; renderTypeSelectHtmlSubFunction = function(data, selectId) { var messageJsonObject = data.message; var html = ''; return html; }; renderRangeHtmlSubFunction = function(data, index) { var templatePathJsonObject = data.templatePath; if( templatePathJsonObject != undefined && templatePathJsonObject != null ) { var formRangeTemplatePath = templatePathJsonObject["formRange"]; var id = data.id; var widgetId = id + "-range-" + index; var messageJsonObject = data.message; var upperLimitMessage = "upper limit"; if( messageJsonObject != undefined && messageJsonObject != null ) { upperLimitMessage = messageJsonObject["upperLimitRange"]; } var lowerLimitLimitMessage = "lower limit"; if( messageJsonObject != undefined && messageJsonObject != null ) { lowerLimitLimitMessage = messageJsonObject["lowerLimitRange"]; } var dataJsonArray = [ { "inputType": "string", "name": "upperLimit", "label": upperLimitMessage, "row": "0", "rowSpan": "1", "colSpan": "1" }, { "inputType": "string", "name": "lowerLimit", "label": lowerLimitLimitMessage, "row": "1", "rowSpan": "1", "colSpan": "1" } ]; var html = null; $.ajax({ url: formRangeTemplatePath, data: { "id": widgetId, "dataJsonArray": JSON.stringify(dataJsonArray) }, type: "post", async: false, dataType: "html", success: function(data) { html = removeSpaceFunction(data); } }); return html; } }; rangeEventSubFunction = function(data, index) { var id = data.id; var widgetId = id + "-range-" + index; var messageJsonObject = data.message; var upperLimitMessage = "upper limit"; if( messageJsonObject != undefined && messageJsonObject != null ) { upperLimitMessage = messageJsonObject["upperLimitRange"]; } var lowerLimitLimitMessage = "lower limit"; if( messageJsonObject != undefined && messageJsonObject != null ) { lowerLimitLimitMessage = messageJsonObject["lowerLimitRange"]; } var dataJsonArray = [ { "inputType": "string", "name": "upperLimit", "label": upperLimitMessage, "row": "0", "rowSpan": "1", "colSpan": "1" }, { "inputType": "string", "name": "lowerLimit", "label": lowerLimitLimitMessage, "row": "1", "rowSpan": "1", "colSpan": "1" } ]; formTemplateInjectV({ "id": widgetId, "dataJsonArray": dataJsonArray, "setLabelTdStyleJsonObjectFunction": function(jsonObject) { var setLabelTdStyleJsonObjectFunction = data.setLabelTdStyleJsonObjectFunction; if( setLabelTdStyleJsonObjectFunction != undefined && setLabelTdStyleJsonObjectFunction != null ) { return setLabelTdStyleJsonObjectFunction(index, "range", null, jsonObject); } else { var name = jsonObject["name"]; var styleJsonObject = { "border": "1px solid #aaaaaa" }; return styleJsonObject; } }, "setLabelTdSpanStyleJsonObjectFunction": function(jsonObject) { var setLabelTdSpanStyleJsonObjectFunction = data.setLabelTdStyleJsonObjectFunction; if( setLabelTdSpanStyleJsonObjectFunction != undefined && setLabelTdSpanStyleJsonObjectFunction != null ) { return setLabelTdSpanStyleJsonObjectFunction(index, "range", null, jsonObject); } else { var name = jsonObject["name"]; var styleJsonObject = null; if( name == "upperLimit" ) { styleJsonObject = { "color": "#000000", "font-family": "Arial,PMingLiU,sans-serif", "font-style": "normal", "font-size": "12px" }; } else if( name == "lowerLimit" ) { styleJsonObject = { "color": "#000000", "font-family": "Arial,PMingLiU,sans-serif", "font-style": "normal", "font-size": "12px" }; } return styleJsonObject; } }, "setModelTdStyleJsonObjectFunction": function(jsonObject) { var setModelTdStyleJsonObjectFunction = data.setModelTdStyleJsonObjectFunction; if( setModelTdStyleJsonObjectFunction != undefined && setModelTdStyleJsonObjectFunction != null ) { return setModelTdStyleJsonObjectFunction(index, "range", null, jsonObject); } else { var name = jsonObject["name"]; var styleJsonObject = { "border": "1px solid #aaaaaa" }; return styleJsonObject; } }, "setInputStyleJsonObjectFunction": function(jsonObject) { var setInputStyleJsonObjectFunction = data.setInputStyleJsonObjectFunction; if( setInputStyleJsonObjectFunction != undefined && setInputStyleJsonObjectFunction != null ) { return setInputStyleJsonObjectFunction(index, "range", null, jsonObject); } else { var name = jsonObject["name"]; var styleJsonObject = null; if( name == "upperLimit" ) { styleJsonObject = { "width": "90px", "font-family": "Arial,PMingLiU,sans-serif", "font-style": "normal", "font-size": "12px" }; } else if( name == "lowerLimit" ) { styleJsonObject = { "width": "90px", "font-family": "Arial,PMingLiU,sans-serif", "font-style": "normal", "font-size": "12px" }; } return styleJsonObject; } }, }); }; typeSelectEventSubFunction = function(data, index, selectId) { var setTableContentTdInputStyleJsonObjectFunction = data.setTableContentTdInputStyleJsonObjectFunction; if( setTableContentTdInputStyleJsonObjectFunction != undefined && setTableContentTdInputStyleJsonObjectFunction != null ) { var typeSelectTableContentTdInputStyleJsonObject = setTableContentTdInputStyleJsonObjectFunction(index, "type", null, "select"); if( typeSelectTableContentTdInputStyleJsonObject != undefined && typeSelectTableContentTdInputStyleJsonObject != null ) { $("#" + selectId).css(typeSelectTableContentTdInputStyleJsonObject); } } else { $("#" + selectId).css({ "font-family": "Arial,PMingLiU,sans-serif", "font-style": "normal", "font-size": "12px" }); } $("#" + selectId).change(function(event) { var value = $(this).val(); var id = data.id; var messageJsonObject = data.message; if( value == "string" ) { $("#" + id + "-option-div-" + index).fadeOut(); $("#" + id + "-range-div-" + index).fadeOut(); $("#" + id + "-default-value-input-text-" + index).fadeIn(); } else if( value == "select" ) { var optionServletSourceHtml = renderOptionServletSourceHtmlSubFunction(data, index); var optionUserDefineSourceHtml = renderOptionUserDefineSourceHtmlSubFunction(data, index); var servletMessage = "[Servlet]"; var userDefineMessage = "user define"; if( messageJsonObject != undefined && messageJsonObject != null ) { userDefineMessage = messageJsonObject["userDefineSelectOption"]; } var tabArray = [ { "name": "servlet", "label": servletMessage }, { "name": "userDefine", "label": userDefineMessage }]; var tabId = id + "-option-tab-div-" + index; $.each(tabArray, function(index, tabJsonObject) { tabJsonObject["tabItemDivId"] = id + "-option-tab-item-div-" + index; }); var html = ""; var renderTabFunction = data.renderTabFunction; if( renderTabFunction != undefined && renderTabFunction != null ) { html = renderTabFunction(index, "option", "select", tabArray, tabId); } else { html += '
'; html += ''; html += ''; html += ''; html += ''; html += ''; html += ''; html += ''; html += '
'; $.each(tabArray, function(index, tabJsonObject) { var label = tabJsonObject["label"]; html +=' '; }); html += '
'; $.each(tabArray, function(index, tabJsonObject) { var tabItemDivId = tabJsonObject["tabItemDivId"]; html += '
'; }); html += '
'; html += '
'; } $("#" + id + "-option-div-" + index).html(html); $.each(tabArray, function(index, tabJsonObject) { var tabItemDivId = tabJsonObject["tabItemDivId"]; if( index == 0 ) { $("#" + tabItemDivId).html(optionServletSourceHtml); } else if( index == 1 ) { $("#" + tabItemDivId).html(optionUserDefineSourceHtml); } }); var tabEventFunction = data.tabEventFunction; if( tabEventFunction != undefined && tabEventFunction != null ) { tabEventFunction(index, "option", "select", tabArray, tabId); } else { $.each(tabArray, function(indexV, tabJsonObject) { var tabItemDivId = tabJsonObject["tabItemDivId"]; $("#" + tabItemDivId).css({ "width": "100%" }); $("#" + tabItemDivId).css({ "background-color": "#cee3f6" }); if( indexV == 0 ) { $("#" + tabId + "-tab-button-" + indexV).css({ "height": "26px", "border-style": "solid", "border": "1px solid #aaaaaa", "background-color": "#cee3f6", "color": "#2e9afe", "font-weight": "bold", "font-size": "12px" }); $("#" + tabItemDivId).css({"display": "block"}); } else { $("#" + tabId + "-tab-button-" + indexV).css({ "height": "26px", "border-style": "solid", "border": "1px solid #aaaaaa", "background-color": "#ffffff", "color": "#aaaaaa", "font-weight": "normal", "font-size": "12px" }); $("#" + tabItemDivId).css({"display": "none"}); } $("#" + tabId + "-tab-button-" + indexV).prop("clicked", false); $("#" + tabId + "-tab-button-" + indexV).unbind("click"); $("#" + tabId + "-tab-button-" + indexV).click(function(event) { event.preventDefault(); var clicked = $(this).prop("clicked"); if( !clicked ) { $.each(tabArray, function(indexV2, tabJsonObjectV2) { var tabItemDivId2 = tabJsonObjectV2["tabItemDivId"]; $("#" + tabId + "-tab-button-" + indexV2).css({ "color": "#aaaaaa", "background-color": "#ffffff", "font-weight": "normal" }); $("#" + tabId + "-tab-button-" + indexV2).prop("clicked", false); $("#" + tabItemDivId2).css({"display": "none"}); }); $("#" + tabId + "-tab-button-" + indexV).css({ "color": "#2e9afe", "background-color": "#cee3f6", "font-weight": "bold" }); $("#" + tabId + "-tab-button-" + indexV).prop("clicked", true); $("#" + tabItemDivId).fadeIn(); } return false; }); }); } optionSelectEventSubFunction(data, index); $("#" + id + "-option-div-" + index).fadeIn(); $("#" + id + "-range-div-" + index).fadeOut(); $("#" + id + "-default-value-input-text-" + index).fadeIn(); } else if( value == "jqx-combobox" ) { $("#" + id + "-option-div-" + index).fadeIn(); $("#" + id + "-range-div-" + index).fadeOut(); $("#" + id + "-default-value-input-text-" + index).fadeIn(); } else if( value == "selection-button" ) { $("#" + id + "-option-div-" + index).fadeIn(); $("#" + id + "-range-div-" + index).fadeOut(); $("#" + id + "-default-value-input-text-" + index).fadeIn(); } else if( value == "integer" ) { $("#" + id + "-option-div-" + index).fadeOut(); $("#" + id + "-range-div-" + index).fadeIn(); $("#" + id + "-default-value-input-text-" + index).fadeIn(); } else if( value == "positive-integer" ) { $("#" + id + "-option-div-" + index).fadeOut(); $("#" + id + "-range-div-" + index).fadeIn(); $("#" + id + "-default-value-input-text-" + index).fadeIn(); } else if( value == "currency" ) { $("#" + id + "-option-div-" + index).fadeOut(); $("#" + id + "-range-div-" + index).fadeIn(); $("#" + id + "-default-value-input-text-" + index).fadeIn(); } else if( value == "date" ) { $("#" + id + "-option-div-" + index).fadeOut(); $("#" + id + "-range-div-" + index).fadeIn(); $("#" + id + "-default-value-input-text-" + index).fadeIn(); } else if( value == "time" ) { $("#" + id + "-option-div-" + index).fadeOut(); $("#" + id + "-range-div-" + index).fadeIn(); $("#" + id + "-default-value-input-text-" + index).fadeIn(); } else if( value == "date-time" ) { $("#" + id + "-option-div-" + index).fadeOut(); $("#" + id + "-range-div-" + index).fadeIn(); $("#" + id + "-default-value-input-text-" + index).fadeIn(); } else if( value == "color" ) { $("#" + id + "-option-div-" + index).fadeOut(); $("#" + id + "-range-div-" + index).fadeOut(); $("#" + id + "-default-value-input-text-" + index).fadeIn(); } else if( value == "upload" ) { $("#" + id + "-option-div-" + index).fadeIn(); $("#" + id + "-range-div-" + index).fadeIn(); $("#" + id + "-default-value-input-text-" + index).fadeOut(); } else if( value == "string-tab" ) { $("#" + id + "-option-div-" + index).fadeIn(); $("#" + id + "-range-div-" + index).fadeOut(); $("#" + id + "-default-value-input-text-" + index).fadeIn(); } }); }; renderOptionServletSourceHtmlSubFunction = function(data, index) { var templatePathJsonObject = data.templatePath; if( templatePathJsonObject != undefined && templatePathJsonObject != null ) { var formOptionServletTemplatePath = templatePathJsonObject["formOptionServlet"]; var id = data.id; var widgetId = id + "-option-servlet-" + index; var messageJsonObject = data.message; var urlMessage = "url"; if( messageJsonObject != undefined && messageJsonObject != null ) { urlMessage = messageJsonObject["urlSelectOptionServlet"]; } var categoryMessage = "[category]"; var authorizationMessage = "authorization"; if( messageJsonObject != undefined && messageJsonObject != null ) { authorizationMessage = messageJsonObject["authorizationSelectOptionServlet"]; } var labelAttributeMessage = "label attribute"; if( messageJsonObject != undefined && messageJsonObject != null ) { labelAttributeMessage = messageJsonObject["labelAttributeSelectOptionServlet"]; } var valueAttributeMessage = "value attribute"; if( messageJsonObject != undefined && messageJsonObject != null ) { valueAttributeMessage = messageJsonObject["valueAttributeSelectOptionServlet"]; } var noMessage = "no"; if( messageJsonObject != undefined && messageJsonObject != null ) { noMessage = messageJsonObject["noSelectOptionServletAuthorization"]; } var yesMessage = "yes"; if( messageJsonObject != undefined && messageJsonObject != null ) { noMessage = messageJsonObject["yesSelectOptionServletAuthorization"]; } var authorizationSelectModelArray = [ { "label": noMessage, "value": "N" }, { "label": yesMessage, "value": "Y" }, ]; var dataJsonArray = [ { "inputType": "string", "name": "url", "label": urlMessage, "row": "0", "rowSpan": "1", "colSpan": "3" }, { "inputType": "string", "name": "category", "label": categoryMessage, "row": "1", "rowSpan": "1", "colSpan": "1" }, { "inputType": "select", "name": "authorization", "label": authorizationMessage, "row": "1", "rowSpan": "1", "colSpan": "1", "selectModelArray": authorizationSelectModelArray }, { "inputType": "string", "name": "labelAttribute", "label": labelAttributeMessage, "row": "2", "rowSpan": "1", "colSpan": "1" }, { "inputType": "string", "name": "valueAttribute", "label": valueAttributeMessage, "row": "2", "rowSpan": "1", "colSpan": "1" }, ]; var html = null; $.ajax({ url: formOptionServletTemplatePath, data: { "id": widgetId, "dataJsonArray": JSON.stringify(dataJsonArray) }, type: "post", async: false, dataType: "html", success: function(data) { html = removeSpaceFunction(data); } }); return html; } }; renderOptionUserDefineSourceHtmlSubFunction = function(data, index) { var templatePathJsonObject = data.templatePath; if( templatePathJsonObject != undefined && templatePathJsonObject != null ) { var formOptionUserDefinedFormTemplatePath = templatePathJsonObject["formOptionUserDefinedForm"]; var id = data.id; var widgetId = id + "-option-user-define-" + index; var html = ''; $.ajax({ url: formOptionUserDefinedFormTemplatePath, data: { "id": widgetId }, type: "post", async: false, dataType: "html", success: function(data) { html = removeSpaceFunction(data); } }); return html; } }; optionSelectEventSubFunction = function(data, index) { var id = data.id; // OptionServlet var optionServletWidgetId = id + "-option-servlet-" + index; var messageJsonObject = data.message; var urlMessage = "url"; if( messageJsonObject != undefined && messageJsonObject != null ) { urlMessage = messageJsonObject["urlSelectOptionServlet"]; } var categoryMessage = "[category]"; var authorizationMessage = "authorization"; if( messageJsonObject != undefined && messageJsonObject != null ) { authorizationMessage = messageJsonObject["authorizationSelectOptionServlet"]; } var labelAttributeMessage = "label attribute"; if( messageJsonObject != undefined && messageJsonObject != null ) { labelAttributeMessage = messageJsonObject["labelAttributeSelectOptionServlet"]; } var valueAttributeMessage = "value attribute"; if( messageJsonObject != undefined && messageJsonObject != null ) { valueAttributeMessage = messageJsonObject["valueAttributeSelectOptionServlet"]; } var noMessage = "no"; if( messageJsonObject != undefined && messageJsonObject != null ) { noMessage = messageJsonObject["noSelectOptionServletAuthorization"]; } var yesMessage = "yes"; if( messageJsonObject != undefined && messageJsonObject != null ) { yesMessage = messageJsonObject["yesSelectOptionServletAuthorization"]; } var authorizationSelectModelArray = [ { "label": noMessage, "value": "N" }, { "label": yesMessage, "value": "Y" }, ]; var dataJsonArray = [ { "inputType": "string", "name": "url", "label": urlMessage, "row": "0", "rowSpan": "1", "colSpan": "3" }, { "inputType": "string", "name": "category", "label": categoryMessage, "row": "1", "rowSpan": "1", "colSpan": "1" }, { "inputType": "select", "name": "authorization", "label": authorizationMessage, "row": "1", "rowSpan": "1", "colSpan": "1" }, { "inputType": "string", "name": "labelAttribute", "label": labelAttributeMessage, "row": "2", "rowSpan": "1", "colSpan": "1" }, { "inputType": "string", "name": "valueAttribute", "label": valueAttributeMessage, "row": "2", "rowSpan": "1", "colSpan": "1" }, ]; formTemplateInjectV({ "id": optionServletWidgetId, "dataJsonArray": dataJsonArray, "selectTemplateInjectVDataFunction": function(jsonObject) { var data = { "renderFunction": function(id, selectId, jsonObject) { var name = jsonObject["name"]; var html = ''; if( name == "authorization" ) { var html = ''; } return html; }, "eventFunction": function(id, selectId, jsonObject) { var injectVDataJsonObject = data.selectTemplateInjectVDataFunction; if( injectVDataJsonObject != undefined && injectVDataJsonObject != null ) { var eventFunction = injectVDataJsonObject.eventFunction; if( eventFunction != undefined && eventFunction != null ) { eventFunction(id, selectId, jsonObject); } else { $("#" + selectId).css({ }); } } }, }; return data; }, "setLabelTdStyleJsonObjectFunction": function(jsonObject) { var setLabelTdStyleJsonObjectFunction = data.setLabelTdStyleJsonObjectFunction; if( setLabelTdStyleJsonObjectFunction != undefined && setLabelTdStyleJsonObjectFunction != null ) { return setLabelTdStyleJsonObjectFunction(index, "option", "select", jsonObject); } else { var name = jsonObject["name"]; var styleJsonObject = { "border": "1px solid #aaaaaa" }; return styleJsonObject; } }, "setLabelTdSpanStyleJsonObjectFunction": function(jsonObject) { var setLabelTdSpanStyleJsonObjectFunction = data.setLabelTdStyleJsonObjectFunction; if( setLabelTdSpanStyleJsonObjectFunction != undefined && setLabelTdSpanStyleJsonObjectFunction != null ) { return setLabelTdSpanStyleJsonObjectFunction(index, "option", "select", jsonObject); } else { var name = jsonObject["name"]; var styleJsonObject = null; if( name == "url" ) { styleJsonObject = { "color": "#0000ff", "font-family": "Arial,PMingLiU,sans-serif", "font-style": "normal", "font-size": "12px" }; } else if( name == "category" ) { styleJsonObject = { "color": "#0000ff", "font-family": "Arial,PMingLiU,sans-serif", "font-style": "normal", "font-size": "12px" }; } else if( name == "authorization" ) { styleJsonObject = { "color": "#0000ff", "font-family": "Arial,PMingLiU,sans-serif", "font-style": "normal", "font-size": "12px" }; } else if( name == "labelAttribute" ) { styleJsonObject = { "color": "#0000ff", "font-family": "Arial,PMingLiU,sans-serif", "font-style": "normal", "font-size": "12px" }; } else if( name == "valueAttribute" ) { styleJsonObject = { "color": "#0000ff", "font-family": "Arial,PMingLiU,sans-serif", "font-style": "normal", "font-size": "12px" }; } return styleJsonObject; } }, "setModelTdStyleJsonObjectFunction": function(jsonObject) { var setModelTdStyleJsonObjectFunction = data.setModelTdStyleJsonObjectFunction; if( setModelTdStyleJsonObjectFunction != undefined && setModelTdStyleJsonObjectFunction != null ) { return setModelTdStyleJsonObjectFunction(index, "option", "select", jsonObject); } else { var name = jsonObject["name"]; var styleJsonObject = { "border": "1px solid #aaaaaa" }; return styleJsonObject; } }, "setInputStyleJsonObjectFunction": function(jsonObject) { var setInputStyleJsonObjectFunction = data.setInputStyleJsonObjectFunction; if( setInputStyleJsonObjectFunction != undefined && setInputStyleJsonObjectFunction != null ) { return setInputStyleJsonObjectFunction(index, "option", "select", jsonObject); } else { var name = jsonObject["name"]; var styleJsonObject = null; if( name == "url" ) { styleJsonObject = { "width": "285px", "font-family": "Arial,PMingLiU,sans-serif", "font-style": "normal", "font-size": "12px" }; } else if( name == "category" ) { styleJsonObject = { "width": "120px", "font-family": "Arial,PMingLiU,sans-serif", "font-style": "normal", "font-size": "12px" }; } else if( name == "authorization" ) { } else if( name == "labelAttribute" ) { styleJsonObject = { "width": "120px", "font-family": "Arial,PMingLiU,sans-serif", "font-style": "normal", "font-size": "12px" }; } else if( name == "valueAttribute" ) { styleJsonObject = { "width": "120px", "font-family": "Arial,PMingLiU,sans-serif", "font-style": "normal", "font-size": "12px" }; } return styleJsonObject; } }, }); // OptionUserDefine var optionUserDefineWidgetId = id + "-option-user-define-" + index; if( messageJsonObject != undefined && messageJsonObject != null ) { var labelMessageKeyMessage = messageJsonObject["labelMessageKeySelectOptionUserDefine"]; if( labelMessageKeyMessage != undefined && labelMessageKeyMessage != null ) { $("#" + optionUserDefineWidgetId + "-label-message-key-table-header-td-span").html(labelMessageKeyMessage); } var valueMessageKeyMessage = messageJsonObject["valueSelectOptionUserDefine"]; if( valueMessageKeyMessage != undefined && valueMessageKeyMessage != null ) { $("#" + optionUserDefineWidgetId + "-value-table-header-td-span").html(valueMessageKeyMessage); } var clearButtonMessage = messageJsonObject["clearButtonOptionUserDefine"]; if( clearButtonMessage != undefined && clearButtonMessage != null ) { $("#" + optionUserDefineWidgetId + "-clear-button-0").html(clearButtonMessage); } var addButtonMessage = messageJsonObject["addButtonOptionUserDefine"]; if( addButtonMessage != undefined && addButtonMessage != null ) { $("#" + optionUserDefineWidgetId + "-add-button-0").html(addButtonMessage); } } else { $("#" + optionUserDefineWidgetId + "-label-message-key-table-header-td-span").html("label message key"); $("#" + optionUserDefineWidgetId + "-value-table-header-td-span").html("value"); $("#" + optionUserDefineWidgetId + "-clear-button-0").html("clear"); $("#" + optionUserDefineWidgetId + "-add-button-0").html("add"); } var setTableHeaderTdStyleJsonObjectFunction = data.setTableHeaderTdStyleJsonObjectFunction; if( setTableHeaderTdStyleJsonObjectFunction != undefined && setTableHeaderTdStyleJsonObjectFunction != null ) { var labelMessageKeyTableHeaderTdStyleJsonObject = setTableHeaderTdStyleJsonObjectFunction("option", "select", "labelMessageKey"); if( labelMessageKeyTableHeaderTdStyleJsonObject != undefined && labelMessageKeyTableHeaderTdStyleJsonObject != null ) { $("#" + optionUserDefineWidgetId + "-label-message-key-table-header-td").css(labelMessageKeyTableHeaderTdStyleJsonObject); } var valueTableHeaderTdStyleJsonObject = setTableHeaderTdStyleJsonObjectFunction("option", "select", "value"); if( valueTableHeaderTdStyleJsonObject != undefined && valueTableHeaderTdStyleJsonObject != null ) { $("#" + optionUserDefineWidgetId + "-value-table-header-td").css(valueTableHeaderTdStyleJsonObject); } var operationTableHeaderTdStyleJsonObject = setTableHeaderTdStyleJsonObjectFunction("option", "select", "operation"); if( operationTableHeaderTdStyleJsonObject != undefined && operationTableHeaderTdStyleJsonObject != null ) { $("#" + optionUserDefineWidgetId + "-operation-table-header-td").css(operationTableHeaderTdStyleJsonObject); } } else { $("#" + optionUserDefineWidgetId + "-label-message-key-table-header-td").css({ "border": "1px solid #aaaaaa" }); $("#" + optionUserDefineWidgetId + "-value-table-header-td").css({ "border": "1px solid #aaaaaa" }); $("#" + optionUserDefineWidgetId + "-operation-table-header-td").css({ "border": "1px solid #aaaaaa" }); } var setTableHeaderTdSpanStyleJsonObjectFunction = data.setTableHeaderTdSpanStyleJsonObjectFunction; if( setTableHeaderTdSpanStyleJsonObjectFunction != undefined && setTableHeaderTdSpanStyleJsonObjectFunction != null ) { var labelMessageKeyTableHeaderTdSpanStyleJsonObject = setTableHeaderTdSpanStyleJsonObjectFunction("option", "select", "labelMessageKey"); if( labelMessageKeyTableHeaderTdSpanStyleJsonObject != undefined && labelMessageKeyTableHeaderTdSpanStyleJsonObject != null ) { $("#" + optionUserDefineWidgetId + "-label-message-key-table-header-td-span").css(labelMessageKeyTableHeaderTdSpanStyleJsonObject); } var valueTableHeaderTdSpanStyleJsonObject = setTableHeaderTdSpanStyleJsonObjectFunction("option", "select", "type"); if( valueTableHeaderTdSpanStyleJsonObject != undefined && valueTableHeaderTdSpanStyleJsonObject != null ) { $("#" + optionUserDefineWidgetId + "-value-table-header-td-span").css(valueTableHeaderTdSpanStyleJsonObject); } var operationTableHeaderTdSpanStyleJsonObject = setTableHeaderTdSpanStyleJsonObjectFunction("option", "select", "operation"); if( operationTableHeaderTdSpanStyleJsonObject != undefined && operationTableHeaderTdSpanStyleJsonObject != null ) { $("#" + optionUserDefineWidgetId + "-operation-table-header-td-span").css(operationTableHeaderTdSpanStyleJsonObject); } } else { $("#" + optionUserDefineWidgetId + "-label-message-key-table-header-td-span").css({ "font-family": "Arial,PMingLiU,sans-serif", "font-style": "normal", "font-size": "12px" }); $("#" + optionUserDefineWidgetId + "-value-table-header-td-span").css({ "font-family": "Arial,PMingLiU,sans-serif", "font-style": "normal", "font-size": "12px" }); $("#" + optionUserDefineWidgetId + "-operation-table-header-td-span").css({ "font-family": "Arial,PMingLiU,sans-serif", "font-style": "normal", "font-size": "12px" }); } var setTableContentTdStyleJsonObjectFunction = data.setTableContentTdStyleJsonObjectFunction; if( setTableContentTdStyleJsonObjectFunction != undefined && setTableContentTdStyleJsonObjectFunction != null ) { var index = 0; var labelMessageKeyTableContentTdStyleJsonObject = setTableContentTdStyleJsonObjectFunction(index, "option", "select", "labelMessageKey"); if( labelMessageKeyTableContentTdStyleJsonObject != undefined && labelMessageKeyTableContentTdStyleJsonObject != null ) { $("#" + optionUserDefineWidgetId + "-label-message-key-table-content-td-" + index).css(labelMessageKeyTableContentTdStyleJsonObject); } var valueTableContentTdStyleJsonObject = setTableContentTdStyleJsonObjectFunction(index, "option", "select", "value"); if( valueTableContentTdStyleJsonObject != undefined && valueTableContentTdStyleJsonObject != null ) { $("#" + optionUserDefineWidgetId + "-value-table-content-td-" + index).css(valueTableContentTdStyleJsonObject); } var clearOperationTableContentTdStyleJsonObject = setTableContentTdStyleJsonObjectFunction(index, "option", "select", "clear-operation"); if( clearOperationTableContentTdStyleJsonObject != undefined && clearOperationTableContentTdStyleJsonObject != null ) { $("#" + optionUserDefineWidgetId + "-clear-operation-table-content-td-" + index).css(clearOperationTableContentTdStyleJsonObject); } var addOperationTableContentTdStyleJsonObject = setTableContentTdStyleJsonObjectFunction(index, "option", "select", "add-operation"); if( addOperationTableContentTdStyleJsonObject != undefined && addOperationTableContentTdStyleJsonObject != null ) { $("#" + optionUserDefineWidgetId + "-add-operation-table-content-td-" + index).css(addOperationTableContentTdStyleJsonObject); } } else { $("#" + optionUserDefineWidgetId + "-label-message-key-table-content-td-0").css({ "border": "1px solid #aaaaaa" }); $("#" + optionUserDefineWidgetId + "-value-table-content-td-0").css({ "border": "1px solid #aaaaaa" }); $("#" + optionUserDefineWidgetId + "-clear-operation-table-content-td-0").css({ "border": "1px solid #aaaaaa" }); $("#" + optionUserDefineWidgetId + "-add-operation-table-content-td-0").css({ "border": "1px solid #aaaaaa" }); } var setTableContentTdInputStyleJsonObjectFunction = data.setTableContentTdInputStyleJsonObjectFunction; if( setTableContentTdInputStyleJsonObjectFunction != undefined && setTableContentTdInputStyleJsonObjectFunction != null ) { var index = 0; var labelMessageKeyTableContentTdInputStyleJsonObject = setTableContentTdInputStyleJsonObjectFunction(index, "option", "select", "labelMessageKey"); if( labelMessageKeyTableContentTdInputStyleJsonObject != undefined && labelMessageKeyTableContentTdInputStyleJsonObject != null ) { $("#" + optionUserDefineWidgetId + "-label-message-key-input-text-" + index).css(labelMessageKeyTableContentTdInputStyleJsonObject); } var valueTableContentTdInputStyleJsonObject = setTableContentTdInputStyleJsonObjectFunction(index, "option", "select", "type"); if( valueTableContentTdInputStyleJsonObject != undefined && valueTableContentTdInputStyleJsonObject != null ) { $("#" + optionUserDefineWidgetId + "-type-select-div-" + index).css(valueTableContentTdInputStyleJsonObject); } } else { var index = 0; setDefaultTableContentTdInputStyleSubFunction("user-defined-option", optionUserDefineWidgetId, index); } var setTableContentTdButtonStyleJsonObjectFunction = data.setTableContentTdButtonStyleJsonObjectFunction; if( setTableContentTdButtonStyleJsonObjectFunction != undefined && setTableContentTdButtonStyleJsonObjectFunction != null ) { var index = 0; var tableContentTdAddButtonStyleJsonObject = setTableContentTdButtonStyleJsonObjectFunction(index, "option", "select", "add-button"); if( tableContentTdAddButtonStyleJsonObject != undefined && tableContentTdAddButtonStyleJsonObject != null ) { $("#" + optionUserDefineWidgetId + "-add-button-" + index).css(tableContentTdAddButtonStyleJsonObject); } } else { $("#" + optionUserDefineWidgetId + "-add-button-0").css({ "height": "26px", "font-size": "12px" }); } var buttonWidgetType = data.buttonWidgetType; if( buttonWidgetType != undefined && buttonWidgetType != null ) { var index = 0; if( buttonWidgetType == "jquery-button" ) { var setJqueryButtonStyleJsonObjectFunction = data.setJqueryButtonStyleJsonObjectFunction; if( setJqueryButtonStyleJsonObjectFunction != undefined && setJqueryButtonStyleJsonObjectFunction != null ) { var jqueryButtonStyleJsonObject = setJqueryButtonStyleJsonObjectFunction(index, "option", "select", "add-button"); $("#" + optionUserDefineWidgetId + "-add-button-" + index).button(jqueryButtonStyleJsonObject); } else { $("#" + optionUserDefineWidgetId + "-add-button-" + index).button(); } } } $("#" + optionUserDefineWidgetId + "-add-button-0").click(function(event) { event.preventDefault(); var templatePathJsonObject = data.templatePath; if( templatePathJsonObject != undefined && templatePathJsonObject != null ) { var formOptionUserDefinedFormAddOptionTemplatePath = templatePathJsonObject["formOptionUserDefinedFormAddOption"]; if( formOptionUserDefinedFormAddOptionTemplatePath != undefined && formOptionUserDefinedFormAddOptionTemplatePath != null ) { var index = $("#" + optionUserDefineWidgetId + "-field-count").val(); $.ajax({ url: formOptionUserDefinedFormAddOptionTemplatePath, data: { "id": optionUserDefineWidgetId, "index": index }, type: "post", async: false, dataType: "html", success: function(dataV) { var html = removeSpaceFunction(dataV); $("#" + optionUserDefineWidgetId + "-table").append(html); var index = $("#" + optionUserDefineWidgetId + "-field-count").val(); $("#" + optionUserDefineWidgetId + "-field-count").val(parseInt(index) + 1); var messageJsonObject = data.message; if( messageJsonObject != undefined && messageJsonObject != null ) { var clearButtonMessage = messageJsonObject["clearButton"]; if( clearButtonMessage != undefined && clearButtonMessage != null ) { $("#" + optionUserDefineWidgetId + "-clear-button-" + index).html(clearButtonMessage); } var removeButtonMessage = messageJsonObject["removeButton"]; if( removeButtonMessage != undefined && removeButtonMessage != null ) { $("#" + optionUserDefineWidgetId + "-remove-button-" + index).html(removeButtonMessage); } } else { $("#" + optionUserDefineWidgetId + "-clear-button-" + index).html("clear"); $("#" + optionUserDefineWidgetId + "-remove-button-" + index).html("remove"); } var setTableContentTdStyleJsonObjectFunction = data.setTableContentTdStyleJsonObjectFunction; if( setTableContentTdStyleJsonObjectFunction != undefined && setTableContentTdStyleJsonObjectFunction != null ) { var labelMessageKeyTableContentTdStyleJsonObject = setTableContentTdStyleJsonObjectFunction(index, "option", "select", "labelMessageKey"); if( labelMessageKeyTableContentTdStyleJsonObject != undefined && labelMessageKeyTableContentTdStyleJsonObject != null ) { $("#" + optionUserDefineWidgetId + "-label-message-key-table-content-td-" + index).css(labelMessageKeyTableContentTdStyleJsonObject); } var valueTableContentTdStyleJsonObject = setTableContentTdStyleJsonObjectFunction(index, "option", "select", "value"); if( valueTableContentTdStyleJsonObject != undefined && valueTableContentTdStyleJsonObject != null ) { $("#" + optionUserDefineWidgetId + "-value-table-content-td-" + index).css(valueTableContentTdStyleJsonObject); } var operationTableContentTdStyleJsonObject = setTableContentTdStyleJsonObjectFunction(index, "option", "select", "operation"); if( operationTableContentTdStyleJsonObject != undefined && operationTableContentTdStyleJsonObject != null ) { $("#" + optionUserDefineWidgetId + "-operation-table-content-td-" + index).css(operationTableContentTdStyleJsonObject); } } else { $("#" + optionUserDefineWidgetId + "-label-message-key-table-content-td-" + index).css({ "border": "1px solid #aaaaaa" }); $("#" + optionUserDefineWidgetId + "-value-table-content-td-" + index).css({ "border": "1px solid #aaaaaa" }); $("#" + optionUserDefineWidgetId + "-clear-operation-table-content-td-" + index).css({ "border": "1px solid #aaaaaa" }); $("#" + optionUserDefineWidgetId + "-remove-operation-table-content-td-" + index).css({ "border": "1px solid #aaaaaa" }); } var setTableContentTdInputStyleJsonObjectFunction = data.setTableContentTdInputStyleJsonObjectFunction; if( setTableContentTdInputStyleJsonObjectFunction != undefined && setTableContentTdInputStyleJsonObjectFunction != null ) { var labelMessageKeyTableContentTdInputStyleJsonObject = setTableContentTdInputStyleJsonObjectFunction(index, "option", "select", "labelMessageKey"); if( labelMessageKeyTableContentTdInputStyleJsonObject != undefined && labelMessageKeyTableContentTdInputStyleJsonObject != null ) { $("#" + optionUserDefineWidgetId + "-label-message-key-input-text-" + index).css(labelMessageKeyTableContentTdInputStyleJsonObject); } var valueTableContentTdInputStyleJsonObject = setTableContentTdInputStyleJsonObjectFunction(index, "option", "select", "type"); if( valueTableContentTdInputStyleJsonObject != undefined && valueTableContentTdInputStyleJsonObject != null ) { $("#" + optionUserDefineWidgetId + "-type-select-div-" + index).css(valueTableContentTdInputStyleJsonObject); } } else { setDefaultTableContentTdInputStyleSubFunction("user-defined-option", optionUserDefineWidgetId, index); } var setTableContentTdButtonStyleJsonObjectFunction = data.setTableContentTdButtonStyleJsonObjectFunction; if( setTableContentTdButtonStyleJsonObjectFunction != undefined && setTableContentTdButtonStyleJsonObjectFunction != null ) { var tableContentTdAddButtonStyleJsonObject = setTableContentTdButtonStyleJsonObjectFunction(index, "option", "select", "clear-button"); if( tableContentTdAddButtonStyleJsonObject != undefined && tableContentTdAddButtonStyleJsonObject != null ) { $("#" + optionUserDefineWidgetId + "-clear-button-" + index).css(tableContentTdAddButtonStyleJsonObject); } } else { $("#" + optionUserDefineWidgetId + "-clear-button-" + index).css({ "height": "26px", "font-size": "12px" }); } var buttonWidgetType = data.buttonWidgetType; if( buttonWidgetType != undefined && buttonWidgetType != null ) { if( buttonWidgetType == "jquery-button" ) { var setJqueryButtonStyleJsonObjectFunction = data.setJqueryButtonStyleJsonObjectFunction; if( setJqueryButtonStyleJsonObjectFunction != undefined && setJqueryButtonStyleJsonObjectFunction != null ) { var jqueryButtonStyleJsonObject = setJqueryButtonStyleJsonObjectFunction(index, "option", "select", "clear-button"); $("#" + optionUserDefineWidgetId + "-clear-button-" + index).button(jqueryButtonStyleJsonObject); } else { $("#" + optionUserDefineWidgetId + "-clear-button-" + index).button(); } } } $("#" + optionUserDefineWidgetId + "-clear-button-" + index).click(function(event) { event.preventDefault(); $("#" + optionUserDefineWidgetId + "-label-message-key-input-text-" + index).val(""); $("#" + optionUserDefineWidgetId + "-value-input-text-" + index).val(""); return false; }); if( setTableContentTdButtonStyleJsonObjectFunction != undefined && setTableContentTdButtonStyleJsonObjectFunction != null ) { var tableContentTdAddButtonStyleJsonObject = setTableContentTdButtonStyleJsonObjectFunction(index, "option", "select", "remove-button"); if( tableContentTdAddButtonStyleJsonObject != undefined && tableContentTdAddButtonStyleJsonObject != null ) { $("#" + optionUserDefineWidgetId + "-remove-button-" + index).css(tableContentTdAddButtonStyleJsonObject); } } else { $("#" + optionUserDefineWidgetId + "-remove-button-" + index).css({ "height": "26px", "font-size": "12px" }); } if( buttonWidgetType != undefined && buttonWidgetType != null ) { if( buttonWidgetType == "jquery-button" ) { var setJqueryButtonStyleJsonObjectFunction = data.setJqueryButtonStyleJsonObjectFunction; if( setJqueryButtonStyleJsonObjectFunction != undefined && setJqueryButtonStyleJsonObjectFunction != null ) { var jqueryButtonStyleJsonObject = setJqueryButtonStyleJsonObjectFunction(index, "option", "select", "remove-button"); $("#" + optionUserDefineWidgetId + "-remove-button-" + index).button(jqueryButtonStyleJsonObject); } else { $("#" + optionUserDefineWidgetId + "-remove-button-" + index).button(); } } } $("#" + optionUserDefineWidgetId + "-remove-button-" + index).click(function(event) { event.preventDefault(); $("#" + optionUserDefineWidgetId + "-clear-button-" + index).unbind("click"); $("#" + optionUserDefineWidgetId + "-remove-button-" + index).unbind("click"); $("#" + optionUserDefineWidgetId + "-table-content-tr-" + index).remove(); return false; }); } }); } } return false; }); if( setTableContentTdButtonStyleJsonObjectFunction != undefined && setTableContentTdButtonStyleJsonObjectFunction != null ) { var index = 0; var tableContentTdAddButtonStyleJsonObject = setTableContentTdButtonStyleJsonObjectFunction(index, "option", "select", "clear-button"); if( tableContentTdAddButtonStyleJsonObject != undefined && tableContentTdAddButtonStyleJsonObject != null ) { $("#" + optionUserDefineWidgetId + "-clear-button-" + index).css(tableContentTdAddButtonStyleJsonObject); } } else { $("#" + optionUserDefineWidgetId + "-clear-button-0").css({ "height": "26px", "font-size": "12px" }); } if( buttonWidgetType != undefined && buttonWidgetType != null ) { var index = 0; if( buttonWidgetType == "jquery-button" ) { var setJqueryButtonStyleJsonObjectFunction = data.setJqueryButtonStyleJsonObjectFunction; if( setJqueryButtonStyleJsonObjectFunction != undefined && setJqueryButtonStyleJsonObjectFunction != null ) { var jqueryButtonStyleJsonObject = setJqueryButtonStyleJsonObjectFunction(index, "option", "select", "clear-button"); $("#" + optionUserDefineWidgetId + "-clear-button-" + index).button(jqueryButtonStyleJsonObject); } else { $("#" + optionUserDefineWidgetId + "-clear-button-" + index).button(); } } } $("#" + optionUserDefineWidgetId + "-clear-button-0").click(function(event) { event.preventDefault(); var index = $("#" + optionUserDefineWidgetId + "-field-count").val(); $("#" + optionUserDefineWidgetId + "-label-message-key-input-text-" + index).val(""); $("#" + optionUserDefineWidgetId + "-value-input-text-" + index).val(""); return false; }); }; getUserDefinedFormSetupDataJsonArray = function(id) { var count = parseInt($("#" + id + "-field-count").val()); var dataJsonArray = []; for( var i = 0; i < count; i++ ) { var nameV = $("#" + id + "-name-input-text-" + i).val(); var labelMessageKeyV = $("#" + id + "-label-message-key-input-text-" + i).val(); var typeV = $("#" + id + "-type-select-" + i).val(); var optionJsonObjectV = null; var rangeJsonObjectV = null; var isnullV = $("#" + id + "-isnull-input-checkbox-" + i).prop("checked"); var defaultValueV = $("#" + id + "-default-value-input-text-" + i).val(); if( i == 0 ) { if( nameV != "" || labelMessageKeyV != "" || typeV != "" || optionJsonObjectV != null || rangeJsonObjectV != null || isnullV != "" || defaultValueV != "" ) { var dataJsonObject = { "name": nameV, "labelMessageKey": labelMessageKeyV, "type": typeV, "optionJsonObject": optionJsonObjectV, "rangeJsonObject": rangeJsonObjectV, "isnull": isnullV, "defaultValue": defaultValueV }; dataJsonArray.push(dataJsonObject); } } else { if( nameV != undefined ) { var dataJsonObject = { "name": nameV, "labelMessageKey": labelMessageKeyV, "type": typeV, "optionJsonObject": optionJsonObjectV, "rangeJsonObject": rangeJsonObjectV, "isnull": isnullV, "defaultValue": defaultValueV }; dataJsonArray.push(dataJsonObject); } } } return dataJsonArray; }; notificationWindowOpen = function(data) { var id = data.id; var width = data.width; var height = data.height; var title = data.title; var message = data.message; var confirmButtonMessage = data.confirmButtonMessage; var confirmActionEventFunction = data.confirmActionEventFunction; if( $("#" + id).hasClass("ui-dialog-content") ) { $("#" + id).dialog("destroy"); } $("#" + id).dialog(); $("#" + id).dialog("destroy"); $("#" + id).attr("title", title); $("#" + id).dialog({ my: "center", at: "center", width: width, height: height, autoOpen: false, resizable: false, modal: true, buttons: [{ text: confirmButtonMessage, click: function () { $(this).dialog("close"); if( confirmActionEventFunction != undefined && confirmActionEventFunction != null ) { confirmActionEventFunction(); } } }] }); $("#" + id + "-message-span").html(message); $("#" + id).dialog("open"); }; notificationWindowClosed = function(data) { var id = data.id; $("#" + id).dialog("close"); }; confirmationWindowOpen = function(data) { var id = data.id; var width = data.width; var height = data.height; var title = data.title; var message = data.message; var confirmButtonMessage = data.confirmButtonMessage; var cancelButtonMessage = data.cancelButtonMessage; var confirmActionEventFunction = data.confirmActionEventFunction; if( $("#" + id).hasClass("ui-dialog-content") ) { $("#" + id).dialog("destroy"); } $("#" + id).dialog(); $("#" + id).dialog("destroy"); $("#" + id).attr("title", title); $("#" + id).dialog({ my: "center", at: "center", width: width, height: height, autoOpen: false, resizable: false, modal: true, buttons: [{ text: confirmButtonMessage, "id": id + "-confirm-button", click: function () { $(this).dialog("close"); confirmActionEventFunction(); } }, { text: cancelButtonMessage, click: function () { $(this).dialog("close"); } }] }); $("#" + id + "-message-span").html(message); $("#" + id).dialog("open"); }; confirmationWindowClosed = function(data) { var id = data.id; $("#" + id).dialog("close"); }; formJqxWindowOpen = function(data) { var id = data.id; var width = data.width; var height = data.height; var title = data.title; var confirmButtonMessage = data.confirmButtonMessage; var resetButtonMessage = data.resetButtonMessage; var cancelButtonMessage = data.cancelButtonMessage; $("#" + id + "-header-span").html(title); var buttonArray = []; if( confirmButtonMessage != undefined && confirmButtonMessage != null ) { var button = { text: confirmButtonMessage, "id": id + "-confirm-button", click: function () { var confirmActionEventFunction = data.confirmActionEventFunction; if( confirmActionEventFunction != undefined && confirmActionEventFunction != null ) { var formDataJsonArray = getFormDataJsonArray(data); confirmActionEventFunction(formDataJsonArray); } } }; buttonArray.push(button); } if( resetButtonMessage != undefined && resetButtonMessage != null ) { var button = { text: resetButtonMessage, click: function () { resetFormDataFunction(data); } }; buttonArray.push(button); } if( cancelButtonMessage != undefined && cancelButtonMessage != null ) { var button = { text: cancelButtonMessage, click: function () { var cancelActionEventFunction = data.cancelActionEventFunction; if( cancelActionEventFunction != undefined && cancelActionEventFunction != null ) { cancelActionEventFunction(); } } }; buttonArray.push(button); } var newWidth = (parseInt(width) + 500); // alert("width: " + newWidth); $("#" + id).jqxWindow({ theme: 'ui-redmond', showCollapseButton: true, maxHeight: 1000, maxWidth: 1000, minHeight: 200, minWidth: 200, width: newWidth, height: height, initContent: function () { $("#" + id).jqxWindow('focus'); } }); $("#" + id).jqxWindow('open'); }; formJqxWindowClosed = function(data) { var id = data.id; $("#" + id).jqxWindow('close'); }; formWindowOpen = function(data) { var id = data.id; var width = data.width; var height = data.height; var title = data.title; var setWidgetValueFunction = data.setWidgetValueFunction; var otherButtonCount = data.otherButtonCount; var otherButtonInjectVDataFunction = data.otherButtonInjectVDataFunction; var confirmButtonInjectVDataFunction = data.confirmButtonInjectVDataFunction; var resetButtonInjectVDataFunction = data.resetButtonInjectVDataFunction; var cancelButtonInjectVDataFunction = data.cancelButtonInjectVDataFunction; var closeActionEventFunction = data.closeActionEventFunction; if( $("#" + id).hasClass("ui-dialog-content") ) { $("#" + id).dialog("destroy"); } $("#" + id).dialog(); $("#" + id).dialog("destroy"); $("#" + id).attr("title", title); if( setWidgetValueFunction != undefined && setWidgetValueFunction != null ) { var dataJsonArray = data.dataJsonArray; if( dataJsonArray != undefined && dataJsonArray != null ) { $.each(dataJsonArray, function(index, jsonObject) { var name = jsonObject["name"]; var widgetId = id + "-form-model-" + name + "-widget"; setWidgetValueFunction(id, widgetId, jsonObject); }); } } var buttonArray = []; if( otherButtonCount != undefined && otherButtonCount != null ) { var otherButtonCountInt = parseInt(otherButtonCount); if( otherButtonInjectVDataFunction != undefined && otherButtonInjectVDataFunction != null ) { var buttonInjectVDataJsonObject = otherButtonInjectVDataFunction(); if( buttonInjectVDataJsonObject != undefined && buttonInjectVDataJsonObject != null ) { var labelFunction = buttonInjectVDataJsonObject.labelFunction; var disabledFunction = buttonInjectVDataJsonObject.disabledFunction; var eventFunction = buttonInjectVDataJsonObject.eventFunction; var formDataJsonArray = getFormDataJsonArray(data); var otherButtonLabelArray = []; for( var index = 0; index < otherButtonCountInt; index++ ) { var buttonId = id + "-other-button-" + index; var buttonLabel = labelFunction(index, formDataJsonArray); otherButtonLabelArray.push(buttonLabel); var buttonDisabled = false; if( disabledFunction != undefined && disabledFunction != null ) { var disabled = disabledFunction(index, formDataJsonArray); if( disabled ) { buttonDisabled = true; } } var button = { "id": buttonId, text: buttonLabel, click: function(event) { if( eventFunction != undefined && eventFunction != null ) { var buttonLabel = $(event.target).html(); var otherButtonLabelArray = $.parseJSON($("#" + id + "-other-button-label-array-input-hidden").val()); $.each(otherButtonLabelArray, function(index, otherButtonLabel) { if( buttonLabel.indexOf(otherButtonLabel) != -1 ) { eventFunction(index, formDataJsonArray); return false; } }); } }, "disabled": buttonDisabled }; buttonArray.push(button); } $("#" + id + "-other-button-label-array-input-hidden").val(JSON.stringify(otherButtonLabelArray)); } } } if( confirmButtonInjectVDataFunction != undefined && confirmButtonInjectVDataFunction != null ) { var confirmButtonInjectVDataJsonObject = confirmButtonInjectVDataFunction(); if( confirmButtonInjectVDataJsonObject != undefined && confirmButtonInjectVDataJsonObject != null ) { var labelFunction = confirmButtonInjectVDataJsonObject.labelFunction; var disabledFunction = confirmButtonInjectVDataJsonObject.disabledFunction; var confirmButtonEventFunction = confirmButtonInjectVDataJsonObject.eventFunction; var buttonId = id + "-confirm-button"; var buttonLabel = labelFunction(); var buttonDisabled = false; if( disabledFunction != undefined && disabledFunction != null ) { var disabled = disabledFunction(); if( disabled ) { buttonDisabled = true; } } var button = { "id": buttonId, text: buttonLabel, click: function(event) { if( confirmButtonEventFunction != undefined && confirmButtonEventFunction != null ) { var formDataJsonArray = getFormDataJsonArray(data); confirmButtonEventFunction(formDataJsonArray); } }, "disabled": buttonDisabled }; buttonArray.push(button); } } if( resetButtonInjectVDataFunction != undefined && resetButtonInjectVDataFunction != null ) { var formDataJsonArray = getFormDataJsonArray(data); var resetButtonInjectVDataJsonObject = resetButtonInjectVDataFunction(formDataJsonArray); if( resetButtonInjectVDataJsonObject != undefined && resetButtonInjectVDataJsonObject != null ) { var labelFunction = resetButtonInjectVDataJsonObject.labelFunction; var disabledFunction = resetButtonInjectVDataJsonObject.disabledFunction; var resetButtonEventFunction = resetButtonInjectVDataJsonObject.eventFunction; var buttonId = id + "-reset-button"; var buttonLabel = labelFunction(); var buttonDisabled = false; if( disabledFunction != undefined && disabledFunction != null ) { var disabled = disabledFunction(); if( disabled ) { buttonDisabled = true; } } var button = { "id": buttonId, text: buttonLabel, click: function(event) { if( resetButtonEventFunction != undefined && resetButtonEventFunction != null ) { resetButtonEventFunction(); } }, "disabled": buttonDisabled }; buttonArray.push(button); } } if( cancelButtonInjectVDataFunction != undefined && cancelButtonInjectVDataFunction != null ) { var formDataJsonArray = getFormDataJsonArray(data); var cancelButtonInjectVDataJsonObject = cancelButtonInjectVDataFunction(formDataJsonArray); if( cancelButtonInjectVDataJsonObject != undefined && cancelButtonInjectVDataJsonObject != null ) { var labelFunction = cancelButtonInjectVDataJsonObject.labelFunction; var disabledFunction = cancelButtonInjectVDataJsonObject.disabledFunction; var cancelButtonEventFunction = cancelButtonInjectVDataJsonObject.eventFunction; var buttonId = id + "-reset-button"; var buttonLabel = labelFunction(); var buttonDisabled = false; if( disabledFunction != undefined && disabledFunction != null ) { var disabled = disabledFunction(); if( disabled ) { buttonDisabled = true; } } var button = { "id": buttonId, text: buttonLabel, click: function(event) { if( cancelButtonEventFunction != undefined && cancelButtonEventFunction != null ) { cancelButtonEventFunction(); } }, "disabled": buttonDisabled }; buttonArray.push(button); } } $("#" + id).dialog({ my: "center", at: "center", width: width, height: height, autoOpen: false, resizable: false, modal: true, buttons: buttonArray, close: function() { if( closeActionEventFunction != undefined && closeActionEventFunction != null ) { closeActionEventFunction(); } } }); $("#" + id).dialog("open"); }; formWindowClosed = function(data) { var id = data.id; $("#" + id).dialog("close"); }; progressWindowOpen = function(data) { var id = data.id; var width = data.width; var height = data.height; var title = data.title; var message = data.message; if( $("#" + id + "-progress-dialog").hasClass("ui-dialog-content") ) { $("#" + id + "-progress-dialog").dialog("destroy"); } $("#" + id + "-progress-dialog").dialog(); $("#" + id + "-progress-dialog").dialog("destroy"); $("#" + id + "-progress-dialog").dialog({ my: "center", at: "center", width: width, height: height, autoOpen: false, resizable: false, modal: true, open: function(event, ui) { //hide close button. $(this).parent().children().children('.ui-dialog-titlebar-close').hide(); } }); $("#" + id + "-progress-dialog").attr("title", title); $("#" + id + "-progress-dialog-message").html(message); $("#" + id + "-progress-dialog").dialog("open"); }; progressWindowClosed = function(data) { var id = data.id; $("#" + id + "-progress-dialog").dialog("close"); }; isMouseRightClickFunction = function(event) { var rightclick; if( !event ) { event = window.event; } if( event.which ) { rightclick = (event.which == 3); } else if( event.button ) { rightclick = (event.button == 2); } return rightclick; }; getWidgetComponentId = function(id, category) { var componentId = null; if( category == "form-window-form-div" ) { componentId = id + "-form-div"; } else if( category == "confirmation-window-message-span" ) { componentId = id + "-message-span"; } else if( category == "notification-window-message-span" ) { componentId = id + "-message-span"; } return componentId; }; disableWidget = function(id, category) { if( category == "form-window-confirm-button" ) { $("#" + id + "-confirm-button").button("disable"); } }; disableWidgetArray = function(id, category, index) { }; enableWidget = function(category, id) { }; enableWidgetArray = function(id, category, index) { if( category == "form-window-other-button" ) { if( index != undefined && index != null ) { $("#" + id + "-other-button-" + index).button("enable"); } } };