mirror of
https://github.com/coderaiser/cloudcmd.git
synced 2026-01-23 10:45:47 +00:00
feature(view) show: data, callback, newConfig -> data, options
This commit is contained in:
parent
b05ae68a03
commit
f4ffdffa82
5 changed files with 55 additions and 53 deletions
|
|
@ -83,8 +83,9 @@ var CloudCmd, Util, DOM;
|
|||
Events.addKey(key, input);
|
||||
}
|
||||
|
||||
CloudCmd.View.show(div, focus, {
|
||||
autoSize: true
|
||||
CloudCmd.View.show(div, {
|
||||
autoSize: true,
|
||||
afterShow: focus
|
||||
});
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -74,38 +74,40 @@ var CloudCmd, Util, DOM, CloudFunc, $;
|
|||
handler();
|
||||
}
|
||||
|
||||
CloudCmd.View.show(Element, function() {
|
||||
var console = jqconsole.$console,
|
||||
input = jqconsole.$input_source,
|
||||
|
||||
focus = function() {
|
||||
var x = window.scrollX,
|
||||
y = window.scrollY;
|
||||
CloudCmd.View.show(Element, {
|
||||
afterShow: function() {
|
||||
var console = jqconsole.$console,
|
||||
input = jqconsole.$input_source,
|
||||
|
||||
input.focus();
|
||||
window.scrollTo(x,y);
|
||||
};
|
||||
|
||||
focus();
|
||||
|
||||
if (!MouseBinded) {
|
||||
MouseBinded = true;
|
||||
|
||||
console.unbind('mouseup');
|
||||
console.mouseup(function() {
|
||||
var top,
|
||||
isSelection = '' + window.getSelection();
|
||||
|
||||
if (!isSelection) {
|
||||
top = console.scrollTop();
|
||||
focus = function() {
|
||||
var x = window.scrollX,
|
||||
y = window.scrollY;
|
||||
|
||||
focus();
|
||||
console.scrollTop(top);
|
||||
}
|
||||
});
|
||||
input.focus();
|
||||
window.scrollTo(x,y);
|
||||
};
|
||||
|
||||
focus();
|
||||
|
||||
if (!MouseBinded) {
|
||||
MouseBinded = true;
|
||||
|
||||
console.unbind('mouseup');
|
||||
console.mouseup(function() {
|
||||
var top,
|
||||
isSelection = '' + window.getSelection();
|
||||
|
||||
if (!isSelection) {
|
||||
top = console.scrollTop();
|
||||
|
||||
focus();
|
||||
console.scrollTop(top);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
Util.exec(callback);
|
||||
}
|
||||
|
||||
Util.exec(callback);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -89,8 +89,9 @@ var CloudCmd, Util, DOM, CloudFunc, ace, DiffProto, diff_match_patch, Zip;
|
|||
var UndoManager = ace.require('ace/undomanager').UndoManager;
|
||||
|
||||
Ace.setValue(Value);
|
||||
CloudCmd.View.show(Element, focus, {
|
||||
beforeClose: isChanged
|
||||
CloudCmd.View.show(Element, {
|
||||
beforeClose: isChanged,
|
||||
afterShow: focus
|
||||
});
|
||||
|
||||
Session.setUndoManager(new UndoManager());
|
||||
|
|
|
|||
|
|
@ -45,10 +45,6 @@ var CloudCmd, Util, DOM, CloudFunc, Terminal;
|
|||
CloudTerm.write = write;
|
||||
|
||||
function show(callback) {
|
||||
var options = {
|
||||
onUpdate: onResize,
|
||||
};
|
||||
|
||||
if (!Loading) {
|
||||
Images.showLoad({top:true});
|
||||
|
||||
|
|
@ -90,12 +86,10 @@ var CloudCmd, Util, DOM, CloudFunc, Terminal;
|
|||
Term.open(Element);
|
||||
}
|
||||
|
||||
CloudCmd.View.show(Element, function() {
|
||||
Element.focus();
|
||||
Terminal.brokenBold = true;
|
||||
|
||||
Util.exec(callback);
|
||||
}, options);
|
||||
CloudCmd.View.show(Element, {
|
||||
onUpdate : onResize,
|
||||
afterShow : afterShow.bind(null, callback)
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -165,6 +159,13 @@ var CloudCmd, Util, DOM, CloudFunc, Terminal;
|
|||
}
|
||||
}
|
||||
|
||||
function afterShow(callback) {
|
||||
Element.focus();
|
||||
Terminal.brokenBold = true;
|
||||
|
||||
Util.exec(callback);
|
||||
}
|
||||
|
||||
function load(callback) {
|
||||
var dir = CloudCmd.LIBDIRCLIENT + 'terminal/',
|
||||
path = dir + 'term.js';
|
||||
|
|
|
|||
|
|
@ -71,8 +71,8 @@ var CloudCmd, Util, DOM, CloudFunc, $;
|
|||
/**
|
||||
* function shows FancyBox
|
||||
*/
|
||||
function show(data, callback, newConfig) {
|
||||
var path, element, func,
|
||||
function show(data, options) {
|
||||
var path, element,
|
||||
config = {};
|
||||
|
||||
if (!Loading) {
|
||||
|
|
@ -80,24 +80,21 @@ var CloudCmd, Util, DOM, CloudFunc, $;
|
|||
|
||||
if (data) {
|
||||
element = $(Element).append(data);
|
||||
func = Util.retExec(callback);
|
||||
|
||||
Config.afterShow = func;
|
||||
|
||||
|
||||
Util.copyObj(config, Config);
|
||||
|
||||
if (newConfig)
|
||||
Object.keys(newConfig).forEach(function(name) {
|
||||
if (options)
|
||||
Object.keys(options).forEach(function(name) {
|
||||
var func,
|
||||
asyncCall = Util.asyncCall,
|
||||
item = newConfig[name],
|
||||
item = options[name],
|
||||
isFunc = Util.isFunction(item);
|
||||
|
||||
if (isFunc) {
|
||||
func = config[name];
|
||||
config[name] = Util.bind(asyncCall, [item, func]);
|
||||
} else {
|
||||
config[name] = newConfig[name];
|
||||
config[name] = options[name];
|
||||
}
|
||||
});
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue