Index: trunk/packages/ezwt_extension/ezextension/ezwt/design/standard/javascript/ezwtsortdd.js
===================================================================
--- trunk/packages/ezwt_extension/ezextension/ezwt/design/standard/javascript/ezwtsortdd.js	(revision 19)
+++ trunk/packages/ezwt_extension/ezextension/ezwt/design/standard/javascript/ezwtsortdd.js	(working copy)
@@ -1,42 +1,70 @@
 var eZWTSortDD = function() {
     var ret = {};
     
+    ret.enabled = false;
     ret.CONFIG = {};
     
-    var yCallback = function(Y) {
-        Y.get('#ezwt-sort-field').on('change', function(e) {
-            var select = e.target;
-            var selectedIndex = select.get('selectedIndex');
+    var setupSortChangeEvent = function( Y )
+    {
+        Y.get('#ezwt-sort-field').on('change', function( e )
+        {
+            var select = e.target, selectedIndex = select.get('selectedIndex');
 
-            if(select.get('options').item(selectedIndex).get('value') == 8) {
+            if( select.get('options').item(selectedIndex).get('value') == 8 )
+            {
                 Y.get('#ezwt-sort-order').set('disabled', true);
-                
-                if(Y.get('#ezwt-sort-order-asc') === null) {
-                    select.get('parentNode').appendChild(Y.Node.create('<input id="ezwt-sort-order-asc" type="hidden" name="SortingOrder" value="1" />'));
+
+                if ( ret.enabled )
+                {
+                    Y.get('#ezwt-automatic-update-container').removeClass('hide');
+                    if ( !Y.get('#ezwt-automatic-update').get('checked') )
+                        Y.get('#ezwt-update-priority').set('disabled', false).replaceClass('button-disabled', 'button');
                 }
-            } else {
+
+                if( Y.get('#ezwt-sort-order-asc') === null )
+                {
+                    select.get('parentNode').appendChild( Y.Node.create('<input id="ezwt-sort-order-asc" type="hidden" name="SortingOrder" value="1" />') );
+                }
+            }
+            else
+            {
                 Y.get('#ezwt-sort-order').set('disabled', false);
-                
-                if(Y.get('#ezwt-sort-order-asc') !== null) {
+
+                if ( ret.enabled )
+                {
+                    Y.get('#ezwt-automatic-update-container').addClass('hide');
+                    Y.get('#ezwt-update-priority').set('disabled', true).replaceClass('button', 'button-disabled');
+                }
+
+                if(Y.get('#ezwt-sort-order-asc') !== null)
+                {
                     select.get('parentNode').removeChild(Y.get('#ezwt-sort-order-asc'));
                 }
             }
         });
-        
-        Y.get('#ezwt-automatic-update').on('click', function(e) {
-            if(e.target.get('checked')) {
+    };
+    
+    var yCallback = function(Y)
+    {
+        setupSortChangeEvent( Y );
+
+        Y.get('#ezwt-automatic-update').on('click', function(e)
+        {
+            if(e.target.get('checked'))
                 Y.get('#ezwt-update-priority').set('disabled', true).replaceClass('button', 'button-disabled');
-            } else {
+            else
                 Y.get('#ezwt-update-priority').set('disabled', false).replaceClass('button-disabled', 'button');
-            }
         });
         
-        var ioCallback = function(id, o) {
-            if (o.responseText !== undefined) {
+        var ioCallback = function(id, o)
+        {
+            if (o.responseText !== undefined)
+            {
             }
         }
         
-        Y.DD.DDM.on('drop:over', function(e) {
+        Y.DD.DDM.on('drop:over', function(e)
+        {
             var drag = e.drag.get('node'),
                 drop = e.drop.get('node');
 
@@ -50,18 +78,23 @@
             }
         });
 
-        Y.DD.DDM.on('drag:drag', function(e) {
+        Y.DD.DDM.on('drag:drag', function(e)
+        {
             var y = e.target.lastXY[1];
 
-            if (y < lastY) {
+            if (y < lastY)
+            {
                 goingUp = true;
-            } else {
+            }
+            else
+            {
                 goingUp = false;
             }
             lastY = y;
         });
 
-        Y.DD.DDM.on('drag:start', function(e) {
+        Y.DD.DDM.on('drag:start', function(e)
+        {
             var drag = e.target;
 
             drag.get('node').setStyle('opacity', '.25');
@@ -73,7 +106,8 @@
             });
         });
 
-        Y.DD.DDM.on('drag:end', function(e) {
+        Y.DD.DDM.on('drag:end', function(e)
+        {
             var drag = e.target;
 
             drag.get('node').setStyles({
@@ -82,51 +116,64 @@
             });
             
             var priority = 0;
-            Y.all('#ezwt-sort-list input.ezwt-priority-input').each(function(i, v) {
+            Y.all('#ezwt-sort-list input.ezwt-priority-input').each(function(i, v)
+            {
                 i.set('value', priority);
                 priority += 10;
             });
             
-            if(Y.get('#ezwt-automatic-update').get('checked')) {
+            if( Y.get('#ezwt-automatic-update').get('checked') )
+            {
                 Y.io.ez('ezwt::updatepriority', {on: {success: ioCallback}, form: { id: 'ezwt-sort-form', upload: false }, method: 'POST'});
             }
         });
 
-        Y.DD.DDM.on('drag:drophit', function(e) {
-            var drop = e.drop.get('node'),
-                drag = e.drag.get('node');
+        Y.DD.DDM.on('drag:drophit', function(e)
+        {
+            var drop = e.drop.get('node'), drag = e.drag.get('node');
 
-            if (drop.get('tagName').toLowerCase() !== 'tr') {
-                if (!drop.contains(drag)) {
-                    drop.appendChild(drag);
+            if ( drop.get('tagName').toLowerCase() !== 'tr' )
+            {
+                if ( !drop.contains(drag) )
+                {
+                    drop.appendChild( drag );
                 }
             }
         });
 
         var goingUp = false, lastY = 0;
-
-        var dragList = Y.Node.all('.ezwt-sort-drag-handler');
-        dragList.each(function(v, k) {
+        var dragdropList = Y.Node.all('tr.ezwt-sort-dragable').addClass('ezwt-sort-drag-handler');
+        dragdropList.each(function(v, k)
+        {
             var dd = new Y.DD.Drag({
                 node: v
-            }).plug(Y.Plugin.DDProxy, {
+            }).plug( Y.Plugin.DDProxy, {
                 moveOnEnd: false
-            }).plug(Y.Plugin.DDConstrained, {
+            }).plug( Y.Plugin.DDConstrained, {
                 constrain2node: '#ezwt-sort-list'
             });
         });
 
-        var dropList = Y.Node.all('.ezwt-sort-drag-handler');
-        dropList.each(function(v, k) {
+        dragdropList.each(function(v, k)
+        {
             var tar = new Y.DD.Drop({
                 node: v
             });
         });
     }
     
-    ret.init = function() {
-        var Y = YUI(YUI3_config).use('node', 'io-ez', 'io-form', 'dd-constrain', 'dd-proxy', 'dd-drop', yCallback);
+    ret.init = function()
+    {
+        if ( document.getElementById('ezwt-sort-field').value == 8 )
+        {
+            YUI(YUI3_config).use('node', 'io-ez', 'io-form', 'dd-constrain', 'dd-proxy', 'dd-drop', yCallback );
+            ret.enabled = true;
+        }
+        else
+        {
+            YUI(YUI3_config).use('node', setupSortChangeEvent );
+        }
     }
-    
+
     return ret;
 }();
Index: trunk/packages/ezwt_extension/ezextension/ezwt/design/standard/templates/parts/websitetoolbar/sort.tpl
===================================================================
--- trunk/packages/ezwt_extension/ezextension/ezwt/design/standard/templates/parts/websitetoolbar/sort.tpl	(revision 19)
+++ trunk/packages/ezwt_extension/ezextension/ezwt/design/standard/templates/parts/websitetoolbar/sort.tpl	(working copy)
@@ -2,10 +2,9 @@
                                            'extra_menu', false(),
                                            'show_path', true())}
 {ezscript_require( array( 'ezjsc::yui3', 'ezjsc::yui3io', 'ezwtsortdd.js' ) )}
-<script type="text/javascript">
-eZWTSortDD.init();
-</script>
-
+{*
+  Drag and drop script inited in the bottom of this template!
+*}
 <div class="border-box">
 <div class="border-tl"><div class="border-tr"><div class="border-tc"></div></div></div>
 <div class="border-ml"><div class="border-mr"><div class="border-mc float-break">
@@ -77,7 +76,7 @@
     {/if}
     {def $section_object = fetch( 'section', 'object', hash( 'section_id', $child.object.section_id ) )}
 
-        <tr class="{$sequence_style} ezwt-sort-drag-handler">
+        <tr class="{$sequence_style} ezwt-sort-dragable">
 
             <td>
             {if $child.can_remove}
@@ -120,11 +119,11 @@
 <div class="context-toolbar">
 {include name=navigator
          uri='design:navigator/alphabetical.tpl'
-         page_uri=$node.url_alias
-         item_count=$children_count
-         view_parameters=$view_parameters
-         node_id=$node.node_id
-         item_limit=$number_of_items}
+         page_uri = concat( '/websitetoolbar/sort/', $node.node_id )
+         item_count = $children_count
+         view_parameters = $view_parameters
+         node_id = $node.node_id
+         item_limit = $number_of_items}
 </div>
 
 <div class="controlbar">
@@ -141,9 +140,10 @@
     {if and( $priority_sorting, $node_can_edit, $children_count )}
         <input id="ezwt-update-priority" class="button" type="submit" name="UpdatePriorityButton" value="{'Update priorities'|i18n( 'design/standard/websitetoolbar/sort' )}" title="{'Apply changes to the priorities of the items in the list above.'|i18n( 'design/standard/websitetoolbar/sort' )}" />
         <input type="hidden" name="RedirectURIAfterPriority" value="websitetoolbar/sort/{$node.node_id}" />
-        {'Automaitc update'|i18n( 'design/standard/websitetoolbar/sort' )} <input id="ezwt-automatic-update" type="checkbox" name="AutomaticUpdate" value="" /> 
+        <span id="ezwt-automatic-update-container">{'Automaitc update'|i18n( 'design/standard/websitetoolbar/sort' )} <input id="ezwt-automatic-update" type="checkbox" name="AutomaticUpdate" value="" /></span>
     {else}
         <input id="ezwt-update-priority" class="button-disabled" type="submit" name="UpdatePriorityButton" value="{'Update priorities'|i18n( 'design/standard/websitetoolbar/sort' )}" title="{'You cannot update the priorities because you do not have permission to edit the current item or because a non-priority sorting method is used.'|i18n( 'design/standard/websitetoolbar/sort' )}" disabled="disabled" />
+        <span id="ezwt-automatic-update-container" class="hide">{'Automaitc update'|i18n( 'design/standard/websitetoolbar/sort' )} <input id="ezwt-automatic-update" type="checkbox" name="AutomaticUpdate" value="" /></span> 
     {/if}
     </div>
 
@@ -201,4 +201,10 @@
 
 </div></div></div>
 <div class="border-bl"><div class="border-br"><div class="border-bc"></div></div></div>
-</div>
\ No newline at end of file
+</div>
+
+<script type="text/javascript">
+
+eZWTSortDD.init();
+
+</script>
\ No newline at end of file
Index: trunk/packages/ezwt_extension/ezextension/ezwt/doc/changelogs/1.2/CHANGELOG-1.1-0-to-1.2-0
===================================================================
--- trunk/packages/ezwt_extension/ezextension/ezwt/doc/changelogs/1.2/CHANGELOG-1.1-0-to-1.2-0	(revision 0)
+++ trunk/packages/ezwt_extension/ezextension/ezwt/doc/changelogs/1.2/CHANGELOG-1.1-0-to-1.2-0	(revision 0)
@@ -0,0 +1,8 @@
+Changes from 1.1-0 to 1.2-0
+
+*Bugs*
+
+- Fixed bug #15861: Several bugs in websitetoolbar/sort
+
+*Enhancements*
+

Property changes on: trunk\packages\ezwt_extension\ezextension\ezwt\doc\changelogs\1.2\CHANGELOG-1.1-0-to-1.2-0
___________________________________________________________________
Added: svn:eol-style
   + native

