I'm currently working with CKFinder to upload images to a web app (and so on).
Now the problem is, there is no callback when the window closes:
With that I mean something like the javascript "onbeforeunload" event. The popup function only returns the api, and the api only contains the document and not the window.
I've looked through the docs and found a "selectActionFunction", but no sign of a "cancelActionFunction" or something similar.
http://docs.cksource.com/ckfinder_2.x_api/symbols/CKFinder.config.html
Thanks
Ok, in the end I didn't really find a solution within ckfinder, but since I was already working with jquery ui I just opened the ckFinder in a ui dialog box. Which gives me the ability to add a callback to the close button.
Maybe it is possible to add a cancel callback through the skins, but I chose the quick way of ui dialogs. (The only skinning I tend to do is in CSS, which is more then enough most of times)
Anyway, I hope this helps someone else too.
Related
I actually want to add a button to Gmail. When someone opens a email, he/she sees a button and when someone clicks on it, I add a function to it. I know one way but it's very intensive where I use setInterval() every 300 ms and run a function to check if it's Gmail or not and then add a button dynamically. I need something less intensive because I don't want people to have problems running my add on.
I want it all from my add on script so that I can easily communicate between other functions of my add on.
To add to pages it depends. Pages can do many tricky things (like GitHub using PJAX see this addon on how it was done).
Method 1 - addEventListener to window or gBrowser
But most usually you can catch a DOMContentLoaded or load event. Template HERE.
Method 2 - Observe http-on-examine-response and loadContext
If the URL of the nsIHTTPChannel matches your pattern then get the contentWindow from the loadContext and then manipulate. I need to make a clean template for this but you can see some messy ones: here and here
Method 3 - Add ProgressListener
ProgressListeners are nice because it helps you catch anchor changes, and usually when sites ajax and change page they change the url somehow but it doesnt really load a new page. I'm working on a template for this but it's not ready yet.
Info about addEventListener
If you add event listener in some situations it works for when 3rd parameter is true or when false. If you find one that works for your situation it will always work.
To figure out what combination works for you install this addon: event-listener-experiment-DOMC-and-load it's on GitHub so you can install straight from GitHub with this addon GitHub Extension Installer
Install that addon then navigate to your page, look in the browser console to see what feedback you're getting. It will tell you which works for you. If you need more help tell me the site and I will help you figure it out.
Here's a bootstrap template you can use once you figure out the combination:
I have just started using ShareThis Widget to help handle social media integration with one of our sites. While the functionality is great, I feel I lose a lot of the capabilities I have if I were to code each item by hand, such as the ability to control the size of the windows opened by clicking a 'share' functionality.
While their site shows basic functions you can add to the buttons (url, etc) I am looking to customize the feel such that when a button is clicked, I can control the size of that window or even possibly open in an existing colorbox snippet.
Has anybody had luck with this before? When I try to control via javascript function it just seems to get overwritten or ignored.
You'd need to unbind their events and handle them all yourself. It probably isn't a good idea, as your code will be at the mercy of their implementation.
I am not sure if your question is resolved, but you will need to add as following inside JS.
popup: 'true'
The same is on their Support Page
I'm working with Sharepoint 2007. I use the built in AssetImagePicker.aspx and I need to retrieve the image url from that page and use it in my custom webpart.
I want to run my javascript code to run when clicking the OK button of the AssetImagePicker.aspx but I can't find a way to do that.
Does anyone know how to do this?
Thanks
Not sure if I'm understanding the question properly, and I know nothing about Sharepoint (and AssetImagePicker.aspx) but it sounds like you want to add an event handler to the OK button: to run a function when the click event of the button is fired.
You can either code event handling yourself (see W3Schools or Quirksmode for examples of this) or (probably better) use a library like jQuery.
Here's the thing
I have this master page, and in one of its slave pages there's a couple of Excel report generators, which, when retrieving the data, they take quite an awefull time because of the ammount of the data.
Well, i'm using a simplemodal windows to show a little gif to keep the user entertained. The thing is, i want this modal to close once its done doing the work
I can close it with the ESC key, but i want it to close by itself once its done working. I already tried with this code
SimpleModal breaks ASP.Net Postbacks
but it didnt worked, maybe its cuz i'm creating an excel file from a gridview, and its writting the scripr to another buffer.
I'm thinking on having close button on the modal once the whole thing its finished, but i'd rather have it close by itself
Any idea on how i can accomplish this will be pretty much appreciated
While I can't provide much help with SimpleModal, maybe you shouldn't use a modal dialog to show a loading/progress icon. I would suggest taking a look at spin.js:
http://fgnass.github.com/spin.js/
This probably makes a little more sense for your use case, and is pretty easy to use.
Good luck!
Try appending to the .NET form, this fixes some issues with jQuery's dialog so it may help.
$("#sample").modal({
opacity:80,
overlayCss: {backgroundColor:"#fff"}
}).parent().appendTo("form");
On the "work is done", you can programatically close the dialog using:
$.modal.close();
Well, i didnt wanted to use a popup windows, but given that to create a Excel file from a gridview needs to write the html of the gridview on the buffer and execute it, it was never reaching the part where the javascript was to be written and executed, so, no other choise than send the dataSet over a Session variable into a popup windows which generate the excel file, so having somehting like a parallel work
I had a pretty ugly issue with IE8, my save dialog wasn't appearing, it worked on IE6 and IE7, as well with opera, firefox and chrome, but IE was giving a issue. Found there's a security option which that didnt allowed the save dialog to appear. For any one having a similar issue, its on Internet option -> Security -> Custom Level... -> Downloas -> Automatic Prompting for file downloads -> Need to be "Enabled"
Any way, thanks for tha help, hope this info also helps someone else!
Sorry for the title.....bit difficult to word what I really want to ask.
Some websites allow a user to copy and paste some widget for use with their own site. For example, getsatisfaction. Yes, those feedback icons that I hope most of you see in various places.
If you have a look at twitterfeed, on the left there will be a feedback icon, once clicked on a nice modal window comes up. the modal windows content is in an iframe to an external source.
I really like this, but my question is:
I could do the same by using some jQuery library for the modal window and then linking the modal content to a site on my page, but how do I stop this from becoming obtrusive to a sites other javascript files?
For example, let's say i'm using my js code and the relevant jquery code, and i've minified it into one file. The user adds my widget to their site. If they're using jQuery, how do I make sure my code isn't going to interfere with theirs?
Would the best way be to use a modal window library which is not very popular?
Thanks very much. Hope that makes sense!
EDIT: I could write my own modal window functionality code, but i'd much rather use a library which already does it.
You can dynamically load jQuery only if it is needed.
First check for the existance of the jQuery object. If not add the script tag.
There are some challenges to this, as there is no onload event when adding a script tag to a page, that works consistently accross browsers, so you will have to poll to see if it fully loaded, and only then run your code.
There is an article on how to do this:
http://www.squidoo.com/load-jQuery-dynamically
You may still have an issue if the user has a differnt version of the jquery library though, although you can probably get around this with some additional checks.
jQuery UI has very nice dialog components that should fit your purpose. Inside them you can instantiate an iframe. see:
http://elijahmanor.com/demos/jqueryuidialogiframe/index.html
If I understand all this correctly, the iframe content is a separate page, so there is no case where your javascript code in that page would interfere with the javascript of the calling page, but maybe I haven't understood that part correctly?
EDIT:
I think I understand what you meant, in that you want to package up the code that you will write that opens the modal window with the iframe. SO you want to make sure that this code does not interfere with existing jQuery code that the user is using.
I think this is a good use case for a jQuery plugin. This way the user of the page can use your function like any jQuery function, so less likelyhood of collisions