lolita 3.1.5 → 3.1.6

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.
Files changed (45) hide show
  1. data/Gemfile +2 -4
  2. data/History.rdoc +19 -2
  3. data/README.rdoc +3 -0
  4. data/VERSION +1 -1
  5. data/app/controllers/lolita/rest_controller.rb +7 -2
  6. data/app/views/components/lolita/configuration/column/_sort.html.erb +1 -1
  7. data/app/views/components/lolita/configuration/columns/_last.html.erb +2 -2
  8. data/app/views/components/lolita/configuration/field/string/text/_display.html.erb +2 -18
  9. data/app/views/components/lolita/configuration/list/_new_resource.html.erb +1 -1
  10. data/app/views/components/lolita/configuration/list/_title.html.erb +1 -1
  11. data/app/views/components/lolita/configuration/tabs/_display.html.erb +0 -1
  12. data/app/views/components/lolita/navigation/_tree.html.erb +10 -6
  13. data/app/views/components/lolita/shared/_flash.html.erb +4 -12
  14. data/app/views/layouts/lolita/application.html.erb +8 -4
  15. data/config/locales/default/lv.yml +181 -0
  16. data/config/locales/en.yml +5 -0
  17. data/config/locales/lv.yml +21 -0
  18. data/lib/lolita/adapter/active_record.rb +1 -1
  19. data/lib/lolita/adapter/mongoid.rb +1 -1
  20. data/lib/lolita/configuration/column.rb +28 -5
  21. data/lib/lolita/configuration/columns.rb +4 -4
  22. data/lib/lolita/configuration/field.rb +6 -1
  23. data/lib/lolita/configuration/list.rb +10 -10
  24. data/lib/lolita/configuration/tab.rb +9 -1
  25. data/lib/lolita/hooks.rb +34 -4
  26. data/lib/lolita/rails.rb +2 -3
  27. data/lib/lolita/rails/all.rb +3 -0
  28. data/lib/lolita/rails/routes.rb +1 -1
  29. data/lib/lolita/support/formatter.rb +2 -2
  30. data/lib/lolita/support/formatter/rails.rb +2 -2
  31. data/lolita.gemspec +17 -9
  32. data/public/javascripts/jquery-1.6.min.js +16 -0
  33. data/public/javascripts/jquery-ui-1.8.13.min.js +407 -0
  34. data/public/javascripts/lolita/main.js +27 -1
  35. data/public/javascripts/lolita/tab.js +0 -3
  36. data/public/javascripts/tinymce/utils/editable_selects.js +70 -0
  37. data/public/javascripts/tinymce/utils/form_utils.js +210 -0
  38. data/public/javascripts/tinymce/utils/mctabs.js +162 -0
  39. data/public/javascripts/tinymce/utils/validate.js +252 -0
  40. data/public/javascripts/tinymce_config.js +15 -0
  41. data/spec/configuration/column_spec.rb +40 -8
  42. data/spec/configuration/columns_spec.rb +1 -1
  43. data/spec/support/formatter_spec.rb +2 -2
  44. metadata +16 -8
  45. data/public/javascripts/jquery-1.5.1.min.js +0 -16
