Skip to content

Commit 9b97827

Browse files
authored
Merge pull request #2 from wilr/master
SS4 Upgrade
2 parents 96c94ac + b9aded5 commit 9b97827

21 files changed

+1026
-887
lines changed

.editorconfig

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# For more information about the properties used in
2+
# this file, please see the EditorConfig documentation:
3+
# http://editorconfig.org/
4+
5+
[*]
6+
charset = utf-8
7+
end_of_line = lf
8+
indent_size = 4
9+
indent_style = space
10+
insert_final_newline = true
11+
trim_trailing_whitespace = true
12+
13+
[*.md]
14+
trim_trailing_whitespace = false
15+
16+
[*.yml]
17+
indent_size = 2
18+
indent_style = space
19+
20+
[*.{yml,json}]
21+
# The indent size used in the `package.json` file cannot be changed
22+
# https://github.com/npm/npm/pull/3180#issuecomment-16336516
23+
indent_size = 2
24+
indent_style = space

_config.php

Lines changed: 0 additions & 3 deletions
This file was deleted.

_config/decisiontree.yml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
---
22
Name: decisiontree
33
---
4-
LeftAndMain:
4+
SilverStripe\Admin\LeftAndMain:
55
extra_requirements_css:
6-
- silverstripe-elemental-decisiontree/css/decisiontree.leftandmain.css
6+
- dnadesign/silverstripe-elemental-decisiontree:css/decisiontree.leftandmain.css
7+
SilverStripe\Control\Controller:
8+
extensions:
9+
- DNADesign\SilverStripeElementalDecisionTree\Extensions\ElementDecisionTreeController

_config/legacy.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
---
2+
Name: decisiontreelegacy
3+
---
4+
SilverStripe\ORM\DatabaseAdmin:
5+
classname_value_remapping:
6+
DecisionTreeAnswer: 'DNADesign\SilverStripeElementalDecisionTree\Model\DecisionTreeAnswer'
7+
DecisionTreeStep: 'DNADesign\SilverStripeElementalDecisionTree\Model\DecisionTreeStep'
8+
DecisionTreeAnswer: 'DNADesign\SilverStripeElementalDecisionTree\Model\DecisionTreeAnswer'

composer.json

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,21 @@
11
{
2-
"name": "dnadesign/silverstripe-elemental-decisiontree",
3-
"description": "Element displaying information in regards to answers given to questions",
4-
"type": "silverstripe-module",
5-
"keywords": ["silverstripe", "element", "elemental", "decision tree"],
6-
"license": "BSD-3-Clause",
7-
"authors": [{
8-
"name": "Alexandre Saelens",
9-
"email": "[email protected]"
10-
}],
11-
"require": {
12-
"dnadesign/silverstripe-elemental": "1.x-dev",
13-
"silvershop/silverstripe-hasonefield": "1.x-dev"
14-
}
2+
"name": "dnadesign/silverstripe-elemental-decisiontree",
3+
"description": "Element displaying information in regards to answers given to questions",
4+
"type": "silverstripe-vendormodule",
5+
"keywords": ["silverstripe", "element", "elemental", "decision tree"],
6+
"license": "BSD-3-Clause",
7+
"authors": [{
8+
"name": "Alexandre Saelens",
9+
"email": "[email protected]"
10+
}],
11+
"extra": {
12+
"expose": [
13+
"css",
14+
"javascript"
15+
]
16+
},
17+
"require": {
18+
"dnadesign/silverstripe-elemental": ">=3",
19+
"silvershop/silverstripe-hasonefield": "3.x-dev"
20+
}
1521
}

javascript/decision-tree.src.js

