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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 49e0c7307a4aaa55cff2d0966fd46cc6dbfec210
4
- data.tar.gz: 2e6049f9c65480051895b2c1171b6dac49edaa10
3
+ metadata.gz: bc5312b4df9cd626e5ef11f6ca4b5c397041ee37
4
+ data.tar.gz: 9f5ddb6ff7138112f92f637dd6b2233b2063201c
5
5
  SHA512:
6
- metadata.gz: 76f858cdc40b7d37b0540713005185d5b5639d09503b67f37ed7ad1991df2222a91620edfea95d5873260e40f6dc33296d9e42863d0791b5ed40aec88bed4362
7
- data.tar.gz: 95c613583563e022d5e8f0bb6a6be14e79271b9e5f26d8365f610975800351d7541c0ffa323795d3744fc60f9eb736d42cab12e7b192d627f788f9742d32a84b
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', '~> 0.0.4'` to your Gemfile.
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
- <%= 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}" %>
3
- <div id="<%= "dyna_span_div#{unique_ref_id}" %>" class='dyna-span' style="display:none;">
4
- <%= form_for(master_ds_object, method: :patch, remote: true, authenticity_token: true) do |f| %>
5
- <% 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? %>
6
- <%= 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|%>
7
- <%= a.hidden_field :id, value: attr_object.id %>
8
- <%= 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}');" %>
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
- <% end %>
14
- </div>
15
- <%= 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;' %>
16
- <%= content_tag('div', dyna_span_edit_text, class: 'dyna-span-edit-text pull-right', onclick: "$().dynaspan.upShow('#{unique_ref_id}');", style: 'cursor:pointer;') %>
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
- <%= 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}" %>
3
- <div id="<%= "dyna_span_div#{unique_ref_id}" %>" class='dyna-span' style="display:none;">
4
- <%= form_for(master_ds_object, method: :patch, remote: true, authenticity_token: true) do |f| %>
5
- <% 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? %>
6
- <%= 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|%>
7
- <%= a.hidden_field :id, value: attr_object.id %>
8
- <%= 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}');" %>
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
- <% end %>
14
- </div>
15
- <%= 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;' %>
16
- <%= content_tag('div', dyna_span_edit_text, class: 'dyna-span-edit-text pull-right', onclick: "$().dynaspan.upShow('#{unique_ref_id}');", style: 'cursor:pointer;') %>
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>
@@ -13,5 +13,6 @@ Gem::Specification.new do |gem|
13
13
  gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
14
14
  gem.name = 'dynaspan'
15
15
  gem.require_paths = ['lib']
16
+ gem.required_ruby_version = '~> 2.0'
16
17
  gem.version = Dynaspan::VERSION
17
18
  end
@@ -1,3 +1,3 @@
1
1
  module Dynaspan
2
- VERSION = '0.0.5'
2
+ VERSION = '0.0.6'
3
3
  end
@@ -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.5
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-09 00:00:00.000000000 Z
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.4.1
59
+ rubygems_version: 2.3.0
60
60
  signing_key:
61
61
  specification_version: 4
62
62
  summary: Text to AJAX editing in place.