updated bookmarks plugin, as submitted by the author with stylesheet fixes

(some non-standard indentation at the moment though)
This commit is contained in:
Jon Atkins 2013-06-07 17:49:10 +01:00
parent 508c2543f4
commit ffbf82a44e
2 changed files with 637 additions and 633 deletions

View File

@ -1,368 +1,380 @@
#bookmarksBox * {
display: block; #bookmarksBox *{
width: auto; display:block;
height: auto; padding:0;
font-family: Verdana,Geneva,sans-serif; margin:0;
font-size: 13px; width:auto;
line-height: 22px; height:auto;
text-indent: 0; font-family:Verdana, Geneva, sans-serif;
text-decoration: none; font-size:13px;
margin: 0; line-height:22px;
padding: 0; text-indent:0;
text-decoration:none;
} }
#bookmarksBox {
margin-top: -100%; #bookmarksBox{
position: absolute!important; margin-top:-100%;
z-index: 4001; position:absolute !important;
top: 100px; z-index:4001;
left: 100px; top:100px;
left:100px;
}
#bookmarksBox .addForm,
#bookmarksBox #bookmarksTypeBar,
#bookmarksBox h5{
height:28px;
overflow:hidden;
color:#fff;
font-size:14px;
} }
#bookmarksBox .addForm,#bookmarksBox #bookmarksTypeBar,#bookmarksBox h5 {
height: 28px; #bookmarksBox #topBar,
overflow: hidden; #bookmarksBox #topBar *{
color: #fff; height:15px !important;
font-size: 14px;
} }
#bookmarksBox #topBar,#bookmarksBox #topBar * { #bookmarksBox #topBar *{
height: 15px!important; float:left !important;
}
#bookmarksBox .handle{
text-indent:-20px;
width:209px;
text-align:center;
color:#fff;
line-height:8px;
cursor:move;
} }
#bookmarksBox #topBar * { #bookmarksBox #topBar .btn{
float: left!important; display:block;
width:19px;
cursor:pointer;
color:#20a8b1;
}
#bookmarksBox #topBar #bookmarksMin{
font-weight:bold;
text-align:center;
line-height:14px;
font-size:18px;
}
#bookmarksBox #topBar #bookmarksMin:hover{
color:gold;
} }
#bookmarksBox .handle { #bookmarksBox #bookmarksTypeBar{
text-indent: -20px; clear:both;
width: 209px;
text-align: center;
color: #fff;
line-height: 8px;
cursor: move;
} }
#bookmarksBox #topBar .btn { #bookmarksBox h5{
display: block; padding:4px 0;
width: 19px; width:114px;
cursor: pointer; text-align:center;
color: #20a8b1; color:#788;
} }
#bookmarksBox #topBar #bookmarksMin { #bookmarksBox h5.current{
font-weight: 700; cursor:default;
text-align: center; background:none;
line-height: 14px; color:#fff !important;
font-size: 18px; }
#bookmarksBox h5:hover{
color:gold;
background:rgba(0,0,0,0);
} }
#bookmarksBox #topBar #bookmarksMin: hover { #bookmarksBox #topBar .btn,
color: #FFD700; #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);
} }
#bookmarksBox #bookmarksTypeBar { #bookmarksBox h5,
clear: both; #bookmarksBox .bookmarkList li.bkmrk:hover .bookmarksLink,
#bookmarksBox .addForm *{
background:rgba(0,0,0,.3);
} }
#bookmarksBox h5 { #bookmarksBox .addForm *{
width: 114px; display:block;
text-align: center; float:left;
color: #788; padding:4px 8px 3px;
padding: 4px 0;
} }
#bookmarksBox h5.current { #bookmarksBox .addForm a{
cursor: default; cursor:pointer;
background: 0; color:#20a8b1;
color: #fff!important; font-size:12px;
width:65px;
text-align:center;
line-height:20px;
padding:4px 0 3px;
} }
#bookmarksBox h5: hover { #bookmarksBox .addForm a:hover{
color: #FFD700; background:gold;
background: rgba(0,0,0,0); color:#000;
text-decoration:none;
} }
#bookmarksBox #topBar .btn,#bookmarksBox .addForm,#bookmarksBox .handle,#bookmarksBox #bookmarksTypeBar,#bookmarksBox .bookmarkList li.bookmarksEmpty,#bookmarksBox .bookmarkList li.bkmrk a,#bookmarksBox .bookmarkList li.bkmrk: hover { #bookmarksBox .addForm input{
background-color: rgba(8,48,78,.85); font-size:11px !important;
color:#ffce00;
width:81px;
line-height:11px;
font-size:12px;
-webkit-box-sizing:content-box;
-moz-box-sizing:content-box;
box-sizing:content-box;
} }
#bookmarksBox h5,#bookmarksBox .bookmarkList li.bkmrk: hover .bookmarksLink,#bookmarksBox .addForm * { #bookmarksBox #bkmrk_portals .addForm input{
background: rgba(0,0,0,.3); width:147px;
} }
#bookmarksBox .addForm * { #bookmarksBox .addForm input:hover,
display: block; #bookmarksBox .addForm input:focus{
float: left; outline:0;
padding: 4px 8px 3px; background:rgba(0,0,0,.6);
} }
#bookmarksBox .addForm a { #bookmarksBox .bookmarkList > ul{
cursor: pointer; width:231px;
color: #20a8b1; clear:both;
font-size: 12px; list-style-type:none;
width: 65px; color:#fff;
text-align: center; overflow:hidden;
line-height: 20px; max-height:550px;
padding: 4px 0 3px;
} }
#bookmarksBox .addForm a: hover { #bookmarksBox .sortable-placeholder{
background: #FFD700; background:rgba(8,48,78,.55);
color: #000; box-shadow:inset 1px 0 0 #20a8b1;
text-decoration: none; }
#bookmarksBox .ui-sortable-helper{
border-top-width:1px;
} }
#bookmarksBox .addForm input { #bookmarksBox .bookmarkList{ display:none; }
font-size: 11px!important; #bookmarksBox .bookmarkList.current{ display:block; }
color: #ffce00;
width: 81px; #bookmarksBox h5,
line-height: 11px; #bookmarksBox .addForm *,
-webkit-box-sizing: content-box; #bookmarksBox ul li.bkmrk,
-moz-box-sizing: content-box; #bookmarksBox ul li.bkmrk a{
box-sizing: content-box; height:22px;
} }
#bookmarksBox #bkmrk_portals .addForm input { #bookmarksBox h5,
width: 147px; #bookmarksBox ul li.bkmrk a{
overflow:hidden;
cursor:pointer;
float:left;
}
#bookmarksBox ul .bookmarksEmpty{ text-indent:27px; color:#eee; }
#bookmarksBox ul .bookmarksRemoveFrom{ width:19px; text-align:center; color:#fff; }
#bookmarksBox ul .bookmarksLink{ width:171px; padding:0 10px 0 8px; color:gold; }
#bookmarksBox ul .bookmarksLink.selected{ color:#03fe03; }
#bookmarksBox ul .othersBookmarks .bookmarksLink{ width:190px; }
#bookmarksBox ul .bookmarksLink:hover{ color:#03fe03; }
#bookmarksBox ul .bookmarksRemoveFrom:hover{ color:#fff; background:#e22; }
/************************************/
#bookmarksBox,
#bookmarksBox *
{ border-color:#20a8b1; border-style:solid; border-width:0; }
#bookmarksBox #topBar
, #bookmarksBox ul .bookmarkFolder
{ border-top-width:1px; }
#bookmarksBox #topBar
, #bookmarksBox #bookmarksTypeBar
, #bookmarksBox .addForm
, #bookmarksBox ul .bookmarkFolder .folderLabel
, #bookmarksBox ul li.bkmrk
{ border-bottom-width:1px; }
#bookmarksBox ul .bookmarkFolder
, #bookmarksBox ul .bookmarksRemoveFrom
{ border-right-width:1px; border-left-width:1px; }
#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:0px; }
/************************************/
#bookmarksShow{
display:block;
position:absolute;
top:0;
left:250px;
width:47px;
margin-top:-36px;
height:64px;
cursor:pointer;
z-index:4005;
background-position:center bottom;
background-repeat:no-repeat;
transition:margin-top 100ms ease-in-out;
background-image:url(@@INCLUDEIMAGE:plugins/bookmarks-by-zaso-logo.png@@);
}
#bookmarksShow:hover{
margin-top:0px !important;
} }
#bookmarksBox .addForm input: hover,#bookmarksBox .addForm input: focus { #bookmarkStar{
outline: 0; display:inline-block;
background: rgba(0,0,0,.6); position:relative;
top:1px;
margin-right:3px;
width:16px;
height:15px;
overflow:hidden;
background-image:url(@@INCLUDEIMAGE:plugins/bookmarks-by-zaso-star.png@@);
background-position:left center;
background-repeat:no-repeat;
}
#bookmarkStar:hover,
#bookmarkStar.favorite{
background-position:right center;
} }
#bookmarksBox .bookmarkList>ul { #bookmarksBox .handleScroll{
width: 231px; cursor:s-resize;
clear: both; width:3px;
list-style-type: none; right:3px;
color: #fff; background:gold;
overflow: hidden; opacity:.7;
max-height: 550px;
} }
#bookmarksBox .sortable-placeholder { /************************************/
background: rgba(8,48,78,.55);
box-shadow: inset 1px 0 0 #20a8b1; #bookmarksBox .bookmarkList .bookmarkFolder{
overflow:hidden;
margin-top:-1px;
height:auto;
background:rgba(8,58,78,.7);
} }
#bookmarksBox .bookmarkList { #bookmarksBox .bookmarkList ul li.sortable-placeholder{
display: none; box-shadow:inset -1px 0 0 #20a8b1, inset 1px 0 0 #20a8b1, 0 -1px 0 #20a8b1;
background:rgba(8,58,78,.9);
} }
#bookmarksBox h5,#bookmarksBox .addForm *,#bookmarksBox ul li.bkmrk,#bookmarksBox ul li.bkmrk a { #bookmarksBox .bookmarkList .bkmrk.ui-sortable-helper{
height: 22px; border-right-width:1px;
border-left-width:1px;
}
#bookmarksBox .bookmarkList ul li ul li.sortable-placeholder{
height:23px;
box-shadow:inset 0 -1px 0 #20a8b1, inset 1px 0 0 #20a8b1;
} }
#bookmarksBox h5,#bookmarksBox ul li.bkmrk a { #bookmarksBox .bookmarkList ul li.bookmarkFolder.ui-sortable-helper,
overflow: hidden; #bookmarksBox .bookmarkList ul li.othersBookmarks ul,
cursor: pointer; #bookmarksBox .bookmarkList ul li.othersBookmarks ul li.sortable-placeholder{
float: left; box-shadow:inset 0 -1px 0 #20a8b1;
} }
#bookmarksBox ul .bookmarksEmpty { #bookmarksBox .bookmarkList .bookmarkFolder .folderLabel .bookmarksAnchor span,
text-indent: 27px; #bookmarksBox .bookmarkList .bookmarkFolder .folderLabel > span,
color: #eee; #bookmarksBox .bookmarkList .bookmarkFolder .folderLabel > span > span,
#bookmarksBox .bookmarkList .triangle{
width:0px;
height:0px;
} }
#bookmarksBox ul .bookmarksRemoveFrom { /************************************/
width: 19px;
text-align: center; #bookmarksBox .bookmarkList .bookmarkFolder .folderLabel{
color: #fff; overflow:visible;
height:25px;
cursor:pointer;
background:#069;
text-indent:0px;
}
#bookmarksBox .bookmarkList .bookmarkFolder .folderLabel > *{
height:25px;
float:left;
}
#bookmarksBox .bookmarkList .bookmarkFolder .folderLabel .bookmarksAnchor{
line-height:25px;
color:#fff;
width:209px;
}
#bookmarksBox .bookmarkList .bookmarkFolder .folderLabel .bookmarksAnchor span{
float:left;
border-width:5px 0 5px 7px;
border-color:transparent transparent transparent white;
margin:7px 7px 0 6px;
}
#bookmarksBox .bookmarkList .bookmarkFolder.active .folderLabel .bookmarksAnchor span{
margin:9px 5px 0 5px;
border-width:7px 5px 0 5px;
border-color:white transparent transparent transparent;
} }
#bookmarksBox ul .bookmarksLink { /************************************************************************************************************/
width: 171px;
color: #FFD700; #bookmarksBox .bookmarkList .bookmarkFolder .folderLabel > span,
padding: 0 10px 0 8px; #bookmarksBox .bookmarkList .bookmarkFolder .folderLabel > span > span{
display:none;
border-width:0px 12px 10px 0;
border-color:transparent #20a8b1 transparent transparent;
margin:-20px 0 0;
position:relative;
top:21px;
left:219px;
}
#bookmarksBox .bookmarkList .bookmarkFolder .folderLabel > span > span{
top:18px;
left:0px;
border-width:0px 10px 9px 0;
border-color:transparent #069 transparent transparent;
}
#bookmarksBox .bookmarkList .bookmarkFolder.active .folderLabel > span,
#bookmarksBox .bookmarkList .bookmarkFolder.active .folderLabel > span > span{
display:block;
}
#bookmarksBox .bookmarkList .bookmarkFolder.active .folderLabel:hover > span > span{
border-color:transparent #036 transparent transparent;
} }
#bookmarksBox ul .othersBookmarks .bookmarksLink { /************************************************************************************************************/
width: 190px;
#bookmarksBox .bookmarkList .bookmarkFolder .folderLabel:hover .bookmarksAnchor{
background:#036;
} }
#bookmarksBox ul .bookmarksRemoveFrom: hover { #bookmarksBox .bookmarkList .bookmarkFolder ul{
color: #fff; display:none;
background: #e22; margin-left:19px;
}
#bookmarksBox .bookmarkList .bookmarkFolder.active ul{
display:block;
min-height:22px;
} }
#bookmarksBox,#bookmarksBox * { #bookmarksBox .bookmarkFolder.othersBookmarks ul{
border-color: #20a8b1; margin-left:0;
border-style: solid; }
border-width: 0;
}
#bookmarksBox #topBar,#bookmarksBox #bookmarksTypeBar,#bookmarksBox .addForm,#bookmarksBox ul .bookmarkFolder .folderLabel,#bookmarksBox ul li.bkmrk {
border-bottom-width: 1px;
}
#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 {
display: block;
position: absolute;
top: 0;
left: 250px;
width: 47px;
margin-top: -100%;
height: 64px;
cursor: pointer;
z-index: 4005;
background-position: center bottom;
background-repeat: no-repeat;
transition: margin-top 100ms ease-in-out;
background-image: url(@@INCLUDEIMAGE:plugins/bookmarks-by-zaso-logo.png@@);
}
#bookmarksShow: hover {
margin-top: 0!important;
}
#bookmarkStar {
display: inline-block;
position: relative;
top: 1px;
margin-right: 3px;
width: 16px;
height: 15px;
overflow: hidden;
background-image: url(@@INCLUDEIMAGE:plugins/bookmarks-by-zaso-star.png@@);
background-position: left center;
background-repeat: no-repeat;
}
#bookmarkStar: hover,#bookmarkStar.favorite {
background-position: right center;
}
#bookmarksBox .handleScroll {
cursor: s-resize;
width: 3px;
right: 3px;
background: #FFD700;
opacity: .7;
}
#bookmarksBox .bookmarkList .bookmarkFolder {
overflow: hidden;
margin-top: -1px;
height: auto;
background: rgba(8,58,78,.7);
}
#bookmarksBox .bookmarkList ul li.sortable-placeholder {
box-shadow: inset -1px 0 0 #20a8b1,inset 1px 0 0 #20a8b1,0 -1px 0 #20a8b1;
background: rgba(8,58,78,.9);
}
#bookmarksBox .bookmarkList ul li ul li.sortable-placeholder {
height: 23px;
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 {
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 {
width: 0;
height: 0;
}
#bookmarksBox .bookmarkList .bookmarkFolder .folderLabel {
overflow: visible;
height: 25px;
cursor: pointer;
background: #069;
text-indent: 0;
}
#bookmarksBox .bookmarkList .bookmarkFolder .folderLabel>* {
height: 25px;
float: left;
}
#bookmarksBox .bookmarkList .bookmarkFolder .folderLabel .bookmarksAnchor {
line-height: 25px;
color: #fff;
width: 209px;
}
#bookmarksBox .bookmarkList .bookmarkFolder .folderLabel .bookmarksAnchor span {
float: left;
border-color: transparent transparent transparent #FFF;
border-width: 5px 0 5px 7px;
margin: 7px 7px 0 6px;
}
#bookmarksBox .bookmarkList .bookmarkFolder.active .folderLabel .bookmarksAnchor span {
border-color: #FFF transparent transparent;
border-width: 7px 5px 0;
margin: 9px 5px 0;
}
#bookmarksBox .bookmarkList .bookmarkFolder .folderLabel>span,#bookmarksBox .bookmarkList .bookmarkFolder .folderLabel>span>span {
display: none;
position: relative;
top: 21px;
left: 219px;
border-color: transparent #20a8b1 transparent transparent;
border-width: 0 12px 10px 0;
margin: -20px 0 0;
}
#bookmarksBox .bookmarkList .bookmarkFolder .folderLabel>span>span {
top: 18px;
left: 0;
border-color: transparent #069 transparent transparent;
border-width: 0 10px 9px 0;
}
#bookmarksBox .bookmarkList .bookmarkFolder.active .folderLabel: hover>span>span {
border-color: transparent #036 transparent transparent;
}
#bookmarksBox .bookmarkList .bookmarkFolder .folderLabel: hover .bookmarksAnchor {
background: #036;
}
#bookmarksBox .bookmarkList .bookmarkFolder ul {
display: none;
margin-left: 19px;
}
#bookmarksBox .bookmarkList .bookmarkFolder.active ul {
display: block;
min-height: 22px;
}
#bookmarksBox .bookmarkFolder.othersBookmarks ul {
margin-left: 0;
}
#bookmarksBox .ui-sortable-helper,#bookmarksBox #topBar,#bookmarksBox ul .bookmarkFolder {
border-top-width: 1px;
}
#bookmarksBox .bookmarkList.current,#bookmarksBox .bookmarkList .bookmarkFolder.active .folderLabel>span,#bookmarksBox .bookmarkList .bookmarkFolder.active .folderLabel>span>span {
display: block;
}
#bookmarksBox ul .bookmarksLink.selected,#bookmarksBox ul .bookmarksLink: hover {
color: #03fe03;
}
#bookmarksBox ul .bookmarkFolder,#bookmarksBox ul .bookmarksRemoveFrom,#bookmarksBox .bookmarkList .bkmrk.ui-sortable-helper {
border-right-width: 1px;
border-left-width: 1px;
}

