Skip to content

Commit abae830

Browse files
committed
0.1.13
1 parent 78b85bf commit abae830

File tree

8 files changed

+152
-48
lines changed

8 files changed

+152
-48
lines changed

build/build.sh

+1
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ cp ../src/dojo/json.js ../release/nodeMirror/src/dojo/
7474
cp ../src/dojo/on.js ../release/nodeMirror/src/dojo/
7575
cp ../src/dojo/sniff.js ../release/nodeMirror/src/dojo/
7676
cp ../src/dojo/when.js ../release/nodeMirror/src/dojo/
77+
cp ../src/dojo/topic.js ../release/nodeMirror/src/dojo/
7778

7879
mkdir ../release/nodeMirror/src/dojox
7980
mkdir ../release/nodeMirror/src/dojox/editor

build/server.profile.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ var profile = (function(){
9595
, "server/files"
9696
, "main/contentIO"
9797
, "sol/node/debug/Protocol"
98-
, "sol/node/fileWalker"
98+
, "sol/node/fileWalker"
9999
]
100100
}
101101
}

src/modules/Directory.js

+66-27
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@ define([
1313
, "main/clientOnly!dijit/form/Button"
1414
, "dojo/_base/lang"
1515
, "main/clientOnly!sol/wgt/Turn"
16+
, "main/clientOnly!dijit/Menu"
17+
, "main/clientOnly!dijit/MenuItem"
18+
, "main/clientOnly!dijit/form/ComboButton"
19+
, "dojo/topic"
1620
], function(
1721
declare
1822
, Base
@@ -28,6 +32,10 @@ define([
2832
, Button
2933
, lang
3034
, Turn
35+
, Menu
36+
, MenuItem
37+
, ComboButton
38+
, topic
3139
){
3240

3341

@@ -39,6 +47,7 @@ define([
3947
, downloadButton: true
4048
, "class": "directory"
4149
, viewMode: "list"
50+
, openDirButton: false
4251

4352
// the model decides if it is competent to handle that type
4453
/* par: {
@@ -151,8 +160,18 @@ define([
151160
, buildRendering: function(){
152161
var ret = this.inherited(arguments);
153162

163+
this.upDirButton = this.ownObj(new Button({
164+
label: "up"
165+
, showLabel: true
166+
, onClick: lang.hitch(this, "goUp")
167+
, region: "left"
168+
, disabled: (this.par.id && this.par.id.length) ? false : true
169+
}));
170+
this.menu.addChild(this.upDirButton, 0);
171+
172+
154173
this.newDirButton = this.ownObj(new Button({
155-
label: "new Directory"
174+
label: "new Folder"
156175
, showLabel: true
157176
, onClick: lang.hitch(this, "createNew", true)
158177
, region: "left"
@@ -167,43 +186,42 @@ define([
167186
}));
168187
this.menu.addChild(this.newButton);
169188

189+
170190
this.searchButton = this.ownObj(new Button({
191+
"class": "searchButton",
171192
label: "search"
172193
, showLabel: true
173194
, onClick: lang.hitch(this, "search")
174195
, region: "left"
175196
}));
176197
this.menu.addChild(this.searchButton);
177198

199+
178200
var self = this;
179-
require(["dijit/Menu", "dijit/MenuItem", "dijit/form/ComboButton", "dojo/domReady!"],
180-
function(Menu, MenuItem, ComboButton){
181-
var menu = new Menu({ style: "display: none;"});
182-
var menuItem1 = new MenuItem({
183-
label: "Details",
184-
onClick: function(){ self.set("viewMode", "details"); }
185-
});
186-
menu.addChild(menuItem1);
187-
188-
var menuItem2 = new MenuItem({
189-
label: "List",
190-
onClick: function(){ self.set("viewMode", "list"); }
191-
});
192-
menu.addChild(menuItem2);
193-
194-
self.viewButton = new ComboButton({
195-
label: "Details",
196-
dropDown: menu,
197-
viewMode: "details",
198-
onClick: function(){
199-
self.set("viewMode", this.viewMode);
200-
}
201-
});
202-
self.menu.addChild(self.viewButton);
203-
204-
201+
var menu = new Menu({ style: "display: none;"});
202+
var menuItem1 = new MenuItem({
203+
label: "Details",
204+
onClick: function(){ self.set("viewMode", "details"); }
205205
});
206+
menu.addChild(menuItem1);
206207

208+
var menuItem2 = new MenuItem({
209+
label: "List",
210+
onClick: function(){ self.set("viewMode", "list"); }
211+
});
212+
menu.addChild(menuItem2);
213+
214+
self.viewButton = new ComboButton({
215+
"class": "viewButton",
216+
label: "Details",
217+
dropDown: menu,
218+
viewMode: "details",
219+
onClick: function(){
220+
self.set("viewMode", this.viewMode);
221+
}
222+
});
223+
self.menu.addChild(self.viewButton);
224+
207225

208226
this.grid = this.ownObj(new Grid({
209227
content: this.content
@@ -221,6 +239,27 @@ define([
221239
return ret;
222240
}
223241

242+
, goUp: function(){
243+
244+
var idStr = "";
245+
var s = this.par.id.split("/");
246+
for (i = 0; i < s.length - 1; ++i){
247+
if (i){
248+
idStr += "/";
249+
};
250+
idStr += s[i];
251+
};
252+
253+
topic.publish("client/openid", {
254+
item: {
255+
id: idStr
256+
, type: "file"
257+
}
258+
, insteadOf: this
259+
});
260+
261+
}
262+
224263
, _setViewModeAttr: function(viewMode){
225264
if (this.viewMode == viewMode){
226265
return;

src/modules/base/WidgetMixin.js

+22
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ define([
1616
, "main/config"
1717
, "dojo/io-query"
1818
, "modules/contentTabs/tabMixin"
19+
, "dojo/topic"
1920
], function(
2021
declare
2122
, domConstruct
@@ -31,6 +32,7 @@ define([
3132
, config
3233
, ioQuery
3334
, tabMixin
35+
, topic
3436
){
3537
return declare([
3638
tabMixin
@@ -41,6 +43,7 @@ define([
4143
, showMenu: true
4244
, idLine: true
4345
, closable: true
46+
, openDirButton: true
4447

4548
, constructor: function(){
4649
this.dirty = false;
@@ -127,6 +130,14 @@ define([
127130
menu.addChild(menu._buttons.downLoadButton);
128131
};
129132

133+
if (this.openDirButton){
134+
menu._buttons.openDirButton = this.ownObj(new Button({
135+
onClick: lang.hitch(this, "openDir")
136+
, label: "open Folder"
137+
}));
138+
menu.addChild(menu._buttons.openDirButton);
139+
};
140+
130141
if (this.textModeButton){
131142
menu._buttons.textmodebutton = this.ownObj(new Button({
132143
onClick: lang.hitch(this, "textmode")
@@ -265,6 +276,17 @@ define([
265276
});*/
266277
});
267278
}
279+
, openDir: function(){
280+
var dirName = fileName.dir(this.par.id);
281+
dirName = dirName.substr(0, dirName.length - 1);
282+
283+
topic.publish("client/openid", {
284+
item: {
285+
id: dirName
286+
, type: "file"
287+
}
288+
});
289+
}
268290

269291
});
270292
});

