activeadmin_ancestry_view 0.0.4 → 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ed828e32cb98a33fc8d20672a7404bc60ce20c0e
4
- data.tar.gz: a21e3e1b3b978f29c7cd58041c674fbf3965c4a5
3
+ metadata.gz: 49910ef703bdcec99abb4da3ecc636583e2bf260
4
+ data.tar.gz: dedb7a126398b4d4069b3d834cc54f29216ab681
5
5
  SHA512:
6
- metadata.gz: a40ef5ac7146d3dd67519c1ac1863b6ee981bb711499a72ff4b288d21f67e433b0ab5df388eb44db3c2db7fad2b19a9ce2df2ac18f238b170c4aa818a91c8a3e
7
- data.tar.gz: 4d67bcf33aca393596735c56c941b11da54615b2f2cbc2a6cdf7f6907e23d5d3809a063227ad45347251b9e41448aa21453420e92d65377830b8a2b8b3bf00c4
6
+ metadata.gz: d13c367cc49edd4cda4aeeb668df9e50123eacfbd68e8542898d3e98ea75df88b75fbf0a3e68a0fabfbc40e697b935f536e8e7e58e008a27c21fa96427b7f9ee
7
+ data.tar.gz: 7392a7fabd0df4fd185adb3c6bb6adec0894ed4b3cea119834b865a5514d9581fe6c04dcc7f8827da7fe47d3db86bdc25c5134c047474756de25718386c9794d
@@ -1,239 +1,244 @@
1
- $(document).ready(function() {
2
- var CSSRule, branchProp, clearAllColors, distance, findPanelHeader, getElements, pseudoElement, similarItems;
3
- CSSRule = {
4
- get: function(ruleName, deleteFlag) {
5
- var cssRule, i, ii, styleSheet;
6
- ruleName = ruleName.toLowerCase();
7
- if (document.styleSheets) {
8
- i = 0;
9
- while (i < document.styleSheets.length) {
10
- styleSheet = document.styleSheets[i];
11
- ii = 0;
12
- cssRule = false;
13
- while (true) {
14
- if (styleSheet.cssRules) {
15
- cssRule = styleSheet.cssRules[ii];
16
- } else {
17
- cssRule = styleSheet.rules[ii];
18
- }
19
- if (cssRule) {
20
- if (cssRule.selectorText.toLowerCase() === ruleName) {
21
- if (deleteFlag === 'delete') {
22
- if (styleSheet.cssRules) {
23
- styleSheet.deleteRule(ii);
1
+ (function() {
2
+ var __indexOf = [].indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; };
3
+
4
+ $(document).ready(function() {
5
+ var CSSRule, branchProp, clearAllColors, distance, findPanelHeader, getElements, pseudoElement, similarItems;
6
+ CSSRule = {
7
+ get: function(ruleName, deleteFlag) {
8
+ var cssRule, i, ii, styleSheet;
9
+ ruleName = ruleName.toLowerCase();
10
+ if (document.styleSheets) {
11
+ i = 0;
12
+ while (i < document.styleSheets.length) {
13
+ styleSheet = document.styleSheets[i];
14
+ ii = 0;
15
+ cssRule = false;
16
+ while (true) {
17
+ if (styleSheet.cssRules) {
18
+ cssRule = styleSheet.cssRules[ii];
19
+ } else {
20
+ cssRule = styleSheet.rules[ii];
21
+ }
22
+ if (cssRule) {
23
+ if (cssRule.selectorText.toLowerCase() === ruleName) {
24
+ if (deleteFlag === 'delete') {
25
+ if (styleSheet.cssRules) {
26
+ styleSheet.deleteRule(ii);
27
+ } else {
28
+ styleSheet.removeRule(ii);
29
+ }
30
+ return true;
24
31
  } else {
25
- styleSheet.removeRule(ii);
32
+ return cssRule;
26
33
  }
27
- return true;
28
- } else {
29
- return cssRule;
30
34
  }
31
35
  }
36
+ ii++;
37
+ if (!cssRule) {
38
+ break;
39
+ }
32
40
  }
33
- ii++;
34
- if (!cssRule) {
35
- break;
36
- }
41
+ i++;
37
42
  }
38
- i++;
39
43
  }
40
- }
41
- return false;
42
- },
43
- add: function(ruleName, properies) {
44
- if (document.styleSheets) {
45
- if (!this.get(ruleName)) {
46
- if (document.styleSheets[0].addRule) {
47
- return document.styleSheets[0].addRule(ruleName, properies, 0);
48
- } else {
49
- return document.styleSheets[0].insertRule(ruleName + (" { " + properies + " }"), 0);
44
+ return false;
45
+ },
46
+ add: function(ruleName, properies) {
47
+ if (document.styleSheets) {
48
+ if (!this.get(ruleName)) {
49
+ if (document.styleSheets[0].addRule) {
50
+ return document.styleSheets[0].addRule(ruleName, properies, 0);
51
+ } else {
52
+ return document.styleSheets[0].insertRule(ruleName + (" { " + properies + " }"), 0);
53
+ }
50
54
  }
51
55
  }
52
56
  }
53
- }
54
- };
55
- distance = {
56
- middleHeight: function(node) {
57
- return Math.abs($(node).height() / 2);
58
- },
59
- betweenTop: function(sourceNode, targetNode) {
60
- return Math.abs($(sourceNode).offset().top - $(targetNode).offset().top);
61
- },
62
- verticalBranch: function(node, lastChild) {
63
- return this.betweenTop(node, lastChild) + this.middleHeight(lastChild);
64
- }
65
- };
66
- branchProp = {
67
- baseMargin: 2,
68
- base: "transition: 150ms ease; " + "content: ''; " + "position: absolute; " + "border: 0.1em solid gray; ",
69
- vertical: function(height) {
70
- return ("margin-left: " + this.baseMargin + "em; ") + ("height: " + height + "px; ") + "z-index: -1; " + this.base;
71
- },
72
- horizontal: function(marginTop, marginLeft) {
73
- return ("margin-top: -" + marginTop + "px; ") + ("margin-left: -" + (marginLeft - this.baseMargin) + "em; ") + ("width: " + (marginLeft - this.baseMargin) + "em; ") + "z-index: -2; " + this.base;
74
- }
75
- };
76
- pseudoElement = {
77
- addHorizontal: function(node) {
78
- var height, id, marginLeft;
79
- id = $(node).attr('id');
80
- height = distance.middleHeight(node);
81
- marginLeft = $(node).attr('data-shift-multiplicator');
82
- return CSSRule.add("[id='" + id + "']::after", branchProp.horizontal(height, marginLeft));
83
- },
84
- addVertical: function(node, purposeNode) {
85
- var dist, id;
86
- dist = distance.verticalBranch(node, purposeNode);
87
- id = $(node).attr('id');
88
- return CSSRule.add("[id='" + id + "']::before", branchProp.vertical(dist));
89
- },
90
- updHorizontal: function(node) {
91
- var id, line, newHeight;
92
- if ($(node).hasClass('panel-root')) {
93
- return false;
94
- } else {
57
+ };
58
+ distance = {
59
+ middleHeight: function(node) {
60
+ return Math.abs($(node).height() / 2);
61
+ },
62
+ betweenTop: function(sourceNode, targetNode) {
63
+ return Math.abs($(sourceNode).offset().top - $(targetNode).offset().top);
64
+ },
65
+ verticalBranch: function(node, lastChild) {
66
+ return this.betweenTop(node, lastChild) + this.middleHeight(lastChild);
67
+ }
68
+ };
69
+ branchProp = {
70
+ baseMargin: 2,
71
+ base: "transition: 150ms ease; " + "content: ''; " + "position: absolute; " + "border: 0.1em solid gray; ",
72
+ vertical: function(height) {
73
+ return ("margin-left: " + this.baseMargin + "em; ") + ("height: " + height + "px; ") + "z-index: -1; " + this.base;
74
+ },
75
+ horizontal: function(marginTop, marginLeft) {
76
+ return ("margin-top: -" + marginTop + "px; ") + ("margin-left: -" + (marginLeft - this.baseMargin) + "em; ") + ("width: " + (marginLeft - this.baseMargin) + "em; ") + "z-index: -2; " + this.base;
77
+ }
78
+ };
79
+ pseudoElement = {
80
+ addHorizontal: function(node) {
81
+ var height, id, marginLeft;
82
+ id = $(node).attr('id');
83
+ height = distance.middleHeight(node);
84
+ marginLeft = $(node).attr('data-shift-multiplicator');
85
+ return CSSRule.add("[id='" + id + "']::after", branchProp.horizontal(height, marginLeft));
86
+ },
87
+ addVertical: function(node, purposeNode) {
88
+ var dist, id;
89
+ dist = distance.verticalBranch(node, purposeNode);
95
90
  id = $(node).attr('id');
96
- newHeight = -Math.abs(distance.middleHeight(node));
97
- line = CSSRule.get('[id="' + id + '"]::after');
98
- return line.style.marginTop = newHeight.toString().concat('px');
91
+ return CSSRule.add("[id='" + id + "']::before", branchProp.vertical(dist));
92
+ },
93
+ updHorizontal: function(node) {
94
+ var id, line, newHeight;
95
+ if ($(node).hasClass('panel-root')) {
96
+ return false;
97
+ } else {
98
+ id = $(node).attr('id');
99
+ newHeight = -Math.abs(distance.middleHeight(node));
100
+ line = CSSRule.get('[id="' + id + '"]::after');
101
+ return line.style.marginTop = newHeight.toString().concat('px');
102
+ }
103
+ },
104
+ updVertical: function(node) {
105
+ var lastChild, line, newDistance, nodeId;
106
+ nodeId = $(node).attr('id');
107
+ lastChild = $(node).parent().find(".panel-container[data-last-child=" + nodeId + "]");
108
+ if ($(lastChild).length) {
109
+ newDistance = distance.verticalBranch(node, lastChild);
110
+ line = CSSRule.get('[id="' + nodeId + '"]::before');
111
+ return line.style.height = newDistance.toString().concat('px');
112
+ }
113
+ },
114
+ updEachVertical: function(node) {
115
+ var actualCollection, actualIds, allParents, nodeClasses, parentIds, that;
116
+ nodeClasses = $(node).attr('class').split(' ');
117
+ allParents = $(node).prevAll('.panel-parent');
118
+ parentIds = $.map(allParents, function(el) {
119
+ return $(el).attr('id');
120
+ });
121
+ actualIds = similarItems(nodeClasses, parentIds);
122
+ actualIds.push($(node).attr('id'));
123
+ actualCollection = getElements(actualIds);
124
+ that = this;
125
+ return $.each(actualCollection, function(i, element) {
126
+ return that.updVertical(element);
127
+ });
99
128
  }
100
- },
101
- updVertical: function(node) {
102
- var lastChild, line, newDistance, nodeId;
103
- nodeId = $(node).attr('id');
104
- lastChild = $(node).parent().find(".panel-container[data-last-child=" + nodeId + "]");
105
- if ($(lastChild).length) {
106
- newDistance = distance.verticalBranch(node, lastChild);
107
- line = CSSRule.get('[id="' + nodeId + '"]::before');
108
- return line.style.height = newDistance.toString().concat('px');
129
+ };
130
+ findPanelHeader = function(object) {
131
+ return object.find('.panel').find('.panel-header');
132
+ };
133
+ clearAllColors = function() {
134
+ $('.panel-header').css('background-color', '');
135
+ return $('.panel-header').each(function() {
136
+ if ($(this).hasClass('selectable')) {
137
+ return $(this).removeClass('selectable');
138
+ }
139
+ });
140
+ };
141
+ similarItems = function(arr1, arr2) {
142
+ var item, _i, _len, _results;
143
+ _results = [];
144
+ for (_i = 0, _len = arr2.length; _i < _len; _i++) {
145
+ item = arr2[_i];
146
+ if (__indexOf.call(arr1, item) >= 0) {
147
+ _results.push(item);
148
+ }
109
149
  }
110
- },
111
- updEachVertical: function(node) {
112
- var actualCollection, actualIds, allParents, nodeClasses, parentIds, that;
113
- nodeClasses = $(node).attr('class').split(' ');
114
- allParents = $(node).prevAll('.panel-parent');
115
- parentIds = $.map(allParents, function(el) {
116
- return $(el).attr('id');
150
+ return _results;
151
+ };
152
+ getElements = function(arrayOfIds) {
153
+ return $.map(arrayOfIds, function(id) {
154
+ return $("#" + id).get();
117
155
  });
118
- actualIds = similarItems(nodeClasses, parentIds);
119
- actualIds.push($(node).attr('id'));
120
- actualCollection = getElements(actualIds);
121
- that = this;
122
- return $.each(actualCollection, function(i, element) {
123
- return that.updVertical(element);
156
+ };
157
+ $('.panel-parent').each(function() {
158
+ var id, parentColor;
159
+ id = $(this).attr('id');
160
+ parentColor = findPanelHeader($(this)).css('background-color');
161
+ return $('.panel-childless').each(function() {
162
+ if ($(this).hasClass(id)) {
163
+ return findPanelHeader($(this)).css('background-color', parentColor);
164
+ }
124
165
  });
125
- }
126
- };
127
- findPanelHeader = function(object) {
128
- return object.find('.panel').find('.panel-header');
129
- };
130
- clearAllColors = function() {
131
- $('.panel-header').css('background-color', '');
132
- return $('.panel-header').each(function() {
133
- if ($(this).hasClass('selectable')) {
134
- return $(this).removeClass('selectable');
135
- }
136
166
  });
137
- };
138
- similarItems = function(arr1, arr2) {
139
- var item, _i, _len, _results;
140
- _results = [];
141
- for (_i = 0, _len = arr2.length; _i < _len; _i++) {
142
- item = arr2[_i];
143
- if (__indexOf.call(arr1, item) >= 0) {
144
- _results.push(item);
167
+ $('.show-content').click(function() {
168
+ var content, node, nodeId, oldNodeHeight, verticalLine;
169
+ node = $(this).parents('.panel-container');
170
+ nodeId = $(node).attr('id');
171
+ content = $(this).parent().next('.panel_contents');
172
+ oldNodeHeight = $(node).height();
173
+ verticalLine = CSSRule.get('[id="' + $(node).attr('id') + '"]::before');
174
+ if (content.is(':hidden')) {
175
+ content.show(0, function() {
176
+ return pseudoElement.updHorizontal(node);
177
+ });
178
+ } else {
179
+ content.hide(0, function() {
180
+ return pseudoElement.updHorizontal(node);
181
+ });
145
182
  }
146
- }
147
- return _results;
148
- };
149
- getElements = function(arrayOfIds) {
150
- return $.map(arrayOfIds, function(id) {
151
- return $("#" + id).get();
183
+ return pseudoElement.updEachVertical(node);
152
184
  });
153
- };
154
- $('.panel-parent').each(function() {
155
- var id, parentColor;
156
- id = $(this).attr('id');
157
- parentColor = findPanelHeader($(this)).css('background-color');
158
- return $('.panel-childless').each(function() {
159
- if ($(this).hasClass(id)) {
160
- return findPanelHeader($(this)).css('background-color', parentColor);
185
+ $('.show-childrens').click(function() {
186
+ var lastChild, lastChildId, nodeContent, nodeId;
187
+ nodeId = $(this).parents('.panel-container').attr('id');
188
+ nodeContent = $(this).parent().next('.panel_contents');
189
+ lastChild = $(".panel-container[data-last-child=" + nodeId + "]");
190
+ lastChildId = $(lastChild).attr('id');
191
+ if (nodeContent.is(':hidden')) {
192
+ nodeContent.show();
193
+ } else {
194
+ nodeContent.hide();
161
195
  }
162
- });
163
- });
164
- $('.show-content').click(function() {
165
- var content, node, nodeId, oldNodeHeight, verticalLine;
166
- node = $(this).parents('.panel-container');
167
- nodeId = $(node).attr('id');
168
- content = $(this).parent().next('.panel_contents');
169
- oldNodeHeight = $(node).height();
170
- verticalLine = CSSRule.get('[id="' + $(node).attr('id') + '"]::before');
171
- if (content.is(':hidden')) {
172
- content.show(0, function() {
173
- return pseudoElement.updHorizontal(node);
174
- });
175
- } else {
176
- content.hide(0, function() {
177
- return pseudoElement.updHorizontal(node);
178
- });
179
- }
180
- return pseudoElement.updEachVertical(node);
181
- });
182
- $('.show-childrens').click(function() {
183
- var lastChild, lastChildId, nodeContent, nodeId;
184
- nodeId = $(this).parents('.panel-container').attr('id');
185
- nodeContent = $(this).parent().next('.panel_contents');
186
- lastChild = $(".panel-container[data-last-child=" + nodeId + "]");
187
- lastChildId = $(lastChild).attr('id');
188
- if (nodeContent.is(':hidden')) {
189
- nodeContent.show();
190
- } else {
191
- nodeContent.hide();
192
- }
193
- $('.panel').each(function() {
194
- var content, subLastChildId, subNode;
195
- subNode = $(this).parent('.panel-container');
196
- if (subNode.hasClass(nodeId)) {
197
- content = $(this).find('.panel_contents');
198
- if (nodeContent.is(':visible')) {
199
- content.show(0, function() {
200
- return pseudoElement.updHorizontal(subNode);
201
- });
202
- } else {
203
- content.hide(0, function() {
204
- return pseudoElement.updHorizontal(subNode);
205
- });
196
+ $('.panel').each(function() {
197
+ var content, subLastChildId, subNode;
198
+ subNode = $(this).parent('.panel-container');
199
+ if (subNode.hasClass(nodeId)) {
200
+ content = $(this).find('.panel_contents');
201
+ if (nodeContent.is(':visible')) {
202
+ content.show(0, function() {
203
+ return pseudoElement.updHorizontal(subNode);
204
+ });
205
+ } else {
206
+ content.hide(0, function() {
207
+ return pseudoElement.updHorizontal(subNode);
208
+ });
209
+ }
210
+ subLastChildId = $(subNode).attr('data-last-child');
211
+ if (subLastChildId != null) {
212
+ return pseudoElement.updVertical($("#" + subLastChildId));
213
+ }
206
214
  }
207
- subLastChildId = $(subNode).attr('data-last-child');
208
- if (subLastChildId != null) {
209
- return pseudoElement.updVertical($("#" + subLastChildId));
215
+ });
216
+ return pseudoElement.updEachVertical(lastChild);
217
+ });
218
+ $('.panel-header').on('click', function() {
219
+ var parentId;
220
+ clearAllColors();
221
+ $(this).addClass('selectable');
222
+ parentId = $(this).parents('.panel-container').attr('id');
223
+ return $('.panel-header').each(function() {
224
+ if (($(this)).parents('.panel-container').hasClass(parentId)) {
225
+ return $(this).addClass('selectable');
210
226
  }
227
+ });
228
+ });
229
+ $('.panel-parent').each(function() {
230
+ var lastChild, nodeId;
231
+ nodeId = $(this).attr('id');
232
+ lastChild = $(this).parent().find(".panel-container[data-last-child=" + nodeId + "]");
233
+ if ($(lastChild).length) {
234
+ return pseudoElement.addVertical(this, lastChild);
211
235
  }
212
236
  });
213
- return pseudoElement.updEachVertical(lastChild);
214
- });
215
- $('.panel-header').on('click', function() {
216
- var parentId;
217
- clearAllColors();
218
- $(this).addClass('selectable');
219
- parentId = $(this).parents('.panel-container').attr('id');
220
- return $('.panel-header').each(function() {
221
- if (($(this)).parents('.panel-container').hasClass(parentId)) {
222
- return $(this).addClass('selectable');
237
+ return $('.panel-container').each(function() {
238
+ if (!$(this).hasClass('panel-root')) {
239
+ return pseudoElement.addHorizontal(this);
223
240
  }
224
241
  });
225
242
  });
226
- $('.panel-parent').each(function() {
227
- var lastChild, nodeId;
228
- nodeId = $(this).attr('id');
229
- lastChild = $(this).parent().find(".panel-container[data-last-child=" + nodeId + "]");
230
- if ($(lastChild).length) {
231
- return pseudoElement.addVertical(this, lastChild);
232
- }
233
- });
234
- return $('.panel-container').each(function() {
235
- if (!$(this).hasClass('panel-root')) {
236
- return pseudoElement.addHorizontal(this);
237
- }
238
- });
239
- });
243
+
244
+ }).call(this);
@@ -1,3 +1,3 @@
1
1
  module ActiveadminAncestryView
2
- VERSION = "0.0.4"
2
+ VERSION = "0.0.5"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: activeadmin_ancestry_view
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dimkarodinz