dynaspan 0.0.5 → 0.0.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +13 -1
- data/app/views/dynaspan/_dynaspan_text_area.html.erb +15 -13
- data/app/views/dynaspan/_dynaspan_text_field.html.erb +15 -13
- data/dynaspan.gemspec +1 -0
- data/lib/dynaspan/version.rb +1 -1
- data/vendor/assets/javascripts/dynaspan/dynaspan.js +5 -4
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bc5312b4df9cd626e5ef11f6ca4b5c397041ee37
|
4
|
+
data.tar.gz: 9f5ddb6ff7138112f92f637dd6b2233b2063201c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6a16ec5ce589adf54c733a39b4c818674d051ed941456b80aa4817c89bb83a02d73727eef2ed9197bed314a8c27d34ef43d1c8cb8d829a66f505cb29e6f81391
|
7
|
+
data.tar.gz: 578097b786f0eaee8579e2e8749a1a8c02d39a1dc9ed0831ce406c42d3262fdfa2fa5b537aba8c393a868e8b6cf7654f89e66a609fff08159ac3a7aa2a5c965f
|
data/README.md
CHANGED
@@ -1,4 +1,6 @@
|
|
1
1
|
##Dynaspan
|
2
|
+
[![Gem Version](https://badge.fury.io/rb/dynaspan.svg)](http://badge.fury.io/rb/dynaspan)
|
3
|
+
#####[JSFiddle Demo](http://jsfiddle.net/680v09y8/)
|
2
4
|
|
3
5
|
Dynaspan is an AJAX tool for Rails to update one field of any object without interfering with your website experience. The user will see the web page as normal text. Where ever you've placed a Dynaspan field people can click on the text and it transforms into text entry. As soon as the person moves away from that entry it sends the update to the server.
|
4
6
|
|
@@ -6,7 +8,7 @@ Dynaspan also accepts updating an attribute for a nested object, but only 1 leve
|
|
6
8
|
|
7
9
|
###Installation
|
8
10
|
|
9
|
-
- [ ] Add `gem 'dynaspan'
|
11
|
+
- [ ] Add `gem 'dynaspan'` to your Gemfile.
|
10
12
|
- [ ] Run `bundle`.
|
11
13
|
- [ ] Next add `include Dynaspan::ApplicationHelper` inside your **ApplicationHelper** module.
|
12
14
|
- [ ] Add `//= require dynaspan/dynaspan` to your **application.js** file.
|
@@ -41,6 +43,16 @@ The AJAX call will call the update method on your first Object parameter via PAT
|
|
41
43
|
|
42
44
|
-- Daniel P. Clark
|
43
45
|
|
46
|
+
###Styles
|
47
|
+
|
48
|
+
As of version 0.0.6 a class will be dynamically added/removed to a div tag containing the class "dyna-span".
|
49
|
+
That class is "ds-content-present". The purpose of this class is to allow CSS content styles depending on
|
50
|
+
whether your text exists or not. The '[edit]' text you can use as a parameter normally drops below the input
|
51
|
+
box. If you don't want it to drop you can style it with the proper CSS selector for content present. E.G.
|
52
|
+
`.ds-content-present > dyna-span-edit-text { margin-top:-18px; }` You can set the height to whatever your input
|
53
|
+
field height is to maintain the position of the edit text. With jQuery you can also set style for
|
54
|
+
hidden and visible changes.
|
55
|
+
|
44
56
|
###License
|
45
57
|
|
46
58
|
The MIT License (MIT)
|
@@ -1,16 +1,18 @@
|
|
1
1
|
<%# This is used through the helper method dynaspan_text_area %>
|
2
|
-
<%=
|
3
|
-
|
4
|
-
<%=
|
5
|
-
|
6
|
-
|
7
|
-
<%=
|
8
|
-
|
2
|
+
<div id="dyna_span_block<%= unique_ref_id %>" class='dyna-span<%= ' ds-content-present' if (attr_object.try(attrib).present? || master_ds_object.try(attrib).present?) %>'>
|
3
|
+
<%= hidden_field_tag "last_dyna_span_val_#{unique_ref_id}", attr_object.try(attrib) || master_ds_object.try(attrib), id: "last_dyna_span_val_#{unique_ref_id}" %>
|
4
|
+
<div id="<%= "dyna_span_div#{unique_ref_id}" %>" style="display:none;">
|
5
|
+
<%= form_for(master_ds_object, method: :patch, remote: true, authenticity_token: true) do |f| %>
|
6
|
+
<% if master_ds_object.nested_attributes_options.keys.any? {|i| i.to_s.=~(/#{attr_object.class.try(:model_name).try(:i18n_key).to_s}/) || i.to_s.=~(/#{attr_object.class.try(:table_name)}/) } and !attr_object.nil? %>
|
7
|
+
<%= f.fields_for master_ds_object.nested_attributes_options.keys.select {|i| i.to_s.=~(/#{attr_object.class.model_name.i18n_key.to_s}/) || i.to_s.=~(/#{attr_object.class.table_name}/) }.first, attr_object do |a|%>
|
8
|
+
<%= a.hidden_field :id, value: attr_object.id %>
|
9
|
+
<%= a.text_area attrib, id: "dyna_span_field_val_#{unique_ref_id}", class: 'dyna-span form-control dyna-span-input', onfocus: "$().dynaspan.upLast('#{unique_ref_id}');", onblur: "$().dynaspan.upHide('#{unique_ref_id}');" %>
|
10
|
+
<% end %>
|
11
|
+
<% else %>
|
12
|
+
<%= f.text_area attrib, id: "dyna_span_field_val_#{unique_ref_id}", class: 'dyna-span form-control dyna-span-input', onfocus: "$().dynaspan.upLast('#{unique_ref_id}');", onblur: "$().dynaspan.upHide('#{unique_ref_id}');" %>
|
9
13
|
<% end %>
|
10
|
-
<% else %>
|
11
|
-
<%= f.text_area attrib, id: "dyna_span_field_val_#{unique_ref_id}", class: 'dyna-span form-control dyna-span-input', onfocus: "$().dynaspan.upLast('#{unique_ref_id}');", onblur: "$().dynaspan.upHide('#{unique_ref_id}');" %>
|
12
14
|
<% end %>
|
13
|
-
|
14
|
-
|
15
|
-
<%= content_tag
|
16
|
-
|
15
|
+
</div>
|
16
|
+
<%= content_tag 'span', attr_object.try(attrib) || master_ds_object.try(attrib), id: "dyna_span_span#{unique_ref_id}", onclick: "$().dynaspan.upShow('#{unique_ref_id}');", class: 'dyna-span dyna-span-text', style: 'display:block;' %>
|
17
|
+
<%= content_tag('div', dyna_span_edit_text, class: 'dyna-span-edit-text pull-right', onclick: "$().dynaspan.upShow('#{unique_ref_id}');", style: 'cursor:pointer;') %>
|
18
|
+
</div>
|
@@ -1,16 +1,18 @@
|
|
1
1
|
<%# This is used through the helper method dynaspan_text_field %>
|
2
|
-
<%=
|
3
|
-
|
4
|
-
<%=
|
5
|
-
|
6
|
-
|
7
|
-
<%=
|
8
|
-
|
2
|
+
<div id="dyna_span_block<%= unique_ref_id %>" class='dyna-span<%= ' ds-content-present' if (attr_object.try(attrib).present? || master_ds_object.try(attrib).present?) %>'>
|
3
|
+
<%= hidden_field_tag "last_dyna_span_val_#{unique_ref_id}", attr_object.try(attrib) || master_ds_object.try(attrib), id: "last_dyna_span_val_#{unique_ref_id}" %>
|
4
|
+
<div id="<%= "dyna_span_div#{unique_ref_id}" %>" style="display:none;">
|
5
|
+
<%= form_for(master_ds_object, method: :patch, remote: true, authenticity_token: true) do |f| %>
|
6
|
+
<% if master_ds_object.nested_attributes_options.keys.any? {|i| i.to_s.=~(/#{attr_object.class.try(:model_name).try(:i18n_key).to_s}/) || i.to_s.=~(/#{attr_object.class.try(:table_name)}/) } and !attr_object.nil? %>
|
7
|
+
<%= f.fields_for master_ds_object.nested_attributes_options.keys.select {|i| i.to_s.=~(/#{attr_object.class.model_name.i18n_key.to_s}/) || i.to_s.=~(/#{attr_object.class.table_name}/) }.first, attr_object do |a|%>
|
8
|
+
<%= a.hidden_field :id, value: attr_object.id %>
|
9
|
+
<%= a.text_field attrib, id: "dyna_span_field_val_#{unique_ref_id}", class: 'dyna-span form-control dyna-span-input', onfocus: "$().dynaspan.upLast('#{unique_ref_id}');", onblur: "$().dynaspan.upHide('#{unique_ref_id}');" %>
|
10
|
+
<% end %>
|
11
|
+
<% else %>
|
12
|
+
<%= f.text_field attrib, id: "dyna_span_field_val_#{unique_ref_id}", class: 'dyna-span form-control dyna-span-input', onfocus: "$().dynaspan.upLast('#{unique_ref_id}');", onblur: "$().dynaspan.upHide('#{unique_ref_id}');" %>
|
9
13
|
<% end %>
|
10
|
-
<% else %>
|
11
|
-
<%= f.text_field attrib, id: "dyna_span_field_val_#{unique_ref_id}", class: 'dyna-span form-control dyna-span-input', onfocus: "$().dynaspan.upLast('#{unique_ref_id}');", onblur: "$().dynaspan.upHide('#{unique_ref_id}');" %>
|
12
14
|
<% end %>
|
13
|
-
|
14
|
-
|
15
|
-
<%= content_tag
|
16
|
-
|
15
|
+
</div>
|
16
|
+
<%= content_tag 'span', attr_object.try(attrib) || master_ds_object.try(attrib), id: "dyna_span_span#{unique_ref_id}", onclick: "$().dynaspan.upShow('#{unique_ref_id}');", class: 'dyna-span dyna-span-text', style: 'display:block;' %>
|
17
|
+
<%= content_tag('div', dyna_span_edit_text, class: 'dyna-span-edit-text pull-right', onclick: "$().dynaspan.upShow('#{unique_ref_id}');", style: 'cursor:pointer;') %>
|
18
|
+
</div>
|
data/dynaspan.gemspec
CHANGED
data/lib/dynaspan/version.rb
CHANGED
@@ -8,12 +8,8 @@
|
|
8
8
|
};
|
9
9
|
|
10
10
|
$.fn.dynaspan.upShow = function(uniq_id_ref){
|
11
|
-
//setTimeout(
|
12
|
-
// function(){
|
13
11
|
$('#dyna_span_div' + uniq_id_ref).show().find('.dyna-span-input').focus();
|
14
12
|
$('#dyna_span_span' + uniq_id_ref).hide();
|
15
|
-
// }, 0
|
16
|
-
//);
|
17
13
|
};
|
18
14
|
|
19
15
|
$.fn.dynaspan.upHide = function(uniq_id_ref){
|
@@ -22,5 +18,10 @@
|
|
22
18
|
$('#last_dyna_span_val_' + uniq_id_ref).val(field_val);
|
23
19
|
$('#dyna_span_span' + uniq_id_ref).show().html(field_val);
|
24
20
|
$('#dyna_span_div' + uniq_id_ref).hide();
|
21
|
+
if (field_val.length == 0){
|
22
|
+
$("#dyna_span_block" + uniq_id_ref).removeClass("ds-content-present")
|
23
|
+
} else {
|
24
|
+
$("#dyna_span_block" + uniq_id_ref).addClass("ds-content-present")
|
25
|
+
}
|
25
26
|
};
|
26
27
|
})(jQuery);
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dynaspan
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Daniel P. Clark
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-12-
|
11
|
+
date: 2014-12-22 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: In place text editing with AJAX substituting text to input field.
|
14
14
|
email:
|
@@ -46,9 +46,9 @@ require_paths:
|
|
46
46
|
- lib
|
47
47
|
required_ruby_version: !ruby/object:Gem::Requirement
|
48
48
|
requirements:
|
49
|
-
- - "
|
49
|
+
- - "~>"
|
50
50
|
- !ruby/object:Gem::Version
|
51
|
-
version: '0'
|
51
|
+
version: '2.0'
|
52
52
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
53
53
|
requirements:
|
54
54
|
- - ">="
|
@@ -56,7 +56,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
56
56
|
version: '0'
|
57
57
|
requirements: []
|
58
58
|
rubyforge_project:
|
59
|
-
rubygems_version: 2.
|
59
|
+
rubygems_version: 2.3.0
|
60
60
|
signing_key:
|
61
61
|
specification_version: 4
|
62
62
|
summary: Text to AJAX editing in place.
|