Last active
December 17, 2015 10:28
-
-
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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