Subversion Repositories DevTools

Rev

Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
5048 dpurdie 1
<%@LANGUAGE="VBSCRIPT"%>
2
<%
3
'   sdk_names_edit.asp
4
'   This file is designed to be injected (loaded) into a 'div' on a window
5
'   It is a pop up dialog
6
%>
7
<script>
8
$( "#f1" ).dialog({
9
autoOpen: true,
10
width: 500,
11
modal: true,
12
draggable: true,
13
resizable: true,
14
dialogClass: "rounded_box",
15
        buttons: [
16
            {
17
            text  : 'Save',
18
            class : 'hideOnError',
19
            click : function(){
20
                        clearInfo();
21
                        $( "#f1" ).submit();
22
                        },
23
            },
24
            {
25
            text : 'Cancel',
26
            click : function(){ 
27
                        $( this ).dialog( "close" ); 
28
                        },
29
            },
30
        ],
31
open: function( event, ui ) {
32
        populateSdkForm(this);
33
        },
34
close : function(event, ui ){
35
        // Need to remove DOM elements on close so that
36
        // When it is opened again - the binds occur correctly
37
        $(this).dialog('destroy').remove();
38
        },
39
});
40
 
41
function setInfo(txt) {
42
    $("#info").text( txt).addClass("error");
43
}
44
 
45
function clearInfo(txt) {
46
    $("#info").text("").removeClass("error");
47
}
48
 
49
$.validate({
50
    form: '#f1',
51
    validateOnBlur : false,
52
    onSuccess : function(f) {
53
        processSdkForm(f);
54
    },
55
 
56
});
57
 
58
// Severe Error processing
59
//  Disable all the inputs on a form
60
//  Hide dialog buttons marked to be hidden
61
//  All the user can do is read the erro message and close the form
62
function disableForm()
63
{   
64
    var form = $("#f1");
65
    form.dialog( "widget" ).find(".hideOnError").hide();
66
    form.find(":input").prop("disabled",true);
67
}
68
 
69
function populateSdkForm(f)
70
{
5097 dpurdie 71
    getAjaxData (
72
        "sdk_opr_json.asp",
73
        { action : "getSdkNameData", sdkId : <%=Request("sdkId")%> },
74
        function(data){
5048 dpurdie 75
            $("#sdk_id").val(data.aaData.SDK_ID);
76
            $("#sdk_name").val(data.aaData.SDK_NAME);
77
            $("#sdk_comment").val(data.aaData.SDK_COMMENT);
5097 dpurdie 78
            populateBaseView(data.aaData.VIEW_ID);
79
        });    
5048 dpurdie 80
}
81
 
5097 dpurdie 82
//  Populate the Base Views
83
//      base_id  - Select this entry if possible
84
function populateBaseView(base_id) {
85
    getAjaxData (
86
        "sdk_opr_json.asp",
87
        { action: "getBaseViews" },
88
        function(data){
89
            // Populate selection
90
            var $options = $("#sdk_base_view").empty();
91
            var name
92
            $options.append($("<option disabled/>").val(null).text('Select One'));
93
            $.each(data.aaData, function (index, value) {
94
                $options.append($("<option />").val(value.VIEW_ID).text(value.VIEW_NAME));
95
            });
96
            $options.val(base_id);
97
        });    
98
}
99
 
5048 dpurdie 100
function processSdkForm(f)
101
{
5097 dpurdie 102
    getAjaxData (
103
        f.attr("action"),
104
        f.serializeArray(),
105
        function(data){
106
            $("#sdk_version").trigger('sdkNameEdited');
107
            f.dialog( "close" );
108
        });    
109
}
110
 
111
$( "#f1" ).submit(function(e) {
112
        e.preventDefault(); //STOP default action
113
        return false;
114
        });
115
 
116
//  getAjaxData - with error processing
117
//      url - url to fetch
118
//      data    - additional data to pass to ajax request
119
//      success - function to call on success
120
function getAjaxData( url, data, success )
121
{
5048 dpurdie 122
    clearInfo();
123
    $("#progressBar").css('visibility', 'visible');
124
    $.ajax(
125
    {
5097 dpurdie 126
        url : url,
5048 dpurdie 127
        type: "POST",
5097 dpurdie 128
        data : data,
5048 dpurdie 129
        dataType : "json",
130
        cache: false,
131
        success:function(data, textStatus, jqXHR)
132
        {
133
            //data: return data from server
134
            //console.log ("UpdateData", data);
135
            if (data.result != 0)
136
            {
137
                setInfo("Error:" + ((data.error != 0) ? data.emsgSummary : "Reason not given"));
138
                if (data.error >= 0) disableForm();
139
                return;
140
            }
5097 dpurdie 141
            //  call user success function
142
            if (jQuery.isFunction(success))
143
            {
144
                success(data);
145
            }
5048 dpurdie 146
        },
147
        error: function(jqXHR, textStatus, errorThrown)
148
        {
149
            setInfo("Error:" + errorThrown);
150
            disableForm();
151
            //if fails
152
        },
153
        complete : function()
154
        {
155
            $("#progressBar").css('visibility', 'hidden');
156
        }
157
    });
5097 dpurdie 158
}
5048 dpurdie 159
 
160
//# sourceURL=sdk_names_edit.js
161
</script>
162
<form title="Edit Entry" id=f1 action="sdk_opr_json.asp" class=td>
163
    <div id="info"></div>
164
	<DIV id='progressBar' style='visibility:hidden;'>
165
        <img src='icons/i_processing.gif' width='79' height='14'>
166
    </DIV>
167
 
168
    <p><label for="sdkName">SDK Name:</label>
5053 dpurdie 169
    <br><input id=sdk_name type="text" name="sdkName" maxlength=50 size=40 data-validation="length,alphanumeric" data-validation-length="min4" data-validation-allowing="_. -">
5048 dpurdie 170
 
171
    <p>Comment:
172
    <br><textarea id=sdk_comment name="sdkComment" cols=40  data-validation="length" data-validation-length="5-4000"></textarea>                                              
173
 
5097 dpurdie 174
    <p>Base View:
175
    <br><select id=sdk_base_view name="sdkBaseView" data-validation="required"></select>                                              
176
 
177
    <input type="hidden" name="action" value="updateSdkName">
5048 dpurdie 178
    <input id=sdk_id type="hidden" name="sdkid" value="">
179
</form>