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 CHANGED
@@ -1 +1 @@
1
- 0.0.1
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 or Zepto.js to use Wiselinks" unless window.JQuery? || window.Zepto?
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 in params
92
- serialized.push("#{params[key]}=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
@@ -1,5 +1,11 @@
1
+ require 'layout'
2
+
1
3
  module Wiselinks
2
4
  class Engine < ::Rails::Engine
5
+
6
+ initializer "wiselinks.register" do
7
+ ActionController::Base.send :include, Layout
8
+ end
3
9
 
4
10
  end
5
11
  end
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.1"
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-26"
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.1
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-26 00:00:00.000000000 Z
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: 4285868062171506601
118
+ hash: -2052284491769893778
117
119
  required_rubygems_version: !ruby/object:Gem::Requirement
118
120
  none: false
119
121
  requirements: