예제 #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 = new List <ToolButton>
                {
                    new ToolButton {
                        Title    = "Dosya Seç",
                        CssClass = "add-file-button",
                        OnClick  = delegate {
                        }
                    },
                    new ToolButton {
                        Title    = "Kaldır",
                        CssClass = "delete-button",
                        OnClick  = delegate {
                            self.entity = null;
                            self.Populate();
                            self.UpdateInterface();
                        }
                    }
                }
            });

            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,
                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();
        }
예제 #2
0
 protected virtual void Populate()
 {
     UploadHelper.PopulateFileSymbols(fileSymbols, entities, true, options.UrlPrefix);
 }