Skip to content

Commit

Permalink
Merge pull request RocketChat#1 from rcaferati/master
Browse files Browse the repository at this point in the history
Refactored and reorganised entire css/less files and logic.
  • Loading branch information
ManojaD2004 committed Feb 5, 2024
2 parents 10afba8 + 897f84f commit 393530e
Show file tree
Hide file tree
Showing 7 changed files with 613 additions and 751 deletions.
22 changes: 11 additions & 11 deletions client/lib/flexTab.coffee
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
@FlexTab = (->
check = ->
$flex = $("section.flex-tab")
if $flex.length
$search = $flex.find ".search-form"
if $search.length
$siblings = $search.siblings("a")
if $siblings.length
width = ($siblings.outerWidth() + $siblings.css("marginLeft").replace("px","") * 2) * $siblings.length + 1
$search.css
width: "calc(100% - #{width}px)"
check: check
check = ->
$flex = $("section.flex-tab")
if $flex.length
$search = $flex.find ".search-form"
if $search.length
$siblings = $search.siblings("a")
if $siblings.length
width = ($siblings.outerWidth() + $siblings.css("marginLeft").replace("px","") * 2) * $siblings.length + 1
$search.css
width: "calc(100% - #{width}px)"
check: check
)()
176 changes: 88 additions & 88 deletions client/lib/modal.coffee
Original file line number Diff line number Diff line change
@@ -1,102 +1,102 @@
@Modal = (->

self = {}
win = $(window)
self = {}
win = $(window)

#mistérios da vida c.483: Pq a self.$window diz ter 100% da janela via css mas na verdade ocupa menos de 100% da tela?
#isso impede que o retorno da janela ao normal quando não mais necessária a classe fluid. (comportamento dançante)
#mistérios da vida c.483: Pq a self.$window diz ter 100% da janela via css mas na verdade ocupa menos de 100% da tela?
#isso impede que o retorno da janela ao normal quando não mais necessária a classe fluid. (comportamento dançante)

focus = ->
if self.$modal
input = self.$modal.find "input[type='text']"
input.get(0).focus() if input.length
keydown = (e) ->
k = e.which
if k is 27
e.preventDefault()
e.stopImmediatePropagation()
close()
focus = ->
if self.$modal
input = self.$modal.find "input[type='text']"
input.get(0).focus() if input.length
keydown = (e) ->
k = e.which
if k is 27
e.preventDefault()
e.stopImmediatePropagation()
close()

check = ->
if self.$modal and self.$modal.length
if win.height() < self.$window.outerHeight() + (win.height() * 0.10)
unless self.$modal.hasClass("fluid")
self.$modal.addClass("fluid")
#else
#if self.$modal.hasClass("fluid")
#self.$modal.removeClass("fluid")
check = ->
if self.$modal and self.$modal.length
if win.height() < self.$window.outerHeight() + (win.height() * 0.10)
unless self.$modal.hasClass("fluid")
self.$modal.addClass("fluid")
#else
#if self.$modal.hasClass("fluid")
#self.$modal.removeClass("fluid")

open = (template, params) ->
params = params or {}
Rocket.animeBack self.$modal, ->
focus()
self.opened = 1
startListening() if params.listening
setContent template, params.data if template?
self.$modal.addClass "opened"
self.$modal.removeClass "fluid"
setTimeout ->
focus()
,200
open = (template, params) ->
params = params or {}
Rocket.animeBack self.$modal, ->
focus()
self.opened = 1
startListening() if params.listening
setContent template, params.data if template?
self.$modal.addClass "opened"
self.$modal.removeClass "fluid"
setTimeout ->
focus()
,200

close = ->
self.$modal.addClass "closed"
win.unbind("keydown.modal")
# acionar no on-complete da animação
setTimeout ->
self.opened = 0
stopListening()
self.$modal.removeClass "opened closed"
, 300
close = ->
self.$modal.addClass "closed"
win.unbind("keydown.modal")
# acionar no on-complete da animação
setTimeout ->
self.opened = 0
stopListening()
self.$modal.removeClass "opened closed"
, 300

setContent = (template, data) ->
self.$main.empty()
if template
if data
Blaze.renderWithData template, data, self.$main.get(0)
else
Blaze.render template, self.$main.get(0)
checkFooter()
check()
setContent = (template, data) ->
self.$main.empty()
if template
if data
Blaze.renderWithData template, data, self.$main.get(0)
else
Blaze.render template, self.$main.get(0)
checkFooter()
check()

checkFooter = ->
if self.$footer and self.$footer.length
buttons = self.$footer.find "button"
buttons.each ->
btn = $(@)
if btn.html().match /fechar/ig
btn.click (e) ->
e.preventDefault()
close()
checkFooter = ->
if self.$footer and self.$footer.length
buttons = self.$footer.find "button"
buttons.each ->
btn = $(@)
if btn.html().match /fechar/ig
btn.click (e) ->
e.preventDefault()
close()

startListening = ->
stopListening()
self.interval = setInterval ->
check()
, 100
startListening = ->
stopListening()
self.interval = setInterval ->
check()
, 100

stopListening = ->
clearInterval self.interval if self.interval
stopListening = ->
clearInterval self.interval if self.interval

init = ($modal, params) ->
self.params = params or {}
self.opened = 0
self.initialized = 0
self.$modal = if $modal.length then $modal else $(".kncty-modal")
if self.$modal.length
self.initialized = 0
self.$window = self.$modal.find ".-modal"
self.$main = self.$modal.find "main"
self.$close = self.$modal.find "header > .close"
self.$footer = self.$modal.find "footer"
self.$close.unbind("click").click close
win.unbind("resize.modal").bind "resize.modal", check
win.unbind("keydown.modal").bind "keydown.modal", (e) ->
keydown(e)
init = ($modal, params) ->
self.params = params or {}
self.opened = 0
self.initialized = 0
self.$modal = if $modal.length then $modal else $(".rocket-modal")
if self.$modal.length
self.initialized = 0
self.$window = self.$modal.find ".modal"
self.$main = self.$modal.find "main"
self.$close = self.$modal.find "header > .close"
self.$footer = self.$modal.find "footer"
self.$close.unbind("click").click close
win.unbind("resize.modal").bind "resize.modal", check
win.unbind("keydown.modal").bind "keydown.modal", (e) ->
keydown(e)

init: init
open: open
close: close
focus: focus
setContent: setContent
init: init
open: open
close: close
focus: focus
setContent: setContent
)()
Loading

0 comments on commit 393530e

Please sign in to comment.