wiselinks 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/app/views/layouts/wiselinks.html.erb +1 -0
- data/lib/assets/javascripts/wiselinks.js.coffee +13 -9
- data/lib/layout.rb +20 -0
- data/lib/wiselinks.rb +6 -0
- data/wiselinks.gemspec +4 -2
- metadata +5 -3
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.2
|
@@ -0,0 +1 @@
|
|
1
|
+
<%= yield %>
|
@@ -1,9 +1,12 @@
|
|
1
1
|
#= require _history
|
2
2
|
|
3
|
+
String.prototype.ends_with = (suffix) ->
|
4
|
+
this.indexOf(suffix, this.length - suffix.length) != -1
|
5
|
+
|
3
6
|
class Wiselinks
|
4
7
|
constructor: (@$target = $('body'), options = {}) ->
|
5
8
|
# check that JQuery or Zepto.js are available
|
6
|
-
throw "Load JQuery
|
9
|
+
throw "Load JQuery to use Wiselinks" unless window.jQuery?
|
7
10
|
|
8
11
|
self = this
|
9
12
|
|
@@ -21,7 +24,7 @@ class Wiselinks
|
|
21
24
|
|
22
25
|
$(document).on(
|
23
26
|
"submit", "form[data-push], form[data-replace]"
|
24
|
-
(event) ->
|
27
|
+
(event) ->
|
25
28
|
self._process_form($(this))
|
26
29
|
|
27
30
|
event.preventDefault()
|
@@ -52,29 +55,30 @@ class Wiselinks
|
|
52
55
|
self = this
|
53
56
|
$(document).trigger('wiselinks:loading')
|
54
57
|
|
55
|
-
console.log @$target
|
56
|
-
|
57
58
|
$.ajax(
|
58
59
|
url: url
|
59
60
|
headers:
|
60
61
|
'X-Slide': slide
|
61
|
-
success: (data) ->
|
62
|
+
success: (data, status, xhr) ->
|
63
|
+
document.title = xhr.getResponseHeader('X-Title')
|
64
|
+
|
62
65
|
$target = if target? then $(target) else self.$target
|
63
66
|
$target.html(data)
|
64
67
|
|
65
68
|
$(document).trigger('wiselinks:success', data)
|
66
|
-
error: (xhr)->
|
69
|
+
error: (xhr, status, error)->
|
67
70
|
$(document).trigger('wiselinks:error', xhr)
|
68
71
|
dataType: "html"
|
69
72
|
)
|
70
73
|
|
71
|
-
_process_form: ($form) ->
|
74
|
+
_process_form: ($form) ->
|
72
75
|
self = this
|
73
76
|
|
74
77
|
$disable = $form.find(':input[value=""]')
|
75
78
|
$disable.attr('disabled', true);
|
76
79
|
|
77
80
|
params = {}
|
81
|
+
|
78
82
|
for item in $form.serializeArray()
|
79
83
|
if item.name != 'utf8'
|
80
84
|
name = if item.name.ends_with('[]')
|
@@ -88,8 +92,8 @@ class Wiselinks
|
|
88
92
|
params[name] = item.value
|
89
93
|
|
90
94
|
serialized = []
|
91
|
-
for key
|
92
|
-
serialized.push("#{params[key]}
|
95
|
+
for key of params
|
96
|
+
serialized.push("#{key}=#{params[key]}")
|
93
97
|
|
94
98
|
serialized = serialized.join('&').replace(/%|!/g, '')
|
95
99
|
|
data/lib/layout.rb
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
module Wiselinks
|
2
|
+
module Layout
|
3
|
+
|
4
|
+
def wiselinks_layout
|
5
|
+
'wiselinks'
|
6
|
+
end
|
7
|
+
|
8
|
+
def render(options = {}, *args, &block)
|
9
|
+
if request.headers['X-Slide'].present?
|
10
|
+
if request.headers['X-Slide'] == 'partial'
|
11
|
+
options[:partial] ||= action_name
|
12
|
+
else
|
13
|
+
options[:layout] = self.wiselinks_layout
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
super
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
data/lib/wiselinks.rb
CHANGED
data/wiselinks.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = "wiselinks"
|
8
|
-
s.version = "0.0.
|
8
|
+
s.version = "0.0.2"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Igor Alexandrov", "Alexey Solilin", "Julia Egorova"]
|
12
|
-
s.date = "2012-11-
|
12
|
+
s.date = "2012-11-28"
|
13
13
|
s.email = "igor.alexandrov@gmail.com"
|
14
14
|
s.extra_rdoc_files = [
|
15
15
|
"LICENSE.txt",
|
@@ -23,8 +23,10 @@ Gem::Specification.new do |s|
|
|
23
23
|
"README.rdoc",
|
24
24
|
"Rakefile",
|
25
25
|
"VERSION",
|
26
|
+
"app/views/layouts/wiselinks.html.erb",
|
26
27
|
"lib/assets/javascripts/_history.js",
|
27
28
|
"lib/assets/javascripts/wiselinks.js.coffee",
|
29
|
+
"lib/layout.rb",
|
28
30
|
"lib/wiselinks.rb",
|
29
31
|
"test/helper.rb",
|
30
32
|
"test/test_wiselinks.rb",
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: wiselinks
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -11,7 +11,7 @@ authors:
|
|
11
11
|
autorequire:
|
12
12
|
bindir: bin
|
13
13
|
cert_chain: []
|
14
|
-
date: 2012-11-
|
14
|
+
date: 2012-11-28 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: shoulda
|
@@ -92,8 +92,10 @@ files:
|
|
92
92
|
- README.rdoc
|
93
93
|
- Rakefile
|
94
94
|
- VERSION
|
95
|
+
- app/views/layouts/wiselinks.html.erb
|
95
96
|
- lib/assets/javascripts/_history.js
|
96
97
|
- lib/assets/javascripts/wiselinks.js.coffee
|
98
|
+
- lib/layout.rb
|
97
99
|
- lib/wiselinks.rb
|
98
100
|
- test/helper.rb
|
99
101
|
- test/test_wiselinks.rb
|
@@ -113,7 +115,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
113
115
|
version: '0'
|
114
116
|
segments:
|
115
117
|
- 0
|
116
|
-
hash:
|
118
|
+
hash: -2052284491769893778
|
117
119
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
118
120
|
none: false
|
119
121
|
requirements:
|