aboutsummaryrefslogtreecommitdiffhomepage
path: root/themes/default
diff options
context:
space:
mode:
authorNicolas LÅ“uillet <nicolas@loeuillet.org>2014-03-27 19:44:28 +0100
committerNicolas LÅ“uillet <nicolas@loeuillet.org>2014-03-27 19:44:28 +0100
commit04fbe8f5efdf7fda0505c5aab9353d2cc61507ed (patch)
tree691934473700749cd12dfd07771dd90c3c58622e /themes/default
parent9591ee2603dd107cd49b61957d0f71a652b7bea3 (diff)
parente68348f6271fab591960902feebe167d01e15468 (diff)
downloadwallabag-04fbe8f5efdf7fda0505c5aab9353d2cc61507ed.tar.gz
wallabag-04fbe8f5efdf7fda0505c5aab9353d2cc61507ed.tar.zst
wallabag-04fbe8f5efdf7fda0505c5aab9353d2cc61507ed.zip
Merge pull request #586 from mariroz/wb-link-in-wb
wallabag a link in wallabag now in default theme, issue #505
Diffstat (limited to 'themes/default')
-rw-r--r--themes/default/_head.twig3
-rw-r--r--themes/default/_menu.twig6
-rwxr-xr-xthemes/default/_pocheit-form.twig26
-rwxr-xr-xthemes/default/css/style.css47
-rwxr-xr-xthemes/default/js/saveLink.js101
-rw-r--r--themes/default/view.twig2
6 files changed, 161 insertions, 24 deletions
diff --git a/themes/default/_head.twig b/themes/default/_head.twig
index f310e420..96a6ab33 100644
--- a/themes/default/_head.twig
+++ b/themes/default/_head.twig
@@ -9,4 +9,5 @@
9 <link rel="stylesheet" href="{{ poche_url }}/themes/default/css/print.css" media="print"> 9 <link rel="stylesheet" href="{{ poche_url }}/themes/default/css/print.css" media="print">
10 <script src="{{ poche_url }}/themes/default/js/jquery-2.0.3.min.js"></script> 10 <script src="{{ poche_url }}/themes/default/js/jquery-2.0.3.min.js"></script>
11 <script src="{{ poche_url }}/themes/default/js/autoClose.js"></script> 11 <script src="{{ poche_url }}/themes/default/js/autoClose.js"></script>
12 <script src="{{ poche_url }}/themes/default/js/closeMessage.js"></script> \ No newline at end of file 12 <script src="{{ poche_url }}/themes/default/js/closeMessage.js"></script>
13 <script src="{{ poche_url }}/themes/default/js/saveLink.js"></script>
diff --git a/themes/default/_menu.twig b/themes/default/_menu.twig
index 0e7dd0a7..0daa0b03 100644
--- a/themes/default/_menu.twig
+++ b/themes/default/_menu.twig
@@ -3,11 +3,11 @@
3 <li><a href="./?view=fav" {% if view == 'fav' %}class="current"{% endif %}>{% trans "favorites" %}</a></li> 3 <li><a href="./?view=fav" {% if view == 'fav' %}class="current"{% endif %}>{% trans "favorites" %}</a></li>
4 <li><a href="./?view=archive" {% if view == 'archive' %}class="current"{% endif %}>{% trans "archive" %}</a></li> 4 <li><a href="./?view=archive" {% if view == 'archive' %}class="current"{% endif %}>{% trans "archive" %}</a></li>
5 <li><a href="./?view=tags" {% if view == 'tags' %}class="current"{% endif %}>{% trans "tags" %}</a></li> 5 <li><a href="./?view=tags" {% if view == 'tags' %}class="current"{% endif %}>{% trans "tags" %}</a></li>
6 <li><a href="javascript: void(null);" id="pocheit">{% trans "save a link" %}</a><span id="pocheit-arrow"></span></li> 6 <li><a href="javascript: void(null);" id="bagit">{% trans "save a link" %}</a><span id="bagit-arrow"></span></li>
7 <li><a href="javascript: void(null);" id="search">{% trans "search" %}</a><span id="search-arrow"></span></li> 7 <li><a href="javascript: void(null);" id="search">{% trans "search" %}</a><span id="search-arrow"></span></li>
8 <li><a href="./?view=config" {% if view == 'config' %}class="current"{% endif %}>{% trans "config" %}</a></li> 8 <li><a href="./?view=config" {% if view == 'config' %}class="current"{% endif %}>{% trans "config" %}</a></li>
9 <li><a href="./?logout" title="{% trans "logout" %}">{% trans "logout" %}</a></li> 9 <li><a href="./?logout" title="{% trans "logout" %}">{% trans "logout" %}</a></li>
10 </ul> 10 </ul>
11 {% include '_pocheit-form.twig' %} 11 {% include '_pocheit-form.twig' %}
12 {% include '_search-form.twig' %} 12 {% include '_search-form.twig' %}
13 13
diff --git a/themes/default/_pocheit-form.twig b/themes/default/_pocheit-form.twig
index 13096159..8c982db0 100755
--- a/themes/default/_pocheit-form.twig
+++ b/themes/default/_pocheit-form.twig
@@ -1,22 +1,8 @@
1<div id="pocheit-form" class="messages info"> 1<div id="bagit-form" class="messages info">
2 <center> 2 <a href="javascript: void(null);" id="bagit-form-close">&nbsp;</a>
3 <form method="get" action="index.php"> 3 <form method="get" action="index.php" id="bagit-form-form">
4 <input required placeholder="example.com/article" class="addurl" id="plainurl" name="plainurl" type="url" /> 4 <input required placeholder="example.com/article" class="addurl" id="plainurl" name="plainurl" type="url" />
5 <input type="submit" value="{% trans "save link!" %}" /> 5 <input type="submit" value="{% trans "save link!" %}" />
6 <div id="add-link-result"></div>
6 </form> 7 </form>
7 </center>
8</div> 8</div>
9<script type="text/javascript">
10 $(document).ready(function() {
11
12 $("#pocheit-form").hide();
13
14 $("#pocheit").click(function(){
15 $("#pocheit-form").toggle();
16 $("#pocheit").toggleClass("current");
17 $("#pocheit-arrow").toggleClass("arrow-down");
18 });
19
20
21 });
22</script>
diff --git a/themes/default/css/style.css b/themes/default/css/style.css
index b3d300ed..e536ac6b 100755
--- a/themes/default/css/style.css
+++ b/themes/default/css/style.css
@@ -355,3 +355,50 @@ a.reading-time span {
355 vertical-align: top; 355 vertical-align: top;
356} 356}
357 357
358
359/* ==========================================================================
360 "save a link" popup div related styles
361 ========================================================================== */
362
363#bagit-form {
364 display: none;
365 padding-left: 30px;
366 width: 450px;
367
368}
369
370a#bagit-form-close {
371 color: #FFF;
372 display: inline-block;
373 float: right;
374 background: url("../img/messages/close.png") no-repeat scroll 0 0 rgba(0, 0, 0, 0);
375 height: 16px;
376 margin: -14px -8px 0 0;
377 width: 16px;
378 text-decoration: none;
379}
380
381
382.add-to-wallabag-link-after {
383 background-color: #000;
384 color: #fff;
385 padding: 0 4px 1px 3px;
386 font-weight: bold;
387 font-size: 0.7em;
388 border-radius: 4px;
389}
390.add-to-wallabag-link-after:hover, .add-to-wallabag-link-after:active {
391 color: #fff;
392}
393.add-to-wallabag-link-after:visited {
394 color: #999;
395}
396
397#add-link-result {
398 display: inline;
399 padding-left: 10px;
400}
401
402.opacity03 {
403 /*opacity: 0.3;*/
404}
diff --git a/themes/default/js/saveLink.js b/themes/default/js/saveLink.js
new file mode 100755
index 00000000..ccc00d1e
--- /dev/null
+++ b/themes/default/js/saveLink.js
@@ -0,0 +1,101 @@
1$.fn.ready(function() {
2
3 var $bagit = $('#bagit'),
4 $bagitForm = $('#bagit-form'),
5 $bagitFormForm = $('#bagit-form-form');
6
7 /* ==========================================================================
8 bag it link and close button
9 ========================================================================== */
10
11 function toggleSaveLinkForm(url, event) {
12 $("#add-link-result").empty();
13
14 $bagit.toggleClass("active-current");
15
16 //only if bagiti link is not presented on page
17 if ( $bagit.length === 0 ) {
18 if ( event !== 'undefined' && event ) {
19 $bagitForm.css( {position:"absolute", top:event.pageY, left:event.pageX-200});
20 }
21 else {
22 $bagitForm.css( {position:"relative", top:"auto", left:"auto"});
23 }
24 }
25
26 $bagitForm.toggle();
27 $('#content').toggleClass("opacity03");
28 if (url !== 'undefined' && url) {
29 $('#plainurl').val(url);
30 }
31 $('#plainurl').focus();
32 }
33
34
35 $bagit.click(function(){
36 $bagit.toggleClass("current");
37 $("#bagit-arrow").toggleClass("arrow-down");
38 toggleSaveLinkForm();
39 });
40
41 $("#bagit-form-close").click(function(){
42 $bagit.removeClass("current");
43 $("#bagit-arrow").removeClass("arrow-down");
44 toggleSaveLinkForm();
45 });
46
47
48 //send "bag it link" form request via ajax
49 $bagitFormForm.submit( function(event) {
50 $("body").css("cursor", "wait");
51 $("#add-link-result").empty();
52
53 $.ajax({
54 type: $bagitFormForm.attr('method'),
55 url: $bagitFormForm.attr('action'),
56 data: $bagitFormForm.serialize(),
57 success: function(data) {
58 $('#add-link-result').html("Done!");
59 $('#plainurl').val('');
60 $('#plainurl').blur('');
61 $("body").css("cursor", "auto");
62 //setTimeout( function() { toggleSaveLinkForm(); }, 1000); //close form after 1000 delay
63 },
64 error: function(data) {
65 $('#add-link-result').html("Failed!");
66 $("body").css("cursor", "auto");
67 }
68 });
69
70 event.preventDefault();
71 });
72
73 /* ==========================================================================
74 Keyboard gestion
75 ========================================================================== */
76
77 $(window).keydown(function(e){
78 if ( ( e.target.tagName.toLowerCase() !== 'input' && e.keyCode == 83 ) || e.keyCode == 27 ) {
79 $bagit.removeClass("current");
80 $("#bagit-arrow").removeClass("arrow-down");
81 toggleSaveLinkForm();
82 return false;
83 }
84 });
85
86 /* ==========================================================================
87 Process all links inside an article
88 ========================================================================== */
89
90 $("article a[href^='http']").after(function() {
91 return " <a href=\"" + $(this).attr('href') + "\" class=\"add-to-wallabag-link-after\" alt=\"add to wallabag\" title=\"add to wallabag\">w</a> ";
92 });
93
94 $(".add-to-wallabag-link-after").click(function(event){
95 toggleSaveLinkForm($(this).attr('href'), event);
96 event.preventDefault();
97 });
98
99});
100
101
diff --git a/themes/default/view.twig b/themes/default/view.twig
index 916abe0d..2be0c33c 100644
--- a/themes/default/view.twig
+++ b/themes/default/view.twig
@@ -1,6 +1,7 @@
1{% extends "layout.twig" %} 1{% extends "layout.twig" %}
2{% block title %}{{ entry.title|raw }} ({{ entry.url | e | getDomain }}){% endblock %} 2{% block title %}{{ entry.title|raw }} ({{ entry.url | e | getDomain }}){% endblock %}
3{% block content %} 3{% block content %}
4 {% include '_pocheit-form.twig' %}
4 <div id="article_toolbar"> 5 <div id="article_toolbar">
5 <ul> 6 <ul>
6 <li><a href="./" title="{% trans "Return home" %}" class="tool back"><span>{% trans "Return home" %}</span></a></li> 7 <li><a href="./" title="{% trans "Return home" %}" class="tool back"><span>{% trans "Return home" %}</span></a></li>
@@ -55,3 +56,4 @@
55 }); 56 });
56 </script> 57 </script>
57{% endblock %} 58{% endblock %}
59