tinymce-rails-imageupload 3.5.6.4 → 3.5.8.0
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.
- data/CHANGELOG.markdown +7 -0
- data/README.markdown +14 -1
- data/lib/tinymce-rails-imageupload/version.rb +1 -1
- data/vendor/assets/javascripts/tinymce/plugins/uploadimage/dialog.html +91 -44
- data/vendor/assets/javascripts/tinymce/plugins/uploadimage/img/spinner.gif +0 -0
- data/vendor/assets/javascripts/tinymce/plugins/uploadimage/langs/en_dlg.js +4 -0
- data/vendor/assets/javascripts/tinymce/plugins/uploadimage/langs/nb_dlg.js +4 -0
- data/vendor/assets/javascripts/tinymce/plugins/uploadimage/langs/pt_dlg.js +4 -0
- data/vendor/assets/javascripts/tinymce/plugins/uploadimage/langs/ru_dlg.js +5 -1
- metadata +21 -20
data/CHANGELOG.markdown
CHANGED
@@ -1,3 +1,10 @@
|
|
1
|
+
## 3.5.8.0 (February 1, 2013)
|
2
|
+
|
3
|
+
* Tested with tinymce-rails 3.5.8
|
4
|
+
* Handle errors from the server, both in the JSON, and from the server (HTTP 5xx and so on)
|
5
|
+
* Don't submit the form without a file selected (fixes #1)
|
6
|
+
* Display a spinner when uploading (fixes #2)
|
7
|
+
|
1
8
|
## 3.5.6.4 (December 10, 2012)
|
2
9
|
|
3
10
|
* Convert CoffeeScript to JavaScript to avoid depending on CoffeeScript (#19). Thanks to sobrinho (Gabriel Sobrinho)
|
data/README.markdown
CHANGED
@@ -5,7 +5,7 @@
|
|
5
5
|
|
6
6
|
This plugin borrows heavily from work done by [Peter Shoukry](http://77effects.com/).
|
7
7
|
|
8
|
-
The icon used for the button comes from the icon set [Silk by famfamfam](http://www.famfamfam.com/lab/icons/silk/)
|
8
|
+
The icon used for the button comes from the icon set [Silk by famfamfam](http://www.famfamfam.com/lab/icons/silk/) and the spinner image from [ajaxload.info](http://ajaxload.info/).
|
9
9
|
|
10
10
|
## Requirements
|
11
11
|
|
@@ -56,6 +56,15 @@
|
|
56
56
|
|
57
57
|
If the JSON response contains a `width` and/or `height` key, those will be used in the inserted HTML (`<img src="..." width="..." height="...">`), but if those are not present, the inserted HTML is just `<img src="...">`.
|
58
58
|
|
59
|
+
## Error handling
|
60
|
+
|
61
|
+
To notify the uploader that an error occurred, return JSON containing a `error` key with a `message`.
|
62
|
+
The message gets show in a paragraph with the ID `error_message`, and the input label gets the class `invalid`.
|
63
|
+
|
64
|
+
Example response:
|
65
|
+
|
66
|
+
"{"error": {"message": "Invalid file type. Only .jpg, .png and .gif allowed"}}"
|
67
|
+
|
59
68
|
## Internationalization
|
60
69
|
|
61
70
|
I18n is taken care of by `tinymce-rails`. This gem includes strings for english, norwegian, russian and portugese.
|
@@ -82,6 +91,10 @@ The available strings are listed below:
|
|
82
91
|
title: 'Insert image',
|
83
92
|
header: "Insert image",
|
84
93
|
input: "Choose an image",
|
94
|
+
uploading: "Uploading…",
|
95
|
+
blank_input: "Must choose a file",
|
96
|
+
bad_response: "Got a bad response from the server",
|
97
|
+
blank_response: "Didn't get a response from the server",
|
85
98
|
insert: "Insert",
|
86
99
|
cancel: "Cancel"
|
87
100
|
});
|
@@ -1,84 +1,131 @@
|
|
1
1
|
<!DOCTYPE html>
|
2
2
|
<html>
|
3
3
|
<head>
|
4
|
+
<meta charset="utf-8">
|
4
5
|
<title>{#uploadimage_dlg.title}</title>
|
6
|
+
<style type="text/css">
|
7
|
+
form { margin-top: 0.5em; }
|
8
|
+
label { margin-bottom: 0.5em; }
|
9
|
+
p#error_message { color: #E00; }
|
10
|
+
#upload_spinner { padding-top: 4px; padding-left: 3px; }
|
11
|
+
#upload_spinner.inactive { display: none; }
|
12
|
+
</style>
|
5
13
|
<script type="text/javascript" src="../../tiny_mce_popup.js"></script>
|
6
14
|
<script type="text/javascript">
|
7
15
|
tinyMCEPopup.requireLangPack();
|
8
16
|
|
9
|
-
|
10
|
-
{
|
11
|
-
for (var i = 0; i < frames.length; i++)
|
12
|
-
if (frames[i].name == name)
|
13
|
-
return frames[i];
|
17
|
+
var UploadImageDialog = {
|
14
18
|
|
15
|
-
|
16
|
-
|
19
|
+
init: function() {
|
20
|
+
this.f = document.forms[0];
|
21
|
+
this.f.action = tinyMCEPopup.getParam("uploadimage_form_url", "/tinymce_assets");
|
22
|
+
document.getElementById("hint").value = tinyMCEPopup.getParam("uploadimage_hint", "");
|
23
|
+
document.getElementById("authenticity_token").value = this.getMetaContents('csrf-token');
|
17
24
|
|
18
|
-
|
19
|
-
|
20
|
-
|
25
|
+
this.iframe = document.getElementById("hidden_upload");
|
26
|
+
if(this.iframe.attachEvent)
|
27
|
+
this.iframe.attachEvent('onload', UploadImageDialog.uploadDone);
|
28
|
+
else
|
29
|
+
this.iframe.addEventListener('load', UploadImageDialog.uploadDone, false);
|
30
|
+
},
|
21
31
|
|
22
|
-
|
23
|
-
|
24
|
-
return m[i].content;
|
32
|
+
insert: function() {
|
33
|
+
var input = document.getElementById("file_upload");
|
25
34
|
|
26
|
-
|
27
|
-
|
35
|
+
if(input.value != "") {
|
36
|
+
document.getElementById("upload_spinner").className = '';
|
37
|
+
this.f.submit();
|
38
|
+
} else
|
39
|
+
this.handleError(tinyMCEPopup.getLang("uploadimage_dlg.blank_input", "Must choose a file"));
|
40
|
+
},
|
41
|
+
|
42
|
+
uploadDone: function() {
|
43
|
+
document.getElementById("upload_spinner").className = 'inactive';
|
28
44
|
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
45
|
+
if(this.document || this.contentDocument) {
|
46
|
+
var doc = this.document ? this.document : this.contentDocument;
|
47
|
+
UploadImageDialog.handleResponse(doc.getElementsByTagName("body")[0].innerHTML);
|
48
|
+
} else
|
49
|
+
UploadImageDialog.handleError(tinyMCEPopup.getLang("uploadimage_dlg.blank_response", "Didn't get a response from the server"));
|
50
|
+
},
|
34
51
|
|
35
|
-
|
52
|
+
handleResponse: function(ret) {
|
53
|
+
try {
|
36
54
|
var json = JSON.parse(ret);
|
37
|
-
var imgstr = "<br><img src='" + json["image"]["url"] + "'";
|
38
55
|
|
39
|
-
if(json["
|
40
|
-
|
41
|
-
|
42
|
-
|
56
|
+
if(json["error"])
|
57
|
+
UploadImageDialog.handleError(json["error"]["message"]);
|
58
|
+
else {
|
59
|
+
tinyMCE.execCommand('mceInsertContent', false, UploadImageDialog.buildHTML(json));
|
60
|
+
tinyMCEPopup.close();
|
61
|
+
}
|
62
|
+
} catch(e) {
|
63
|
+
UploadImageDialog.handleError(tinyMCEPopup.getLang("uploadimage_dlg.bad_response", "Got a bad response from the server"));
|
64
|
+
}
|
65
|
+
},
|
43
66
|
|
44
|
-
|
67
|
+
buildHTML: function(json) {
|
68
|
+
var imgstr = "<br><img src='" + json["image"]["url"] + "'";
|
45
69
|
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
}
|
70
|
+
if(json["image"]["height"])
|
71
|
+
imgstr += " height='" + json["image"]["height"] + "'";
|
72
|
+
if(json["image"]["width"])
|
73
|
+
imgstr += " width='" + json["image"]["width"] + "'";
|
51
74
|
|
52
|
-
|
75
|
+
imgstr += "/>";
|
53
76
|
|
54
|
-
|
55
|
-
this.f = document.forms[0];
|
56
|
-
this.f.action = tinyMCEPopup.getParam("uploadimage_form_url", "/tinymce_assets");
|
57
|
-
document.getElementById("hint").value = tinyMCEPopup.getParam("uploadimage_hint", "");
|
58
|
-
document.getElementById("authenticity_token").value = getMetaContents('csrf-token');
|
77
|
+
return imgstr;
|
59
78
|
},
|
60
79
|
|
61
|
-
|
62
|
-
|
63
|
-
|
80
|
+
handleError: function(error) {
|
81
|
+
var className = 'invalid';
|
82
|
+
var label = document.getElementById("file_upload_label");
|
83
|
+
var message = document.getElementById("error_message");
|
84
|
+
|
85
|
+
if(message)
|
86
|
+
message.innerHTML = error;
|
87
|
+
|
88
|
+
// Add the 'invalid' class, avoiding duplicates
|
89
|
+
if(label) {
|
90
|
+
var cn = label.className;
|
91
|
+
if(cn.indexOf(className) == -1) {
|
92
|
+
if(cn != '')
|
93
|
+
className = ' ' + className;
|
94
|
+
label.className = cn + className;
|
95
|
+
}
|
96
|
+
}
|
97
|
+
},
|
98
|
+
|
99
|
+
getMetaContents: function(mn) {
|
100
|
+
var m = (window.opener || window.parent).document.getElementsByTagName('meta');
|
101
|
+
|
102
|
+
for(var i in m)
|
103
|
+
if(m[i].name == mn)
|
104
|
+
return m[i].content;
|
105
|
+
|
106
|
+
return null;
|
107
|
+
},
|
64
108
|
};
|
65
109
|
|
66
110
|
tinyMCEPopup.onInit.add(UploadImageDialog.init, UploadImageDialog);
|
67
111
|
</script>
|
68
112
|
</head>
|
69
113
|
<body>
|
114
|
+
<h1>{#uploadimage_dlg.header}</h1>
|
70
115
|
|
71
116
|
<form method="post" enctype='multipart/form-data' accept-charset="UTF-8" target="hidden_upload" action='#replaceme' name="uploadimageForm">
|
72
117
|
<input type="hidden" name="utf8" value="✓">
|
73
118
|
<input type="hidden" name="authenticity_token" id="authenticity_token" value="#replaceme">
|
74
119
|
<input type="hidden" name="hint" id="hint" value="#replaceme">
|
75
|
-
<iframe id="hidden_upload" name="hidden_upload" src=
|
120
|
+
<iframe id="hidden_upload" name="hidden_upload" src="" style='width:0;height:0;border:0px solid #fff'></iframe>
|
76
121
|
|
77
|
-
<
|
78
|
-
<
|
122
|
+
<label id='file_upload_label' for='file_upload'>{#uploadimage_dlg.input}:</label>
|
123
|
+
<input type='file' name='file' id='file_upload'>
|
124
|
+
<p id="error_message"></p>
|
79
125
|
|
80
126
|
<div class="mceActionPanel">
|
81
127
|
<input type="button" id="insert" name="insert" value="{#uploadimage_dlg.insert}" onclick="UploadImageDialog.insert();"/>
|
128
|
+
<img src="img/spinner.gif" alt="#{uploadimage_dlg.uploading}" id="upload_spinner" height="16" width="16" class="inactive">
|
82
129
|
<input type="button" id="cancel" name="cancel" value="{#uploadimage_dlg.cancel}" onclick="tinyMCEPopup.close();" />
|
83
130
|
</div>
|
84
131
|
</form>
|
@@ -2,6 +2,10 @@ tinyMCE.addI18n('en.uploadimage_dlg', {
|
|
2
2
|
title: 'Insert image',
|
3
3
|
header: "Insert image",
|
4
4
|
input: "Choose an image",
|
5
|
+
uploading: "Uploading…",
|
6
|
+
blank_input: "Must choose a file",
|
7
|
+
bad_response: "Got a bad response from the server",
|
8
|
+
blank_response: "Didn't get a response from the server",
|
5
9
|
insert: "Insert",
|
6
10
|
cancel: "Cancel"
|
7
11
|
});
|
@@ -2,6 +2,10 @@ tinyMCE.addI18n('nb.uploadimage_dlg', {
|
|
2
2
|
title: 'Sett inn bilde',
|
3
3
|
header: "Sett inn bilde",
|
4
4
|
input: "Velg et bilde",
|
5
|
+
uploading: "Laster opp…",
|
6
|
+
blank_input: "M\u00e5 velge en fil",
|
7
|
+
bad_response: "Fikk et ugyldig svar fra serveren",
|
8
|
+
blank_response: "Fikk ikke svar fra serveren",
|
5
9
|
insert: "Sett inn",
|
6
10
|
cancel: "Avbryt"
|
7
11
|
});
|
@@ -2,6 +2,10 @@ tinyMCE.addI18n('pt.uploadimage_dlg', {
|
|
2
2
|
title: 'Inserir imagem',
|
3
3
|
header: "Inserir imagem",
|
4
4
|
input: "Escolher uma imagem",
|
5
|
+
uploading: "A enviar…",
|
6
|
+
blank_input: "É necessário seleccionar um ficheiro",
|
7
|
+
bad_response: "Resposta inesperada do servidor",
|
8
|
+
blank_response: "Não foi obtida uma resposta do servidor",
|
5
9
|
insert: "Inserir",
|
6
10
|
cancel: "Cancelar"
|
7
11
|
});
|
@@ -2,6 +2,10 @@ tinyMCE.addI18n('ru.uploadimage_dlg', {
|
|
2
2
|
title: 'Вставить изображение',
|
3
3
|
header: "Вставить изображение",
|
4
4
|
input: "Выберите изображение",
|
5
|
+
uploading: "Загрузка…",
|
6
|
+
blank_input: "Необходимо выбрать файл",
|
7
|
+
bad_response: "Получен некорректный ответ с сервера",
|
8
|
+
blank_response: "Не получен ответ с сервера",
|
5
9
|
insert: "Вставить",
|
6
10
|
cancel: "Отмена"
|
7
|
-
});
|
11
|
+
});
|
metadata
CHANGED
@@ -1,80 +1,80 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tinymce-rails-imageupload
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.5.6.4
|
5
4
|
prerelease:
|
5
|
+
version: 3.5.8.0
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Per Christian B. Viken
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2013-02-01 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: railties
|
16
|
-
|
16
|
+
type: :runtime
|
17
17
|
requirement: !ruby/object:Gem::Requirement
|
18
|
+
none: false
|
18
19
|
requirements:
|
19
20
|
- - ! '>='
|
20
21
|
- !ruby/object:Gem::Version
|
21
22
|
version: '3.1'
|
22
|
-
|
23
|
-
type: :runtime
|
23
|
+
prerelease: false
|
24
24
|
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
25
26
|
requirements:
|
26
27
|
- - ! '>='
|
27
28
|
- !ruby/object:Gem::Version
|
28
29
|
version: '3.1'
|
29
|
-
none: false
|
30
30
|
- !ruby/object:Gem::Dependency
|
31
31
|
name: tinymce-rails
|
32
|
-
|
32
|
+
type: :runtime
|
33
33
|
requirement: !ruby/object:Gem::Requirement
|
34
|
+
none: false
|
34
35
|
requirements:
|
35
36
|
- - ! '>='
|
36
37
|
- !ruby/object:Gem::Version
|
37
38
|
version: 3.4.9
|
38
|
-
|
39
|
-
type: :runtime
|
39
|
+
prerelease: false
|
40
40
|
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
41
42
|
requirements:
|
42
43
|
- - ! '>='
|
43
44
|
- !ruby/object:Gem::Version
|
44
45
|
version: 3.4.9
|
45
|
-
none: false
|
46
46
|
- !ruby/object:Gem::Dependency
|
47
47
|
name: bundler
|
48
|
-
|
48
|
+
type: :development
|
49
49
|
requirement: !ruby/object:Gem::Requirement
|
50
|
+
none: false
|
50
51
|
requirements:
|
51
52
|
- - ~>
|
52
53
|
- !ruby/object:Gem::Version
|
53
54
|
version: 1.0.0
|
54
|
-
|
55
|
-
type: :development
|
55
|
+
prerelease: false
|
56
56
|
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
57
58
|
requirements:
|
58
59
|
- - ~>
|
59
60
|
- !ruby/object:Gem::Version
|
60
61
|
version: 1.0.0
|
61
|
-
none: false
|
62
62
|
- !ruby/object:Gem::Dependency
|
63
63
|
name: rails
|
64
|
-
|
64
|
+
type: :development
|
65
65
|
requirement: !ruby/object:Gem::Requirement
|
66
|
+
none: false
|
66
67
|
requirements:
|
67
68
|
- - ! '>='
|
68
69
|
- !ruby/object:Gem::Version
|
69
70
|
version: '3.1'
|
70
|
-
|
71
|
-
type: :development
|
71
|
+
prerelease: false
|
72
72
|
version_requirements: !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
73
74
|
requirements:
|
74
75
|
- - ! '>='
|
75
76
|
- !ruby/object:Gem::Version
|
76
77
|
version: '3.1'
|
77
|
-
none: false
|
78
78
|
description: TinyMCE plugin for taking image uploads in Rails >= 3.1
|
79
79
|
email:
|
80
80
|
- perchr@northblue.org
|
@@ -95,6 +95,7 @@ files:
|
|
95
95
|
- tinymce-rails-imageupload.gemspec
|
96
96
|
- vendor/assets/javascripts/tinymce/plugins/uploadimage/dialog.html
|
97
97
|
- vendor/assets/javascripts/tinymce/plugins/uploadimage/editor_plugin.js
|
98
|
+
- vendor/assets/javascripts/tinymce/plugins/uploadimage/img/spinner.gif
|
98
99
|
- vendor/assets/javascripts/tinymce/plugins/uploadimage/img/uploadimage.png
|
99
100
|
- vendor/assets/javascripts/tinymce/plugins/uploadimage/langs/en.js
|
100
101
|
- vendor/assets/javascripts/tinymce/plugins/uploadimage/langs/en_dlg.js
|
@@ -111,17 +112,17 @@ rdoc_options: []
|
|
111
112
|
require_paths:
|
112
113
|
- lib
|
113
114
|
required_ruby_version: !ruby/object:Gem::Requirement
|
115
|
+
none: false
|
114
116
|
requirements:
|
115
117
|
- - ! '>='
|
116
118
|
- !ruby/object:Gem::Version
|
117
119
|
version: '0'
|
118
|
-
none: false
|
119
120
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
121
|
+
none: false
|
120
122
|
requirements:
|
121
123
|
- - ! '>='
|
122
124
|
- !ruby/object:Gem::Version
|
123
125
|
version: '0'
|
124
|
-
none: false
|
125
126
|
requirements: []
|
126
127
|
rubyforge_project:
|
127
128
|
rubygems_version: 1.8.24
|