pagesjs 0.0.4 → 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
data/ChangeLog CHANGED
@@ -1,3 +1,10 @@
1
+ == 0.0.5 (Pyotr Kakhovsky)
2
+ * Add data.from with URL changing source.
3
+ * Pages.open() will change URL if it necessary.
4
+ * Don’t track location hash changes.
5
+ * Don’t run animation, when page wasn’t be changed.
6
+ * Use lib/assets path in gem instead of vendor/assets.
7
+
1
8
  == 0.0.4 (Mikhail Bestuzhev-Ryumin)
2
9
  * Allow to set several page options for one page.
3
10
  * Set empty jQuery object to Pages.current on load.
@@ -162,8 +162,8 @@
162
162
  this._events = true;
163
163
 
164
164
  $(window).on('popstate.pages', function() {
165
- if ( Pages._lastUrl != location.href ) {
166
- Pages.open(location.pathname);
165
+ if ( Pages._lastUrl != location.pathname ) {
166
+ Pages.open(location.pathname, { from: 'popstate' });
167
167
  }
168
168
  });
169
169
 
@@ -174,7 +174,7 @@
174
174
  return true;
175
175
  },
176
176
 
177
- // Disable session history management. Pages will load by default browser
177
+ // Disable session history management. Pages.js will load by default browser
178
178
  // way without AJAX and animations.
179
179
  disable: function() {
180
180
  $(this._document).off('click.pages', 'a');
@@ -184,15 +184,22 @@
184
184
  },
185
185
 
186
186
  // Show page by `url` with overrided page `data`. Return true if page is
187
- // already loaded and false if Pages request it from server.
187
+ // already loaded and false if Pages.js request it from server.
188
188
  //
189
189
  // setTimeout(function() {
190
190
  // Pages.open('/gameover');
191
191
  // }, 5000);
192
192
  open: function(url, data) {
193
+ if ( location.pathname != url ) {
194
+ history.pushState({ }, '', url);
195
+ }
196
+
193
197
  if ( typeof(data) == 'undefined' ) {
194
198
  data = { };
195
199
  }
200
+ if ( typeof(data.from) == 'undefined' ) {
201
+ data.from = 'js';
202
+ }
196
203
  data.url = url;
197
204
  Pages._lastUrl = url;
198
205
 
@@ -400,15 +407,28 @@
400
407
  return true;
401
408
  }
402
409
 
403
- history.pushState({ }, '', href);
404
- var data = link.data();
410
+ var data = link.data();
405
411
  data.link = link;
406
- this.open(href, data);
412
+ data.from = 'link';
413
+
414
+ href = href.split('#', 2);
415
+ var path = href[0];
416
+ var hash = href[1];
417
+
418
+ this.open(path, data);
419
+ if ( hash && location.hash != hash ) {
420
+ location.hash = hash;
421
+ }
407
422
  return false;
408
423
  },
409
424
 
410
425
  // Open loaded page.
411
426
  _openPage: function(page, data) {
427
+ if ( page[0] == Pages.current[0] ) {
428
+ Pages._setCurrent(page);
429
+ return;
430
+ }
431
+
412
432
  var anim, pageData = page.data();
413
433
  data = $.extend(pageData, data);
414
434
 
@@ -494,7 +514,7 @@
494
514
  };
495
515
 
496
516
  $(document).ready(function() {
497
- Pages._lastUrl = location.href;
517
+ Pages._lastUrl = location.pathname;
498
518
  Pages.init();
499
519
  if ( !Pages.disabled ) {
500
520
  Pages.enable();
data/lib/pagesjs.rb CHANGED
@@ -1,4 +1,4 @@
1
- # Used only for Ruby on Rails gem to tell, that gem contain `vendor/assets` with
1
+ # Used only for Ruby on Rails gem to tell, that gem contain `lib/assets` with
2
2
  # pages.js file.
3
3
  module PagesJs
4
4
  module Rails
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pagesjs
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-05-29 00:00:00.000000000 Z
12
+ date: 2012-10-22 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: sprockets
16
- requirement: &20932360 !ruby/object:Gem::Requirement
16
+ requirement: !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,7 +21,12 @@ dependencies:
21
21
  version: '2'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *20932360
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: '2'
25
30
  description: Pages.js allow you to manage pages JS code and forget about low-level
26
31
  History API.
27
32
  email:
@@ -33,7 +38,7 @@ extra_rdoc_files:
33
38
  - README.md
34
39
  - ChangeLog
35
40
  files:
36
- - vendor/assets/javascripts/pages.js
41
+ - lib/assets/javascripts/pages.js
37
42
  - lib/pagesjs.rb
38
43
  - LICENSE
39
44
  - README.md
@@ -58,7 +63,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
58
63
  version: '0'
59
64
  requirements: []
60
65
  rubyforge_project:
61
- rubygems_version: 1.8.11
66
+ rubygems_version: 1.8.23
62
67
  signing_key:
63
68
  specification_version: 3
64
69
  summary: Pages.js - is a framework for History pushState.