Subversion Repositories DevTools

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
5048 dpurdie 1
<%@LANGUAGE="VBSCRIPT"%>
2
<%
3
'   sdk_names_new.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  : 'Add',
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
        },
33
    close : function(event, ui ){
34
        // Need to remove DOM elements on close so that
35
        // When it is opened again - the binds occur correctly
36
        $(this).dialog('destroy').remove();
37
        },
38
    });
39
 
40
function setInfo(txt) {
41
    $("#info").text( txt).addClass("error");
42
}
43
 
44
function clearInfo(txt) {
45
    $("#info").text("").removeClass("error");
46
}
47
 
48
$.validate({
49
    form: '#f1',
50
    validateOnBlur : false,
51
    onSuccess : function(f) {
52
        processSdkForm(f);
53
    },
54
 
55
});
56
 
57
// Severe Error processing
58
//  Disable all the inputs on a form
59
//  Hide dialog buttons marked to be hidden
60
//  All the user can do is read the erro message and close the form
61
function disableForm()
62
{   
63
    var form = $("#f1");
64
    form.dialog( "widget" ).find(".hideOnError").hide();
65
    form.find(":input").prop("disabled",true);
66
}
67
 
68
function processSdkForm(f)
69
{
70
    clearInfo();
71
    $("#progressBar").css('visibility', 'visible');
72
    var postData = f.serializeArray();
73
    var formURL = f.attr("action");
74
    $.ajax(
75
    {
76
        url : formURL,
77
        type: "POST",
78
        data : postData,
79
        dataType : "json",
80
        cache: false,
81
        success:function(data, textStatus, jqXHR)
82
        {
83
            //data: return data from server
84
            //console.log ("UpdateData", data);
85
            if (data.result != 0)
86
            {
87
                setInfo("Error:" + ((data.error != 0) ? data.emsgSummary : "Reason not given"));
88
                if (data.error >= 0) disableForm();
89
                return;
90
            }
5051 dpurdie 91
            $("#sdk_version").trigger('sdkNameEdited');
5048 dpurdie 92
            f.dialog( "close" );
93
        },
94
        error: function(jqXHR, textStatus, errorThrown)
95
        {
96
            setInfo("Error:" + errorThrown);
97
            disableForm();
98
            //if fails
99
        },
100
        complete : function()
101
        {
102
            $("#progressBar").css('visibility', 'hidden');
103
        }
104
    });
105
};
106
 
107
$( "#f1" ).submit(function(e) {
108
        e.preventDefault(); //STOP default action
109
        return false;
110
        });
111
 
112
//# sourceURL=sdk_names_new.asp
113
</script>
114
<form title="Add New SDK Family" id=f1 action="sdk_opr_json.asp" class=td>
115
    <div id="info"></div>
116
	<DIV id='progressBar' style='visibility:hidden;'>
117
        <img src='icons/i_processing.gif' width='79' height='14'>
118
    </DIV>
119
 
120
    <p><label for="sdkName">SDK Name:</label>
5053 dpurdie 121
    <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 122
 
123
    <p>Comment:
124
    <br><textarea id=sdk_comment name="sdkComment" cols=40  data-validation="length" data-validation-length="5-4000"></textarea>                                              
125
 
126
    <input type="hidden" name="action" value="addNew">
127
</form>
128