Bookmarks 0.1.55: add support to IITC_MOBILE

- the plugin work on mobile (the open/close folders script is disabled);
- add a category plugin: "Controls";
- fixed on firefox accidental click event on the bookmark's link when
the bookmark is dragged
- edit z-index of the ribbon: now it's shown below the chat;
This commit is contained in:
Giacinto Garcea 2013-06-13 22:05:21 +02:00
parent f6714a73c8
commit 6df39749f5
3 changed files with 498 additions and 253 deletions

View File

@ -1,4 +1,3 @@
#bookmarksBox *{ #bookmarksBox *{
display:block; display:block;
padding:0; padding:0;
@ -11,8 +10,6 @@
text-indent:0; text-indent:0;
text-decoration:none; text-decoration:none;
} }
#bookmarksBox{ #bookmarksBox{
margin-top:-100%; margin-top:-100%;
position:absolute !important; position:absolute !important;
@ -20,21 +17,15 @@
top:100px; top:100px;
left:100px; left:100px;
} }
#bookmarksBox .addForm, #bookmarksBox .addForm, #bookmarksBox #bookmarksTypeBar, #bookmarksBox h5{
#bookmarksBox #bookmarksTypeBar,
#bookmarksBox h5{
height:28px; height:28px;
overflow:hidden; overflow:hidden;
color:#fff; color:#fff;
font-size:14px; font-size:14px;
} }
#bookmarksBox #topBar, #bookmarksBox #topBar *{
#bookmarksBox #topBar,
#bookmarksBox #topBar *{
height:15px !important; height:15px !important;
} }
#bookmarksBox #topBar *{ #bookmarksBox #topBar *{
float:left !important; float:left !important;
} }
@ -46,7 +37,6 @@
line-height:8px; line-height:8px;
cursor:move; cursor:move;
} }
#bookmarksBox #topBar .btn{ #bookmarksBox #topBar .btn{
display:block; display:block;
width:19px; width:19px;
@ -62,50 +52,35 @@
#bookmarksBox #topBar #bookmarksMin:hover{ #bookmarksBox #topBar #bookmarksMin:hover{
color:gold; color:gold;
} }
#bookmarksBox #bookmarksTypeBar{ #bookmarksBox #bookmarksTypeBar{
clear:both; clear:both;
} }
#bookmarksBox h5{ #bookmarksBox h5{
padding:4px 0; padding:4px 0;
width:114px; width:114px;
text-align:center; text-align:center;
color:#788; color:#788;
} }
#bookmarksBox h5.current{ #bookmarksBox h5.current{
cursor:default; cursor:default;
background:none; background:0;
color:#fff !important; color:#fff !important;
} }
#bookmarksBox h5:hover{ #bookmarksBox h5:hover{
color:gold; color:gold;
background:rgba(0,0,0,0); background:rgba(0,0,0,0);
} }
#bookmarksBox #topBar .btn, #bookmarksBox .addForm, #bookmarksBox .handle, #bookmarksBox #bookmarksTypeBar, #bookmarksBox .bookmarkList li.bookmarksEmpty, #bookmarksBox .bookmarkList li.bkmrk a, #bookmarksBox .bookmarkList li.bkmrk:hover{
#bookmarksBox #topBar .btn,
#bookmarksBox .addForm,
#bookmarksBox .handle,
#bookmarksBox #bookmarksTypeBar,
#bookmarksBox .bookmarkList li.bookmarksEmpty,
#bookmarksBox .bookmarkList li.bkmrk a,
#bookmarksBox .bookmarkList li.bkmrk:hover{
background-color:rgba(8,48,78,.85); background-color:rgba(8,48,78,.85);
} }
#bookmarksBox h5, #bookmarksBox .bookmarkList li.bkmrk:hover .bookmarksLink, #bookmarksBox .addForm *{
#bookmarksBox h5,
#bookmarksBox .bookmarkList li.bkmrk:hover .bookmarksLink,
#bookmarksBox .addForm *{
background:rgba(0,0,0,.3); background:rgba(0,0,0,.3);
} }
#bookmarksBox .addForm *{ #bookmarksBox .addForm *{
display:block; display:block;
float:left; float:left;
padding:4px 8px 3px; padding:4px 8px 3px;
} }
#bookmarksBox .addForm a{ #bookmarksBox .addForm a{
cursor:pointer; cursor:pointer;
color:#20a8b1; color:#20a8b1;
@ -115,13 +90,11 @@
line-height:20px; line-height:20px;
padding:4px 0 3px; padding:4px 0 3px;
} }
#bookmarksBox .addForm a:hover{ #bookmarksBox .addForm a:hover{
background:gold; background:gold;
color:#000; color:#000;
text-decoration:none; text-decoration:none;
} }
#bookmarksBox .addForm input{ #bookmarksBox .addForm input{
font-size:11px !important; font-size:11px !important;
color:#ffce00; color:#ffce00;
@ -132,18 +105,14 @@
-moz-box-sizing:content-box; -moz-box-sizing:content-box;
box-sizing:content-box; box-sizing:content-box;
} }
#bookmarksBox #bkmrk_portals .addForm input{ #bookmarksBox #bkmrk_portals .addForm input{
width:147px; width:147px;
} }
#bookmarksBox .addForm input:hover, #bookmarksBox .addForm input:focus{
#bookmarksBox .addForm input:hover,
#bookmarksBox .addForm input:focus{
outline:0; outline:0;
background:rgba(0,0,0,.6); background:rgba(0,0,0,.6);
} }
#bookmarksBox .bookmarkList>ul{
#bookmarksBox .bookmarkList > ul{
width:231px; width:231px;
clear:both; clear:both;
list-style-type:none; list-style-type:none;
@ -151,7 +120,6 @@
overflow:hidden; overflow:hidden;
max-height:550px; max-height:550px;
} }
#bookmarksBox .sortable-placeholder{ #bookmarksBox .sortable-placeholder{
background:rgba(8,48,78,.55); background:rgba(8,48,78,.55);
box-shadow:inset 1px 0 0 #20a8b1; box-shadow:inset 1px 0 0 #20a8b1;
@ -159,69 +127,71 @@
#bookmarksBox .ui-sortable-helper{ #bookmarksBox .ui-sortable-helper{
border-top-width:1px; border-top-width:1px;
} }
#bookmarksBox .bookmarkList{
#bookmarksBox .bookmarkList{ display:none; } display:none;
#bookmarksBox .bookmarkList.current{ display:block; } }
#bookmarksBox .bookmarkList.current{
#bookmarksBox h5, display:block;
#bookmarksBox .addForm *, }
#bookmarksBox ul li.bkmrk, #bookmarksBox h5, #bookmarksBox .addForm *, #bookmarksBox ul li.bkmrk, #bookmarksBox ul li.bkmrk a{
#bookmarksBox ul li.bkmrk a{
height:22px; height:22px;
} }
#bookmarksBox h5, #bookmarksBox ul li.bkmrk a{
#bookmarksBox h5,
#bookmarksBox ul li.bkmrk a{
overflow:hidden; overflow:hidden;
cursor:pointer; cursor:pointer;
float:left; float:left;
} }
#bookmarksBox ul .bookmarksEmpty{ text-indent:27px; color:#eee; } #bookmarksBox ul .bookmarksEmpty{
#bookmarksBox ul .bookmarksRemoveFrom{ width:19px; text-align:center; color:#fff; } text-indent:27px;
#bookmarksBox ul .bookmarksLink{ width:171px; padding:0 10px 0 8px; color:gold; } color:#eee;
#bookmarksBox ul .bookmarksLink.selected{ color:#03fe03; } }
#bookmarksBox ul .othersBookmarks .bookmarksLink{ width:190px; } #bookmarksBox ul .bookmarksRemoveFrom{
width:19px;
#bookmarksBox ul .bookmarksLink:hover{ color:#03fe03; } text-align:center;
#bookmarksBox ul .bookmarksRemoveFrom:hover{ color:#fff; background:#e22; } color:#fff;
}
/************************************/ #bookmarksBox ul .bookmarksLink{
width:171px;
#bookmarksBox, padding:0 10px 0 8px;
#bookmarksBox * color:gold;
{ border-color:#20a8b1; border-style:solid; border-width:0; } }
#bookmarksBox ul .bookmarksLink.selected{
#bookmarksBox #topBar color:#03fe03;
, #bookmarksBox ul .bookmarkFolder }
{ border-top-width:1px; } #bookmarksBox ul .othersBookmarks .bookmarksLink{
width:190px;
#bookmarksBox #topBar }
, #bookmarksBox #bookmarksTypeBar #bookmarksBox ul .bookmarksLink:hover{
, #bookmarksBox .addForm color:#03fe03;
, #bookmarksBox ul .bookmarkFolder .folderLabel }
, #bookmarksBox ul li.bkmrk #bookmarksBox ul .bookmarksRemoveFrom:hover{
{ border-bottom-width:1px; } color:#fff;
background:#e22;
#bookmarksBox ul .bookmarkFolder }
, #bookmarksBox ul .bookmarksRemoveFrom #bookmarksBox, #bookmarksBox *{
{ border-right-width:1px; border-left-width:1px; } border-color:#20a8b1;
border-style:solid;
#bookmarksBox #topBar * border-width:0;
, #bookmarksBox #bookmarksTypeBar * }
, #bookmarksBox .addForm * #bookmarksBox #topBar, #bookmarksBox ul .bookmarkFolder{
{ border-left-width:1px; } border-top-width:1px;
}
#bookmarksBox #topBar #bookmarksBox #topBar, #bookmarksBox #bookmarksTypeBar, #bookmarksBox .addForm, #bookmarksBox ul .bookmarkFolder .folderLabel, #bookmarksBox ul li.bkmrk{
, #bookmarksBox #bookmarksTypeBar border-bottom-width:1px;
, #bookmarksBox .addForm }
{ border-right-width:1px; } #bookmarksBox ul .bookmarkFolder, #bookmarksBox ul .bookmarksRemoveFrom{
border-right-width:1px;
#bookmarksBox ul .othersBookmarks .bookmarksRemoveFrom border-left-width:1px;
, #bookmarksBox ul .bookmarkFolder .folderLabel .bookmarksRemoveFrom }
{ border-left-width:0px; } #bookmarksBox #topBar *, #bookmarksBox #bookmarksTypeBar *, #bookmarksBox .addForm *{
border-left-width:1px;
/************************************/ }
#bookmarksBox #topBar, #bookmarksBox #bookmarksTypeBar, #bookmarksBox .addForm{
border-right-width:1px;
}
#bookmarksBox ul .othersBookmarks .bookmarksRemoveFrom, #bookmarksBox ul .bookmarkFolder .folderLabel .bookmarksRemoveFrom{
border-left-width:0;
}
#bookmarksShow{ #bookmarksShow{
display:block; display:block;
position:absolute; position:absolute;
@ -231,22 +201,22 @@
margin-top:-36px; margin-top:-36px;
height:64px; height:64px;
cursor:pointer; cursor:pointer;
z-index:4005; z-index:2999;
background-position:center bottom; background-position:center bottom;
background-repeat:no-repeat; background-repeat:no-repeat;
transition:margin-top 100ms ease-in-out; transition:margin-top 100ms ease-in-out;
background-image:url(@@INCLUDEIMAGE:plugins/bookmarks-by-zaso-logo.png@@); background-image:url(@@INCLUDEIMAGE:plugins/bookmarks-by-zaso-logo.png@@);
} }
#bookmarksShow:hover{ #bookmarksShow:hover{
margin-top:0px !important; margin-top:0 !important;
}
#sidebar #portaldetails h3.title{
width:auto;
} }
#bookmarkStar{ #bookmarkStar{
display:inline-block; display:inline-block;
position:relative; float:left;
top:1px; margin:3px 1px 0 4px;
margin-right:3px;
width:16px; width:16px;
height:15px; height:15px;
overflow:hidden; overflow:hidden;
@ -254,11 +224,9 @@
background-position:left center; background-position:left center;
background-repeat:no-repeat; background-repeat:no-repeat;
} }
#bookmarkStar:hover, #bookmarkStar:hover, #bookmarkStar.favorite{
#bookmarkStar.favorite{
background-position:right center; background-position:right center;
} }
#bookmarksBox .handleScroll{ #bookmarksBox .handleScroll{
cursor:s-resize; cursor:s-resize;
width:3px; width:3px;
@ -266,21 +234,16 @@
background:gold; background:gold;
opacity:.7; opacity:.7;
} }
/************************************/
#bookmarksBox .bookmarkList .bookmarkFolder{ #bookmarksBox .bookmarkList .bookmarkFolder{
overflow:hidden; overflow:hidden;
margin-top:-1px; margin-top:-1px;
height:auto; height:auto;
background:rgba(8,58,78,.7); background:rgba(8,58,78,.7);
} }
#bookmarksBox .bookmarkList ul li.sortable-placeholder{ #bookmarksBox .bookmarkList ul li.sortable-placeholder{
box-shadow:inset -1px 0 0 #20a8b1, inset 1px 0 0 #20a8b1, 0 -1px 0 #20a8b1; box-shadow:inset -1px 0 0 #20a8b1, inset 1px 0 0 #20a8b1, 0 -1px 0 #20a8b1;
background:rgba(8,58,78,.9); background:rgba(8,58,78,.9);
} }
#bookmarksBox .bookmarkList .bkmrk.ui-sortable-helper{ #bookmarksBox .bookmarkList .bkmrk.ui-sortable-helper{
border-right-width:1px; border-right-width:1px;
border-left-width:1px; border-left-width:1px;
@ -289,31 +252,21 @@
height:23px; height:23px;
box-shadow:inset 0 -1px 0 #20a8b1, inset 1px 0 0 #20a8b1; box-shadow:inset 0 -1px 0 #20a8b1, inset 1px 0 0 #20a8b1;
} }
#bookmarksBox .bookmarkList ul li.bookmarkFolder.ui-sortable-helper, #bookmarksBox .bookmarkList ul li.othersBookmarks ul, #bookmarksBox .bookmarkList ul li.othersBookmarks ul li.sortable-placeholder{
#bookmarksBox .bookmarkList ul li.bookmarkFolder.ui-sortable-helper,
#bookmarksBox .bookmarkList ul li.othersBookmarks ul,
#bookmarksBox .bookmarkList ul li.othersBookmarks ul li.sortable-placeholder{
box-shadow:inset 0 -1px 0 #20a8b1; box-shadow:inset 0 -1px 0 #20a8b1;
} }
#bookmarksBox .bookmarkList .bookmarkFolder .folderLabel .bookmarksAnchor span, #bookmarksBox .bookmarkList .bookmarkFolder .folderLabel>span, #bookmarksBox .bookmarkList .bookmarkFolder .folderLabel>span>span, #bookmarksBox .bookmarkList .triangle{
#bookmarksBox .bookmarkList .bookmarkFolder .folderLabel .bookmarksAnchor span, width:0;
#bookmarksBox .bookmarkList .bookmarkFolder .folderLabel > span, height:0;
#bookmarksBox .bookmarkList .bookmarkFolder .folderLabel > span > span,
#bookmarksBox .bookmarkList .triangle{
width:0px;
height:0px;
} }
/************************************/
#bookmarksBox .bookmarkList .bookmarkFolder .folderLabel{ #bookmarksBox .bookmarkList .bookmarkFolder .folderLabel{
overflow:visible; overflow:visible;
height:25px; height:25px;
cursor:pointer; cursor:pointer;
background:#069; background:#069;
text-indent:0px; text-indent:0;
} }
#bookmarksBox .bookmarkList .bookmarkFolder .folderLabel > *{ #bookmarksBox .bookmarkList .bookmarkFolder .folderLabel>*{
height:25px; height:25px;
float:left; float:left;
} }
@ -333,39 +286,30 @@
border-width:7px 5px 0 5px; border-width:7px 5px 0 5px;
border-color:white transparent transparent transparent; border-color:white transparent transparent transparent;
} }
#bookmarksBox .bookmarkList .bookmarkFolder .folderLabel>span, #bookmarksBox .bookmarkList .bookmarkFolder .folderLabel>span>span{
/************************************************************************************************************/
#bookmarksBox .bookmarkList .bookmarkFolder .folderLabel > span,
#bookmarksBox .bookmarkList .bookmarkFolder .folderLabel > span > span{
display:none; display:none;
border-width:0px 12px 10px 0; border-width:0 12px 10px 0;
border-color:transparent #20a8b1 transparent transparent; border-color:transparent #20a8b1 transparent transparent;
margin:-20px 0 0; margin:-20px 0 0;
position:relative; position:relative;
top:21px; top:21px;
left:219px; left:219px;
} }
#bookmarksBox .bookmarkList .bookmarkFolder .folderLabel > span > span{ #bookmarksBox .bookmarkList .bookmarkFolder .folderLabel>span>span{
top:18px; top:18px;
left:0px; left:0;
border-width:0px 10px 9px 0; border-width:0 10px 9px 0;
border-color:transparent #069 transparent transparent; border-color:transparent #069 transparent transparent;
} }
#bookmarksBox .bookmarkList .bookmarkFolder.active .folderLabel > span, #bookmarksBox .bookmarkList .bookmarkFolder.active .folderLabel>span, #bookmarksBox .bookmarkList .bookmarkFolder.active .folderLabel>span>span{
#bookmarksBox .bookmarkList .bookmarkFolder.active .folderLabel > span > span{
display:block; display:block;
} }
#bookmarksBox .bookmarkList .bookmarkFolder.active .folderLabel:hover > span > span{ #bookmarksBox .bookmarkList .bookmarkFolder.active .folderLabel:hover>span>span{
border-color:transparent #036 transparent transparent; border-color:transparent #036 transparent transparent;
} }
/************************************************************************************************************/
#bookmarksBox .bookmarkList .bookmarkFolder .folderLabel:hover .bookmarksAnchor{ #bookmarksBox .bookmarkList .bookmarkFolder .folderLabel:hover .bookmarksAnchor{
background:#036; background:#036;
} }
#bookmarksBox .bookmarkList .bookmarkFolder ul{ #bookmarksBox .bookmarkList .bookmarkFolder ul{
display:none; display:none;
margin-left:19px; margin-left:19px;
@ -374,7 +318,7 @@
display:block; display:block;
min-height:22px; min-height:22px;
} }
#bookmarksBox .bookmarkFolder.othersBookmarks ul{ #bookmarksBox .bookmarkFolder.othersBookmarks ul{
margin-left:0; margin-left:0;
} }
)

