allow for file buttons with 'image' type

This commit is contained in:
rolux 2012-06-27 10:37:12 +02:00
parent 9bb6b7bcb9
commit 0564db6ec5

View file

@ -5,6 +5,12 @@ Ox.FileButton <f> File Button
([options[, self]]) -> <o:Ox.Element> File Button ([options[, self]]) -> <o:Ox.Element> File Button
click <!> click click <!> click
options <o> Options options <o> Options
disabled <b|false> If true, the button is disabled
maxFiles <n|-1> Maximum number of files, or -1 for unlimited
maxSize <n|-1> Maximum total file size in bytes, or -1 for unlimited
title <s|''> Title of the button
type <s|'text'> Type of the button ('text' or 'image')
width <n|256> Width of the button in px
self <o> Shared private variable self <o> Shared private variable
@*/ @*/
Ox.FileButton = function(options, self) { Ox.FileButton = function(options, self) {
@ -18,7 +24,7 @@ Ox.FileButton = function(options, self) {
style: 'default', style: 'default',
title: '', title: '',
type: 'text', type: 'text',
width: 256 width: options.type == 'image' ? 16 : 256
}) })
.options(options || {}) .options(options || {})
.update({ .update({
@ -41,7 +47,7 @@ Ox.FileButton = function(options, self) {
style: self.options.style, style: self.options.style,
title: self.options.title, title: self.options.title,
type: self.options.type, type: self.options.type,
width: self.options.width width: self.options.type == 'image' ? 'auto' : self.options.width
}) })
.css({ .css({
float: 'left' float: 'left'
@ -89,7 +95,9 @@ Ox.FileButton = function(options, self) {
return $('<input>') return $('<input>')
.attr( .attr(
Ox.extend({ Ox.extend({
title: self.options.title, title: self.options.type == 'text' ? self.options.title
: self.options.maxFiles == 1 ? 'Select File...'
: 'Select Files...',
type: 'file' type: 'file'
}, self.multiple ? { }, self.multiple ? {
multiple: true multiple: true