My RN 0.61.5 app is running the react-native-gifted-chat 0.13.0. Here is the render which is pretty plain:
render() {
console.log("In GiftedChat render : ");
return (
<GiftedChat
messages={this.state.messages}
onSend={messages => this._onSend(messages)}
user={{_id: this.state.myself.id,
name: this.state.myself.name,
avatar: this.state.myself.user_data.avatar}}
/>
);
}
I would like to add a file upload button (which can open gallery or file manager) by the typing text box allowing user to upload an image or video file. How can I do that? I have searched online and gone over the doc but did not find a way/hook to add a button to the chat screen. Many thank.
There is a prop called renderActions() in gifted chat docs. It adds a custom action button on the left of the message composer. I have implemented image uploading button by using this.
<GiftedChat
messages={this.state.messages}
onSend={this.send}
...
renderActions={() => (
<React.Fragment>
<ImgPicker setmsgImgUrl={this.setmsgImgUrl} />
</React.Fragment>
)}
/>
I have created the ImgPicker component by using codes in the expo docs image picker.
If you want to see the ImgPicker component code, here is the link.
Github link for the ImgPicker Component Code
Related
Im writing a python script which reads from a file and plots graphs in seperate html files with plotly.I would like to have a button to redirect from one page to another(load from disc).I've come across this :
updatemenus = list([
dict(type="buttons",
buttons=list([dict(label = 'Next',method = 'update', args = ['shapes', []])])
)])
layout=go.Layout(title="Iteration_Number:"+str(counter_iter),updatemenus=updatemenus)
But this is used for updating data or changing layout. What i want is open another html page from disc on button click. Is that possible ?
I have also seen this :
import webbrowser
url = "file:///home/tinyOS/Simulation_"+str(counter_iter+1)+".html"
webbrowser.open(url)
Which helps me open a new page but again i want it to happen when clicking on the button.Any ideas? Thanks a lot !
From the question I understand that you want a group of buttons on the plotly graph, that are going to open a plotly graph in new tab.
So you need not use plotly buttons for this requirements.because they are mainly used for restyle, relayout, etc., so there is no relation between these buttons and opening links in new tabs.
I would recommend having simple html buttons which on click are going to take you to the new tab.
A simple way to do it will be, wrap the plot in a div set to relative positioning and make the div wrapping the button absolute positioned and position it anywhere over the graph, please refer the below example and let me know if this solves your issue!
Solution:
import plotly.plotly as py
import plotly.graph_objs as go
import plotly.offline as py_offline
from IPython.core.display import display, HTML
py_offline.init_notebook_mode()
display(HTML("""
<style>
.wrapper{
position:relative;
}
.button-group{
position:absolute;
top:40px;
left:90%;
z-index: 30000;
}
.button-group a{
display:block;
}
</style>
"""))
What is happening in the above piece of code is, first we include the necessary packages, then styles needed!
data = [go.Bar(
x=['giraffes', 'orangutans', 'monkeys'],
y=[20, 14, 23]
)]
display(HTML("""
<div class="wrapper">
<div class="button-group">
Google It
Yahoo It
</div>"""
+str(py_offline.plot(data, filename='plot_name' ,output_type="div", include_plotlyjs=False))
+ '</div>'))
The main piece of code, with which we embed the buttons is shown above, first we define the plotly plot , then using display and html functions, we can embed the buttons inside a div with class button-group and with CSS we position that button.
Please do try the above code and let me know if there are any doubts regarding the working!
Hi i have added the google reCaptcha in the bootstrap modal i am using same key on the index page and on the modal which opens after button click on the index ,on page it is working fine but on modal popup it is showing error "ERROR for site owner:
Invalid domain for site key"
I have added the screenshot
Try to enqueue recaptcha script or add it to the footer like this
<script type=’text/javascript’ src=’https://www.google.com/recaptcha/api.js?;ver=2.0′></script>
I have a SharePoint 2013 Community Site that is used for discussions. I want to create a link to a specific discussion item that will open the discussion item in "Reply" mode, i.e. the mode you get to if you click the Reply button just under the Discussion item text. I want to do this because the Reply mode text entry box is right under the discussion item text where it is obvious to see. The default reply text entry box is at the bottom of the page and it scrolls off the page if there are already a lot of replies on the topic.
Here is the default view on a Discussion item
If you click the "Reply" link here
then the a Reply Pane opens up right under the discussion item text.
But what I want to do it to be able to send a URL by mail that will open the discussion thread already in Reply mode.
The solution I found to do this consisted of customizing the /Lists/Community Discussion/Flat.aspx with client-side script as follows.
First insert a Script Editor into the page (Settings -> Edit Page -> Add a Web Part -> Categories -> Media and Content -> Content Editor -> Script Editor.
Next upload a copy of jquery.min.js to the Site Assets library.
Then add the following code to the Script Editor using Edit Snippet:
<script src="/SiteAssets/jquery.min.js" type="text/javascript"></script>
<script language="javascript" type="text/javascript">
$(document).ready(function() {
if (location.search.indexOf('replyMode=1') != -1)
{
openReplyPane();
}
});
function openReplyPane()
{
var mouseEvent = new MouseEvent("click", {
'bubbles': true,
'cancelable': true,
'view': window,
'detail': 0,
'screenX': 0,
'screenY': 0,
'clientX': 0,
'clientY': 0,
'ctrlKey': false,
'altKey': false,
'shiftKey': false,
'metaKey': false,
'button': 0,
'relatedTarget': null,
'currentTarget': 'form#aspnetForm',
'srcElement': 'a#commandBar0-reply-Link.ms-secondaryCommandLink',
'target':'a#commandBar0-reply-Link.ms-secondaryCommandLink',
'timeStamp':1425842811416,
'toElement':'a#commandBar0-reply-Link.ms-secondaryCommandLink'
});
var replyLink = document.getElementById('commandBar0-reply-Link');
replyLink.dispatchEvent(mouseEvent);
}
</script>
Save your changes.
Now if you add the string "&replyMode=1" to the end of the URL for the discussion item, you can navigate to the post, and the Reply pane will be automatically opened for the user.
I have a Timeline App that creates a wall posting via the Graph API. The wall posting indicates that the posting was created by the App, which is fine. However, the link for the app points to the Canvas page: http://apps.facebook.com/app_name_space.
I need the link to point to the timeline version of the App: http://www.facebook.com/pages/PAGENAME/PAGEID?sk=app_APPID
I have tried the "actions" parameter on the Post call, but that didn't solve the problem.
Redirecting the Canvas page
Since you cannot use a 301 redirect for this purpose, here is what I did (asp.net):
1) Create a folder named 'canvas' under the website root.
2) Add a default.aspx file to the folder (can't use a static file as an app landing page)
3) Add the following javascript to the head tag:
<script type="text/javascript">
var parentPageName = '<%=ConfigurationSettings.AppSettings["ParentPageName"]%>';
var appID = '<%=ConfigurationSettings.AppSettings["AppID"]%>';
var myHREF = "http://www.facebook.com/" + parentPageName + "?sk=app_" + appID;
top.location.href = myHREF;
</script>
4) Change your App Canvas url to point to the 'canvas' folder.
That's how it works, the 'via' link goes to your app, not to an arbitrary page the app is installed on, because it could be installed on any Facebook page.
Redirect users that land on the canvas app to the page tab, if that's what you want
I have a view that can take several seconds to process a GET request and render the results. I'd like to put up a temporary page that says "Processing..." while the view is doing its stuff. How can I do this?
UPDATE
I don't have any control over the link to my page. It is a link to me a third party has on their page. When they click it I run some stuff and display the results. I don't want them to have to click anything on the pages I display.
Ideally, I would like the following:
A user clicks a link to my website that is on a 3rd party website
My websites displays a "processing request" message - the user doesn't have to click anything, just wait.
After a few seconds the results are displayed.
All the user had to do was click a link once and wait for the results.
Some example code would be greatly appreciated as I am quite new to things like jQuery - if that's what I need.
Use jQuery to display the message while waiting for the view to return the result.
Place a hidden div-tag in the page containing the processing message/image.
If you submit the GET request by clicking a button you put an onclick event on the button to display the div-tag. When the view is done processing, the page will be reloaded and the target page will be displayed.
If the view is called using AJAX you can place the show/hide of the div in the ajaxStart and ajaxComplete events.
EDIT: OK since the page will be called from by a 3rd party it will complicate things a bit. I would suggest that you load the page without the data and once the page is loaded you do an AJAX GET request to retrieve the data.
You could do as follows:
Add a hidden div-tag to the page with the Progress message/image.
<div id="progress">Please wait while the page is loading.</div>
Then add the ajax GET call to the page:
$(document).ready(function () {
//Attach the ajaxStart and ajaxComplete event to the div
$('#progress').ajaxStart(function() {
$(this).show();
});
$('#progress').ajaxComplete(function() {
$(this).hide();
});
//Perform the AJAX get
$.get('/your_view/', function(data) {
//Do whatever you want with the data here
});
});
The above code has not been tested but it will give you an idea.
UPDATE
I would suggest that you return a JSON object or similar from your view:
companies = Company.objects.filter(name__istartswith=companyname)
results = [{'value': company.name, 'id':company.id} for company in companies ]
json = simplejson.dumps(results)
return HttpResponse(json, mimetype='application/json')
You can also use the getJSON() method instead of get() in jQuery.
very simple example:
<script>
showProcessingMessage = function() {
$("body").append('<div id="style_me_as_message">processing request</div>');
}
$("body").on('click', "a.slow", showProcessingMessage);
</script>
<a class="slow" href="/slow-response-page/">show slow page</a>