active_admin_pro 0.1.8 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d234b1fc99606b31a281ae58de67fb786c8fa7c8
|
4
|
+
data.tar.gz: 2ce7519061be0f5f951e81bc5529ea99bef32d75
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fb6f50e85086d2b749b42288f736d7198129c7c09fab6f2896d53b79e79b011591d0f9b9f1fe99e09928874dde03aa9ff03116035907125703fc7cb16f348302
|
7
|
+
data.tar.gz: d05dfcaf12668652b311eb94aca234c5fbc998cccd6a11739ee1c9e93cb807093cdbcc78fefb231172c99666dbe817a8ea77db51a1af2744e5681651ddb639de
|
@@ -31,13 +31,53 @@
|
|
31
31
|
//= require codemirror/modes/shell
|
32
32
|
//= require codemirror/modes/xml
|
33
33
|
//= require codemirror/modes/yaml
|
34
|
+
|
34
35
|
/* globals CodeMirror */
|
35
36
|
|
37
|
+
var globalEditor;
|
38
|
+
|
36
39
|
// CodeMirror editor field.
|
37
40
|
// @see https://codemirror.net
|
38
41
|
(function() {
|
39
42
|
"use strict";
|
40
43
|
|
44
|
+
function uploadAndInsertImage(editor, position, imageFile, callback) {
|
45
|
+
var fileName = imageFile.name;
|
46
|
+
|
47
|
+
// Add temporary uploading message
|
48
|
+
var uploadingMessage = '![Uploading ' + fileName + '…]()';
|
49
|
+
editor.doc.setSelection(position);
|
50
|
+
editor.doc.replaceSelection(uploadingMessage);
|
51
|
+
|
52
|
+
// Upload the file using the image upload ability from the Summernote editor
|
53
|
+
var data = new FormData();
|
54
|
+
data.append('file', imageFile);
|
55
|
+
|
56
|
+
$.ajax({
|
57
|
+
data: data,
|
58
|
+
type: 'POST',
|
59
|
+
url: '/admin/active_admin_pro_summernote_images',
|
60
|
+
cache: false,
|
61
|
+
contentType: false,
|
62
|
+
processData: false,
|
63
|
+
|
64
|
+
success: function(url) {
|
65
|
+
editor.doc.setSelection(position, { line: position.line, ch: position.ch + uploadingMessage.length });
|
66
|
+
editor.doc.replaceSelection('![' + fileName + '](' + url + ')');
|
67
|
+
},
|
68
|
+
|
69
|
+
error: function(err) {
|
70
|
+
var json_err = jQuery.parseJSON(err.responseText);
|
71
|
+
$('#wrapper').prepend('<div class="flashes animate"><div class="flash flash_notice">' + json_err.error + '</div></div>');
|
72
|
+
$('.note-editor .modal-dialog .note-image-input').val('');
|
73
|
+
},
|
74
|
+
|
75
|
+
complete: function() {
|
76
|
+
callback.call();
|
77
|
+
}
|
78
|
+
});
|
79
|
+
}
|
80
|
+
|
41
81
|
App.register('component').enter(function() {
|
42
82
|
var codemirrorInputs = $('.input.codemirror');
|
43
83
|
var windowElement = $(window);
|
@@ -62,13 +102,24 @@
|
|
62
102
|
codemirrorInput.focus();
|
63
103
|
});
|
64
104
|
|
65
|
-
codemirrorInput.on('focus', function() {
|
66
|
-
wrapper.addClass('focused');
|
67
|
-
});
|
68
|
-
|
69
105
|
codemirrorInput.on('blur', function() {
|
70
106
|
wrapper.removeClass('focused');
|
71
107
|
});
|
108
|
+
|
109
|
+
codemirrorInput.on('drop', function(editor, event) {
|
110
|
+
globalEditor = editor;
|
111
|
+
var position = editor.coordsChar({ left: event.pageX, top: event.pageY });
|
112
|
+
var file = event.dataTransfer.files[0];
|
113
|
+
|
114
|
+
editor.setOption('readOnly', true);
|
115
|
+
uploadAndInsertImage(editor, position, file, function() {
|
116
|
+
editor.setOption('readOnly', false);
|
117
|
+
});
|
118
|
+
});
|
119
|
+
|
120
|
+
codemirrorInput.on('focus', function() {
|
121
|
+
wrapper.addClass('focused');
|
122
|
+
});
|
72
123
|
});
|
73
124
|
|
74
125
|
// Code Mirror works best when there is a fixed width on its container, so
|
@@ -97,8 +97,8 @@
|
|
97
97
|
|
98
98
|
$.ajax({
|
99
99
|
data: data,
|
100
|
-
type:
|
101
|
-
url:
|
100
|
+
type: 'POST',
|
101
|
+
url: '/admin/active_admin_pro_summernote_images',
|
102
102
|
cache: false,
|
103
103
|
contentType: false,
|
104
104
|
processData: false,
|
@@ -109,7 +109,7 @@
|
|
109
109
|
},
|
110
110
|
|
111
111
|
error: function(err) {
|
112
|
-
var json_err = jQuery.parseJSON(err.responseText)
|
112
|
+
var json_err = jQuery.parseJSON(err.responseText);
|
113
113
|
$('#wrapper').prepend('<div class="flashes animate"><div class="flash flash_notice">' + json_err.error + '</div></div>');
|
114
114
|
$('.note-editor .modal-dialog .note-image-input').val('');
|
115
115
|
}
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: active_admin_pro
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Brian Pattison
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-03-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activeadmin
|
@@ -619,3 +619,4 @@ specification_version: 4
|
|
619
619
|
summary: Active Admin add-ons
|
620
620
|
test_files:
|
621
621
|
- spec/spec_helper.rb
|
622
|
+
has_rdoc:
|