bone_tree 0.5.6 → 0.9.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (57) hide show
  1. data/.gitignore +26 -3
  2. data/Gemfile +5 -12
  3. data/Rakefile +7 -9
  4. data/bone_tree.gemspec +30 -14
  5. data/config.rb +8 -0
  6. data/lib/assets/javascripts/bone_tree.js +277 -981
  7. data/lib/assets/stylesheets/bone_tree.css +108 -0
  8. data/lib/bone_tree/rails.rb +5 -0
  9. data/lib/bone_tree/sprockets.rb +3 -0
  10. data/lib/{version.rb → bone_tree/version.rb} +1 -1
  11. data/lib/bone_tree.rb +11 -6
  12. data/source/index.html.haml +10 -382
  13. data/source/javascripts/{_backbone.js → backbone.js} +282 -142
  14. data/source/javascripts/bone_tree/models/directory.js.coffee +109 -0
  15. data/source/javascripts/bone_tree/models/file.js.coffee +12 -0
  16. data/source/javascripts/bone_tree/models/node.js.coffee +24 -0
  17. data/source/javascripts/bone_tree/models/settings.js.coffee +5 -0
  18. data/source/javascripts/bone_tree/{_namespace.js.coffee → namespace.js.coffee} +1 -1
  19. data/source/javascripts/bone_tree/views/directory.js.coffee +56 -0
  20. data/source/javascripts/bone_tree/views/file.js.coffee +25 -0
  21. data/source/javascripts/bone_tree/views/tree.js.coffee +87 -0
  22. data/source/javascripts/bone_tree.js.coffee +2 -1
  23. data/source/stylesheets/bone_tree.css.sass +0 -38
  24. data/spec/javascripts/directory_spec.coffee +26 -0
  25. data/spec/javascripts/helpers/spec_helper.coffee +3 -4
  26. data/spec/javascripts/sorting_spec.coffee +12 -0
  27. data/spec/javascripts/support/jasmine.yml +6 -4
  28. metadata +143 -36
  29. data/Gemfile.lock +0 -190
  30. data/docs/index.html +0 -222
  31. data/docs/resources/base.css +0 -70
  32. data/docs/resources/index.css +0 -20
  33. data/docs/resources/module.css +0 -24
  34. data/docs/source/javascripts/bone_tree/_namespace.js.html +0 -45
  35. data/docs/source/javascripts/bone_tree/models/_directory.js.html +0 -126
  36. data/docs/source/javascripts/bone_tree/models/_file.js.html +0 -112
  37. data/docs/source/javascripts/bone_tree/models/_nodes.js.html +0 -174
  38. data/docs/source/javascripts/bone_tree/models/_settings.js.html +0 -75
  39. data/docs/source/javascripts/bone_tree/views/_directory.js.html +0 -94
  40. data/docs/source/javascripts/bone_tree/views/_file.js.html +0 -82
  41. data/docs/source/javascripts/bone_tree/views/_menu.js.html +0 -110
  42. data/docs/source/javascripts/bone_tree/views/_tree.js.html +0 -432
  43. data/source/javascripts/_jquery.min.js +0 -5
  44. data/source/javascripts/_underscore.js +0 -999
  45. data/source/javascripts/bone_tree/models/_directory.js.coffee +0 -63
  46. data/source/javascripts/bone_tree/models/_file.js.coffee +0 -55
  47. data/source/javascripts/bone_tree/models/_nodes.js.coffee +0 -117
  48. data/source/javascripts/bone_tree/models/_settings.js.coffee +0 -25
  49. data/source/javascripts/bone_tree/views/_directory.js.coffee +0 -73
  50. data/source/javascripts/bone_tree/views/_file.js.coffee +0 -51
  51. data/source/javascripts/bone_tree/views/_menu.js.coffee +0 -97
  52. data/source/javascripts/bone_tree/views/_tree.js.coffee +0 -498
  53. data/spec/javascripts/directory_view_spec.coffee +0 -91
  54. data/spec/javascripts/file_view_spec.coffee +0 -70
  55. data/spec/javascripts/menu_view_spec.coffee +0 -42
  56. data/spec/javascripts/nodes_spec.coffee +0 -37
  57. data/spec/javascripts/tree_view_spec.coffee +0 -39
