nathanborror (owner)

Revisions

gist: 202782 Download_button fork
public
Public Clone URL: git://gist.github.com/202782.git
Embed All Files: show embed
HTML #
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
 
<html lang="en">
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  <title>untitled</title>
  <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/mootools/1.2.3/mootools-yui-compressed.js"></script>
  <script type="text/javascript">
    var Box = new Class({
      initialize: function(element) {
        this.element = $(element);
        this.p = this.element.getElement('p');
        this.doc = $(document);
 
        this.element.addEvent('click', this.click.bind(this));
        this.doc.addEvents({
          'click': this.hide.bind(this),
          'reset': this.hide.bind(this)
        });
      },
 
      click: function(e) {
        e.stop();
        var target = $(e.target);
        if (target.get('tag') == 'a') {
          if (this.p.getStyle('display') == 'block') {
            this.hide();
          }
          else {
            this.show();
          }
        }
      },
 
      hide: function(e) {
        this.p.setStyle('display', 'none');
      },
 
      show: function(e) {
        this.doc.fireEvent('reset');
        this.p.setStyle('display', 'block');
      }
    });
    
    window.addEvent('domready',function() {
      new Box('button1');
      new Box('button2');
    });
  </script>
  <style type="text/css" media="screen">
    body { font: 16px "Helvetica Neue", helvetica, arial, sans-serif; }
    a { text-decoration: none; }
 
    .button { margin-bottom: 10px; padding: 20px; width: 300px; border: 1px solid #ddd; }
    .button a { display: block; }
    .button p { display: none; }
  </style>
</head>
<body>
 
<div class="button" id="button1">
  <a href="#">Button 1</a>
  <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
</div>
 
<div class="button" id="button2">
  <a href="#">Button 2</a>
  <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
</div>
 
</body>
</html>