Commits

Anonymous committed 15c6df4

bookmarkplugin: uses an image sprite for the bookmark icon

Comments (0)

Files changed (6)

bookmarkplugin/trunk/tracbookmark/__init__.py

 
                 if self._is_ajax(req):
                     content = '&'.join((
-                        req.href.chrome('bookmark/' + self.image_map['on']),
+                        'on',
                         req.href.bookmark('delete', resource),
                         'Delete bookmark'))
                     if isinstance(content, unicode):
 
                 if self._is_ajax(req):
                     content = '&'.join((
-                        req.href.chrome('bookmark/' + self.image_map['off']),
+                        'off',
                         req.href.bookmark('add', resource),
                         'Bookmark this page'))
                     if isinstance(content, unicode):
         bookmark = self.get_bookmark(req, resource)
 
         if bookmark:
-            img = 'on'
+            class_ = 'bookmark_on'
             title = 'Delete Bookmark'
             href = req.href.bookmark('delete', resource)
         else:
-            img = 'off'
+            class_ = 'bookmark_off'
             title = 'Bookmark this page'
             href = req.href.bookmark('add', resource)
-        img = tag.img(src=req.href.chrome('bookmark/' + self.image_map[img]))
-        anchor = tag.a(img, id='bookmark_this', title=title, href=href,
-                       data_list=req.href.bookmark())
+        anchor = tag.a(u'\u200b', id='bookmark_this', class_=class_,
+                       title=title, href=href, data_list=req.href.bookmark())
+        req.chrome.setdefault('ctxtnav', []).insert(0, anchor)
 
         add_script(req, 'bookmark/js/tracbookmark.js')
         add_stylesheet(req, 'bookmark/css/tracbookmark.css')
-        elm = tag.span(anchor, id='bookmark')
-        req.chrome.setdefault('ctxtnav', []).insert(0, elm)
 
         menu = self._get_bookmarks_menu(req)
         item = tag.span(tag.a('Bookmarks', href=req.href.bookmark()),

bookmarkplugin/trunk/tracbookmark/htdocs/bookmark.png

Added
New image

bookmarkplugin/trunk/tracbookmark/htdocs/bookmark_off.png

Removed
Old image

bookmarkplugin/trunk/tracbookmark/htdocs/bookmark_on.png

Removed
Old image

bookmarkplugin/trunk/tracbookmark/htdocs/css/tracbookmark.css

 }
 
 #bookmark_this {
+    display: inline-block;
+    *display: inline;
+    *zoom: 1;
+    width: 12px;
+    height: 12px;
+    background-image: url(../bookmark.png);
+    background-repeat: no-repeat;
+    background-position: 0 100%;
+    vertical-align: middle;
     border-width: 0;
 }
-#bookmark_this img {
-    vertical-align: middle;
-}
+#bookmark_this.bookmark_off { background-position: -12px 100% }
 
 ul.bookmarks li {
     padding-left: 1.5em;

bookmarkplugin/trunk/tracbookmark/htdocs/js/tracbookmark.js

 
         $.get($(this).attr('href'), function(result) {
             var params = result.split('&');
-            button.find('img:first').attr('src', params[0]);
+            if (params[0] == 'off')
+                button.addClass('bookmark_off');
+            else
+                button.removeClass('bookmark_off');
             button.attr('href', params[1]);
             button.attr('title', params[2]);
 
                 $('#bookmark_menu').html(result);
             });
         });
+
+        button.blur();
         return false;
     });
 });