diff --git a/.meteor/versions b/.meteor/versions index b08caf68d57..7c82ddbbbf9 100644 --- a/.meteor/versions +++ b/.meteor/versions @@ -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 diff --git a/client/lib/modal.coffee b/client/lib/modal.coffee index 86821a104ac..6493aebcc5d 100644 --- a/client/lib/modal.coffee +++ b/client/lib/modal.coffee @@ -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 diff --git a/client/lib/rocket.coffee b/client/lib/rocket.coffee index 1d8daf6f834..2ff6190ef8f 100644 --- a/client/lib/rocket.coffee +++ b/client/lib/rocket.coffee @@ -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 = $("
").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 = $("
").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 diff --git a/client/methods/sendMessage.coffee b/client/methods/sendMessage.coffee index 958ffaf1655..9b69d863761 100644 --- a/client/methods/sendMessage.coffee +++ b/client/methods/sendMessage.coffee @@ -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 diff --git a/packages/rocketchat-lib/package.js b/packages/rocketchat-lib/package.js index 08efe3a605d..d75f01631ff 100644 --- a/packages/rocketchat-lib/package.js +++ b/packages/rocketchat-lib/package.js @@ -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) {