From bf71013a37b81fec2f0b143c8f17a5e8fbe02d59 Mon Sep 17 00:00:00 2001 From: coderaiser Date: Thu, 5 Jun 2014 06:21:09 -0400 Subject: [PATCH] feature(view) {before,after}{show, close} exec: parallel -> series --- lib/client/view.js | 42 +++++++++++++++++++++++++++++++----------- 1 file changed, 31 insertions(+), 11 deletions(-) diff --git a/lib/client/view.js b/lib/client/view.js index 1f51cde8..cf2a35bd 100644 --- a/lib/client/view.js +++ b/lib/client/view.js @@ -6,23 +6,41 @@ var CloudCmd, Util, DOM, CloudFunc, $; CloudCmd.View = ViewProto; function ViewProto(CallBack) { - var Name = 'View', - Loading = false, - Events = DOM.Events, - Info = DOM.CurrentInfo, - Key = CloudCmd.Key, - Images = DOM.Images, - View = Util.exec.bind(Util), + var Name = 'View', + Loading = false, + FocusWas = false, + Events = DOM.Events, + Info = DOM.CurrentInfo, + Key = CloudCmd.Key, + Images = DOM.Images, + View = Util.exec.bind(Util), Element, TemplateAudio, Overlay, Config = { - beforeShow : function() { + beforeShow : function(callback) { Images.hide(); Key.unsetBind(); DOM.show(Overlay); + + Util.exec(callback); }, - beforeClose : function() { + beforeClose : function(callback) { Key.setBind(); DOM.hide(Overlay); + + Util.exec(callback); + }, + afterShow : function(callback) { + if (!FocusWas) { + FocusWas = true; + Element.focus(); + } + + Util.exec(callback); + }, + afterClose : function(callback) { + FocusWas = false; + + Util.exec(callback); }, fitToView : true, loop : false, @@ -91,13 +109,15 @@ var CloudCmd, Util, DOM, CloudFunc, $; Object.keys(options).forEach(function(name) { var func, isConfig = !!config[name], - execParallel = Util.exec.parallel, + series = Util.exec.series, item = options[name], isFunc = Util.isFunction(item); if (isFunc && isConfig) { func = config[name]; - config[name] = Util.exec.with(execParallel, [item, func]); + config[name] = function() { + series([func, item]); + }; } else { config[name] = options[name]; }