mirror of
https://github.com/wallabag/wallabag.git
synced 2025-09-15 18:57:05 +00:00
_global-izing some more js & css
This commit is contained in:
parent
db3bffa284
commit
eb365a01fb
16 changed files with 14 additions and 14 deletions
6
themes/_global/js/autoClose.js
Normal file
6
themes/_global/js/autoClose.js
Normal file
|
@ -0,0 +1,6 @@
|
|||
$(document).ready(function() {
|
||||
current_url = window.location.href
|
||||
if (current_url.match("&closewin=true")) {
|
||||
window.close();
|
||||
}
|
||||
});
|
47
themes/_global/js/autoCompleteTags.js
Executable file
47
themes/_global/js/autoCompleteTags.js
Executable file
|
@ -0,0 +1,47 @@
|
|||
jQuery(function($) {
|
||||
|
||||
function split( val ) {
|
||||
return val.split( /,\s*/ );
|
||||
}
|
||||
function extractLast( term ) {
|
||||
return split( term ).pop();
|
||||
}
|
||||
|
||||
|
||||
$("#value").bind("keydown", function(event) {
|
||||
if (event.keyCode === $.ui.keyCode.TAB && $(this).data("ui-autocomplete").menu.active) {
|
||||
event.preventDefault();
|
||||
}
|
||||
}).autocomplete({
|
||||
source : function(request, response) {
|
||||
$.getJSON("./?view=tags", {
|
||||
term : extractLast(request.term),
|
||||
//id: $(':hidden#entry_id').val()
|
||||
}, response);
|
||||
},
|
||||
search : function() {
|
||||
// custom minLength
|
||||
var term = extractLast(this.value);
|
||||
if (term.length < 1) {
|
||||
return false;
|
||||
}
|
||||
},
|
||||
focus : function() {
|
||||
// prevent value inserted on focus
|
||||
return false;
|
||||
},
|
||||
select : function(event, ui) {
|
||||
var terms = split(this.value);
|
||||
// remove the current input
|
||||
terms.pop();
|
||||
// add the selected item
|
||||
terms.push(ui.item.value);
|
||||
// add placeholder to get the comma-and-space at the end
|
||||
terms.push("");
|
||||
this.value = terms.join(", ");
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
});
|
1
themes/_global/js/jquery-2.0.3.min.js
vendored
Normal file
1
themes/_global/js/jquery-2.0.3.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
2519
themes/_global/js/jquery-ui-1.10.4.custom.js
vendored
Normal file
2519
themes/_global/js/jquery-ui-1.10.4.custom.js
vendored
Normal file
File diff suppressed because it is too large
Load diff
6
themes/_global/js/jquery-ui-1.10.4.custom.min.js
vendored
Normal file
6
themes/_global/js/jquery-ui-1.10.4.custom.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
72
themes/_global/js/popupForm.js
Normal file
72
themes/_global/js/popupForm.js
Normal file
|
@ -0,0 +1,72 @@
|
|||
$(document).ready(function() {
|
||||
|
||||
$("#search-form").hide();
|
||||
$("#bagit-form").hide();
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// Toggle the "Search" popup in the sidebar
|
||||
//---------------------------------------------------------------------------
|
||||
function toggleSearch() {
|
||||
$("#search-form").toggle();
|
||||
$("#search").toggleClass("current");
|
||||
$("#search").toggleClass("active-current");
|
||||
$("#search-arrow").toggleClass("arrow-down");
|
||||
if ($("#search").hasClass("current")) {
|
||||
$("#content").addClass("opacity03");
|
||||
} else {
|
||||
$("#content").removeClass("opacity03");
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// Toggle the "Save a Link" popup in the sidebar
|
||||
//---------------------------------------------------------------------------
|
||||
function toggleBagit() {
|
||||
$("#bagit-form").toggle();
|
||||
$("#bagit").toggleClass("current");
|
||||
$("#bagit").toggleClass("active-current");
|
||||
$("#bagit-arrow").toggleClass("arrow-down");
|
||||
if ($("#bagit").hasClass("current")) {
|
||||
$("#content").addClass("opacity03");
|
||||
} else {
|
||||
$("#content").removeClass("opacity03");
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// Close all #links popups in the sidebar
|
||||
//---------------------------------------------------------------------------
|
||||
function closePopups() {
|
||||
$("#links .messages").hide();
|
||||
$("#links > li > a").removeClass("active-current");
|
||||
$("#links > li > a").removeClass("current");
|
||||
$("[id$=-arrow]").removeClass("arrow-down");
|
||||
$("#content").removeClass("opacity03");
|
||||
}
|
||||
|
||||
$("#search").click(function(){
|
||||
closePopups();
|
||||
toggleSearch();
|
||||
$("#searchfield").focus();
|
||||
});
|
||||
|
||||
$("#bagit").click(function(){
|
||||
closePopups();
|
||||
toggleBagit();
|
||||
$("#plainurl").focus();
|
||||
});
|
||||
|
||||
$("#search-form-close").click(function(){
|
||||
toggleSearch();
|
||||
});
|
||||
|
||||
$("#bagit-form-close").click(function(){
|
||||
toggleBagit();
|
||||
});
|
||||
|
||||
// $("#").click(function(){
|
||||
// toggleSearch();
|
||||
// });
|
||||
|
||||
|
||||
});
|
25
themes/_global/js/restoreScroll.js
Normal file
25
themes/_global/js/restoreScroll.js
Normal file
|
@ -0,0 +1,25 @@
|
|||
function supportsLocalStorage() {
|
||||
try {
|
||||
return 'localStorage' in window && window['localStorage'] !== null;
|
||||
} catch (e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
function savePercent(id, percent) {
|
||||
if (!supportsLocalStorage()) { return false; }
|
||||
localStorage["poche.article." + id + ".percent"] = percent;
|
||||
return true;
|
||||
}
|
||||
|
||||
function retrievePercent(id) {
|
||||
if (!supportsLocalStorage()) { return false; }
|
||||
|
||||
var bheight = $(document).height();
|
||||
var percent = localStorage["poche.article." + id + ".percent"];
|
||||
var scroll = bheight * percent;
|
||||
|
||||
$('html,body').animate({scrollTop: scroll}, 'fast');
|
||||
|
||||
return true;
|
||||
}
|
109
themes/_global/js/saveLink.js
Executable file
109
themes/_global/js/saveLink.js
Executable file
|
@ -0,0 +1,109 @@
|
|||
$.fn.ready(function() {
|
||||
|
||||
var $bagit = $('#bagit'),
|
||||
$bagitForm = $('#bagit-form'),
|
||||
$bagitFormForm = $('#bagit-form-form');
|
||||
|
||||
/* ==========================================================================
|
||||
bag it link and close button
|
||||
========================================================================== */
|
||||
|
||||
function toggleSaveLinkForm(url, event) {
|
||||
$("#add-link-result").empty();
|
||||
|
||||
$bagit.toggleClass("active-current");
|
||||
|
||||
//only if bag-it link is not presented on page
|
||||
if ( $bagit.length === 0 ) {
|
||||
if ( event !== 'undefined' && event ) {
|
||||
$bagitForm.css( {position:"absolute", top:event.pageY, left:event.pageX-200});
|
||||
}
|
||||
else {
|
||||
$bagitForm.css( {position:"relative", top:"auto", left:"auto"});
|
||||
}
|
||||
}
|
||||
|
||||
if ($("#search-form").length != 0) {
|
||||
$("#search").removeClass("current");
|
||||
$("#search-arrow").removeClass("arrow-down");
|
||||
$("#search-form").hide();
|
||||
}
|
||||
$bagitForm.toggle();
|
||||
$('#content').toggleClass("opacity03");
|
||||
if (url !== 'undefined' && url) {
|
||||
$('#plainurl').val(url);
|
||||
}
|
||||
$('#plainurl').focus();
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// These two functions are now taken care of in popupForm.js
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
// $bagit.click(function(){
|
||||
// $bagit.toggleClass("current");
|
||||
// $("#bagit-arrow").toggleClass("arrow-down");
|
||||
// toggleSaveLinkForm();
|
||||
// });
|
||||
|
||||
// $("#bagit-form-close").click(function(){
|
||||
// $bagit.removeClass("current");
|
||||
// $("#bagit-arrow").removeClass("arrow-down");
|
||||
// toggleSaveLinkForm();
|
||||
// });
|
||||
|
||||
|
||||
//send "bag it link" form request via ajax
|
||||
$bagitFormForm.submit( function(event) {
|
||||
$("body").css("cursor", "wait");
|
||||
$("#add-link-result").empty();
|
||||
|
||||
$.ajax({
|
||||
type: $bagitFormForm.attr('method'),
|
||||
url: $bagitFormForm.attr('action'),
|
||||
data: $bagitFormForm.serialize(),
|
||||
success: function(data) {
|
||||
$('#add-link-result').html("Done!");
|
||||
$('#plainurl').val('');
|
||||
$('#plainurl').blur('');
|
||||
$("body").css("cursor", "auto");
|
||||
//setTimeout( function() { toggleSaveLinkForm(); }, 1000); //close form after 1000 delay
|
||||
},
|
||||
error: function(data) {
|
||||
$('#add-link-result').html("Failed!");
|
||||
$("body").css("cursor", "auto");
|
||||
}
|
||||
});
|
||||
|
||||
event.preventDefault();
|
||||
});
|
||||
|
||||
/* ==========================================================================
|
||||
Keyboard gestion
|
||||
========================================================================== */
|
||||
|
||||
$(window).keydown(function(e){
|
||||
if ( ( e.target.tagName.toLowerCase() !== 'input' && e.keyCode == 83 ) || (e.keyCode == 27 && $bagitForm.is(':visible') ) ) {
|
||||
$bagit.removeClass("current");
|
||||
$("#bagit-arrow").removeClass("arrow-down");
|
||||
toggleSaveLinkForm();
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
/* ==========================================================================
|
||||
Process all links inside an article
|
||||
========================================================================== */
|
||||
|
||||
$("article a[href^='http']").after(function() {
|
||||
return " <a href=\"" + $(this).attr('href') + "\" class=\"add-to-wallabag-link-after\" alt=\"add to wallabag\" title=\"add to wallabag\"></a> ";
|
||||
});
|
||||
|
||||
$(".add-to-wallabag-link-after").click(function(event){
|
||||
toggleSaveLinkForm($(this).attr('href'), event);
|
||||
event.preventDefault();
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue