Skip to content

Commit 50b4345

Browse files
committed
Embed bookmarks in main page done!
1 parent 7842fa1 commit 50b4345

File tree

6 files changed

+63
-97
lines changed

6 files changed

+63
-97
lines changed

content/bookmarks.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,18 +9,18 @@
99
<link rel="shortcut icon" href="images/favicon.ico" />
1010
</head>
1111
<body>
12-
<section id="mb-labels" class="container-fluid" style="margin-top: 5px;">
12+
<section id="bm-labels" class="container-fluid" style="margin-top: 5px;">
1313
<h3><i class="fa fa-tags"></i> Labels <span class="edit" data-state="normal">edit</span></h3>
1414
<div class="labels-panel"></div>
1515
</section>
16-
<section id="mb-requests" class="container-fluid">
16+
<section id="bm-requests" class="container-fluid">
1717
<h3><i class="fa fa-bookmark"></i> Bookmarks <span class="badge requestNum">123</span></h3>
1818
<ul class="bookmark-requests">
1919
</ul>
2020
<div class="loading hide"><img src="chrome://restclient/content/images/ajax-loader.gif" /> </div>
2121
</section>
2222

23-
<section id="mb-footer" class="container-fluid">
23+
<section id="bm-footer" class="container-fluid">
2424
<h4 class="backtotop"><a href="#"> ↑ Back to top</a></h4>
2525
<p></p>
2626
</section>

content/css/restclient.bookmark.css

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,82 +1,82 @@
1-
#mb-labels .label {
1+
#bm-labels .label {
22
font-size: 14px;
33
cursor: pointer;
44
}
5-
#mb-labels span.edit {
5+
#bm-labels span.edit {
66
font-size: 14px;
77
color: #999;
88
cursor: pointer;
99
}
1010
.hide {
1111
display: none;
1212
}
13-
#mb-labels .label-div{
13+
#bm-labels .label-div{
1414
display: inline-block;
1515
margin-right: 5px;
1616
margin-bottom: 10px;
1717
}
18-
#mb-labels .label-div .remove {
18+
#bm-labels .label-div .remove {
1919
margin-left: 5px;
2020
margin-right: 3px;
2121
cursor: pointer;
2222
}
23-
#mb-requests {
23+
#bm-requests {
2424
font-size: 14px;
2525
line-height: 12px;
2626
}
27-
#mb-requests .requestNum {
27+
#bm-requests .requestNum {
2828
vertical-align: top;
2929
font-size: 12px;
3030
margin-left: -5px;
3131
}
32-
#mb-requests ul{
32+
#bm-requests ul{
3333
margin-left: 0px;
3434
}
35-
#mb-requests ul li
35+
#bm-requests ul li
3636
{
3737
list-style-type: none;
3838
margin-bottom: 15px;
3939
padding: 10px 19px;
4040
}
41-
#mb-requests .loading {
41+
#bm-requests .loading {
4242
width: 100%;
4343
text-align: center;
4444
margin-bottom: 20px;
4545
}
46-
#mb-requests .bookmark-button {
46+
#bm-requests .bookmark-button {
4747
float: right;
4848
}
49-
#mb-requests div.bookmark-title {
49+
#bm-requests div.bookmark-title {
5050
font-size: 16px;
5151
}
52-
#mb-requests div.bookmark-details {
52+
#bm-requests div.bookmark-details {
5353
margin: 5px 0;
5454
}
55-
#mb-requests div.curl {
55+
#bm-requests div.curl {
5656
margin-left: 30px;
5757
}
58-
#mb-requests span.bookmark-label {
58+
#bm-requests span.bookmark-label {
5959
text-align: left;
6060
font-weight:bold;
6161
}
62-
#mb-requests .lastAccess {
62+
#bm-requests .lastAccess {
6363
font-size: 11px;
6464
color: #666;
6565
}
66-
#mb-requests .bookmark-details .label {
66+
#bm-requests .bookmark-details .label {
6767
padding: 0px 8px;
6868
line-height: 20px;
6969
font-size: 12px;
7070
background-color: #ddd;
7171
color: #333;
7272
text-shadow: 0px -1px 0px rgba(1, 1, 1, 0.05);
7373
}
74-
#mb-requests .labels {
74+
#bm-requests .labels {
7575
margin-top: 12px !important
7676
}
7777

7878

79-
#mb-footer .backtotop {
79+
#bm-footer .backtotop {
8080
width: 100%;
8181
text-align: right;
8282
}

