﻿icomefromthenet.NewImage_FormPanel = Ext.extend(Ext.form.FormPanel, {
    // configurables
    // anything what is here can be configured from outside
    //renderTo: document.body,
    frame: true,
    //title: 'NewImage Form Panel',
    border: false,
    width: 600,
    fileUpload: true,

    autoHeight: true,
    bodyStyle: 'padding: 10px 10px 0 10px;',
    labelWidth: 50

        , initComponent: function() {
            Ext.apply(this, {
                // anything here, e.g. items, tools or buttons arrays,
                // cannot be changed from outside
                defaults: {
                    anchor: '95%'
                    //allowBlank: false,
                    //msgTarget: 'side'
                },
                items: [
                //{
                // xtype: 'textfield',
                //fieldLabel: 'Name',
                //name: 'FName'
                //}, 
                {
                xtype: 'xtCustomCombo',
                fieldLabel: 'Category'
            }, {
                xtype: 'textfield',
                fieldLabel: 'PassKey',
                name: 'PassKey'
            }, {
                xtype: 'fileuploadfield',
                id: 'form-file',
                emptyText: 'Select an image',
                fieldLabel: 'Photo',
                name: 'PhotoPath',
                buttonCfg: {
                    text: '',
                    iconCls: 'upload-icon'
                }
}]
        , buttons: [{
            text: 'Save',
            scope: this,
            handler: function() {
                if (this.getForm().isValid()) {
                    this.getForm().submit({
                        url: 'Services/UploadImg.ashx',
                        method: 'POST',
                        waitMsg: 'Uploading your photo...',
                        success: function(NewImage, o) {
                            Ext.Msg.alert("Upload Details", "upload sucessful");
                            icomefromthenet.ImageStore.load(); //refresh the datastore
                        },
                        failure: function() {
                            Ext.Msg.alert("Upload Details", "upload NOT Sucessful");
                        }
                    });
                }
            }
        }, {
            text: 'Reset',
            scope: this,
            handler: function() { this.getForm().reset(); }
}] //end of bottons

            }); // e/o apply
            // call parent
            icomefromthenet.NewImage_FormPanel.superclass.initComponent.apply(this, arguments);

            // after parent code here, e.g. install event handlers

        } // e/o function initComponent

});             // e/o extend

// register xtype
Ext.reg('NewImagesFormPanel', icomefromthenet.NewImage_FormPanel); 

