[bookmarks-by-zaso] allow bookmarking without waiting for portal details

This commit is contained in:
fkloft 2015-01-14 20:13:51 +01:00
parent 2fc7433bf3
commit 1c9d0bf44e

View File

@ -288,12 +288,16 @@
} }
// Append a 'star' flag in sidebar. // Append a 'star' flag in sidebar.
window.plugin.bookmarks.addStarToSidebar = function() { window.plugin.bookmarks.onPortalSelected = function() {
$('.bkmrksStar').remove();
if(window.selectedPortal == null) return;
setTimeout(function() { // the sidebar is constructed after firing the hook
if(typeof(Storage) === "undefined") { if(typeof(Storage) === "undefined") {
$('#portaldetails > .imgpreview').after(plugin.bookmarks.htmlDisabledMessage); $('#portaldetails > .imgpreview').after(plugin.bookmarks.htmlDisabledMessage);
return; return;
} }
$('.bkmrksStar').remove();
// Prepend a star to mobile status-bar // Prepend a star to mobile status-bar
if(window.plugin.bookmarks.isSmart) { if(window.plugin.bookmarks.isSmart) {
@ -303,6 +307,7 @@
$('#portaldetails > h3.title').before(plugin.bookmarks.htmlStar); $('#portaldetails > h3.title').before(plugin.bookmarks.htmlStar);
window.plugin.bookmarks.updateStarPortal(); window.plugin.bookmarks.updateStarPortal();
}, 0);
} }
// Update the status of the star (when a portal is selected from the map/bookmarks-list) // Update the status of the star (when a portal is selected from the map/bookmarks-list)
@ -1198,13 +1203,6 @@
if(window.useAndroidPanes()) if(window.useAndroidPanes())
android.addPane("plugin-bookmarks", "Bookmarks", "ic_action_star"); android.addPane("plugin-bookmarks", "Bookmarks", "ic_action_star");
window.addHook('paneChanged', window.plugin.bookmarks.onPaneChanged); window.addHook('paneChanged', window.plugin.bookmarks.onPaneChanged);
// Remove the star
window.addHook('portalSelected', function(data) {
if(data.selectedPortalGuid === null) {
$('.bkmrksStar').remove();
}
});
} }
$('#toolbox').append(window.plugin.bookmarks.htmlCallSetBox+window.plugin.bookmarks.htmlCalldrawBox); $('#toolbox').append(window.plugin.bookmarks.htmlCallSetBox+window.plugin.bookmarks.htmlCalldrawBox);
@ -1220,7 +1218,7 @@
if(window.plugin.bookmarks.statusBox['show'] === 0) { window.plugin.bookmarks.switchStatusBkmrksBox(0); } if(window.plugin.bookmarks.statusBox['show'] === 0) { window.plugin.bookmarks.switchStatusBkmrksBox(0); }
if(window.plugin.bookmarks.statusBox['page'] === 1) { $('#bookmarksBox h5.bkmrk_portals').trigger('click'); } if(window.plugin.bookmarks.statusBox['page'] === 1) { $('#bookmarksBox h5.bkmrk_portals').trigger('click'); }
window.addHook('portalDetailsUpdated', window.plugin.bookmarks.addStarToSidebar); window.addHook('portalSelected', window.plugin.bookmarks.onPortalSelected);
// Sync // Sync
window.addHook('pluginBkmrksEdit', window.plugin.bookmarks.syncBkmrks); window.addHook('pluginBkmrksEdit', window.plugin.bookmarks.syncBkmrks);