AddUploadInput() public static method

public static AddUploadInput ( UploadInputOptions options ) : jQueryObject
options UploadInputOptions
return jQueryObject
Exemplo n.º 1
0
        public ImageUploadEditor(jQueryObject div, ImageUploadEditorOptions opt)
            : base(div, opt)
        {
            div.AddClass("s-ImageUploadEditor");

            if (options.OriginalNameProperty.IsEmptyOrNull())
            {
                div.AddClass("hide-original-name");
            }

            var self = this;

            toolbar = new Toolbar(J("<div/>").AppendTo(this.Element), new ToolbarOptions
            {
                Buttons = GetToolButtons()
            });

            var progress = J("<div><div></div></div>").AddClass("upload-progress")
                           .PrependTo(toolbar.Element);

            var addFileButton = toolbar.FindButton("add-file-button");

            uploadInput = UploadHelper.AddUploadInput(new UploadInputOptions
            {
                Container = addFileButton,
                InputName = this.uniqueName,
                Zone      = this.element,
                Progress  = progress,
                FileDone  = (response, name, data) =>
                {
                    if (!UploadHelper.CheckImageConstraints(response, options))
                    {
                        return;
                    }

                    var newEntity = new UploadedFile
                    {
                        OriginalName = name,
                        Filename     = response.TemporaryFile
                    };

                    self.entity = newEntity;
                    self.Populate();
                    self.UpdateInterface();
                }
            });

            fileSymbols = jQuery.FromHtml("<ul/>")
                          .AppendTo(this.element);

            this.UpdateInterface();
        }