task_21363 #1
|
@ -29,6 +29,12 @@
|
|||
<attribute name="maven.pomderived" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="lib" path="/home/francesco-mangiacrapa/.m2/repository/javax/servlet/javax.servlet-api/3.1.0/javax.servlet-api-3.1.0.jar"/>
|
||||
<classpathentry kind="lib" path="/home/francescomangiacrapa/.m2/repository/javax/servlet/javax.servlet-api/3.1.0/javax.servlet-api-3.1.0.jar"/>
|
||||
<classpathentry excluding="**" kind="src" output="target/test-classes" path="src/test/resources">
|
||||
<attributes>
|
||||
<attribute name="test" value="true"/>
|
||||
<attribute name="maven.pomderived" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="output" path="target/ckan-content-moderator-widget-0.1.0-SNAPSHOT/WEB-INF/classes"/>
|
||||
</classpath>
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
eclipse.preferences.version=1
|
||||
lastWarOutDir=/home/francesco-mangiacrapa/git/ckan-content-moderator-widget/target/ckan-content-moderator-widget-0.1.0-SNAPSHOT
|
||||
lastWarOutDir=/home/francescomangiacrapa/git/ckan-content-moderator-widget/target/ckan-content-moderator-widget-0.1.0-SNAPSHOT
|
||||
warSrcDir=src/main/webapp
|
||||
warSrcDirIsOutput=false
|
||||
|
|
|
@ -1,11 +1,21 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?><project-modules id="moduleCoreId" project-version="1.5.0">
|
||||
|
||||
<wb-module deploy-name="ckan-content-moderator-widget-0.1.0-SNAPSHOT">
|
||||
|
||||
<wb-resource deploy-path="/" source-path="/target/m2e-wtp/web-resources"/>
|
||||
|
||||
<wb-resource deploy-path="/" source-path="/src/main/webapp" tag="defaultRootSource"/>
|
||||
|
||||
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/java"/>
|
||||
|
||||
<wb-resource deploy-path="/WEB-INF/classes" source-path="/target/generated-sources/gwt"/>
|
||||
|
||||
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/resources"/>
|
||||
|
||||
<property name="context-root" value="ckan-content-moderator-widget"/>
|
||||
|
||||
<property name="java-output-path" value="/ckan-content-moderator-widget/target/ckan-content-moderator-widget-0.1.0-SNAPSHOT/WEB-INF/classes"/>
|
||||
|
||||
</wb-module>
|
||||
|
||||
</project-modules>
|
||||
|
|
|
@ -0,0 +1,7 @@
|
|||
<root>
|
||||
<facet id="jst.jaxrs">
|
||||
<node name="libprov">
|
||||
<attribute name="provider-id" value="jaxrs-no-op-library-provider"/>
|
||||
</node>
|
||||
</facet>
|
||||
</root>
|
65
pom.xml
65
pom.xml
|
@ -38,6 +38,7 @@
|
|||
<maven.compiler.source>1.8</maven.compiler.source>
|
||||
<maven.compiler.target>1.8</maven.compiler.target>
|
||||
<webappDirectory>${project.build.directory}/${project.build.finalName}</webappDirectory>
|
||||
<gwt-material.version>2.4.0</gwt-material.version>
|
||||
</properties>
|
||||
|
||||
<dependencyManagement>
|
||||
|
@ -48,13 +49,20 @@
|
|||
<version>3.6.2-SNAPSHOT</version>
|
||||
<type>pom</type>
|
||||
<scope>import</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.google.gwt</groupId>
|
||||
<artifactId>gwt</artifactId>
|
||||
<version>${gwtVersion}</version>
|
||||
<type>pom</type>
|
||||
<scope>import</scope>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>com.google.gwt</groupId>
|
||||
<artifactId>gwt-user</artifactId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<groupId>com.google.gwt</groupId>
|
||||
<artifactId>gwt-servlet</artifactId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<groupId>com.google.gwt</groupId>
|
||||
<artifactId>gwt-dev</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</dependencyManagement>
|
||||
|
@ -67,19 +75,23 @@
|
|||
<version>3.1.0</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>xml-apis</groupId>
|
||||
<artifactId>xml-apis</artifactId>
|
||||
<version>1.4.01</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.google.gwt</groupId>
|
||||
<artifactId>gwt-user</artifactId>
|
||||
<version>${gwtVersion}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.google.gwt</groupId>
|
||||
<artifactId>gwt-servlet</artifactId>
|
||||
<version>${gwtVersion}</version>
|
||||
<scope>runtime</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.google.gwt</groupId>
|
||||
<artifactId>gwt-dev</artifactId>
|
||||
|
@ -92,23 +104,23 @@
|
|||
<version>2.3.2.0</version>
|
||||
</dependency>
|
||||
|
||||
<!-- <dependency> -->
|
||||
<!-- <groupId>com.github.gwtmaterialdesign</groupId> -->
|
||||
<!-- <artifactId>gwt-material</artifactId> -->
|
||||
<!-- <version>2.1.1</version> -->
|
||||
<!-- </dependency> -->
|
||||
<dependency>
|
||||
<groupId>com.github.gwtmaterialdesign</groupId>
|
||||
<artifactId>gwt-material-jquery</artifactId>
|
||||
<version>${gwt-material.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!-- <dependency> -->
|
||||
<!-- <groupId>com.github.gwtmaterialdesign</groupId> -->
|
||||
<!-- <artifactId>gwt-material-addins</artifactId> -->
|
||||
<!-- <version>2.4.0</version> -->
|
||||
<!-- </dependency> -->
|
||||
<!-- <dependency> -->
|
||||
<!-- <groupId>com.github.gwtmaterialdesign</groupId> -->
|
||||
<!-- <artifactId>gwt-material-addins</artifactId> -->
|
||||
<!-- <version>${gwt-material.version}</version> -->
|
||||
<!-- </dependency> -->
|
||||
|
||||
<!-- <dependency> -->
|
||||
<!-- <groupId>com.github.gwtmaterialdesign</groupId> -->
|
||||
<!-- <artifactId>gwt-material-table</artifactId> -->
|
||||
<!-- <version>2.1.1</version> -->
|
||||
<!-- </dependency> -->
|
||||
<dependency>
|
||||
<groupId>com.github.gwtmaterialdesign</groupId>
|
||||
<artifactId>gwt-material-table</artifactId>
|
||||
<version>${gwt-material.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!-- <dependency> -->
|
||||
<!-- <groupId>com.gwtplatform</groupId> -->
|
||||
|
@ -188,16 +200,11 @@
|
|||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<configuration>
|
||||
<source>${maven.compiler.source}</source>
|
||||
<target>${maven.compiler.target}</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<!-- SA Plugin -->
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-assembly-plugin</artifactId>
|
||||
<version>2.2</version>
|
||||
<configuration>
|
||||
<descriptors>
|
||||
<descriptor>descriptor.xml</descriptor>
|
||||
|
|
|
@ -6,11 +6,14 @@
|
|||
<!-- Inherit the default GWT style sheet. You can change -->
|
||||
<!-- the theme of your GWT application by uncommenting -->
|
||||
<!-- any one of the following lines. -->
|
||||
<inherits name='com.google.gwt.user.theme.standard.Standard' />
|
||||
<!-- <inherits name='com.google.gwt.user.theme.standard.Standard' /> -->
|
||||
<!-- <inherits name='com.google.gwt.user.theme.chrome.Chrome'/> -->
|
||||
<!-- <inherits name='com.google.gwt.user.theme.dark.Dark'/> -->
|
||||
|
||||
<!-- <inherits name="gwt.material.design.GwtMaterialDesign" /> -->
|
||||
<inherits
|
||||
name="gwt.material.design.GwtMaterialBasicWithJQuery" />
|
||||
<!-- <inherits name="gwt.material.design.addins.GwtMaterialAddins" /> -->
|
||||
<inherits name="gwt.material.design.GwtMaterialTable" />
|
||||
|
||||
<!-- Other module inherits -->
|
||||
|
||||
|
|
|
@ -1,7 +1,17 @@
|
|||
package org.gcube.portlets.widgets.ckancontentmoderator.client;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.gcube.portlets.widgets.ckancontentmoderator.client.material.table.CustomizedView;
|
||||
import org.gcube.portlets.widgets.ckancontentmoderator.client.material.table.DataGenerator;
|
||||
|
||||
import com.google.gwt.core.client.EntryPoint;
|
||||
import com.google.gwt.core.client.GWT;
|
||||
import com.google.gwt.user.client.ui.HTML;
|
||||
import com.google.gwt.user.client.ui.RootPanel;
|
||||
|
||||
import gwt.material.design.client.ui.table.MaterialDataTable;
|
||||
|
||||
/**
|
||||
* Entry point classes define <code>onModuleLoad()</code>.
|
||||
|
@ -23,13 +33,20 @@ public class CkanContentModeratorWidget implements EntryPoint {
|
|||
* This is the entry point method.
|
||||
*/
|
||||
public void onModuleLoad() {
|
||||
|
||||
// MaterialDataTable<String> table = new MaterialDataTable<String>();
|
||||
// table.getTableTitle().setText("Customers");
|
||||
// List<String> users = new ArrayList<String>();
|
||||
// users.add("Pippo");
|
||||
// table.setRowData(0, users);
|
||||
|
||||
CustomizedView cvTable = new CustomizedView();
|
||||
cvTable.setData(DataGenerator.generateUsers(10));
|
||||
|
||||
RootPanel.get().add(cvTable);
|
||||
// table.getView().refresh();
|
||||
|
||||
//CustomizedView cvTable = new CustomizedView();
|
||||
// cvTable.setData(DataGenerator.generateUsers(10));
|
||||
//
|
||||
// RootPanel.get().add(cvTable);
|
||||
|
||||
//
|
||||
// greetingService.getListItemsForStatus(ItemStatus.PENDING, new AsyncCallback<List<CkanDataset>>() {
|
||||
//
|
||||
// @Override
|
||||
|
|
|
@ -1,83 +1,66 @@
|
|||
///*
|
||||
// * #%L
|
||||
// * GwtMaterial
|
||||
// * %%
|
||||
// * Copyright (C) 2015 - 2017 GwtMaterialDesign
|
||||
// * %%
|
||||
// * Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// * you may not use this file except in compliance with the License.
|
||||
// * You may obtain a copy of the License at
|
||||
// *
|
||||
// * http://www.apache.org/licenses/LICENSE-2.0
|
||||
// *
|
||||
// * Unless required by applicable law or agreed to in writing, software
|
||||
// * distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// * See the License for the specific language governing permissions and
|
||||
// * limitations under the License.
|
||||
// * #L%
|
||||
// */
|
||||
//package org.gcube.portlets.widgets.ckancontentmoderator.client.material.table;
|
||||
//
|
||||
//import java.util.List;
|
||||
//
|
||||
//
|
||||
//import org.gcube.portlets.widgets.ckancontentmoderator.shared.User;
|
||||
//
|
||||
//import com.google.gwt.core.client.GWT;
|
||||
//import com.google.gwt.event.dom.client.ClickEvent;
|
||||
//import com.google.gwt.event.dom.client.ClickHandler;
|
||||
//import com.google.gwt.uibinder.client.UiBinder;
|
||||
//import com.google.gwt.uibinder.client.UiField;
|
||||
//import com.google.gwt.user.cellview.client.ColumnSortEvent;
|
||||
//import com.google.gwt.user.cellview.client.TextColumn;
|
||||
//import com.google.gwt.user.client.ui.Composite;
|
||||
//import com.google.gwt.user.client.ui.Widget;
|
||||
//
|
||||
//
|
||||
//import gwt.material.design.client.constants.IconType;
|
||||
//import gwt.material.design.client.data.events.ColumnSortHandler;
|
||||
//import gwt.material.design.client.data.events.RowSelectEvent;
|
||||
//import gwt.material.design.client.data.events.RowSelectHandler;
|
||||
//import gwt.material.design.client.ui.MaterialIcon;
|
||||
//import gwt.material.design.client.ui.MaterialImage;
|
||||
//import gwt.material.design.client.ui.MaterialListBox;
|
||||
//import gwt.material.design.client.ui.MaterialPanel;
|
||||
//import gwt.material.design.client.ui.table.MaterialDataTable;
|
||||
//import gwt.material.design.client.ui.table.cell.WidgetColumn;
|
||||
//
|
||||
//public class CustomizedView extends Composite {
|
||||
//
|
||||
// interface CustomizedViewUiBinder extends UiBinder<Widget, CustomizedView> {
|
||||
// }
|
||||
//
|
||||
// private List<User> users;
|
||||
//
|
||||
// @UiField
|
||||
// MaterialDataTable<User> table;
|
||||
//
|
||||
//
|
||||
// public CustomizedView(Binder uiBinder) {
|
||||
// initWidget(uiBinder.createAndBindUi(this));
|
||||
// }
|
||||
//
|
||||
//
|
||||
// public void setupTable() {
|
||||
// MaterialIcon icon = new MaterialIcon();
|
||||
// icon.setPadding(4);
|
||||
// icon.setIconType(IconType.ADD_CIRCLE_OUTLINE);
|
||||
//
|
||||
// icon.addClickHandler(new ClickHandler() {
|
||||
//
|
||||
// @Override
|
||||
// public void onClick(ClickEvent event) {
|
||||
// users.add(0, new DataGenerator().generateUsers(1).get(0));
|
||||
// setData(users);
|
||||
//
|
||||
// }
|
||||
// });
|
||||
// table.getScaffolding().getToolPanel().add(icon);
|
||||
//
|
||||
package org.gcube.portlets.widgets.ckancontentmoderator.client.material.table;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.gcube.portlets.widgets.ckancontentmoderator.shared.User;
|
||||
|
||||
import com.google.gwt.core.client.GWT;
|
||||
import com.google.gwt.event.dom.client.ClickEvent;
|
||||
import com.google.gwt.event.dom.client.ClickHandler;
|
||||
import com.google.gwt.uibinder.client.UiBinder;
|
||||
import com.google.gwt.uibinder.client.UiField;
|
||||
import com.google.gwt.user.client.ui.Composite;
|
||||
import com.google.gwt.user.client.ui.Widget;
|
||||
|
||||
import gwt.material.design.client.base.Waves;
|
||||
import gwt.material.design.client.constants.IconType;
|
||||
import gwt.material.design.client.data.events.ColumnSortHandler;
|
||||
import gwt.material.design.client.data.events.RowSelectEvent;
|
||||
import gwt.material.design.client.data.events.RowSelectHandler;
|
||||
import gwt.material.design.client.ui.MaterialIcon;
|
||||
import gwt.material.design.client.ui.MaterialImage;
|
||||
import gwt.material.design.client.ui.MaterialListBox;
|
||||
import gwt.material.design.client.ui.MaterialPanel;
|
||||
import gwt.material.design.client.ui.table.MaterialDataTable;
|
||||
import gwt.material.design.client.ui.table.cell.WidgetColumn;
|
||||
|
||||
public class CustomizedView extends Composite {
|
||||
|
||||
interface CustomizedViewUiBinder extends UiBinder<Widget, CustomizedView> {
|
||||
}
|
||||
private static CustomizedViewUiBinder uiBinder = GWT.create(CustomizedViewUiBinder.class);
|
||||
|
||||
private List<User> users;
|
||||
|
||||
@UiField
|
||||
MaterialDataTable<User> table;
|
||||
|
||||
|
||||
public CustomizedView() {
|
||||
initWidget(uiBinder.createAndBindUi(this));
|
||||
setupTable();
|
||||
}
|
||||
|
||||
|
||||
public void setupTable() {
|
||||
MaterialIcon icon = new MaterialIcon();
|
||||
icon.setPadding(4);
|
||||
icon.setIconType(IconType.ADD_CIRCLE_OUTLINE);
|
||||
|
||||
icon.addClickHandler(new ClickHandler() {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent event) {
|
||||
users.add(0, new DataGenerator().generateUsers(1).get(0));
|
||||
setData(users);
|
||||
|
||||
}
|
||||
});
|
||||
table.setWaves(null);
|
||||
table.setWidth("500px");
|
||||
table.setUseStickyHeader(false);
|
||||
//table.getScaffolding().getToolPanel().add(icon);
|
||||
|
||||
// MaterialIcon delete = new MaterialIcon();
|
||||
// delete.setPadding(4);
|
||||
// delete.setIconType(IconType.DELETE);
|
||||
|
@ -93,7 +76,7 @@
|
|||
//
|
||||
// }
|
||||
// });
|
||||
//
|
||||
|
||||
// table.addColumn("Image", new WidgetColumn<User, MaterialPanel>() {
|
||||
// @Override
|
||||
// public MaterialPanel getValue(User object) {
|
||||
|
@ -107,19 +90,19 @@
|
|||
// return panel;
|
||||
// }
|
||||
// });
|
||||
//
|
||||
// table.addColumn("First Name", new TextColumn<User>() {
|
||||
// @Override
|
||||
// public String getValue(User object) {
|
||||
// return object.getName();
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public boolean sortable() {
|
||||
// return true;
|
||||
// }
|
||||
// });
|
||||
//
|
||||
|
||||
table.addColumn("First Name", new gwt.material.design.client.ui.table.cell.TextColumn<User>() {
|
||||
@Override
|
||||
public String getValue(User object) {
|
||||
return object.getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean sortable() {
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
// table.addColumn("Option", new WidgetColumn<User, MaterialListBox>() {
|
||||
// @Override
|
||||
// public MaterialListBox getValue(User object) {
|
||||
|
@ -130,120 +113,120 @@
|
|||
// return listBox;
|
||||
// }
|
||||
// }).width(200);
|
||||
|
||||
table.addColumn("City", new gwt.material.design.client.ui.table.cell.TextColumn<User>() {
|
||||
@Override
|
||||
public String getValue(User object) {
|
||||
return object.getCity();
|
||||
}
|
||||
});
|
||||
|
||||
table.addRowSelectHandler(new RowSelectHandler<User>() {
|
||||
|
||||
@Override
|
||||
public void onRowSelect(RowSelectEvent<User> event) {
|
||||
log("RowSelectEvent", event.getModel().getName() + ": " + event.isSelected());
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
table.addColumnSortHandler(new ColumnSortHandler<User>() {
|
||||
|
||||
@Override
|
||||
public void onColumnSort(gwt.material.design.client.data.events.ColumnSortEvent<User> event) {
|
||||
log("ColumnSortEvent",
|
||||
"Sorted: " + event.getSortContext().getSortDir() + ", columnIndex: " + event.getColumnIndex());
|
||||
table.getView().refresh();
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
/*
|
||||
* // Add category opened handler, called when a category is opened.
|
||||
* table.addCategoryOpenedHandler(event -> { log("CategoryOpenedEvent",
|
||||
* "Category Opened: " + event.getName()); });
|
||||
*
|
||||
* // Add category closed handler, called when a category is closed.
|
||||
* table.addCategoryClosedHandler(event -> { log("CategoryClosedEvent",
|
||||
* "Category Closed: " + event.getName()); });
|
||||
*
|
||||
* // Add a row double click handler, called when a row is double clicked.
|
||||
* table.addRowDoubleClickHandler(event -> { log("RowDoubleClickEvent",
|
||||
* "Row Double Clicked: " + event.getModel().getName() + ", x:" +
|
||||
* event.getMouseEvent().getPageX() + ", y: " +
|
||||
* event.getMouseEvent().getPageY()); });
|
||||
*
|
||||
* // Configure the tables long press duration configuration. // The short press
|
||||
* is when a click is held less than this duration.
|
||||
* table.setLongPressDuration(400);
|
||||
*
|
||||
* // Add a row long press handler, called when a row is long pressed.
|
||||
* table.addRowLongPressHandler(event -> { log("RowLongPressEvent",
|
||||
* "Row Long Pressed: " + event.getModel().getName() + ", x:" +
|
||||
* event.getMouseEvent().getPageX() + ", y: " +
|
||||
* event.getMouseEvent().getPageY()); });
|
||||
*
|
||||
* // Add a row short press handler, called when a row is short pressed.
|
||||
* table.addRowShortPressHandler(event -> { log("RowShortPressEvent",
|
||||
* "Row Short Pressed: " + event.getModel().getName() + ", x:" +
|
||||
* event.getMouseEvent().getPageX() + ", y: " +
|
||||
* event.getMouseEvent().getPageY()); });
|
||||
*
|
||||
* // Add rendered handler, called when 'setRowData' calls finish rendering. //
|
||||
* Guaranteed to only be called once from the data set render, ignoring sort
|
||||
* renders and refreshView renders. table.addRenderedHandler(e -> {
|
||||
* log("RenderedEvent", "Table Rendered"); });
|
||||
*
|
||||
* // Add components rendered handler, Called each time when components are
|
||||
* rendered, // which includes sorting renders and refreshView() renders.
|
||||
* table.addComponentsRenderedHandler(e -> { log("ComponentsRenderedEvent",
|
||||
* "Data Table Components Rendered"); });
|
||||
*/
|
||||
}
|
||||
|
||||
protected void log(String eventName, String description) {
|
||||
GWT.log(description);
|
||||
}
|
||||
|
||||
|
||||
public void setData(List<User> users) {
|
||||
this.users = users;
|
||||
// Customized Table Scaffolding elements
|
||||
table.getTableTitle().setText("Customers");
|
||||
table.setRowData(0, users);
|
||||
table.getView().refresh();
|
||||
}
|
||||
|
||||
// @Override
|
||||
// public void setupOptions() {
|
||||
// // Table Name
|
||||
// tableName.addKeyUpHandler(event -> table.getTableTitle().setText(tableName.getValue()));
|
||||
//
|
||||
// table.addColumn("City", new TextColumn<User>() {
|
||||
// @Override
|
||||
// public String getValue(User object) {
|
||||
// return object.getCity();
|
||||
// }
|
||||
// });
|
||||
// // Selection Type
|
||||
// selectionType.add(SelectionType.NONE);
|
||||
// selectionType.add(SelectionType.SINGLE);
|
||||
// selectionType.add(SelectionType.MULTIPLE);
|
||||
// selectionType.addValueChangeHandler(event -> table.setSelectionType(event.getValue()));
|
||||
// selectionType.setValue(SelectionType.SINGLE, true);
|
||||
// // Density
|
||||
// }
|
||||
//
|
||||
// table.addRowSelectHandler(new RowSelectHandler<User>() {
|
||||
// @UiHandler("stickyHeader")
|
||||
// void stickyHeader(ValueChangeEvent<Boolean> event) {
|
||||
// table.setUseStickyHeader(event.getValue());
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void onRowSelect(RowSelectEvent<User> event) {
|
||||
// log("RowSelectEvent", event.getModel().getName() + ": " + event.isSelected());
|
||||
//
|
||||
// }
|
||||
// });
|
||||
//
|
||||
// table.addColumnSortHandler(new ColumnSortHandler<User>() {
|
||||
//
|
||||
// @Override
|
||||
// public void onColumnSort(ColumnSortEvent<User> event) {
|
||||
// log("ColumnSortEvent",
|
||||
// "Sorted: " + event.getSortContext().getSortDir() + ", columnIndex: " + event.getColumnIndex());
|
||||
// table.getView().refresh();
|
||||
//
|
||||
// }
|
||||
// });
|
||||
//
|
||||
// /*
|
||||
// * // Add category opened handler, called when a category is opened.
|
||||
// * table.addCategoryOpenedHandler(event -> { log("CategoryOpenedEvent",
|
||||
// * "Category Opened: " + event.getName()); });
|
||||
// *
|
||||
// * // Add category closed handler, called when a category is closed.
|
||||
// * table.addCategoryClosedHandler(event -> { log("CategoryClosedEvent",
|
||||
// * "Category Closed: " + event.getName()); });
|
||||
// *
|
||||
// * // Add a row double click handler, called when a row is double clicked.
|
||||
// * table.addRowDoubleClickHandler(event -> { log("RowDoubleClickEvent",
|
||||
// * "Row Double Clicked: " + event.getModel().getName() + ", x:" +
|
||||
// * event.getMouseEvent().getPageX() + ", y: " +
|
||||
// * event.getMouseEvent().getPageY()); });
|
||||
// *
|
||||
// * // Configure the tables long press duration configuration. // The short press
|
||||
// * is when a click is held less than this duration.
|
||||
// * table.setLongPressDuration(400);
|
||||
// *
|
||||
// * // Add a row long press handler, called when a row is long pressed.
|
||||
// * table.addRowLongPressHandler(event -> { log("RowLongPressEvent",
|
||||
// * "Row Long Pressed: " + event.getModel().getName() + ", x:" +
|
||||
// * event.getMouseEvent().getPageX() + ", y: " +
|
||||
// * event.getMouseEvent().getPageY()); });
|
||||
// *
|
||||
// * // Add a row short press handler, called when a row is short pressed.
|
||||
// * table.addRowShortPressHandler(event -> { log("RowShortPressEvent",
|
||||
// * "Row Short Pressed: " + event.getModel().getName() + ", x:" +
|
||||
// * event.getMouseEvent().getPageX() + ", y: " +
|
||||
// * event.getMouseEvent().getPageY()); });
|
||||
// *
|
||||
// * // Add rendered handler, called when 'setRowData' calls finish rendering. //
|
||||
// * Guaranteed to only be called once from the data set render, ignoring sort
|
||||
// * renders and refreshView renders. table.addRenderedHandler(e -> {
|
||||
// * log("RenderedEvent", "Table Rendered"); });
|
||||
// *
|
||||
// * // Add components rendered handler, Called each time when components are
|
||||
// * rendered, // which includes sorting renders and refreshView() renders.
|
||||
// * table.addComponentsRenderedHandler(e -> { log("ComponentsRenderedEvent",
|
||||
// * "Data Table Components Rendered"); });
|
||||
// */
|
||||
// }
|
||||
//
|
||||
// protected void log(String eventName, String description) {
|
||||
// GWT.log(description);
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void setData(List<User> users) {
|
||||
// this.users = users;
|
||||
// // Customized Table Scaffolding elements
|
||||
// table.getTableTitle().setText("Customers");
|
||||
// table.setRowData(0, users);
|
||||
// table.getView().refresh();
|
||||
// }
|
||||
//
|
||||
//// @Override
|
||||
//// public void setupOptions() {
|
||||
//// // Table Name
|
||||
//// tableName.addKeyUpHandler(event -> table.getTableTitle().setText(tableName.getValue()));
|
||||
////
|
||||
//// // Selection Type
|
||||
//// selectionType.add(SelectionType.NONE);
|
||||
//// selectionType.add(SelectionType.SINGLE);
|
||||
//// selectionType.add(SelectionType.MULTIPLE);
|
||||
//// selectionType.addValueChangeHandler(event -> table.setSelectionType(event.getValue()));
|
||||
//// selectionType.setValue(SelectionType.SINGLE, true);
|
||||
//// // Density
|
||||
//// }
|
||||
////
|
||||
//// @UiHandler("stickyHeader")
|
||||
//// void stickyHeader(ValueChangeEvent<Boolean> event) {
|
||||
//// table.setUseStickyHeader(event.getValue());
|
||||
//// }
|
||||
////
|
||||
//// @UiHandler("striped")
|
||||
//// void striped(ValueChangeEvent<Boolean> event) {
|
||||
//// if (event.getValue()) {
|
||||
//// table.getScaffolding().getTable().addStyleName("striped");
|
||||
//// } else {
|
||||
//// table.getScaffolding().getTable().removeStyleName("striped");
|
||||
//// }
|
||||
//// }
|
||||
//
|
||||
// public void reload() {
|
||||
// table.getView().setRedraw(true);
|
||||
// table.getView().refresh();
|
||||
// }
|
||||
//}
|
||||
// @UiHandler("striped")
|
||||
// void striped(ValueChangeEvent<Boolean> event) {
|
||||
// if (event.getValue()) {
|
||||
// table.getScaffolding().getTable().addStyleName("striped");
|
||||
// } else {
|
||||
// table.getScaffolding().getTable().removeStyleName("striped");
|
||||
// }
|
||||
// }
|
||||
|
||||
public void reload() {
|
||||
table.getView().setRedraw(true);
|
||||
table.getView().refresh();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,7 +10,10 @@
|
|||
<!-- <inherits name='com.google.gwt.user.theme.chrome.Chrome'/> -->
|
||||
<!-- <inherits name='com.google.gwt.user.theme.dark.Dark'/> -->
|
||||
|
||||
<!-- <inherits name="gwt.material.design.GwtMaterialDesign" /> -->
|
||||
<inherits
|
||||
name="gwt.material.design.GwtMaterialBasicWithJQuery" />
|
||||
<!-- <inherits name="gwt.material.design.addins.GwtMaterialAddins" /> -->
|
||||
<inherits name="gwt.material.design.GwtMaterialTable" />
|
||||
|
||||
<!-- Other module inherits -->
|
||||
|
||||
|
|
|
@ -32,3 +32,325 @@ h1 {
|
|||
#closeButton {
|
||||
margin: 15px 6px 6px;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
html{
|
||||
overflow-x: hidden !important;
|
||||
}
|
||||
|
||||
body {
|
||||
padding-top: 70px;
|
||||
}
|
||||
|
||||
pre.prettyprint {
|
||||
padding: 9.5px !important;
|
||||
border: none !important;
|
||||
margin-bottom: 0px !important;
|
||||
background: transparent !important;
|
||||
margin-bottom: 10px !important;
|
||||
}
|
||||
|
||||
.page-header {
|
||||
margin-top: 0px !important;
|
||||
}
|
||||
|
||||
.progress{
|
||||
background-color: #E8F4FD;
|
||||
}
|
||||
|
||||
nav{
|
||||
width: calc(100% - 240px);
|
||||
}
|
||||
|
||||
nav .button-collapse i {
|
||||
font-size: 24px !important;
|
||||
}
|
||||
|
||||
/* Styles for Affix/sidebar shamelessly copied from http://getbootstrap.com/assets/css/docs.css */
|
||||
|
||||
/* By default it's not affixed in mobile views, so undo that */
|
||||
.bs-sidebar.affix {
|
||||
position: static;
|
||||
}
|
||||
|
||||
/* First level of nav */
|
||||
.bs-sidenav {
|
||||
margin-top: 30px;
|
||||
margin-bottom: 30px;
|
||||
padding-top: 10px;
|
||||
padding-bottom: 10px;
|
||||
text-shadow: 0 1px 0 #fff;
|
||||
background-color: #f7f5fa;
|
||||
border-radius: 5px;
|
||||
}
|
||||
|
||||
/* All levels of nav */
|
||||
.bs-sidebar .nav > li > a {
|
||||
display: block;
|
||||
color: #716b7a;
|
||||
padding: 5px 20px;
|
||||
}
|
||||
|
||||
.bs-sidebar .nav > li > a:hover,
|
||||
.bs-sidebar .nav > li > a:focus {
|
||||
text-decoration: none;
|
||||
background-color: #e5e3e9;
|
||||
border-right: 1px solid #dbd8e0;
|
||||
}
|
||||
|
||||
.bs-sidebar .nav > .active > a,
|
||||
.bs-sidebar .nav > .active:hover > a,
|
||||
.bs-sidebar .nav > .active:focus > a {
|
||||
font-weight: bold;
|
||||
color: #563d7c;
|
||||
background-color: transparent;
|
||||
border-right: 1px solid #563d7c;
|
||||
}
|
||||
|
||||
/* Nav: second level (shown on .active) */
|
||||
.bs-sidebar .nav .nav {
|
||||
display: none; /* Hide by default, but at >768px, show it */
|
||||
margin-bottom: 8px;
|
||||
}
|
||||
|
||||
.bs-sidebar .nav .nav > li > a {
|
||||
padding-top: 3px;
|
||||
padding-bottom: 3px;
|
||||
padding-left: 30px;
|
||||
font-size: 90%;
|
||||
}
|
||||
|
||||
/* Mobile down */
|
||||
@media only screen and (max-width: 600px) {
|
||||
.panel {
|
||||
padding: 0px !important;
|
||||
}
|
||||
pre.prettyprint {
|
||||
width: calc(100vw - 80px);
|
||||
}
|
||||
}
|
||||
@media only screen and (max-width: 992px) {
|
||||
header {
|
||||
width: 100% !important;
|
||||
}
|
||||
}
|
||||
/* Tablets and up */
|
||||
@media screen and (min-width: 768px) {
|
||||
|
||||
/* Show the docs nav */
|
||||
.bs-sidebar {
|
||||
display: block;
|
||||
}
|
||||
|
||||
/* Show the hidden subnavs when space allows it */
|
||||
.bs-sidebar .nav > .active > ul {
|
||||
display: block;
|
||||
}
|
||||
}
|
||||
|
||||
/* Tablets/desktops and up */
|
||||
@media screen and (min-width: 992px) {
|
||||
|
||||
/* Widen the fixed sidebar */
|
||||
.bs-sidebar.affix,
|
||||
.bs-sidebar.affix-bottom {
|
||||
width: 213px;
|
||||
}
|
||||
|
||||
.bs-sidebar.affix {
|
||||
position: fixed; /* Undo the static from mobile-first approach */
|
||||
top: 60px;
|
||||
}
|
||||
|
||||
.bs-sidebar.affix-bottom {
|
||||
position: absolute; /* Undo the static from mobile-first approach */
|
||||
}
|
||||
|
||||
.bs-sidebar.affix-bottom .bs-sidenav,
|
||||
.bs-sidebar.affix .bs-sidenav {
|
||||
margin-top: 0;
|
||||
margin-bottom: 0;
|
||||
}
|
||||
}
|
||||
|
||||
/* Large desktops and up */
|
||||
@media screen and (min-width: 1200px) {
|
||||
|
||||
/* Widen the fixed sidebar again */
|
||||
.bs-sidebar.affix-bottom,
|
||||
.bs-sidebar.affix {
|
||||
width: 270px;
|
||||
}
|
||||
}
|
||||
|
||||
ul.side-nav.fixed li:hover,ul.side-nav.fixed li.active {
|
||||
background-color: rgba(0, 0, 0, 0.05);
|
||||
}
|
||||
|
||||
.side-nav .collapsible-body li.active, .side-nav.fixed .collapsible-body li.active {
|
||||
background-color: rgba(0, 0, 0, 0.05);
|
||||
}
|
||||
|
||||
/** Top Panel **/
|
||||
#customTable .top-panel {
|
||||
background-color: white;
|
||||
color: black;
|
||||
}
|
||||
|
||||
/** ToolPanel icons **/
|
||||
#customTable .top-panel .tool-panel i {
|
||||
color: #e91e63;
|
||||
}
|
||||
|
||||
/** Hovering rows **/
|
||||
#customTable table tbody tr.data-row:hover {
|
||||
background: rgba(33, 150, 243, 0.27);
|
||||
color: #3f3f3f;
|
||||
}
|
||||
|
||||
/** Columns **/
|
||||
#customTable table tbody td:nth-child(3) {
|
||||
background: #2196f3 !important;
|
||||
color: #fff;
|
||||
border-bottom: 2px solid #1976d2;
|
||||
}
|
||||
|
||||
/** Table Headers **/
|
||||
#customTable table thead tr th {
|
||||
color: #1976d2;
|
||||
}
|
||||
|
||||
/** Scroll Navigated menu **/
|
||||
.table-of-contents.pinned {
|
||||
top: 80px !important;
|
||||
}
|
||||
|
||||
.side-nav .collapsible-body li.active a, .side-nav.fixed .collapsible-body li.active a {
|
||||
color: #000 !important;
|
||||
}
|
||||
|
||||
body {
|
||||
background: #e9e9e9;
|
||||
}
|
||||
|
||||
main .panel {
|
||||
margin-top: -40px;
|
||||
}
|
||||
|
||||
main .panel, main {
|
||||
background: none;
|
||||
}
|
||||
|
||||
.code {
|
||||
margin-bottom: 12px;
|
||||
}
|
||||
|
||||
.code > div:not(.empty-state) h4 {
|
||||
font-size: 1.2em;
|
||||
margin-top: 0px !important;
|
||||
}
|
||||
|
||||
.code div p.range-field {
|
||||
margin-bottom: 0px;
|
||||
}
|
||||
|
||||
.code div p {
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
|
||||
.code {
|
||||
padding: 20px;
|
||||
margin-bottom: 12px;
|
||||
background: #fff;
|
||||
box-shadow: 0 2px 5px 0 rgba(0, 0, 0, 0.16), 0 2px 10px 0 rgba(0, 0, 0, 0.12);
|
||||
}
|
||||
|
||||
.TouchSplitter h4 {
|
||||
padding-top: 100px;
|
||||
}
|
||||
|
||||
/** Set ids using widget.getElement().setId("idOfElement") */
|
||||
#closeButton {
|
||||
margin: 15px 6px 6px;
|
||||
}
|
||||
|
||||
table tbody tr td img {
|
||||
max-width: initial !important;
|
||||
}
|
||||
|
||||
.side-nav {
|
||||
height: 100% !important;
|
||||
box-sizing: border-box !important;
|
||||
-moz-box-sizing: border-box !important;
|
||||
-webkit-box-sizing: border-box !important
|
||||
}
|
||||
|
||||
pre {
|
||||
padding-top: 20px;
|
||||
white-space: pre;
|
||||
background: #F3FBFF;
|
||||
border: 1px solid rgba(51, 51, 51, .12);
|
||||
font-size: 1.2em;
|
||||
padding-left: 10px
|
||||
}
|
||||
|
||||
.tag {
|
||||
color: #905
|
||||
}
|
||||
|
||||
.attr {
|
||||
color: #690
|
||||
}
|
||||
|
||||
.comment {
|
||||
color: #999
|
||||
}
|
||||
|
||||
h1 {
|
||||
font-size: 2em;
|
||||
font-weight: 700;
|
||||
color: #777;
|
||||
margin: 40px 0 70px;
|
||||
text-align: center
|
||||
}
|
||||
|
||||
.sendButton {
|
||||
display: block;
|
||||
font-size: 16pt
|
||||
}
|
||||
|
||||
.gwt-DialogBox {
|
||||
width: 400px
|
||||
}
|
||||
|
||||
.dialogVPanel {
|
||||
margin: 5px
|
||||
}
|
||||
|
||||
.serverResponseLabelError {
|
||||
color: red
|
||||
}
|
||||
|
||||
#closeButton {
|
||||
margin: 15px 6px 6px
|
||||
}
|
||||
|
||||
.gitter-open-chat-button, .gitter-open-chat-button:visited {
|
||||
background: #2465c0
|
||||
}
|
||||
|
||||
aside.gitter-chat-embed {
|
||||
z-index: 9999
|
||||
}
|
||||
|
||||
/** Carousel **/
|
||||
#demo-carousel-fixed {
|
||||
bottom: 16%;
|
||||
position: fixed;
|
||||
text-align: center;
|
||||
left: calc(50% - 90px);
|
||||
z-index: 1;
|
||||
z-index: 999;
|
||||
}
|
|
@ -6,58 +6,49 @@
|
|||
<!-- differences in layout. -->
|
||||
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
|
||||
<head>
|
||||
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
|
||||
|
||||
<!-- -->
|
||||
<!-- Consider inlining CSS to reduce the number of requested files -->
|
||||
<!-- -->
|
||||
<link type="text/css" rel="stylesheet" href="CkanContentModeratorWidget.css">
|
||||
<!-- -->
|
||||
<!-- Consider inlining CSS to reduce the number of requested files -->
|
||||
<!-- -->
|
||||
<link type="text/css" rel="stylesheet"
|
||||
href="CkanContentModeratorWidget.css">
|
||||
|
||||
<!-- -->
|
||||
<!-- Any title is fine -->
|
||||
<!-- -->
|
||||
<title>Web Application Starter Project</title>
|
||||
<script type="text/javascript" src="js/jquery.min.js"></script>
|
||||
|
||||
<!-- -->
|
||||
<!-- This script loads your compiled module. -->
|
||||
<!-- If you add any GWT meta tags, they must -->
|
||||
<!-- be added before this line. -->
|
||||
<!-- -->
|
||||
<script type="text/javascript" language="javascript" src="CkanContentModeratorWidget/CkanContentModeratorWidget.nocache.js"></script>
|
||||
</head>
|
||||
<!-- -->
|
||||
<!-- Any title is fine -->
|
||||
<!-- -->
|
||||
<title>Web Application Starter Project</title>
|
||||
|
||||
<!-- -->
|
||||
<!-- The body can have arbitrary html, or -->
|
||||
<!-- you can leave the body empty if you want -->
|
||||
<!-- to create a completely dynamic UI. -->
|
||||
<!-- -->
|
||||
<body>
|
||||
<!-- -->
|
||||
<!-- This script loads your compiled module. -->
|
||||
<!-- If you add any GWT meta tags, they must -->
|
||||
<!-- be added before this line. -->
|
||||
<!-- -->
|
||||
<script type="text/javascript" language="javascript"
|
||||
src="CkanContentModeratorWidget/CkanContentModeratorWidget.nocache.js"></script>
|
||||
</head>
|
||||
|
||||
<!-- OPTIONAL: include this if you want history support -->
|
||||
<iframe src="javascript:''" id="__gwt_historyFrame" tabIndex='-1' style="position:absolute;width:0;height:0;border:0"></iframe>
|
||||
<!-- -->
|
||||
<!-- The body can have arbitrary html, or -->
|
||||
<!-- you can leave the body empty if you want -->
|
||||
<!-- to create a completely dynamic UI. -->
|
||||
<!-- -->
|
||||
<body>
|
||||
|
||||
<!-- RECOMMENDED if your web app will not function without JavaScript enabled -->
|
||||
<noscript>
|
||||
<div style="width: 22em; position: absolute; left: 50%; margin-left: -11em; color: red; background-color: white; border: 1px solid red; padding: 4px; font-family: sans-serif">
|
||||
Your web browser must have JavaScript enabled
|
||||
in order for this application to display correctly.
|
||||
</div>
|
||||
</noscript>
|
||||
<!-- OPTIONAL: include this if you want history support -->
|
||||
<iframe src="javascript:''" id="__gwt_historyFrame" tabIndex='-1'
|
||||
style="position: absolute; width: 0; height: 0; border: 0"></iframe>
|
||||
|
||||
<h1>Web Application Starter Project</h1>
|
||||
|
||||
<table align="center">
|
||||
<tr>
|
||||
<td colspan="2" style="font-weight:bold;">Please enter your name:</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td id="nameFieldContainer"></td>
|
||||
<td id="sendButtonContainer"></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="2" style="color:red;" id="errorLabelContainer"></td>
|
||||
</tr>
|
||||
</table>
|
||||
</body>
|
||||
<!-- RECOMMENDED if your web app will not function without JavaScript enabled -->
|
||||
<noscript>
|
||||
<div
|
||||
style="width: 22em; position: absolute; left: 50%; margin-left: -11em; color: red; background-color: white; border: 1px solid red; padding: 4px; font-family: sans-serif">
|
||||
Your web browser must have JavaScript enabled in order for this
|
||||
application to display correctly.</div>
|
||||
</noscript>
|
||||
<div id="theContentModeratorDiv"></div>
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
<!-- Servlets -->
|
||||
<servlet>
|
||||
<servlet-name>greetServlet</servlet-name>
|
||||
<servlet-class>org.gcube.portlets.widgets.ckancontentmoderator.server.GreetingServiceImpl</servlet-class>
|
||||
<servlet-class>org.gcube.portlets.widgets.ckancontentmoderator.server.CkanContentModeratorServiceAImpl</servlet-class>
|
||||
</servlet>
|
||||
|
||||
<servlet-mapping>
|
||||
|
|
|
@ -0,0 +1,187 @@
|
|||
/*!
|
||||
jQuery Autosize v1.16.12
|
||||
(c) 2013 Jack Moore - jacklmoore.com
|
||||
updated: 2013-05-31
|
||||
license: http://www.opensource.org/licenses/mit-license.php
|
||||
*/
|
||||
|
||||
(function ($) {
|
||||
var
|
||||
defaults = {
|
||||
className: 'autosizejs',
|
||||
append: '',
|
||||
callback: false
|
||||
},
|
||||
hidden = 'hidden',
|
||||
borderBox = 'border-box',
|
||||
lineHeight = 'lineHeight',
|
||||
|
||||
// border:0 is unnecessary, but avoids a bug in FireFox on OSX
|
||||
copy = '<textarea tabindex="-1" style="position:absolute; top:-999px; left:0; right:auto; bottom:auto; border:0; -moz-box-sizing:content-box; -webkit-box-sizing:content-box; box-sizing:content-box; word-wrap:break-word; height:0 !important; min-height:0 !important; overflow:hidden;"/>',
|
||||
|
||||
// line-height is conditionally included because IE7/IE8/old Opera do not return the correct value.
|
||||
copyStyle = [
|
||||
'fontFamily',
|
||||
'fontSize',
|
||||
'fontWeight',
|
||||
'fontStyle',
|
||||
'letterSpacing',
|
||||
'textTransform',
|
||||
'wordSpacing',
|
||||
'textIndent'
|
||||
],
|
||||
oninput = 'oninput',
|
||||
onpropertychange = 'onpropertychange',
|
||||
|
||||
// to keep track which textarea is being mirrored when adjust() is called.
|
||||
mirrored,
|
||||
|
||||
// the mirror element, which is used to calculate what size the mirrored element should be.
|
||||
mirror = $(copy).data('autosize', true)[0];
|
||||
|
||||
// test that line-height can be accurately copied.
|
||||
mirror.style.lineHeight = '99px';
|
||||
if ($(mirror).css(lineHeight) === '99px') {
|
||||
copyStyle.push(lineHeight);
|
||||
}
|
||||
mirror.style.lineHeight = '';
|
||||
|
||||
$.fn.autosize = function (options) {
|
||||
options = $.extend({}, defaults, options || {});
|
||||
|
||||
if (mirror.parentNode !== document.body) {
|
||||
$(document.body).append(mirror);
|
||||
}
|
||||
|
||||
return this.each(function () {
|
||||
var
|
||||
ta = this,
|
||||
$ta = $(ta),
|
||||
minHeight,
|
||||
maxHeight,
|
||||
resize,
|
||||
boxOffset = 0,
|
||||
callback = $.isFunction(options.callback);
|
||||
|
||||
if ($ta.data('autosize')) {
|
||||
// exit if autosize has already been applied, or if the textarea is the mirror element.
|
||||
return;
|
||||
}
|
||||
|
||||
if ($ta.css('box-sizing') === borderBox || $ta.css('-moz-box-sizing') === borderBox || $ta.css('-webkit-box-sizing') === borderBox){
|
||||
boxOffset = $ta.outerHeight() - $ta.height();
|
||||
}
|
||||
|
||||
// IE8 and lower return 'auto', which parses to NaN, if no min-height is set.
|
||||
minHeight = Math.max(parseInt($ta.css('minHeight'), 10) - boxOffset || 0, $ta.height());
|
||||
|
||||
resize = ($ta.css('resize') === 'none' || $ta.css('resize') === 'vertical') ? 'none' : 'horizontal';
|
||||
|
||||
$ta.css({
|
||||
overflow: hidden,
|
||||
overflowY: hidden,
|
||||
wordWrap: 'break-word',
|
||||
resize: resize
|
||||
}).data('autosize', true);
|
||||
|
||||
function initMirror() {
|
||||
mirrored = ta;
|
||||
mirror.className = options.className;
|
||||
maxHeight = parseInt($ta.css('maxHeight'), 10);
|
||||
|
||||
// mirror is a duplicate textarea located off-screen that
|
||||
// is automatically updated to contain the same text as the
|
||||
// original textarea. mirror always has a height of 0.
|
||||
// This gives a cross-browser supported way getting the actual
|
||||
// height of the text, through the scrollTop property.
|
||||
$.each(copyStyle, function(i, val){
|
||||
mirror.style[val] = $ta.css(val);
|
||||
});
|
||||
|
||||
// The textarea overflow is probably now hidden, but Chrome doesn't reflow the text to account for the
|
||||
// new space made available by removing the scrollbars. This workaround causes Chrome to reflow the text.
|
||||
if (oninput in ta) {
|
||||
var value = ta.value;
|
||||
ta.value = '';
|
||||
ta.value = value;
|
||||
}
|
||||
}
|
||||
|
||||
// Using mainly bare JS in this function because it is going
|
||||
// to fire very often while typing, and needs to very efficient.
|
||||
function adjust() {
|
||||
var height, overflow, original;
|
||||
|
||||
if (mirrored !== ta) {
|
||||
initMirror();
|
||||
}
|
||||
|
||||
mirror.value = ta.value + options.append;
|
||||
mirror.style.overflowY = ta.style.overflowY;
|
||||
original = parseInt(ta.style.height,10);
|
||||
|
||||
// Update the width in case the original textarea width has changed
|
||||
// A floor of 0 is needed because IE8 returns a negative value for hidden textareas, raising an error.
|
||||
mirror.style.width = Math.max($ta.width(), 0) + 'px';
|
||||
|
||||
// Needed for IE8 and lower to reliably return the correct scrollTop
|
||||
mirror.scrollTop = 0;
|
||||
|
||||
mirror.scrollTop = 9e4;
|
||||
|
||||
// Using scrollTop rather than scrollHeight because scrollHeight is non-standard and includes padding.
|
||||
height = mirror.scrollTop;
|
||||
|
||||
if (maxHeight && height > maxHeight) {
|
||||
height = maxHeight;
|
||||
overflow = 'scroll';
|
||||
} else if (height < minHeight) {
|
||||
height = minHeight;
|
||||
}
|
||||
|
||||
height += boxOffset;
|
||||
ta.style.overflowY = overflow || hidden;
|
||||
|
||||
if (original !== height) {
|
||||
ta.style.height = height + 'px';
|
||||
if (callback) {
|
||||
options.callback.call(ta,ta);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (onpropertychange in ta) {
|
||||
if (oninput in ta) {
|
||||
// Detects IE9. IE9 does not fire onpropertychange or oninput for deletions,
|
||||
// so binding to onkeyup to catch most of those occassions. There is no way that I
|
||||
// know of to detect something like 'cut' in IE9.
|
||||
ta[oninput] = ta.onkeyup = adjust;
|
||||
} else {
|
||||
// IE7 / IE8
|
||||
ta[onpropertychange] = function(){
|
||||
if(event.propertyName === 'value'){
|
||||
adjust();
|
||||
}
|
||||
};
|
||||
}
|
||||
} else {
|
||||
// Modern Browsers
|
||||
ta[oninput] = adjust;
|
||||
}
|
||||
|
||||
$(window).on('resize', function(){
|
||||
active = false;
|
||||
adjust();
|
||||
});
|
||||
|
||||
// Allow for manual triggering if needed.
|
||||
$ta.on('autosize', function(){
|
||||
active = false;
|
||||
adjust();
|
||||
});
|
||||
|
||||
// Call adjust in case the textarea already contains text.
|
||||
adjust();
|
||||
});
|
||||
};
|
||||
}(window.jQuery || window.Zepto));
|
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue