rostra 0.1.4 → 0.1.5

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.
@@ -29,9 +29,33 @@ var custom_validation_callbacks = {
29
29
  field.find('.error').text("can't be blank");
30
30
  }
31
31
  }
32
+ },
33
+
34
+ // Custom valiation form Tiny MCE wysiwyg.
35
+ //
36
+ wysiwyg: function(element, event_data) {
37
+ var wysiwyg_textarea = element.hasClass('wysiwyg');
38
+ if (wysiwyg_textarea) {
39
+ var textarea_field = element.closest('.field');
40
+ var editor = tinyMCE.get(element.attr('id'))
41
+ textarea_field.append('<span class="error"></span>'); // Cuase sometimes it doesn't have a error span. Why?
42
+
43
+ var wysiwyg_has_content = function() {
44
+ return $.trim( editor.getContent().replace(/<[^>]+>/g, '') ) ? true : false;
45
+ }
46
+
47
+ element.data('valid', wysiwyg_has_content());
48
+
49
+ editor.onKeyUp.add(function(ed, e) {
50
+ var error_message = wysiwyg_has_content() ? '' : "can't be blank";
51
+ textarea_field.find('.error').text(error_message);
52
+ });
53
+ }
32
54
  }
55
+
33
56
  };
34
57
 
35
58
  clientSideValidations.callbacks.element.after = function(element, event_data) {
36
59
  custom_validation_callbacks.taglist(element, event_data);
60
+ custom_validation_callbacks.wysiwyg(element, event_data);
37
61
  }
@@ -2,11 +2,11 @@
2
2
 
3
3
  <div id="page_content">
4
4
  <div id="questions">
5
- <% if @questions.empty? %>
6
- <h3>No questions have been asked.</h3>
7
-
5
+ <% if Rostra::Question.count.zero? %>
6
+ <h3>Sorry! No questions have been asked.</h3>
7
+ <% elsif @questions.empty? %>
8
+ <h3>Sorry! No questions found.</h3>
8
9
  <% else %>
9
-
10
10
  <% @questions.each do |question| %>
11
11
  <div class="question">
12
12
 
@@ -1,3 +1,3 @@
1
1
  module Rostra
2
- VERSION = "0.1.4"
2
+ VERSION = "0.1.5"
3
3
  end
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: rostra
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.1.4
5
+ version: 0.1.5
6
6
  platform: ruby
7
7
  authors:
8
8
  - Cory Schires