diff options
Diffstat (limited to 'tpl/vintage/pluginsadmin.html')
-rw-r--r-- | tpl/vintage/pluginsadmin.html | 73 |
1 files changed, 72 insertions, 1 deletions
diff --git a/tpl/vintage/pluginsadmin.html b/tpl/vintage/pluginsadmin.html index ead1734e..63b45cac 100644 --- a/tpl/vintage/pluginsadmin.html +++ b/tpl/vintage/pluginsadmin.html | |||
@@ -129,6 +129,77 @@ | |||
129 | </div> | 129 | </div> |
130 | {include="page.footer"} | 130 | {include="page.footer"} |
131 | 131 | ||
132 | <script src="inc/plugin_admin.js#"></script> | 132 | <script> |
133 | /** | ||
134 | * Change the position counter of a row. | ||
135 | * | ||
136 | * @param elem Element Node to change. | ||
137 | * @param toPos int New position. | ||
138 | */ | ||
139 | function changePos(elem, toPos) { | ||
140 | var elemName = elem.getAttribute('data-line'); | ||
141 | |||
142 | elem.setAttribute('data-order', toPos); | ||
143 | var hiddenInput = document.querySelector('[name="order_' + elemName + '"]'); | ||
144 | hiddenInput.setAttribute('value', toPos); | ||
145 | } | ||
146 | |||
147 | /** | ||
148 | * Move a row up or down. | ||
149 | * | ||
150 | * @param pos Element Node to move. | ||
151 | * @param move int Move: +1 (down) or -1 (up) | ||
152 | */ | ||
153 | function changeOrder(pos, move) { | ||
154 | var newpos = parseInt(pos) + move; | ||
155 | var lines = document.querySelectorAll('[data-order="' + pos + '"]'); | ||
156 | var changelines = document.querySelectorAll('[data-order="' + newpos + '"]'); | ||
157 | |||
158 | // If we go down reverse lines to preserve the rows order | ||
159 | if (move > 0) { | ||
160 | lines = [].slice.call(lines).reverse(); | ||
161 | } | ||
162 | |||
163 | for (var i = 0; i < lines.length; i++) { | ||
164 | var parent = changelines[0].parentNode; | ||
165 | changePos(lines[i], newpos); | ||
166 | changePos(changelines[i], parseInt(pos)); | ||
167 | var changeItem = move < 0 ? changelines[0] : changelines[changelines.length - 1].nextSibling; | ||
168 | parent.insertBefore(lines[i], changeItem); | ||
169 | } | ||
170 | } | ||
171 | |||
172 | /** | ||
173 | * Move a row up in the table. | ||
174 | * | ||
175 | * @param pos int row counter. | ||
176 | * | ||
177 | * @returns false | ||
178 | */ | ||
179 | function orderUp(pos) { | ||
180 | if (pos == 0) { | ||
181 | return false; | ||
182 | } | ||
183 | changeOrder(pos, -1); | ||
184 | return false; | ||
185 | } | ||
186 | |||
187 | /** | ||
188 | * Move a row down in the table. | ||
189 | * | ||
190 | * @param pos int row counter. | ||
191 | * | ||
192 | * @returns false | ||
193 | */ | ||
194 | function orderDown(pos) { | ||
195 | var lastpos = document.querySelector('[data-order]:last-child').getAttribute('data-order'); | ||
196 | if (pos == lastpos) { | ||
197 | return false; | ||
198 | } | ||
199 | |||
200 | changeOrder(pos, +1); | ||
201 | return false; | ||
202 | } | ||
203 | </script> | ||
133 | </body> | 204 | </body> |
134 | </html> | 205 | </html> |