urb 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/CHANGELOG.rdoc +4 -0
- data/README.rdoc +14 -0
- data/VERSION +1 -1
- data/app/assets/javascripts/urb.js.erb +11 -9
- data/lib/urb/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
NGY2ZWJiMDJhNGI0ZGU5MDA5OGM1NmJkNjg0NjAxNTk0YjZjZmUwMA==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
YmVkMzNjMjcxOTZmZGFmNWU1NWE4ZjRlNWNlMDYwMTVmNDkwMDViOQ==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
NTE1ZGYxM2Q3YjU2YWY5YTJmZjFkMjRhNGVkYmQ3OTY5NjA4YWM5MjNjOTIy
|
10
|
+
MTBmYzRmMTgzZWQ4ZWE2OTFjNzM0NWU4Y2FjZTdiM2IwNGM3NjZjMjhlM2Ni
|
11
|
+
MzM1OGQ3MGY5MjExMjZkMjk3MWU0ODRjYjU1MmQ5NWU4YzJlMWQ=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
YmFhMTZlOWY1NTg1YzUzNzI4MmM1NWE4ZmI0OThmNTJmMjYwODZmNTIwODEy
|
14
|
+
OWEwNjEzYmJlNmJlNzk4ZjJiOWIxMjNhMGQ0MjBkYTJjZTYzYzg3ZTU4NTc0
|
15
|
+
YzRjMGE0YzA5NWYwYjA1N2Q4MTE2MGU3ODIxZWYzOGJjZWRhZjM=
|
data/CHANGELOG.rdoc
CHANGED
data/README.rdoc
CHANGED
@@ -16,6 +16,8 @@ Run the following in your console to install with Bundler:
|
|
16
16
|
|
17
17
|
=== Usage
|
18
18
|
|
19
|
+
==== Include urb.js
|
20
|
+
|
19
21
|
Invoke the view helper method <tt>urb</tt> within your template:
|
20
22
|
|
21
23
|
<!DOCTYPE html>
|
@@ -28,6 +30,18 @@ Invoke the view helper method <tt>urb</tt> within your template:
|
|
28
30
|
<%= urb %>
|
29
31
|
</head>
|
30
32
|
|
33
|
+
==== Add urb.js to the precompiled Rails assets
|
34
|
+
|
35
|
+
You will need to add <tt>urb.js</tt> to the additional precompiled assets in the production and staging environment.
|
36
|
+
|
37
|
+
(e.g. in config/environments/production.rb)
|
38
|
+
|
39
|
+
# Precompile additional assets.
|
40
|
+
# application.js, application.css, and all non-JS/CSS in app/assets folder are already added.
|
41
|
+
config.assets.precompile += %w(urb.js)
|
42
|
+
|
43
|
+
==== Start opening URLs
|
44
|
+
|
31
45
|
Click on links within your webpage or call the Javascript function <tt>URB.open()</tt>.
|
32
46
|
|
33
47
|
<script>
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.1
|
@@ -7,7 +7,7 @@ if (typeof(URB) == 'undefined') {
|
|
7
7
|
// * Except otherwise noted, URB is licensed under
|
8
8
|
// * http://creativecommons.org/licenses/by/3.0
|
9
9
|
// *
|
10
|
-
// * $Date: 2014-
|
10
|
+
// * $Date: 2014-07-08 10:56:53 $
|
11
11
|
// *
|
12
12
|
|
13
13
|
URB = (function() {
|
@@ -18,29 +18,31 @@ URB = (function() {
|
|
18
18
|
on: function(e,t,f,r){if(e.attachEvent?(r?e.detachEvent('on'+t,e[t+f]):1):(r?e.removeEventListener(t,f,0):e.addEventListener(t,f,0))){e['e'+t+f]=f;e[t+f]=function(){e['e'+t+f](window.event);};e.attachEvent('on'+t,e[t+f]);}},
|
19
19
|
hasClass: function(e,c){return $.indexOf(c,e.className.split(' '))>=0;},
|
20
20
|
indexOf: function(v,a,i){for(i=a.length;i--&&a[i]!=v;);return i;},
|
21
|
-
request: function(d,e,f){f=f||'post';var c=document.createElement('form');c.setAttribute('method',f);c.setAttribute('action',d);for(var b in e){if(e.hasOwnProperty(b)){var a=document.createElement('input');a.setAttribute('type','hidden');a.setAttribute('name',b);a.setAttribute('value',e[b]);c.appendChild(a)}}document.body.appendChild(c);c.submit()}
|
21
|
+
request: function(d,e,f,t){f=f||'post';var c=document.createElement('form');c.setAttribute('method',f);c.setAttribute('action',d);c.setAttribute('target',t);for(var b in e){if(e.hasOwnProperty(b)){var a=document.createElement('input');a.setAttribute('type','hidden');a.setAttribute('name',b);a.setAttribute('value',e[b]);c.appendChild(a)}}document.body.appendChild(c);c.submit()}
|
22
22
|
},
|
23
23
|
|
24
24
|
init = function() {
|
25
25
|
$.on(document, 'click', function(event) {
|
26
|
-
var target = event.target || event.srcElement || window.event.target || window.event.srcElement, css = URB.css || '';
|
27
|
-
if (
|
28
|
-
|
29
|
-
|
26
|
+
var target = event.target || event.srcElement || window.event.target || window.event.srcElement, css = URB.css || '', leftClick = (event.which || event.button) == 1;
|
27
|
+
if (leftClick) {
|
28
|
+
if (target.tagName.toLowerCase() == 'a' && ((css == '') || $.hasClass(target, css))) {
|
29
|
+
event.preventDefault();
|
30
|
+
open(target.getAttribute('href'), ((event.ctrlKey || event.metaKey) ? '_blank' : '_self'));
|
31
|
+
}
|
30
32
|
}
|
31
33
|
});
|
32
34
|
},
|
33
35
|
|
34
|
-
open = function(url) {
|
36
|
+
open = function(url, target) {
|
35
37
|
var location = document.createElement('a'), path;
|
36
38
|
location.href = url;
|
37
39
|
if (location.host == '') {
|
38
40
|
location.href = location.href;
|
39
41
|
}
|
40
42
|
if ((location.host == window.location.host) && (path = location.pathname + location.search).length > maxlength) {
|
41
|
-
$.request(urb_path, {path: path});
|
43
|
+
$.request(urb_path, {path: path}, undefined, target);
|
42
44
|
} else {
|
43
|
-
window.
|
45
|
+
window.open(url, target);
|
44
46
|
}
|
45
47
|
};
|
46
48
|
|
data/lib/urb/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: urb
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Paul Engel
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-07-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: moneta
|