@@ -0,0 +1,252 @@
1
+ /**
2
+ * validate.js
3
+ *
4
+ * Copyright 2009, Moxiecode Systems AB
5
+ * Released under LGPL License.
6
+ *
7
+ * License: http://tinymce.moxiecode.com/license
8
+ * Contributing: http://tinymce.moxiecode.com/contributing
9
+ */
10
+
11
+ /**
12
+ // String validation:
13
+
14
+ if (!Validator.isEmail('myemail'))
15
+ alert('Invalid email.');
16
+
17
+ // Form validation:
18
+
19
+ var f = document.forms['myform'];
20
+
21
+ if (!Validator.isEmail(f.myemail))
22
+ alert('Invalid email.');
23
+ */
24
+
25
+ var Validator = {
26
+ isEmail : function(s) {
27
+ return this.test(s, '^[-!#$%&\'*+\\./0-9=?A-Z^_`a-z{|}~]+@[-!#$%&\'*+\\/0-9=?A-Z^_`a-z{|}~]+\.[-!#$%&\'*+\\./0-9=?A-Z^_`a-z{|}~]+$');
28
+ },
29
+
30
+ isAbsUrl : function(s) {
31
+ return this.test(s, '^(news|telnet|nttp|file|http|ftp|https)://[-A-Za-z0-9\\.]+\\/?.*$');
32
+ },
33
+
34
+ isSize : function(s) {
35
+ return this.test(s, '^[0-9.]+(%|in|cm|mm|em|ex|pt|pc|px)?$');
36
+ },
37
+
38
+ isId : function(s) {
39
+ return this.test(s, '^[A-Za-z_]([A-Za-z0-9_])*$');
40
+ },
41
+
42
+ isEmpty : function(s) {
43
+ var nl, i;
44
+
45
+ if (s.nodeName == 'SELECT' && s.selectedIndex < 1)
46
+ return true;
47
+
48
+ if (s.type == 'checkbox' && !s.checked)
49
+ return true;
50
+
51
+ if (s.type == 'radio') {
52
+ for (i=0, nl = s.form.elements; i<nl.length; i++) {
53
+ if (nl[i].type == "radio" && nl[i].name == s.name && nl[i].checked)
54
+ return false;
55
+ }
56
+
57
+ return true;
58
+ }
59
+
60
+ return new RegExp('^\\s*$').test(s.nodeType == 1 ? s.value : s);
61
+ },
62
+
63
+ isNumber : function(s, d) {
64
+ return !isNaN(s.nodeType == 1 ? s.value : s) && (!d || !this.test(s, '^-?[0-9]*\\.[0-9]*$'));
65
+ },
66
+
67
+ test : function(s, p) {
68
+ s = s.nodeType == 1 ? s.value : s;
69
+
70
+ return s == '' || new RegExp(p).test(s);
71
+ }
72
+ };
73
+
74
+ var AutoValidator = {
75
+ settings : {
76
+ id_cls : 'id',
77
+ int_cls : 'int',
78
+ url_cls : 'url',
79
+ number_cls : 'number',
80
+ email_cls : 'email',
81
+ size_cls : 'size',
82
+ required_cls : 'required',
83
+ invalid_cls : 'invalid',
84
+ min_cls : 'min',
85
+ max_cls : 'max'
86
+ },
87
+
88
+ init : function(s) {
89
+ var n;
90
+
91
+ for (n in s)
92
+ this.settings[n] = s[n];
93
+ },
94
+
95
+ validate : function(f) {
96
+ var i, nl, s = this.settings, c = 0;
97
+
98
+ nl = this.tags(f, 'label');
99
+ for (i=0; i<nl.length; i++) {
100
+ this.removeClass(nl[i], s.invalid_cls);
101
+ nl[i].setAttribute('aria-invalid', false);
102
+ }
103
+
104
+ c += this.validateElms(f, 'input');
105
+ c += this.validateElms(f, 'select');
106
+ c += this.validateElms(f, 'textarea');
107
+
108
+ return c == 3;
109
+ },
110
+
111
+ invalidate : function(n) {
112
+ this.mark(n.form, n);
113
+ },
114
+
115
+ getErrorMessages : function(f) {
116
+ var nl, i, s = this.settings, field, msg, values, messages = [], ed = tinyMCEPopup.editor;
117
+ nl = this.tags(f, "label");
118
+ for (i=0; i<nl.length; i++) {
119
+ if (this.hasClass(nl[i], s.invalid_cls)) {
120
+ field = document.getElementById(nl[i].getAttribute("for"));
121
+ values = { field: nl[i].textContent };
122
+ if (this.hasClass(field, s.min_cls, true)) {
123
+ message = ed.getLang('invalid_data_min');
124
+ values.min = this.getNum(field, s.min_cls);
125
+ } else if (this.hasClass(field, s.number_cls)) {
126
+ message = ed.getLang('invalid_data_number');
127
+ } else if (this.hasClass(field, s.size_cls)) {
128
+ message = ed.getLang('invalid_data_size');
129
+ } else {
130
+ message = ed.getLang('invalid_data');
131
+ }
132
+
133
+ message = message.replace(/{\#([^}]+)\}/g, function(a, b) {
134
+ return values[b] || '{#' + b + '}';
135
+ });
136
+ messages.push(message);
137
+ }
138
+ }
139
+ return messages;
140
+ },
141
+
142
+ reset : function(e) {
143
+ var t = ['label', 'input', 'select', 'textarea'];
144
+ var i, j, nl, s = this.settings;
145
+
146
+ if (e == null)
147
+ return;
148
+
149
+ for (i=0; i<t.length; i++) {
150
+ nl = this.tags(e.form ? e.form : e, t[i]);
151
+ for (j=0; j<nl.length; j++) {
152
+ this.removeClass(nl[j], s.invalid_cls);
153
+ nl[j].setAttribute('aria-invalid', false);
154
+ }
155
+ }
156
+ },
157
+
158
+ validateElms : function(f, e) {
159
+ var nl, i, n, s = this.settings, st = true, va = Validator, v;
160
+
161
+ nl = this.tags(f, e);
162
+ for (i=0; i<nl.length; i++) {
163
+ n = nl[i];
164
+
165
+ this.removeClass(n, s.invalid_cls);
166
+
167
+ if (this.hasClass(n, s.required_cls) && va.isEmpty(n))
168
+ st = this.mark(f, n);
169
+
170
+ if (this.hasClass(n, s.number_cls) && !va.isNumber(n))
171
+ st = this.mark(f, n);
172
+
173
+ if (this.hasClass(n, s.int_cls) && !va.isNumber(n, true))
174
+ st = this.mark(f, n);
175
+
176
+ if (this.hasClass(n, s.url_cls) && !va.isAbsUrl(n))
177
+ st = this.mark(f, n);
178
+
179
+ if (this.hasClass(n, s.email_cls) && !va.isEmail(n))
180
+ st = this.mark(f, n);
181
+
182
+ if (this.hasClass(n, s.size_cls) && !va.isSize(n))
183
+ st = this.mark(f, n);
184
+
185
+ if (this.hasClass(n, s.id_cls) && !va.isId(n))
186
+ st = this.mark(f, n);
187
+
188
+ if (this.hasClass(n, s.min_cls, true)) {
189
+ v = this.getNum(n, s.min_cls);
190
+
191
+ if (isNaN(v) || parseInt(n.value) < parseInt(v))
192
+ st = this.mark(f, n);
193
+ }
194
+
195
+ if (this.hasClass(n, s.max_cls, true)) {
196
+ v = this.getNum(n, s.max_cls);
197
+
198
+ if (isNaN(v) || parseInt(n.value) > parseInt(v))
199
+ st = this.mark(f, n);
200
+ }
201
+ }
202
+
203
+ return st;
204
+ },
205
+
206
+ hasClass : function(n, c, d) {
207
+ return new RegExp('\\b' + c + (d ? '[0-9]+' : '') + '\\b', 'g').test(n.className);
208
+ },
209
+
210
+ getNum : function(n, c) {
211
+ c = n.className.match(new RegExp('\\b' + c + '([0-9]+)\\b', 'g'))[0];
212
+ c = c.replace(/[^0-9]/g, '');
213
+
214
+ return c;
215
+ },
216
+
217
+ addClass : function(n, c, b) {
218
+ var o = this.removeClass(n, c);
219
+ n.className = b ? c + (o != '' ? (' ' + o) : '') : (o != '' ? (o + ' ') : '') + c;
220
+ },
221
+
222
+ removeClass : function(n, c) {
223
+ c = n.className.replace(new RegExp("(^|\\s+)" + c + "(\\s+|$)"), ' ');
224
+ return n.className = c != ' ' ? c : '';
225
+ },
226
+
227
+ tags : function(f, s) {
228
+ return f.getElementsByTagName(s);
229
+ },
230
+
231
+ mark : function(f, n) {
232
+ var s = this.settings;
233
+
234
+ this.addClass(n, s.invalid_cls);
235
+ n.setAttribute('aria-invalid', 'true');
236
+ this.markLabels(f, n, s.invalid_cls);
237
+
238
+ return false;
239
+ },
240
+
241
+ markLabels : function(f, n, ic) {
242
+ var nl, i;
243
+
244
+ nl = this.tags(f, "label");
245
+ for (i=0; i<nl.length; i++) {
246
+ if (nl[i].getAttribute("for") == n.id || nl[i].htmlFor == n.id)
247
+ this.addClass(nl[i], ic);
248
+ }
249
+
250
+ return null;
251
+ }
252
+ };
@@ -0,0 +1,15 @@
1
+ function load_tinymce(){
2
+ $("textarea[data-simple!=true]").tinymce({
3
+ script_url: "/javascripts/tinymce/tiny_mce.js",
4
+ theme: "advanced",
5
+ skin: "cirkuit",
6
+ mode: "textareas",
7
+ theme_advanced_buttons1 : "bold,italic,underline,|,justifyleft,justifycenter,justifyright,|,formatselect,|,link,unlink,image,code",
8
+ theme_advanced_buttons2 : "",
9
+ theme_advanced_buttons3 : "",
10
+ theme_advanced_toolbar_location: "top",
11
+ theme_advanced_toolbar_align: "left",
12
+ // theme_advanced_statusbar_location : "bottom",
13
+ theme_advanced_resizing: true
14
+ });
15
+ }
@@ -1,10 +1,12 @@
1
1
  require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
