FileButton: add image option (so tooltip title becomes configurable if type is 'image')

This commit is contained in:
rolux 2012-06-27 11:07:34 +02:00
parent 0564db6ec5
commit b1019a7c5d

View file

@ -2,16 +2,17 @@
/*@
Ox.FileButton <f> File Button
([options[, self]]) -> <o:Ox.Element> File Button
click <!> click
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
image <s|false> Symbol name (if type is 'image')
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 (and its tooltip)
type <s|'text'> Type of the button ('text' or 'image')
width <n|256> Width of the button in px
self <o> Shared private variable
([options[, self]]) -> <o:Ox.Element> File Button
click <!> click
@*/
Ox.FileButton = function(options, self) {
@ -19,6 +20,7 @@ Ox.FileButton = function(options, self) {
var that = Ox.Element({}, self)
.defaults({
disabled: false,
image: '',
maxFiles: -1,
maxSize: -1,
style: 'default',
@ -45,9 +47,13 @@ Ox.FileButton = function(options, self) {
self.$button = Ox.Button({
disabled: self.options.disabled,
style: self.options.style,
title: self.options.title,
title: self.options.type == 'image'
? self.options.image
: self.options.title,
type: self.options.type,
width: self.options.type == 'image' ? 'auto' : self.options.width
width: self.options.type == 'image'
? 'auto'
: self.options.width
})
.css({
float: 'left'
@ -95,9 +101,7 @@ Ox.FileButton = function(options, self) {
return $('<input>')
.attr(
Ox.extend({
title: self.options.type == 'text' ? self.options.title
: self.options.maxFiles == 1 ? 'Select File...'
: 'Select Files...',
title: self.options.title,
type: 'file'
}, self.multiple ? {
multiple: true