src/modules/contentTabs/TabController.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ define([
7777
if (this.anim){
7878
this.anim.stop();
7979
};
80-
console.log("cancel");
80+
//console.log("cancel");
8181
this.doAnimation.cancel();
8282
domStyle.set(this.fadeNode, {
8383
opacity: 0

src/modules/directory/NewDlg.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ define([
4949
, postMixInProperties: function(){
5050
this.inherited(arguments);
5151
if (this.newDir){
52-
this.title = "create new Directory";
52+
this.title = "create new Folder";
5353
};
5454
}
5555
});

src/modules/files/Tree.js

+42-6
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ define([
1010
, "dojo/dom-class"
1111
, "dojo/dom-construct"
1212
, "./OverflowWgt"
13+
, "dojo/_base/fx"
1314
], function(
1415
declare
1516
, Tree
@@ -22,6 +23,7 @@ define([
2223
, domClass
2324
, domConstruct
2425
, OverflowWgt
26+
, fx
2527
){
2628

2729

@@ -115,7 +117,7 @@ define([
115117

116118
, scrollToTop: function(){
117119
var box = domGeo.getMarginBox(this.domNode);
118-
this.tree.domNode.scrollTop = box.t - this.getIndentAddition();
120+
this.tree.scrollTo(box.t - this.getIndentAddition());
119121
}
120122

121123
, expand: function(){
@@ -147,16 +149,31 @@ define([
147149
};
148150
};
149151
this._onScroll = on(this.tree.domNode, "scroll", checkFun);
150-
res.then(checkFun);
152+
this.tree._lastExpand = this;
153+
res.then(function(){
154+
checkFun();
155+
if (self.tree._lastExpand === self){
156+
var box1 = domGeo.getMarginBox(self.domNode);
157+
if (box1.t + box1.h > self.tree.domNode.scrollTop + self.tree.domNode.clientHeight){
158+
var indent = self.getIndentAddition();
159+
if (indent + box1.h > self.tree.domNode.clientHeight){
160+
self.scrollToTop();
161+
}else{
162+
self.tree.scrollTo(box1.t + box1.h - self.tree.domNode.clientHeight);
163+
};
164+
};
165+
};
166+
});
151167
return res;
152168
}
153169
, collapse: function(){
154170
var res = this.inherited(arguments);
155171
if (this._floatStyleAdded){
156172
var self = this;
157-
res.then(function(){
173+
self.scrollToTop();
174+
/*res.then(function(){
158175
self.scrollToTop();
159-
});
176+
});*/
160177
};
161178
this._removeFloat();
162179
return res;
@@ -188,10 +205,23 @@ define([
188205
};
189206
}
190207

208+
, scrollTo: function(parScrollTop){
209+
var self = this;
210+
if (this._scrollAnimation){
211+
this._scrollAnimation.stop();
212+
};
213+
this._scrollAnimation = new fx.Animation({
214+
curve: [this.domNode.scrollTop, parScrollTop]
215+
, onAnimate: function(value){
216+
self.domNode.scrollTop = value;
217+
}
218+
});
219+
this._scrollAnimation.play();
220+
}
221+
191222
, _onClick: function(/*TreeNode*/ nodeWidget, /*Event*/ e){
192223
if (e.target && domClass.contains(e.target, "treeOpenMore")){
193-
//var box = domGeo.getMarginBox(nodeWidget.domNode);
194-
nodeWidget.scrollToTop();//tree.domNode.scrollTop = box.t - nodeWidget.getIndentAddition();
224+
nodeWidget.scrollToTop();
195225
e.stopPropagation();
196226
e.preventDefault();
197227
return;
@@ -233,6 +263,12 @@ define([
233263
// the children too.
234264
return new TreeNode(args);
235265
}
266+
, destroy: function(){
267+
if (this._scrollAnimation){
268+
this._scrollAnimation.stop();
269+
};
270+
this.inherited(arguments);
271+
}
236272

237273
});
238274
});

src/modules/terminal/TerminalWgt.js

+18-12
Original file line numberDiff line numberDiff line change
@@ -29,15 +29,23 @@ define([
2929
return charBox;
3030
};
3131
var tryWgt = new Try({});
32+
var textStr = "";
33+
for (var i = 0; i < 1000; ++i){
34+
textStr += ".";
35+
};
3236
var text = new Text({
33-
text: "."
37+
text: textStr
3438
});
3539

3640
tryWgt.placeAt(document.body);
37-
charBox = tryWgt.getMarginBox({
41+
var box = tryWgt.getMarginBox({
3842
node: text.domNode
3943
, "class": "terminal"
4044
});
45+
charBox = {
46+
w: box.w / 1000
47+
, h: box.h
48+
};
4149

4250
text.destroy();
4351
tryWgt.destroy();
@@ -62,15 +70,6 @@ define([
6270
screenKeys: true
6371
});
6472

65-
66-
/*term.on('data', function(data) {
67-
socket.emit('data', data);
68-
});
69-
70-
term.on('title', function(title) {
71-
document.title = title;
72-
});*/
73-
7473
this.terminal.open(this.domNode);
7574

7675
/*this.mouseWgt = this.ownObj(new MouseWgt({
@@ -125,8 +124,15 @@ define([
125124
};
126125
}
127126
, resize: function(){
127+
var box = {
128+
w: this._contentBox && this._contentBox.w
129+
, h: this._contentBox && this._contentBox.h
130+
};
128131
this.inherited(arguments);
129-
//this.emitResize();
132+
if (this._contentBox.w == box.w && this._contentBox.h == box.h && this._resizeEmited){
133+
return;
134+
};
135+
this._resizeEmited = true;
130136
this.sceduleEmitResize.exec();
131137
}
132138
});

0 commit comments

Comments
 (0)