promethee 1.2.2 → 1.2.3
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.
- checksums.yaml +4 -4
- data/app/views/promethee/_edit.html.erb +106 -1
- data/app/views/promethee/edit/_move.html.erb +72 -0
- data/app/views/promethee/edit/_write.html.erb +35 -0
- data/lib/promethee/rails/version.rb +1 -1
- metadata +1 -3
- data/app/assets/javascripts/promethee-edit.js +0 -211
- data/app/assets/javascripts/promethee.js +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a0dc296374c813a4bcc4a553fc5db6b8dfbb0713
|
4
|
+
data.tar.gz: f1a82615609bc4c13c08405838b331aaceb455f4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f8044bfca87fef65222f683a39ae6cb843c90c270ac3c9b8532b6b9e47070c3b043b386f107ec33edcc1e4ec754a67b84f11f4344a34543a0300aef6562f32ef
|
7
|
+
data.tar.gz: 20a8b093c8f55c820f465be847d73030aa587e4111e0f983ced8eb93a8ba5564a1a20aa403761bffe334190d0844ed15e22e96e9a7111056050f0abd5e7e8358
|
@@ -1,6 +1,112 @@
|
|
1
1
|
<%
|
2
2
|
promethee_data = Promethee::Data.new master_data
|
3
3
|
%>
|
4
|
+
|
5
|
+
<script type="text/javascript">
|
6
|
+
var promethee = angular
|
7
|
+
.module('Promethee', ['summernote', 'ngAnimate'])
|
8
|
+
.value('definitions', [])
|
9
|
+
.filter('htmlSafe', ['$sce', function($sce) {
|
10
|
+
return function(val) {
|
11
|
+
return $sce.trustAsHtml(val);
|
12
|
+
};
|
13
|
+
}])
|
14
|
+
.filter('urlSafe', ['$sce', function($sce) {
|
15
|
+
return function(val) {
|
16
|
+
return $sce.trustAsResourceUrl(val);
|
17
|
+
};
|
18
|
+
}])
|
19
|
+
.filter('humanize', function() {
|
20
|
+
return function(val) {
|
21
|
+
val = (val + '').replace(/_/g, ' ').replace(/([A-Z])/g, ' $1').replace(/\s\s+/, ' ').trim();
|
22
|
+
return val[0].toUpperCase() + val.substring(1).toLowerCase();
|
23
|
+
};
|
24
|
+
})
|
25
|
+
.filter('textContentFromHTML', function() {
|
26
|
+
return function(val, distinctParagraphs) {
|
27
|
+
var element = document.createElement('div');
|
28
|
+
element.innerHTML = val;
|
29
|
+
|
30
|
+
if(distinctParagraphs === 'distinctParagraphs') {
|
31
|
+
var paragraphs = element.querySelectorAll('p');
|
32
|
+
for(var i = 0; i < paragraphs.length; i++) paragraphs[i].textContent += ' ';
|
33
|
+
}
|
34
|
+
|
35
|
+
return element.textContent;
|
36
|
+
}
|
37
|
+
})
|
38
|
+
.filter('numberOfCharacters', function() {
|
39
|
+
return function(val) {
|
40
|
+
return val.length;
|
41
|
+
};
|
42
|
+
})
|
43
|
+
.filter('numberOfWords', function() {
|
44
|
+
return function(val) {
|
45
|
+
var words = val
|
46
|
+
.replace(/\bhttps?:\/\/[a-z0-9\-\._]+(?:\/[^\s\n\r]+)?/gi, 'a') // A URL is one word
|
47
|
+
.replace(/\b[a-z0-9\-\._]+@[a-z0-9\-\._]+\.[a-z0-9\-\._]+\b/gi, 'a') // An email is one word
|
48
|
+
.replace(/[^a-z0-9\s\n\r]/gi, ' ')
|
49
|
+
.replace(/[\s\n\r]+/g, ' ')
|
50
|
+
.trim()
|
51
|
+
.split(' ');
|
52
|
+
|
53
|
+
return words[0] === '' ? 0 : words.length;
|
54
|
+
};
|
55
|
+
});
|
56
|
+
|
57
|
+
promethee.controller('PrometheeController', ['$scope', function($scope) {
|
58
|
+
|
59
|
+
// Data (TODO use Adder and probably page definition to init)
|
60
|
+
if ($scope.data === null || $scope.data === '') {
|
61
|
+
$scope.data = {
|
62
|
+
id: '',
|
63
|
+
type: 'page',
|
64
|
+
version: 1,
|
65
|
+
children: []
|
66
|
+
};
|
67
|
+
}
|
68
|
+
|
69
|
+
$scope.promethee = {
|
70
|
+
data: $scope.data,
|
71
|
+
inspected: null,
|
72
|
+
mode: 'write',
|
73
|
+
//mode: 'move',
|
74
|
+
preview: 'desktop',
|
75
|
+
fullscreen: false
|
76
|
+
};
|
77
|
+
|
78
|
+
$scope.inspect = function(component, event) {
|
79
|
+
$scope.promethee.inspected = component;
|
80
|
+
event.stopPropagation();
|
81
|
+
}
|
82
|
+
|
83
|
+
$scope.enablePreview = function() {
|
84
|
+
if (this.promethee.mode === 'preview') return;
|
85
|
+
this.promethee.mode = 'preview';
|
86
|
+
|
87
|
+
var form = document.createElement('form');
|
88
|
+
document.body.appendChild(form);
|
89
|
+
form.method = 'POST';
|
90
|
+
form.action = '/promethee/preview';
|
91
|
+
form.target = 'preview';
|
92
|
+
|
93
|
+
var input = document.createElement('input');
|
94
|
+
input.type = 'text';
|
95
|
+
input.value = JSON.stringify($scope.promethee.data);
|
96
|
+
input.name = 'data';
|
97
|
+
form.appendChild(input);
|
98
|
+
form.submit();
|
99
|
+
document.body.removeChild(form);
|
100
|
+
}
|
101
|
+
|
102
|
+
$scope.remove = function(component, components) {
|
103
|
+
var index = components.indexOf(component);
|
104
|
+
components.splice(index, 1);
|
105
|
+
}
|
106
|
+
|
107
|
+
}]);
|
108
|
+
</script>
|
109
|
+
|
4
110
|
<div
|
5
111
|
id="promethee"
|
6
112
|
class="promethee-edit"
|
@@ -43,4 +149,3 @@ promethee_data = Promethee::Data.new master_data
|
|
43
149
|
<%= render 'promethee/edit/move' %>
|
44
150
|
<%= render 'promethee/edit/preview' %>
|
45
151
|
</div>
|
46
|
-
|
@@ -1,3 +1,75 @@
|
|
1
|
+
|
2
|
+
<script type="text/javascript">
|
3
|
+
promethee
|
4
|
+
.directive('draggable', function() {
|
5
|
+
return {
|
6
|
+
restrict:'A',
|
7
|
+
link: function(scope, element, attrs) {
|
8
|
+
element.draggable({
|
9
|
+
revert: true,
|
10
|
+
revertDuration: 0,
|
11
|
+
scroll: true,
|
12
|
+
refreshPositions: true,
|
13
|
+
cursor: 'move',
|
14
|
+
start: function() {
|
15
|
+
var $elementDragged = $(element[0]);
|
16
|
+
var type = $elementDragged.data('type');
|
17
|
+
$('.promethee-edit__move').addClass('promethee-edit__move--dragging promethee-edit__move--dragging--' + type);
|
18
|
+
|
19
|
+
// The droppable zone immediately before has no use, it would put the object at the same position
|
20
|
+
// FIXME the selector is not correct
|
21
|
+
/*
|
22
|
+
var $droppableBefore = $elementDragged.prev('.promethee-edit__move__draggable').find('.promethee-edit__move__droppable').last();
|
23
|
+
if ($droppableBefore.length === 0) {
|
24
|
+
// For the first child, we look for the previous droppable zone
|
25
|
+
$droppableBefore = $elementDragged.prev('.promethee-edit__move__droppable');
|
26
|
+
}
|
27
|
+
$droppableBefore.addClass('promethee-edit__move__droppable--hidden');
|
28
|
+
*/
|
29
|
+
},
|
30
|
+
stop: function() {
|
31
|
+
var $elementDragged = $(element[0]);
|
32
|
+
var type = $elementDragged.data('type');
|
33
|
+
$('.promethee-edit__move').removeClass('promethee-edit__move--dragging promethee-edit__move--dragging--' + type);
|
34
|
+
// $('.promethee-edit__move__droppable').removeClass('promethee-edit__move__droppable--hidden');
|
35
|
+
}
|
36
|
+
});
|
37
|
+
}
|
38
|
+
}
|
39
|
+
})
|
40
|
+
.directive('droppable', function($compile) {
|
41
|
+
return {
|
42
|
+
restrict: 'A',
|
43
|
+
link: function(scope, element, attrs) {
|
44
|
+
element.droppable({
|
45
|
+
tolerance: 'pointer',
|
46
|
+
drop: function(event, ui) {
|
47
|
+
var draggedFromList = angular.element(ui.draggable).parent().scope().components;
|
48
|
+
var draggedFromIndex = parseInt(ui.draggable[0].getAttribute('data-index'));
|
49
|
+
// console.log('dragged', draggedFromList, draggedFromIndex);
|
50
|
+
draggedFromList.splice(draggedFromIndex, 1);
|
51
|
+
|
52
|
+
var component = angular.element(ui.draggable).scope().component;
|
53
|
+
var droppedToList = angular.element(this).scope().components;
|
54
|
+
var droppedToIndex = parseInt(this.getAttribute('data-index'));
|
55
|
+
if (draggedFromList == droppedToList) {
|
56
|
+
// The object we dragged was removed from the list
|
57
|
+
if (draggedFromIndex < droppedToIndex) {
|
58
|
+
// It was before the dropped index, so removing it changed the index
|
59
|
+
droppedToIndex -= 1;
|
60
|
+
}
|
61
|
+
}
|
62
|
+
// console.log('dropped', component, droppedToList, droppedToIndex);
|
63
|
+
droppedToList.splice(droppedToIndex, 0, component);
|
64
|
+
|
65
|
+
scope.$apply();
|
66
|
+
}
|
67
|
+
});
|
68
|
+
}
|
69
|
+
}
|
70
|
+
});
|
71
|
+
</script>
|
72
|
+
|
1
73
|
<div class="promethee-edit__move" ng-show="promethee.mode == 'move'">
|
2
74
|
<div class="promethee-edit__move__columns row">
|
3
75
|
<% 12.times do %>
|
@@ -1,3 +1,38 @@
|
|
1
|
+
<script type="text/javascript">
|
2
|
+
promethee.controller('AdderController', ['$scope', '$rootScope', 'definitions', function($scope, $rootScope, definitions) {
|
3
|
+
|
4
|
+
$scope.adding = false;
|
5
|
+
$scope.childrenToAddTo = null;
|
6
|
+
$scope.definitions = definitions;
|
7
|
+
|
8
|
+
$scope.close = function() {
|
9
|
+
$scope.adding = false;
|
10
|
+
$scope.addingToChildren = null;
|
11
|
+
};
|
12
|
+
|
13
|
+
$scope.pushComponent = function(definition) {
|
14
|
+
var definition = angular.copy(definition.data);
|
15
|
+
definition.id = $scope.createIdentifier();
|
16
|
+
$scope.childrenToAddTo.push(definition);
|
17
|
+
$scope.close();
|
18
|
+
};
|
19
|
+
|
20
|
+
$rootScope.addComponentTo = function(components) {
|
21
|
+
$scope.adding = true;
|
22
|
+
$scope.childrenToAddTo = components;
|
23
|
+
};
|
24
|
+
|
25
|
+
// https://gist.github.com/gordonbrander/2230317
|
26
|
+
$scope.createIdentifier = function () {
|
27
|
+
// Math.random should be unique because of its seeding algorithm.
|
28
|
+
// Convert it to base 36 (numbers + letters), and grab the first 9 characters
|
29
|
+
// after the decimal.
|
30
|
+
return '' + Math.random().toString(36).substr(2, 9);
|
31
|
+
};
|
32
|
+
|
33
|
+
}])
|
34
|
+
</script>
|
35
|
+
|
1
36
|
<div class="promethee-edit__write" ng-show="promethee.mode == 'write'">
|
2
37
|
<div ng-class="{ 'container-fluid': promethee.fullscreen }">
|
3
38
|
<div ng-init="component = promethee.data"
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: promethee
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.2.
|
4
|
+
version: 1.2.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Julien Dargelos
|
@@ -225,8 +225,6 @@ files:
|
|
225
225
|
- app/assets/images/icon-promethee.svg
|
226
226
|
- app/assets/images/logo-promethee-horizontal.svg
|
227
227
|
- app/assets/images/logo-promethee-vertical.svg
|
228
|
-
- app/assets/javascripts/promethee-edit.js
|
229
|
-
- app/assets/javascripts/promethee.js
|
230
228
|
- app/assets/stylesheets/promethee-edit.sass
|
231
229
|
- app/assets/stylesheets/promethee-edit/_move.sass
|
232
230
|
- app/assets/stylesheets/promethee-edit/_preview.sass
|
@@ -1,211 +0,0 @@
|
|
1
|
-
var promethee = angular
|
2
|
-
.module('Promethee', ['summernote', 'ngAnimate'])
|
3
|
-
.value('definitions', [])
|
4
|
-
// What does the next 3 lines do? Why?
|
5
|
-
.config(function($rootScopeProvider) {
|
6
|
-
$rootScopeProvider.digestTtl(20);
|
7
|
-
})
|
8
|
-
.filter('htmlSafe', ['$sce', function($sce) {
|
9
|
-
return function(val) {
|
10
|
-
return $sce.trustAsHtml(val);
|
11
|
-
};
|
12
|
-
}])
|
13
|
-
.filter('urlSafe', ['$sce', function($sce) {
|
14
|
-
return function(val) {
|
15
|
-
return $sce.trustAsResourceUrl(val);
|
16
|
-
};
|
17
|
-
}])
|
18
|
-
.filter('humanize', function() {
|
19
|
-
return function(val) {
|
20
|
-
val = (val + '').replace(/_/g, ' ').replace(/([A-Z])/g, ' $1').replace(/\s\s+/, ' ').trim();
|
21
|
-
return val[0].toUpperCase() + val.substring(1).toLowerCase();
|
22
|
-
};
|
23
|
-
})
|
24
|
-
.filter('textContentFromHTML', function() {
|
25
|
-
return function(val, distinctParagraphs) {
|
26
|
-
var element = document.createElement('div');
|
27
|
-
element.innerHTML = val;
|
28
|
-
|
29
|
-
if(distinctParagraphs === 'distinctParagraphs') {
|
30
|
-
var paragraphs = element.querySelectorAll('p');
|
31
|
-
for(var i = 0; i < paragraphs.length; i++) paragraphs[i].textContent += ' ';
|
32
|
-
}
|
33
|
-
|
34
|
-
return element.textContent;
|
35
|
-
}
|
36
|
-
})
|
37
|
-
.filter('numberOfCharacters', function() {
|
38
|
-
return function(val) {
|
39
|
-
return val.length;
|
40
|
-
};
|
41
|
-
})
|
42
|
-
.filter('numberOfWords', function() {
|
43
|
-
return function(val) {
|
44
|
-
var words = val
|
45
|
-
.replace(/\bhttps?:\/\/[a-z0-9\-\._]+(?:\/[^\s\n\r]+)?/gi, 'a') // A URL is one word
|
46
|
-
.replace(/\b[a-z0-9\-\._]+@[a-z0-9\-\._]+\.[a-z0-9\-\._]+\b/gi, 'a') // An email is one word
|
47
|
-
.replace(/[^a-z0-9\s\n\r]/gi, ' ')
|
48
|
-
.replace(/[\s\n\r]+/g, ' ')
|
49
|
-
.trim()
|
50
|
-
.split(' ');
|
51
|
-
|
52
|
-
return words[0] === '' ? 0 : words.length;
|
53
|
-
};
|
54
|
-
});
|
55
|
-
|
56
|
-
promethee.controller('PrometheeController', ['$scope', 'definitions', '$http', function($scope, definitions, $http) {
|
57
|
-
|
58
|
-
// Data (TODO use Adder and probably page definition to init)
|
59
|
-
if($scope.data === null || $scope.data === '') {
|
60
|
-
$scope.data = {
|
61
|
-
id: '',
|
62
|
-
type: 'page',
|
63
|
-
version: 1,
|
64
|
-
children: []
|
65
|
-
};
|
66
|
-
}
|
67
|
-
|
68
|
-
$scope.promethee = {
|
69
|
-
data: $scope.data,
|
70
|
-
inspected: null,
|
71
|
-
mode: 'write',
|
72
|
-
//mode: 'move',
|
73
|
-
preview: 'desktop',
|
74
|
-
fullscreen: false
|
75
|
-
};
|
76
|
-
|
77
|
-
$scope.inspect = function(component, event) {
|
78
|
-
$scope.promethee.inspected = component;
|
79
|
-
event.stopPropagation();
|
80
|
-
}
|
81
|
-
|
82
|
-
$scope.enablePreview = function() {
|
83
|
-
if (this.promethee.mode === 'preview') return;
|
84
|
-
this.promethee.mode = 'preview';
|
85
|
-
|
86
|
-
var form = document.createElement('form');
|
87
|
-
document.body.appendChild(form);
|
88
|
-
form.method = 'POST';
|
89
|
-
form.action = '/promethee/preview';
|
90
|
-
form.target = 'preview';
|
91
|
-
|
92
|
-
var input = document.createElement('input');
|
93
|
-
input.type = 'text';
|
94
|
-
input.value = JSON.stringify($scope.promethee.data);
|
95
|
-
input.name = 'data';
|
96
|
-
form.appendChild(input);
|
97
|
-
form.submit();
|
98
|
-
document.body.removeChild(form);
|
99
|
-
}
|
100
|
-
|
101
|
-
$scope.remove = function(component, components) {
|
102
|
-
var index = components.indexOf(component);
|
103
|
-
components.splice(index, 1);
|
104
|
-
}
|
105
|
-
|
106
|
-
}]);
|
107
|
-
|
108
|
-
|
109
|
-
promethee.controller('AdderController', ['$scope', '$rootScope', 'definitions', function($scope, $rootScope, definitions) {
|
110
|
-
|
111
|
-
$scope.adding = false;
|
112
|
-
$scope.childrenToAddTo = null;
|
113
|
-
$scope.definitions = definitions;
|
114
|
-
|
115
|
-
$scope.close = function() {
|
116
|
-
$scope.adding = false;
|
117
|
-
$scope.addingToChildren = null;
|
118
|
-
};
|
119
|
-
|
120
|
-
$scope.pushComponent = function(definition) {
|
121
|
-
var definition = angular.copy(definition.data);
|
122
|
-
definition.id = $scope.createIdentifier();
|
123
|
-
$scope.childrenToAddTo.push(definition);
|
124
|
-
$scope.close();
|
125
|
-
};
|
126
|
-
|
127
|
-
$rootScope.addComponentTo = function(components) {
|
128
|
-
$scope.adding = true;
|
129
|
-
$scope.childrenToAddTo = components;
|
130
|
-
};
|
131
|
-
|
132
|
-
// https://gist.github.com/gordonbrander/2230317
|
133
|
-
$scope.createIdentifier = function () {
|
134
|
-
// Math.random should be unique because of its seeding algorithm.
|
135
|
-
// Convert it to base 36 (numbers + letters), and grab the first 9 characters
|
136
|
-
// after the decimal.
|
137
|
-
return '' + Math.random().toString(36).substr(2, 9);
|
138
|
-
};
|
139
|
-
|
140
|
-
}])
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
promethee
|
145
|
-
.directive('draggable', function() {
|
146
|
-
return {
|
147
|
-
restrict:'A',
|
148
|
-
link: function(scope, element, attrs) {
|
149
|
-
element.draggable({
|
150
|
-
revert: true,
|
151
|
-
revertDuration: 0,
|
152
|
-
scroll: true,
|
153
|
-
refreshPositions: true,
|
154
|
-
cursor: 'move',
|
155
|
-
start: function() {
|
156
|
-
var $elementDragged = $(element[0]);
|
157
|
-
var type = $elementDragged.data('type');
|
158
|
-
$('.promethee-edit__move').addClass('promethee-edit__move--dragging promethee-edit__move--dragging--' + type);
|
159
|
-
|
160
|
-
// The droppable zone immediately before has no use, it would put the object at the same position
|
161
|
-
// FIXME the selector is not correct
|
162
|
-
/*
|
163
|
-
var $droppableBefore = $elementDragged.prev('.promethee-edit__move__draggable').find('.promethee-edit__move__droppable').last();
|
164
|
-
if ($droppableBefore.length === 0) {
|
165
|
-
// For the first child, we look for the previous droppable zone
|
166
|
-
$droppableBefore = $elementDragged.prev('.promethee-edit__move__droppable');
|
167
|
-
}
|
168
|
-
$droppableBefore.addClass('promethee-edit__move__droppable--hidden');
|
169
|
-
*/
|
170
|
-
},
|
171
|
-
stop: function() {
|
172
|
-
var $elementDragged = $(element[0]);
|
173
|
-
var type = $elementDragged.data('type');
|
174
|
-
$('.promethee-edit__move').removeClass('promethee-edit__move--dragging promethee-edit__move--dragging--' + type);
|
175
|
-
// $('.promethee-edit__move__droppable').removeClass('promethee-edit__move__droppable--hidden');
|
176
|
-
}
|
177
|
-
});
|
178
|
-
}
|
179
|
-
}
|
180
|
-
})
|
181
|
-
.directive('droppable', function($compile) {
|
182
|
-
return {
|
183
|
-
restrict: 'A',
|
184
|
-
link: function(scope, element, attrs) {
|
185
|
-
element.droppable({
|
186
|
-
tolerance: 'pointer',
|
187
|
-
drop: function(event, ui) {
|
188
|
-
var draggedFromList = angular.element(ui.draggable).parent().scope().components;
|
189
|
-
var draggedFromIndex = parseInt(ui.draggable[0].getAttribute('data-index'));
|
190
|
-
// console.log('dragged', draggedFromList, draggedFromIndex);
|
191
|
-
draggedFromList.splice(draggedFromIndex, 1);
|
192
|
-
|
193
|
-
var component = angular.element(ui.draggable).scope().component;
|
194
|
-
var droppedToList = angular.element(this).scope().components;
|
195
|
-
var droppedToIndex = parseInt(this.getAttribute('data-index'));
|
196
|
-
if (draggedFromList == droppedToList) {
|
197
|
-
// The object we dragged was removed from the list
|
198
|
-
if (draggedFromIndex < droppedToIndex) {
|
199
|
-
// It was before the dropped index, so removing it changed the index
|
200
|
-
droppedToIndex -= 1;
|
201
|
-
}
|
202
|
-
}
|
203
|
-
// console.log('dropped', component, droppedToList, droppedToIndex);
|
204
|
-
droppedToList.splice(droppedToIndex, 0, component);
|
205
|
-
|
206
|
-
scope.$apply();
|
207
|
-
}
|
208
|
-
});
|
209
|
-
}
|
210
|
-
}
|
211
|
-
});
|
File without changes
|