Skip to content

Instantly share code, notes, and snippets.

@walterdavis
Last active December 17, 2015 10:28
Show Gist options
  • Select an option

  • Save walterdavis/5594632 to your computer and use it in GitHub Desktop.

Select an option

Save walterdavis/5594632 to your computer and use it in GitHub Desktop.
So, in my usual rather perverse fashion, I am force-fitting Prototype into Bootstrap, since I have a gigantic mental block where jQuery should be. It actually works pretty well. Here are some widgets I have made over the course of building projects with these two frameworks.
document.observe('dom:loaded', function(){
var file_decorator = function(){
$$('input.file').each(function(elm){
var elm = elm.hide();
if(elm.decorated) return;
elm['decorated'] = true;
var group = new Element('div', {
'class': 'input-append'
});
var txt = new Element('input', {
type: 'text',
'class': 'input'
});
var btn = new Element('a', {
'class': 'btn'
}).update('Browse').observe('click', function(evt){
elm.click();
});
elm.insert({after: group});
group.insert(txt);
group.insert(btn);
elm.observe('change', function(evt){
txt.setValue(this.getValue().split(/[\\\/]/).last());
});
});
};
file_decorator();
document.observe('DOMSubtreeModified', file_decorator);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment