sc-frank-cucumber 1.2.1.00af28c
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +4 -0
- data/Gemfile +4 -0
- data/Rakefile +38 -0
- data/bin/frank +6 -0
- data/bin/frank-skeleton +33 -0
- data/frank-skeleton/features/my_first.feature +12 -0
- data/frank-skeleton/features/step_definitions/launch_steps.rb +20 -0
- data/frank-skeleton/features/support/env.rb +8 -0
- data/frank-skeleton/frank_static_resources.bundle/ViewAttributeMapping.plist +63 -0
- data/frank-skeleton/frank_static_resources.bundle/ViewAttributeMappingMac.plist +99 -0
- data/frank-skeleton/frank_static_resources.bundle/images/ajax-loader.gif +0 -0
- data/frank-skeleton/frank_static_resources.bundle/images/file.gif +0 -0
- data/frank-skeleton/frank_static_resources.bundle/images/folder-closed.gif +0 -0
- data/frank-skeleton/frank_static_resources.bundle/images/folder.gif +0 -0
- data/frank-skeleton/frank_static_resources.bundle/images/loader.gif +0 -0
- data/frank-skeleton/frank_static_resources.bundle/images/loader.png +0 -0
- data/frank-skeleton/frank_static_resources.bundle/images/minus.gif +0 -0
- data/frank-skeleton/frank_static_resources.bundle/images/plus.gif +0 -0
- data/frank-skeleton/frank_static_resources.bundle/images/treeview-black-line.gif +0 -0
- data/frank-skeleton/frank_static_resources.bundle/images/treeview-black.gif +0 -0
- data/frank-skeleton/frank_static_resources.bundle/images/treeview-default-line.gif +0 -0
- data/frank-skeleton/frank_static_resources.bundle/images/treeview-default.gif +0 -0
- data/frank-skeleton/frank_static_resources.bundle/images/treeview-famfamfam-line.gif +0 -0
- data/frank-skeleton/frank_static_resources.bundle/images/treeview-famfamfam.gif +0 -0
- data/frank-skeleton/frank_static_resources.bundle/images/treeview-gray-line.gif +0 -0
- data/frank-skeleton/frank_static_resources.bundle/images/treeview-gray.gif +0 -0
- data/frank-skeleton/frank_static_resources.bundle/images/treeview-red-line.gif +0 -0
- data/frank-skeleton/frank_static_resources.bundle/images/treeview-red.gif +0 -0
- data/frank-skeleton/frank_static_resources.bundle/index.html +86 -0
- data/frank-skeleton/frank_static_resources.bundle/index.html.haml +76 -0
- data/frank-skeleton/frank_static_resources.bundle/js/accessible_views_view.coffee +41 -0
- data/frank-skeleton/frank_static_resources.bundle/js/accessible_views_view.js +46 -0
- data/frank-skeleton/frank_static_resources.bundle/js/controller.coffee +134 -0
- data/frank-skeleton/frank_static_resources.bundle/js/controller.js +139 -0
- data/frank-skeleton/frank_static_resources.bundle/js/details_view.coffee +42 -0
- data/frank-skeleton/frank_static_resources.bundle/js/details_view.js +51 -0
- data/frank-skeleton/frank_static_resources.bundle/js/dropdown_control.coffee +64 -0
- data/frank-skeleton/frank_static_resources.bundle/js/dropdown_control.js +73 -0
- data/frank-skeleton/frank_static_resources.bundle/js/ersatz_model.coffee +46 -0
- data/frank-skeleton/frank_static_resources.bundle/js/ersatz_model.js +60 -0
- data/frank-skeleton/frank_static_resources.bundle/js/ersatz_view.coffee +167 -0
- data/frank-skeleton/frank_static_resources.bundle/js/ersatz_view.js +205 -0
- data/frank-skeleton/frank_static_resources.bundle/js/experiment_bar_model.coffee +10 -0
- data/frank-skeleton/frank_static_resources.bundle/js/experiment_bar_model.js +17 -0
- data/frank-skeleton/frank_static_resources.bundle/js/experiment_bar_view.coffee +44 -0
- data/frank-skeleton/frank_static_resources.bundle/js/experiment_bar_view.js +63 -0
- data/frank-skeleton/frank_static_resources.bundle/js/frank.coffee +96 -0
- data/frank-skeleton/frank_static_resources.bundle/js/frank.js +146 -0
- data/frank-skeleton/frank_static_resources.bundle/js/lib/backbone.js +1431 -0
- data/frank-skeleton/frank_static_resources.bundle/js/lib/coffee-script.js +8 -0
- data/frank-skeleton/frank_static_resources.bundle/js/lib/jquery-ui.min.js +405 -0
- data/frank-skeleton/frank_static_resources.bundle/js/lib/jquery.min.js +4 -0
- data/frank-skeleton/frank_static_resources.bundle/js/lib/jquery.treeview.js +251 -0
- data/frank-skeleton/frank_static_resources.bundle/js/lib/json2.js +481 -0
- data/frank-skeleton/frank_static_resources.bundle/js/lib/raphael.js +5815 -0
- data/frank-skeleton/frank_static_resources.bundle/js/lib/require.js +2053 -0
- data/frank-skeleton/frank_static_resources.bundle/js/lib/underscore.js +1059 -0
- data/frank-skeleton/frank_static_resources.bundle/js/main.coffee +27 -0
- data/frank-skeleton/frank_static_resources.bundle/js/main.js +29 -0
- data/frank-skeleton/frank_static_resources.bundle/js/tabs_controller.coffee +13 -0
- data/frank-skeleton/frank_static_resources.bundle/js/tabs_controller.js +22 -0
- data/frank-skeleton/frank_static_resources.bundle/js/toast_controller.coffee +15 -0
- data/frank-skeleton/frank_static_resources.bundle/js/toast_controller.js +28 -0
- data/frank-skeleton/frank_static_resources.bundle/js/transform_stack.coffee +59 -0
- data/frank-skeleton/frank_static_resources.bundle/js/transform_stack.js +78 -0
- data/frank-skeleton/frank_static_resources.bundle/js/tree_view.coffee +53 -0
- data/frank-skeleton/frank_static_resources.bundle/js/tree_view.js +64 -0
- data/frank-skeleton/frank_static_resources.bundle/js/view_hier_model.coffee +37 -0
- data/frank-skeleton/frank_static_resources.bundle/js/view_hier_model.js +48 -0
- data/frank-skeleton/frank_static_resources.bundle/js/view_model.coffee +39 -0
- data/frank-skeleton/frank_static_resources.bundle/js/view_model.js +62 -0
- data/frank-skeleton/frank_static_resources.bundle/pictos/index.html +329 -0
- data/frank-skeleton/frank_static_resources.bundle/pictos/pictos-web.eot +0 -0
- data/frank-skeleton/frank_static_resources.bundle/pictos/pictos-web.svg +114 -0
- data/frank-skeleton/frank_static_resources.bundle/pictos/pictos-web.ttf +0 -0
- data/frank-skeleton/frank_static_resources.bundle/pictos/pictos-web.woff +0 -0
- data/frank-skeleton/frank_static_resources.bundle/pictos/pictos.css +20 -0
- data/frank-skeleton/frank_static_resources.bundle/pictos/pictos_base64.css +18 -0
- data/frank-skeleton/frank_static_resources.bundle/stylesheets/css/symbiote.css +1 -0
- data/frank-skeleton/frank_static_resources.bundle/stylesheets/sass/_elements.scss +28 -0
- data/frank-skeleton/frank_static_resources.bundle/stylesheets/sass/_header.scss +61 -0
- data/frank-skeleton/frank_static_resources.bundle/stylesheets/sass/_inspect_tabs_list_tabs.scss +194 -0
- data/frank-skeleton/frank_static_resources.bundle/stylesheets/sass/_jquery.treeview.scss +68 -0
- data/frank-skeleton/frank_static_resources.bundle/stylesheets/sass/_jqui.scss +2 -0
- data/frank-skeleton/frank_static_resources.bundle/stylesheets/sass/_layout.scss +13 -0
- data/frank-skeleton/frank_static_resources.bundle/stylesheets/sass/_mixins.sass +137 -0
- data/frank-skeleton/frank_static_resources.bundle/stylesheets/sass/_reset.scss +32 -0
- data/frank-skeleton/frank_static_resources.bundle/stylesheets/sass/_selector_test_toolbar.scss +81 -0
- data/frank-skeleton/frank_static_resources.bundle/stylesheets/sass/_solarized.scss +16 -0
- data/frank-skeleton/frank_static_resources.bundle/stylesheets/sass/_typography.scss +11 -0
- data/frank-skeleton/frank_static_resources.bundle/stylesheets/sass/_unicode.scss +3 -0
- data/frank-skeleton/frank_static_resources.bundle/stylesheets/sass/_z_index.scss +2 -0
- data/frank-skeleton/frank_static_resources.bundle/stylesheets/sass/symbiote.scss +26 -0
- data/frank-skeleton/frankify.xcconfig.tt +6 -0
- data/frank-skeleton/libCocoaAsyncSocket.a +0 -0
- data/frank-skeleton/libCocoaAsyncSocketMac.a +0 -0
- data/frank-skeleton/libCocoaHTTPServer.a +0 -0
- data/frank-skeleton/libCocoaHTTPServerMac.a +0 -0
- data/frank-skeleton/libCocoaLumberjack.a +0 -0
- data/frank-skeleton/libCocoaLumberjackMac.a +0 -0
- data/frank-skeleton/libFrank.a +0 -0
- data/frank-skeleton/libFrankMac.a +0 -0
- data/frank-skeleton/libShelley.a +0 -0
- data/frank-skeleton/libShelleyMac.a +0 -0
- data/frank-skeleton/plugins/.empty_directory +0 -0
- data/lib/frank-cucumber.rb +15 -0
- data/lib/frank-cucumber/app_bundle_locator.rb +58 -0
- data/lib/frank-cucumber/bonjour.rb +73 -0
- data/lib/frank-cucumber/cli.rb +299 -0
- data/lib/frank-cucumber/color_helper.rb +13 -0
- data/lib/frank-cucumber/console.rb +28 -0
- data/lib/frank-cucumber/core_frank_steps.rb +260 -0
- data/lib/frank-cucumber/frank.xcconfig.erb +17 -0
- data/lib/frank-cucumber/frank_helper.rb +459 -0
- data/lib/frank-cucumber/frank_localize.rb +43 -0
- data/lib/frank-cucumber/frank_mac_helper.rb +120 -0
- data/lib/frank-cucumber/frankifier.rb +150 -0
- data/lib/frank-cucumber/gateway.rb +135 -0
- data/lib/frank-cucumber/gesture_helper.rb +99 -0
- data/lib/frank-cucumber/host_scripting.rb +96 -0
- data/lib/frank-cucumber/keyboard_helper.rb +69 -0
- data/lib/frank-cucumber/launcher.rb +70 -0
- data/lib/frank-cucumber/localize.yml +104 -0
- data/lib/frank-cucumber/location_helper.rb +20 -0
- data/lib/frank-cucumber/mac_launcher.rb +35 -0
- data/lib/frank-cucumber/plugins/plugin.rb +57 -0
- data/lib/frank-cucumber/rect.rb +26 -0
- data/lib/frank-cucumber/scroll_helper.rb +24 -0
- data/lib/frank-cucumber/version.rb +5 -0
- data/lib/frank-cucumber/wait_helper.rb +57 -0
- data/sc-frank-cucumber.gemspec +37 -0
- data/test/keyboard_helper_test.rb +84 -0
- data/test/launcher_test.rb +57 -0
- data/test/rect_test.rb +25 -0
- data/test/test_helper.rb +16 -0
- metadata +395 -0
@@ -0,0 +1,27 @@
|
|
1
|
+
require ['controller','tabs_controller','tree_view','ersatz_view','details_view', 'accessible_views_view','experiment_bar_view','toast_controller'], (createMainController,createTabsController,TreeView,ErsatzView,DetailsView,AccessibleViewsView,ExperimentBarView,createToastController)->
|
2
|
+
$ ->
|
3
|
+
treeView = new TreeView()
|
4
|
+
|
5
|
+
ersatzView = new ErsatzView()
|
6
|
+
detailsView = new DetailsView()
|
7
|
+
accessibleViewsView = new AccessibleViewsView()
|
8
|
+
experimentBarView = new ExperimentBarView()
|
9
|
+
|
10
|
+
tabsController = createTabsController( $("#list-tabs"), $("#inspect-tabs") );
|
11
|
+
toastController = createToastController( $('.toast') )
|
12
|
+
|
13
|
+
mainController = createMainController(
|
14
|
+
tabsController: tabsController
|
15
|
+
toastController: toastController
|
16
|
+
treeView: treeView
|
17
|
+
ersatzView: ersatzView
|
18
|
+
detailsView: detailsView
|
19
|
+
accessibleViewsView: accessibleViewsView
|
20
|
+
experimentBarModel: experimentBarView.model
|
21
|
+
$asplodeButton: $('#asploder button')
|
22
|
+
$reloadButton: $('button#dump_button')
|
23
|
+
$liveButton: $('#live-view button')
|
24
|
+
)
|
25
|
+
mainController.boot()
|
26
|
+
|
27
|
+
|
@@ -0,0 +1,29 @@
|
|
1
|
+
(function() {
|
2
|
+
|
3
|
+
require(['controller', 'tabs_controller', 'tree_view', 'ersatz_view', 'details_view', 'accessible_views_view', 'experiment_bar_view', 'toast_controller'], function(createMainController, createTabsController, TreeView, ErsatzView, DetailsView, AccessibleViewsView, ExperimentBarView, createToastController) {
|
4
|
+
return $(function() {
|
5
|
+
var accessibleViewsView, detailsView, ersatzView, experimentBarView, mainController, tabsController, toastController, treeView;
|
6
|
+
treeView = new TreeView();
|
7
|
+
ersatzView = new ErsatzView();
|
8
|
+
detailsView = new DetailsView();
|
9
|
+
accessibleViewsView = new AccessibleViewsView();
|
10
|
+
experimentBarView = new ExperimentBarView();
|
11
|
+
tabsController = createTabsController($("#list-tabs"), $("#inspect-tabs"));
|
12
|
+
toastController = createToastController($('.toast'));
|
13
|
+
mainController = createMainController({
|
14
|
+
tabsController: tabsController,
|
15
|
+
toastController: toastController,
|
16
|
+
treeView: treeView,
|
17
|
+
ersatzView: ersatzView,
|
18
|
+
detailsView: detailsView,
|
19
|
+
accessibleViewsView: accessibleViewsView,
|
20
|
+
experimentBarModel: experimentBarView.model,
|
21
|
+
$asplodeButton: $('#asploder button'),
|
22
|
+
$reloadButton: $('button#dump_button'),
|
23
|
+
$liveButton: $('#live-view button')
|
24
|
+
});
|
25
|
+
return mainController.boot();
|
26
|
+
});
|
27
|
+
});
|
28
|
+
|
29
|
+
}).call(this);
|
@@ -0,0 +1,13 @@
|
|
1
|
+
define ->
|
2
|
+
|
3
|
+
createController = ($listTabs,$inspectTabs)->
|
4
|
+
$listTabs.tabs();
|
5
|
+
$inspectTabs.tabs();
|
6
|
+
|
7
|
+
selectViewDetailsTab = -> $inspectTabs.tabs('select', 0)
|
8
|
+
selectLocatorTab = -> $inspectTabs.tabs('select', 1)
|
9
|
+
{
|
10
|
+
selectViewDetailsTab: selectViewDetailsTab
|
11
|
+
selectLocatorTab: selectLocatorTab
|
12
|
+
}
|
13
|
+
|
@@ -0,0 +1,22 @@
|
|
1
|
+
(function() {
|
2
|
+
|
3
|
+
define(function() {
|
4
|
+
var createController;
|
5
|
+
return createController = function($listTabs, $inspectTabs) {
|
6
|
+
var selectLocatorTab, selectViewDetailsTab;
|
7
|
+
$listTabs.tabs();
|
8
|
+
$inspectTabs.tabs();
|
9
|
+
selectViewDetailsTab = function() {
|
10
|
+
return $inspectTabs.tabs('select', 0);
|
11
|
+
};
|
12
|
+
selectLocatorTab = function() {
|
13
|
+
return $inspectTabs.tabs('select', 1);
|
14
|
+
};
|
15
|
+
return {
|
16
|
+
selectViewDetailsTab: selectViewDetailsTab,
|
17
|
+
selectLocatorTab: selectLocatorTab
|
18
|
+
};
|
19
|
+
};
|
20
|
+
});
|
21
|
+
|
22
|
+
}).call(this);
|
@@ -0,0 +1,15 @@
|
|
1
|
+
TOAST_SHOW_TIME = 3000
|
2
|
+
define ->
|
3
|
+
createController = ($toast)->
|
4
|
+
existingTimeout = undefined
|
5
|
+
|
6
|
+
hideToast = -> $toast.removeClass('show')
|
7
|
+
|
8
|
+
hideToast()
|
9
|
+
|
10
|
+
showToastMessage: (message)->
|
11
|
+
$toast.addClass('show')
|
12
|
+
$toast.html(message)
|
13
|
+
|
14
|
+
window.clearTimeout(existingTimeout) if existingTimeout?
|
15
|
+
existingTimeout = window.setTimeout( hideToast, TOAST_SHOW_TIME )
|
@@ -0,0 +1,28 @@
|
|
1
|
+
(function() {
|
2
|
+
var TOAST_SHOW_TIME;
|
3
|
+
|
4
|
+
TOAST_SHOW_TIME = 3000;
|
5
|
+
|
6
|
+
define(function() {
|
7
|
+
var createController;
|
8
|
+
return createController = function($toast) {
|
9
|
+
var existingTimeout, hideToast;
|
10
|
+
existingTimeout = void 0;
|
11
|
+
hideToast = function() {
|
12
|
+
return $toast.removeClass('show');
|
13
|
+
};
|
14
|
+
hideToast();
|
15
|
+
return {
|
16
|
+
showToastMessage: function(message) {
|
17
|
+
$toast.addClass('show');
|
18
|
+
$toast.html(message);
|
19
|
+
if (existingTimeout != null) {
|
20
|
+
window.clearTimeout(existingTimeout);
|
21
|
+
}
|
22
|
+
return existingTimeout = window.setTimeout(hideToast, TOAST_SHOW_TIME);
|
23
|
+
}
|
24
|
+
};
|
25
|
+
};
|
26
|
+
});
|
27
|
+
|
28
|
+
}).call(this);
|
@@ -0,0 +1,59 @@
|
|
1
|
+
R = Raphael
|
2
|
+
|
3
|
+
define ->
|
4
|
+
(initialMatrix)->
|
5
|
+
currentMatrix = initialMatrix || R.matrix()
|
6
|
+
stack = [currentMatrix]
|
7
|
+
|
8
|
+
clone = ->
|
9
|
+
transformStack( currentMatrix.clone() )
|
10
|
+
|
11
|
+
|
12
|
+
push = ->
|
13
|
+
stack.push( currentMatrix )
|
14
|
+
currentMatrix = currentMatrix.clone()
|
15
|
+
@
|
16
|
+
|
17
|
+
pop = ->
|
18
|
+
stack.pop()
|
19
|
+
currentMatrix = _.last( stack )
|
20
|
+
@
|
21
|
+
|
22
|
+
desc = ->
|
23
|
+
currentMatrix.toTransformString()
|
24
|
+
|
25
|
+
descAndPop = ->
|
26
|
+
str = desc()
|
27
|
+
pop()
|
28
|
+
str
|
29
|
+
|
30
|
+
prefixedWithTranslate = (x,y)->
|
31
|
+
prefix = R.matrix()
|
32
|
+
prefix.translate(x,y)
|
33
|
+
prefix.add( currentMatrix )
|
34
|
+
prefix
|
35
|
+
|
36
|
+
|
37
|
+
chainerFor = ( methodName )->
|
38
|
+
(args...)->
|
39
|
+
currentMatrix[methodName](args...)
|
40
|
+
@
|
41
|
+
|
42
|
+
translate = chainerFor('translate')
|
43
|
+
rotate = chainerFor('rotate')
|
44
|
+
scale = chainerFor('scale')
|
45
|
+
|
46
|
+
skew = (x,y)->
|
47
|
+
x = R.rad(x)
|
48
|
+
y = R.rad(y)
|
49
|
+
currentMatrix.add( 1, 0, Math.tan(x), 1, 0, 0 )
|
50
|
+
currentMatrix.add( 1, Math.tan(y), 0, 1, 0, 0 )
|
51
|
+
@
|
52
|
+
|
53
|
+
rotateAroundPoint = (rot,x,y)->
|
54
|
+
@translate(x,y).rotate(rot).translate(-x,-y)
|
55
|
+
|
56
|
+
{
|
57
|
+
clone, translate, rotate, scale, skew, rotateAroundPoint,
|
58
|
+
push, pop, desc, descAndPop, prefixedWithTranslate
|
59
|
+
}
|
@@ -0,0 +1,78 @@
|
|
1
|
+
(function() {
|
2
|
+
var R,
|
3
|
+
__slice = [].slice;
|
4
|
+
|
5
|
+
R = Raphael;
|
6
|
+
|
7
|
+
define(function() {
|
8
|
+
return function(initialMatrix) {
|
9
|
+
var chainerFor, clone, currentMatrix, desc, descAndPop, pop, prefixedWithTranslate, push, rotate, rotateAroundPoint, scale, skew, stack, translate;
|
10
|
+
currentMatrix = initialMatrix || R.matrix();
|
11
|
+
stack = [currentMatrix];
|
12
|
+
clone = function() {
|
13
|
+
return transformStack(currentMatrix.clone());
|
14
|
+
};
|
15
|
+
push = function() {
|
16
|
+
stack.push(currentMatrix);
|
17
|
+
currentMatrix = currentMatrix.clone();
|
18
|
+
return this;
|
19
|
+
};
|
20
|
+
pop = function() {
|
21
|
+
stack.pop();
|
22
|
+
currentMatrix = _.last(stack);
|
23
|
+
return this;
|
24
|
+
};
|
25
|
+
desc = function() {
|
26
|
+
return currentMatrix.toTransformString();
|
27
|
+
};
|
28
|
+
descAndPop = function() {
|
29
|
+
var str;
|
30
|
+
str = desc();
|
31
|
+
pop();
|
32
|
+
return str;
|
33
|
+
};
|
34
|
+
prefixedWithTranslate = function(x, y) {
|
35
|
+
var prefix;
|
36
|
+
prefix = R.matrix();
|
37
|
+
prefix.translate(x, y);
|
38
|
+
prefix.add(currentMatrix);
|
39
|
+
return prefix;
|
40
|
+
};
|
41
|
+
chainerFor = function(methodName) {
|
42
|
+
return function() {
|
43
|
+
var args;
|
44
|
+
args = 1 <= arguments.length ? __slice.call(arguments, 0) : [];
|
45
|
+
currentMatrix[methodName].apply(currentMatrix, args);
|
46
|
+
return this;
|
47
|
+
};
|
48
|
+
};
|
49
|
+
translate = chainerFor('translate');
|
50
|
+
rotate = chainerFor('rotate');
|
51
|
+
scale = chainerFor('scale');
|
52
|
+
skew = function(x, y) {
|
53
|
+
x = R.rad(x);
|
54
|
+
y = R.rad(y);
|
55
|
+
currentMatrix.add(1, 0, Math.tan(x), 1, 0, 0);
|
56
|
+
currentMatrix.add(1, Math.tan(y), 0, 1, 0, 0);
|
57
|
+
return this;
|
58
|
+
};
|
59
|
+
rotateAroundPoint = function(rot, x, y) {
|
60
|
+
return this.translate(x, y).rotate(rot).translate(-x, -y);
|
61
|
+
};
|
62
|
+
return {
|
63
|
+
clone: clone,
|
64
|
+
translate: translate,
|
65
|
+
rotate: rotate,
|
66
|
+
scale: scale,
|
67
|
+
skew: skew,
|
68
|
+
rotateAroundPoint: rotateAroundPoint,
|
69
|
+
push: push,
|
70
|
+
pop: pop,
|
71
|
+
desc: desc,
|
72
|
+
descAndPop: descAndPop,
|
73
|
+
prefixedWithTranslate: prefixedWithTranslate
|
74
|
+
};
|
75
|
+
};
|
76
|
+
});
|
77
|
+
|
78
|
+
}).call(this);
|
@@ -0,0 +1,53 @@
|
|
1
|
+
define ['view_hier_model'],(ViewHierModel)->
|
2
|
+
|
3
|
+
TreeNodeView = Backbone.View.extend
|
4
|
+
tagName: 'li'
|
5
|
+
|
6
|
+
initialize: ->
|
7
|
+
@model.on 'change:selected', _.bind( @refreshSelectedness, @ )
|
8
|
+
|
9
|
+
$a: -> @$( '> a' )
|
10
|
+
|
11
|
+
render: ->
|
12
|
+
$childList = $("<ul/>")
|
13
|
+
|
14
|
+
for child in @model.get('children')
|
15
|
+
childView = new TreeNodeView( model: child )
|
16
|
+
$childList.append( childView.render().el )
|
17
|
+
|
18
|
+
@$el.append("<a>#{@model.getDesc()}</a>").append($childList)
|
19
|
+
|
20
|
+
# have to do this by hand rather than with events property
|
21
|
+
# because BB doesn't appear to let you bind to just immediate
|
22
|
+
# descendants using e.g. "mouseenter > a"
|
23
|
+
@$a()
|
24
|
+
.on( 'mouseenter', => @model.setActive() )
|
25
|
+
.on( 'mouseleave', => @model.unsetActive() )
|
26
|
+
.on( 'click', => @model.trigger('selected',@model) )
|
27
|
+
|
28
|
+
@refreshSelectedness()
|
29
|
+
@
|
30
|
+
|
31
|
+
refreshSelectedness: ->
|
32
|
+
if @model.get('selected')
|
33
|
+
@$a().addClass('selected')
|
34
|
+
else
|
35
|
+
@$a().removeClass('selected')
|
36
|
+
|
37
|
+
|
38
|
+
|
39
|
+
|
40
|
+
|
41
|
+
TreeView = Backbone.View.extend
|
42
|
+
el: $('#dom-dump > ul')
|
43
|
+
|
44
|
+
initialize: ->
|
45
|
+
@model = new ViewHierModel()
|
46
|
+
@model.on 'change', _.bind(@refresh,@)
|
47
|
+
|
48
|
+
refresh: ->
|
49
|
+
@$el.empty()
|
50
|
+
rootNodeView = new TreeNodeView(model: @model.get('root'))
|
51
|
+
@$el.append( rootNodeView.render().el )
|
52
|
+
@$el.treeview( collapsed: false )
|
53
|
+
|
@@ -0,0 +1,64 @@
|
|
1
|
+
(function() {
|
2
|
+
|
3
|
+
define(['view_hier_model'], function(ViewHierModel) {
|
4
|
+
var TreeNodeView, TreeView;
|
5
|
+
TreeNodeView = Backbone.View.extend({
|
6
|
+
tagName: 'li',
|
7
|
+
initialize: function() {
|
8
|
+
return this.model.on('change:selected', _.bind(this.refreshSelectedness, this));
|
9
|
+
},
|
10
|
+
$a: function() {
|
11
|
+
return this.$('> a');
|
12
|
+
},
|
13
|
+
render: function() {
|
14
|
+
var $childList, child, childView, _i, _len, _ref,
|
15
|
+
_this = this;
|
16
|
+
$childList = $("<ul/>");
|
17
|
+
_ref = this.model.get('children');
|
18
|
+
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
19
|
+
child = _ref[_i];
|
20
|
+
childView = new TreeNodeView({
|
21
|
+
model: child
|
22
|
+
});
|
23
|
+
$childList.append(childView.render().el);
|
24
|
+
}
|
25
|
+
this.$el.append("<a>" + (this.model.getDesc()) + "</a>").append($childList);
|
26
|
+
this.$a().on('mouseenter', function() {
|
27
|
+
return _this.model.setActive();
|
28
|
+
}).on('mouseleave', function() {
|
29
|
+
return _this.model.unsetActive();
|
30
|
+
}).on('click', function() {
|
31
|
+
return _this.model.trigger('selected', _this.model);
|
32
|
+
});
|
33
|
+
this.refreshSelectedness();
|
34
|
+
return this;
|
35
|
+
},
|
36
|
+
refreshSelectedness: function() {
|
37
|
+
if (this.model.get('selected')) {
|
38
|
+
return this.$a().addClass('selected');
|
39
|
+
} else {
|
40
|
+
return this.$a().removeClass('selected');
|
41
|
+
}
|
42
|
+
}
|
43
|
+
});
|
44
|
+
return TreeView = Backbone.View.extend({
|
45
|
+
el: $('#dom-dump > ul'),
|
46
|
+
initialize: function() {
|
47
|
+
this.model = new ViewHierModel();
|
48
|
+
return this.model.on('change', _.bind(this.refresh, this));
|
49
|
+
},
|
50
|
+
refresh: function() {
|
51
|
+
var rootNodeView;
|
52
|
+
this.$el.empty();
|
53
|
+
rootNodeView = new TreeNodeView({
|
54
|
+
model: this.model.get('root')
|
55
|
+
});
|
56
|
+
this.$el.append(rootNodeView.render().el);
|
57
|
+
return this.$el.treeview({
|
58
|
+
collapsed: false
|
59
|
+
});
|
60
|
+
}
|
61
|
+
});
|
62
|
+
});
|
63
|
+
|
64
|
+
}).call(this);
|
@@ -0,0 +1,37 @@
|
|
1
|
+
define ['view_model'], (ViewModel)->
|
2
|
+
ViewCollection = Backbone.Collection
|
3
|
+
|
4
|
+
flatten = (rootViewModel)->
|
5
|
+
flattenedViewModels = [rootViewModel]
|
6
|
+
for childViewModel in rootViewModel.get('children')
|
7
|
+
flattenedViewModels = flattenedViewModels.concat( flatten(childViewModel) )
|
8
|
+
|
9
|
+
flattenedViewModels
|
10
|
+
|
11
|
+
|
12
|
+
|
13
|
+
ViewHierModel = Backbone.Model.extend
|
14
|
+
getAccessibleViews: ->
|
15
|
+
@get( 'allViews' ).filter (viewModel)-> viewModel.has('accessibilityLabel')
|
16
|
+
|
17
|
+
resetViewHier: (rawRootView)->
|
18
|
+
rootViewModel = new ViewModel(rawRootView)
|
19
|
+
allViews = new ViewCollection( flatten( rootViewModel ) )
|
20
|
+
|
21
|
+
allViews.on 'change:active', (viewModel)=>
|
22
|
+
if viewModel.get('active')
|
23
|
+
@trigger( 'active-view-changed', viewModel )
|
24
|
+
|
25
|
+
allViews.on 'selected', (selectedViewModel)=>
|
26
|
+
allViews.each (viewModel)->
|
27
|
+
viewModel.set('selected',viewModel == selectedViewModel)
|
28
|
+
@trigger( 'selected-view-changed', selectedViewModel )
|
29
|
+
|
30
|
+
allViews.on 'accessible-selected', (viewModel)=>
|
31
|
+
@trigger( 'accessible-view-selected', viewModel )
|
32
|
+
|
33
|
+
@set( 'root', rootViewModel )
|
34
|
+
@set( 'allViews', allViews )
|
35
|
+
|
36
|
+
|
37
|
+
ViewHierModel
|
@@ -0,0 +1,48 @@
|
|
1
|
+
(function() {
|
2
|
+
|
3
|
+
define(['view_model'], function(ViewModel) {
|
4
|
+
var ViewCollection, ViewHierModel, flatten;
|
5
|
+
ViewCollection = Backbone.Collection;
|
6
|
+
flatten = function(rootViewModel) {
|
7
|
+
var childViewModel, flattenedViewModels, _i, _len, _ref;
|
8
|
+
flattenedViewModels = [rootViewModel];
|
9
|
+
_ref = rootViewModel.get('children');
|
10
|
+
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
11
|
+
childViewModel = _ref[_i];
|
12
|
+
flattenedViewModels = flattenedViewModels.concat(flatten(childViewModel));
|
13
|
+
}
|
14
|
+
return flattenedViewModels;
|
15
|
+
};
|
16
|
+
ViewHierModel = Backbone.Model.extend({
|
17
|
+
getAccessibleViews: function() {
|
18
|
+
return this.get('allViews').filter(function(viewModel) {
|
19
|
+
return viewModel.has('accessibilityLabel');
|
20
|
+
});
|
21
|
+
},
|
22
|
+
resetViewHier: function(rawRootView) {
|
23
|
+
var allViews, rootViewModel,
|
24
|
+
_this = this;
|
25
|
+
rootViewModel = new ViewModel(rawRootView);
|
26
|
+
allViews = new ViewCollection(flatten(rootViewModel));
|
27
|
+
allViews.on('change:active', function(viewModel) {
|
28
|
+
if (viewModel.get('active')) {
|
29
|
+
return _this.trigger('active-view-changed', viewModel);
|
30
|
+
}
|
31
|
+
});
|
32
|
+
allViews.on('selected', function(selectedViewModel) {
|
33
|
+
allViews.each(function(viewModel) {
|
34
|
+
return viewModel.set('selected', viewModel === selectedViewModel);
|
35
|
+
});
|
36
|
+
return _this.trigger('selected-view-changed', selectedViewModel);
|
37
|
+
});
|
38
|
+
allViews.on('accessible-selected', function(viewModel) {
|
39
|
+
return _this.trigger('accessible-view-selected', viewModel);
|
40
|
+
});
|
41
|
+
this.set('root', rootViewModel);
|
42
|
+
return this.set('allViews', allViews);
|
43
|
+
}
|
44
|
+
});
|
45
|
+
return ViewHierModel;
|
46
|
+
});
|
47
|
+
|
48
|
+
}).call(this);
|