Advertisement
Guest User

Untitled

a guest
Feb 22nd, 2019
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.94 KB | None | 0 0
  1. "use strict";
  2.  
  3. /**
  4. * Description.
  5. * @class
  6. * @augments [class]
  7. * @param {Object} options - Options object.
  8. * @param {string} options.opt1 - CSS selector of [some] element
  9. * @param {string} options.opt2 - CSS selector of [some] element
  10. * @version 1.0.0-alpha
  11. * @author Daur Gamisonia <daurgam@gmail.com>
  12. */
  13. function Obj( options ) {
  14. this._opt1 = options.opt1;
  15. this._opt2 = options.opt2;
  16.  
  17. this.listen = function() {
  18. document.body.addEventListener( "click", this._handle );
  19. };
  20.  
  21. this._handle = function( event ) {
  22. var target = event.target;
  23.  
  24. while( true ) {
  25.  
  26. if ( target == document.body ) {
  27. break;
  28. }
  29.  
  30. if ( !target.classList.contains("some-class") {
  31.  
  32. target = target.parentElement;
  33.  
  34. continue;
  35. }
  36.  
  37. break;
  38. }
  39. };
  40.  
  41. this.open = function() {
  42. ...
  43. };
  44.  
  45. this.close = function() {
  46. ...
  47. };
  48. };
  49.  
  50. var func = new Obj({
  51. opt1: "value",
  52. opt2: "value"
  53. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement