angular-history-rails 0.7.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.gitignore +17 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +14 -0
- data/Rakefile +1 -0
- data/angular-history-rails.gemspec +22 -0
- data/lib/angular/history/rails.rb +9 -0
- data/lib/angular/history/rails/version.rb +7 -0
- data/vendor/assets/javascripts/angular-history.js +1517 -0
- data/vendor/assets/javascripts/angular-lazy-bind.js +91 -0
- metadata +82 -0
@@ -0,0 +1,91 @@
|
|
1
|
+
(function () {
|
2
|
+
"use strict";
|
3
|
+
|
4
|
+
var lazyBindProvider = function($cacheFactory, $timeout) {
|
5
|
+
var idx = 0;
|
6
|
+
|
7
|
+
// return lazy funtion.
|
8
|
+
return function(scope, isCopy, cacheTime, capacity) {
|
9
|
+
|
10
|
+
cacheTime = cacheTime || 500;
|
11
|
+
|
12
|
+
// exp exe count
|
13
|
+
var expExeCount = {};
|
14
|
+
|
15
|
+
// create cache object
|
16
|
+
var cacheId = "lazyBindCache" + idx++;
|
17
|
+
var bindCache = $cacheFactory.get(cacheId) ||
|
18
|
+
$cacheFactory(cacheId, {capacity: capacity || 1000});
|
19
|
+
|
20
|
+
var isLazyDigest = false;
|
21
|
+
|
22
|
+
// cache timeout
|
23
|
+
var cacheTimeoutPromise;
|
24
|
+
var setCacheTimeout = function() {
|
25
|
+
if (!cacheTimeoutPromise && !isLazyDigest) {
|
26
|
+
cacheTimeoutPromise = $timeout(function() {
|
27
|
+
lazy.flush();
|
28
|
+
if (!scope.$$phase) {
|
29
|
+
isLazyDigest = true;
|
30
|
+
scope.$digest();
|
31
|
+
isLazyDigest = false;
|
32
|
+
}
|
33
|
+
}, cacheTime, false);
|
34
|
+
}
|
35
|
+
};
|
36
|
+
|
37
|
+
var clearCacheTimeout = function() {
|
38
|
+
if (cacheTimeoutPromise) {
|
39
|
+
$timeout.cancel(cacheTimeoutPromise);
|
40
|
+
cacheTimeoutPromise = null;
|
41
|
+
}
|
42
|
+
};
|
43
|
+
|
44
|
+
|
45
|
+
|
46
|
+
// lazy exp fn, public api
|
47
|
+
var lazy = function(exp) {
|
48
|
+
setCacheTimeout(this);
|
49
|
+
if ((expExeCount[exp] = expExeCount[exp] || 0) < 2) {
|
50
|
+
++expExeCount[exp];
|
51
|
+
return undefined;
|
52
|
+
}
|
53
|
+
var result = bindCache.get(exp);
|
54
|
+
if (!result) {
|
55
|
+
result = this.$eval(exp);
|
56
|
+
result = isCopy ? angular.copy(result) : result;
|
57
|
+
bindCache.put(exp, result);
|
58
|
+
}
|
59
|
+
return result;
|
60
|
+
};
|
61
|
+
|
62
|
+
// set copy exp result or not
|
63
|
+
lazy.isCopy = function(value) {
|
64
|
+
if (arguments.length) {
|
65
|
+
isCopy = value;
|
66
|
+
}
|
67
|
+
return isCopy;
|
68
|
+
};
|
69
|
+
|
70
|
+
// set cache timeout
|
71
|
+
lazy.cacheTime = function(value) {
|
72
|
+
if (arguments.length) {
|
73
|
+
cacheTime = ~~value;
|
74
|
+
}
|
75
|
+
return cacheTime;
|
76
|
+
};
|
77
|
+
|
78
|
+
// clear cache
|
79
|
+
lazy.flush = function() {
|
80
|
+
clearCacheTimeout();
|
81
|
+
bindCache.removeAll();
|
82
|
+
};
|
83
|
+
|
84
|
+
return lazy;
|
85
|
+
};
|
86
|
+
};
|
87
|
+
|
88
|
+
var app = angular.module("lazyBind", []);
|
89
|
+
app.factory("$lazyBind", lazyBindProvider);
|
90
|
+
|
91
|
+
})();
|
metadata
ADDED
@@ -0,0 +1,82 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: angular-history-rails
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.7.3
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Paul Vonderscher
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-03-21 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.5'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.5'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
description:
|
42
|
+
email:
|
43
|
+
- paul.vonderscher@gmail.com
|
44
|
+
executables: []
|
45
|
+
extensions: []
|
46
|
+
extra_rdoc_files: []
|
47
|
+
files:
|
48
|
+
- ".gitignore"
|
49
|
+
- Gemfile
|
50
|
+
- LICENSE.txt
|
51
|
+
- README.md
|
52
|
+
- Rakefile
|
53
|
+
- angular-history-rails.gemspec
|
54
|
+
- lib/angular/history/rails.rb
|
55
|
+
- lib/angular/history/rails/version.rb
|
56
|
+
- vendor/assets/javascripts/angular-history.js
|
57
|
+
- vendor/assets/javascripts/angular-lazy-bind.js
|
58
|
+
homepage: https://github.com/VonD/angular-history-rails/
|
59
|
+
licenses:
|
60
|
+
- MIT
|
61
|
+
metadata: {}
|
62
|
+
post_install_message:
|
63
|
+
rdoc_options: []
|
64
|
+
require_paths:
|
65
|
+
- lib
|
66
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
67
|
+
requirements:
|
68
|
+
- - ">="
|
69
|
+
- !ruby/object:Gem::Version
|
70
|
+
version: '0'
|
71
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
requirements: []
|
77
|
+
rubyforge_project:
|
78
|
+
rubygems_version: 2.2.1
|
79
|
+
signing_key:
|
80
|
+
specification_version: 4
|
81
|
+
summary: Adds the angular-history module to the asset pipeline
|
82
|
+
test_files: []
|