You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Great work with this so far. I've found that when selecting images you have to select a new upload.
I've created a way that you could do this by opening a popup showing the Django file list, after selecting a file it returns the image back to sir trevor. My demo uses django-filer as that supports the popup and callback out of the box.
Could you add this as a real feature to your version?
Here is my example script you embed on the same page as sir trevor, and it adds the events to load the popup window and listen to the returned value
/**
* Editor
* @class Editor
* @example var editor = new Editor();
**/
/*globals window, SirTrevor*/
(function () {
'use strict';
var module = {
popup: 'popup.html', // '/admin/filer/folder/7/list/?_popup=1',
/**
* @method init
*/
init: function () {
var me = this;
// on page load, add sir trevor event
this.addEvent('load', window, function (e) {
SirTrevor.EventBus.on('block:create:new', function (e) {
me.addClick(e.el);
});
me.checkAll();
});
// when callback is fired from popup window
window.dismissRelatedImageLookupPopup = function (win, chosenId, src) {
document.getElementById(me.current).innerHTML = '<img src="http://djangosuit.com' + src + '" alt="" id="' + chosenId + '" />';
win.close();
};
},
/**
* @method checkAll
*/
checkAll: function (el) {
var i = 0,
divs = document.getElementsByTagName('div');
for (i = 0; i < divs.length; i += 1) {
if (divs[i].getAttribute('data-type') === 'image') {
this.addClick(divs[i]);
}
}
},
/**
* @method addClick
*/
addClick: function (el) {
var me = this,
win;
this.addEvent('click', el.firstChild, function (e) {
e.preventDefault();
me.current = el.id;
win = window.open(me.popup, 'files', 'height=500,width=800,resizable=yes,scrollbars=yes');
win.focus();
});
},
/**
* @method addEvent
*/
addEvent: function (name, el, func) {
if (el.addEventListener) {
el.addEventListener(name, func, false);
} else if (el.attachEvent) {
el.attachEvent('on' + name, func);
} else {
el[name] = func;
}
}
};
module.init();
}());
The text was updated successfully, but these errors were encountered:
Great work with this so far. I've found that when selecting images you have to select a new upload.
I've created a way that you could do this by opening a popup showing the Django file list, after selecting a file it returns the image back to sir trevor. My demo uses django-filer as that supports the popup and callback out of the box.
Could you add this as a real feature to your version?
Here is my example script you embed on the same page as sir trevor, and it adds the events to load the popup window and listen to the returned value
The text was updated successfully, but these errors were encountered: