dynaspan 0.1.0 → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: fe015e308bc55699d068d01a096f8e2f4964e2db
4
- data.tar.gz: 369852add27511b776be766f4a132bfeaa6ff573
3
+ metadata.gz: 594c27faf04b8c51de65d4f8e6101d0062b9b863
4
+ data.tar.gz: 6e5a1b2b1a091dc17f1e86a0d98af328caa8eb42
5
5
  SHA512:
6
- metadata.gz: 167c0cc24f7a2425dc2b8162759d1137fc5e576679ccd3bc77f4c101c79f16931f6dd05683197f27714038649380196e30ba2684b0289438ec81a7f19080df18
7
- data.tar.gz: a028f7e1b474d89d22331684b2b907137f753487f358d888dc83e95f005a66f9cd6ae1e5927d28e3eb4e5fc0c087662dfa424fcb4e9492f4c7600aa6fd5d4ae5
6
+ metadata.gz: 616eadcaff9b70872a1776a62f0879a3696e1609c6bbf045ed57370a279f89711dfad0979e7a52d371ebeee0c1185f79f1f31b2c105b82ac1a29ed1cf7e471b4
7
+ data.tar.gz: d663df0da430cab97a4c0b280276db167349eef59b252ab5cb4d42e9680d0b1f6109b03742e34de49f37e0417be7a5fd3fb0f14e05810068a148fb4f5b05d867
data/README.md CHANGED
@@ -23,7 +23,11 @@ Example #1:
23
23
  Example #2:
24
24
 
25
25
  dynaspan_text_field(profile, profile.websites, :url, '[edit]',
26
- {hidden_field: {page_name: 'page2'}, callback_on_update: "alert('Awesome!');"})
26
+ {
27
+ hidden_fields: {page_name: 'page2'},
28
+ callback_on_update: "alert('Awesome!');"
29
+ }
30
+ )
27
31
 
28
32
  This will show the value of note in the comment object as plain text. It can be clicked on to instantly become a text field input. And once unselected the `@article` object will update with its nested attribute object `comment` and its new value in the `note` attribute.
29
33
 
@@ -73,6 +77,22 @@ calling parents with selectors. Example usage:
73
77
 
74
78
  ###What's New
75
79
 
80
+ ####Version 0.1.1
81
+
82
+ Added a JavaScript callback that will **append** a Hash/Dictionary of the updated Dynaspan Object to the end of your
83
+ functions parameters. The method is named **callback_with_values**.
84
+
85
+ {
86
+ callback_with_values: "console.log();"
87
+ }
88
+
89
+ This will be called everytime the Dynaspan field submits and it will **inject** the following result **as the last parameter**:
90
+
91
+ {
92
+ ds_selector: "dyna_span_unique_label<#>",
93
+ ds_input: "the entered text from the input field"
94
+ }
95
+
76
96
  ####Version 0.1.0
77
97
 
78
98
  Added the same hidden_fields from version 0.0.8 to support non-nested Objects. You can use them now on anything.
@@ -29,16 +29,18 @@ module Dynaspan
29
29
  end
30
30
  edit_text = nil unless edit_text.is_a? String
31
31
  options = (parameters[-1].is_a?(Hash) ? parameters[-1] : {})
32
+ options.default = nil
32
33
  render(
33
34
  partial: "dynaspan/dynaspan_text_#{kind}",
34
35
  locals: {
35
- master_ds_object: master_ds_object,
36
- attr_object: attr_object,
37
- attrib: attrib,
38
- unique_ref_id: dynaspan_counter,
39
- dyna_span_edit_text: edit_text,
40
- hidden_fields: options[:hidden_fields],
41
- ds_callback_on_update: options[:callback_on_update]
36
+ master_ds_object: master_ds_object,
37
+ attr_object: attr_object,
38
+ attrib: attrib,
39
+ unique_ref_id: dynaspan_counter,
40
+ dyna_span_edit_text: edit_text,
41
+ hidden_fields: options[:hidden_fields],
42
+ ds_callback_on_update: options[:callback_on_update],
43
+ ds_callback_with_values: options[:callback_with_values]
42
44
  }
43
45
  )
44
46
  end
@@ -1,5 +1,5 @@
1
1
  <%# This is used through the helper method dynaspan_text_area %>
2
- <div id="dyna_span_block<%= unique_ref_id %>" <%= "data-ds-callback-on-update=\"#{ds_callback_on_update}\" " if ds_callback_on_update.present? %>class='dyna-span<%= ' ds-content-present' if (attr_object.try(attrib).present? || master_ds_object.try(attrib).present?) %>'>
2
+ <div id="dyna_span_block<%= unique_ref_id %>" <%= "data-ds-callback-on-update=\"#{ds_callback_on_update}\" " if ds_callback_on_update.present? %> <%= "data-ds-callback-with-values=\"#{ds_callback_with_values}\" " if ds_callback_with_values.present? %>class='dyna-span<%= ' ds-content-present' if (attr_object.try(attrib).present? || master_ds_object.try(attrib).present?) %>'>
3
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
4
  <div id="<%= "dyna_span_div#{unique_ref_id}" %>" style="display:none;">
5
5
  <%= form_for(master_ds_object, method: :patch, remote: true, authenticity_token: true) do |f| %>
@@ -1,5 +1,5 @@
1
1
  <%# This is used through the helper method dynaspan_text_field %>
2
- <div id="dyna_span_block<%= unique_ref_id %>" <%= "data-ds-callback-on-update=\"#{ds_callback_on_update}\" " if ds_callback_on_update.present? %>class='dyna-span<%= ' ds-content-present' if (attr_object.try(attrib).present? || master_ds_object.try(attrib).present?) %>'>
2
+ <div id="dyna_span_block<%= unique_ref_id %>" <%= "data-ds-callback-on-update=\"#{ds_callback_on_update}\" " if ds_callback_on_update.present? %> <%= "data-ds-callback-with-values=\"#{ds_callback_with_values}\" " if ds_callback_with_values.present? %>class='dyna-span<%= ' ds-content-present' if (attr_object.try(attrib).present? || master_ds_object.try(attrib).present?) %>'>
3
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
4
  <div id="<%= "dyna_span_div#{unique_ref_id}" %>" style="display:none;">
5
5
  <%= form_for(master_ds_object, method: :patch, remote: true, authenticity_token: true) do |f| %>
@@ -1,3 +1,3 @@
1
1
  module Dynaspan
2
- VERSION = '0.1.0'
2
+ VERSION = '0.1.1'
3
3
  end
@@ -3,6 +3,18 @@
3
3
  (function($){
4
4
  $.fn.dynaspan = function(){};
5
5
 
6
+ $.fn.dynaspan.appendParameter = function(excmd,append_param){
7
+ var regExp = [/\(([^)]+)\);?$/,/\(\);?$/];
8
+ var matches = [regExp[0].exec(excmd), regExp[1].exec(excmd)];
9
+ if (matches[0]){
10
+ return(excmd.replace(matches[0][0],'(' + matches[0][1] + ',' + append_param +');'));
11
+ } else if (matches[1]) {
12
+ return(excmd.replace(matches[1][0],'(' + append_param + ');'));
13
+ } else {
14
+ return excmd.replace(/;$/,'') + '(' + append_param + ');';
15
+ }
16
+ };
17
+
6
18
  $.fn.dynaspan.upLast = function(uniq_id_ref){
7
19
  $('#dyna_span_field_val_' + uniq_id_ref).val($('#last_dyna_span_val_' + uniq_id_ref).val());
8
20
  };
@@ -26,6 +38,14 @@
26
38
  } else {
27
39
  ds_block.addClass("ds-content-present")
28
40
  }
41
+ if (ds_block.data('dsCallbackWithValues')){
42
+ eval(
43
+ $.fn.dynaspan.appendParameter(
44
+ ds_block.data('dsCallbackWithValues'),
45
+ "{ds_selector:'#dyna_span_block" + uniq_id_ref + "',ds_input:'" + field_val + "'}"
46
+ )
47
+ )
48
+ }
29
49
  if (ds_block.data('dsCallbackOnUpdate')){
30
50
  eval(ds_block.data('dsCallbackOnUpdate'))
31
51
  }
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.1.0
4
+ version: 0.1.1
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-30 00:00:00.000000000 Z
11
+ date: 2014-12-31 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: