modeljs 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/app/assets/images/loading.gif +0 -0
- data/app/assets/images/loading_small.gif +0 -0
- data/app/assets/javascripts/attribute/h1.js +61 -0
- data/app/assets/javascripts/{modeljs/attribute → attribute}/image.js +2 -2
- data/app/assets/javascripts/{modeljs/attribute → attribute}/rich-text.js +7 -4
- data/app/assets/javascripts/{modeljs/form.js → form.js} +10 -3
- data/app/assets/javascripts/{modeljs/model.js → model.js} +5 -0
- data/lib/modeljs/version.rb +1 -1
- metadata +24 -21
- /data/app/assets/javascripts/{modeljs/attribute → attribute}/checkbox-multiple.js +0 -0
- /data/app/assets/javascripts/{modeljs/attribute → attribute}/checkbox.js +0 -0
- /data/app/assets/javascripts/{modeljs/attribute → attribute}/date-time.js +0 -0
- /data/app/assets/javascripts/{modeljs/attribute → attribute}/file.js +0 -0
- /data/app/assets/javascripts/{modeljs/attribute → attribute}/hidden.js +0 -0
- /data/app/assets/javascripts/{modeljs/attribute → attribute}/password.js +0 -0
- /data/app/assets/javascripts/{modeljs/attribute → attribute}/radio.js +0 -0
- /data/app/assets/javascripts/{modeljs/attribute → attribute}/select.js +0 -0
- /data/app/assets/javascripts/{modeljs/attribute → attribute}/texarea.js +0 -0
- /data/app/assets/javascripts/{modeljs/attribute → attribute}/textjs.js +0 -0
- /data/app/assets/javascripts/{modeljs/attribute → attribute}/time.js +0 -0
- /data/app/assets/javascripts/{modeljs/attribute → attribute}/video.js +0 -0
- /data/app/assets/javascripts/{modeljs/attribute.js → attribute.js} +0 -0
- /data/app/assets/javascripts/{modeljs/form → form}/embedded.js +0 -0
- /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',
|
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
|
-
|
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('
|
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', '
|
54
|
-
|
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() {
|
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,
|
data/lib/modeljs/version.rb
CHANGED
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.
|
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-
|
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/
|
70
|
-
- app/assets/
|
71
|
-
- app/assets/javascripts/
|
72
|
-
- app/assets/javascripts/
|
73
|
-
- app/assets/javascripts/
|
74
|
-
- app/assets/javascripts/
|
75
|
-
- app/assets/javascripts/
|
76
|
-
- app/assets/javascripts/
|
77
|
-
- app/assets/javascripts/
|
78
|
-
- app/assets/javascripts/
|
79
|
-
- app/assets/javascripts/
|
80
|
-
- app/assets/javascripts/
|
81
|
-
- app/assets/javascripts/
|
82
|
-
- app/assets/javascripts/
|
83
|
-
- app/assets/javascripts/
|
84
|
-
- app/assets/javascripts/
|
85
|
-
- app/assets/javascripts/
|
86
|
-
- app/assets/javascripts/
|
87
|
-
- app/assets/
|
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
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|