2
2
 
3
3
  describe Lolita::Configuration::Column do
4
- let(:column){Lolita::Configuration::Column.new(:col1)}
4
+ let(:dbi){Lolita::DBI::Base.new(Post)}
5
+ let(:column){Lolita::Configuration::Column.new(dbi,:col1)}
6
+
5
7
 
6
8
  it "should create new column with Hash attributes" do
7
- column=Lolita::Configuration::Column.new(:name=>"col1",:title=>"Col1",:type=>String)
9
+ column=Lolita::Configuration::Column.new(dbi,:name=>"col1",:title=>"Col1",:type=>String)
8
10
  column.name.should == "col1"
9
11
  end
10
12
 
@@ -14,12 +16,12 @@ describe Lolita::Configuration::Column do
14
16
  title "Col one"
15
17
  type String
16
18
  }
17
- column=Lolita::Configuration::Column.new &p
19
+ column=Lolita::Configuration::Column.new dbi,&p
18
20
  column.type.should == String
19
21
  end
20
22
 
21
23
  it "should create new column with block given" do
22
- column=Lolita::Configuration::Column.new do
24
+ column=Lolita::Configuration::Column.new(dbi) do
23
25
  name "col1"
24
26
  title "Col one"
25
27
  type String
@@ -28,27 +30,57 @@ describe Lolita::Configuration::Column do
28
30
  end
29
31
 
30
32
  it "should create new column when String or Symbol is given" do
31
- column=Lolita::Configuration::Column.new(:col1)
33
+ column=Lolita::Configuration::Column.new(dbi,:col1)
32
34
  column.name.should == "col1"
33
- column=Lolita::Configuration::Column.new("col2")
35
+ column=Lolita::Configuration::Column.new(dbi,"col2")
34
36
  column.name.should == "col2"
35
37
  end
36
38
 
37
39
  it "should raise error when no name is provided for column" do
38
40
  lambda{
39
- Lolita::Configuration::Column.new do
41
+ Lolita::Configuration::Column.new(dbi) do
40
42
  title "Col one"
41
43
  end
42
44
  }.should raise_error(ArgumentError, "Column must have name.")
43
45
  end
44
46
 
45
- it "should allow to add formatter" do
47
+ it "should allow to add formatter with block" do
46
48
  column.formatter do|value|
47
49
  "value #{value}"
48
50
  end
49
51
  column.formatter.with("1").should == "value 1"
50
52
  end
51
53
 
54
+ it "should allow to add formatter as attribute" do
55
+ column.type :float
56
+ column.formatter = "%.3f"
57
+ column.formatter.with(44.88).should == "44.880"
58
+ end
59
+
60
+ it "should allow to add formatter as attribute with Lolita::Support instance" do
61
+ column.formatter = Lolita::Support::Formatter.new("%s")
62
+ column.formatter.is_a?(Lolita::Support::Formatter::Rails).should be_false
63
+ column.formatter = "%s"
64
+ column.formatter.is_a?(Lolita::Support::Formatter::Rails).should be_true
65
+ end
66
+
67
+ it "should allow to add formatter as block with Lolita::Support instance" do
68
+ column=Lolita::Configuration::Column.new(dbi) do
69
+ name "col1"
70
+ title "Col one"
71
+ type String
72
+ formatter Lolita::Support::Formatter.new("%s")
73
+ end
74
+ column.formatter.is_a?(Lolita::Support::Formatter::Rails).should be_false
75
+ column=Lolita::Configuration::Column.new(dbi) do
76
+ name "col1"
77
+ title "Col one"
78
+ type String
79
+ formatter "%s"
80
+ end
81
+ column.formatter.is_a?(Lolita::Support::Formatter::Rails).should be_true
82
+ end
83
+
52
84
  it "should make default formater not defined" do
