From 6840ad362e6e56df429e55ea8cecb85d6af5dab6 Mon Sep 17 00:00:00 2001 From: macuser Date: Fri, 27 Sep 2013 01:38:26 +0200 Subject: [PATCH 1/4] =?UTF-8?q?Taxe=20Rules=20:=20Modification=20du=20java?= =?UTF-8?q?script=20Drag=20&=20Drop=20pour=20ordonner=20les=20e=CC=81le?= =?UTF-8?q?=CC=81ments.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- templates/admin/default/tax-rule-edit.html | 202 +++++++++++++-------- 1 file changed, 123 insertions(+), 79 deletions(-) diff --git a/templates/admin/default/tax-rule-edit.html b/templates/admin/default/tax-rule-edit.html index 1bf6346d1..748482016 100644 --- a/templates/admin/default/tax-rule-edit.html +++ b/templates/admin/default/tax-rule-edit.html @@ -21,10 +21,10 @@
{intl l="Edit tax rule $TITLE"} -
- + +
- +
@@ -39,14 +39,14 @@
- +

{intl l="Countries that have the same tax rule"} :

Italy England Japan

- +
@@ -57,12 +57,12 @@

--> -
+

Create a tax rule

- +

@@ -84,7 +84,7 @@

-
+

List of taxes

@@ -93,7 +93,7 @@
Dapibus ac facilisis in
Morbi leo risus
Porta ac consectetur ac
-
Vestibulum at eros
+
Vestibulum at eros
- +
@@ -114,7 +114,7 @@ {/block} {block name="javascript-initialization"} - + {javascripts file='assets/js/bootstrap-select/bootstrap-select.js'} {/javascripts} @@ -124,18 +124,22 @@ {/javascripts} + {literal} + {/literal} {/block} \ No newline at end of file From a82d671d4ae01f4a30e2a1f0334aaf85db0ce053 Mon Sep 17 00:00:00 2001 From: touffies Date: Fri, 27 Sep 2013 11:59:35 +0200 Subject: [PATCH 2/4] Change dragging containment --- templates/admin/default/tax-rule-edit.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/admin/default/tax-rule-edit.html b/templates/admin/default/tax-rule-edit.html index 748482016..9794d37a6 100644 --- a/templates/admin/default/tax-rule-edit.html +++ b/templates/admin/default/tax-rule-edit.html @@ -154,7 +154,7 @@ $('.draggable', $list).draggable({ cursor: 'move', helper: 'clone', - //containment: "document", + containment: "document", opacity: 0.5, revert: "invalid", // when not dropped, the item will revert back to its initial position zIndex: 10 From bce83ea5c01e70083458c12a098c63a7b92344a3 Mon Sep 17 00:00:00 2001 From: touffies Date: Fri, 27 Sep 2013 12:32:16 +0200 Subject: [PATCH 3/4] Test commit with coda --- templates/admin/default/tax-rule-edit.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/admin/default/tax-rule-edit.html b/templates/admin/default/tax-rule-edit.html index 9794d37a6..f424cda75 100644 --- a/templates/admin/default/tax-rule-edit.html +++ b/templates/admin/default/tax-rule-edit.html @@ -265,7 +265,7 @@ } }); }); - // --> + // --> {/literal} From cbf0d19dcdd5dbc9d7066c5ad02a42cb654c1bac Mon Sep 17 00:00:00 2001 From: touffies Date: Fri, 27 Sep 2013 17:23:08 +0200 Subject: [PATCH 4/4] =?UTF-8?q?Refonte=20du=20code=20javascript=20pour=20m?= =?UTF-8?q?ieux=20ge=CC=81rer=20le=20drag=20and=20drop,=20maintenant=20il?= =?UTF-8?q?=20faudrait=20ajouter=20un=20peu=20de=20css.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- templates/admin/default/tax-rule-edit.html | 136 ++++++++------------- 1 file changed, 48 insertions(+), 88 deletions(-) diff --git a/templates/admin/default/tax-rule-edit.html b/templates/admin/default/tax-rule-edit.html index f424cda75..013826bb1 100644 --- a/templates/admin/default/tax-rule-edit.html +++ b/templates/admin/default/tax-rule-edit.html @@ -150,121 +150,81 @@ }); }); - // Make the list of taxes draggable - $('.draggable', $list).draggable({ + // Default options for draggable + var dragOptions = { cursor: 'move', - helper: 'clone', containment: "document", opacity: 0.5, revert: "invalid", // when not dropped, the item will revert back to its initial position zIndex: 10 - }); + }; - // Droppable Options - var droppableOptions = { - accept: "#panel-list .draggable", // Controls which draggable elements are accepted - hoverClass: 'over', - drop: function( event, ui ) { - var $current_group = $(this), - $tax = ui.draggable; - - // Move taxes - $tax.fadeOut(function() { - $(this).remove(); - $tax.appendTo( $current_group ).fadeIn(); - - }); + // Default options for sortabble + var sortOptions = { + cursor: 'crosshair', + items: 'div', + update: function( event, ui ){ + // Check if we have an empty group + var $zone = $('.add-to-group', $group); + if($zone.size() > 1 && $(this).find('> div').size() == 0){ // Remove empty group only if we have more than 1 group + $(this).slideUp(function(){ $(this).remove(); }); + } } }; - // let the drop-group be droppable & sortable, accepting the tax items - $('.add-to-group', $group) - .sortable({ // Sort - //axis: 'y', - cursor: 'crosshair', - items: "div", - revert: true, - }).droppable(droppableOptions); - - - // Allow the user to create a new drop-group - $('.create-group', $group) - .droppable({ + // Default options for droppable + var dropOptions = { accept: "#panel-list .draggable", // Controls which draggable elements are accepted - hoverClass: 'over', + hoverClass: "over", drop: function( event, ui ) { - var $tax = ui.draggable; - var $create_group; + var $drop = $(this); - // Check if we have already an empty group - var $empty_group = $group.find('.drop-group:not(:has(> .draggable))'); - if($empty_group.size() > 0){ // if yes (Use the first empty group) - $create_group = $empty_group.filter(':first'); + if($(this).hasClass('create-group')){ + // Check if we have already an empty group + var $empty_group = $group.find('.drop-group:not(:has(> div))'); + if($empty_group.size() > 0){ // if yes (Use the first empty group) + $drop = $empty_group.filter(':first'); + }else{ //if no (Create a new group) + $drop = $group.find('.drop-group:last-child').clone().appendTo($group.find('.panel-body')); - // Move taxes - $tax.fadeOut(function() { - $(this).remove(); - $tax.appendTo( $create_group ).show(); - $group.find('.panel-body').append($create_group); - }); + // Remove taxes + $drop.find('> div').remove(); - }else{ //if no (Create a new group) - $create_group = $group.find('.drop-group:last-child').clone(); - - // Remove taxes - $create_group.find('.draggable').remove(); - - // Make the new group droppable - $create_group - .sortable({ // Sort - //axis: 'y', - cursor: 'crosshair', - items: "div", - revert: true, - }) - .droppable(droppableOptions); - - // Move taxes - $tax.fadeOut(function() { - $(this).remove(); - $tax.appendTo( $create_group ).show(); - $group.find('.panel-body').append($create_group); - }); + // Make the new group droppable + $drop + .droppable(dropOptions) + .sortable(sortOptions); + } } + $("
").addClass('drag').text( ui.draggable.text() ).appendTo( $drop ); + ui.draggable.remove(); } - }); + }; - // let the gallery be droppable as well, accepting items from the trash + // Make the list of taxes draggable + $('.draggable', $list).draggable(dragOptions); + + + // let the drop-group be droppable & sortable, accepting the tax items + $('.droppable', $group) + .droppable(dropOptions) + .sortable(sortOptions); + + // let the gallery be droppable as well, accepting items from the trash $('.remove-from-group', $list) .droppable({ - accept: "#panel .draggable", + accept: "#panel .drag", hoverClass: 'over', drop: function( event, ui ) { - var $tax = ui.draggable.clone(); ui.draggable.remove(); - // Move taxes - $tax.fadeOut(function() { - //$(this).remove(); - $tax.removeClass('ui-sortable-helper').addClass('ui-draggable').removeAttr('style').draggable({ - cursor: 'move', - helper: 'clone', - //containment: "document", - opacity: 0.5, - revert: "invalid", // when not dropped, the item will revert back to its initial position - zIndex: 10 - }).prependTo( $list.find('.panel-body') ).fadeIn(); + $("
").addClass('draggable').text( ui.draggable.text() ).draggable(dragOptions).appendTo( $list.find('.panel-body') ); + ui.draggable.remove(); - // Check if we have an empty group - var $zone = $('.add-to-group', $group); - var $empty_zone = $zone.filter(':not(:has(> .draggable))'); - if($zone.size() > $empty_zone.size()){ // Remove empty group only if we have more than 1 group - $empty_zone.slideUp(function(){ $(this).remove(); }); - } - }); } }); }); + // --> {/literal}