Lines changed: 60 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -1,65 +1,68 @@
11
(function($) {
22

3-
$(document).ready(function() {
4-
/**
5-
* Submit Step form when selecting an answer
6-
* Adds loading animation to empty "nextstep" div
7-
* Fetch content via ajax
8-
* Insert HTML and update URL
9-
*/
10-
$(document).on( 'change', 'input[name=stepanswerid] ', function() {
11-
var form = $(this).parents('form'),
12-
step = form.parent('.step'),
13-
nextstep_holder = step.find('> .nextstep');
3+
$(document).ready(function() {
4+
/**
5+
* Submit Step form when selecting an answer
6+
* Adds loading animation to empty "nextstep" div
7+
* Fetch content via ajax
8+
* Insert HTML and update URL
9+
*/
10+
$(document).on( 'change', 'input[name=stepanswerid] ', function() {
11+
var form = $(this).parents('form'),
12+
step = form.parent('.step'),
13+
nextstep_holder = step.find('> .nextstep');
1414

15-
nextstep_holder.html('<div class="spinner-holder"><div class="spinner"><span class="sr-only">loading</span></div></div>');
16-
setTimeout(function() {
17-
nextstep_holder.addClass('loading');
18-
}, 100);
15+
nextstep_holder.html('<div class="spinner-holder"><div class="spinner"><span class="sr-only">loading</span></div></div>');
16+
setTimeout(function() {
17+
nextstep_holder.addClass('loading');
18+
}, 100);
1919

20-
$.ajax({
21-
url : form.attr('action'),
22-
type : form.attr('method'),
23-
dataType: 'json',
24-
data : form.serialize(),
25-
success : function( data ) {
26-
nextstep_holder.addClass('new-content-loaded');
27-
nextstep_holder.html(data.html);
28-
window.history.pushState(null, null, data.nexturl);
29-
},
30-
error : function( xhr, err ) {
31-
nextstep_holder.html(xhr.responseText);
32-
}
33-
}).always(function() {
34-
setTimeout(function() {
35-
nextstep_holder.removeClass('loading new-content-loaded');
36-
}, 100);
37-
});
38-
});
20+
$.ajax({
21+
url : form.attr('action'),
22+
type : form.attr('method'),
23+
dataType: 'json',
24+
data : form.serialize(),
25+
success : function( data ) {
26+
nextstep_holder.addClass('new-content-loaded');
27+
nextstep_holder.html(data.html);
28+
window.history.pushState(null, null, data.nexturl);
29+
},
30+
error : function( xhr, err ) {
31+
nextstep_holder.html(xhr.responseText);
32+
}
33+
}).always(function() {
34+
setTimeout(function() {
35+
nextstep_holder.removeClass('loading new-content-loaded');
36+
}, 100);
37+
});
38+
});
3939

40-
/**
41-
* Handles the restart button
42-
* Empties all subsequent steps then
43-
* Scroll back to first step then
44-
* Reset url to original page url
45-
*/
46-
$(document).on('click', 'button[data-action="restart-tree"]', function() {
47-
var button = $(this),
48-
firststep = button.parents('.step--first'),
49-
radio = firststep.find('input[type="radio"]'),
50-
tree = firststep.parents('.ElementDecisionTree');
40+
/**
41+
* Handles the restart button
42+
* Empties all subsequent steps then
43+
* Scroll back to first step then
44+
* Reset url to original page url
45+
*/
46+
$(document).on('click', 'button[data-action="restart-tree"]', function() {
47+
var button = $(this),
48+
firststep = button.parents('.step--first'),
49+
radio = firststep.find('input[type="radio"]'),
50+
tree = firststep.parents('.ElementDecisionTree');
5151

52-
if (firststep) {
53-
firststep.find('.nextstep').fadeOut(function() {
54-
$(this).html('').show();
55-
radio.removeAttr('checked');
56-
$('html, body').animate({
57-
scrollTop: $(tree).offset().top - 150
58-
}, 500);
59-
window.history.pushState(null, null, button.data('target'));
60-
});
61-
}
62-
});
52+
if (firststep) {
53+
firststep.find('.nextstep').fadeOut(function() {
54+
$(this).html('').show();
55+
radio.removeAttr('checked');
6356

64-
});
57+
if ($(tree).length > 0) {
58+
$('html, body').animate({
59+
scrollTop: $(tree).offset().top - 150
60+
}, 500);
61+
}
62+
63+
window.history.pushState(null, null, button.data('target'));
64+
});
65+
}
66+
});
67+
});
6568
})(jQuery);

src/ElementDecisionTree.php

Lines changed: 0 additions & 179 deletions
This file was deleted.

0 commit comments

Comments
 (0)