From e501717300b2e4cc3bf1014b404b661b04cfffb5 Mon Sep 17 00:00:00 2001 From: rlx <0x0073@0x2620.org> Date: Sun, 28 Aug 2011 19:50:38 +0000 Subject: [PATCH] add tooltip to lists; bugfixes for drag and drop --- static/js/pandora/pandora.js | 13 +++++++++---- static/js/pandora/ui/folderBrowserList.js | 21 ++++++++++++++++----- static/js/pandora/ui/folders.js | 4 ++-- static/js/pandora/ui/foldersList.js | 15 ++++++++++++--- static/js/pandora/ui/list.js | 3 +++ static/js/pandora/ui/menu.js | 3 +++ 6 files changed, 45 insertions(+), 14 deletions(-) diff --git a/static/js/pandora/pandora.js b/static/js/pandora/pandora.js index 75f6803..7cc2bc9 100644 --- a/static/js/pandora/pandora.js +++ b/static/js/pandora/pandora.js @@ -61,10 +61,15 @@ pandora.getGroupsSizes = function() { }; pandora.getListData = function() { - var data = {}; + Ox.print('getListData ............') + var data = {}, folder; if (pandora.user.ui.list) { - var folder = pandora.$ui.folderList['personal'].options('selected')[0] == - pandora.user.ui.list ? 'personal' : 'featured'; + Ox.forEach(pandora.$ui.folderList, function(list, key) { + if (list.options('selected').length) { + folder = key; + return false; + } + }); data = pandora.$ui.folderList[folder].value(pandora.user.ui.list); } data.editable = data.user == pandora.user.username && data.type == 'static'; @@ -218,7 +223,7 @@ pandora.resizeFolders = function() { var i = Ox.getPositionById(pandora.site.sectionFolders[pandora.user.ui.section], id); pandora.$ui.folder[i].css({width: width + 'px'}); $list.css({width: width + 'px'}); - Ox.print('...', id, $list.options()) + Ox.print('...', width, id, $list.options()) if (pandora.user.ui.section == 'site') { $list.resizeColumn('title', columnWidth.title); } else if (pandora.user.ui.section == 'items') { diff --git a/static/js/pandora/ui/folderBrowserList.js b/static/js/pandora/ui/folderBrowserList.js index 9873c9d..39f536e 100644 --- a/static/js/pandora/ui/folderBrowserList.js +++ b/static/js/pandora/ui/folderBrowserList.js @@ -52,16 +52,16 @@ pandora.ui.folderBrowserList = function(id) { clickable: function(data) { return data.type == 'smart'; }, - format: function(value) { + format: function(value, data) { return $('') .attr({ - src: Ox.UI.getImageURL('symbolFind') + src: Ox.UI.getImageURL(value == 'static' ? 'symbolClick' : 'symbolFind') }) .css({ width: '10px', height: '10px', padding: '3px 2px 1px 2px', // fixme: strange - opacity: value == 'static' ? 0.1 : 1 + opacity: data.user == pandora.user.username ? 1 : 0.25 }); }, id: 'type', @@ -75,6 +75,11 @@ pandora.ui.folderBrowserList = function(id) { height: '10px', padding: '3px 2px 1px 2px', }), + tooltip: function(data) { + return data.type == 'smart' + ? (data.user == pandora.user.username ? 'Edit Query' : 'Show Query') + : ''; + }, visible: true, width: 16 }, @@ -91,8 +96,9 @@ pandora.ui.folderBrowserList = function(id) { width: '10px', height: '10px', padding: '3px 2px 1px 2px', - opacity: id == 'favorite' ? (value ? 1 : 0.1) : - (value == 'featured' ? 1 : 0.1) + opacity: id == 'favorite' + ? (value ? 1 : 0.1) + : (value == 'featured' ? 1 : 0.1) }); }, id: id == 'favorite' ? 'subscribed' : 'status', @@ -108,6 +114,11 @@ pandora.ui.folderBrowserList = function(id) { height: '10px', padding: '3px 2px 1px 2px' }), + tooltip: function(data) { + var checked = id == 'favorite' ? data.subscribed : data.status == 'featured'; + return (checked ? 'Remove from' : 'Add to') + + ' ' + Ox.toTitleCase(id) + ' Lists'; + }, visible: true, width: 16 }, diff --git a/static/js/pandora/ui/folders.js b/static/js/pandora/ui/folders.js index 9f28b85..2c5dd72 100644 --- a/static/js/pandora/ui/folders.js +++ b/static/js/pandora/ui/folders.js @@ -13,7 +13,7 @@ pandora.ui.folders = function() { pandora.$ui.folderBrowser = {}; pandora.$ui.folderList = {}; if (pandora.user.ui.section == 'site') { - $.each(pandora.site.sectionFolders.site, function(i, folder) { + pandora.site.sectionFolders.site.forEach(function(folder, i) { var height = (Ox.getObjectById(pandora.site.sectionFolders.site, folder.id).items.length * 16); pandora.$ui.folder[i] = Ox.CollapsePanel({ id: folder.id, @@ -42,7 +42,7 @@ pandora.ui.folders = function() { }); //pandora.resizeFolders(); } else if (pandora.user.ui.section == 'items') { - $.each(pandora.site.sectionFolders.items, function(i, folder) { + pandora.site.sectionFolders.items.forEach(function(folder, i) { var extras = []; if (folder.id == 'personal' && pandora.user.level != 'guest') { extras = [Ox.Select({ diff --git a/static/js/pandora/ui/foldersList.js b/static/js/pandora/ui/foldersList.js index ee0e6eb..7a8a577 100644 --- a/static/js/pandora/ui/foldersList.js +++ b/static/js/pandora/ui/foldersList.js @@ -80,6 +80,7 @@ pandora.ui.folderList = function(id) { autovalidate: pandora.ui.autovalidateListname }, operator: '+', + tooltip: id == 'personal' ? 'Edit Title' : null, visible: id != 'favorite', width: pandora.user.ui.sidebarWidth - 88 }, @@ -94,20 +95,25 @@ pandora.ui.folderList = function(id) { clickable: function(data) { return data.type == 'smart'; }, - format: function(value) { + format: function(value, data) { return $('') .attr({ - src: Ox.UI.getImageURL('symbolFind') + src: Ox.UI.getImageURL(value == 'static' ? 'symbolClick' : 'symbolFind') }) .css({ width: '10px', height: '10px', padding: '3px 2px 1px 2px', - opacity: value == 'static' ? 0.1 : 1 + opacity: data.user == pandora.user.username ? 1 : 0.25 }); }, id: 'type', operator: '+', + tooltip: function(data) { + return data.type == 'smart' + ? (data.user == pandora.user.username ? 'Edit Query' : 'Show Query') + : ''; + }, visible: true, width: 16 }, @@ -130,6 +136,9 @@ pandora.ui.folderList = function(id) { }, id: 'status', operator: '+', + tooltip: id == 'personal' ? function(data) { + return data.status == 'private' ? 'Make Public' : 'Make Private'; + } : null, visible: true, width: 16 } diff --git a/static/js/pandora/ui/list.js b/static/js/pandora/ui/list.js index 836c2de..483093d 100644 --- a/static/js/pandora/ui/list.js +++ b/static/js/pandora/ui/list.js @@ -464,10 +464,12 @@ pandora.ui.list = function() { // fixme: remove view argument ['list', 'icons'].indexOf(view) > -1 && that.bind({ dragstart: function(e) { + Ox.print('DRAGSTART'); var editable = pandora.getListData().editable, ids = that.options('selected'), item = ids.length == 1 ? that.value(ids[0], 'title') : ids.length; Ox.forEach(pandora.$ui.folderList, function($list, i) { + Ox.print('FOLDERLIST', i) $list.find('.OxItem').each(function() { var $item = $(this), data = $list.value($item.data('id')); @@ -539,6 +541,7 @@ pandora.ui.list = function() { // fixme: remove view argument setTimeout(function() { $this.removeClass('OxDragover'); }, 250); + e.originalEvent.preventDefault(); e.originalEvent.stopPropagation(); return false; } diff --git a/static/js/pandora/ui/menu.js b/static/js/pandora/ui/menu.js index fd6d937..bff9f0d 100644 --- a/static/js/pandora/ui/menu.js +++ b/static/js/pandora/ui/menu.js @@ -139,6 +139,9 @@ pandora.ui.mainMenu = function() { {}, { id: 'users', title: 'Manage Users...' }, { id: 'lists', title: 'Manage Lists...' }, + {}, + { id: 'news', title: 'Manage News...' }, + { id: 'tour', title: 'Manage Tour...' } ] }, { id: 'helpMenu', title: 'Help', items: [ { id: 'help', title: pandora.site.site.name + ' Help', keyboard: 'shift ?' }