display the tabBar of a GXT Tabpanel to other containers - gwt

I have a GXT TabPanel and would like to hide the tabBar and disable the tabBar to other container.
Now I have hidden the tabBar by set height 0px:
getBar(this.getElement()).setHeight(0)
But how to display tabBar to other containers I do not know how to solve the problem。
When i see the source of TabPanelTemplates
<div class="{style.tab}">
<div class="{style.tabBar}">
<div class="{style.tabStripWrap}">
<ul class="{style.tabStrip}">
<li class="{style.tabEdge}"></li>
<div class="x-clear"></div>
</ul>
</div>
<div class="{style.tabStripSpacer}"></div>
</div>
<div class="{style.tabBody}"></div>
</div>
I try to get the div class="{style.tabBar}", and display the part to other container,but i do not know how to do it.
I do not know if this idea is correct. Could someone help me solve this problem?

I try to display the tabBar to other container like this :
conter.getElement().insertFirst(new SafeHtml() {
private static final long serialVersionUID = 1L;
#Override
public String asString() {
return getAppearance().getBar(ex).getInnerHTML();
}
});
Now the bar is visiable ,but the event is not available

Related

Materializecss Modal on page load not open the modal

I use Materializecss 0.100.2 and i need to open a modal on page load or document ready. But not work, it will be work only if i click on button, i don't know why.
The modal has class "open" but the modal have "display: none" and the div modal-overlay is hidden. It work but not completely.
jQuery(document).ready(function () {
jQuery('#modalInfo').modal();
jQuery('#modalInfo').modal('open');
});
This thing works with vanillaJS. You need to get the modal class using querySelector() and then pass it in M.Modal.init(), and with the help of this instance you can call open() method.
HTML -
<div class="modal">
<div class="modal-content">
<h4>Modal Header</h4>
<p>A bunch of text</p>
</div>
<div class="modal-footer">
Agree
</div>
</div>
JS -
document.addEventListener('DOMContentLoaded', function () {
var Modalelem = document.querySelector('.modal');
var instanceModal = M.Modal.init(Modalelem);
instanceModal.open();
});

How to close Materialize modal only when user clicks on close btn?

I want to close modal ONLY when user clicks on close button. I know, how to do this in Bootstrap. Could you help with Materialize?
You can customize the behavior of Materialize modal using Options which can be found Here at the bottom of the page
change option dismissible to false (which by default in modal plugin is true) so modal only get closed when click on close button.
$('.modalselector').leanModal({
dismissible: false
);
Example Modal
$(document).ready(function(){
$('.modal-trigger').leanModal({
dismissible: false
});
});
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/materialize/0.97.1/css/materialize.min.css" />
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.0/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/materialize/0.97.1/js/materialize.min.js"></script>
<!-- Modal Trigger -->
<a class="waves-effect waves-light btn modal-trigger" href="#modal1">Modal</a>
<!-- Modal Structure -->
<div id="modal1" class="modal">
<div class="modal-content">
<h4>Modal Header</h4>
<p>A bunch of text</p>
</div>
<div class="modal-footer">
Close
</div>
</div>
You can close the modal with the following code:
$('#modalname').closeModal(); or $('#modalname').modal('close');
$(document).ready(function(){
$('#modal1').openModal({
dismissible:false
});
});
Try This It worked for me
Below code worked for me with materialize.css 1.0.0
$(document).ready(function(){
var elems = document.querySelectorAll('.modal');
var instances = M.Modal.init(elems,{
dismissible:false
});
var singleModalElem = document.querySelector('#login-page');
var instance = M.Modal.getInstance(singleModalElem);
instance.open();
})
<link href="https://cdnjs.cloudflare.com/ajax/libs/materialize/1.0.0/css/materialize.min.css" rel="stylesheet"/>
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
<script src="https://cdnjs.cloudflare.com/ajax/libs/materialize/1.0.0/js/materialize.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.2.1/jquery.min.js"></script>
<div id="login-page" class="modal">
<form class="login-form">
<div class="row">
</div>
<div class="row">
<div class="input-field col s12">
<i class="material-icons prefix">account_circle</i>
<input class="validate" id="nick_name" type="text">
<label for="nick_name" data-error="wrong" data-success="right">Nick Name</label>
</div>
</div>
<div class="row">
<div class="input-field col s12">
Entra
</div>
</div>
</form>
</div>
None of the methods worked for me. However, this did,
$('#modal1').closeModal({ dismissible: true});
The leanModal(), openModal(), and closeModal() all failed for me. Things must have changed since then. Instead:
$("#modal1").modal({
dismissible: false
});
or even just calling the modal a second time:
$("#modal1").modal();
Just set the data-backdrop property to static.
If you only want to insert button for closing the modal (sometime CSS conflict won't allow the modal to close) use this:
<span
class="modal-action modal-close"
style="float:right; font-size:30px;"
onclick="$('#myModal2').closeModal();"
>
X
</span>
Came across the need to do something similar and thought I'll share this for others who are looking for it too. I'm using Materialize 1.0.0 and none of the suggestions above worked for me. Basically, we want to be able to have control over the modal's 'dismissible' property and change it whenever we want, from wherever we want and it shouldn't matter if it is before or after the modal is open. The most elegant way I found was to do it this way. This will control the modal's behavior from disappearing when a user clicks outside of its area.
var m = M.Modal.getInstance(modal);
m.options.dismissible = true|false;
where the modal param is your modal div.
Hope that helps.
Pure JavaScript, this is the way.
The span element that will close the modal.
var span = document.getElementsByClassName("close")[0];
When you want to click the X to close the modal you can use this.
span.onclick = function() {
modal.style.display = "none";
}
If you are clicking outside of modal this will close the modal.
window.onclick = function(event) {
if(event.target == modal) {
modal.style.display = "none";
}
}
$(".modal4").addClass('modal-close');
Where modal4 is class of modal you want to close
In Vue Js, By using materialize-css package
Install package npm i materialize-css
import the package import M from 'materialize-css';
Attach the code below in your eventListener such as click
methods: {
closeMaterializeModal(){
var elem = document.getElementById("modal4");
var instance = M.Modal.getInstance(elem);
instance.close();
}
}
Below code worked for me.
$('#modal1').closeModal();
Reference: materializecss

Dynamic nested unordered lists in GWT UIBinder

I'm trying to implement a simple CSS-based menu in GWT UIBinder, but I'm having some difficulties with one particular part.
The menu has two main-level items: "New session" and "Current sessions." When the user clicks "New session", a new list item should be added to the sublist under "Current sessions."
Here is the plain HTML version of the menu:
<div id="cssmenu">
<ul>
<li>New Session</li>
<li class="has-sub">Current Sessions
<ul>
<li>Session 1</li>
<li>Session 2</li>
</ul>
</li>
</ul>
</div>
The basic format was pretty simple to implement in UIBinder, but the dynamic sublist is giving me difficulties.
Here's the basic UIBinder template that I came up with:
The XML:
<!-- Menu.ui.xml -->
<ui:UiBinder xmlns:ui='urn:ui:com.google.gwt.uibinder' xmlns:g='urn:import:com.google.gwt.user.client.ui'>
<g:HTMLPanel id="cssmenu" ui:field="menuDiv">
<ul>
<li ui:field="newSessionItem">New Session</li>
<li class="has-sub" ui:field="currentSessionItem">
Current Sessions
<ul id="currentSessionSublist" ui:field="currentSessionSublistItem">
<li>Session 1</li>
<li>Session 2</li>
</ul>
</li>
</ul>
</g:HTMLPanel>
</ui:UiBinder>
The Java:
// Menu.java
public class Menu extends UIObject {
interface MenuBinder extends UiBinder<DivElement, Menu> {}
private static MenuBinder uiBinder = GWT.create(MenuBinder.class);
#UiField HTMLPanel menuDiv;
#UiField LIElement newSessionItem;
#UiField LIElement currentSessionItem;
#UiField UListElement currentSessionSublistItem;
public Menu() {
setElement(uiBinder.createAndBindUi(this));
}
#UiHandler("newSessionItem")
void handleClick(ClickEvent e) {
addCurrentSession();
}
private void addCurrentSession() {
// dynamic LI should be added here
}
}
I'm unsure how to add the dynamic list items in addCurrentSession(). I tried adding a custom widget that compiles to a <li> element, but was unable to add it using RootPanel.get("currentSessionSublist").add(item). I read somewhere that while it's possible to nest both HTML and Widgets inside an HTMLPanel, Widgets cannot be nested within HTML. If this is the case, how would I go about adding items to the sublist? I was hoping to go the widget route so I could later add the ability to remove a specific list item programmatically.
I don't want to use GWT's Menu, MenuItem, etc because those compile to tables.
Try this to dynamically add an item to a list (ordered/unordered):
final LIElement listItem = Document.get().createLIElement();
listItem.setInnerText("your text"); // or setInnerHTML("...")
this.currentSessionSublistItem.appendChild(listItem);
The crux is to go through the HTMLPanel:
menuDiv.add(item, currentSessionSublistItem);

GWT-Bootstrap Modal not shown after setVisible is called

I have a simple modal that I want to show when a button is clicked.
Here's the Code that I'm using to show the Modal
#UiHandler("submit")
void handleClick(ClickEvent e){
ModalDialogDemo modalDialog = (ModalDialogDemo) RootPanel.get().getWidget(2);
modalDialog.setHeight("200px");
modalDialog.setWidth("100px");
modalDialog.setVisible(true);
if(modalDialog.isVisible()){
System.out.println("Successfully Displayed the Modal!");
}
else{
System.out.println("Something went wrong.");
}
}
Even though the Modal isn't displayed on the screen the Message logged onto the console is the former i.e. Successfully Displayed the Modal!
I did some digging with firebug and before the button is clicked the rendered HTML is
<div>
<div class="modal" style="display: none;" aria-hidden="true">
<div class="modal-header"><a class="close" data-dismiss="modal">×</a><h3>Name</h3></div>
<div class="modal-body"><div class="gwt-Label">Modal Content Comes Here</div></div>
<div class="modal-footer"><div class="gwt-Label">And this is the footer</div></div></div>
</div>
after the button is clicked it changes to
<div style="height: 200px; width: 100px;" aria-hidden="false">
<div class="modal" style="display: none;" aria-hidden="true">
<div class="modal-header"><a class="close" data-dismiss="modal">×</a><h3>Name</h3></div>
<div class="modal-body"><div class="gwt-Label">Modal Content Comes Here</div></div>
<div class="modal-footer"><div class="gwt-Label">And this is the footer</div></div></div>
</div>
The first div has the height and width that I set applied and the aria-hidden also cleared but the child div which actually contains the modal isn't affected.
I don't know how I can tell GWT to apply the changes to the child div also, can someone help me out with this?
Edit:
This is my ModalDialogDemo.ui.xml
<!DOCTYPE ui:UiBinder SYSTEM "http://dl.google.com/gwt/DTD/xhtml.ent">
<ui:UiBinder xmlns:ui="urn:ui:com.google.gwt.uibinder"
xmlns:g="urn:import:com.google.gwt.user.client.ui"
xmlns:b = "urn:import:com.github.gwtbootstrap.client.ui">
<g:HTMLPanel>
<b:Modal title="VipName" backdrop="STATIC">
<g:Label>Modal Content Comes Here</g:Label>
<b:ModalFooter>
<g:Label>And this is the footer</g:Label>
</b:ModalFooter>
</b:Modal>
</g:HTMLPanel>
</ui:UiBinder>
You need to call the show() method on a GWT-Bootstrap modal object to display it.
Updated:
In ui.xml file, Assign one id for modal.
<b:Modal title="VipName" ui:field="vipNameModel" backdrop="STATIC">
In ModalDialogDemo.JAVA file, Get that object.
#UiField
Modal vipNameModel;
Create getter method:
Modal getVipNameModel()
{
return vipNameModel'
}
then call, modalDialog.getVipNameModel().show(); from ModalDialogDemo class

iScroll not scrolling on iPhone

I'm developing a phonegap app and trying to use iScroll 4 for scrolling on my pages. It works fine on web, but when I test on device/simulator the scroll doesn't work smoothly. When I touch the device screen it already click on my li element, and if I scroll down it doesn't look like an scroller.
Here's the script that I've take form iScroll website:
function onDeviceReady(){
var myScroll;
function loaded() {
myScroll = new iScroll('wrapper');
}
document.addEventListener('touchmove', function (e) { e.preventDefault(); }, false);
document.addEventListener('DOMContentLoaded', function () { setTimeout(loaded, 200); }, false);
document.addEventListener('DOMContentLoaded', loaded, false);
}
and here's how my list style looks like:
<div id="wrapper">
<div id="scroller">
<ul id="thelist">
<li>
<div class="item">
<div class="arrow"></div>
<div class="score">98 <span>score</span></div>
<div class="job-title">Expert UI/UX Designer</div>
<div class="detail">
at <span>Hewlett Packpard</span> - 30 connections
</div>
<div>
</div>
</div>
</li>
</ul>
</div>
</div>
I think everything is right, take a look at the live page:
http://rodrigoparra.com/bright/pages/dashboard.html
and here a sample of iScroll on the same app:
http://rodrigoparra.com/bright/simple/index.html
If you test on your device, you will see the first one doesn't work and second one works fine.
Not sure what is wrong :\
Any ideas of how I could fix it?
Thanks Guys
Hi as per my knowledge you need to set your scroll view content size.