View File

@ -0,0 +1,136 @@
#sidebar #bookmarksBox{
position:static !important;
width:auto !important;
margin:0 !important;
width:100%;
}
#sidebar #bookmarksBox .bookmarkList > ul > li, #sidebar #bookmarksBox .bookmarkList > ul > li > ul, #sidebar #bookmarksBox .bookmarkList > ul > li > ul > li{
width:100% !important;
}
#sidebar #bookmarksBox *{
box-shadow:none !important;
border-width:0 !important
}
#sidebar #bookmarksBox #topBar{
display:none !important;
}
#sidebar #bookmarksBox #bookmarksTypeBar h5{
cursor:pointer;
text-align:center;
float:left;
width:50%;
padding:7px 0;
}
#sidebar #bookmarksBox #bookmarksTypeBar h5.current{
cursor:default;
color:#fff;
}
#sidebar #bookmarksBox #bookmarksTypeBar, #sidebar #bookmarksBox .bookmarkList .addForm{
border-bottom:1px solid #20a8b1 !important;
}
#sidebar #bookmarksBox .bookmarkList ul li ul li.bkmrk{
height:36px !important;
clear:both;
}
#sidebar #bookmarksBox .bookmarkList li.bookmarkFolder .folderLabel{
height:36px;
}
#sidebar #bookmarksBox .bookmarkList li.bookmarkFolder .folderLabel a, #sidebar #bookmarksBox .bookmarkList ul li ul li.bkmrk a{
background:none;
padding:7px 0;
height:auto;
box-shadow:inset 0 1px 0 #20a8b1 !important;
}
#sidebar #bookmarksBox .bookmarkList li.bookmarkFolder a.bookmarksRemoveFrom, #sidebar #bookmarksBox .bookmarkList li.bkmrk a.bookmarksRemoveFrom{
box-shadow:inset 0 1px 0 #20a8b1, inset -1px 0 0 #20a8b1 !important;
width:15%;
}
#sidebar #bookmarksBox .bookmarkList li.bookmarkFolder a.bookmarksAnchor, #sidebar #bookmarksBox .bookmarkList li.bkmrk a.bookmarksLink{
text-indent:10px;
width:85%;
height:21px /*22*/;
overflow:hidden;
}
#sidebar #bookmarksBox .bookmarkList ul li.bookmarkFolder ul{
margin-left:0 !important;
}
#sidebar #bookmarksBox .bookmarkList ul, #bookmarksBox .bookmarkList ul li, #sidebar #bookmarksBox .bookmarkList ul li ul, #sidebar #bookmarksBox .bookmarkList ul li ul li{
display:block !important;
}
#sidebar #bookmarksBox .bookmarkList{
display:none !important;
}
#sidebar #bookmarksBox .bookmarkList > ul{
border-bottom:1px solid #20a8b1 !important;
border-right:1px solid #20a8b1 !important;
}
#sidebar #bookmarksBox .bookmarkList.current{
display:block !important;
}
#sidebar #bookmarksBox .bookmarkList .bookmarkFolder.othersBookmarks ul{
border-top:5px solid #20a8b1 !important;
}
#sidebar #bookmarksBox .bookmarkList li.bookmarkFolder, #sidebar #bookmarksBox .bookmarkList li.bkmrk{
box-shadow:inset 0 1px 0 #20a8b1, 1px 0 0 #20a8b1, -1px 1px 0 #20a8b1 !important;
}
#sidebar #bookmarksBox .bookmarkList li.bookmarkFolder .bkmrk.sortable-placeholder{
height:36px !important;
}
#sidebar #bookmarksBox .bookmarkList .sortable-placeholder{
box-shadow:inset 0 1px 0 #20a8b1 !important;
}
#sidebar #bookmarksBox .ui-sortable .ui-sortable-helper{
border-top:0;
width:85% !important;
}
#sidebar #bookmarksBox .bookmarkList > ul{
max-height:none;
width:85% !important;
}
#sidebar #bookmarksBox .bookmarkList li.bookmarkFolder .folderLabel{
box-shadow:0 1px 0 #20a8b1 !important;
}
#sidebar #bookmarksBox .bookmarkList ul li.bookmarkFolder ul{
width:85% !important;
margin-left:15% !important;
}
#sidebar #bookmarksBox .bookmarkList ul li.bookmarkFolder.othersBookmarks ul{
width:100% !important;
margin-left:0% !important;
}
#sidebar #bookmarksShowMobile{
text-decoration:none;
display:block !important;
padding:11px 0 9px;
text-align:center;
}
#sidebar #portaldetails{
margin-top:25px;
}
#sidebar #bookmarksBox #bookmarksTypeBar{
height:auto;
}
#sidebar #bookmarksBox .addForm, #sidebar #bookmarksBox .addForm *{
height:35px;
padding:0;
}
#sidebar #bookmarksBox .addForm a{
line-height:37px;
}
#sidebar #bookmarksBox .addForm a{
width:25% !important;
}
#sidebar #bookmarksBox .addForm input{
width:50% !important;
text-indent:10px;
}
#sidebar #bookmarksBox #bkmrk_portals .addForm input{
width:75% !important;
}
#sidebar #bookmarksBox #bookmarksTypeBar h5, #sidebar #bookmarksBox .bookmarkList .addForm a{
box-shadow:-1px 0 0 #20a8b1 !important;
}
#sidebar #bookmarksBox .bookmarkList li.bookmarkFolder ul{
display:block !important;
min-height:37px !important;
}

