Use vex dialog on mobile when inserting a comment
Change-Id: Ibe089c810edba7696fd6e707e4a757ee83fdf99d
This commit is contained in:
parent
ae89da611d
commit
c8962910a5
1 changed files with 64 additions and 9 deletions
|
@ -3,7 +3,8 @@
|
|||
* Impress tile layer is used to display a presentation document
|
||||
*/
|
||||
|
||||
/* global $ _ w2ui w2utils _UNO */
|
||||
/* global $ _ w2ui w2utils _UNO L */
|
||||
|
||||
L.ImpressTileLayer = L.TileLayer.extend({
|
||||
extraSize: L.point(290, 0),
|
||||
|
||||
|
@ -20,14 +21,68 @@ L.ImpressTileLayer = L.TileLayer.extend({
|
|||
return;
|
||||
}
|
||||
this.onAnnotationCancel();
|
||||
this._draft = L.annotation(L.latLng(0, 0), comment, {noMenu: true}).addTo(this._map);
|
||||
this._draft.edit();
|
||||
var mapCenter = this._map.latLngToLayerPoint(this._map.getCenter());
|
||||
var bounds = this._draft.getBounds();
|
||||
var topLeft = mapCenter.subtract(L.point(bounds.max.x - bounds.min.x, (bounds.max.y - bounds.min.y)/2));
|
||||
this._draft.setLatLng(this._map.layerPointToLatLng(topLeft));
|
||||
this.layoutAnnotations();
|
||||
this._draft.focus();
|
||||
|
||||
if (window.mode.isMobile()) {
|
||||
var that = this;
|
||||
|
||||
var dialog = vex.dialog.open({
|
||||
message: '',
|
||||
input: [
|
||||
'<textarea name="comment" content="' + comment.text + '" class="loleaflet-annotation-textarea" style="max-width: 400px" required />'
|
||||
].join(''),
|
||||
buttons: [
|
||||
$.extend({}, vex.dialog.buttons.YES, { text: _('Save') }),
|
||||
$.extend({}, vex.dialog.buttons.NO, { text: _('Cancel') })
|
||||
],
|
||||
callback: function (data) {
|
||||
if (data) {
|
||||
that._draft = L.annotation(L.latLng(0, 0), comment, {noMenu: true}).addTo(that._map);
|
||||
that._draft._data.text = data.comment;
|
||||
that.onAnnotationSave();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
var tagTd = 'td',
|
||||
empty = '',
|
||||
tagDiv = 'div';
|
||||
this._author = L.DomUtil.create('table', 'loleaflet-annotation-table');
|
||||
var tbody = L.DomUtil.create('tbody', empty, this._author);
|
||||
var tr = L.DomUtil.create('tr', empty, tbody);
|
||||
var tdImg = L.DomUtil.create(tagTd, 'loleaflet-annotation-img', tr);
|
||||
var tdAuthor = L.DomUtil.create(tagTd, 'loleaflet-annotation-author', tr);
|
||||
var imgAuthor = L.DomUtil.create('img', 'avatar-img', tdImg);
|
||||
imgAuthor.setAttribute('src', L.Icon.Default.imagePath + '/user.png');
|
||||
imgAuthor.setAttribute('width', 32);
|
||||
imgAuthor.setAttribute('height', 32);
|
||||
this._authorAvatarImg = imgAuthor;
|
||||
this._contentAuthor = L.DomUtil.create(tagDiv, 'loleaflet-annotation-content-author', tdAuthor);
|
||||
this._contentDate = L.DomUtil.create(tagDiv, 'loleaflet-annotation-date', tdAuthor);
|
||||
|
||||
$(this._nodeModifyText).text(comment.text);
|
||||
$(this._contentAuthor).text(comment.author);
|
||||
$(this._authorAvatarImg).attr('src', comment.avatar);
|
||||
var user = this._map.getViewId(comment.author);
|
||||
if (user >= 0) {
|
||||
var color = L.LOUtil.rgbToHex(this._map.getViewColor(user));
|
||||
$(this._authorAvatarImg).css('border-color', color);
|
||||
}
|
||||
|
||||
var d = new Date(comment.dateTime.replace(/,.*/, 'Z'));
|
||||
var dateOptions = { weekday: 'short', year: 'numeric', month: 'short', day: 'numeric' };
|
||||
$(this._contentDate).text((isNaN(d.getTime()) || this._map.getDocType() === 'spreadsheet')? comment.dateTime: d.toLocaleDateString(String.locale, dateOptions));
|
||||
|
||||
dialog.get(0).insertBefore(this._author, dialog.get(0).childNodes[0]);
|
||||
} else {
|
||||
this._draft = L.annotation(L.latLng(0, 0), comment, {noMenu: true}).addTo(this._map);
|
||||
this._draft.edit();
|
||||
var mapCenter = this._map.latLngToLayerPoint(this._map.getCenter());
|
||||
var bounds = this._draft.getBounds();
|
||||
var topLeft = mapCenter.subtract(L.point(bounds.max.x - bounds.min.x, (bounds.max.y - bounds.min.y)/2));
|
||||
this._draft.setLatLng(this._map.layerPointToLatLng(topLeft));
|
||||
this.layoutAnnotations();
|
||||
this._draft.focus();
|
||||
}
|
||||
},
|
||||
|
||||
beforeAdd: function (map) {
|
||||
|
|
Loading…
Reference in a new issue