express_ui 0.1.0.rc1 → 0.1.0.rc3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3aba4d25bce3a9b4dad5029c100a38467f15c305
4
- data.tar.gz: d99847094ecdb814e7a25718cbd09e23b265f7fc
3
+ metadata.gz: 6a531b717f8900a082c67d629e18b6ca4bd9cbd6
4
+ data.tar.gz: 5aaeb73fc86c6a21895bd6abde982e61424917a1
5
5
  SHA512:
6
- metadata.gz: '0362895f696cd259db5f153335668a32af3cd688a0d2a76c5ab402f05696b60b7a92a65593842fa62ea00596d0745d799bf1f5c146e6e335362b6ad1f3db2ba0'
7
- data.tar.gz: 485aeecd0951c2ee20a9d67e129480a4e95ba072263e27cc7c1270c6d05f53db3af040087772cc0d20d3c93d570518a5fa01f72d2af105988bfb3c181504cfb5
6
+ metadata.gz: 0f2da03f0ddad81828954d4122cfcbe141e0e8676fc5b6b64e78a285e004b2209524a51ca23c9c0e9ffdd64ac408b61dcb0c8ad9004d5eb70e419c20409b5495
7
+ data.tar.gz: 79ad6877164bf83a51e7c0a86f6ba3f13ff7bae796b95acbf98af84c03fde760cbb7348f0cf3e536dd0db64653476c078f112f9d55333b55410fe12de0e3e43b
@@ -1,3 +1,3 @@
1
1
  module ExpressUi
2
- VERSION = '0.1.0.rc1'
2
+ VERSION = '0.1.0.rc3'
3
3
  end
@@ -0,0 +1,217 @@
1
+ /*
2
+ The MIT License (MIT)
3
+
4
+ Copyright (c) <2013> <Ren Aysha>
5
+
6
+ Permission is hereby granted, free of charge, to any person obtaining a copy
7
+ of this software and associated documentation files (the "Software"), to deal
8
+ in the Software without restriction, including without limitation the rights
9
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+ copies of the Software, and to permit persons to whom the Software is
11
+ furnished to do so, subject to the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be included in
14
+ all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22
+ THE SOFTWARE.
23
+ */
24
+
25
+ if ( typeof Object.create !== 'function' ) {
26
+ Object.create = function( obj ) {
27
+ function F() {}
28
+ F.prototype = obj;
29
+ return new F();
30
+ };
31
+ }
32
+
33
+ (function( $, window, document, undefined ) {
34
+ "use strict";
35
+
36
+ var Anchorific = {
37
+
38
+ init: function( options, elem ) {
39
+ var self = this;
40
+
41
+ self.elem = elem;
42
+ self.$elem = $( elem );
43
+
44
+ self.opt = $.extend( {}, this.opt, options );
45
+
46
+ self.headers = self.$elem.find( self.opt.headers );
47
+ self.previous = 0;
48
+
49
+ // Fix bug #1
50
+ if ( self.headers.length !== 0 ) {
51
+ self.first = parseInt( self.headers.prop( 'nodeName' ).substring( 1 ), null );
52
+ }
53
+
54
+ self.build();
55
+ },
56
+
57
+ opt: {
58
+ navigation: '.anchorific', // position of navigation
59
+ headers: 'h1, h2, h3, h4, h5, h6',
60
+ speed: 200, // speed of sliding back to top
61
+ anchorClass: 'ae-anchor', // class of anchor links
62
+ anchorText: 'TOP', // prepended or appended to anchor headings
63
+ top: '.ae-top', // back to top button or link class
64
+ spy: true, // scroll spy
65
+ position: 'append', // position of anchor text
66
+ spyOffset: !0 // specify heading offset for spy scrolling
67
+ },
68
+
69
+ build: function() {
70
+ var self = this, obj, navigations = function() {};
71
+ // when navigation configuration is set
72
+ if ( self.opt.navigation ) {
73
+ $( self.opt.navigation ).append( '<ul />' );
74
+ self.previous = $( self.opt.navigation ).find( 'ul' ).last();
75
+ navigations = function( obj ) {
76
+ return self.navigations( obj );
77
+ };
78
+ }
79
+
80
+ for( var i = 0; i < self.headers.length; i++ ) {
81
+ obj = self.headers.eq( i );
82
+ navigations( obj );
83
+ self.anchor( obj );
84
+ }
85
+
86
+ if ( self.opt.spy )
87
+ self.spy();
88
+
89
+ if ( self.opt.top )
90
+ self.back();
91
+ },
92
+
93
+ navigations: function( obj ) {
94
+ var self = this, link, list, which, name = self.name( obj );
95
+
96
+ if ( obj.attr( 'id' ) !== undefined )
97
+ name = obj.attr( 'id' );
98
+
99
+ link = $( '<a />' ).attr( 'href', '#' + name ).text( obj.text() );
100
+ list = $( '<li />' ).append( link );
101
+
102
+ which = parseInt( obj.prop( 'nodeName' ).substring( 1 ), null );
103
+ list.attr( 'data-tag', which );
104
+
105
+ self.subheadings( which, list );
106
+
107
+ self.first = which;
108
+ },
109
+
110
+ subheadings: function( which, a ) {
111
+ var self = this, ul = $( self.opt.navigation ).find( 'ul' ),
112
+ li = $( self.opt.navigation ).find( 'li' );
113
+
114
+ if ( which === self.first ) {
115
+ self.previous.append( a );
116
+ } else if ( which > self.first ) {
117
+ li.last().append( '<ul />' );
118
+ // can't use cache ul; need to find ul once more
119
+ $( self.opt.navigation ).find( 'ul' ).last().append( a );
120
+ self.previous = a.parent();
121
+ } else {
122
+ $( 'li[data-tag=' + which + ']' ).last().parent().append( a );
123
+ self.previous = a.parent();
124
+ }
125
+ },
126
+
127
+ name: function( obj ) {
128
+ var name = obj.text().replace( /[^\w\s]/gi, '' )
129
+ .replace( /\s+/g, '-' )
130
+ .toLowerCase();
131
+
132
+ return name;
133
+ },
134
+
135
+ anchor: function( obj ) {
136
+ var self = this, name = self.name( obj ), anchor, text = self.opt.anchorText,
137
+ klass = self.opt.anchorClass, id;
138
+
139
+ if ( obj.attr( 'id' ) === undefined )
140
+ obj.attr( 'id', name );
141
+
142
+ id = obj.attr( 'id' );
143
+
144
+ anchor = $( '<a />' ).attr( 'href', '#').html( text ).addClass( klass );
145
+
146
+ if ( self.opt.position === 'append' ) {
147
+ obj.append( anchor );
148
+ } else {
149
+ obj.prepend( anchor );
150
+ }
151
+ },
152
+
153
+ back: function() {
154
+ var self = this, body = $( 'body, html' ), top = $( self.opt.top );
155
+
156
+ top.on( 'click', function( e ) {
157
+ e.preventDefault();
158
+
159
+ body.animate({
160
+ 'scrollTop': 0
161
+ }, self.opt.speed );
162
+ });
163
+ },
164
+
165
+ top: function( that ) {
166
+ var self = this, top = self.opt.top, back;
167
+
168
+ if ( top !== false ) {
169
+ back = ( $( that ).scrollTop() > 200 ) ?
170
+ $( top ).fadeIn() :
171
+ $( top ).fadeOut();
172
+ }
173
+ },
174
+
175
+ spy: function() {
176
+ var self = this, previous, current, list, top, prev;
177
+
178
+ $( window ).scroll( function( e ) {
179
+ // show links back to top
180
+ self.top( this );
181
+ // get all the header on top of the viewport
182
+ current = self.headers.map( function( e ) {
183
+ if ( ( $( this ).offset().top - $( window ).scrollTop() ) < self.opt.spyOffset ) {
184
+ return this;
185
+ }
186
+ });
187
+ // get only the latest header on the viewport
188
+ current = $( current ).eq( current.length - 1 );
189
+
190
+ if ( current && current.length ) {
191
+ // get all li tag that contains href of # ( all the parents )
192
+ list = $( 'li:has(a[href="#' + current.attr( 'id' ) + '"])' );
193
+
194
+ if ( prev !== undefined ) {
195
+ prev.removeClass( 'active' );
196
+ }
197
+
198
+ list.addClass( 'active' );
199
+ prev = list;
200
+ }
201
+ });
202
+ }
203
+ };
204
+
205
+ $.fn.anchorific = function( options ) {
206
+ return this.each(function() {
207
+ if ( ! $.data( this, 'anchorific' ) ) {
208
+ var anchor = Object.create( Anchorific );
209
+
210
+ anchor.init( options, this );
211
+
212
+ $.data( this, 'anchorific', anchor );
213
+ }
214
+ });
215
+ };
216
+
217
+ })( jQuery, window, document );