Change in Code Indentation

This commit is contained in:
Luis Fernando Molina committed 2020-07-29 11:09:04 +02:00
1 parent 1a52e5494e
commit 199a71a4e5
89 files changed
+22093 -22093

No files matched your search

+100 -100
View File
@@ -1,107 +1,107 @@
function newListItem () {
const MODULE_NAME = 'List Item'
const ERROR_LOG = true
const logger = newWebDebugLog()
logger.fileName = MODULE_NAME
function newListItem() {
const MODULE_NAME = 'List Item'
const ERROR_LOG = true
const logger = newWebDebugLog()
logger.fileName = MODULE_NAME
let thisObject = {
container: undefined,
fitFunction: undefined,
physics: physics,
draw: draw,
getContainer: getContainer,
initialize: initialize,
finalize: finalize
}
thisObject.container = newContainer()
thisObject.container.initialize()
thisObject.container.isDraggeable = false
thisObject.container.isWheelable = false
thisObject.container.detectMouseOver = true
thisObject.container.isClickeable = true
thisObject.container.frame.width = SIDE_PANEL_WIDTH * 0.75
thisObject.container.frame.height = SIDE_PANEL_WIDTH * 0.75
let name
let type
let onMouseOverEventSubscriptionId
let onMouseNotOverEventSubscriptionId
let onMouseClickEventSubscriptionId
let isMouseOver = false
return thisObject
function finalize () {
thisObject.container.eventHandler.stopListening(onMouseOverEventSubscriptionId)
thisObject.container.eventHandler.stopListening(onMouseNotOverEventSubscriptionId)
thisObject.container.eventHandler.stopListening(onMouseClickEventSubscriptionId)
thisObject.container.finalize()
thisObject.container = undefined
thisObject.fitFunction = undefined
}
function initialize (pName, pType) {
name = pName
type = pType
onMouseOverEventSubscriptionId = thisObject.container.eventHandler.listenToEvent('onMouseOver', onMouseOver)
onMouseNotOverEventSubscriptionId = thisObject.container.eventHandler.listenToEvent('onMouseNotOver', onMouseNotOver)
onMouseClickEventSubscriptionId = thisObject.container.eventHandler.listenToEvent('onMouseClick', onMouseClick)
}
function getContainer (point) {
if (thisObject.container.frame.isThisPointHere(point, true) === true) {
return thisObject.container
}
}
function onMouseOver (event) {
isMouseOver = true
}
function onMouseNotOver () {
isMouseOver = false
}
function onMouseClick (event) {
canvas.designSpace.workspace.replaceWorkspaceByLoadingOne(name)
}
function physics () {
}
function draw () {
let icon = canvas.designSpace.iconByUiObjectType.get(type)
let backgroundColor = UI_COLOR.BLACK
let labelColor
const RED_LINE_HIGHT = 4
const OPACITY = 1
let params = {
cornerRadius: 0,
lineWidth: 1,
container: thisObject.container,
borderColor: UI_COLOR.RUSTED_RED,
castShadow: false,
backgroundColor: backgroundColor,
opacity: OPACITY
let thisObject = {
container: undefined,
fitFunction: undefined,
physics: physics,
draw: draw,
getContainer: getContainer,
initialize: initialize,
finalize: finalize
}
if (isMouseOver === false) {
labelColor = UI_COLOR.WHITE
} else {
labelColor = UI_COLOR.TITANIUM_YELLOW
thisObject.container = newContainer()
thisObject.container.initialize()
thisObject.container.isDraggeable = false
thisObject.container.isWheelable = false
thisObject.container.detectMouseOver = true
thisObject.container.isClickeable = true
thisObject.container.frame.width = SIDE_PANEL_WIDTH * 0.75
thisObject.container.frame.height = SIDE_PANEL_WIDTH * 0.75
let name
let type
let onMouseOverEventSubscriptionId
let onMouseNotOverEventSubscriptionId
let onMouseClickEventSubscriptionId
let isMouseOver = false
return thisObject
function finalize() {
thisObject.container.eventHandler.stopListening(onMouseOverEventSubscriptionId)
thisObject.container.eventHandler.stopListening(onMouseNotOverEventSubscriptionId)
thisObject.container.eventHandler.stopListening(onMouseClickEventSubscriptionId)
thisObject.container.finalize()
thisObject.container = undefined
thisObject.fitFunction = undefined
}
roundedCornersBackground(params)
function initialize(pName, pType) {
name = pName
type = pType
drawLabel(name, 1 / 2, 3.0 / 10, -5, 0, 15, thisObject.container, labelColor)
drawLabel(type, 1 / 2, 7.2 / 10, -5, 0, 15, thisObject.container, labelColor)
drawIcon(icon, 1 / 2, 1 / 2, 0, 0, 80, thisObject.container)
}
onMouseOverEventSubscriptionId = thisObject.container.eventHandler.listenToEvent('onMouseOver', onMouseOver)
onMouseNotOverEventSubscriptionId = thisObject.container.eventHandler.listenToEvent('onMouseNotOver', onMouseNotOver)
onMouseClickEventSubscriptionId = thisObject.container.eventHandler.listenToEvent('onMouseClick', onMouseClick)
}
function getContainer(point) {
if (thisObject.container.frame.isThisPointHere(point, true) === true) {
return thisObject.container
}
}
function onMouseOver(event) {
isMouseOver = true
}
function onMouseNotOver() {
isMouseOver = false
}
function onMouseClick(event) {
canvas.designSpace.workspace.replaceWorkspaceByLoadingOne(name)
}
function physics() {
}
function draw() {
let icon = canvas.designSpace.iconByUiObjectType.get(type)
let backgroundColor = UI_COLOR.BLACK
let labelColor
const RED_LINE_HIGHT = 4
const OPACITY = 1
let params = {
cornerRadius: 0,
lineWidth: 1,
container: thisObject.container,
borderColor: UI_COLOR.RUSTED_RED,
castShadow: false,
backgroundColor: backgroundColor,
opacity: OPACITY
}
if (isMouseOver === false) {
labelColor = UI_COLOR.WHITE
} else {
labelColor = UI_COLOR.TITANIUM_YELLOW
}
roundedCornersBackground(params)
drawLabel(name, 1 / 2, 3.0 / 10, -5, 0, 15, thisObject.container, labelColor)
drawLabel(type, 1 / 2, 7.2 / 10, -5, 0, 15, thisObject.container, labelColor)
drawIcon(icon, 1 / 2, 1 / 2, 0, 0, 80, thisObject.container)
}
}
+245 -245
View File
@@ -1,271 +1,271 @@
function newListView () {
const MODULE_NAME = 'List View'
const ERROR_LOG = true
const logger = newWebDebugLog()
logger.fileName = MODULE_NAME
function newListView() {
const MODULE_NAME = 'List View'
const ERROR_LOG = true
const logger = newWebDebugLog()
logger.fileName = MODULE_NAME
let thisObject = {
fitFunction: undefined,
container: undefined,
listItems: [],
payload: undefined,
isVisible: false,
resize: resize,
turnOn: turnOn,
turnOff: turnOff,
physics: physics,
draw: draw,
getContainer: getContainer,
initialize: initialize,
finalize: finalize
}
thisObject.container = newContainer()
thisObject.container.initialize()
thisObject.container.isDraggeable = false
thisObject.container.isWheelable = true
thisObject.container.detectMouseOver = true
let isInitialized = false
let listItemsMap = new Map()
let visibleListItems = []
let firstVisibleListItem
let headerHeight = 40
let footerHeight = 30
let listItemHeight = SIDE_PANEL_WIDTH * 0.75
let posibleVisibleListItems
let itemSeparation
let onMouseWheelEventSuscriptionId
return thisObject
function finalize () {
thisObject.container.eventHandler.stopListening(onMouseWheelEventSuscriptionId)
listItemsMap = undefined
visibleListItems = undefined
thisObject.container.finalize()
thisObject.container = undefined
thisObject.payload = undefined
thisObject = undefined
}
function initialize () {
thisObject.container.name = MODULE_NAME
thisObject.container.frame.containerName = thisObject.container.name
thisObject.container.frame.width = SIDE_PANEL_WIDTH * 0.75
let position = { // Default position
x: SIDE_PANEL_WIDTH * 0.25 / 2,
y: 20
let thisObject = {
fitFunction: undefined,
container: undefined,
listItems: [],
payload: undefined,
isVisible: false,
resize: resize,
turnOn: turnOn,
turnOff: turnOff,
physics: physics,
draw: draw,
getContainer: getContainer,
initialize: initialize,
finalize: finalize
}
thisObject.container.frame.position = position
thisObject.container = newContainer()
thisObject.container.initialize()
thisObject.container.isDraggeable = false
thisObject.container.isWheelable = true
thisObject.container.detectMouseOver = true
onMouseWheelEventSuscriptionId = thisObject.container.eventHandler.listenToEvent('onMouseWheel', onMouseWheel)
let isInitialized = false
resize()
turnOn()
}
let listItemsMap = new Map()
let visibleListItems = []
let firstVisibleListItem
function resize () {
thisObject.container.frame.height = browserCanvas.height - thisObject.container.frame.position.y * 2
let headerHeight = 40
let footerHeight = 30
let listItemHeight = SIDE_PANEL_WIDTH * 0.75
let spaceForListItems = (thisObject.container.frame.height - headerHeight - footerHeight)
posibleVisibleListItems = Math.trunc(spaceForListItems / (listItemHeight))
if ((posibleVisibleListItems - 1) !== 0) {
itemSeparation = (spaceForListItems - listItemHeight * posibleVisibleListItems) / (posibleVisibleListItems - 1)
} else {
itemSeparation = 0
}
}
let posibleVisibleListItems
function turnOn () {
firstVisibleListItem = 1
let itemSeparation
callServer(undefined, 'ListWorkspaces', onResponse)
let onMouseWheelEventSuscriptionId
function onResponse (err, text) {
if (err && err.result !== GLOBAL.DEFAULT_OK_RESPONSE.result) {
if (ERROR_LOG === true) { logger.write('[ERROR] initialize -> Could not load the list of your workspaces from the backend. ') }
return
}
return thisObject
let workspacelist = JSON.parse(text)
thisObject.listItems = []
for (let i = 0; i < workspacelist.length; i++) {
let workspace = workspacelist[i].replace('.json', '')
let listItem = newListItem()
listItem.initialize(workspace, 'Workspace')
listItem.container.connectToParent(thisObject.container, false, false)
function finalize() {
thisObject.container.eventHandler.stopListening(onMouseWheelEventSuscriptionId)
thisObject.listItems.push(listItem)
}
calculateVisbleListItems()
isInitialized = true
thisObject.isVisible = true
}
}
listItemsMap = undefined
visibleListItems = undefined
function turnOff () {
thisObject.isVisible = false
}
thisObject.container.finalize()
thisObject.container = undefined
function onMouseWheel (event) {
delta = event.wheelDelta
if (delta > 0) {
delta = -1
} else {
delta = 1
thisObject.payload = undefined
thisObject = undefined
}
firstVisibleListItem = firstVisibleListItem + delta
function initialize() {
thisObject.container.name = MODULE_NAME
thisObject.container.frame.containerName = thisObject.container.name
thisObject.container.frame.width = SIDE_PANEL_WIDTH * 0.75
calculateVisbleListItems()
}
function calculateVisbleListItems () {
let availableSlots = Math.trunc(posibleVisibleListItems)
if (firstVisibleListItem < 1) { firstVisibleListItem = 1 }
if (firstVisibleListItem > (thisObject.listItems.length - availableSlots + 1)) { firstVisibleListItem = thisObject.listItems.length - availableSlots + 1 }
visibleListItems = []
for (let i = 0; i < thisObject.listItems.length; i++) {
if (i + 1 >= firstVisibleListItem && i + 1 < firstVisibleListItem + availableSlots) {
let listItem = thisObject.listItems[i]
listItem.container.frame.position.x = 0
listItem.container.frame.position.y = (listItemHeight + itemSeparation) * visibleListItems.length + headerHeight
/* Add to Visible Product Array */
visibleListItems.push(listItem)
}
}
}
function getContainer (point, purpose) {
if (isInitialized === false || thisObject.isVisible === false) { return }
let container
/* First we check if thisObject point is inside thisObject space. */
if (thisObject.container.frame.isThisPointHere(point, true) === true) {
/* Now we see which is the inner most container that has it */
for (let i = 0; i < visibleListItems.length; i++) {
container = visibleListItems[i].getContainer(point)
if (container !== undefined) {
if (container.isForThisPurpose(purpose) === true) {
return container
}
let position = { // Default position
x: SIDE_PANEL_WIDTH * 0.25 / 2,
y: 20
}
}
return thisObject.container
}
}
thisObject.container.frame.position = position
function childrenPhysics () {
for (let i = 0; i < thisObject.listItems.length; i++) {
let listItem = thisObject.listItems[i]
listItem.physics()
}
}
onMouseWheelEventSuscriptionId = thisObject.container.eventHandler.listenToEvent('onMouseWheel', onMouseWheel)
function physics () {
if (isInitialized === false || thisObject.isVisible === false) { return }
if (isInitialized === false) { return }
if (thisObject.isVisible === false) { return }
childrenPhysics()
}
function draw () {
if (isInitialized === false || thisObject.isVisible === false) { return }
drawBackground()
drawChildren()
drawScrollBar()
}
function drawChildren () {
for (let i = 0; i < visibleListItems.length; i++) {
let listItem = visibleListItems[i]
if (listItem !== undefined) {
listItem.draw()
}
}
}
function drawBackground () {
let label = 'Your Workspaces'
let backgroundColor = UI_COLOR.WHITE
let params = {
cornerRadius: 5,
lineWidth: 1,
container: thisObject.container,
borderColor: UI_COLOR.RUSTED_RED,
castShadow: false,
backgroundColor: backgroundColor,
opacity: 1
resize()
turnOn()
}
roundedCornersBackground(params)
function resize() {
thisObject.container.frame.height = browserCanvas.height - thisObject.container.frame.position.y * 2
drawLabel(label, 1 / 2, 0, 0, 25, 15, thisObject.container, UI_COLOR.BLACK)
}
function drawScrollBar () {
if (thisObject.listItems.length > posibleVisibleListItems && posibleVisibleListItems > 0) {
let xOffset = 4
let barTopPoint = {
x: thisObject.container.frame.width - xOffset,
y: headerHeight
}
let barBottomPoint = {
x: thisObject.container.frame.width - xOffset,
y: thisObject.container.frame.height - footerHeight
}
let ratio = (posibleVisibleListItems * listItemHeight + (posibleVisibleListItems - 1) * itemSeparation) / (thisObject.listItems.length * listItemHeight + (thisObject.listItems.length - 1) * itemSeparation)
let handleHeight = posibleVisibleListItems * (listItemHeight * ratio) + (posibleVisibleListItems - 1) * itemSeparation * ratio
let handleTopPoint = {
x: thisObject.container.frame.width - xOffset,
y: headerHeight + (listItemHeight * ratio * (firstVisibleListItem - 1) + itemSeparation * ratio * (firstVisibleListItem - 1))
}
let handleBottomPoint = {
x: thisObject.container.frame.width - xOffset,
y: handleTopPoint.y + handleHeight
}
barTopPoint = thisObject.container.frame.frameThisPoint(barTopPoint)
barBottomPoint = thisObject.container.frame.frameThisPoint(barBottomPoint)
handleTopPoint = thisObject.container.frame.frameThisPoint(handleTopPoint)
handleBottomPoint = thisObject.container.frame.frameThisPoint(handleBottomPoint)
browserCanvasContext.beginPath()
browserCanvasContext.moveTo(barTopPoint.x, barTopPoint.y)
browserCanvasContext.lineTo(barBottomPoint.x, barBottomPoint.y)
browserCanvasContext.closePath()
browserCanvasContext.setLineDash([0, 0])
browserCanvasContext.lineWidth = 1
browserCanvasContext.strokeStyle = 'rgba(' + UI_COLOR.GREY + ', ' + 1 + ')'
browserCanvasContext.stroke()
browserCanvasContext.beginPath()
browserCanvasContext.moveTo(handleTopPoint.x, handleTopPoint.y)
browserCanvasContext.lineTo(handleBottomPoint.x, handleBottomPoint.y)
browserCanvasContext.closePath()
browserCanvasContext.setLineDash([0, 0])
browserCanvasContext.lineWidth = 4
browserCanvasContext.strokeStyle = 'rgba(' + UI_COLOR.PATINATED_TURQUOISE + ', ' + 1 + ')'
browserCanvasContext.stroke()
let spaceForListItems = (thisObject.container.frame.height - headerHeight - footerHeight)
posibleVisibleListItems = Math.trunc(spaceForListItems / (listItemHeight))
if ((posibleVisibleListItems - 1) !== 0) {
itemSeparation = (spaceForListItems - listItemHeight * posibleVisibleListItems) / (posibleVisibleListItems - 1)
} else {
itemSeparation = 0
}
}
function turnOn() {
firstVisibleListItem = 1
callServer(undefined, 'ListWorkspaces', onResponse)
function onResponse(err, text) {
if (err && err.result !== GLOBAL.DEFAULT_OK_RESPONSE.result) {
if (ERROR_LOG === true) { logger.write('[ERROR] initialize -> Could not load the list of your workspaces from the backend. ') }
return
}
let workspacelist = JSON.parse(text)
thisObject.listItems = []
for (let i = 0; i < workspacelist.length; i++) {
let workspace = workspacelist[i].replace('.json', '')
let listItem = newListItem()
listItem.initialize(workspace, 'Workspace')
listItem.container.connectToParent(thisObject.container, false, false)
thisObject.listItems.push(listItem)
}
calculateVisbleListItems()
isInitialized = true
thisObject.isVisible = true
}
}
function turnOff() {
thisObject.isVisible = false
}
function onMouseWheel(event) {
delta = event.wheelDelta
if (delta > 0) {
delta = -1
} else {
delta = 1
}
firstVisibleListItem = firstVisibleListItem + delta
calculateVisbleListItems()
}
function calculateVisbleListItems() {
let availableSlots = Math.trunc(posibleVisibleListItems)
if (firstVisibleListItem < 1) { firstVisibleListItem = 1 }
if (firstVisibleListItem > (thisObject.listItems.length - availableSlots + 1)) { firstVisibleListItem = thisObject.listItems.length - availableSlots + 1 }
visibleListItems = []
for (let i = 0; i < thisObject.listItems.length; i++) {
if (i + 1 >= firstVisibleListItem && i + 1 < firstVisibleListItem + availableSlots) {
let listItem = thisObject.listItems[i]
listItem.container.frame.position.x = 0
listItem.container.frame.position.y = (listItemHeight + itemSeparation) * visibleListItems.length + headerHeight
/* Add to Visible Product Array */
visibleListItems.push(listItem)
}
}
}
function getContainer(point, purpose) {
if (isInitialized === false || thisObject.isVisible === false) { return }
let container
/* First we check if thisObject point is inside thisObject space. */
if (thisObject.container.frame.isThisPointHere(point, true) === true) {
/* Now we see which is the inner most container that has it */
for (let i = 0; i < visibleListItems.length; i++) {
container = visibleListItems[i].getContainer(point)
if (container !== undefined) {
if (container.isForThisPurpose(purpose) === true) {
return container
}
}
}
return thisObject.container
}
}
function childrenPhysics() {
for (let i = 0; i < thisObject.listItems.length; i++) {
let listItem = thisObject.listItems[i]
listItem.physics()
}
}
function physics() {
if (isInitialized === false || thisObject.isVisible === false) { return }
if (isInitialized === false) { return }
if (thisObject.isVisible === false) { return }
childrenPhysics()
}
function draw() {
if (isInitialized === false || thisObject.isVisible === false) { return }
drawBackground()
drawChildren()
drawScrollBar()
}
function drawChildren() {
for (let i = 0; i < visibleListItems.length; i++) {
let listItem = visibleListItems[i]
if (listItem !== undefined) {
listItem.draw()
}
}
}
function drawBackground() {
let label = 'Your Workspaces'
let backgroundColor = UI_COLOR.WHITE
let params = {
cornerRadius: 5,
lineWidth: 1,
container: thisObject.container,
borderColor: UI_COLOR.RUSTED_RED,
castShadow: false,
backgroundColor: backgroundColor,
opacity: 1
}
roundedCornersBackground(params)
drawLabel(label, 1 / 2, 0, 0, 25, 15, thisObject.container, UI_COLOR.BLACK)
}
function drawScrollBar() {
if (thisObject.listItems.length > posibleVisibleListItems && posibleVisibleListItems > 0) {
let xOffset = 4
let barTopPoint = {
x: thisObject.container.frame.width - xOffset,
y: headerHeight
}
let barBottomPoint = {
x: thisObject.container.frame.width - xOffset,
y: thisObject.container.frame.height - footerHeight
}
let ratio = (posibleVisibleListItems * listItemHeight + (posibleVisibleListItems - 1) * itemSeparation) / (thisObject.listItems.length * listItemHeight + (thisObject.listItems.length - 1) * itemSeparation)
let handleHeight = posibleVisibleListItems * (listItemHeight * ratio) + (posibleVisibleListItems - 1) * itemSeparation * ratio
let handleTopPoint = {
x: thisObject.container.frame.width - xOffset,
y: headerHeight + (listItemHeight * ratio * (firstVisibleListItem - 1) + itemSeparation * ratio * (firstVisibleListItem - 1))
}
let handleBottomPoint = {
x: thisObject.container.frame.width - xOffset,
y: handleTopPoint.y + handleHeight
}
barTopPoint = thisObject.container.frame.frameThisPoint(barTopPoint)
barBottomPoint = thisObject.container.frame.frameThisPoint(barBottomPoint)
handleTopPoint = thisObject.container.frame.frameThisPoint(handleTopPoint)
handleBottomPoint = thisObject.container.frame.frameThisPoint(handleBottomPoint)
browserCanvasContext.beginPath()
browserCanvasContext.moveTo(barTopPoint.x, barTopPoint.y)
browserCanvasContext.lineTo(barBottomPoint.x, barBottomPoint.y)
browserCanvasContext.closePath()
browserCanvasContext.setLineDash([0, 0])
browserCanvasContext.lineWidth = 1
browserCanvasContext.strokeStyle = 'rgba(' + UI_COLOR.GREY + ', ' + 1 + ')'
browserCanvasContext.stroke()
browserCanvasContext.beginPath()
browserCanvasContext.moveTo(handleTopPoint.x, handleTopPoint.y)
browserCanvasContext.lineTo(handleBottomPoint.x, handleBottomPoint.y)
browserCanvasContext.closePath()
browserCanvasContext.setLineDash([0, 0])
browserCanvasContext.lineWidth = 4
browserCanvasContext.strokeStyle = 'rgba(' + UI_COLOR.PATINATED_TURQUOISE + ', ' + 1 + ')'
browserCanvasContext.stroke()
}
}
}
}
+215 -215
View File
@@ -1,237 +1,237 @@
function newSidePanelTab () {
const MODULE_NAME = 'Side Panel Tab'
let thisObject = {
pointerDirection: 'left',
container: undefined,
resize: resize,
physics: physics,
draw: draw,
getContainer: getContainer,
initialize: initialize
}
const TAB_WIDTH = 25
const TAB_HEIGHT = 60
let isInitialized = false
let animation = 'none'
let ORIGINAL_PARENT_POSITON
let xOffset = 0
thisObject.container = newContainer()
thisObject.container.name = MODULE_NAME
thisObject.container.initialize()
thisObject.container.isClickeable = true
thisObject.container.isDraggeable = false
return thisObject
function initialize () {
thisObject.container.frame.width = TAB_WIDTH
thisObject.container.frame.height = TAB_HEIGHT
ORIGINAL_PARENT_POSITON = thisObject.container.parentContainer.frame.position.x
thisObject.container.eventHandler.listenToEvent('onMouseClick', onMouseClick)
resize()
isInitialized = true
}
function resize () {
thisObject.container.frame.position.x = 0 + thisObject.container.parentContainer.frame.width
thisObject.container.frame.position.y = 69
setClosed()
}
function onMouseClick (event) {
if (thisObject.pointerDirection === 'left') {
animation = 'opening'
thisObject.container.eventHandler.raiseEvent('opening')
} else {
animation = 'closing'
thisObject.container.eventHandler.raiseEvent('closing')
}
}
function getContainer (point) {
let container
if (thisObject.container.frame.isThisPointHere(point, true) === true) {
return thisObject.container
} else {
return undefined
}
}
function physics () {
if (isInitialized === false) { return }
animate()
}
function draw () {
if (isInitialized === false) { return }
borders()
arrow()
}
function animate () {
const STEP = 50
if (animation === 'opening') {
xOffset = xOffset + STEP
thisObject.container.parentContainer.frame.position.x = ORIGINAL_PARENT_POSITON + xOffset
if (xOffset >= thisObject.container.parentContainer.frame.width) {
setOpened()
thisObject.container.eventHandler.raiseEvent('opened')
}
function newSidePanelTab() {
const MODULE_NAME = 'Side Panel Tab'
let thisObject = {
pointerDirection: 'left',
container: undefined,
resize: resize,
physics: physics,
draw: draw,
getContainer: getContainer,
initialize: initialize
}
if (animation === 'closing') {
xOffset = xOffset - STEP
thisObject.container.parentContainer.frame.position.x = ORIGINAL_PARENT_POSITON + xOffset
if (xOffset <= 0) {
const TAB_WIDTH = 25
const TAB_HEIGHT = 60
let isInitialized = false
let animation = 'none'
let ORIGINAL_PARENT_POSITON
let xOffset = 0
thisObject.container = newContainer()
thisObject.container.name = MODULE_NAME
thisObject.container.initialize()
thisObject.container.isClickeable = true
thisObject.container.isDraggeable = false
return thisObject
function initialize() {
thisObject.container.frame.width = TAB_WIDTH
thisObject.container.frame.height = TAB_HEIGHT
ORIGINAL_PARENT_POSITON = thisObject.container.parentContainer.frame.position.x
thisObject.container.eventHandler.listenToEvent('onMouseClick', onMouseClick)
resize()
isInitialized = true
}
function resize() {
thisObject.container.frame.position.x = 0 + thisObject.container.parentContainer.frame.width
thisObject.container.frame.position.y = 69
setClosed()
thisObject.container.eventHandler.raiseEvent('closed')
}
}
}
function setOpened () {
animation = 'none'
xOffset = thisObject.container.parentContainer.frame.width
thisObject.container.parentContainer.frame.position.x = ORIGINAL_PARENT_POSITON + xOffset
thisObject.container.parentContainer.status = 'visible'
thisObject.pointerDirection = 'right'
}
function setClosed () {
animation = 'none'
xOffset = 0
thisObject.container.parentContainer.frame.position.x = ORIGINAL_PARENT_POSITON
thisObject.container.parentContainer.status = 'hidden'
thisObject.pointerDirection = 'left'
}
function arrow () {
let point1
let point2
let point3
if (thisObject.pointerDirection === 'left') {
point1 = {
x: TAB_WIDTH * 3.5 / 10,
y: TAB_HEIGHT * 12.5 / 30
}
point2 = {
x: TAB_WIDTH * 6.5 / 10,
y: TAB_HEIGHT * 15 / 30
}
point3 = {
x: TAB_WIDTH * 3.5 / 10,
y: TAB_HEIGHT * 17.5 / 30
}
} else {
point1 = {
x: TAB_WIDTH * 6.5 / 10,
y: TAB_HEIGHT * 12.5 / 30
}
point2 = {
x: TAB_WIDTH * 3.5 / 10,
y: TAB_HEIGHT * 15 / 30
}
point3 = {
x: TAB_WIDTH * 6.5 / 10,
y: TAB_HEIGHT * 17.5 / 30
}
}
point1 = thisObject.container.frame.frameThisPoint(point1)
point2 = thisObject.container.frame.frameThisPoint(point2)
point3 = thisObject.container.frame.frameThisPoint(point3)
browserCanvasContext.beginPath()
browserCanvasContext.moveTo(point1.x, point1.y)
browserCanvasContext.lineTo(point2.x, point2.y)
browserCanvasContext.lineTo(point3.x, point3.y)
browserCanvasContext.closePath()
let opacity = 1
browserCanvasContext.fillStyle = 'rgba(' + UI_COLOR.GREY + ', ' + opacity + ''
browserCanvasContext.fill()
}
function borders () {
let point1
let point2
let point3
let point4
point1 = {
x: 0,
y: 0
function onMouseClick(event) {
if (thisObject.pointerDirection === 'left') {
animation = 'opening'
thisObject.container.eventHandler.raiseEvent('opening')
} else {
animation = 'closing'
thisObject.container.eventHandler.raiseEvent('closing')
}
}
point2 = {
x: TAB_WIDTH,
y: 0
function getContainer(point) {
let container
if (thisObject.container.frame.isThisPointHere(point, true) === true) {
return thisObject.container
} else {
return undefined
}
}
point3 = {
x: TAB_WIDTH,
y: TAB_HEIGHT
function physics() {
if (isInitialized === false) { return }
animate()
}
point4 = {
x: 0,
y: TAB_HEIGHT
function draw() {
if (isInitialized === false) { return }
borders()
arrow()
}
point1 = thisObject.container.frame.frameThisPoint(point1)
point2 = thisObject.container.frame.frameThisPoint(point2)
point3 = thisObject.container.frame.frameThisPoint(point3)
point4 = thisObject.container.frame.frameThisPoint(point4)
function animate() {
const STEP = 50
let opacity
if (animation === 'opening') {
xOffset = xOffset + STEP
thisObject.container.parentContainer.frame.position.x = ORIGINAL_PARENT_POSITON + xOffset
if (xOffset >= thisObject.container.parentContainer.frame.width) {
setOpened()
thisObject.container.eventHandler.raiseEvent('opened')
}
}
/* Shadow */
for (let i = 0; i <= 5; i++) {
opacity = 1 - (i / 100) - 0.93
browserCanvasContext.beginPath()
browserCanvasContext.moveTo(point1.x + i, point1.y + i)
browserCanvasContext.lineTo(point2.x + i, point2.y + i)
browserCanvasContext.lineTo(point3.x + i, point3.y + i)
browserCanvasContext.lineTo(point4.x + i, point4.y + i)
browserCanvasContext.lineTo(point1.x + i, point1.y + i)
browserCanvasContext.closePath()
browserCanvasContext.strokeStyle = 'rgba(' + UI_COLOR.BLACK + ', ' + opacity + ''
browserCanvasContext.lineWidth = 1
browserCanvasContext.stroke()
if (animation === 'closing') {
xOffset = xOffset - STEP
thisObject.container.parentContainer.frame.position.x = ORIGINAL_PARENT_POSITON + xOffset
if (xOffset <= 0) {
setClosed()
thisObject.container.eventHandler.raiseEvent('closed')
}
}
}
/* Background and Border */
function setOpened() {
animation = 'none'
xOffset = thisObject.container.parentContainer.frame.width
thisObject.container.parentContainer.frame.position.x = ORIGINAL_PARENT_POSITON + xOffset
thisObject.container.parentContainer.status = 'visible'
thisObject.pointerDirection = 'right'
}
function setClosed() {
animation = 'none'
xOffset = 0
thisObject.container.parentContainer.frame.position.x = ORIGINAL_PARENT_POSITON
thisObject.container.parentContainer.status = 'hidden'
thisObject.pointerDirection = 'left'
}
browserCanvasContext.setLineDash([0, 0])
browserCanvasContext.beginPath()
browserCanvasContext.moveTo(point1.x, point1.y)
browserCanvasContext.lineTo(point2.x, point2.y)
browserCanvasContext.lineTo(point3.x, point3.y)
browserCanvasContext.lineTo(point4.x, point4.y)
browserCanvasContext.lineTo(point1.x, point1.y)
browserCanvasContext.closePath()
function arrow() {
let point1
let point2
let point3
opacity = 1
if (thisObject.pointerDirection === 'left') {
point1 = {
x: TAB_WIDTH * 3.5 / 10,
y: TAB_HEIGHT * 12.5 / 30
}
browserCanvasContext.fillStyle = 'rgba(' + UI_COLOR.WHITE + ', ' + opacity + ''
browserCanvasContext.fill()
point2 = {
x: TAB_WIDTH * 6.5 / 10,
y: TAB_HEIGHT * 15 / 30
}
browserCanvasContext.strokeStyle = 'rgba(' + UI_COLOR.GREY + ', ' + opacity + ''
browserCanvasContext.lineWidth = 0.3
browserCanvasContext.stroke()
}
point3 = {
x: TAB_WIDTH * 3.5 / 10,
y: TAB_HEIGHT * 17.5 / 30
}
} else {
point1 = {
x: TAB_WIDTH * 6.5 / 10,
y: TAB_HEIGHT * 12.5 / 30
}
point2 = {
x: TAB_WIDTH * 3.5 / 10,
y: TAB_HEIGHT * 15 / 30
}
point3 = {
x: TAB_WIDTH * 6.5 / 10,
y: TAB_HEIGHT * 17.5 / 30
}
}
point1 = thisObject.container.frame.frameThisPoint(point1)
point2 = thisObject.container.frame.frameThisPoint(point2)
point3 = thisObject.container.frame.frameThisPoint(point3)
browserCanvasContext.beginPath()
browserCanvasContext.moveTo(point1.x, point1.y)
browserCanvasContext.lineTo(point2.x, point2.y)
browserCanvasContext.lineTo(point3.x, point3.y)
browserCanvasContext.closePath()
let opacity = 1
browserCanvasContext.fillStyle = 'rgba(' + UI_COLOR.GREY + ', ' + opacity + ''
browserCanvasContext.fill()
}
function borders() {
let point1
let point2
let point3
let point4
point1 = {
x: 0,
y: 0
}
point2 = {
x: TAB_WIDTH,
y: 0
}
point3 = {
x: TAB_WIDTH,
y: TAB_HEIGHT
}
point4 = {
x: 0,
y: TAB_HEIGHT
}
point1 = thisObject.container.frame.frameThisPoint(point1)
point2 = thisObject.container.frame.frameThisPoint(point2)
point3 = thisObject.container.frame.frameThisPoint(point3)
point4 = thisObject.container.frame.frameThisPoint(point4)
let opacity
/* Shadow */
for (let i = 0; i <= 5; i++) {
opacity = 1 - (i / 100) - 0.93
browserCanvasContext.beginPath()
browserCanvasContext.moveTo(point1.x + i, point1.y + i)
browserCanvasContext.lineTo(point2.x + i, point2.y + i)
browserCanvasContext.lineTo(point3.x + i, point3.y + i)
browserCanvasContext.lineTo(point4.x + i, point4.y + i)
browserCanvasContext.lineTo(point1.x + i, point1.y + i)
browserCanvasContext.closePath()
browserCanvasContext.strokeStyle = 'rgba(' + UI_COLOR.BLACK + ', ' + opacity + ''
browserCanvasContext.lineWidth = 1
browserCanvasContext.stroke()
}
/* Background and Border */
browserCanvasContext.setLineDash([0, 0])
browserCanvasContext.beginPath()
browserCanvasContext.moveTo(point1.x, point1.y)
browserCanvasContext.lineTo(point2.x, point2.y)
browserCanvasContext.lineTo(point3.x, point3.y)
browserCanvasContext.lineTo(point4.x, point4.y)
browserCanvasContext.lineTo(point1.x, point1.y)
browserCanvasContext.closePath()
opacity = 1
browserCanvasContext.fillStyle = 'rgba(' + UI_COLOR.WHITE + ', ' + opacity + ''
browserCanvasContext.fill()
browserCanvasContext.strokeStyle = 'rgba(' + UI_COLOR.GREY + ', ' + opacity + ''
browserCanvasContext.lineWidth = 0.3
browserCanvasContext.stroke()
}
}