r12275 - in mb_server/trunk/root/static: scripts/MB/Control styles

View: New views
1 Messages — Rating Filter:   Alert me  

r12275 - in mb_server/trunk/root/static: scripts/MB/Control styles

by root-97 :: Rate this Message:

Reply (Restricted by the Administrator) | Reply to Author | View Threaded | Show Only this Message

Author: acid2
Date: 2009-10-31 13:24:23 +0000 (Sat, 31 Oct 2009)
New Revision: 12275

Modified:
   mb_server/trunk/root/static/scripts/MB/Control/ArtistCreditEditor.js
   mb_server/trunk/root/static/scripts/MB/Control/Lookup.js
   mb_server/trunk/root/static/scripts/MB/Control/TableSorting.js
   mb_server/trunk/root/static/scripts/MB/Control/ToggleButton.js
   mb_server/trunk/root/static/styles/release-editor.css
Log:
Various fixes for the AC editor that Brian picked up on

Merge branch 'ac-editor-fixes'

Modified: mb_server/trunk/root/static/scripts/MB/Control/ArtistCreditEditor.js
===================================================================
--- mb_server/trunk/root/static/scripts/MB/Control/ArtistCreditEditor.js 2009-10-31 12:30:02 UTC (rev 12274)
+++ mb_server/trunk/root/static/scripts/MB/Control/ArtistCreditEditor.js 2009-10-31 13:24:23 UTC (rev 12275)
@@ -69,7 +69,9 @@
 
             this.row
                 .append(
-                    $(MB.html.td()).append(this.remove))
+                    $(MB.html.td())
+                        .append('<span class="mover">Move </span>')
+                        .append(this.remove))
                 .append(
                     $(MB.html.td())
                         .append(this.lookup.query)
@@ -80,20 +82,22 @@
                 )
                 .append($(MB.html.td()).append(this.joinPhrase));
 
-            var remove = new MB.Control.ToggleButton({
+            this.removeControl = new MB.Control.ToggleButton({
                     onImage: MB.url.ArtistCreditEditor.removeArtistOn,
                     offImage: MB.url.ArtistCreditEditor.removeArtistOff,
                     toggleOn: function() {
                         thisRow.row.find('input').attr('disabled', true);
                         updateLivePreview();
+                        toggleDel();
                     },
                     toggleOff: function() {
                         thisRow.row.find('input').attr('disabled', false);
                         updateLivePreview();
+                        toggleDel();
                     }
                 });
 
-            remove.draw(this.remove);
+            this.removeControl.draw(this.remove);
         };
 
         options = $.extend({
@@ -121,6 +125,18 @@
 
         var editorBody = $(MB.html.tbody()).appendTo(editor);
 
+        var creditSorting = new MB.Control.TableSorting({
+            dragHandle: '.mover',
+            dragComplete: function(row, oldTable, origPos, newPos) {
+                var credit = credits[origPos];
+
+                credits.splice(origPos, 1);
+                credits.splice(newPos, 0, credit);
+                updateLivePreview();
+            }
+        });
+        creditSorting.addTables(editor);
+
         // Row to add a new artist credit
         var newLookup = new MB.Control.EntityLookup('artist', {
             selection: function(result) {
@@ -199,6 +215,7 @@
                 var ac = new ArtistCredit(artist);
                 credits.push(ac);
                 editorBody.append(ac.row);
+                creditSorting.activate();
             },
             openAt: function(node) {
                 if (currentEditor) {
@@ -219,6 +236,7 @@
         // Initialize the current artist credit
         creditsFromContainer();
         savedCredits = credits;
+        toggleDel();
 
         // Previews
         self.textDisplay = $('<span>')
@@ -249,7 +267,8 @@
             }).join('');
         }
 
-        function creditsFromContainer() {
+        function creditsFromContainer(creditSep) {
+            creditSep = creditSep || 'div.credit';
             credits = [];
             editorBody.empty();
             creditContainer.find('div.credit').each(function() {
@@ -268,5 +287,23 @@
                 self.appendArtist(this.artist);
             });
         }
+
+        function toggleDel() {
+            var rows = editor.find('tr input.removed:not(:checked)');
+            if(rows.length > 1) {
+                editor.find('tr').each(function(i) {
+                    if(!credits[i]) { return false; }
+                    credits[i].removeControl.enable();
+                });
+            } else {
+                var row = rows.closest('tr');
+                $.each(credits, function() {
+                    if (this.row[0] === row[0]) {
+                        this.removeControl.disable();
+                        return false;
+                    }
+                });
+            }
+        }
     };
 })(MB);
\ No newline at end of file

Modified: mb_server/trunk/root/static/scripts/MB/Control/Lookup.js
===================================================================
--- mb_server/trunk/root/static/scripts/MB/Control/Lookup.js 2009-10-31 12:30:02 UTC (rev 12274)
+++ mb_server/trunk/root/static/scripts/MB/Control/Lookup.js 2009-10-31 13:24:23 UTC (rev 12275)
@@ -153,6 +153,7 @@
             clear: function() {
                 clearResults();
                 self.query.val('');
+                info.html(MB.text.ClickLookup);
             },
             goToPage: function(page) {
                 self.search(lastSearch, page);

Modified: mb_server/trunk/root/static/scripts/MB/Control/TableSorting.js
===================================================================
--- mb_server/trunk/root/static/scripts/MB/Control/TableSorting.js 2009-10-31 12:30:02 UTC (rev 12274)
+++ mb_server/trunk/root/static/scripts/MB/Control/TableSorting.js 2009-10-31 13:24:23 UTC (rev 12275)
@@ -29,6 +29,7 @@
         var insertMethod;
         var oldTable;
         var rows;
+        var startPos;
 
         var dragHelper = $(MB.html.table({
                              style: 'position: absolute',
@@ -64,6 +65,8 @@
             rows = tables.find('> tbody > tr');
 
             currentDrag = $(el);
+            startPos = currentDrag.prevAll().length;
+            
             oldTable = currentDrag.parent('table');
             dragHelper.append(currentDrag).show();
 
@@ -85,10 +88,10 @@
             dragHelper.hide().empty();
 
             if (options.dragComplete) {
-                options.dragComplete(currentDrag, oldTable);
+                options.dragComplete(currentDrag, oldTable, startPos, currentDrag.prevAll().length);
             }
 
-            currentDrag = currentOver = oldTable = null;
+            currentDrag = currentOver = oldTable = startPos = null;
         }
 
         function above(element, y) {

Modified: mb_server/trunk/root/static/scripts/MB/Control/ToggleButton.js
===================================================================
--- mb_server/trunk/root/static/scripts/MB/Control/ToggleButton.js 2009-10-31 12:30:02 UTC (rev 12274)
+++ mb_server/trunk/root/static/scripts/MB/Control/ToggleButton.js 2009-10-31 13:24:23 UTC (rev 12275)
@@ -19,7 +19,8 @@
     $.extend(MB.url, {
         ToggleButton: {
             defaultOn: '/static/images/release_editor/edit-on.png',
-            defaultOff: '/static/images/release_editor/edit-off.png'
+            defaultOff: '/static/images/release_editor/edit-off.png',
+            defaultDisable: '/static/images/release_editor/remove-disabled.png',
         }
     });
 
@@ -31,7 +32,8 @@
             toggleOn: undefined,
             toggleOff: undefined,
             onImage: MB.url.ToggleButton.defaultOn,
-            offImage: MB.url.ToggleButton.defaultOff
+            offImage: MB.url.ToggleButton.defaultOff,
+            disableImage: MB.url.ToggleButton.defaultDisable,
         }, options);
 
         var state = options.defaultOn;
@@ -55,8 +57,18 @@
             draw: function(checkbox) {
                 input = $(checkbox);
                 updateCheckbox();
-                self.image.click(function() { self.toggle(); });
+                self.image.click(self.toggle);
                 input.hide().after(self.image);
+            },
+            enable: function() {
+                input.attr('disabled', false);
+                updateImage();
+                self.image.bind('click', self.toggle);
+            },
+            disable: function() {
+                input.attr('disabled', 'disabled');
+                self.image.attr('src', options.disableImage);
+                self.image.unbind('click', self.toggle);
             }
         });
 

Modified: mb_server/trunk/root/static/styles/release-editor.css
===================================================================
--- mb_server/trunk/root/static/styles/release-editor.css 2009-10-31 12:30:02 UTC (rev 12274)
+++ mb_server/trunk/root/static/styles/release-editor.css 2009-10-31 13:24:23 UTC (rev 12275)
@@ -98,7 +98,7 @@
     text-align: left;
 }
 .ac-editor input.join {
-    width: 2em;
+    width: 3em;
 }
 
 div.ac-editor .buttons {


_______________________________________________
MusicBrainz-commits mailing list
MusicBrainz-commits@...
http://lists.musicbrainz.org/mailman/listinfo/musicbrainz-commits