diff js/dnd-library.js @ 18:0d557e6e73f7

Added beautytips and some additional event handling code to the library.
author David Eads <eads@chicagotech.org>
date Fri, 06 Mar 2009 14:11:46 -0600
parents 1a77f87927dd
children d83073a08b25
line wrap: on
line diff
--- a/js/dnd-library.js	Wed Mar 04 13:29:31 2009 -0600
+++ b/js/dnd-library.js	Fri Mar 06 14:11:46 2009 -0600
@@ -37,27 +37,30 @@
     $editor.bind('wysiwygAttach', Drupal.behaviors.dndLibrary.attach_library);
     $editor.bind('wysiwygDetach', Drupal.behaviors.dndLibrary.detach_library);
 
-    // Add basic hover behavior to editor items
-    $('.editor-item', context).hover(function() {
-      var $this = $(this);
-      var p = $('#edit-body-wrapper').position();
-      var preview = $(Drupal.settings.dndLibraryPreviews[this.id]).css({
-        'position' : 'absolute',
-        'top'      : p.top + 150,
-        'left'     : p.left + $('#edit-body-wrapper').width() + 150,
-        'display'  : 'none',
-        'width'    : '300px',
-        'background-color' : '#ddd',
-        'border' : '3px solid #999',
-        'padding' : '4px',
-        'z-index'  : 10
+    $('.editor-item', context).each(function () {
+      $(this).bt(Drupal.settings.dndLibraryPreviews[this.id], {
+        'trigger' : 'none',
+        'width' : 300,
+        'spikeLength' : 7,
+        'spikeGirth' : 9,
+        'corner-radius' : 3,
+        'strokeWidth' : 1,
+        'fill' : '#eee',
+        'strokeStyle': '#555'
       });
-      $('body').prepend(preview);
-      preview.fadeIn('slow');
-    }, function() {
-      $('#' + this.id.replace(/test/,'preview')).fadeOut('fast', function() { $(this).remove(); });
+      $(this).hover(function() {
+        var $this = $(this);
+        this.btOn();
+        // Remove the preview once dragging of any image has commenced
+        $('img', $this).bind('drag', function(e) {
+          $this.btOff();
+        });
+      }, function() {
+        this.btOff();
+      });
     });
 
+
     // Ajax pager
     $('.pager a', $this).click(function() {
       $.getJSON(this.href, function(data) {