Responsive File Manager. Prevent modal close on image select - javascript

The plugin is this: http://www.responsivefilemanager.com
I'm using the stand-alone feature in a bootstrap modal. Is it possible to prevent modal close on image select?

Responsive File Manager not support using the stand-alone feature in a bootstrap modal.
You can use javascipt popup instead of bootstrap modal.
Image
Do not forget add popup parameter and value (1) to URL dialog.php?type=1&popup=1&field_id
And popup open_popup method for JS.
function open_popup(url)
{
var w = 880;
var h = 570;
var l = Math.floor((screen.width - w) / 2);
var t = Math.floor((screen.height - h) / 2);
var win = window.open(url, 'ResponsiveFilemanager', "scrollbars=1,width=" + w + ",height=" + h + ",top=" + t + ",left=" + l);
}

First off this is a plugin so not garenteed to work with framework such as bootstrap.
Ideally would need to see your code to make a judgement on the problem.
A modal will close on "submit" as the modal is designed as a pop-up, you click something then it goes, you can place form elements in the modal, but soon as "submit" button is clicked, the modal closes. I would suggest looking at the coding (as i cant) and see if the image select function is casuing it to close.
Again place your code in a fiddle and we can all look at it better.

Related

Open a new page with div contents

I have some hidden divs in a HTML page with specific IDs:
<div id='log1' style='visibility: hidden;display: none;'>content</div>
<div id='log2' style='visibility: hidden;display: none;'>content</div>
And then some links:
<a href='?' target='_blank'>Log 1</a>
<a href='?' target='_blank'>Log 2</a>
I want the browser to open a new page / tab (or even a popup but this might be bad if the user has popup blockers) with the contents of the corresponding div.
I know I could do some Javascript to create a floating div and show the data in the same page, but I'd like to avoid that. Moreover, if there is a way of doing what I ask without JS (which I doubt) even better.
You can't do a popup based on hidden divs in your HTML without using JavaScript, no. There's a CSS trick where if you put the divs far off the page and give them an ID, then link to that as an anchor, the browser will scroll it into view.
On the JavaScript side, it's fairly straightforward. First, add a data-log attribute to them to tell us what log we should show, then:
var links = document.querySelectorAll("...some selectors for your links...");
Array.prototype.forEach.call(links, function(link) {
link.onclick = function() {
var log = document.getElementById(this.getAttribute("data-log"));
var wnd = window.open("", "_blank");
wnd.document.write(
"<!doctype html>" +
"<html><head>" +
"<meta charset='appropriate charset here'>" +
"<title>Title here</title>" +
"</head><body>" +
"<div>" + log.innerHTML + "</div>" +
"</body></html>"
);
wnd.document.close();
return false; // Prevents the default action of following the link
};
});
Note the window.open must be done within the click handler; most popup blockers will allow the popup if it's in direct response to a user action.
window.open returns a reference to the window, and then we can write to its document.
(I don't normally use onclick handlers, but you didn't mention using any library and there's still a lot of IE8 out there. Using onclick lets us use return false to prevent the default; details in this small article on my anemic little blog.)
var newWindow = window.open("about:blank", "", "_blank");
newWindow.document.write(html);
In this case you should be doing this using javascript within a call back it could be on page load or on button click or something else

How to open popup window with window.open() having the confirmation message as Yex/No?

I am opening a pop-up window having the Message asking for confirmation that "Do you want to delete a record" with Yes/No buttons. But, its not working correctly. Below is the code:
var modal = window.open (sUrl,"", "dialogHeight:" + iHeight + "px; dialogWidth:" + iWidth + "px;status=no;scrollbars=yes;resizable=no;titlebar=no;", null);
modal.dialogArguments = messageObject;
As the program goes to this line it opens the pop-up window but does not load it and proceeds further finishing the whole JavaScript code. I want the program to stop till it gets confirmation from the child window Yes/No.
Note: I am getting the value of Yes/No using a hidden variable in the parent window. Here is the code written in child window and which gets me the confirmation value:
window.opener.setMsgValue(returnValue);
This is the function written in the parent window:
function setMsgValue(msgSel) {
document.getElementById('msgSel').value = msgSel;
}
I know I can do this using the window.showModelessDialog. But, this works only in IE8 and I am doing this code for chrome 39.
You could use something like
if (confirm("Are you sure?")) {
// Delete it!
} else {
// Do nothing!
}
It's shorter, but every browser styles it different.

window.print() from Chrome subwindow - close, then breaks

When in our webapp a Chrome subwindow is launched, either by window.open() or by user clicking a link with target="_blank", then in that subwindow, body onload="window.print()" to auto-launch the print dialog and print preview, then user CLOSES the print/subwindow instead of clicking cancel, the parent window gets completely hosed. Specifically:
No javascript events will fire
No links are clickable
Hitting F5 shows the little spinner in the tab but the page never reloads.
The parent window is truly dead -- all you can do is close it.
If you click cancel on the subwindow (where the print-preview is launched via window.print()) everything is fine. But if user closes the window, all the craziness happens.
This is a known bug in Chrome:
bug 1
bug 2
bug 3
Does anyone know of a workaround for this?
Instead of using window.print(), just bring your content to new window and then call print functionality as given below, to print the content.
following is a function call where we passed element's inner html through it's id to new window.
PrintContent(document.getElementById('div-content-id').innerHTML);
function PrintContent(printableContent) {
var printWindow = window.open("", "Print_Content", 'scrollbars=1,width=900,height=900top=' + (screen.height - 700) / 2 + ',left=' + (screen.width - 700) / 2);
printWindow.document.write(printableContent);
printWindow.document.close();
printWindow.focus();
printWindow.print();
printWindow.close();
return false;
}
I was also facing same problem, it works for me.

Opening multiple images in one window, and opening multiple such type of windows

I am new to html and javascript. I am working on a web based UI where I have a lot of data to show on a web page. I am showing it in table. Now for each row I have 2 images to display. I want to create one link in each row which opens a new window and show both the images. And also when I click on other links in other rows they should also open with the previous window already open.
Here is what I am doing:
for ($i=0;$i<$total_images;$i++){
<tr><td>Open Images with Link $i<td></tr>
}
and here is the javascript
function newPopup(url1,url2) {
popupWindow = window.open(url1,'popUpWindow','height=700,width=800,left=10,top=10,resizable=yes,scrollbars=yes,toolbar=yes,menubar=no,location=no,directories=no,status=yes')
popupWindow = window.open(url2,'popUpWindow','height=700,width=800,left=10,top=10,resizable=yes,scrollbars=yes,toolbar=yes,menubar=no,location=no,directories=no,status=yes')
}
The problem I am having is that this is opening only the second image not both images and I have to close the previous window for opening a new one.
Please tell me what mistake I am doing or what modifications I need to do in code to resolve both problems.
You're using popUpWindow as the reference for both.
That means the 2nd call to window.open will not open a new window, but will use the already existing one.
Give them different refences, for example...
function newPopup(url1,url2) {
popupWindow1 = window.open(url1,'popUpWindow1',...);
popupWindow2 = window.open(url2,'popUpWindow2',...);
}
In addition, due to comments by the OP, if you always want a new window then use _blank as a reference...
window.open(url1,'_blank',...);
You can open both urls in one window as easy as:
function newPopup(url1,url2){
var contents = '<img src="' + url1+ '"></img>' + '<img src="' + url2+ '"></img>' ;
var previewWindow = window.open('','Preview','','');
previewWindow.document.body.innerHTML = contents;
}

window.openDialog does not remove the titlebar on linux

I use the following code to display a popup:
var win = window.openDialog("chrome://broceliand/content/view/popup/nameMapPopup.xul",
"",
"all=no," +
"titlebar=no," +
"chrome=yes," +
"toolbar=no," +
"dialog=no," +
"resizable=no," +
"modal=yes," +
"dependent=yes," +
"top="+popupY+"px," +
"left="+popupX+"px",
args);
On windows the popup is pretty clean. There are no common elements remaining.
But on linux le titlebar still remains and the popup is resizable.
Try setting the hidechrome attribute on the window element to true. See https://developer.mozilla.org/en/xul/window
That might be because on Linux the window decorator is responsible for the titlebar. This can even be a seperate program to the window manager.
Does the popup need to be as a seperate window? Perhaps panel is really what you are looking for.

Categories