Skip to content
Browse files

JS reordering of rules

  • Loading branch information...
1 parent 3aa1051 commit 746dc3315be9a34a33514584ad169ee84a40692f @cargowire committed Mar 29, 2012
Showing with 30 additions and 2 deletions.
  1. +30 −2 rule-based-themes-settings.php
View
32 rule-based-themes-settings.php
@@ -24,6 +24,7 @@
#rule-table > tbody > tr:nth-child(4n+1), #rule-table > tbody > tr:nth-child(4n+2) {background: rgba(243,238,233,0.25);}
#rule-table > tbody > tr:nth-child(4n+3), #rule-table > tbody > tr:nth-child(4n+4) {background: rgba(180, 188, 84,0.15);}
+ #rule-table .up, #rule-table .down { background:transparent;border:none; }
#rule-table .deleterule, #rule-table .delete {width: 20px; height: 20px; border: 0; background: #dd4444; border-radius: 10px; color: #fff; font-size: 10px; font-weight: bold; box-shadow: 1px 1px 5px rgba(0,0,0,0.2); line-height: 30px; text-transform: uppercase; cursor: pointer; text-indent:-9999px}
#rule-table .delete {width: 14px; height: 14px; font-size: 7px;}
#rule-table .deleterule:hover, #rule-table .delete:hover {background: #ee5555;}
@@ -59,6 +60,25 @@
rbtme.rules.save(json);
e.preventDefault();
});
+ $('#rule-table').on('click', '.up', function(e){
+ var row = $(this).parents('tr:first');
+ var actions = row.next('tr');
+ var prevActions = row.prev('tr');
+ var prev = prevActions.prev('tr');
+ if(prev.length)
+ actions.after(prevActions).after(prev);
+ e.preventDefault();
+ });
+ $('#rule-table').on('click', '.down', function(e){
+ var row = $(this).parents('tr:first');
+ var actions = row.next('tr');
+ var next = actions.next('tr');
+ var nextActions = next.next('tr');
+
+ if(nextActions.length)
+ nextActions.after(actions).after(row);
+ e.preventDefault();
+ });
$('#rule-table').on('click', '.delete', function(e){
$(this).parents('table:first').remove();
e.preventDefault();
@@ -136,7 +156,11 @@ function(data) {
</script>
<script type="text/html" id="rule-form">
<tr class="rule">
- <td><button class="deleterule">x</button></td>
+ <td>
+ <button class="deleterule">x</button>
+ <button class="up">&#9650;</button>
+ <button class="down">&#9660;</button>
+ </td>
<td>
<input type="text" name="rulekey" required="required" pattern="^[a-zA-Z0-9\-\s]*$" placeholder="Rule name" value=""/><br/>
<input type="text" name="display" pattern="^[a-zA-Z0-9\-\s]*$" placeholder="Display" value=""/>
@@ -228,7 +252,11 @@ function(data) {
foreach ($rbtme_rules as $rulekey => $parentRule):
?>
<tr class="rule">
- <td><button class="deleterule">x</button></td>
+ <td>
+ <button class="deleterule">x</button>
+ <button class="up">&#9650;</button>
+ <button class="down">&#9660;</button>
+ </td>
<td>
<input type="text" name="rulekey" required="required" pattern="^[a-zA-Z0-9\-\s]*$" placeholder="Rule name" value="<?php echo $rulekey; ?>"/><br/>
<input type="text" name="display" pattern="^[a-zA-Z0-9\-\s]*$" placeholder="Display" value="<?php echo $parentRule["display"]; ?>"/>

0 comments on commit 746dc33

Please sign in to comment.
Something went wrong with that request. Please try again.