modeljs 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (24) hide show
  1. data/app/assets/images/loading.gif +0 -0
  2. data/app/assets/images/loading_small.gif +0 -0
  3. data/app/assets/javascripts/attribute/h1.js +61 -0
  4. data/app/assets/javascripts/{modeljs/attribute → attribute}/image.js +2 -2
  5. data/app/assets/javascripts/{modeljs/attribute → attribute}/rich-text.js +7 -4
  6. data/app/assets/javascripts/{modeljs/form.js → form.js} +10 -3
  7. data/app/assets/javascripts/{modeljs/model.js → model.js} +5 -0
  8. data/lib/modeljs/version.rb +1 -1
  9. metadata +24 -21
  10. /data/app/assets/javascripts/{modeljs/attribute → attribute}/checkbox-multiple.js +0 -0
  11. /data/app/assets/javascripts/{modeljs/attribute → attribute}/checkbox.js +0 -0
  12. /data/app/assets/javascripts/{modeljs/attribute → attribute}/date-time.js +0 -0
  13. /data/app/assets/javascripts/{modeljs/attribute → attribute}/file.js +0 -0
  14. /data/app/assets/javascripts/{modeljs/attribute → attribute}/hidden.js +0 -0
  15. /data/app/assets/javascripts/{modeljs/attribute → attribute}/password.js +0 -0
  16. /data/app/assets/javascripts/{modeljs/attribute → attribute}/radio.js +0 -0
  17. /data/app/assets/javascripts/{modeljs/attribute → attribute}/select.js +0 -0
  18. /data/app/assets/javascripts/{modeljs/attribute → attribute}/texarea.js +0 -0
  19. /data/app/assets/javascripts/{modeljs/attribute → attribute}/textjs.js +0 -0
  20. /data/app/assets/javascripts/{modeljs/attribute → attribute}/time.js +0 -0
  21. /data/app/assets/javascripts/{modeljs/attribute → attribute}/video.js +0 -0
  22. /data/app/assets/javascripts/{modeljs/attribute.js → attribute.js} +0 -0
  23. /data/app/assets/javascripts/{modeljs/form → form}/embedded.js +0 -0
  24. /data/app/assets/stylesheets/{modeljs/modeljs.css → modeljs.css} +0 -0
Binary file
Binary file
@@ -0,0 +1,61 @@
1
+
2
+ Model.Attribute.H1 = Model.Attribute.extend({
3
+
4
+ show_reminder: true,
5
+ width: '100%',
6
+
7
+ view: function()
8
+ {
9
+ var html = false;
10
+ if (typeof(this.value) == 'string')
11
+ html = this.value && this.value.length > 0 ? this.value : this.empty_text;
12
+ else if (typeof(this.value) == 'number')
13
+ html = this.value != null ? this.value : this.empty_text;
14
+ else
15
+ html = this.value;
16
+
17
+ return $('<h1/>')
18
+ .html(html);
19
+ },
20
+
21
+ form: function()
22
+ {
23
+ var this2 = this;
24
+ var input = $('<input/>')
25
+ .attr('type', 'text')
26
+ .attr('id', this.base)
27
+ .attr('name', this.base)
28
+ .css('width', this.width)
29
+ .val(this.value);
30
+ if (this.show_reminder)
31
+ input.keyup(function (){ this2.flash_reminder(); })
32
+ if (this.css)
33
+ input.css(this.css);
34
+ var form = $('<form/>').append(input);
35
+ if (this.show_reminder)
36
+ form.append($('<span/>').attr('id', this.base + '_reminder').css('font-size', '75%'));
37
+
38
+ return form;
39
+ },
40
+
41
+ flash_reminder: function()
42
+ {
43
+ $('#' + this.base + '_reminder')
44
+ .html(' (Enter to update, Escape to cancel)')
45
+ .delay(1000)
46
+ .fadeOut({ done: function() { $(this).empty().show(); }});
47
+ },
48
+
49
+ post_form_display: function()
50
+ {
51
+ // Put the focus at the end of the string
52
+ $('#' + this.base).focus();
53
+ val = $('#' + this.base).val();
54
+ $('#' + this.base).val('');
55
+ $('#' + this.base).val(val);
56
+
57
+ if (this.show_reminder)
58
+ this.flash_reminder();
59
+ }
60
+
61
+ });
@@ -68,7 +68,7 @@ Model.Attribute.Image = Model.Attribute.extend({
68
68
  .append($('<input/>').attr('type', 'submit').val('Update').addClass('update_btn').click(function() { this2.loading('Uploading...'); }))
69
69
  .append($('<input/>').attr('type', 'button').val('Cancel').addClass('cancel_btn').click(function() { this2.model.show_attribute(this2); }));
70
70
  form.append(controls);
71
- form.append($('<span/>').attr('id', attrib.message));
71
+ form.append($('<span/>').attr('id', this.message));
72
72
  return form;
73
73
  },
74
74
 
@@ -97,7 +97,7 @@ Model.Attribute.Image = Model.Attribute.extend({
97
97
  {
98
98
  if (resp.attribute)
99
99
  for (var thing in resp.attribute)
100
- attrib[thing] = resp.attribute[thing];
100
+ this[thing] = resp.attribute[thing];
101
101
  this.model.show_attribute(this);
102
102
  }
103
103
  }
@@ -5,7 +5,8 @@ Model.Attribute.RichText = Model.Attribute.extend({
5
5
 
6
6
  view: function()
7
7
  {
8
- tinyMCE.execCommand('mceRemoveControl', null, $('#' + this.base));
8
+ //tinyMCE.execCommand('mceRemoveControl', null, $('#' + this.base));
9
+ tinyMCE.execCommand('mceRemoveControl', null, this.base);
9
10
  var html = this.value && this.value.length > 0 ? this.value : this.empty_text;
10
11
  return $('<div/>')
11
12
  .addClass('model_attribute_container')
@@ -16,7 +17,7 @@ Model.Attribute.RichText = Model.Attribute.extend({
16
17
  {
17
18
  return $('<form/>')
18
19
  .append($('<textarea/>')
19
- .addClass('mceEditor')
20
+ .addClass('tinymce')
20
21
  .attr('id', this.base)
21
22
  .attr('name', this.base)
22
23
  .val(this.value)
@@ -26,14 +27,16 @@ Model.Attribute.RichText = Model.Attribute.extend({
26
27
  form_value: function()
27
28
  {
28
29
  tinyMCE.triggerSave();
29
- tinyMCE.execCommand('mceRemoveControl', null, $('#' + this.base));
30
+ //tinyMCE.execCommand('mceRemoveControl', null, $('#' + this.base));
31
+ tinyMCE.execCommand('mceRemoveControl', null, this.base);
30
32
  return $('#' + this.base).val();
31
33
  },
32
34
 
33
35
  post_form_display: function()
34
36
  {
35
37
  $('#' + this.base).css('display', 'block');
36
- tinyMCE.execCommand('mceAddControl', null, $('#' + this.base));
38
+ //tinyMCE.execCommand('mceAddControl', null, $('#' + this.base));
39
+ tinyMCE.execCommand('mceAddControl', null, this.base);
37
40
  $('#' + this.base).focus();
38
41
  }
39
42
 
@@ -50,8 +50,12 @@ Model.Form = Class.extend({
50
50
  .append($('<table/>').append(tbody))
51
51
  .append($('<div/>').attr('id', this.message_div))
52
52
  .append($('<p/>')
53
- .append($('<input/>').attr('type', 'submit').val('Add ' + m.name).click(function() { m.ajax_add(); }))
54
- .append($('<input/>').attr('type', 'button').val('Back').click(function() { window.location = m.listing_url; }))
53
+ .append($('<input/>').attr('type', 'button').val('Back').click(function() {
54
+ obj = Model.parse_url(m.listing_url);
55
+ window.location = obj.url;
56
+ }))
57
+ .append(' ')
58
+ .append($('<input/>').attr('type', 'submit').val('Add ' + m.name).click(function() { m.ajax_add(); }))
55
59
  );
56
60
  return form;
57
61
  },
@@ -79,7 +83,10 @@ Model.Form = Class.extend({
79
83
  .append($('<table/>').append(tbody))
80
84
  .append($('<div/>').attr('id', this.message))
81
85
  .append($('<p/>')
82
- .append($('<input/>').attr('type', 'button').val('Back').click(function() { window.location = m.listing_url; }))
86
+ .append($('<input/>').attr('type', 'button').val('Back').click(function() {
87
+ var obj = Model.parse_url(m.listing_url);
88
+ window.location = obj.url;
89
+ }))
83
90
  .append(' ')
84
91
  .append($('<input/>').attr('type', 'button').val('Delete ' + m.name).click(function() { m.ajax_delete(); }))
85
92
  );
@@ -350,6 +350,11 @@ Model.prototype = {
350
350
  attrib.loading();
351
351
  this2 = this;
352
352
  data = attrib.form_values();
353
+
354
+ for (var thing in data)
355
+ if (data[thing].constructor.name == 'Array' && data[thing].length == 0)
356
+ data[thing] = null;
357
+
353
358
  obj = Model.parse_url(attrib.update_url ? attrib.update_url : this.update_url, this.id);
354
359
  $.ajax({
355
360
  url: obj.url,
@@ -1,3 +1,3 @@
1
1
  module Modeljs
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: modeljs
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-05-24 00:00:00.000000000 Z
12
+ date: 2013-06-03 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails
@@ -66,25 +66,28 @@ executables: []
66
66
  extensions: []
67
67
  extra_rdoc_files: []
68
68
  files:
69
- - app/assets/javascripts/modeljs/attribute/checkbox-multiple.js
70
- - app/assets/javascripts/modeljs/attribute/checkbox.js
71
- - app/assets/javascripts/modeljs/attribute/date-time.js
72
- - app/assets/javascripts/modeljs/attribute/file.js
73
- - app/assets/javascripts/modeljs/attribute/hidden.js
74
- - app/assets/javascripts/modeljs/attribute/image.js
75
- - app/assets/javascripts/modeljs/attribute/password.js
76
- - app/assets/javascripts/modeljs/attribute/radio.js
77
- - app/assets/javascripts/modeljs/attribute/rich-text.js
78
- - app/assets/javascripts/modeljs/attribute/select.js
79
- - app/assets/javascripts/modeljs/attribute/texarea.js
80
- - app/assets/javascripts/modeljs/attribute/textjs.js
81
- - app/assets/javascripts/modeljs/attribute/time.js
82
- - app/assets/javascripts/modeljs/attribute/video.js
83
- - app/assets/javascripts/modeljs/attribute.js
84
- - app/assets/javascripts/modeljs/form/embedded.js
85
- - app/assets/javascripts/modeljs/form.js
86
- - app/assets/javascripts/modeljs/model.js
87
- - app/assets/stylesheets/modeljs/modeljs.css
69
+ - app/assets/images/loading.gif
70
+ - app/assets/images/loading_small.gif
71
+ - app/assets/javascripts/attribute/checkbox-multiple.js
72
+ - app/assets/javascripts/attribute/checkbox.js
73
+ - app/assets/javascripts/attribute/date-time.js
74
+ - app/assets/javascripts/attribute/file.js
75
+ - app/assets/javascripts/attribute/h1.js
76
+ - app/assets/javascripts/attribute/hidden.js
77
+ - app/assets/javascripts/attribute/image.js
78
+ - app/assets/javascripts/attribute/password.js
79
+ - app/assets/javascripts/attribute/radio.js
80
+ - app/assets/javascripts/attribute/rich-text.js
81
+ - app/assets/javascripts/attribute/select.js
82
+ - app/assets/javascripts/attribute/texarea.js
83
+ - app/assets/javascripts/attribute/textjs.js
84
+ - app/assets/javascripts/attribute/time.js
85
+ - app/assets/javascripts/attribute/video.js
86
+ - app/assets/javascripts/attribute.js
87
+ - app/assets/javascripts/form/embedded.js
88
+ - app/assets/javascripts/form.js
89
+ - app/assets/javascripts/model.js
90
+ - app/assets/stylesheets/modeljs.css
88
91
  - lib/modeljs/engine.rb
89
92
  - lib/modeljs/version.rb
90
93
  - lib/modeljs.rb