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,112 +0,0 @@
1
- <!DOCTYPE html>
2
-
3
- <html>
4
- <head>
5
- <title>_file.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>_file.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="#Models.File">Models.File</a></li>
21
-
22
- </ul>
23
-
24
-
25
- <h4>Functions</h4>
26
- <ul class="functionlist">
27
-
28
- <li><a href="#Models.File.createFromFileName">Models.File.createFromFileName</a></li>
29
-
30
- </ul>
31
-
32
- </div>
33
- <div id="main">
34
-
35
-
36
- <div id="classes">
37
- <h2>Classes</h2>
38
-
39
- <div class="class">
40
- <div class="header">
41
- <a id="Models.File"><h3>Models.File</h3></a>
42
-
43
-
44
- <a class="parent" href="#Models.Node"><h3>extends Models.Node</h3></a>
45
-
46
-
47
- </div>
48
- <div class="class_content">
49
- <p>Public: Object representing file data in the tree.</p>
50
-
51
- <ul>
52
- <li>defaults
53
- <ul><li>name - A String naming the file (default: "New File").</li>
54
- <li>sortPriority - A String representing the priority with which the
55
- node is sorted. Directories have sortPriority "0"
56
- allowing them to be sorted before Files which have
57
- sortPriority "1".</li>
58
- <li>nodeType - A String denoting what type of node this object is.
59
- The two types are "file" and "directory".</li></ul></li>
60
- </ul>
61
- <div class="methods">
62
-
63
-
64
- </div>
65
- </div>
66
- </div>
67
-
68
- </div>
69
-
70
-
71
- <div id="functions">
72
- <h2>Functions</h2>
73
-
74
- <div class="function">
75
- <div class="header">
76
- <a id="Models.File.createFromFileName"><h3>Models.File.createFromFileName(fileName, fileData)</h3></a>
77
- </div>
78
-
79
- <div>
80
- <p>Public: Class method to create a new File object based on the fileName
81
- and fileData passed in.</p>
82
-
83
- <ul>
84
- <li><p>fileName - A String representing the name of the file to be created.
85
- files with '.' in the name will be parsed out and only the
86
- string after the final '.' will be considered the extension.</p></li>
87
- <li><p>fileData - An Object of attributes to associate with the file.</p></li>
88
- </ul>
89
-
90
- <p>Examples</p>
91
-
92
- <pre><code>data = {
93
- contents: alert 'this is the code in the file'
94
- createdAt: 1330846900589
95
- language: 'CoffeeScript'
96
- }
97
-
98
- BoneTree.Models.File.createFromFileName('example.coffee', data)
99
- # =&gt; &lt;File&gt;
100
- </code></pre>
101
-
102
- <p>Returns the File object just created.</p>
103
- </div>
104
-
105
- </div>
106
-
107
- </div>
108
-
109
- </div>
110
- </div>
111
- </body>
112
- </html>
@@ -1,174 +0,0 @@
1
- <!DOCTYPE html>
2
-
3
- <html>
4
- <head>
5
- <title>_nodes.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>_nodes.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="#Models.Node">Models.Node</a></li>
21
-
22
- <li><a href="#Models.Nodes">Models.Nodes</a></li>
23
-
24
- </ul>
25
-
26
-
27
- </div>
28
- <div id="main">
29
-
30
-
31
- <div id="classes">
32
- <h2>Classes</h2>
33
-
34
- <div class="class">
35
- <div class="header">
36
- <a id="Models.Node"><h3>Models.Node</h3></a>
37
-
38
-
39
- <a class="parent" href="#Backbone.Model"><h3>extends Backbone.Model</h3></a>
40
-
41
-
42
- </div>
43
- <div class="class_content">
44
- <p>Internal: An abstract super class for File and Directory objects to inherit from.</p>
45
- <div class="methods">
46
-
47
-
48
- <div class="instancemethods">
49
- <h3>Instance Methods</h3>
50
-
51
- <div class="method">
52
- <h4>initialize()</h4>
53
- <p>Internal: Initialize a new Node object. Set it up to contain a collection of
54
- children nodes.</p>
55
- </div>
56
-
57
- <div class="method">
58
- <h4>constantize()</h4>
59
- <p>Public: Returns a String with the nodeType capitalized so that it may be used
60
- to instatiate the appropriate view type</p>
61
-
62
- <p>Examples</p>
63
-
64
- <pre><code>file = new BoneTree.Models.File
65
- directory = new BoneTree.Models.Directory
66
-
67
- file.constantize()
68
- # =&gt; 'File'
69
-
70
- directory.constantize()
71
- # =&gt; 'Directory'
72
-
73
- # use it to create a new view of the appropriate type
74
- view = new BoneTree.Views[file.constantize()]
75
- </code></pre>
76
-
77
- <p>Returns a String of the nodeType with the first letter capitalized.</p>
78
- </div>
79
-
80
- <div class="method">
81
- <h4>nameWithExtension()</h4>
82
- <p>Public: Returns the node name with the extension if it has
83
- one and just the node name if there is no extension.</p>
84
-
85
- <p>Examples</p>
86
-
87
- <pre><code>file = new BoneTree.Models.File
88
- name: "file"
89
- extension: "coffee"
90
-
91
- noExt = new BoneTree.Models.File
92
- name: "file2"
93
-
94
- directory = new BoneTree.Model.Directory
95
- name: "source"
96
-
97
- file.nameWithExtension()
98
- # =&gt; "file.coffee"
99
-
100
- noExt.nameWithExtension()
101
- # =&gt; "file2"
102
-
103
- directory.nameWithExtension()
104
- # =&gt; "source"
105
- </code></pre>
106
-
107
- <p>Returns a String. If the extension exists then the node name plus the extension
108
- are returned. If there is no extension, then just the node name is returned.</p>
109
- </div>
110
-
111
- </div>
112
-
113
- </div>
114
- </div>
115
- </div>
116
-
117
- <div class="class">
118
- <div class="header">
119
- <a id="Models.Nodes"><h3>Models.Nodes</h3></a>
120
-
121
-
122
- <a class="parent" href="#Backbone.Collection"><h3>extends Backbone.Collection</h3></a>
123
-
124
-
125
- </div>
126
- <div class="class_content">
127
- <p>Internal: A collection of node models. Since Node is an abstract super
128
- class, in practice this collection will hold File objects
129
- and Directory objects.</p>
130
- <div class="methods">
131
-
132
-
133
- <div class="instancemethods">
134
- <h3>Instance Methods</h3>
135
-
136
- <div class="method">
137
- <h4>comparator(node)</h4>
138
- <p>Internal: Function that determines how the file tree is sorted. Directories
139
- are sorted before files. After node type sort
140
- priority, nodes are sorted by name.</p>
141
-
142
- <p>Examples</p>
143
-
144
- <pre><code>tree.addFile('/source/file1.coffee')
145
- tree.addFile('/source/file2.coffee')
146
- tree.addFile('main.coffee')
147
-
148
- tree.render()
149
-
150
- # even though 'main' comes before 'source' alphabetically it is placed
151
- # after the 'source' directory due to the sortPriority of the Directory object.
152
- tree.toAscii()
153
- # =&gt; "
154
- -source
155
- -file1.coffee
156
- -file2.coffee
157
- -main.coffee
158
- "
159
- </code></pre>
160
- </div>
161
-
162
- </div>
163
-
164
- </div>
165
- </div>
166
- </div>
167
-
168
- </div>
169
-
170
-
171
- </div>
172
- </div>
173
- </body>
174
- </html>
@@ -1,75 +0,0 @@
1
- <!DOCTYPE html>
2
-
3
- <html>
4
- <head>
5
- <title>_settings.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>_settings.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="#Models.Settings">Models.Settings</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="Models.Settings"><h3>Models.Settings</h3></a>
35
-
36
-
37
- <a class="parent" href="#Backbone.Model"><h3>extends Backbone.Model</h3></a>
38
-
39
-
40
- </div>
41
- <div class="class_content">
42
- <p>Internal: A configuration object. Consumers of the API don't need to
43
- worry about this. It is used internally to manage the options
44
- passed into the file tree.</p>
45
-
46
- <ul>
47
- <li>defaults
48
- <ul><li>autoOpenFiles - A Boolean. If true, each file that is added to the tree
49
- immediately triggers an <code>openFile</code> event (default: true).</li>
50
- <li>beforeAdd - A Function that is invoked before each file is added to the tree.
51
- It is passed the raw file attributes and should return true if
52
- that file should be added to the tree and false if not. The
53
- default implementation is to return true.</li>
54
- <li>confirmDeletes - A Boolean. If true, the tree will prompt the user, making
55
- sure they want to delete the file (default: false).</li>
56
- <li>showExtensions - A Boolean. If true, files display their extensions. Internally,
57
- extensions are always kept track of but by default they are
58
- hidden (default: false).</li>
59
- <li>viewCache - An Object that stores views when they are created and is used
60
- to look them up to prevent extra views from being created.</li></ul></li>
61
- </ul>
62
- <div class="methods">
63
-
64
-
65
- </div>
66
- </div>
67
- </div>
68
-
69
- </div>
70
-
71
-
72
- </div>
73
- </div>
74
- </body>
75
- </html>
@@ -1,94 +0,0 @@
1
- <!DOCTYPE html>
2
-
3
- <html>
4
- <head>
5
- <title>_directory.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>_directory.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.Directory">Views.Directory</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.Directory"><h3>Views.Directory</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>Internal: View that renders a Directory node and controls its behavior (class: 'directory', tag: 'ul').</p>
43
- <div class="methods">
44
-
45
-
46
- <div class="instancemethods">
47
- <h3>Instance Methods</h3>
48
-
49
- <div class="method">
50
- <h4>initialize(options)</h4>
51
- <p>Internal: Initialize a new directory node. Adds associated model cid to the
52
- view element. Binds change handler to the <code>change:open</code> event that
53
- toggles the display of directory contents. Binds change handler to
54
- the <code>change:name</code> event that re-renders a sorted file tree.</p>
55
-
56
- <ul>
57
- <li>options - Passes in settings object, which is used for access to the
58
- tree view root in order to proxy events to it.</li>
59
- </ul>
60
- </div>
61
-
62
- <div class="method">
63
- <h4>appendView(node)</h4>
64
- <p>Internal: Appends a view based on the underlying node model to this view.</p>
65
-
66
- <p>node - A Node model. Either a File or a Directory. This is the model the
67
- created view will be associated with.</p>
68
- </div>
69
-
70
- <div class="method">
71
- <h4>render()</h4>
72
- <p>Internal: Set the text of the view element based on the underlying model name.</p>
73
-
74
- <p>Returns <code>this</code> view.</p>
75
- </div>
76
-
77
- <div class="method">
78
- <h4>displayChildren(open)</h4>
79
- <p>Internal: Toggles display of the children Files or Diretories of this view.</p>
80
- </div>
81
-
82
- </div>
83
-
84
- </div>
85
- </div>
86
- </div>
87
-
88
- </div>
89
-
90
-
91
- </div>
92
- </div>
93
- </body>
94
- </html>
@@ -1,82 +0,0 @@
1
- <!DOCTYPE html>
2
-
3
- <html>
4
- <head>
5
- <title>_file.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>_file.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.File">Views.File</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.File"><h3>Views.File</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>Internal: View that renders a File node and controls its behavior (class: 'file', tag: 'li').</p>
43
- <div class="methods">
44
-
45
-
46
- <div class="instancemethods">
47
- <h3>Instance Methods</h3>
48
-
49
- <div class="method">
50
- <h4>initialize(options)</h4>
51
- <p>Internal: Initialize a new file node. Adds associated model cid to the
52
- view element. Binds change handlers to the <code>change:name</code> and
53
- <code>change:extension</code> events. These take care of resorting the file
54
- nodes.</p>
55
-
56
- <ul>
57
- <li>options - Passes in settings object, which is used to control
58
- whether or not file extensions are shown.</li>
59
- </ul>
60
- </div>
61
-
62
- <div class="method">
63
- <h4>render()</h4>
64
- <p>Internal: Sets the text of the file node according to the underlying model
65
- name. If the 'showExtensions' setting is set, renders the
66
- full file name with extension, otherwise renders just the file
67
- name attribute.</p>
68
- </div>
69
-
70
- </div>
71
-
72
- </div>
73
- </div>
74
- </div>
75
-
76
- </div>
77
-
78
-
79
- </div>
80
- </div>
81
- </body>
82
- </html>
@@ -1,110 +0,0 @@
1
- <!DOCTYPE html>
2
-
3
- <html>
4
- <head>
5
- <title>_menu.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>_menu.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.Menu">Views.Menu</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.Menu"><h3>Views.Menu</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>Internal: View that controls the context menu (class: 'filetree_context_menu').</p>
43
-
44
- <p>Events</p>
45
-
46
- <ul>
47
- <li><p>contextMenu - Prevents the standard browser context menu from appearing
48
- when right clicking within the file tree context menu.</p></li>
49
- <li><p>click .rename - Prompts the user to rename a file.</p></li>
50
- <li><p>click .delete - Deletes a node from the file tree.</p></li>
51
- </ul>
52
- <div class="methods">
53
-
54
-
55
- <div class="instancemethods">
56
- <h3>Instance Methods</h3>
57
-
58
- <div class="method">
59
- <h4>initialize(options)</h4>
60
- <p>Internal: Initialize a new menu widget.</p>
61
-
62
- <ul>
63
- <li>options - An Object. Internally used to pass the settings configuration
64
- into the menu. This controls whether or not the user is
65
- prompted to confirm deleting a file.</li>
66
- </ul>
67
- </div>
68
-
69
- <div class="method">
70
- <h4>contextMenu(e)</h4>
71
- <p>Internal: Kill the default browser behavior for the contextmenu event.</p>
72
- </div>
73
-
74
- <div class="method">
75
- <h4>delete(e)</h4>
76
- <p>Internal: Deletes a node from the file tree. If the confirmDeletes setting
77
- is set, prompts the user for delete confirmation.</p>
78
- </div>
79
-
80
- <div class="method">
81
- <h4>rename(e)</h4>
82
- <p>Internal: Prompts the user to rename a File or Directory.</p>
83
- </div>
84
-
85
- <div class="method">
86
- <h4>render()</h4>
87
- <p>Internal: Renders the <ul> that contains the context menu choices
88
- 'Rename' and 'Delete'.</p>
89
-
90
- <p>Returns <code>this</code>, the menu view.</p>
91
- </div>
92
-
93
- <div class="method">
94
- <h4>template()</h4>
95
- <p>Internal: html template for the context menu.</p>
96
- </div>
97
-
98
- </div>
99
-
100
- </div>
101
- </div>
102
- </div>
103
-
104
- </div>
105
-
106
-
107
- </div>
108
- </div>
109
- </body>
110
- </html>