I am looking for some help as I don't know how bad those lines of codes are.
I am trying to adapt this original Codepen.io work (http://codepen.io/ettrics/pen/Jdjdzp/ , by Ettrics) for one of my teaching project. I run my web page on a Express4+Stylus+Coffescript Node's server.
The CoffeeScript file:
# Each popup takes the entire window, so it is a modal
Modal = ->
# Make it easier for yourself by not having to type as much to select an element (QuerySelectorAll)
$qsa = (el) ->
document.querySelectorAll(el)
trigger = $qsa('.modal__trigger') # What you click to activate the modal
modals = $qsa('.modal') # The entire modal (takes up entire window)
modalsbg = $qsa('.modal__bg') # The entire modal (takes up entire window)
content = $qsa('.modal__content') # The inner content of the modal
closers = $qsa('.modal__close') # An element used to close the modal
isOpen = false
contentDelay = 100 # Duration after you click the button and wait for the content to show
len = trigger.length
getId = (event) ->
event.preventDefault()
# Get the value of the data-modal attribute from the button
modalId = this.dataset.modal
# Remove the '#' from the string
len = modalId.length
modalId = modalId.substring(1, len)
# Select the modal we want to activate
modal = document.getElementById(modalId)
# Execute function that creates the temporary expanding div named fakeDiv
makefakeDiv(this, modal)
makefakeDiv = (self, modal) ->
fakeDiv = document.getElementById('modal__temp');
# If there isn't a 'fakeDiv', create one and append it to the button that was
# clicked. after that execute the function 'moveTrigger' which handles the animations.
if fakeDiv?
fakeDiv = document.createElement('div')
fakeDiv.id = 'modal__temp'
self.appendChild(fakeDiv)
moveTrigger(self, modal, fakeDiv)
moveTrigger = (trigger, modal, div) ->
triggerProps = trigger.getBoundingClientRect()
modalProps = modal.querySelector('.modal__content').getBoundingClientRect()
xc = window.innerWidth / 2
yc = window.innerHeight / 2
######## VOIR LE CSS !!
# This class increases z-index value so the button goes overtop the other buttons
trigger.classList.add('modal__trigger--active')
# These values are used for scale the fakeDiv div to the same size as the modal
scaleX = modalProps.width / triggerProps.width
scaleY = modalProps.height / triggerProps.height
scaleX = scaleX.toFixed(3) # Round to 3 decimal places
scaleY = scaleY.toFixed(3)
# These values are used to move the button to the center of the window (to pepare the ease out effect)
transX = Math.round(xc - triggerProps.left - triggerProps.width / 2)
transY = Math.round(yc - triggerProps.top - triggerProps.height / 2)
# If the modal is aligned to the top then move the button to the center-y of the modal instead of the window
if modal.classList.contains('modal--align-top')
transY = Math.round(modalProps.height / 2 + modalProps.top - triggerProps.top - triggerProps.height / 2)
# Translate button to center of screen
trigger.style.transform = 'translate(' + transX + 'px, ' + transY + 'px)'
trigger.style.webkitTransform = 'translate(' + transX + 'px, ' + transY + 'px)'
# Expand fakeDiv to the same size as the modal
div.style.transform = 'scale(' + scaleX + ',' + scaleY + ')';
div.style.webkitTransform = 'scale(' + scaleX + ',' + scaleY + ')'
# Smart animation API used to open
window.setTimeout( ->
window.requestAnimationFrame(open(modal, div))
, contentDelay)
open = (modal, div) ->
if !isOpen
# Select the content inside the modal
content = modal.querySelector('.modal__content')
# Reveal the modal
modal.classList.add('modal--active')
# Reveal the modal content
content.classList.add('modal__content--active')
###
# When the modal content is finished transitioning, fadeout expanding
# fakeDiv so when the window resizes it isn't visible ( it doesn't
# move with the window).
###
content.addEventListener('transitionend', hidefakeDiv, false)
isOpen = true
hidefakeDiv = ->
# Fadeout fakeDiv so that it can't be seen when the window is resized
div.style.opacity = '0'
content.removeEventListener('transitionend', hidefakeDiv, false)
close = (event) ->
event.preventDefault()
event.stopImmediatePropagation()
target = event.target
div = document.getElementById('modal__temp')
###
# Make sure the modal__bg or modal__close was clicked, we don't
# want to be able to click inside the modal and have it close.
###
if isOpen and target.classList.contains('modal__bg') or target.classList.contains('modal__close')
# Make the hidden div visible again and remove the transforms so it scales back to its original size
div.style.opacity = '1'
div.removeAttribute('style')
###
# Iterate through the modals, modal contents and triggers to remove their active classes.
# Remove the inline css from the trigger to move it back into its original position.
###
for i in [0..len]
modals[i].classList.remove('modal--active')
content[i].classList.remove('modal__content--active')
trigger[i].style.transform = 'none'
trigger[i].style.webkitTransform = 'none'
trigger[i].classList.remove('modal__trigger--active')
# When fakeDiv opacity is 1 again, we want to remove it from the dom
div.addEventListener('transitionend', removeDiv, false)
isOpen = false
removeDiv = ->
setTimeout( ->
window.requestAnimationFrame(div.remove())
, contentDelay - 50)
bindActions = ->
for i in [0..len]
trigger[i].addEventListener('click', getId, false)
closers[i].addEventListener('click', close, false)
modalsbg[i].addEventListener('click', close, false)
init = ->
bindActions()
{init: init}
window.onload = Modal.init
This coffeescript file is called in jade by
script(src='javascripts/coffee-script.js')
script(src='javascripts/modal.coffee', type='text/coffeescript')
I could not use the CoffeeScript compiler logs because the of the 'window.onload = Modal.init' which returned a "window is not defined" error. But browser console returns no error, Codepen neither.
I have to confess that I began to learn these 4 languages 3 days ago. So I basically don't know anything about anything... I don't even know if my app settings are right.
Can anyone give me a hand on this?
Thanks a lot! :)
Related
Using NeutralinoJS, how can start the app right in the center of the screen?
It should look like the splashscreen of any app. Unlike ElectronJS, Neutralino's window options doesn't seem to have a center() method.
I made a simple javascript function by using native API of neutralionJS. Used Neutralino.computer.getDisplays() to height & width of the screen along with Neutralino.window.getSize() to height & width of the window and Neutralino.window.move(x,y) to center it. Note: x,y is the coordinates of the top right corner of the window. For a better explaination I have also attested a img demostrating it.
async function centerWindow(){
let display = await Neutralino.computer.getDisplays();
const displayHeight = display[0].resolution.height;
const displayWidth = display[0].resolution.width;
let window = await Neutralino.window.getSize();
const windowHeight = window.height;
const windowWidth = window.width;
const x = (displayWidth - windowWidth) / 2;
const y = (displayHeight - windowHeight) / 2;
Neutralino.window.move(x,y);
}
centerWindow();
Image link
The black dot is actual center of screen, red dot is where Neutralino.window.move(x,y) takes you too.
Following along a great tutorial, code is replicated yet does not function as shown. No new texture appears to be created when I try to drag the texture button. Only difference is the tutorial uses a TextureRect, while I'm using a TextureButton.
extends TextureButton
func get_drag_data(position: Vector2):
var vControl = Control.new()
var vData = {}
var vTexture = TextureRect.new()
vTexture.expand = true
vTexture.texture = texture_disabled
vTexture.rect_size = Vector2(320, 400)
vControl.add_child(vTexture)
vTexture.rect_position = -0.5 * vTexture.rect_size
set_drag_preview(vTexture)
return vData
Code above is attached to Party_1. texture_disabled does have a texture set.
It would work if you had the code in get_drag_data looking like this:
func get_drag_data(_position: Vector2):
var vTexture = TextureRect.new()
vTexture.expand = true
vTexture.texture = texture_disabled
vTexture.rect_size = Vector2(320, 400)
set_drag_preview(vTexture)
return {}
However, that would place the TextureRect top-left corner at the cursor position.
You want to offset the position of the TextureRect so it is centered at the cursor position. To do that, you create another Control, add the TextureRect as a child to it… And pass the TextureRect anyway? No, that does not work, you need to pass the new Control:
func get_drag_data(_position: Vector2):
var vTexture = TextureRect.new()
vTexture.expand = true
vTexture.texture = texture_disabled
vTexture.rect_size = Vector2(320, 400)
var vControl = Control.new()
vControl.add_child(vTexture)
vTexture.rect_position = -0.5 * vTexture.rect_size
set_drag_preview(vControl)
return {}
Please notice I'm giving vControl to set_drag_preview, not vTexture.
You cannot give to set_drag_preview a Control that has a parent. In fact, if you tried you would get an error in the Output console saying:
_gui_set_drag_preview: Condition "p_control->get_parent() != nullptr" is true.
Or
_gui_set_drag_preview: Condition "p_control->is_inside_tree()" is true.
I want to force Terminator to open at the top-left of my screen. When I saved the layout I had the window positioned correctly. However, whenever I open Terminator upon computer restart, the window is positioned near the top and about 1.5 inches from the left.
I've been messing around with the config file, but cannot figure out the 'position' paramters. For example, under [[[child0]]] :
position = 36:32
and under [[[child1]]] :
position = 834
Can anyone explain how to customize these parameters?
System info:
Ubuntu 17.10, kernel 4.13.0-43
screen dimensions: 1920x1080 pixels, or 508x286 mm
Terminator v 1.91
terminator/config :
[global_config]
always_split_with_profile = True
suppress_multiple_term_dialog = True
title_transmit_bg_color = "#8ae234"
[keybindings]
[layouts]
[[default]]
[[[child0]]]
fullscreen = False
last_active_term = a69b1a79-eb9d-4c15-ac27-0502efc4c4f7
last_active_window = True
maximised = False
order = 0
parent = ""
position = 36:32
size = 808, 1014
title = bp#bpenner: ~
type = Window
[[[child1]]]
order = 0
parent = child0
position = 834
ratio = 0.826560951437
type = VPaned
[[[terminal2]]]
order = 0
parent = child1
profile = BP
type = Terminal
uuid = a69b1a79-eb9d-4c15-ac27-0502efc4c4f7
[[[terminal3]]]
order = 1
parent = child1
profile = BP
type = Terminal
uuid = 454d7873-3e55-49a4-af8c-6456f99d5e1e
[plugins]
[profiles]
[[default]]
cursor_color = "#aaaaaa"
There are a couple of things to try.
The following worked for me:
Open Terminator, then adjust its window's size and position as desired.
In the Terminator window, in the command-line area, right-click then choose Preferences.
In the Layouts tab, expand the Type / Name list, select Terminal1, then click Save.
Exit the Preferences dialog, then close and re-open Terminator.
Another approach that one can use to configure the display properties of many applications is to add the --geometry= parameter to the application's command line.
In a shell command line, type man x to display the man page for the X window system.
Scroll down to GEOMETRY SPECIFICATIONS.
I believe that your config file is missing the first [[[window0]]] entry, which comes before the [[[child]]] entries on my default settings.
Here are my config settings in which the first window starts with the upper left corner at position y=100 and x=100 pixels and it's size is 1000 X 700 pixels.
(notice the different format required to make these entries)
[global_config]
[keybindings]
[profiles]
[[default]]
audible_bell = True
cursor_color = "#aaaaaa"
[layouts]
[[default]]
[[[window0]]]
type = Window
parent = ""
size = 1000 , 700
position = 100:100
[[[child1]]]
type = Terminal
parent = window0
[plugins]
Hope it helps.
This worked for me to set terminator windows on the top left corner on 4k display (ubuntu 22.04):
Edit config file nano ~/.config/terminator/config
Under [[[window0]]] add size and position:
[[[window0]]]
type = Window
size = 1920, 1080
position = 0:0
parent = ""
I have an issue regarding a kendo dialog window including an upload.
When I upload multiple elements the list gets longer and longer and at some point gets bigger than my browserwindow and runs out of bounds at the bottom of the screen.
The insert button then is below the bottom bound of the browser but the browser doesn't allow me to scroll (firefox + chrome).
How can I limit my window to the browser screen and not exceed it?
#(Html.Kendo().Dialog()
.Name("ImageBrowser")
.Content( Html.Partial("ImageBrowserContent").ToString())
.MinWidth(400)
.MinHeight(800)
.MaxHeight(1000)
.MaxWidth(800)
.Modal(true)
.Visible(false)
)
#(Html.Kendo().Upload()
.Name("imageUpload")
.Messages(mess => mess.Select("Upload"))
.Async(a => a
.Save("Upload", "Image")
.Remove("RemoveUpload", "Image")
.AutoUpload(true)
)
)
I have provided a dojo here for you which hopefully is what you are after.
https://dojo.telerik.com/eqaZibIL
It uses the javascript version but you can just apply the function I have created to the dialog initial event. like so:
#Html.Kendo().Dialog().Events(e => e.InitOpen("dialog_resize"))
(This is some code I have modified for handling kendoWindow's so could be optimized more I think)
function dialog_resize() {
//THIS GETS THE POPUP DIALOG
var popUpDialog = $('#dialog').data("kendoDialog");
//THIS GETS THE CONTENT AREA FOR THE ENTIRE DIALOG
var contentArea = $(".k-widget.k-window.k-dialog");
//THIS GETS THE ACTUAL CONTENT AREA OF THE DIALOG IE.WHAT YOU WANT DISPLAYED
var innerForm = $("#dialog");
var windowHeight = $(window).innerHeight();
var windowWidth = $(window).innerWidth();
//CALCULATE THE WIDTH OF THE DIALOG AND SET IT TO 80%
//OF SCREEN REALESTATE TO STRECH OUT.
//NOT REQUIRED IF YOU ARE SETTING THE WIDTH MANUALLY.
contentArea.width(windowWidth * 0.8)
//CENTER THE DIALOG ON THE SCREEN.
popUpDialog.center();
//GET 97% OF THE AVAILABLE DIALOG CONTENT AREA TO SHOW Y-SCROLL BAR
var fixedHeight = (contentArea.height() * 0.97);
var fixedWidth = contentArea.width() * 0.965;
//SET THE HEIGHT, WIDTH AND SCROLL BAR OF THE CONTENT AREA
//SHOWING BLUE BORDER TO SHOW THE ITEM IS POSITIONING CORRECTLY IN DIALOG
innerForm.height(fixedHeight).width(fixedWidth).css({
maxHeight: fixedHeight + 'px !important',
maxWidth: fixedWidth + 'px !important',
overflowY: 'scroll',
overflowX: 'hidden',
border: '1px solid blue'
});
}
Hopefully you can follow what is going off here.
As long as you have set the maxHeight for the dialog on initialization all this seems to work correctly. I have applied a blue border to the content area just for demo purposes so you can see it in action.
I am having trouble with my view controllers in iOS 7. I'm trying to figure out the best way to adjust my view's layout under the nav bar and status bar while maintaining the transparency/blur of the nav bar. So for example, if I have a view controller with:
def viewDidLoad
#scroll = UIScrollView.alloc.initWithFrame(new_frame)
#scroll.bounces = true
#scroll.delegate = self
#scroll.alwaysBounceVertical = true
#scroll.scrollsToTop = true
#scroll.contentSize = CGSizeMake(UIScreen.mainScreen.bounds.size.width, scroll_frame.size.height)
self.view.addSubview(#scroll)
end
My content appears under the nav bar, which I get given the iOS 7 transition guide. To correct that, if I add the following inside of viewDidLoad:
self.edgesForExtendedLayout = UIRectEdgeNone
The layout is adjusted but the navbar no longer has transparency or blur because the view doesn't extend behind it.
If I don't adjust scrollView insets instead of setting edges for layout:
self.automaticallyAdjustsScrollViewInsets = false
Then change my scroll frame to:
def viewDidLoad
nav_bar_height = self.navigationController.navigationBar.frame.size.height
status_height = UIApplication.sharedApplication.statusBarFrame.size.height
height = nav_bar_height + status_height
scroll_frame = self.view.bounds
new_frame = CGRect.new([0, height], [scroll_frame.size.width, scroll_frame.size.height])
#scroll = UIScrollView.alloc.initWithFrame(new_frame)
#scroll.bounces = true
#scroll.delegate = self
#scroll.alwaysBounceVertical = true
#scroll.scrollsToTop = true
#scroll.contentSize = CGSizeMake(UIScreen.mainScreen.bounds.size.width, scroll_frame.size.height)
self.view.addSubview(#scroll)
end
I no longer get the transparent/blur of the nav bar. Only when I adjust the scroll's frame - at the x origin - with a new height does this seem to happen. So I'm wondering why that is and how I can best adjust my scroll without losing the blur/transparency.
Maybe you can try with inset
[scroll setContentInset:UIEdgeInsetsMake(nav_bar_height + status_height, 0.0, 0.0, 0.0)];
[scroll setScrollIndicatorInsets:UIEdgeInsetsMake(nav_bar_height + status_height,0.0,0.0,0.0)];
Hope that help