effective_regions 1.6.7 → 1.6.8

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: 89fc6dc3f1fcfcde70131c1626294ffd3c6d1603
4
- data.tar.gz: 2b13278aa0e5ef8e7abfeb5bae3b957fce924a1c
3
+ metadata.gz: 329d8f65af81f3ddf8c52b829e5afee575256b57
4
+ data.tar.gz: 92b3db27ca82f3471272d25aa1dea94fa3d4a641
5
5
  SHA512:
6
- metadata.gz: d71fe5229c3e116decea52b1a7e424f11f1489ff0927fb1fc826f5822c702d5b1eaaf6916e2d50fe0a4ccc5b85b0863fa3ff2a4508541d642e6ae975ef4a90cb
7
- data.tar.gz: e0e14e76f52ed1453c4f5045020992b2530a4ea9b4685e8eb8fb6d55aee8c543b0fd51ecc8fd8cc3370986df975473edfe7d607b6849e6d7f2055d2e11b8169d
6
+ metadata.gz: 5d6ea4d77501b53c0b37023c5e4a8d4838b134c42f8425673df0e70f1818953060b1c4a25e204a6fa9c14a6a5c03e4c1b323760513c5f46477b86ced1f16eea0
7
+ data.tar.gz: 65726b395dab84db6a267984576ffd14daf85a0546b03c0b8e19cd6f8b750b62bcfd5dceb76e2903370135cca542df940d4d3b303c154dc875a32520c8298004
data/README.md CHANGED
@@ -552,6 +552,13 @@ and then in your routes.rb:
552
552
  get '/effective/snippets/posts', :to => 'effective/snippets/posts#index'
553
553
  ```
554
554
 
555
+ ### Summary
556
+
557
+ This Snippet makes an AJAX request to the server and receives a JSON response containing all the Posts. The Posts are displayed in a select drop-down, and when one is chosen, inserted into the given region.
558
+
559
+
560
+ ## Snippet Usage
561
+
555
562
  ### Default Content
556
563
 
557
564
  We can pre-populate an effective_region's default content with some posts. These posts will be displayed until a user edits that region and selects some specific posts.
@@ -566,9 +573,39 @@ We can pre-populate an effective_region's default content with some posts. Thes
566
573
 
567
574
  Using the `snippet_locals` approach as above prevents an N+1 query when each snippet has to look up its own post.
568
575
 
569
- ### Summary
576
+ ### Inline
570
577
 
571
- This Snippet makes an AJAX request to the server and receives a JSON response containing all the Posts. The Posts are displayed in a select drop-down, and when one is chosen, inserted into the given region.
578
+ By default, all snippets are wrapped with a block level `<div>`.
579
+
580
+ To to use an inline `<span>` wrapper instead, change the snippet model file:
581
+
582
+ ```ruby
583
+ module Effective
584
+ module Snippets
585
+ class CurrentUserInfo < Snippet
586
+ attribute :display_method, String
587
+
588
+ def snippet_tag
589
+ :span
590
+ end
591
+
592
+ end
593
+ end
594
+ end
595
+ ```
596
+
597
+ ### Javascript event
598
+
599
+ Watch for the `effectiveSnippetReady` event to run custom javascript after a snippet has been initialized.
600
+
601
+ This event is fired once for each snippet, after the page has loaded, and the snippet is completely displayed.
602
+
603
+ It is also fired after the OK button is clicked on the dialog screen.
604
+
605
+ ```coffeescript
606
+ $(document).on 'effectiveSnippetReady', (event, snippet, element) ->
607
+ $(element).html('overwrite the entire content')
608
+ ```
572
609
 
573
610
 
574
611
  ## Templates
@@ -58,7 +58,7 @@ module Effective
58
58
 
59
59
  # Hand off the appropriate params to EffectivePages gem
60
60
  if defined?(EffectivePages) && params[:effective_menus].present?
61
- Effective::Menu.update_from_effective_regions!(params[:effective_menus])
61
+ Effective::Menu.update_from_effective_regions!(menu_params)
62
62
  end
63
63
 
64
64
  response[:refresh] = true if refresh_page
@@ -138,6 +138,14 @@ module Effective
138
138
 
139
139
  end
140
140
 
141
+ def menu_params
142
+ begin
143
+ params.require(:effective_menus).permit!
144
+ rescue => e
145
+ params[:effective_menus]
146
+ end
147
+ end
148
+
141
149
  end
142
150
  end
143
151
 
@@ -103,6 +103,11 @@ module EffectiveRegionsHelper
103
103
  content = render(:partial => snippet.to_partial_path, :object => snippet, :locals => {:snippet => snippet})
104
104
  end
105
105
 
106
+ if content.present?
107
+ binding.pry
108
+ content += render(:partial => 'effective_regions/snippet_ready_javascript', :locals => {:snippet => snippet})
109
+ end
110
+
106
111
  if effectively_editing? && can_edit
107
112
  content_tag(snippet.snippet_tag, content, :data => {'effective-snippet' => snippet.class_name, 'snippet-data' => snippet.data().to_json})
108
113
  else
@@ -0,0 +1,7 @@
1
+ :javascript
2
+ $(document).on('ready', function() {
3
+ console.log;
4
+ console.log($(this));
5
+ console.log($(this).parent('script').parent());
6
+ $(document).trigger('effectiveSnippetReady');
7
+ });
@@ -1,3 +1,3 @@
1
1
  module EffectiveRegions
2
- VERSION = '1.6.7'.freeze
2
+ VERSION = '1.6.8'.freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: effective_regions
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.6.7
4
+ version: 1.6.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Code and Effect
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-12-08 00:00:00.000000000 Z
11
+ date: 2016-02-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -74,6 +74,9 @@ executables: []
74
74
  extensions: []
75
75
  extra_rdoc_files: []
76
76
  files:
77
+ - MIT-LICENSE
78
+ - README.md
79
+ - Rakefile
77
80
  - app/assets/images/effective/templates/image_and_title.png
78
81
  - app/assets/javascripts/effective/snippets/current_date_time.js.coffee
79
82
  - app/assets/javascripts/effective/snippets/current_user_info.js.coffee
@@ -92,23 +95,24 @@ files:
92
95
  - app/views/effective/snippets/_current_user_info.html.haml
93
96
  - app/views/effective/templates/_image_and_title.html.haml
94
97
  - app/views/effective_regions/_include_tags_javascript.html.haml
98
+ - app/views/effective_regions/_snippet_ready_javascript.html.haml
95
99
  - config/routes.rb
96
100
  - db/migrate/01_create_effective_regions.rb.erb
101
+ - lib/effective_regions.rb
97
102
  - lib/effective_regions/engine.rb
98
103
  - lib/effective_regions/version.rb
99
- - lib/effective_regions.rb
100
104
  - lib/generators/effective_regions/install_generator.rb
101
- - lib/generators/templates/effective_regions.rb
102
105
  - lib/generators/templates/README
106
+ - lib/generators/templates/effective_regions.rb
103
107
  - lib/tasks/effective_regions_tasks.rake
104
- - MIT-LICENSE
105
- - Rakefile
106
- - README.md
108
+ - spec/dummy/README.rdoc
109
+ - spec/dummy/Rakefile
107
110
  - spec/dummy/app/assets/javascripts/application.js
108
111
  - spec/dummy/app/assets/stylesheets/application.css
109
112
  - spec/dummy/app/controllers/application_controller.rb
110
113
  - spec/dummy/app/helpers/application_helper.rb
111
114
  - spec/dummy/app/views/layouts/application.html.erb
115
+ - spec/dummy/config.ru
112
116
  - spec/dummy/config/application.rb
113
117
  - spec/dummy/config/boot.rb
114
118
  - spec/dummy/config/database.yml
@@ -124,7 +128,6 @@ files:
124
128
  - spec/dummy/config/initializers/wrap_parameters.rb
125
129
  - spec/dummy/config/locales/en.yml
126
130
  - spec/dummy/config/routes.rb
127
- - spec/dummy/config.ru
128
131
  - spec/dummy/db/development.sqlite3
129
132
  - spec/dummy/db/schema.rb
130
133
  - spec/dummy/db/test.sqlite3
@@ -134,8 +137,6 @@ files:
134
137
  - spec/dummy/public/422.html
135
138
  - spec/dummy/public/500.html
136
139
  - spec/dummy/public/favicon.ico
137
- - spec/dummy/Rakefile
138
- - spec/dummy/README.rdoc
139
140
  - spec/dummy/script/rails
140
141
  - spec/effective_regions_spec.rb
141
142
  - spec/spec_helper.rb
@@ -160,7 +161,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
160
161
  version: '0'
161
162
  requirements: []
162
163
  rubyforge_project:
163
- rubygems_version: 2.0.14
164
+ rubygems_version: 2.4.6
164
165
  signing_key:
165
166
  specification_version: 4
166
167
  summary: Create editable content regions within your existing, ordinary ActionView::Base