pagesjs 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- data/ChangeLog +6 -0
- data/vendor/assets/javascripts/pages.js +56 -29
- metadata +6 -6
data/ChangeLog
CHANGED
@@ -1,3 +1,9 @@
|
|
1
|
+
== 0.0.4 (Mikhail Bestuzhev-Ryumin)
|
2
|
+
* Allow to set several page options for one page.
|
3
|
+
* Set empty jQuery object to Pages.current on load.
|
4
|
+
* Remove non-ASCII symbols from gemspec.
|
5
|
+
* Print testing URL in test task.
|
6
|
+
|
1
7
|
== 0.0.3 (Sergey Muravyov-Apostol)
|
2
8
|
* Allow to add listener for all new content.
|
3
9
|
* Allow to set animation page options in JS.
|
@@ -38,7 +38,7 @@
|
|
38
38
|
// jQuery node for current page.
|
39
39
|
//
|
40
40
|
// if ( Pages.current.is('.comments-page') ) { … }
|
41
|
-
current:
|
41
|
+
current: $(),
|
42
42
|
|
43
43
|
// Selector to find page blocks. Use to find loaded pages and detect
|
44
44
|
// current one.
|
@@ -327,50 +327,66 @@
|
|
327
327
|
return $(this.pagesSelector + ':visible:first', this._document)
|
328
328
|
},
|
329
329
|
|
330
|
-
// Return `$$(selector)` function, which is analog of `$(selector, nodes)`.
|
331
|
-
_subfind: function(nodes) {
|
332
|
-
return function(subselector) {
|
333
|
-
return $(subselector, nodes);
|
334
|
-
};
|
335
|
-
},
|
336
|
-
|
337
330
|
// Find pages in new content, set caches and trigger load event on them.
|
338
331
|
_enlive: function(nodes) {
|
339
|
-
var
|
332
|
+
var args = this._callbackArgs(divs)
|
340
333
|
for (var i = 0; i < this._liveCallbacks.length; i++) {
|
341
|
-
this._liveCallbacks[i].
|
334
|
+
this._liveCallbacks[i].apply(nodes, args);
|
342
335
|
}
|
343
336
|
|
344
|
-
var page;
|
337
|
+
var page, pages;
|
345
338
|
for (var i = 0; i < this._pages.length; i++) {
|
346
339
|
page = this._pages[i];
|
347
340
|
var divs = nodes.filter(page.selector);
|
348
341
|
divs = divs.add( nodes.find(page.selector) );
|
349
342
|
if ( divs.length ) {
|
350
|
-
divs.data('
|
343
|
+
pages = divs.data('pages')
|
344
|
+
if ( pages ) {
|
345
|
+
pages.push(page);
|
346
|
+
} else {
|
347
|
+
divs.data('pages', [page]);
|
348
|
+
}
|
351
349
|
if ( page.load ) {
|
352
|
-
page.load.
|
350
|
+
page.load.apply(divs, this._callbackArgs(divs));
|
353
351
|
}
|
354
352
|
}
|
355
353
|
}
|
356
354
|
},
|
357
355
|
|
358
|
-
//
|
359
|
-
|
360
|
-
|
361
|
-
|
362
|
-
|
363
|
-
|
364
|
-
|
365
|
-
|
366
|
-
|
356
|
+
// Return callback arguments.
|
357
|
+
_callbackArgs: function(nodes) {
|
358
|
+
var $$ = function(subselector) {
|
359
|
+
return $(subselector, nodes);
|
360
|
+
};
|
361
|
+
return [$, $$, nodes];
|
362
|
+
},
|
363
|
+
|
364
|
+
// Run _type_ callback on every pages in _div_.
|
365
|
+
_callback: function(div, type, args) {
|
366
|
+
if ( !div ) {
|
367
|
+
return;
|
367
368
|
}
|
368
369
|
|
369
|
-
var
|
370
|
-
if (
|
371
|
-
|
370
|
+
var page, pages = div.data('pages')
|
371
|
+
if ( !pages ) {
|
372
|
+
return;
|
372
373
|
}
|
373
374
|
|
375
|
+
for (var i = 0; i < pages.length; i++) {
|
376
|
+
page = pages[i];
|
377
|
+
if ( page[type] ) {
|
378
|
+
page[type].apply(div, this._callbackArgs(div));
|
379
|
+
}
|
380
|
+
}
|
381
|
+
},
|
382
|
+
|
383
|
+
// Find page descriptions for current and next page and fire `close` and
|
384
|
+
// `open` events.
|
385
|
+
_setCurrent: function(next) {
|
386
|
+
if ( this.current ) {
|
387
|
+
this._callback(this.current, 'close');
|
388
|
+
}
|
389
|
+
this._callback(next, 'open');
|
374
390
|
this.current = next;
|
375
391
|
},
|
376
392
|
|
@@ -393,13 +409,24 @@
|
|
393
409
|
|
394
410
|
// Open loaded page.
|
395
411
|
_openPage: function(page, data) {
|
396
|
-
var pageData = page.data();
|
412
|
+
var anim, pageData = page.data();
|
397
413
|
data = $.extend(pageData, data);
|
398
|
-
|
399
|
-
|
414
|
+
|
415
|
+
if ( data.pageAnimation ) {
|
416
|
+
anim = data.pageAnimation;
|
400
417
|
} else {
|
401
|
-
var
|
418
|
+
var pageAnimation = null;
|
419
|
+
if ( pageData.pages ) {
|
420
|
+
for (var i = 0; i < pageData.pages.length; i++) {
|
421
|
+
pageAnimation = pageData.pages[i].animation;
|
422
|
+
}
|
423
|
+
}
|
424
|
+
if ( pageAnimation ) {
|
425
|
+
anim = pageAnimation(this.current);
|
426
|
+
}
|
402
427
|
}
|
428
|
+
anim = anim || Pages.animation;
|
429
|
+
|
403
430
|
this.animating.wait(function() {
|
404
431
|
if ( typeof(data.title) != 'undefined' ) {
|
405
432
|
Pages.title(data.title);
|
metadata
CHANGED
@@ -1,19 +1,19 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pagesjs
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
|
-
- Andrey
|
8
|
+
- Andrey "A.I." Sitnik
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-05-
|
12
|
+
date: 2012-05-29 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: sprockets
|
16
|
-
requirement: &
|
16
|
+
requirement: &20932360 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,7 +21,7 @@ dependencies:
|
|
21
21
|
version: '2'
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *20932360
|
25
25
|
description: Pages.js allow you to manage pages JS code and forget about low-level
|
26
26
|
History API.
|
27
27
|
email:
|
@@ -61,5 +61,5 @@ rubyforge_project:
|
|
61
61
|
rubygems_version: 1.8.11
|
62
62
|
signing_key:
|
63
63
|
specification_version: 3
|
64
|
-
summary: Pages.js
|
64
|
+
summary: Pages.js - is a framework for History pushState.
|
65
65
|
test_files: []
|