View File

@ -5,384 +5,376 @@
// @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@@
// @description [@@BUILDNAME@@-@@BUILDDATE@@] Save your favorite Maps and Portals. // @description [@@BUILDNAME@@-@@BUILDDATE@@] Save your favorite Maps and Portals and move the intelmap view in a second. The ingress world just a click.
// @include https://www.ingress.com/intel* // @include https://www.ingress.com/intel*
// @include http://www.ingress.com/intel* // @include http://www.ingress.com/intel*
// @match https://www.ingress.com/intel* // @match https://www.ingress.com/intel*
// @match http://www.ingress.com/intel* // @match http://www.ingress.com/intel*
// ==/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 ////////////////////////////////////////////////////////
// use own namespace for plugin
window.plugin.bookmarks = function(){};
// PLUGIN START //////////////////////////////////////////////////////// window.plugin.bookmarks.KEY_OTHER_BKMRK = 'idOthers';
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_maps = 'plugin-bookmarks-maps-data';
window.plugin.bookmarks.bkmrk_portals = {};
window.plugin.bookmarks.bkmrk_maps = {};
// use own namespace for plugin window.plugin.bookmarks.disabledMessage;
window.plugin.bookmarks = function() {}; window.plugin.bookmarks.contentStarHTML;
window.plugin.bookmarks.bkmrkBox;
window.plugin.bookmarks.KEY_OTHER_BKMRK = 'idOthers'; window.plugin.bookmarks.bkmrkRibbon;
window.plugin.bookmarks.LOCAL_STORAGE_status_box = 'plugin-bookmarks-status-box'; window.plugin.bookmarks.loadList;
window.plugin.bookmarks.LOCAL_STORAGE_bkmrk_portals = 'plugin-bookmarks-portals-data'; window.plugin.bookmarks.setupJS;
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;
window.plugin.bookmarks.bkmrkBox;
window.plugin.bookmarks.bkmrkRibbon;
window.plugin.bookmarks.loadList;
window.plugin.bookmarks.setupJS;
/***************************************************************************************************************************************************************/ /***************************************************************************************************************************************************************/
window.plugin.bookmarks.addStarToSidebar = function() { 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(); var title = $('#portaldetails > h3').text();
$('#portaldetails > h3').html(plugin.bookmarks.contentStarHTML+title); $('#portaldetails > h3').html(plugin.bookmarks.contentStarHTML+title);
plugin.bookmarks.updateStarPortal(); plugin.bookmarks.updateStarPortal();
} }
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']; var list = plugin.bookmarks['bkmrk_portals'];
$('#bookmarkStar').removeClass('favorite'); $('#bookmarkStar').removeClass('favorite');
$('.bkmrk a.bookmarksLink.selected').removeClass('selected'); $('.bkmrk a.bookmarksLink.selected').removeClass('selected');
for(var idFolders in list) {
for(var idBkmrk in list[idFolders]['bkmrk']) {
var portalGuid = list[idFolders]['bkmrk'][idBkmrk]['guid'];
if(guid == portalGuid) {
$('#bookmarkStar').addClass('favorite');
$('.bkmrk#'+idBkmrk+' a.bookmarksLink').addClass('selected');
}
}
}
}
window.plugin.bookmarks.switchStarPortal = function() {
var guid = window.selectedPortal;
if($('#bookmarkStar').hasClass('favorite')) { //If current portal is into bookmarks: select bookmark portal from portals list and select the star in sideabar
var list = plugin.bookmarks['bkmrk_portals']; for(var idFolders in list){
for(var idBkmrk in list[idFolders]['bkmrk']){
var portalGuid = list[idFolders]['bkmrk'][idBkmrk]['guid'];
if(guid == portalGuid){
$('#bookmarkStar').addClass('favorite');
$('.bkmrk#'+idBkmrk+' a.bookmarksLink').addClass('selected');
}
}
}
}
window.plugin.bookmarks.switchStarPortal = function(){
var guid = window.selectedPortal;
for(var idFolders in list) { //Remove portal from bookmarks
for(var idBkmrk in list[idFolders]['bkmrk']) { if($('#bookmarkStar').hasClass('favorite')){
var portalGuid = list[idFolders]['bkmrk'][idBkmrk]['guid']; var list = plugin.bookmarks['bkmrk_portals'];
if(guid == portalGuid) {
delete list[idFolders]['bkmrk'][idBkmrk];
$('.bkmrk#'+idBkmrk+'').remove();
}
}
}
}
else {
var linka = $('#portaldetails .linkdetails aside a:contains("Portal link")').attr('href');
var namePortal = $('#portaldetails h3').text();
var ID = window.plugin.bookmarks.generateID(); for(var idFolders in list){
for(var idBkmrk in list[idFolders]['bkmrk']){
var portalGuid = list[idFolders]['bkmrk'][idBkmrk]['guid'];
if(guid == portalGuid){
delete list[idFolders]['bkmrk'][idBkmrk];
$('.bkmrk#'+idBkmrk+'').remove();
}
}
}
}
//Add portal into bookmarks
else{
var linka = $('#portaldetails .linkdetails aside a:contains("Portal link")').attr('href');
var namePortal = $('#portaldetails h3').text();
var spac = linka.split('pll='); var ID = window.plugin.bookmarks.generateID();
var latlng = spac[1] ;
plugin.bookmarks['bkmrk_portals'][plugin.bookmarks.KEY_OTHER_BKMRK]['bkmrk'][ID] = {"guid":guid,"latlng":latlng,"label":namePortal};
$('#bkmrk_portals li.othersBookmarks ul').append('<li class="bkmrk" id="'+ID+'"><a class="bookmarksRemoveFrom" title="Remove from bookmarks">X</a><a class="bookmarksLink" onclick="window.zoomToAndShowPortal(\''+guid+'\', ['+latlng+']);return false;">'+namePortal+'</a></li>');
}
window.plugin.bookmarks.storeBookmarks('bkmrk_portals');
window.plugin.bookmarks.updateStarPortal();
}
window.plugin.bookmarks.addBookmarkMap = function(elem) {
var mapLink = $(elem).attr('href');
var pars = new RegExp('[\\?&amp;]ll=([^&amp;#]*)[&amp;]z=([^&amp;#]*)').exec(mapLink);
var res = pars[1].split(',');
res[2] = pars[2];
var latlng = res[0]+','+res[1];
var zoom = res[2];
var ID = window.plugin.bookmarks.generateID(); var spac = linka.split('pll=');
var latlng = spac[1] ;
plugin.bookmarks['bkmrk_portals'][plugin.bookmarks.KEY_OTHER_BKMRK]['bkmrk'][ID] = {"guid":guid,"latlng":latlng,"label":namePortal};
$('#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.updateStarPortal();
}
window.plugin.bookmarks.addBookmarkMap = function(elem){
var mapLink = $(elem).attr('href');
var pars = new RegExp('[\\?&amp;]ll=([^&amp;#]*)[&amp;]z=([^&amp;#]*)').exec(mapLink);
var res = pars[1].split(',');
res[2] = pars[2];
var latlng = res[0]+','+res[1];
var zoom = res[2];
var nameMap = $(elem).siblings('input').val(); var ID = window.plugin.bookmarks.generateID();
nameMap = nameMap.replace(/\//g, '&#47;').replace(/\\/g, '&#92;').replace(/"/g, '&#34;').replace(/"/g, '&#39;');
if(nameMap == '') { nameMap = ''; } var nameMap = $(elem).siblings('input').val();
$(elem).siblings('input').val(''); nameMap = nameMap.replace(/\//g, '&#47;').replace(/\\/g, '&#92;').replace(/"/g, '&#34;').replace(/"/g, '&#39;');
plugin.bookmarks['bkmrk_maps'][plugin.bookmarks.KEY_OTHER_BKMRK]['bkmrk'][ID] = {"label":nameMap,"latlng":latlng,"z":parseInt(zoom)}; if(nameMap == ''){ nameMap = ''; }
plugin.bookmarks.storeBookmarks('bkmrk_maps'); $(elem).siblings('input').val('');
if(nameMap=='') { nameMap = latlng+' ['+zoom+']'; } plugin.bookmarks['bkmrk_maps'][plugin.bookmarks.KEY_OTHER_BKMRK]['bkmrk'][ID] = {"label":nameMap,"latlng":latlng,"z":parseInt(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>'); plugin.bookmarks.storeBookmarks('bkmrk_maps');
}
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>');
}
/***************************************************************************************************************************************************************/ /***************************************************************************************************************************************************************/
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);
var ID = 'id'+ID.toString(); var ID = 'id'+ID.toString();
return ID; return ID;
} }
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');
var newFlag; var newFlag;
var flag = plugin.bookmarks[typeList][ID]['state']; var flag = plugin.bookmarks[typeList][ID]['state'];
if(flag) { newFlag = 0; } if(flag){ newFlag = 0; }
else if(!flag) { newFlag = 1; } else if(!flag){ newFlag = 1; }
window.plugin.bookmarks[typeList][ID]['state'] = newFlag; window.plugin.bookmarks[typeList][ID]['state'] = newFlag;
window.plugin.bookmarks.storeBookmarks(typeList); window.plugin.bookmarks.storeBookmarks(typeList);
} }
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';
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":{}}; plugin.bookmarks[typeList][ID] = {"label":nameFolder,"state":0,"bkmrk":{}};
plugin.bookmarks.storeBookmarks(typeList); plugin.bookmarks.storeBookmarks(typeList);
$('#'+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" 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>');
} }
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');
var IDfold = $(elem).parent().parent().parent('li').attr('id'); var IDfold = $(elem).parent().parent().parent('li').attr('id');
delete window.plugin.bookmarks[typeList][IDfold]['bkmrk'][ID]; delete window.plugin.bookmarks[typeList][IDfold]['bkmrk'][ID];
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(); }
} }
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');
delete plugin.bookmarks[typeList][ID]; delete plugin.bookmarks[typeList][ID];
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(); }
} }
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 = {};
$('#'+typeList+' li.bookmarkFolder').each(function() { $('#'+typeList+' li.bookmarkFolder').each(function(){
var idFold = $(this).attr('id'); var idFold = $(this).attr('id');
newArr[idFold] = window.plugin.bookmarks[typeList][idFold]; newArr[idFold] = window.plugin.bookmarks[typeList][idFold];
}); });
window.plugin.bookmarks[typeList] = newArr; window.plugin.bookmarks[typeList] = newArr;
window.plugin.bookmarks.storeBookmarks(typeList); window.plugin.bookmarks.storeBookmarks(typeList);
} }
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];
var newArr = {}; var newArr = {};
$('#'+typeList+' li.bookmarkFolder').each(function() { $('#'+typeList+' li.bookmarkFolder').each(function(){
var idFold = $(this).attr('id'); var idFold = $(this).attr('id');
newArr[idFold] = window.plugin.bookmarks[typeList][idFold]; newArr[idFold] = window.plugin.bookmarks[typeList][idFold];
newArr[idFold].bkmrk = {}; newArr[idFold].bkmrk = {};
}); });
$('#'+typeList+' li.bkmrk').each(function() { $('#'+typeList+' li.bkmrk').each(function(){
window.plugin.bookmarks.loadBookmarks(typeList); window.plugin.bookmarks.loadBookmarks(typeList);
var idFold = $(this).parent().parent('li').attr('id'); var idFold = $(this).parent().parent('li').attr('id');
var id = $(this).attr('id'); var id = $(this).attr('id');
var list = window.plugin.bookmarks[typeList]; var list = window.plugin.bookmarks[typeList];
for(var idFoldersOrigin in list) { for(var idFoldersOrigin in list){
for(var idBkmrk in list[idFoldersOrigin]['bkmrk']) { for(var idBkmrk in list[idFoldersOrigin]['bkmrk']){
if(idBkmrk == id) { if(idBkmrk == id){
newArr[idFold].bkmrk[id] = window.plugin.bookmarks[typeList][idFoldersOrigin].bkmrk[id]; newArr[idFold].bkmrk[id] = window.plugin.bookmarks[typeList][idFoldersOrigin].bkmrk[id];
} }
} }
} }
}); });
window.plugin.bookmarks[typeList] = newArr; window.plugin.bookmarks[typeList] = newArr;
window.plugin.bookmarks.storeBookmarks(typeList); window.plugin.bookmarks.storeBookmarks(typeList);
} }
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;
} }
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];
} }
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 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 = '';
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){ folderLabel = ''; active= ' othersBookmarks active' }
element += '<li class="bookmarkFolder'+active+'" id="'+idFolders+'">'+folderLabel+'<ul>'; element += '<li class="bookmarkFolder'+active+'" id="'+idFolders+'">'+folderLabel+'<ul>';
var fold = folders['bkmrk']; var fold = folders['bkmrk'];
for(var idBkmrk in fold) { for(var idBkmrk in fold){
var btn_link; var btn_link;
var btn_remove = '<a class="bookmarksRemoveFrom" title="Remove from bookmarks">X</a>'; var btn_remove = '<a class="bookmarksRemoveFrom" title="Remove from bookmarks">X</a>';
var bkmrk = fold[idBkmrk]; var bkmrk = fold[idBkmrk];
var label = bkmrk['label']; var label = bkmrk['label'];
var latlng = bkmrk['latlng']; var latlng = bkmrk['latlng'];
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>';
} }
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>'; element += '<li class="bkmrk" id="'+idBkmrk+'">'+btn_remove+btn_link+'</li>';
} }
element += '</li></ul>'; element += '</li></ul>';
} }
$('#'+typeList+' ul').html(element); $('#'+typeList+' ul').html(element);
} }
/***************************************************************************************************************************************************************/ /***************************************************************************************************************************************************************/
window.plugin.bookmarks.setupJS = function() { window.plugin.bookmarks.setupJS = function(){$(document).ready(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 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; });
$('#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'); }
//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');});
//ACTIVE VERTICAL SCROLL-BAR ON THE LONG LISTS
$('.bookmarkList > ul').enscroll({ showOnHover: true, verticalTrackClass: 'trackScroll', verticalHandleClass: 'handleScroll', minScrollbarLength:28 });
//ENABLED THE SORTABLE PROPERTY OF THE FOLDERS AND BOOKMARKS
$(".bookmarkList > ul").sortable({items:"li.bookmarkFolder:not(.othersBookmarks)",handle:".bookmarksAnchor",placeholder:"sortable-placeholder",forcePlaceholderSize:true,
update:function(event, ui) {
var typeList = $('#'+ui.item.context.id).parent().parent('.bookmarkList').attr('id');
window.plugin.bookmarks.sortBookmarksFolder(typeList);
}
});
$(".bookmarkList ul li ul").sortable({items:"li.bkmrk",connectWith:".bookmarkList ul ul",handle:".bookmarksLink",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);
}
});
//REMOVE FOLDER
$('.bookmarkList').on('click', '.folderLabel .bookmarksRemoveFrom', function(e) {
window.plugin.bookmarks.deletFolder(this);
$(this).parent().parent('li').remove();
e.preventDefault();
});
//REMOVE BOOKMARK
$('.bookmarkList').on('click', '.bkmrk .bookmarksRemoveFrom', function(e) {
window.plugin.bookmarks.deletBookmark(this);
$(this).parent('li').remove();
e.preventDefault();
});
//OPEN/CLOSE FOLDER
$('#bookmarksBox').on('click', '.bookmarksAnchor', function(e) {
window.plugin.bookmarks.openFolder(this);
$(this).parent().parent('li').toggleClass('active');
e.preventDefault();
});
//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,
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() { //SWICTH VISIBILITY PROPERTY OF THE BOX
$("<style>").prop("type", "text/css") $('#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; });
.html("@@INCLUDESTRING:plugins/bookmarks-by-zaso.css@@").appendTo("head"); $('#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'); }
window.plugin.bookmarks.setupContent = function() { //SWITCH LIST (MAPS/PORTALS)
plugin.bookmarks.contentStarHTML = '<a id="bookmarkStar" onclick="window.plugin.bookmarks.switchStarPortal();return false;" title="Save this portal in your bookmarks"><span></span></a>'; $('#bookmarksBox h5').click(function(){$('h5').removeClass('current');$(this).addClass('current');var sectList = '#'+$(this).attr('class').replace(' current', '');$('#bookmarksBox .bookmarkList').removeClass('current');$(sectList).addClass('current');});
plugin.bookmarks.disabledMessage = '<div class="notStorageSupport" title="Your browser do not support localStorage">Plugin Bookmarks disabled</div>';
plugin.bookmarks.bkmrkBox = '<div id="bookmarksBox">' //ACTIVE VERTICAL SCROLL-BAR ON THE LONG LISTS
+'<div id="topBar"><a id="bookmarksMin" class="btn" title="Minimize">-</a><div class="handle">...</div></div>' $('.bookmarkList > ul').enscroll({ showOnHover: true, verticalTrackClass: 'trackScroll', verticalHandleClass: 'handleScroll', minScrollbarLength:28 });
+'<div id="bookmarksTypeBar"><h5 class="bkmrk_maps current">Maps</h5><h5 class="bkmrk_portals">Portals</h5></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>' //ENABLED THE SORTABLE PROPERTY OF THE FOLDERS AND BOOKMARKS
+'<div id="bkmrk_portals" class="bookmarkList"><div class="addForm"><input placeholder="Insert label"><a class="newFolder">+ Folder</a></div><ul></ul></div>' $(".bookmarkList > ul").sortable({items:"li.bookmarkFolder:not(.othersBookmarks)",handle:".bookmarksAnchor",distance:5,placeholder:"sortable-placeholder",forcePlaceholderSize:true,
+'</div>'; update:function(event, ui){
plugin.bookmarks.bkmrkRibbon = '<a id="bookmarksShow"></a>'; var typeList = $('#'+ui.item.context.id).parent().parent('.bookmarkList').attr('id');
} 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,
update:function(event, ui){
var typeList = $('#'+ui.item.context.id).parent().parent().parent().parent('.bookmarkList').attr('id');
window.plugin.bookmarks.sortBookmarks(typeList);
}
});
//REMOVE FOLDER
$('.bookmarkList').on('click', '.folderLabel .bookmarksRemoveFrom', function(e){
window.plugin.bookmarks.deletFolder(this);
$(this).parent().parent('li').remove();
e.preventDefault();
});
//REMOVE BOOKMARK
$('.bookmarkList').on('click', '.bkmrk .bookmarksRemoveFrom', function(e){
window.plugin.bookmarks.deletBookmark(this);
$(this).parent('li').remove();
e.preventDefault();
});
//OPEN/CLOSE FOLDER
$('#bookmarksBox').on('click', '.bookmarksAnchor', function(e){
window.plugin.bookmarks.openFolder(this);
$(this).parent().parent('li').toggleClass('active');
e.preventDefault();
});
//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');
}
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.disabledMessage = '<div class="notStorageSupport" title="Your browser do not support localStorage">Plugin Bookmarks disabled</div>';
plugin.bookmarks.bkmrkRibbon = '<a id="bookmarksShow"></a>';
plugin.bookmarks.bkmrkBox = '<div id="bookmarksBox">'
+'<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="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>';
}
/***************************************************************************************************************************************************************/ /***************************************************************************************************************************************************************/
var setup = function() { var setup = function(){
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']] = 0;}
if($.inArray('pluginBookmarksUpdate', window.VALID_HOOKS) < 0) { window.VALID_HOOKS.push('pluginBookmarksUpdate'); } if($.inArray('pluginBookmarksUpdate', window.VALID_HOOKS) < 0){ window.VALID_HOOKS.push('pluginBookmarksUpdate'); }
window.plugin.bookmarks.setupCSS(); window.plugin.bookmarks.setupCSS();
window.plugin.bookmarks.setupJS(); window.plugin.bookmarks.setupJS();
window.plugin.bookmarks.setupContent(); 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); window.addHook('portalDetailsUpdated', window.plugin.bookmarks.addStarToSidebar);
//Add to DOM the element of the plugin and load data from localStorage //Add to DOM the element of the plugin and load data from localStorage
$('body').append(plugin.bookmarks.bkmrkRibbon); $('body').append(plugin.bookmarks.bkmrkRibbon);
$('body').append(plugin.bookmarks.bkmrkBox); $('body').append(plugin.bookmarks.bkmrkBox);
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 //Load the js page for the scrollbar
var script2 = document.createElement('script'); var script2 = document.createElement('script');
script2.type = 'text/javascript'; script2.type = 'text/javascript';
script2.src = 'http://enscrollplugin.com/releases/enscroll-0.4.0.min.js'; script2.src = 'http://enscrollplugin.com/releases/enscroll-0.4.0.min.js';
script2.appendChild(document.createTextNode('('+ wrapper +')();')); script2.appendChild(document.createTextNode('('+ wrapper +')();'));
(document.body || document.head || document.documentElement).appendChild(script2); (document.body || document.head || document.documentElement).appendChild(script2);
} }
// PLUGIN END //////////////////////////////////////////////////////////
// PLUGIN END ////////////////////////////////////////////////////////// if(window.iitcLoaded && typeof setup === 'function'){ setup(); }
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);