File: demo.html

package info (click to toggle)
libjs-jquery-center 1.1.0+dfsg1-2
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, buster, sid
  • size: 140 kB
  • sloc: makefile: 37
file content (148 lines) | stat: -rw-r--r-- 4,045 bytes parent folder | download
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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>jQuery Center Plugin Demo</title>
    <style type="text/css">
      h1{
        text-align : center;
      }
      #wrap{
        width: 880px;
        margin: 0 auto 50px;
      }
      #info{
        text-align: center;
        margin: 50px 0 0;
      }
      #play-ground1{
        height: 150px;
      }
      #play-ground2{
        height: 220px;
        position: relative;
      }
      .spacer{
        height: 50px;
      }
      .parent{
        width: 200px;
        height: 200px;
        position: relative;
        background: #cccccc;
        display: inline;
        float: left;
        margin: 0 20px 0 0;
      }
      .some-element{
        width: 100px;
        height: 100px;
        position: absolute;
        background: #333333;
        color: white;
      }
      .btn{
        background: #cccccc;
        float: left;
        display: inline;
        font-family: arial;
        font-size: 12px;
        font-weight: bolder;
        padding: 3px 7px;
        margin: 0 8px 0 0;
        cursor: pointer;
      }
    </style>
  </head>
  <body>
    <div id="wrap">
      <h1>
        jQuery Center Plugin Demo
      </h1>
      <p>
        Try clicking the buttons to see how they works :)
      </p>
      <h2>
        centralize #some-element against the window
      </h2>
      <div id="sample1" class="spacer">
        <div id="btn1" class="btn">Centralize</div>
        <div class="btn restore">Restore</div>
      </div>
      <div id="play-ground1">
        <div id="some-element" class="some-element">
          #some-element
        </div>
      </div>
      <h2>
        centralize .some-element against its parent
      </h2>
      <div id="sample2" class="spacer">
        <div id="btn2" class="btn">Centralize</div>
        <div class="btn restore">Restore</div>
      </div>
      <div id="play-ground2">
        <div class="parent">
          .parent
          <div class="some-element">
            .some-element
          </div>
        </div>
        <div class="parent">
          .parent
          <div class="some-element">
            .some-element
          </div>
        </div>
        <div class="parent">
          .parent
          <div class="some-element">
            .some-element
          </div>
        </div>
        <div class="parent">
          .parent
          <div class="some-element">
            .some-element
          </div>
        </div>
      </div>
      <h3 id="info">
        Demo provides by <a href="http://dreamerslab.com/">DreamersLab</a>
      </h3>
    </div>
    <script type="text/javascript" src="file:///usr/share/javascript/jquery/jquery.js"></script>
    <script type="text/javascript" src="file:///usr/share/javascript/libjs-jquery-center/jquery.center.js"></script>
    <script type="text/javascript" charset="utf-8">
      // wrap everything in document ready event
      $( function(){

        // cache jquery obj
        var $el    = $( '#some-element' );
        var $pg2el = $( '#play-ground2' ).find( '.some-element' );

        // centerize '#some-element' against the window on clicking #btn1
        $( '#btn1' ).bind( 'click', function(){
          $el.center();
        });

        // restore '#some-element' position on clicking '.restore'
        $( '#sample1' ).find( '.restore' ).bind( 'click', function(){
          $el.attr( 'style', '' );
        });

        // centerize each '.some-element' against its parent on clicking #btn2
        $( '#btn2' ).bind( 'click', function(){
          $pg2el.center({ against: 'parent' });
        });

        // restore '.some-element' position on clicking '.restore'
        $( '#sample2' ).find( '.restore' ).bind( 'click', function(){
          $pg2el.attr( 'style', '' );
        });
      });


    </script>
  </body>
</html>