View File

@ -1,7 +1,8 @@
// ==UserScript== // ==UserScript==
// @id iitc-plugin-bookmarks@zaso // @id iitc-plugin-bookmarks@ZasoGD
// @name IITC plugin: Bookmarks for maps and portals // @name IITC plugin: Bookmarks for maps and portals
// @version 0.1.3.@@DATETIMEVERSION@@ // @category Controls
// @version 0.1.55.@@DATETIMEVERSION@@
// @namespace https://github.com/jonatkins/ingress-intel-total-conversion // @namespace https://github.com/jonatkins/ingress-intel-total-conversion
// @updateURL @@UPDATEURL@@ // @updateURL @@UPDATEURL@@
// @downloadURL @@DOWNLOADURL@@ // @downloadURL @@DOWNLOADURL@@
@ -13,58 +14,66 @@
// ==/UserScript== // ==/UserScript==
function wrapper() { function wrapper() {
// ensure plugin framework is there, even if iitc is not yet loaded // ensure plugin framework is there, even if iitc is not yet loaded
if(typeof window.plugin !== 'function') window.plugin = function(){}; if(typeof window.plugin !== 'function') window.plugin = function(){};
// PLUGIN START ////////////////////////////////////////////////////////
// PLUGIN START ////////////////////////////////////////////////////////
// use own namespace for plugin // use own namespace for plugin
window.plugin.bookmarks = function(){}; window.plugin.bookmarks = function() {};
window.plugin.bookmarks.bkmrk_portals = {};
window.plugin.bookmarks.bkmrk_maps = {};
window.plugin.bookmarks.disabledMessage;
window.plugin.bookmarks.contentStarHTML;
window.plugin.bookmarks.KEY_OTHER_BKMRK = 'idOthers'; window.plugin.bookmarks.KEY_OTHER_BKMRK = 'idOthers';
window.plugin.bookmarks.LOCAL_STORAGE_status_box = 'plugin-bookmarks-status-box'; window.plugin.bookmarks.LOCAL_STORAGE_status_box = 'plugin-bookmarks-status-box';
window.plugin.bookmarks.LOCAL_STORAGE_bkmrk_portals = 'plugin-bookmarks-portals-data'; window.plugin.bookmarks.LOCAL_STORAGE_bkmrk_portals = 'plugin-bookmarks-portals-data';
window.plugin.bookmarks.LOCAL_STORAGE_bkmrk_maps = 'plugin-bookmarks-maps-data'; window.plugin.bookmarks.LOCAL_STORAGE_bkmrk_maps = 'plugin-bookmarks-maps-data';
window.plugin.bookmarks.bkmrk_portals = {}; /*********************************************************************************************************************/
window.plugin.bookmarks.bkmrk_maps = {};
window.plugin.bookmarks.disabledMessage; //---------------------------------------------------------------------------------------
window.plugin.bookmarks.contentStarHTML; // Append a 'star' flag in sidebar.
window.plugin.bookmarks.bkmrkBox; //---------------------------------------------------------------------------------------
window.plugin.bookmarks.bkmrkRibbon; window.plugin.bookmarks.addToSidebar = function(){
window.plugin.bookmarks.loadList;
window.plugin.bookmarks.setupJS;
/***************************************************************************************************************************************************************/
window.plugin.bookmarks.addStarToSidebar = function(){
if(typeof(Storage) === "undefined"){ $('#portaldetails > .imgpreview').after(plugin.bookmarks.disabledMessage); return; } if(typeof(Storage) === "undefined"){ $('#portaldetails > .imgpreview').after(plugin.bookmarks.disabledMessage); return; }
var title = $('#portaldetails > h3').text(); $('#portaldetails > h3.title').before(plugin.bookmarks.contentStarHTML);
$('#portaldetails > h3').html(plugin.bookmarks.contentStarHTML+title);
plugin.bookmarks.updateStarPortal(); plugin.bookmarks.updateStarPortal();
} }
//---------------------------------------------------------------------------------------
// Update the status of the star (when a portal is selected from the map/bookmarks-list)
//---------------------------------------------------------------------------------------
window.plugin.bookmarks.updateStarPortal = function(){ window.plugin.bookmarks.updateStarPortal = function(){
window.plugin.bookmarks.loadBookmarks('bkmrk_portals'); window.plugin.bookmarks.loadBookmarks('bkmrk_portals');
var guid = window.selectedPortal; var guid = window.selectedPortal;
var list = plugin.bookmarks['bkmrk_portals'];
$('#bookmarkStar').removeClass('favorite'); $('#bookmarkStar').removeClass('favorite');
$('.bkmrk a.bookmarksLink.selected').removeClass('selected'); $('.bkmrk a.bookmarksLink.selected').removeClass('selected');
//If current portal is into bookmarks: select bookmark portal from portals list and select the star in sideabar //If current portal is into bookmarks: select bookmark portal from portals list and select the star
if(localStorage[window.plugin.bookmarks.LOCAL_STORAGE_bkmrk_portals].search(guid) != -1){
$('#bookmarkStar').addClass('favorite');
var list = plugin.bookmarks['bkmrk_portals'];
for(var idFolders in list){ for(var idFolders in list){
for(var idBkmrk in list[idFolders]['bkmrk']){ for(var idBkmrk in list[idFolders]['bkmrk']){
var portalGuid = list[idFolders]['bkmrk'][idBkmrk]['guid']; var portalGuid = list[idFolders]['bkmrk'][idBkmrk]['guid'];
if(guid == portalGuid){ if(guid == portalGuid){
$('#bookmarkStar').addClass('favorite');
$('.bkmrk#'+idBkmrk+' a.bookmarksLink').addClass('selected'); $('.bkmrk#'+idBkmrk+' a.bookmarksLink').addClass('selected');
} }
} }
} }
} }
}
//---------------------------------------------------------------------------------------
// Switch the status of the star
//---------------------------------------------------------------------------------------
window.plugin.bookmarks.switchStarPortal = function(){ window.plugin.bookmarks.switchStarPortal = function(){
var guid = window.selectedPortal; var guid = window.selectedPortal;
//Remove portal from bookmarks //If portal is saved in bookmarks: Remove this bookmark
if($('#bookmarkStar').hasClass('favorite')){ if($('#bookmarkStar').hasClass('favorite')){
var list = plugin.bookmarks['bkmrk_portals']; var list = plugin.bookmarks['bkmrk_portals'];
@ -78,22 +87,29 @@ function wrapper() {
} }
} }
} }
//Add portal into bookmarks //If portal isn't saved in bookmarks: Add this bookmark
else{ else{
// Get the bookmark data (name, coordinates, portal id) from the portal link
var linka = $('#portaldetails .linkdetails aside a:contains("Portal link")').attr('href'); var linka = $('#portaldetails .linkdetails aside a:contains("Portal link")').attr('href');
var namePortal = $('#portaldetails h3').text(); var namePortal = $('#portaldetails h3').text();
var ID = window.plugin.bookmarks.generateID(); var ID = window.plugin.bookmarks.generateID();
var spac = linka.split('pll='); var spac = linka.split('pll=');
var latlng = spac[1] ; var latlng = spac[1] ;
// Add bookmark in the localStorage
plugin.bookmarks['bkmrk_portals'][plugin.bookmarks.KEY_OTHER_BKMRK]['bkmrk'][ID] = {"guid":guid,"latlng":latlng,"label":namePortal}; plugin.bookmarks['bkmrk_portals'][plugin.bookmarks.KEY_OTHER_BKMRK]['bkmrk'][ID] = {"guid":guid,"latlng":latlng,"label":namePortal};
//Append the new bookmark to the map list
$('#bkmrk_portals li.othersBookmarks ul').append('<li class="bkmrk" id="'+ID+'"><a class="bookmarksRemoveFrom" title="Remove from bookmarks">X</a><a class="bookmarksLink selected" onclick="window.zoomToAndShowPortal(\''+guid+'\', ['+latlng+']);return false;">'+namePortal+'</a></li>'); $('#bkmrk_portals li.othersBookmarks ul').append('<li class="bkmrk" id="'+ID+'"><a class="bookmarksRemoveFrom" title="Remove from bookmarks">X</a><a class="bookmarksLink selected" onclick="window.zoomToAndShowPortal(\''+guid+'\', ['+latlng+']);return false;">'+namePortal+'</a></li>');
} }
window.plugin.bookmarks.storeBookmarks('bkmrk_portals'); window.plugin.bookmarks.storeBookmarks('bkmrk_portals');
window.plugin.bookmarks.updateStarPortal(); window.plugin.bookmarks.updateStarPortal();
} }
//---------------------------------------------------------------------------------------
// Save a bookmark map
//---------------------------------------------------------------------------------------
window.plugin.bookmarks.addBookmarkMap = function(elem){ window.plugin.bookmarks.addBookmarkMap = function(elem){
// Get the coordinates and zoom level from the permalink
var mapLink = $(elem).attr('href'); var mapLink = $(elem).attr('href');
var pars = new RegExp('[\\?&amp;]ll=([^&amp;#]*)[&amp;]z=([^&amp;#]*)').exec(mapLink); var pars = new RegExp('[\\?&amp;]ll=([^&amp;#]*)[&amp;]z=([^&amp;#]*)').exec(mapLink);
var res = pars[1].split(','); var res = pars[1].split(',');
@ -103,21 +119,25 @@ function wrapper() {
var ID = window.plugin.bookmarks.generateID(); var ID = window.plugin.bookmarks.generateID();
//Get the label | Convert some characters | Set the input (empty)
var nameMap = $(elem).siblings('input').val(); var nameMap = $(elem).siblings('input').val();
nameMap = nameMap.replace(/\//g, '&#47;').replace(/\\/g, '&#92;').replace(/"/g, '&#34;').replace(/"/g, '&#39;'); nameMap = nameMap.replace(/\//g, '&#47;').replace(/\\/g, '&#92;').replace(/"/g, '&#34;').replace(/"/g, '&#39;');
if(nameMap == ''){ nameMap = ''; }
$(elem).siblings('input').val(''); $(elem).siblings('input').val('');
// Add bookmark in the localStorage
plugin.bookmarks['bkmrk_maps'][plugin.bookmarks.KEY_OTHER_BKMRK]['bkmrk'][ID] = {"label":nameMap,"latlng":latlng,"z":parseInt(zoom)}; plugin.bookmarks['bkmrk_maps'][plugin.bookmarks.KEY_OTHER_BKMRK]['bkmrk'][ID] = {"label":nameMap,"latlng":latlng,"z":parseInt(zoom)};
plugin.bookmarks.storeBookmarks('bkmrk_maps'); plugin.bookmarks.storeBookmarks('bkmrk_maps');
//Append the new bookmark to the map list
if(nameMap==''){ nameMap = latlng+' ['+zoom+']'; } if(nameMap==''){ nameMap = latlng+' ['+zoom+']'; }
$('#bkmrk_maps li.othersBookmarks ul').append('<li class="bkmrk" id="'+ID+'"><a class="bookmarksRemoveFrom" title="Remove from bookmarks">X</a><a class="bookmarksLink" onclick="map.setView(['+latlng+'], '+zoom+');return false;">'+nameMap+'</a></li>'); $('#bkmrk_maps li.othersBookmarks ul').append('<li class="bkmrk" id="'+ID+'"><a class="bookmarksRemoveFrom" title="Remove from bookmarks">X</a><a class="bookmarksLink" onclick="map.setView(['+latlng+'], '+zoom+');return false;">'+nameMap+'</a></li>');
} }
/***************************************************************************************************************************************************************/ /*********************************************************************************************************************/
//---------------------------------------------------------------------------------------
// Generate an ID for the bookmark (date time + random number)
//---------------------------------------------------------------------------------------
window.plugin.bookmarks.generateID = function(){ window.plugin.bookmarks.generateID = function(){
var d = new Date(); var d = new Date();
var ID = d.getTime()+(Math.floor(Math.random()*99)+1); var ID = d.getTime()+(Math.floor(Math.random()*99)+1);
@ -125,6 +145,9 @@ function wrapper() {
return ID; return ID;
} }
//---------------------------------------------------------------------------------------
// Switch the status folder to open/close (in the localStorage)
//---------------------------------------------------------------------------------------
window.plugin.bookmarks.openFolder = function(elem){ window.plugin.bookmarks.openFolder = function(elem){
var typeList = $(elem).parent().parent().parent().parent('div').attr('id'); var typeList = $(elem).parent().parent().parent().parent('div').attr('id');
var ID = $(elem).parent().parent('li').attr('id'); var ID = $(elem).parent().parent('li').attr('id');
@ -135,19 +158,29 @@ function wrapper() {
window.plugin.bookmarks[typeList][ID]['state'] = newFlag; window.plugin.bookmarks[typeList][ID]['state'] = newFlag;
window.plugin.bookmarks.storeBookmarks(typeList); window.plugin.bookmarks.storeBookmarks(typeList);
} }
//---------------------------------------------------------------------------------------
// Switch the status folder to open/close (in the localStorage)
//---------------------------------------------------------------------------------------
window.plugin.bookmarks.addFolder = function(typeList){ window.plugin.bookmarks.addFolder = function(typeList){
var ID = window.plugin.bookmarks.generateID(); var ID = window.plugin.bookmarks.generateID();
var input = '#'+typeList+' .addForm input'; var input = '#'+typeList+' .addForm input';
//Get the label | Convert some characters | Set the input (empty)
var nameFolder = $(input).val(); var nameFolder = $(input).val();
nameFolder = nameFolder.replace(/\//g, '&#47;').replace(/\\/g, '&#92;').replace(/"/g, '&#34;').replace(/"/g, '&#39;'); nameFolder = nameFolder.replace(/\//g, '&#47;').replace(/\\/g, '&#92;').replace(/"/g, '&#34;').replace(/"/g, '&#39;');
if(nameFolder == ''){ nameFolder = 'Folder'; } if(nameFolder == ''){ nameFolder = 'Folder'; }
$(input).val(''); $(input).val('');
plugin.bookmarks[typeList][ID] = {"label":nameFolder,"state":0,"bkmrk":{}}; // Add new folder in the localStorage
plugin.bookmarks[typeList][ID] = {"label":nameFolder,"state":1,"bkmrk":{}};
plugin.bookmarks.storeBookmarks(typeList); plugin.bookmarks.storeBookmarks(typeList);
//Append the new folder to the list
$('#'+typeList+' li.othersBookmarks').before('<li class="bookmarkFolder" id="'+ID+'"><span class="folderLabel"><a class="bookmarksRemoveFrom">X</a><a class="bookmarksAnchor"><span></span>'+nameFolder+'</a><span><span></span></span></span><ul></ul></li>'); $('#'+typeList+' li.othersBookmarks').before('<li class="bookmarkFolder active" id="'+ID+'"><span class="folderLabel"><a class="bookmarksRemoveFrom">X</a><a class="bookmarksAnchor"><span></span>'+nameFolder+'</a><span><span></span></span></span><ul></ul></li>');
} }
//---------------------------------------------------------------------------------------
// Remove the bookmark (from the localStorage)
//---------------------------------------------------------------------------------------
window.plugin.bookmarks.deletBookmark = function(elem){ window.plugin.bookmarks.deletBookmark = function(elem){
var typeList = $(elem).parent().parent().parent().parent().parent('div').attr('id'); var typeList = $(elem).parent().parent().parent().parent().parent('div').attr('id');
var ID = $(elem).parent('li').attr('id'); var ID = $(elem).parent('li').attr('id');
@ -156,6 +189,10 @@ function wrapper() {
window.plugin.bookmarks.storeBookmarks(typeList); window.plugin.bookmarks.storeBookmarks(typeList);
if(typeList == 'bkmrk_portals'){ window.plugin.bookmarks.updateStarPortal(); } if(typeList == 'bkmrk_portals'){ window.plugin.bookmarks.updateStarPortal(); }
} }
//---------------------------------------------------------------------------------------
// Remove the folder (from the localStorage)
//---------------------------------------------------------------------------------------
window.plugin.bookmarks.deletFolder = function(elem){ window.plugin.bookmarks.deletFolder = function(elem){
var typeList = $(elem).parent().parent().parent().parent('div').attr('id'); var typeList = $(elem).parent().parent().parent().parent('div').attr('id');
var ID = $(elem).parent().parent('li').attr('id'); var ID = $(elem).parent().parent('li').attr('id');
@ -164,6 +201,9 @@ function wrapper() {
if(typeList == 'bkmrk_portals'){ window.plugin.bookmarks.updateStarPortal(); } if(typeList == 'bkmrk_portals'){ window.plugin.bookmarks.updateStarPortal(); }
} }
//---------------------------------------------------------------------------------------
// Saved the new sort of the folders (in the localStorage)
//---------------------------------------------------------------------------------------
window.plugin.bookmarks.sortBookmarksFolder = function(typeList){ window.plugin.bookmarks.sortBookmarksFolder = function(typeList){
window.plugin.bookmarks.loadBookmarks(typeList); window.plugin.bookmarks.loadBookmarks(typeList);
var newArr = {}; var newArr = {};
@ -174,6 +214,10 @@ function wrapper() {
window.plugin.bookmarks[typeList] = newArr; window.plugin.bookmarks[typeList] = newArr;
window.plugin.bookmarks.storeBookmarks(typeList); window.plugin.bookmarks.storeBookmarks(typeList);
} }
//---------------------------------------------------------------------------------------
// Saved the new sort of the bookmarks (in the localStorage)
//---------------------------------------------------------------------------------------
window.plugin.bookmarks.sortBookmarks = function(typeList){ window.plugin.bookmarks.sortBookmarks = function(typeList){
window.plugin.bookmarks.loadBookmarks(typeList); window.plugin.bookmarks.loadBookmarks(typeList);
var list = window.plugin.bookmarks[typeList]; var list = window.plugin.bookmarks[typeList];
@ -203,34 +247,53 @@ function wrapper() {
window.plugin.bookmarks.storeBookmarks(typeList); window.plugin.bookmarks.storeBookmarks(typeList);
} }
//---------------------------------------------------------------------------------------
// Update the localStorage
//---------------------------------------------------------------------------------------
window.plugin.bookmarks.storeBookmarks = function(typeList){ window.plugin.bookmarks.storeBookmarks = function(typeList){
var bookmarksObject = {}; var bookmarksObject = {};
bookmarksObject[typeList] = plugin.bookmarks[typeList]; bookmarksObject[typeList] = plugin.bookmarks[typeList];
var bookmarksObjectJSON = JSON.stringify(bookmarksObject); var bookmarksObjectJSON = JSON.stringify(bookmarksObject);
localStorage[plugin.bookmarks['LOCAL_STORAGE_'+typeList]] = bookmarksObjectJSON; localStorage[plugin.bookmarks['LOCAL_STORAGE_'+typeList]] = bookmarksObjectJSON;
} }
//---------------------------------------------------------------------------------------
// Load the localStorage
//---------------------------------------------------------------------------------------
window.plugin.bookmarks.loadBookmarks = function(typeList){ window.plugin.bookmarks.loadBookmarks = function(typeList){
var bookmarksObjectJSON = localStorage[plugin.bookmarks['LOCAL_STORAGE_'+typeList]]; var bookmarksObjectJSON = localStorage[plugin.bookmarks['LOCAL_STORAGE_'+typeList]];
if(!bookmarksObjectJSON) return; if(!bookmarksObjectJSON) return;
var bookmarksObject = JSON.parse(bookmarksObjectJSON); var bookmarksObject = JSON.parse(bookmarksObjectJSON);
plugin.bookmarks[typeList] = bookmarksObject[typeList]; plugin.bookmarks[typeList] = bookmarksObject[typeList];
} }
//---------------------------------------------------------------------------------------
// Load the bookmarks
//---------------------------------------------------------------------------------------
window.plugin.bookmarks.loadList = function(typeList){ window.plugin.bookmarks.loadList = function(typeList){
window.plugin.bookmarks.loadBookmarks(typeList); window.plugin.bookmarks.loadBookmarks(typeList);
var element = ''; var element = '';
var elementTemp = '';
var elementExc = '';
// For each folder
var list = window.plugin.bookmarks[typeList]; var list = window.plugin.bookmarks[typeList];
for(var idFolders in list){ for(var idFolders in list){
var folders = list[idFolders]; var folders = list[idFolders];
var active = ''; var active = '';
// Create a label and a anchor for the sortable
var folderLabel = '<span class="folderLabel"><a class="bookmarksRemoveFrom" title="Remove this folder">X</a>'; var folderLabel = '<span class="folderLabel"><a class="bookmarksRemoveFrom" title="Remove this folder">X</a>';
folderLabel += '<a class="bookmarksAnchor"><span></span>'+folders['label']+'</a><span><span></span></span></span>'; folderLabel += '<a class="bookmarksAnchor"><span></span>'+folders['label']+'</a><span><span></span></span></span>';
if(folders['state']){ active = ' active'; } if(folders['state']){ active = ' active'; }
if(idFolders == window.plugin.bookmarks.KEY_OTHER_BKMRK){ folderLabel = ''; active= ' othersBookmarks active' } if(idFolders == window.plugin.bookmarks.KEY_OTHER_BKMRK){
element += '<li class="bookmarkFolder'+active+'" id="'+idFolders+'">'+folderLabel+'<ul>'; folderLabel = ''; active= ' othersBookmarks active';
}
// Create a folder
elementTemp = '<li class="bookmarkFolder'+active+'" id="'+idFolders+'">'+folderLabel+'<ul>';
// For each bookmark
var fold = folders['bkmrk']; var fold = folders['bkmrk'];
for(var idBkmrk in fold){ for(var idBkmrk in fold){
var btn_link; var btn_link;
@ -239,53 +302,143 @@ function wrapper() {
var label = bkmrk['label']; var label = bkmrk['label'];
var latlng = bkmrk['latlng']; var latlng = bkmrk['latlng'];
// If it's a map
if(typeList == 'bkmrk_maps'){ if(typeList == 'bkmrk_maps'){
if(bkmrk['label']==''){ label = bkmrk['latlng']+' ['+bkmrk['z']+']'; } if(bkmrk['label']==''){ label = bkmrk['latlng']+' ['+bkmrk['z']+']'; }
btn_link = '<a class="bookmarksLink" onclick="map.setView(['+latlng+'], '+bkmrk['z']+');return false;">'+label+'</a>'; btn_link = '<a class="bookmarksLink" onclick="map.setView(['+latlng+'], '+bkmrk['z']+');return false;">'+label+'</a>';
} }
// If it's a portal
else if(typeList == 'bkmrk_portals'){ else if(typeList == 'bkmrk_portals'){
var guid = bkmrk['guid']; var guid = bkmrk['guid'];
var btn_link = '<a class="bookmarksLink" onclick="window.zoomToAndShowPortal(\''+guid+'\', ['+latlng+']);return false;">'+label+'</a>'; var btn_link = '<a class="bookmarksLink" onclick="window.zoomToAndShowPortal(\''+guid+'\', ['+latlng+']);return false;">'+label+'</a>';
} }
element += '<li class="bkmrk" id="'+idBkmrk+'">'+btn_remove+btn_link+'</li>'; // Create the bookmark
elementTemp += '<li class="bkmrk" id="'+idBkmrk+'">'+btn_remove+btn_link+'</li>';
} }
element += '</li></ul>'; elementTemp += '</li></ul>';
//Add folder 'Others' in last position
if(idFolders != window.plugin.bookmarks.KEY_OTHER_BKMRK){ element += elementTemp; }
else{ elementExc = elementTemp; }
} }
element += elementExc;
// Append all folders and bookmarks
$('#'+typeList+' ul').html(element); $('#'+typeList+' ul').html(element);
} }
/***************************************************************************************************************************************************************/ /*********************************************************************************************************************/
//---------------------------------------------------------------------------------------
// Append the stylesheet
//---------------------------------------------------------------------------------------
window.plugin.bookmarks.setupCSS = function(){
$('<style>').prop('type', 'text/css').html('@@INCLUDESTRING:plugins/bookmarks-by-zaso-css-desktop.css@@').appendTo('head');
}
//---------------------------------------------------------------------------------------
// Append the stylesheet for mobile app
//---------------------------------------------------------------------------------------
window.plugin.bookmarks.setupCSS_mobile = function(){
$('<style>').prop('type', 'text/css').html('@@INCLUDESTRING:plugins/bookmarks-by-zaso-css-mobile.css@@').appendTo('head');
}
//---------------------------------------------------------------------------------------
// Append the js script
//---------------------------------------------------------------------------------------
window.plugin.bookmarks.setupJS = function(){$(document).ready(function(){ window.plugin.bookmarks.setupJS = function(){$(document).ready(function(){
//ENABLED THE DRAGGABLE PROPERTY OF THE BOX //ENABLED THE DRAGGABLE PROPERTY OF THE BOX
$('#bookmarksBox').draggable({ handle:'.handle', containment:'window' }); $('#bookmarksBox').draggable({ handle:'.handle', containment:'window' });
$("#bookmarksBox #bookmarksMin , #bookmarksBox ul li, #bookmarksBox ul li a, #bookmarksBox h5, #bookmarksBox .addForm a").disableSelection(); $("#bookmarksBox #bookmarksMin , #bookmarksBox ul li, #bookmarksBox ul li a, #bookmarksBox h5, #bookmarksBox .addForm a").disableSelection();
//SWICTH VISIBILITY PROPERTY OF THE BOX //SWICTH VISIBILITY PROPERTY OF THE BOX
$('#bookmarksMin').click(function(){ $('#bookmarksBox').animate({marginTop:'-100%'}, {duration:400, queue:false}); $('#bookmarksShow').animate({marginTop:-36}, {duration:400, queue:false}); localStorage[window.plugin.bookmarks['LOCAL_STORAGE_status_box']] = 0; }); $('#bookmarksMin').click(function(){
$('#bookmarksBox').animate({marginTop:'-100%'}, {duration:400, queue:false}); $('#bookmarksShow').animate({marginTop:-36}, {duration:400, queue:false}); localStorage[window.plugin.bookmarks['LOCAL_STORAGE_status_box']] = 0;
});
$('#bookmarksShow').click(function(){ $('#bookmarksBox').animate({marginTop:0}, {duration:400, queue:false}); $('#bookmarksShow').animate({marginTop:-100}, {duration:400, queue:false}); localStorage[window.plugin.bookmarks['LOCAL_STORAGE_status_box']]= 1; }); $('#bookmarksShow').click(function(){ $('#bookmarksBox').animate({marginTop:0}, {duration:400, queue:false}); $('#bookmarksShow').animate({marginTop:-100}, {duration:400, queue:false}); localStorage[window.plugin.bookmarks['LOCAL_STORAGE_status_box']]= 1; });
if(localStorage[window.plugin.bookmarks['LOCAL_STORAGE_status_box']] == 1){ $('#bookmarksShow').trigger('click'); }else{ $('#bookmarksMin').trigger('click'); } if(localStorage[window.plugin.bookmarks['LOCAL_STORAGE_status_box']] == 1){ $('#bookmarksShow').trigger('click'); }else{ $('#bookmarksMin').trigger('click'); }
//SWITCH LIST (MAPS/PORTALS) //SWITCH LIST (MAPS/PORTALS)
$('#bookmarksBox h5').click(function(){$('h5').removeClass('current');$(this).addClass('current');var sectList = '#'+$(this).attr('class').replace(' current', '');$('#bookmarksBox .bookmarkList').removeClass('current');$(sectList).addClass('current');}); $('#bookmarksBox h5').click(function(){
$('h5').removeClass('current');
$(this).addClass('current');
var sectList = '#'+$(this).attr('class').replace(' current', '');
$('#bookmarksBox .bookmarkList').removeClass('current');
$(sectList).addClass('current');
});
//ACTIVE VERTICAL SCROLL-BAR ON THE LONG LISTS if(!window.isSmartphone()){
//DESTOP: active vertical scroll-bar on the long lists
$('.bookmarkList > ul').enscroll({ showOnHover: true, verticalTrackClass: 'trackScroll', verticalHandleClass: 'handleScroll', minScrollbarLength:28 }); $('.bookmarkList > ul').enscroll({ showOnHover: true, verticalTrackClass: 'trackScroll', verticalHandleClass: 'handleScroll', minScrollbarLength:28 });
//OPEN/CLOSE FOLDER (to be corrected in mobile mode)---------------
$('#bookmarksBox').on('click', '.bookmarksAnchor', function(e){
window.plugin.bookmarks.openFolder(this);
$(this).parent().parent('li').toggleClass('active');
e.preventDefault();
});
}
//ENABLED THE SORTABLE PROPERTY OF THE FOLDERS AND BOOKMARKS //ENABLED THE SORTABLE PROPERTY OF THE FOLDERS AND BOOKMARKS
$(".bookmarkList > ul").sortable({items:"li.bookmarkFolder:not(.othersBookmarks)",handle:".bookmarksAnchor",distance:5,placeholder:"sortable-placeholder",forcePlaceholderSize:true, $(".bookmarkList > ul").sortable({
items:"li.bookmarkFolder:not(.othersBookmarks)",
handle:".bookmarksAnchor",
placeholder:"sortable-placeholder",
forcePlaceholderSize:true,
helper:'clone',
distance:5,
update:function(event, ui){ update:function(event, ui){
var typeList = $('#'+ui.item.context.id).parent().parent('.bookmarkList').attr('id'); var typeList = $('#'+ui.item.context.id).parent().parent('.bookmarkList').attr('id');
window.plugin.bookmarks.sortBookmarksFolder(typeList); window.plugin.bookmarks.sortBookmarksFolder(typeList);
} }
}); });
$(".bookmarkList ul li ul").sortable({items:"li.bkmrk",connectWith:".bookmarkList ul ul",handle:".bookmarksLink",distance:5,placeholder:"sortable-placeholder",forcePlaceholderSize:true, $(".bookmarkList ul li ul").sortable({
items:"li.bkmrk",
connectWith:".bookmarkList ul ul",
handle:".bookmarksLink",
placeholder:"sortable-placeholder",
forcePlaceholderSize:true,
helper:'clone',
distance:5,
update:function(event, ui){ update:function(event, ui){
var typeList = $('#'+ui.item.context.id).parent().parent().parent().parent('.bookmarkList').attr('id'); var typeList = $('#'+ui.item.context.id).parent().parent().parent().parent('.bookmarkList').attr('id');
window.plugin.bookmarks.sortBookmarks(typeList); window.plugin.bookmarks.sortBookmarks(typeList);
} }
}); });
if(window.isSmartphone()){
// The clone not working in mobile mode (to be corrected)---------------
$(".bookmarkList > ul").sortable("option", "helper", "original");
$(".bookmarkList ul li ul").sortable("option", "helper", "original");
};
//ADD BOOKMARK/FOLDER
$('#bookmarksBox .addForm a').click(function(e){
var typeList = $(this).parent().parent('div').attr('id');
if($(this).hasClass('newMap')){ window.plugin.bookmarks.addBookmarkMap(this); }
else{ window.plugin.bookmarks.addFolder(typeList); }
//REFRESS SORTABLE EVENT FOR BKMRK
$(".bookmarkList ul li ul").sortable({
items:"li.bkmrk",
connectWith:".bookmarkList ul ul",
handle:".bookmarksLink",
placeholder:"sortable-placeholder",
forcePlaceholderSize:true,
helper:'clone',
distance:5,
update:function(event, ui){
var typeList = $('#'+ui.item.context.id).parent().parent().parent().parent('.bookmarkList').attr('id');
window.plugin.bookmarks.sortBookmarks(typeList);
}
});
if(window.isSmartphone()){
// The clone not working in mobile mode (to be corrected)---------------
$(".bookmarkList ul li ul").sortable("option", "helper", "original");
};
e.preventDefault();
});
//REMOVE FOLDER //REMOVE FOLDER
$('.bookmarkList').on('click', '.folderLabel .bookmarksRemoveFrom', function(e){ $('.bookmarkList').on('click', '.folderLabel .bookmarksRemoveFrom', function(e){
window.plugin.bookmarks.deletFolder(this); window.plugin.bookmarks.deletFolder(this);
@ -300,81 +453,93 @@ function wrapper() {
e.preventDefault(); e.preventDefault();
}); });
//OPEN/CLOSE FOLDER
$('#bookmarksBox').on('click', '.bookmarksAnchor', function(e){ if(window.isSmartphone()){
window.plugin.bookmarks.openFolder(this); //FOR MOBILE
$(this).parent().parent('li').toggleClass('active'); $('#bookmarksBox').hide();
e.preventDefault(); $('#bookmarksShowMobile').click(function(){
$(this).toggleClass('open');
$('#bookmarksBox').toggle();
if($(this).hasClass('open')){ $(this).text('[-] Bookmarks'); }
else{ $(this).text('[+] Bookmarks'); }
}); });
//ADD BOOKMARK/FOLDER
$('#bookmarksBox .addForm a').click(function(e){
var typeList = $(this).parent().parent('div').attr('id');
if($(this).hasClass('newMap')){ window.plugin.bookmarks.addBookmarkMap(this); }
else{ window.plugin.bookmarks.addFolder(typeList); }
//REFRESS SORTABLE EVENT FOR BKMRK
$(".bookmarkList ul li ul").sortable({items:"li.bkmrk",connectWith:".bookmarkList ul ul",handle:".bookmarksLink",distance:5,placeholder:"sortable-placeholder",forcePlaceholderSize:true,
update:function(event, ui){
var typeList = $('#'+ui.item.context.id).parent().parent().parent().parent('.bookmarkList').attr('id');
window.plugin.bookmarks.sortBookmarks(typeList);
} }
});
e.preventDefault();
});
});} });}
window.plugin.bookmarks.setupCSS = function(){ //---------------------------------------------------------------------------------------
$('<style>').prop('type','text/css').html('@@INCLUDESTRING:plugins/bookmarks-by-zaso.css@@').appendTo('head'); // HTML element
} //---------------------------------------------------------------------------------------
window.plugin.bookmarks.setupContent = function(){ window.plugin.bookmarks.setupContent = function(){
plugin.bookmarks.contentStarHTML = '<a id="bookmarkStar" onclick="window.plugin.bookmarks.switchStarPortal();return false;" title="Save this portal in your bookmarks"><span></span></a>'; plugin.bookmarks.contentStarHTML = '<a id="bookmarkStar" onclick="window.plugin.bookmarks.switchStarPortal();return false;" title="Save this portal in your bookmarks"><span></span></a>';
plugin.bookmarks.disabledMessage = '<div class="notStorageSupport" title="Your browser do not support localStorage">Plugin Bookmarks disabled</div>'; plugin.bookmarks.disabledMessage = '<div title="Your browser do not support localStorage">Plugin Bookmarks disabled</div>';
plugin.bookmarks.bkmrkRibbon = '<a id="bookmarksShow"></a>'; plugin.bookmarks.bkmrkRibbon = '<a id="bookmarksShow"></a>';
plugin.bookmarks.bkmrkBox = '<div id="bookmarksBox">' plugin.bookmarks.bkmrkBox = '<div id="bookmarksBox">'
+'<div id="topBar"><a id="bookmarksMin" class="btn" title="Minimize">-</a><div class="handle">...</div></div>' +'<div id="topBar"><a id="bookmarksMin" class="btn" title="Minimize">-</a><div class="handle">...</div></div>'
+'<div id="bookmarksTypeBar"><h5 class="bkmrk_maps current">Maps</h5><h5 class="bkmrk_portals">Portals</h5></div>' +'<div id="bookmarksTypeBar"><h5 class="bkmrk_maps current">Maps</h5><h5 class="bkmrk_portals">Portals</h5><div style="clear:both !important;"></div></div>'
+'<div id="bkmrk_maps" class="bookmarkList current"><div class="addForm"><input placeholder="Insert label"><a class="newMap" onmouseover="setPermaLink(this);return false">+ Map</a><a class="newFolder">+ Folder</a></div><ul></ul></div>' +'<div id="bkmrk_maps" class="bookmarkList current"><div class="addForm"><input placeholder="Insert label"><a class="newMap" onmouseover="setPermaLink(this);return false">+ Map</a><a class="newFolder">+ Folder</a></div><ul></ul></div>'
+'<div id="bkmrk_portals" class="bookmarkList"><div class="addForm"><input placeholder="Insert label"><a class="newFolder">+ Folder</a></div><ul></ul></div>' +'<div id="bkmrk_portals" class="bookmarkList"><div class="addForm"><input placeholder="Insert label"><a class="newFolder">+ Folder</a></div><ul></ul></div>'
+'</div>'; +'</div>';
plugin.bookmarks.bkmrkTriggerMobile= '<a id="bookmarksShowMobile">[+] Bookmarks</a>';
} }
/***************************************************************************************************************************************************************/ /***************************************************************************************************************************************************************/
var setup = function(){ var setup = function(){
//Set the localStorage (if not exist)
if(!localStorage[window.plugin.bookmarks['LOCAL_STORAGE_bkmrk_portals']]){localStorage[plugin.bookmarks['LOCAL_STORAGE_bkmrk_portals']] = '{"bkmrk_portals":{"'+window.plugin.bookmarks.KEY_OTHER_BKMRK+'":{"label":"Others","state":1,"bkmrk":{}}}}'; } if(!localStorage[window.plugin.bookmarks['LOCAL_STORAGE_bkmrk_portals']]){localStorage[plugin.bookmarks['LOCAL_STORAGE_bkmrk_portals']] = '{"bkmrk_portals":{"'+window.plugin.bookmarks.KEY_OTHER_BKMRK+'":{"label":"Others","state":1,"bkmrk":{}}}}'; }
if(!localStorage[window.plugin.bookmarks['LOCAL_STORAGE_bkmrk_maps']]){localStorage[plugin.bookmarks['LOCAL_STORAGE_bkmrk_maps']] = '{"bkmrk_maps":{"'+window.plugin.bookmarks.KEY_OTHER_BKMRK+'":{"label":"Others","state":1,"bkmrk":{}}}}'; } if(!localStorage[window.plugin.bookmarks['LOCAL_STORAGE_bkmrk_maps']]){localStorage[plugin.bookmarks['LOCAL_STORAGE_bkmrk_maps']] = '{"bkmrk_maps":{"'+window.plugin.bookmarks.KEY_OTHER_BKMRK+'":{"label":"Others","state":1,"bkmrk":{}}}}'; }
if(!localStorage[window.plugin.bookmarks['LOCAL_STORAGE_status_box']]){localStorage[plugin.bookmarks['LOCAL_STORAGE_status_box']] = 0;} if(!localStorage[window.plugin.bookmarks['LOCAL_STORAGE_status_box']]){localStorage[plugin.bookmarks['LOCAL_STORAGE_status_box']] = 1;}
if($.inArray('pluginBookmarksUpdate', window.VALID_HOOKS) < 0){ window.VALID_HOOKS.push('pluginBookmarksUpdate'); } //Load data from localStorage
window.plugin.bookmarks.setupCSS();
window.plugin.bookmarks.setupJS();
window.plugin.bookmarks.setupContent();
window.plugin.bookmarks.loadBookmarks('bkmrk_portals'); window.plugin.bookmarks.loadBookmarks('bkmrk_portals');
window.plugin.bookmarks.loadBookmarks('bkmrk_maps'); window.plugin.bookmarks.loadBookmarks('bkmrk_maps');
window.addHook('portalDetailsUpdated', window.plugin.bookmarks.addStarToSidebar);
//Add to DOM the element of the plugin and load data from localStorage if(window.isSmartphone()){
$('body').append(plugin.bookmarks.bkmrkRibbon); //FOR MOBILE: load the script for the touch events
$('body').append(plugin.bookmarks.bkmrkBox); var script2 = document.createElement('script');
script2.type = 'text/javascript';
script2.src = 'https://raw.github.com/furf/jquery-ui-touch-punch/master/jquery.ui.touch-punch.min.js';
script2.appendChild(document.createTextNode('('+ wrapper +')();'));
(document.body || document.head || document.documentElement).appendChild(script2);
}else{
//FOR DESKTOP: load the script to active the vertical scrollbar (in the bookmarks box)
var script3 = document.createElement('script');
script3.type = 'text/javascript';
script3.src = 'http://enscrollplugin.com/releases/enscroll-0.4.0.min.js';
script3.appendChild(document.createTextNode('('+ wrapper +')();'));
(document.body || document.head || document.documentElement).appendChild(script3);
}
if($.inArray('pluginBookmarksUpdate', window.VALID_HOOKS) < 0){ window.VALID_HOOKS.push('pluginBookmarksUpdate'); }
window.plugin.bookmarks.setupCSS();
if(window.isSmartphone()){window.plugin.bookmarks.setupCSS_mobile();}
window.plugin.bookmarks.setupContent();
//Append the bookmarks box
if(!window.isSmartphone()){ $('body').append(plugin.bookmarks.bkmrkRibbon+plugin.bookmarks.bkmrkBox); }
else{ $('#portaldetails').before(plugin.bookmarks.bkmrkTriggerMobile+plugin.bookmarks.bkmrkBox); }
//Load bookmarks and folders in the box
window.plugin.bookmarks.loadList('bkmrk_maps'); window.plugin.bookmarks.loadList('bkmrk_maps');
window.plugin.bookmarks.loadList('bkmrk_portals'); window.plugin.bookmarks.loadList('bkmrk_portals');
//Load the js page for the scrollbar window.plugin.bookmarks.setupJS();
var script2 = document.createElement('script'); window.addHook('portalDetailsUpdated', window.plugin.bookmarks.addToSidebar);
script2.type = 'text/javascript';
script2.src = 'http://enscrollplugin.com/releases/enscroll-0.4.0.min.js';
script2.appendChild(document.createTextNode('('+ wrapper +')();'));
(document.body || document.head || document.documentElement).appendChild(script2);
} }
// PLUGIN END //////////////////////////////////////////////////////////
if(window.iitcLoaded && typeof setup === 'function'){ setup(); } // PLUGIN END //////////////////////////////////////////////////////////
else{ if(window.bootPlugins){ window.bootPlugins.push(setup); } else{ window.bootPlugins = [setup]; }}
if(window.iitcLoaded && typeof setup === 'function') {
setup();
} else {
if(window.bootPlugins)
window.bootPlugins.push(setup);
else
window.bootPlugins = [setup];
}
} // wrapper end } // wrapper end
// inject code into site context // inject code into site context
var script = document.createElement('script'); var script = document.createElement('script');
script.appendChild(document.createTextNode('('+ wrapper +')();')); script.appendChild(document.createTextNode('('+ wrapper +')();'));
(document.body || document.head || document.documentElement).appendChild(script); (document.body || document.head || document.documentElement).appendChild(script);