@@ -1,432 +0,0 @@
1
- <!DOCTYPE html>
2
-
3
- <html>
4
- <head>
5
- <title>_tree.js.coffee</title>
6
- <meta http-equiv="content-type" content="text/html; charset=UTF-8">
7
- <link rel="stylesheet" media="all" href="../../../../resources/base.css" />
8
- <link rel="stylesheet" media="all" href="../../../../resources/module.css" />
9
- </head>
10
- <body>
11
- <header>
12
- <h1>_tree.js.coffee</h1>
13
- </header>
14
- <div id="content">
15
- <div id="sidebar">
16
-
17
- <h4>Classes</h4>
18
- <ul class="classlist">
19
-
20
- <li><a href="#Views.Tree">Views.Tree</a></li>
21
-
22
- </ul>
23
-
24
-
25
- </div>
26
- <div id="main">
27
-
28
-
29
- <div id="classes">
30
- <h2>Classes</h2>
31
-
32
- <div class="class">
33
- <div class="header">
34
- <a id="Views.Tree"><h3>Views.Tree</h3></a>
35
-
36
-
37
- <a class="parent" href="#Backbone.View"><h3>extends Backbone.View</h3></a>
38
-
39
-
40
- </div>
41
- <div class="class_content">
42
- <p>Public: The base tree object. Events from other objects are proxied to the tree
43
- so API consumers only need to know about this top level object.</p>
44
- <div class="methods">
45
-
46
-
47
- <div class="instancemethods">
48
- <h3>Instance Methods</h3>
49
-
50
- <div class="method">
51
- <h4>initialize()</h4>
52
- <p>Public: Initialize a new filetree widget</p>
53
-
54
- <ul>
55
- <li>options - An Object of global configuration options for the file tree.
56
- <ul><li>autoOpenFiles - A Boolean. If true, each file that is added to the tree
57
- immediately triggers an <code>openFile</code> event (default: true).</li>
58
- <li>beforeAdd - A Function that is invoked before each file is added to the tree.
59
- It is passed the raw file attributes and should return true if
60
- that file should be added to the tree and false if not. The
61
- default implementation is to return true.</li>
62
- <li>confirmDeletes - A Boolean. If true, the tree will prompt the user, making
63
- sure they want to delete the file (default: false).</li>
64
- <li>showExtensions - A Boolean. If true, files display their extensions. Internally,
65
- extensions are always kept track of but by default they are
66
- hidden (default: false).</li></ul></li>
67
- </ul>
68
- </div>
69
-
70
- <div class="method">
71
- <h4>addFile(filePath, fileData)</h4>
72
- <p>Public: Method to add files and associated file data to the tree.</p>
73
-
74
- <ul>
75
- <li>filePath - A String that represents the directory path to the file.
76
- Directories that don't yet exist will be created. If no
77
- file is specified, eg. '/dir1/dir2/' then only the directories
78
- will be created and this method will return null.</li>
79
- <li>fileData - An Object of attributes to store in the File object. This
80
- could represent information such as lastModified, fileContents,
81
- fileCreator, etc.</li>
82
- </ul>
83
-
84
- <p>Examples</p>
85
-
86
- <pre><code>tree.addFile '/source/main.coffee',
87
- contents: "alert('hello world.')"
88
- lastModified: 1330725130170
89
- # =&gt; &lt;File&gt;
90
- </code></pre>
91
-
92
- <p>Returns the File object if it was created and null if no file was given.</p>
93
- </div>
94
-
95
- <div class="method">
96
- <h4>addFromJSON(data, currentPath)</h4>
97
- <p>Public: Creates a file tree from a JSON representation. Expects the
98
- JSON object to have a <code>name</code> property at each level, specifying
99
- the name of the file or directory, and a files array if the
100
- current node has child directories or files.</p>
101
-
102
- <ul>
103
- <li><p>data - An Object that represents hierarchical file data.</p></li>
104
- <li><p>currentPath - A String representing the current location in the tree.
105
- Defaults to the file tree root. (default: "")</p></li>
106
- </ul>
107
-
108
- <p>Examples</p>
109
-
110
- <pre><code>data = {
111
- name: "My Project"
112
- files: [
113
- { name: "Empty Folder" }
114
- { name: "SomeFile.coffee" }
115
- { name: "AnotherFile.coffee" }
116
- {
117
- name: "Folder with Files inside"
118
- files: [
119
- { name: "NestedFile.coffee" }
120
- ]
121
- }
122
- ]
123
- }
124
-
125
- tree.addFromJSON(data)
126
- # =&gt; &lt;Tree&gt;
127
- </code></pre>
128
-
129
- <p>Returns the Tree view object.</p>
130
- </div>
131
-
132
- <div class="method">
133
- <h4>addToTree(currentDirectory, remainingDirectories, fileName)</h4>
134
- <p>Internal: Recursive method that traverses nodes, creating
135
- Files and Directories.</p>
136
-
137
- <ul>
138
- <li>currentDirectory - A Node object representing which directory we are
139
- adding the current Directory or File to.</li>
140
- <li>remainingDirectories - A '/' separated String representing the remaining
141
- directories to add.</li>
142
- <li>fileName - The String name of the file to be added. This can
143
- include the extension name separated by a '.'.</li>
144
- </ul>
145
-
146
- <p>Examples</p>
147
-
148
- <pre><code>tree.addToTree(@root, '/source/subdirectory/', 'main.coffee')
149
- # =&gt; &lt;File&gt;
150
- </code></pre>
151
-
152
- <p>Returns the File object if it was created and null if no file was given.</p>
153
- </div>
154
-
155
- <div class="method">
156
- <h4>beforeAdd(fileData)</h4>
157
- <p>Internal: This function provides a filter to exclude files from the
158
- file tree based on conditions from their raw data. This function
159
- shouldn't be modified directly, it should instead by passed in
160
- as an option when instantiating the file tree. The default
161
- implementation is to return true and allow all files to be
162
- added to the tree.</p>
163
-
164
- <ul>
165
- <li>fileData - An Object containing the raw attributes of the file to be
166
- created. Use these to determine conditions to allow or
167
- exclude files from the tree.</li>
168
- </ul>
169
-
170
- <p>Examples</p>
171
-
172
- <pre><code># set up a beforeAdd filter on the tree view
173
- tree = new BoneTree.Views.Tree
174
- beforeAdd: (fileData) -&gt;
175
- if fileData.extension is 'wav'
176
- return false
177
- else
178
- return true
179
- </code></pre>
180
-
181
- <p>Returns true if the file should be added to the tree and false otherwise.</p>
182
- </div>
183
-
184
- <div class="method">
185
- <h4>findOrCreateView(node)</h4>
186
- <p>Internal: Look up existing view in the view cache or Create a new view
187
- of the correct type (either File or Directory).</p>
188
-
189
- <ul>
190
- <li>node - A Node object. Either a File object or a Directory object.
191
- This is the model that the view will be associated with.</li>
192
- </ul>
193
-
194
- <p>Examples</p>
195
-
196
- <pre><code>file = new BoneTree.Models.File
197
-
198
- # This will create a new view since we just created the File
199
- tree.findOrCreateView(file)
200
- # =&gt; &lt;FileView&gt;
201
- </code></pre>
202
-
203
- <p>Returns the view corresponding to the model passed in.</p>
204
- </div>
205
-
206
- <div class="method">
207
- <h4>getModelByCid(cid)</h4>
208
-
209
- </div>
210
-
211
- <div class="method">
212
- <h4>closeDirectories()</h4>
213
- <p>Public: Close all the directories in the file tree.</p>
214
-
215
- <p>Examples</p>
216
-
217
- <pre><code>tree.closeDirectories()
218
- # =&gt; &lt;Tree&gt;
219
- </code></pre>
220
-
221
- <p>Returns the Tree view object.</p>
222
- </div>
223
-
224
- <div class="method">
225
- <h4>closeMenu(e)</h4>
226
- <p>Internal: Close the context menu. This is called every click on
227
- the document and closes the menu unless you are clicking
228
- within it. This shouldn't be called directly, it is called
229
- automatically by Backbone from user interactions.</p>
230
-
231
- <p>Returns the Menu view object.</p>
232
- </div>
233
-
234
- <div class="method">
235
- <h4>contextMenu(e)</h4>
236
- <p>Internal: Open the context menu. This prevents the default browser
237
- context menu event. This shouldn't be called directly, it is
238
- called automatically by Backbone from user interations.</p>
239
-
240
- <p>Returns the Menu view object.</p>
241
- </div>
242
-
243
- <div class="method">
244
- <h4>filterNodes(nodeType, nodeName)</h4>
245
- <p>Internal: Returns file tree nodes that match the nodeType and nodeName.</p>
246
-
247
- <ul>
248
- <li>nodeType - A String that represents the nodeType to match. Choices are
249
- 'file' or 'directory'.</li>
250
- <li>nodeName - A String that represents the name of the node to match.</li>
251
- </ul>
252
-
253
- <p>Examples</p>
254
-
255
- <pre><code># Add some files to the tree
256
- tree.addFile('/source/main.coffee')
257
- tree.addFile('/source/player.coffee')
258
-
259
- # returns an array containing the File 'main.coffee'
260
- tree.filterNodes('file', 'main')
261
- # =&gt; [&lt;File&gt;]
262
- </code></pre>
263
-
264
- <p>Returns an Array of nodes that match the filter criteria.</p>
265
- </div>
266
-
267
- <div class="method">
268
- <h4>flatten(currentNode, results)</h4>
269
- <p>Internal: Returns a one dimensional ordered array representing the
270
- Directory and File nodes in the tree.</p>
271
-
272
- <ul>
273
- <li>currentNode - The node to start at when flattening</li>
274
- <li>nodeName - A String that represents the name of the node to match.</li>
275
- </ul>
276
-
277
- <p>Examples</p>
278
-
279
- <pre><code># Add some files to the tree
280
- tree.addFile('/source/main.coffee')
281
- tree.addFile('/source/player.coffee')
282
-
283
- # returns an array containing the File 'main.coffee'
284
- tree.filterNodes('file', 'main')
285
- # =&gt; [&lt;File&gt;]
286
- </code></pre>
287
-
288
- <p>Returns an Array of nodes that match the filter criteria.</p>
289
- </div>
290
-
291
- <div class="method">
292
- <h4>getDirectory(directoryName)</h4>
293
- <p>Public: Returns an array of directories matching the given directoryName.</p>
294
-
295
- <ul>
296
- <li>directoryName - A String naming the directory to match.</li>
297
- </ul>
298
-
299
- <p>Examples</p>
300
-
301
- <pre><code># Add some files to the tree
302
- tree.addFile('/source/main.coffee')
303
- tree.addFile('/source/player.coffee')
304
- tree.addFile('/directory2/file.coffee')
305
-
306
- # returns an array containing the Directory 'source'
307
- tree.getDirectory('source')
308
- # =&gt; [&lt;Directory&gt;]
309
- </code></pre>
310
-
311
- <p>Returns an Array of Directory nodes that match directoryName.</p>
312
- </div>
313
-
314
- <div class="method">
315
- <h4>getFile(fileName)</h4>
316
- <p>Public: Returns an array of files match the given fileName.</p>
317
-
318
- <ul>
319
- <li>fileName - A String naming the files to match.</li>
320
- </ul>
321
-
322
- <p>Examples</p>
323
-
324
- <pre><code># Add some files to the tree
325
- tree.addFile('/source/main.coffee')
326
- tree.addFile('/source/player.coffee')
327
- tree.addFile('/directory2/main.coffee')
328
-
329
- # returns an array containing both the files named main.
330
- tree.getFile('main')
331
- # =&gt; [&lt;File&gt;, &lt;File&gt;]
332
-
333
- # return an array containing the file named player.
334
- tree.getFile('player')
335
- # =&gt; [&lt;File&gt;]
336
- </code></pre>
337
-
338
- <p>Returns an Array of File nodes that match fileName.</p>
339
- </div>
340
-
341
- <div class="method">
342
- <h4>getFiles(directoryName)</h4>
343
- <p>Public: Returns an array of files contained within the directory
344
- matching directoryName.</p>
345
-
346
- <ul>
347
- <li>directoryName - A String naming the directory to look inside.</li>
348
- </ul>
349
-
350
- <p>Examples</p>
351
-
352
- <pre><code># Add some files to the tree
353
- tree.addFile('/source/main.coffee')
354
- tree.addFile('/source/player.coffee')
355
- tree.addFile('/directory2/main.coffee')
356
-
357
- # returns an array containing the files 'player.coffee' and 'main.coffee'
358
- tree.getFiles('source')
359
- # =&gt; [&lt;File&gt;, &lt;File&gt;]
360
- </code></pre>
361
-
362
- <p>Returns an Array of File nodes that are contained in the
363
- Directory matching directoryName.</p>
364
- </div>
365
-
366
- <div class="method">
367
- <h4>toAscii(collection, indentation, output)</h4>
368
- <p>Internal: A String representation of the filetree.</p>
369
-
370
- <ul>
371
- <li>collection - A NodeCollection object describing which folder to start at.</li>
372
- <li>indentation - A Number describing how many spaces to indent the next filetree element (default: 0).</li>
373
- <li>output - A String representing the current filetree output (default: "\n").</li>
374
- </ul>
375
-
376
- <p>Examples</p>
377
-
378
- <pre><code># Add some files to the tree
379
- tree.addFile('/source/main.coffee')
380
- tree.addFile('/source/player.coffee')
381
- tree.addFile('/directory2/main.coffee')
382
-
383
- tree.toAscii()
384
- # =&gt; "
385
- -directory2
386
- -main.coffee
387
- -source
388
- -main.coffee
389
- -player.coffee
390
- "
391
- </code></pre>
392
-
393
- <p>Returns a String representation of the sorted nodes of the file tree.</p>
394
- </div>
395
-
396
- <div class="method">
397
- <h4>getModelFromClick(e)</h4>
398
- <p>Internal: Look up a model based on the cid of the clicked view element.</p>
399
-
400
- <p>Returns the Node corresponding to the view element that the user clicked on.</p>
401
- </div>
402
-
403
- <div class="method">
404
- <h4>openDirectory(e)</h4>
405
- <p>Internal: Toggle the directory icon and display the contents of the clicked Directory.</p>
406
- </div>
407
-
408
- <div class="method">
409
- <h4>openFile(e)</h4>
410
- <p>Internal: Trigger the 'openFile' event, passing in the file corresponding
411
- to the view element that the user clicked.</p>
412
- </div>
413
-
414
- <div class="method">
415
- <h4>render()</h4>
416
- <p>Internal: Call render on each of the nodes underneath the root node.
417
- Also calls sort on each of the subcollections.</p>
418
- </div>
419
-
420
- </div>
421
-
422
- </div>
423
- </div>
424
- </div>
425
-
426
- </div>
427
-
428
-
429
- </div>
430
- </div>
431
- </body>
432
- </html>