Advertisement
Guest User

Untitled

a guest
Jan 21st, 2017
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.47 KB | None | 0 0
  1. <div id="reserveButtonOuter"> <button id="reserveButton">Reserve a Table</button> </div>
  2.  
  3. <div id="sb-search" class="sb-search">
  4. <form>
  5. <input class="sb-search-input" placeholder="Enter your search term..." type="search" value="" name="search" id="search">
  6. <input class="sb-search-submit" type="submit" value="">
  7. <span class="sb-icon-search"></span>
  8. </form>
  9. </div>
  10.  
  11. ;( function( window ) {
  12.  
  13. function UISearch( el, options ) {
  14. this.el = el;
  15. this.inputEl = el.querySelector( 'form > input.sb-search-input' );
  16. this._initEvents();
  17. }
  18.  
  19. UISearch.prototype = {
  20. _initEvents : function() {
  21. var self = this,
  22. initSearchFn = function( ev ) {
  23. if( !classie.has( self.el, 'sb-search-open' ) ) { // open it
  24. ev.preventDefault();
  25. self.open();
  26. }
  27. else if( classie.has( self.el, 'sb-search-open' ) && /^s*$/.test( self.inputEl.value ) ) { // close it
  28. self.close();
  29. }
  30. }
  31.  
  32. this.el.addEventListener( 'click', initSearchFn );
  33. this.inputEl.addEventListener( 'click', function( ev ) { ev.stopPropagation(); });
  34. },
  35. open : function() {
  36. classie.add( this.el, 'sb-search-open' );
  37. },
  38. close : function() {
  39. classie.remove( this.el, 'sb-search-open' );
  40. }
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement