-
Notifications
You must be signed in to change notification settings - Fork 741
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Remove latlng usage from ContentControl section.
Signed-off-by: Gökay Şatır <[email protected]> Change-Id: Id450c65c52f28508381f2ea5f11f4300116cbd36
- Loading branch information
1 parent
ddb21e5
commit 1cf4ca6
Showing
5 changed files
with
199 additions
and
176 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
154 changes: 154 additions & 0 deletions
154
browser/src/canvas/sections/ContentControlDropdownSubSection.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,154 @@ | ||
/* global Proxy _ */ | ||
/* | ||
* Copyright the Collabora Online contributors. | ||
* | ||
* SPDX-License-Identifier: MPL-2.0 | ||
* | ||
* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this | ||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. | ||
*/ | ||
|
||
class ContentControlDropdownSubSection extends HTMLObjectSection { | ||
constructor( | ||
sectionName: string, | ||
documentPosition: cool.SimplePoint, | ||
visible: boolean = true, | ||
dropdownMarkerWidth: number, | ||
dropdownMarkerHeight: number, | ||
) { | ||
super( | ||
sectionName, | ||
dropdownMarkerWidth, | ||
dropdownMarkerHeight, | ||
documentPosition, | ||
'writer-drop-down-marker', | ||
visible, | ||
); | ||
} | ||
|
||
private callback( | ||
objectType: any, | ||
eventType: any, | ||
object: any, | ||
data: any, | ||
builder: any, | ||
): void { | ||
var fireEvent: string = 'jsdialog'; | ||
if ((<any>window).mode.isMobile()) { | ||
fireEvent = 'mobilewizard'; | ||
} | ||
var closeDropdownJson = { | ||
jsontype: 'dialog', | ||
type: 'modalpopup', | ||
action: 'close', | ||
id: builder.windowId, | ||
}; | ||
|
||
if (eventType === 'close') { | ||
app.map.fire(fireEvent, { data: closeDropdownJson, callback: undefined }); | ||
} else if (eventType === 'select') { | ||
app.socket.sendMessage( | ||
'contentcontrolevent type=drop-down selected=' + data, | ||
); | ||
app.map.fire(fireEvent, { data: closeDropdownJson, callback: undefined }); | ||
} | ||
} | ||
|
||
private showDatePicker(): void { | ||
if ($('#datepicker').is(':visible')) { | ||
$('#datepicker').hide(); | ||
} else { | ||
var datePicker = document.getElementById('datepicker'); | ||
datePicker.style.left = this.position[0] + this.size[0] + 'px'; | ||
datePicker.style.top = this.position[1] + this.size[1] + 'px'; | ||
$('#datepicker').show(); | ||
} | ||
} | ||
|
||
private getDropdownJson(): any { | ||
if (!this.sectionProperties.json.items) return; | ||
|
||
const json: any = { | ||
children: [ | ||
{ | ||
id: 'container-dropdown', | ||
type: 'container', | ||
text: '', | ||
enabled: true, | ||
children: [ | ||
{ | ||
id: 'contentControlList', | ||
type: 'treelistbox', | ||
text: '', | ||
enabled: true, | ||
singleclickactivate: true, | ||
}, | ||
], | ||
vertical: true, | ||
}, | ||
], | ||
jsontype: 'dialog', | ||
type: 'modalpopup', | ||
cancellable: true, | ||
popupParent: '_POPOVER_', | ||
clickToClose: '_POPOVER_', | ||
id: 'contentControlModalpopup', | ||
isPopupPartialScreen: true, | ||
}; | ||
|
||
const entries = []; | ||
const items = this.sectionProperties.json.items; | ||
|
||
//add entries | ||
for (var i in items) { | ||
var entry = { | ||
text: items[i], | ||
columns: [ | ||
{ | ||
text: items[i], | ||
}, | ||
], | ||
row: i.toString(), | ||
}; | ||
entries.push(entry); | ||
} | ||
json.children[0].children[0].entries = entries; | ||
|
||
//add position | ||
json.posx = this.position[0] + this.size[0]; | ||
json.posy = this.position[1] + this.size[1]; | ||
|
||
return json; | ||
} | ||
|
||
onMouseEnter(point: Array<number>, e: MouseEvent): void { | ||
app.map.dontHandleMouse = true; | ||
} | ||
|
||
onMouseLeave(point: Array<number>, e: MouseEvent): void { | ||
app.map.dontHandleMouse = false; | ||
} | ||
|
||
onClick(point: number[], e: MouseEvent): void { | ||
e.preventDefault(); | ||
e.stopPropagation(); | ||
this.stopPropagating(); | ||
|
||
if (this.sectionProperties.datePicker) { | ||
this.showDatePicker(); | ||
} else if (this.sectionProperties.json.items) { | ||
var fireEvent: string = 'jsdialog'; | ||
if ((<any>window).mode.isMobile()) { | ||
fireEvent = 'mobilewizard'; | ||
} | ||
app.map.fire(fireEvent, { | ||
data: this.getDropdownJson(), | ||
callback: this.callback, | ||
}); | ||
} | ||
} | ||
} | ||
|
||
app.definitions.contentControlDropdownSubSection = | ||
ContentControlDropdownSubSection; |
Oops, something went wrong.