Dropzone: How to open the document when using double clicks on the thumbnail - dropzone.js

I would like to open the document when the user double clicks on a Dropzone thumbnail but cannot seem to find o how to do this in the documentation.

myDropzone.on("addedfile", function(file) {
file.previewElement.addEventListener("click", function() {
...
});
});

Related

CKEditor not editable in IE11 after ajax call

Example:
Jsfiddle
If the page is loaded the first time, the CKEditor is working right and the value of the editor can be edited. After hitting the button "ajax" which is calling the following function (cursor must be in the editor field):
function ajax_call() {
var html = "<textarea id=\"textarea\"><p>test 1</p><p>test 2</p><p>test 3</p></textarea><script type='text/javascript'>jQuery(document).ready(function() { ckEditor('textarea'); });<\/script>";
$.post("/echo/html/", { html: html }, function(data){
jQuery('#target').html(data);
});
}
it isn't possible to click on the text in IE11 to edit the value. Clicking beyond the text or left of it enabels the editor again.
Looks like creation of new textarea after CKEDITOR is initiated brakes editor in IE. Though i just tried to set data directly on instance of CKEDITOR and it worked fine,rather than creating new textarea tag.
function ajax_call() {
var html = "<p>test 4</p><p>test 5</p><p>test 6</p>";
$.post("/echo/html/", { html: html }, function(data){
//jQuery('#target').html(data); <-- Removed from original
CKEDITOR.instances['textarea'].setData(data)// <-- Added
});
}
function ckEditor(id) {
CKEDITOR.replace(id, {
language : 'de',
});
}
jQuery(document).ready(function() {
ckEditor('textarea');
});
Here is working example:
http://jsfiddle.net/2wq86gqs/15/

clicking a thumbnail image in galleria

I need to create separate pre, next, play and index count out of the current galleria and thumb containers.
I have worked out how to do the pre/next and play/pause but can not tie it into if a person clicks on the thumbnail image.
How do I bind the thumbnail being clicked to update the index count.
i.e.from 5/20 to 9/20 or whatever thumbnail was clicked.
$('.galleria-thumbnails .galleria-image').click(function() {
var current_index = $('.galleria-thumbnails .galleria-image').index($(this)));
});
Hope this helps!
Try as below.
Galleria.ready(function() {
this.bind('thumbnail', function(e) {
$(e.thumbTarget).parent().unbind('click').click(function() {
$('#id_of_hidden_div').show();
});
});
});

Ajax file upload is not working when used the second time

I'm using this jquery plugin ajaxFileupload in our project. My design is I have a file upload control and set the opacity to 0.01 and then using an anchor link, I trigger the file upload control click event. This works fine until I try to click the anchor link the second time which it doesn't open the file dialog box.
Here is my code.
$(".btnUpload").live("click", function () {
$(".lblUploadError").text("");
$(".fleAttachment").trigger("click");
});
$(".fleAttachment").change(function () {
var reg = /^.*\.(jpg|JPG|gif|GIF|jpeg|JPEG)$/;
var vals = $(this).val(),
val = vals.length ? vals.split("\\").pop() : "";
if (reg.test(vals) == false) {
$(".lblUploadError").text("Invalid Image Type. We only accept .GIF or .JPG");
} else {
ajaxFileUpload();
eval($(".btnRefreshAttachmentList").attr("href"));
}
});
I don't see any error in the console so it makes it difficult to debug it.
Change
$(".fleAttachment").change(function() {
to
$(".fleAttachment").live('change', function() {
$( document ).on( "click", ".fleAttachment", function() {
//--> Logic Here // jQuery 1.7+
});
this.value="";
at the end should work

Appcelerator switch windows

I have a main window (app.js) and two sub-windows (login.js and signUp.js)
Here is my app.js
var login=Titanium.UI.createWindow({
url:'wins/login.js',
title:'Login',
backgroundColor:'#CCC',
navBarHidden:true
});
var signUp=Titanium.UI.createWindow({
url:'wins/signUp.js',
title:'Sign-up',
backgroundColor:'#CCC',
navBarHidden:true
});
login.open({fullscreen:true});
Now I want to open signUp.js from with login.js. Is there any way to do this? I've tried googling and reading over the documentation to no avail.
just typed this up, not perfect, but this is the general idea.
// create buttons on main window
var loginBtn = Titanium.UI.createButton({
title : 'LOGIN'
});
var signUpBtn = Titanium.UI.createButton({
title : 'SIGN UP'
});
// add to window
mainWindow.add(loginBtn);
mainWindow.add(signUpBtn);
// associate click events
loginBtn.addEventListener('click', function() {
Ti.API.log('loginBtn button clicked, show window');
login.open();
});
signUpBtn.addEventListener('click', function() {
Ti.API.log('signUpBtn button clicked, show window');
signUp.open();
});

ckeditor - onpaste event

Does anyone know how I can attach an onpaste event in CKEditor 3.x?
I basically want to grab CTRL + V data and add few text to it and then add it to the editor.
I have looked around but have not found a definitive answer. CKEditor forum is of not much help.
This should do the trick
var editor = CKEDITOR.instances.YourInputControlName;
editor.on('paste', function(evt) {
// Update the text
evt.editor.setData(evt.editor.getData() + ' your additional comments.');
}, editor.element.$);
Your both examples are a little bit synthetic.
At first, editor.getData() gets all the content of editor, so if you want to process only pasted data, you need to get ev.data.html and paste to correct place.
editor = CKEDITOR.instances.editor1;
editor.on('paste', function (evt) {
var editor = evt.editor;
evt.stop(); // we don't let editor to paste data, only for current event
// show loader that blocks editor changes
$.post('clean.php', {html: evt.data.html}, function (data) {
editor.insertHtml( data.html ); // text will be inserted at correct place
// hide loader
}, 'json');
});
Don't use functions editor.setReadonly(true/false), you won't be able to paste text in correct place (in cases with async data processing).
This example edits the content to be pasted by removing all img elements.
CKEDITOR.on('instanceReady', function (ev) {
ev.editor.on('paste', function (ev) {
ev.data.html = ev.data.html.replace(/<img( [^>]*)?>/gi, '');
});
});
editor = CKEDITOR.instances[id];
editor.on('paste', function (evt) {
evt.stop();
var data = evt.data.dataValue;
if (window.chrome || window.safari) {
// removing span wrapper on webkit browsers.
data = $(data).html();
}
evt.editor.insertHtml(data);
});
I know it's an old question, but thought I'd add my version of aliaksej's answer as it allows the use of a custom 'cleaner' - it didn't quite work for me until I modded it as below.
editor = CKEDITOR.instances[id];
editor.on('paste', function (evt) {
evt.stop();
$.post('/actions/clean.php', {html: evt.data.dataValue}).done(function (data) {
evt.editor.insertHtml(data);
}, 'json');
});

Resources