auto-include library scripts
This commit is contained in:
parent
7f73a1f87e
commit
f070bbe69e
@ -80,6 +80,10 @@ class GenericPage {
|
|||||||
case "page":
|
case "page":
|
||||||
header("Cache-control: no-cache");
|
header("Cache-control: no-cache");
|
||||||
usort($this->blocks, "blockcmp");
|
usort($this->blocks, "blockcmp");
|
||||||
|
$data_href = get_base_href();
|
||||||
|
foreach(glob("lib/*.js") as $js) {
|
||||||
|
$this->add_header("<script src='$data_href/$js' type='text/javascript'></script>");
|
||||||
|
}
|
||||||
$layout = new Layout();
|
$layout = new Layout();
|
||||||
$layout->display_page($page);
|
$layout->display_page($page);
|
||||||
break;
|
break;
|
||||||
|
11
lib/jquery.auto-complete.pack.js
Normal file
11
lib/jquery.auto-complete.pack.js
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
/**
|
||||||
|
* Auto Complete v2.1
|
||||||
|
* June 11, 2009
|
||||||
|
* Corey Hart @ http://www.codenothing.com
|
||||||
|
*
|
||||||
|
* Auto Complete takes input from the user and runs a check through PHP to find what the user
|
||||||
|
* is looking for. This test case runs a limited search on words that begin with the letter 'a'.
|
||||||
|
*
|
||||||
|
* @css: Optional class for list rollovers, defaults to 'non-404'
|
||||||
|
*/
|
||||||
|
;(function($){$.fn.autoComplete=function(css){this.each(function(){var $obj=$(this),$input=$("input[type='text']",$obj),settings={opt:-1,inputval:"",css:(css)?css:"non-404",ajax:$("input[name='href']",$obj).val()};$input.keyup(function(e){var key=e.keyCode;if((key>47&&key<91)||key==8){settings.opt=-1;settings.inputval=$input.val();sendRequest(settings.inputval)}else{if(key==37||key==39){settings.opt=-1;$("ul",$obj).html("")}else{if(key==38){if(settings.opt>=0){settings.opt--;var val=$("ul li",$obj).removeClass(settings.css).eq(settings.opt).addClass(settings.css).attr("rel");val=(settings.opt<0)?settings.inputval:val;if(val){$input.val(val)}}}else{if(key==40){if(settings.opt<$("ul li",$obj).length-1){settings.opt++;var val=$("ul li",$obj).removeClass(settings.css).eq(settings.opt).addClass(settings.css).attr("rel");if(val){$input.val(val)}}}}}}}).blur(function(){settings.opt=-1;$("ul",$obj).html("")});var sendRequest=function(val){$.post(settings.ajax,{value:val},function(json){$("ul",$obj).html("");json=eval(json);if(json&&json.length>0){for(i in json){$("ul",$obj).append('<li rel="'+json[i].value+'">'+json[i].display+"</li>")}mouseaction()}})};function mouseaction(){$("ul li",$obj).mouseover(function(){$("ul li",$obj).removeClass(settings.css);$input.val($(this).addClass(settings.css).attr("rel"))}).click(function(){$("ul",$obj).html("")});$("ul",$obj).mouseout(function(){$input.val(settings.inputval)})}})}})(jQuery);
|
97
lib/jquery.cookie.js
Normal file
97
lib/jquery.cookie.js
Normal file
@ -0,0 +1,97 @@
|
|||||||
|
/**
|
||||||
|
* Cookie plugin
|
||||||
|
*
|
||||||
|
* Copyright (c) 2006 Klaus Hartl (stilbuero.de)
|
||||||
|
* Dual licensed under the MIT and GPL licenses:
|
||||||
|
* http://www.opensource.org/licenses/mit-license.php
|
||||||
|
* http://www.gnu.org/licenses/gpl.html
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a cookie with the given name and value and other optional parameters.
|
||||||
|
*
|
||||||
|
* @example $.cookie('the_cookie', 'the_value');
|
||||||
|
* @desc Set the value of a cookie.
|
||||||
|
* @example $.cookie('the_cookie', 'the_value', { expires: 7, path: '/', domain: 'jquery.com', secure: true });
|
||||||
|
* @desc Create a cookie with all available options.
|
||||||
|
* @example $.cookie('the_cookie', 'the_value');
|
||||||
|
* @desc Create a session cookie.
|
||||||
|
* @example $.cookie('the_cookie', null);
|
||||||
|
* @desc Delete a cookie by passing null as value. Keep in mind that you have to use the same path and domain
|
||||||
|
* used when the cookie was set.
|
||||||
|
*
|
||||||
|
* @param String name The name of the cookie.
|
||||||
|
* @param String value The value of the cookie.
|
||||||
|
* @param Object options An object literal containing key/value pairs to provide optional cookie attributes.
|
||||||
|
* @option Number|Date expires Either an integer specifying the expiration date from now on in days or a Date object.
|
||||||
|
* If a negative value is specified (e.g. a date in the past), the cookie will be deleted.
|
||||||
|
* If set to null or omitted, the cookie will be a session cookie and will not be retained
|
||||||
|
* when the the browser exits.
|
||||||
|
* @option String path The value of the path atribute of the cookie (default: path of page that created the cookie).
|
||||||
|
* @option String domain The value of the domain attribute of the cookie (default: domain of page that created the cookie).
|
||||||
|
* @option Boolean secure If true, the secure attribute of the cookie will be set and the cookie transmission will
|
||||||
|
* require a secure protocol (like HTTPS).
|
||||||
|
* @type undefined
|
||||||
|
*
|
||||||
|
* @name $.cookie
|
||||||
|
* @cat Plugins/Cookie
|
||||||
|
* @author Klaus Hartl/klaus.hartl@stilbuero.de
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the value of a cookie with the given name.
|
||||||
|
*
|
||||||
|
* @example $.cookie('the_cookie');
|
||||||
|
* @desc Get the value of a cookie.
|
||||||
|
*
|
||||||
|
* @param String name The name of the cookie.
|
||||||
|
* @return The value of the cookie.
|
||||||
|
* @type String
|
||||||
|
*
|
||||||
|
* @name $.cookie
|
||||||
|
* @cat Plugins/Cookie
|
||||||
|
* @author Klaus Hartl/klaus.hartl@stilbuero.de
|
||||||
|
*/
|
||||||
|
jQuery.cookie = function(name, value, options) {
|
||||||
|
if (typeof value != 'undefined') { // name and value given, set cookie
|
||||||
|
options = options || {};
|
||||||
|
if (value === null) {
|
||||||
|
value = '';
|
||||||
|
options = $.extend({}, options); // clone object since it's unexpected behavior if the expired property were changed
|
||||||
|
options.expires = -1;
|
||||||
|
}
|
||||||
|
var expires = '';
|
||||||
|
if (options.expires && (typeof options.expires == 'number' || options.expires.toUTCString)) {
|
||||||
|
var date;
|
||||||
|
if (typeof options.expires == 'number') {
|
||||||
|
date = new Date();
|
||||||
|
date.setTime(date.getTime() + (options.expires * 24 * 60 * 60 * 1000));
|
||||||
|
} else {
|
||||||
|
date = options.expires;
|
||||||
|
}
|
||||||
|
expires = '; expires=' + date.toUTCString(); // use expires attribute, max-age is not supported by IE
|
||||||
|
}
|
||||||
|
// NOTE Needed to parenthesize options.path and options.domain
|
||||||
|
// in the following expressions, otherwise they evaluate to undefined
|
||||||
|
// in the packed version for some reason...
|
||||||
|
var path = options.path ? '; path=' + (options.path) : '';
|
||||||
|
var domain = options.domain ? '; domain=' + (options.domain) : '';
|
||||||
|
var secure = options.secure ? '; secure' : '';
|
||||||
|
document.cookie = [name, '=', encodeURIComponent(value), expires, path, domain, secure].join('');
|
||||||
|
} else { // only name given, get cookie
|
||||||
|
var cookieValue = null;
|
||||||
|
if (document.cookie && document.cookie != '') {
|
||||||
|
var cookies = document.cookie.split(';');
|
||||||
|
for (var i = 0; i < cookies.length; i++) {
|
||||||
|
var cookie = jQuery.trim(cookies[i]);
|
||||||
|
// Does this cookie string begin with the name we want?
|
||||||
|
if (cookie.substring(0, name.length + 1) == (name + '=')) {
|
||||||
|
cookieValue = decodeURIComponent(cookie.substring(name.length + 1));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return cookieValue;
|
||||||
|
}
|
||||||
|
};
|
@ -49,10 +49,6 @@ class Layout {
|
|||||||
<meta http-equiv="Content-Type" content="text/html;charset=utf-8">
|
<meta http-equiv="Content-Type" content="text/html;charset=utf-8">
|
||||||
<link rel="stylesheet" href="$data_href/themes/$theme_name/style.css" type="text/css">
|
<link rel="stylesheet" href="$data_href/themes/$theme_name/style.css" type="text/css">
|
||||||
$header_html
|
$header_html
|
||||||
<script src='$data_href/themes/$theme_name/sidebar.js' type='text/javascript'></script>
|
|
||||||
<script src='$data_href/themes/$theme_name/script.js' type='text/javascript'></script>
|
|
||||||
<script src='$data_href/lib/jquery-1.3.2.min.js' type='text/javascript'></script>
|
|
||||||
<script src='$data_href/lib/jquery.tablesorter.min.js' type='text/javascript'></script>
|
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body>
|
<body>
|
||||||
@ -92,7 +88,16 @@ EOD;
|
|||||||
$(document).ready(function() {
|
$(document).ready(function() {
|
||||||
$(\"#$i-toggle\").click(function() {
|
$(\"#$i-toggle\").click(function() {
|
||||||
$(\"#$i\").slideToggle(\"slow\");
|
$(\"#$i\").slideToggle(\"slow\");
|
||||||
|
if($(\"#$i\").is(\":hidden\")) {
|
||||||
|
$.cookie(\"$i-hidden\", true);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$.cookie(\"$i-hidden\", false);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
if($.cookie(\"$i-hidden\")) {
|
||||||
|
$(\"#$i\").hide();
|
||||||
|
}
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
<div class='hrr'>
|
<div class='hrr'>
|
||||||
|
@ -1,83 +0,0 @@
|
|||||||
/*
|
|
||||||
* This script shamelessly stolen from wakachan.org d(^_^)b
|
|
||||||
*/
|
|
||||||
|
|
||||||
var cookie_name="shimmie_sidebar";
|
|
||||||
var default_sections=["upload", "edit_tags"];
|
|
||||||
|
|
||||||
function toggle(id)
|
|
||||||
{
|
|
||||||
var e=document.getElementById(id);
|
|
||||||
if(!e) return;
|
|
||||||
if(e.style.display)
|
|
||||||
{
|
|
||||||
remove_section(id);
|
|
||||||
e.style.display="";
|
|
||||||
|
|
||||||
var e2 = document.getElementById(id+"-toggle");
|
|
||||||
if(e2) {
|
|
||||||
e2.style.color = "#000";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
add_section(id);
|
|
||||||
e.style.display="none";
|
|
||||||
|
|
||||||
var e2 = document.getElementById(id+"-toggle");
|
|
||||||
if(e2) {
|
|
||||||
e2.style.color = "#AAA";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function add_section(id)
|
|
||||||
{
|
|
||||||
var sections=get_sections();
|
|
||||||
for(var i=0;i<sections.length;i++) if(sections[i]==id) return;
|
|
||||||
sections.push(id);
|
|
||||||
set_sections(sections);
|
|
||||||
}
|
|
||||||
|
|
||||||
function remove_section(id)
|
|
||||||
{
|
|
||||||
var sections=get_sections();
|
|
||||||
var new_sections=new Array();
|
|
||||||
for(var i=0;i<sections.length;i++) if(sections[i]!=id) new_sections.push(sections[i]);
|
|
||||||
set_sections(new_sections);
|
|
||||||
}
|
|
||||||
|
|
||||||
function get_sections()
|
|
||||||
{
|
|
||||||
var cookie=get_cookie(cookie_name);
|
|
||||||
if(cookie) return cookie.split(/,/);
|
|
||||||
else return default_sections;
|
|
||||||
}
|
|
||||||
|
|
||||||
function set_sections(sections) { set_cookie(cookie_name,sections.join(","),365); }
|
|
||||||
|
|
||||||
function get_cookie(name)
|
|
||||||
{
|
|
||||||
with(document.cookie)
|
|
||||||
{
|
|
||||||
var index=indexOf(name+"=");
|
|
||||||
if(index==-1) return '';
|
|
||||||
index=indexOf("=",index)+1;
|
|
||||||
var endstr=indexOf(";",index);
|
|
||||||
if(endstr==-1) endstr=length;
|
|
||||||
return unescape(substring(index,endstr));
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
function set_cookie(name,value,days)
|
|
||||||
{
|
|
||||||
if(days)
|
|
||||||
{
|
|
||||||
var date=new Date();
|
|
||||||
date.setTime(date.getTime()+(days*24*60*60*1000));
|
|
||||||
var expires="; expires="+date.toGMTString();
|
|
||||||
}
|
|
||||||
else expires="";
|
|
||||||
document.cookie=name+"="+value+expires+"; path=/";
|
|
||||||
}
|
|
||||||
|
|
Loading…
x
Reference in New Issue
Block a user