Make @namespace RocketChat available on the client side too.

pull/161/head
Gabriel Engel 11 years ago
parent 053d01492b
commit 0146c2ea11
  1. 2
      .meteor/versions
  2. 2
      client/lib/modal.coffee
  3. 212
      client/lib/rocket.coffee
  4. 2
      client/methods/sendMessage.coffee
  5. 8
      packages/rocketchat-lib/package.js

@ -113,7 +113,7 @@ todda00:friendly-slugs@0.3.0
tracker@1.0.7
ui@1.0.6
underscore@1.0.3
underscorestring:underscore.string@3.0.3_1
underscorestring:underscore.string@3.1.1
url@1.0.4
webapp@1.2.0
webapp-hashing@1.0.3

@ -28,7 +28,7 @@
open = (template, params) ->
params = params or {}
Rocket.animeBack self.$modal, ->
RocketChat.animeBack self.$modal, ->
focus()
self.opened = 1
startListening() if params.listening

@ -1,120 +1,112 @@
@RocketChat = (->
RocketChat.Login = (->
onClick = (el) ->
$el = $(el)
if $el.length
$el.addClass "active"
$el.find("input").focus()
onBlur = (input) ->
$input = $(input)
if $input.length
if input.value == ""
$input.parents(".input-text").removeClass "active"
check = (form) ->
$form = $(form)
if $form.length
inputs = $form.find("input")
inputs.each ->
if @.value != ""
console.log @.value
$(@).parents(".input-text").addClass "active"
check: check
onClick: onClick
onBlur: onBlur
)()
RocketChat.Button = (->
time = undefined
loading = (el) ->
$el = $(el)
next = el.attr("data-loading-text")
html = el.find("span").html()
el.addClass("-progress").attr("data-def-text",html).find("span").html(next)
time = setTimeout ->
el.addClass("going")
, 1
done = (el) ->
$el = $(el)
el.addClass("done")
reset = (el) ->
clearTimeout(time) if time
$el = $(el)
html= $el.attr("data-def-text")
$el.find("span").html(html) if html
$el.removeClass("-progress going done")
done: done
loading: loading
reset: reset
)()
@Login = (->
onClick = (el) ->
$el = $(el)
if $el.length
$el.addClass "active"
$el.find("input").focus()
onBlur = (input) ->
$input = $(input)
if $input.length
if input.value == ""
$input.parents(".input-text").removeClass "active"
check = (form) ->
$form = $(form)
if $form.length
inputs = $form.find("input")
inputs.each ->
if @.value != ""
console.log @.value
$(@).parents(".input-text").addClass "active"
check: check
onClick: onClick
onBlur: onBlur
)()
RocketChat.animationSupport = ->
animeEnd =
WebkitAnimation: "webkitAnimationEnd"
OAnimation: "oAnimationEnd"
msAnimation: "MSAnimationEnd"
animation: "animationend"
@Button = (->
time = undefined
loading = (el) ->
$el = $(el)
next = el.attr("data-loading-text")
html = el.find("span").html()
el.addClass("-progress").attr("data-def-text",html).find("span").html(next)
time = setTimeout ->
el.addClass("going")
, 1
done = (el) ->
$el = $(el)
el.addClass("done")
reset = (el) ->
clearTimeout(time) if time
$el = $(el)
html= $el.attr("data-def-text")
$el.find("span").html(html) if html
$el.removeClass("-progress going done")
done: done
loading: loading
reset: reset
)()
transEndEventNames =
WebkitTransition: "webkitTransitionEnd"
MozTransition: "transitionend"
OTransition: "oTransitionEnd otransitionend"
msTransition: "MSTransitionEnd"
transition: "transitionend"
prefixB = transEndEventNames[Modernizr.prefixed("transition")]
prefixA = animeEnd[Modernizr.prefixed("animation")]
support = Modernizr.cssanimations
support: support
animation: prefixA
transition: prefixB
animationSupport = ->
animeEnd =
WebkitAnimation: "webkitAnimationEnd"
OAnimation: "oAnimationEnd"
msAnimation: "MSAnimationEnd"
animation: "animationend"
RocketChat.animeBack = (el, callback, type) ->
el = $(el)
if not el.length > 0
callback el if callback
return
s = animationSupport()
p = ((if type then s.animation else s.transition))
el.one p, (e) ->
transEndEventNames =
WebkitTransition: "webkitTransitionEnd"
MozTransition: "transitionend"
OTransition: "oTransitionEnd otransitionend"
msTransition: "MSTransitionEnd"
transition: "transitionend"
prefixB = transEndEventNames[Modernizr.prefixed("transition")]
prefixA = animeEnd[Modernizr.prefixed("animation")]
support = Modernizr.cssanimations
support: support
animation: prefixA
transition: prefixB
#el.off(p);
callback e
return
animeBack = (el, callback, type) ->
el = $(el)
if not el.length > 0
callback el if callback
return
s = animationSupport()
p = ((if type then s.animation else s.transition))
el.one p, (e) ->
return
#el.off(p);
callback e
return
RocketChat.preLoadImgs = (urls, callback) ->
L_ = (x) ->
if x.width > 0
$(x).addClass("loaded").removeClass "loading"
loaded = $(".loaded", preLoader)
if loaded.length is urls.length and not ended
ended = 1
imgs = preLoader.children()
callback imgs
preLoader.remove()
return
im = new Array()
preLoader = $("<div/>").attr(id: "perverter-preloader")
loaded = undefined
ended = undefined
i = 0
return
while i < urls.length
im[i] = new Image()
im[i].onload = ->
L_ this
return
preLoadImgs = (urls, callback) ->
L_ = (x) ->
if x.width > 0
$(x).addClass("loaded").removeClass "loading"
loaded = $(".loaded", preLoader)
if loaded.length is urls.length and not ended
ended = 1
imgs = preLoader.children()
callback imgs
preLoader.remove()
return
im = new Array()
preLoader = $("<div/>").attr(id: "perverter-preloader")
loaded = undefined
ended = undefined
i = 0
$(im[i]).appendTo(preLoader).addClass "loading"
im[i].src = urls[i]
L_ im[i] if im[i].width > 0
i++
while i < urls.length
im[i] = new Image()
im[i].onload = ->
L_ this
return
$(im[i]).appendTo(preLoader).addClass "loading"
im[i].src = urls[i]
L_ im[i] if im[i].width > 0
i++
return
preLoadImgs: preLoadImgs
animeBack: animeBack
Button: Button
Login: Login
)()
return

@ -3,6 +3,8 @@ Meteor.methods
Tracker.nonreactive ->
now = new Date(Date.now() + TimeSync.serverOffset())
msg = RocketChat.callbacks.run 'sendMessage', msg
ChatMessage.upsert { rid: msg.rid, t: 't' },
$set:
ts: now

@ -14,11 +14,11 @@ Package.onUse(function(api) {
'underscorestring:underscore.string'
]);
api.addFiles('lib/underscore.string.coffee', 'server');
api.addFiles('lib/core.coffee', 'server');
api.addFiles('lib/callbacks.coffee', 'server');
api.addFiles('lib/underscore.string.coffee', ['server', 'client']);
api.addFiles('lib/core.coffee', ['server', 'client']);
api.addFiles('lib/callbacks.coffee', ['server', 'client']);
api.export(['RocketChat'], ['server']);
api.export(['RocketChat'], ['server', 'client']);
});
Package.onTest(function(api) {

Loading…
Cancel
Save