content/css/restclient.css

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -363,7 +363,7 @@ issue: https://github.com/twitter/bootstrap/issues/6344
363363
}
364364
#bookmark-sidebar {
365365
background-color:rgba(0, 0, 0, 0.2);
366-
z-index:10160;
366+
z-index:1038;
367367
position: fixed;
368368
top: 0;
369369
right: 0;
@@ -380,7 +380,7 @@ issue: https://github.com/twitter/bootstrap/issues/6344
380380
width: 674px;
381381
background: #fff;
382382
height: 100%;
383-
z-index: 1999;
383+
z-index: 1039;
384384
-webkit-box-shadow: 0px 0 20px 0 rgba(0, 0, 0, 0.1);
385385
box-shadow: 0px 0 20px 0 rgba(0, 0, 0, 0.1);
386386
overflow: scroll;

content/js/restclient.bookmark.js

Lines changed: 16 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -33,66 +33,13 @@ restclient.bookmark = {
3333
cachedRequests: new Array(),
3434
callback: null,
3535
init: function(){
36-
/*var retVals = (window.hasOwnProperty('arguments') && window.arguments.length > 0) ? window.arguments[0] : {};
37-
var theme = (typeof retVals.theme !== 'undefined') ? retVals.theme : 'simplex';
38-
39-
restclient.bookmark.callback = (window.hasOwnProperty('arguments') && typeof window.arguments[1] === 'function') ? window.arguments[1] : false;
40-
restclient.bookmark.initSkin(theme);*/
41-
42-
restclient.init();
43-
restclient.sqlite.open();
44-
4536
restclient.bookmark.initLabels();
46-
restclient.bookmark.initModals();
4737
restclient.bookmark.updateRequests(0);
48-
restclient.bookmark.initEvents();
49-
},
50-
unload: function(){},
51-
initSkin: function(theme) {
52-
$("link").remove();
53-
$("<link/>", {
54-
rel: "stylesheet",
55-
type: "text/css",
56-
href: "css/themes/" + theme + "/bootstrap.css"
57-
}).appendTo("head");
58-
$("<link/>", {
59-
rel: "stylesheet",
60-
type: "text/css",
61-
href: "css/themes/" + theme + "/bootstrap-responsive.css"
62-
}).appendTo("head");
63-
$("<link/>", {
64-
rel: "stylesheet",
65-
type: "text/css",
66-
href: "css/font-awesome.css"
67-
}).appendTo("head");
68-
$("<link/>", {
69-
rel: "stylesheet",
70-
type: "text/css",
71-
href: "css/restclient.bookmark.css"
72-
}).appendTo("head");
73-
$("<link/>", {
74-
rel: "stylesheet",
75-
type: "text/css",
76-
href: "css/animate.css"
77-
}).appendTo("head");
78-
},
79-
initModals: function(){
80-
$('#modal-label-remove').on('show', function () {
81-
var label = $('#modal-label-remove').data('label');
82-
$('#modal-label-remove .label').text(label);
83-
});
84-
85-
$('.modal .btnClose').live('click', function () {
86-
$(this).parents('.modal').modal('hide');
87-
return false;
88-
});
8938
},
90-
initEvents: function(){
91-
$('a.favorite').live('click', restclient.bookmark.toggleFavorite);
92-
$('#mb-labels span.edit').on('click', restclient.bookmark.clickLabelEdit);
93-
$('.removeBookmark').live('click', restclient.bookmark.clickRemoveBookmark);
94-
$('.requestName').live('click', restclient.bookmark.applyRequest);
95-
$( window ).bind('scroll', restclient.bookmark.scrollWindow);
39+
unload: function(){
40+
$('#bookmark-sidebar').hide();
41+
$('#bookmark-sidebar #bm-labels .edit').text('edit').attr('data-state', 'normal');
42+
$('#bookmark-sidebar .labels-panel').empty();
9643
},
9744
initLabels: function(){
9845
var labels = restclient.sqlite.getLabels();
@@ -116,11 +63,12 @@ restclient.bookmark = {
11663
if( restclient.bookmark.scrollProcessing )
11764
return false;
11865
restclient.bookmark.scrollProcessing = true;
119-
if ($(window).scrollTop() >= $(document).height() - $(window).height() - 700){
120-
console.log('scrolling');
121-
var num = $('#requests li[data-uuid]').length;
122-
console.log(num);
123-
var requestNum = parseInt($('.requestNum').text());
66+
//console.log($('#bm-sidebar-inner').scrollTop());
67+
//console.log($('#bm-requests').height() + $('#bm-labels').height() + $('#bm-footer').height() - $('#bm-sidebar-inner').height() - 400);
68+
if ($('#bm-sidebar-inner').scrollTop() >= $('#bm-requests').height() + $('#bm-labels').height() + $('#bm-footer').height() - $('#bm-sidebar-inner').height() - 400){
69+
var num = $('#bm-requests li[data-uuid]').length;
70+
//console.log(num);
71+
var requestNum = parseInt($('#bm-requests .requestNum').text());
12472
if(num < requestNum)
12573
{
12674
$('.loading').show();
@@ -130,6 +78,10 @@ restclient.bookmark = {
13078
}
13179
restclient.bookmark.scrollProcessing = false;
13280
},
81+
scrollToTop: function(){
82+
$('#bm-sidebar-inner').scrollTop(0);
83+
return false;
84+
},
13385
clickLabel: function(){
13486
$(this).toggleClass('label-important');
13587
var spans = $('.labels-panel .label-important');
@@ -146,12 +98,12 @@ restclient.bookmark = {
14698
if($(this).attr('data-state') === 'normal')
14799
{
148100
$(this).text('cancel').attr('data-state', 'edit');
149-
$('#mb-labels .remove').show();
101+
$('#bm-labels .remove').show();
150102
}
151103
else
152104
{
153105
$(this).text('edit').attr('data-state', 'normal');
154-
$('#mb-labels .remove').hide();
106+
$('#bm-labels .remove').hide();
155107
}
156108
return false;
157109
},

content/js/restclient.main.js

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -53,16 +53,12 @@ restclient.main = {
5353
restclient.init();
5454
restclient.sqlite.open();
5555

56+
this.initEvents();
5657
this.initSkin();
5758

5859
restclient.main.navTop = $('.subnav').length && $('.subnav').offset().top - $('.navbar').first().height();
5960
$(window).on('scroll', restclient.main.processScroll).scroll();
6061

61-
$('.modal .btnClose').live('click', function () {
62-
$(this).parents('.modal').modal('hide');
63-
return false;
64-
});
65-
6662
this.initHotKeys();
6763
this.initModal();
6864
this.initOAuthWindow();
@@ -132,6 +128,15 @@ restclient.main = {
132128
window.onhashchange = restclient.main.hashChange;
133129
restclient.main.hashChange();
134130
},
131+
initEvents: function(){
132+
$('#bm-sidebar-inner a.favorite').live('click', restclient.bookmark.toggleFavorite);
133+
$('#bm-labels span.edit').on('click', restclient.bookmark.clickLabelEdit);
134+
$('#bm-sidebar-inner.removeBookmark').live('click', restclient.bookmark.clickRemoveBookmark);
135+
$('#bm-sidebar-inner.requestName').live('click', restclient.bookmark.applyRequest);
136+
$('#bm-sidebar-inner .close').on('click', restclient.bookmark.unload);
137+
$('#bm-sidebar-inner').bind('scroll', restclient.bookmark.scrollWindow);
138+
$('#bm-sidebar-inner .bm-top').bind('click', restclient.bookmark.scrollToTop);
139+
},
135140
unload: function() {
136141
restclient.sqlite.close();
137142
},
@@ -635,6 +640,15 @@ restclient.main = {
635640
else
636641
autoRefresh.removeClass('active');
637642
});
643+
$('#modal-label-remove').on('show', function () {
644+
var label = $('#modal-label-remove').data('label');
645+
$('#modal-label-remove .label').text(label);
646+
});
647+
648+
$('.modal .btnClose').live('click', function () {
649+
$(this).parents('.modal').modal('hide');
650+
return false;
651+
});
638652
},
639653
showModal: function (modalId) {
640654
$('#' + modalId).modal('show').on('shown', function () {

content/restclient.html

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -644,19 +644,19 @@ <h3>Processing</h3>
644644

645645
<div id="bookmark-sidebar" class="hide">
646646
<div id="bm-sidebar-inner">
647-
<section id="mb-labels" class="container-fluid" style="margin-top: 5px;">
648-
<h3><i class="fa fa-tags"></i> Labels <span class="edit" data-state="normal">edit</span></h3>
647+
<section id="bm-labels" class="container-fluid" style="margin-top: 5px;">
648+
<h3><i class="fa fa-tags"></i> Labels <span class="edit" data-state="normal">edit</span><button class="close pull-right">&times;</button></h3>
649649
<div class="labels-panel"></div>
650650
</section>
651-
<section id="mb-requests" class="container-fluid">
651+
<section id="bm-requests" class="container-fluid">
652652
<h3><i class="fa fa-bookmark"></i> Bookmarks <span class="badge requestNum">123</span></h3>
653653
<ul class="bookmark-requests">
654654
</ul>
655655
<div class="loading hide"><img src="chrome://restclient/content/images/ajax-loader.gif" /> </div>
656656
</section>
657657

658-
<section id="mb-footer" class="container-fluid">
659-
<h4 class="backtotop"><a href="#"> ↑ Back to top</a></h4>
658+
<section id="bm-footer" class="container-fluid">
659+
<h4 class="backtotop"><a href="#" class="bm-top"> ↑ Back to top</a></h4>
660660
<p></p>
661661
</section>
662662
</div>

0 commit comments

Comments
 (0)