Commits

Anonymous committed 7bced05

Bug in reordering js code. Picasa "no galleries" message.

  • Participants
  • Parent commits 58d164e

Comments (0)

Files changed (4)

File eagproject/eag-static/css/style.css

 .picasa-window {
     width: 40em;
     height: 30em;
-    margin: -20em 0 0 -15em;
+    margin: -17em 0 0 -22em;
     padding: 2.0em;
     border: 2px solid #000;
     left: 50%;

File eagproject/eag-static/js/picasa.js

 var PicasaUrl = {
+    noGalleries: 'No Picasa galleries found. Go to <a href="http://picasaweb.google.com/%user%">Picasa Web</a> and add one.',
     galleries: 'http://picasaweb.google.com/data/feed/api/user/%user%',
     gallery: 'http://picasaweb.google.com/data/feed/api/user/%user%/albumid/%albumid%',
     genGalleryUrl: function (id) {
     proccessGalleries: function (json) {
         this.clear();
         var galleries = json.feed.entry;
+        if (!galleries) {
+            new Element('p', {'html': PicasaUrl.noGalleries}).inject(this._window);
+            return;
+        }
         galleries.each(function (item) {
             var wrapper = new Element('div', {
                 'class': this.options.css.gallery});

File eagproject/eag-static/js/site-tree.js

         var to = getLevel(prev);
         var cx = clone.getPosition().x;
 
-        if (from > to) {
+        if (from >= to) {
             setLevel(elem, from);
             return;
         }
 
-        if (cx > tx) {
-            setLevel(elem, to + 1);
-        } else if (cx < fx || from == to) {
-            setLevel(elem, from);
-        } else {
-            var w = (tx - fx) / (to - from);
-            var delta = (cx - fx) / parseFloat(w) + 0.5;
-            setLevel(elem, to + parseInt(delta));
-        }
+        var stepLength = (tx - fx) / parseFloat(to - from);
+        var relativePos = cx - fx;
+        var newLevel = Math.max(from, Math.min(to + 1, parseInt(relativePos / stepLength)));
+        setLevel(elem, parseInt(newLevel));
     }
 
     function startReordering () {

File eagproject/templates/eagadmin/edit.html

   <script type="text/javascript" charset="utf-8"
     src="{{ MEDIA_URL }}eag-static/js/picasa.js"></script>
   <script type="text/javascript" charset="utf-8">
+    PicasaUrl.noGalleries = '{% trans "No Picasa galleries found. Go to <a href=\'http://picasaweb.google.com/\'>Picasa Web</a> and add one." %}';
     PicasaUrl.galleries = '{% url eagadmin:picasa-all %}';
     PicasaUrl.gallery = '{% url eagadmin:picasa-one '%albumid%' %}';
   </script>