how to open a popup including external site (addon SDK)? - firefox-addon-sdk

I am trying just to open a new popup HTML page (from )
window.open ('http://www.google.fr', 'win', 'height=240, width=640, toolbar=no, menubar=no, scrollbars=no, resizable=no, location=no, directories=no, status=no');
Looks like windows does not have options to specify width, height and other options.
https://developer.mozilla.org/en-US/Add-ons/SDK/High-Level_APIs/windows

You would have to use Low-Level SDK API called 'window/utils' and its openDialog() function (instead of open()), which provides more features to set.
require('sdk/window/utils').openDialog({
url: 'http://www.google.fr',
name: 'The window I dreamt of',
features: 'height = 240,' +
'width = 640,' +
'toolbar = no,' +
'menubar = no,' +
'scrollbars = no,' +
'resizable = no,' +
'location = no,' +
'directories = no,' +
'status = no'
});
This API is described here:
https://developer.mozilla.org/en-US/Add-ons/SDK/Low-Level_APIs/window_utils
And here you can find full list of supported features for openDialog():
https://developer.mozilla.org/pl/docs/Web/API/Window/open

Related

add local osrm sever to mapbox gl direction

I am going to use my local osrm server in order to do routing in a map based on mapbox GL. In mapbox-gl-directions.js there is a server part:
var initialState = {
api: 'https://api.mapbox.com/directions/v5/',
profile: 'driving-traffic',
unit: 'imperial',
proximity: false,
styles: [],
controls: {
inputs: true,
instructions: true
},
I would like to replace api with 'localhost:5000/route/v1/'
but it is not working.
Thanks.
OK. There are two lines that should be modified in mapbox-gl-directions.js.
First: change
api: 'https://api.mapbox.com/directions/v5/',
to
api: 'localhost:5000/route/v1/driving/',
Second: change
request.open('GET', api + 'mapbox/' + profile + '/' + query + '.json?' + options.join('&'), true);
to
request.open('GET', api + query + '?alternatives=true&steps=true&geometries=polyline&overview=full&annotations=true', true);

Creating a geojson-vt and displaying in Leaflet 0.7

I have a GEOJSON that I am loading up and displaying on a map using Leaflet it is, colour coding them depending on the abundance of the animal in an area and able to display a popup with more information.
What I have been trying to do is turn this into a vectorTile using geojson-vt and display this. This polygon geojson is one of the smaller and takes a long time to load and some others crash the browser.
I have tired to work through the example here http://bl.ocks.org/Sumbera/c67e5551b21c68dc8299 but I cannot understand what is happening.
I am definitely open to other ideas on how to display this data, I am very much a newbie.
If you wish to see what I have so far please look at http://huntingspots.co.nz/gareth/leaflet_layering.html.
Thank you very much for your time.
//Pig Layer
var pigLayer = new L.LayerGroup();
$.getJSON("feralpig.geojson",function(hoodData){
L.geoJson( hoodData, {
style: function(feature){
var fillColour,
abundance = feature.properties.Abundance;
if (abundance == "H") fillColour = "#194866";
else if ( abundance == "M" ) fillColour = "#2c7eb2";
else if ( abundance == "L" ) fillColour = "#40b5ff";
else fillColour = "#f7f7f7"; // no data
return { color: "#999", weight: 1, fillColor: fillColour, fillOpacity: .4 };
},
onEachFeature: function( feature, layer ){
layer.bindPopup( "<strong>" + "Species: " + "</strong>" + feature.properties.Scientific
+ "<br/>" + "<strong>" + "Common Name: " + "</strong>" + feature.properties.CommonName
+ "<br/>" + "<strong>" + "Abundance: " + "</strong>" + feature.properties.Abundance
+ "<br/>" + "<strong>" + "Data collection method: " + "</strong>" + feature.properties.AbundRelia
+ "<br/>" + "<strong>" + "Notes: " + "</strong>" + feature.properties.AbundNotes);
}
}).addTo(pigLayer);
});

I am using action_send for Facebook sharing here insert image only but not added text what is the reason?

Here is Facebook sharing code:
String text = "Offer Ends:" + offerending + "\n Offer Type:"
+ offertype + "\n Address:" + offaddress + "\n"
+ webbsuitee;
String completePath = Environment.getExternalStorageDirectory()
+ "/" + "temporary_file.jpg";
File file = new File(completePath);
// Uri imageUri = Uri.fromFile(file);
Uri imageUri = Uri.fromFile(file);
Intent shareIntent = new Intent();
shareIntent.setAction(Intent.ACTION_SEND);
shareIntent.setType("image/*");
shareIntent.putExtra(Intent.EXTRA_TEXT, "Hello");
shareIntent.putExtra(Intent.EXTRA_STREAM, imageUri);
shareIntent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
startActivity(Intent.createChooser(shareIntent, "send"));
It is closed by Facebook API. You need to use the Facebook SDK for Android to do so!
check this: https://developers.facebook.com/bugs/332619626816423

How to close a popup window in Liferay?

I load the WebContent edit portlet on a Popup window using the following code:
<liferay-ui:icon
image="edit"
label="true"
message="news-edit-url"
url="${oneNews.newsEditUrl}"
/>
editUrl:
taglibEditURL = "javascript:Liferay.Util.openWindow({dialog: {width: 960}," +
"id: '" + renderResponse.getNamespace() + "'," +
"title: '" + LanguageUtil.format(request.getLocale(), "edit-x", HtmlUtil.escape(assetRenderer.getTitle(request.getLocale()))) + "'," +
"uri:'" + HtmlUtil.escapeURL(editPortletURLString) + "'});";
When the content is saved or published, the portlet is loaded on the popup window. I want the popup window to close and the portlet with the editURL link to refresh.
Any help regarding this...
Here is the code to close the pop-up, this should be present in the parent page which opens the pop-up:
Liferay version 6.1
Liferay.provide(
window,
'<portlet:namespace />closePopup',
function(popupIdToClose) {
var A = AUI();
A.DialogManager.closeByChild('#' + popupIdToClose);
},
['aui-base','aui-dialog','aui-dialog-iframe']
);
Liferay version 6.2
Liferay.provide(
window,
'<portlet:namespace/>closePopup',
function(popupIdToClose) {
var popupDialog = Liferay.Util.Window.getById(popupIdToClose);
popupDialog.destroy();
},
['liferay-util-window']
);
Here is the code to refresh the portlet which opened the pop-up. This should be present in the parent page which opens the pop-up:
Liferay.provide(
window,
'<portlet:namespace />refreshPortlet',
function() {
<%-- refreshing the portlet [Liferay.Util.getOpener().] --%>
var curPortletBoundaryId = '#p_p_id<portlet:namespace />';
Liferay.Portlet.refresh(curPortletBoundaryId);
},
['aui-dialog','aui-dialog-iframe']
);
It is up to you how to call the closePopup & refreshPortlet functions. One way is you can let the pop-up refresh and call the closePopup function from the pop-up itself only when the request is successfully processed and then call the refreshPortlet function also from the pop-up.
Here is a code-snippet which would help you to call parent-page functions from the pop-up:
Liferay.Util.getOpener().<portlet:namespace />closePopup(popupIdToClose);
Liferay.Util.getOpener().<portlet:namespace />refreshPortlet();
The popupIdToClose is the same id which is used when opening the pop-up as shown:
taglibEditURL = "javascript:"
+ Liferay.Util.openWindow({"
+ "dialog: {width: 960},"
+ "id: '" + renderResponse.getNamespace() + "'," // This is the "popupIdToClose"
+ "title: '" + LanguageUtil.format(request.getLocale(), "edit-x", HtmlUtil.escape(assetRenderer.getTitle(request.getLocale()))) + "',"
+ "uri:'" + HtmlUtil.escapeURL(editPortletURLString)
+ "'}"
+ ");";
Hope this helps.
AUI taglib solution for 6.2 version. No additional JS required.
<aui:button cssClass="close-panel" type="cancel" value="close" />
Important part is cssClass="close-panel".

phonegap - using external site as app - facebook login

I'm building a app site running through phone gap. Phone gap simply checks the user has internet connection and loads an external web app into the frame. I can navigat through the site fine with no blibs but as soon as I try the login to Facebook (either PHP redirect or javascript SDK) the app suddenly gets its navbar back or opens a new window (javascript SDK).
Is there anyway I can prevent this?
regards
It took some doing but using the ChildBrowser plugin, I've managed to login! (this is for android) I've used some code from a facebook connect plugin which didnt work for me, re wrote some stuffs so I could understand it and now works. Chears Juicy Scripter!
var fb_success = 'https://www.facebook.com/connect/login_success.html';
var fb_logout = 'https://www.facebook.com/connect/login_failed.html';
var fb_logout_ = 'http://m.facebook.com/logout.php?confirm=1&next=' + fb_logout;
var authorize_url = '';
var my_client_id = '##################';
var my_secret = '######################';
var my_type = 'user_agent';
var my_display = 'touch';
var token = false;
var fb_code = false;
var device_ready = false;
var ajax_url = '';
function logged_in(){
// alert('do what you need to do!');
}
function fb_force_logout(){
}
function fb_auth_check(){
console.log('fb_auth_check()');
if( fb_code !== false ) {
console.log('ajax test instigated...');
ajax_url = 'https://graph.facebook.com/oauth/access_token?client_id=' + encodeURIComponent(my_client_id) + '&client_secret=' + encodeURIComponent(my_secret) + '&code=' + encodeURIComponent(fb_code) + '&redirect_uri=' + fb_success;
$.ajax({
url: ajax_url,
type: 'POST',
success: function(html){
token = html.split("=")[1];
console.log('success! token = ' + token);
window.plugins.childBrowser.close();
fb_init();
},
error: function(error) {
console.log('there was an error...' + ajax_url);
window.plugins.childBrowser.close();
}
});
}
}
function fb_track_redirects(loc){
console.log('redirect tracked... ' + loc);
if ( loc.indexOf(fb_success) >= 0 || loc.indexOf(fb_success) > -1 ) {
fb_code = loc.match(/code=(.*)$/)[1]
console.log('success redirect... fb_code=' + fb_code);
fb_auth_check();
window.plugins.childBrowser.close();
} else if ( loc.indexOf(fb_logout) >= 0 || loc.indexOf(fb_logout) > -1 ) {
window.plugins.childBrowser.close();
}
}
function inner_init(){
console.log('inner_init()');
if( token === false ) {
console.log('token was false...');
authorize_url += "https://graph.facebook.com/oauth/authorize?";
authorize_url += "client_id=" + encodeURIComponent(my_client_id);
authorize_url += "&redirect_uri=" + encodeURIComponent(fb_success);
authorize_url += "&display=" + encodeURIComponent(my_display);
authorize_url += "&scope=publish_stream,offline_access";
console.log('instigated location change...');
window.plugins.childBrowser.onLocationChange = function(loc){
fb_track_redirects(loc);
}
console.log('open Facebbok login window');
window.plugins.childBrowser.showWebPage(authorize_url);
}else{
logged_in();
}
}
function fb_init(){
console.log('fb_init()');
if( device_ready === false ) {
console.log('first device run...');
document.addEventListener("deviceready", function(){
device_ready = true;
console.log('device ready...');
inner_init();
}, false);
}else{
inner_init();
}
}
$(document).ready(function(){
$('#login').bind('click', function(){
fb_init();
return false;
})
});
</script>
This is how it works for all apps native or web without patching the SDK code.
This is probably can be done, but will require digging into code. The question is do you really need it? This is a desired behavior.
You can try to use PhoneGap Facebook plugin and enable Single Sign On so native Facebook App if exists will be opened instead of browser to authenticate the user.
BTW,
Apps that are just external sites wrapped mostly rejected in app store.
Update:
Where is some points that may be also helpful in answer (by Facebook employee) to similar question How can I use an access token to circumvent FB.login().
Also have a look on ChildBrowser PhoneGap plugin (and Example).