53
85
  column.formatter.with(1).should == 1
54
86
  end
@@ -26,7 +26,7 @@ describe Lolita::Configuration::Columns do
26
26
  it "should make Lolita::Configuration::Column for each element " do
27
27
  columns=Lolita::Configuration::Columns.new(@list)
28
28
  columns<<{:name=>"col1"}
29
- columns<<Lolita::Configuration::Column.new(:name=>"col2")
29
+ columns<<Lolita::Configuration::Column.new(@dbi,:name=>"col2")
30
30
  columns.first.class.should == Lolita::Configuration::Column
31
31
  end
32
32
 
@@ -35,8 +35,8 @@ describe Lolita::Support::Formatter do
35
35
  end
36
36
 
37
37
  it "should convert received value to string and call #unpack" do
38
- formatter=klass.new('C')
39
- formatter.with("\100").should == [64]
38
+ formatter=klass.new("%.3f")
39
+ formatter.with(44.88).should == "44.880"
40
40
  end
41
41
  end
42
42
  end
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: lolita
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 3.1.5
5
+ version: 3.1.6
6
6
  platform: ruby
7
7
  authors:
8
8
  - ITHouse (Latvia) and Arturs Meisters
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2011-04-20 00:00:00 +03:00
13
+ date: 2011-05-19 00:00:00 +03:00
14
14
  default_executable:
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
@@ -73,9 +73,9 @@ dependencies:
73
73
  requirement: &id006 !ruby/object:Gem::Requirement
74
74
  none: false
75
75
  requirements:
76
- - - ">="
76
+ - - ~>
77
77
  - !ruby/object:Gem::Version
78
- version: 2.2.0
78
+ version: 2.6.0
79
79
  type: :development
80
80
  prerelease: false
81
81
  version_requirements: *id006
@@ -84,9 +84,9 @@ dependencies:
84
84
  requirement: &id007 !ruby/object:Gem::Requirement
85
85
  none: false
86
86
  requirements:
87
- - - ">="
87
+ - - ~>
88
88
  - !ruby/object:Gem::Version
89
- version: "0"
89
+ version: 2.6.0
90
90
  type: :development
91
91
  prerelease: false
92
92
  version_requirements: *id007
@@ -241,7 +241,9 @@ files:
241
241
  - app/views/lolita/rest/form.html.erb
242
242
  - app/views/lolita/rest/index.html.erb
243
243
  - author
244
+ - config/locales/default/lv.yml
244
245
  - config/locales/en.yml
246
+ - config/locales/lv.yml
245
247
  - db/seed.rb
246
248
  - features/create_page.feature
247
249
  - features/step_definitions/lolita_steps.rb
@@ -305,7 +307,8 @@ files:
305
307
  - lib/lolita/test/matchers.rb
306
308
  - lolita.gemspec
307
309
  - public/images/lolita/plus.png
308
- - public/javascripts/jquery-1.5.1.min.js
310
+ - public/javascripts/jquery-1.6.min.js
311
+ - public/javascripts/jquery-ui-1.8.13.min.js
309
312
  - public/javascripts/lolita/main.js
310
313
  - public/javascripts/lolita/tab.js
311
314
  - public/javascripts/modernizr-1.7.min.js
@@ -360,6 +363,11 @@ files:
360
363
  - public/javascripts/tinymce/themes/advanced/source_editor.htm
361
364
  - public/javascripts/tinymce/tiny_mce.js
362
365
  - public/javascripts/tinymce/tiny_mce_popup.js
366
+ - public/javascripts/tinymce/utils/editable_selects.js
367
+ - public/javascripts/tinymce/utils/form_utils.js
368
+ - public/javascripts/tinymce/utils/mctabs.js
369
+ - public/javascripts/tinymce/utils/validate.js
370
+ - public/javascripts/tinymce_config.js
363
371
  - public/stylesheets/lolita/default.css
364
372
  - public/stylesheets/lolita/style.css
365
373
  - spec/adapter_helper.rb
@@ -486,7 +494,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
486
494
  requirements:
487
495
  - - ">="
488
496
  - !ruby/object:Gem::Version
489
- hash: 884824061
497
+ hash: 354459983
490
498
  segments:
491
499
  - 0
492
500
  version: "0"