Skip to content

Commit debe524

Browse files
committed
docs: update for new view/SidebarTabs.js and fix some docs layout issues
1 parent 9b60c01 commit debe524

File tree

12 files changed

+802
-498
lines changed

12 files changed

+802
-498
lines changed

docs/API-Reference/view/MainViewFactory.md

Lines changed: 56 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3,39 +3,80 @@
33
const MainViewFactory = brackets.getModule("view/MainViewFactory")
44
```
55

6-
<a name="_"></a>
6+
<a name="module_view/MainViewFactory"></a>
77

8-
## \_
9-
MainViewFactory is a singleton for managing view factories.Registering a view factory:```js registerViewFactory({ canOpenFile: function (fullPath) { return (fullPath.slice(-4) === ".ico"); }, openFile: function(file, pane) { return createIconView(file, pane); } });``` The openFile method is used to open the file and construct a view of it. Implementation should add the view to the pane```js function createIconView(file, pane) { // IconView will construct its DOM and append // it to pane.$el var view = new IconView(file, pane.$el); // Then tell the pane to add it to // its view map and show it pane.addView(view, true); return new $.Deferred().resolve().promise(); }``` Factories should only create 1 view of a file per pane. Brackets currently only supports 1 view of a file open at a given time but that may change to allow the same file open in more than 1 pane. Therefore Factories can do a simple check to see if a view already exists and show it before creating a new one:```js var view = pane.getViewForPath(file.fullPath); if (view) { pane.showView(view); } else { return createIconView(file, pane); }```
8+
## view/MainViewFactory
9+
MainViewFactory is a singleton for managing view factories.
1010

11-
**Kind**: global variable
12-
<a name="registerViewFactory"></a>
11+
Registering a view factory:
12+
```js
13+
registerViewFactory({
14+
canOpenFile: function (fullPath) {
15+
return (fullPath.slice(-4) === ".ico");
16+
},
17+
openFile: function(file, pane) {
18+
return createIconView(file, pane);
19+
}
20+
});
21+
```
22+
The openFile method is used to open the file and construct
23+
a view of it. Implementation should add the view to the pane
24+
```js
25+
function createIconView(file, pane) {
26+
// IconView will construct its DOM and append
27+
// it to pane.$el
28+
var view = new IconView(file, pane.$el);
29+
// Then tell the pane to add it to
30+
// its view map and show it
31+
pane.addView(view, true);
32+
return new $.Deferred().resolve().promise();
33+
}
34+
```
35+
Factories should only create 1 view of a file per pane. Brackets currently only supports 1 view of
36+
a file open at a given time but that may change to allow the same file open in more than 1 pane. Therefore
37+
Factories can do a simple check to see if a view already exists and show it before creating a new one:
38+
```js
39+
var view = pane.getViewForPath(file.fullPath);
40+
if (view) {
41+
pane.showView(view);
42+
} else {
43+
return createIconView(file, pane);
44+
}
45+
```
46+
47+
48+
* [view/MainViewFactory](#module_view/MainViewFactory)
49+
* [.registerViewFactory(factory)](#module_view/MainViewFactory..registerViewFactory)
50+
* [.findSuitableFactoryForPath(fullPath)](#module_view/MainViewFactory..findSuitableFactoryForPath) ⇒ <code>Factory</code>
51+
* [.Factory](#module_view/MainViewFactory..Factory) : <code>Object</code>
52+
53+
<a name="module_view/MainViewFactory..registerViewFactory"></a>
1354

14-
## registerViewFactory(factory)
55+
### view/MainViewFactory.registerViewFactory(factory)
1556
Registers a view factory
1657

17-
**Kind**: global function
58+
**Kind**: inner method of [<code>view/MainViewFactory</code>](#module_view/MainViewFactory)
1859

1960
| Param | Type | Description |
2061
| --- | --- | --- |
21-
| factory | [<code>Factory</code>](#Factory) | The view factory to register. |
62+
| factory | <code>Factory</code> | The view factory to register. |
2263

23-
<a name="findSuitableFactoryForPath"></a>
64+
<a name="module_view/MainViewFactory..findSuitableFactoryForPath"></a>
2465

25-
## findSuitableFactoryForPath(fullPath) ⇒ [<code>Factory</code>](#Factory)
66+
### view/MainViewFactory.findSuitableFactoryForPath(fullPath) ⇒ <code>Factory</code>
2667
Finds a factory that can open the specified file
2768

28-
**Kind**: global function
29-
**Returns**: [<code>Factory</code>](#Factory) - A factory that can create a view for the path or undefined if there isn't one.
69+
**Kind**: inner method of [<code>view/MainViewFactory</code>](#module_view/MainViewFactory)
70+
**Returns**: <code>Factory</code> - A factory that can create a view for the path or undefined if there isn't one.
3071

3172
| Param | Type | Description |
3273
| --- | --- | --- |
3374
| fullPath | <code>string</code> | The file to open. |
3475

35-
<a name="Factory"></a>
76+
<a name="module_view/MainViewFactory..Factory"></a>
3677

37-
## Factory : <code>Object</code>
38-
**Kind**: global typedef
78+
### view/MainViewFactory.Factory : <code>Object</code>
79+
**Kind**: inner typedef of [<code>view/MainViewFactory</code>](#module_view/MainViewFactory)
3980
**Properties**
4081

4182
| Name | Type | Description |

0 commit comments

Comments
 (0)