Added smaller backend JS files to 2k11 admin theme; also coding style QA and documentation in those files.
This commit is contained in:
parent
ec83606bf1
commit
0a3d63ab01
92
templates/2k11/admin/admin_scripts.js
Normal file
92
templates/2k11/admin/admin_scripts.js
Normal file
@ -0,0 +1,92 @@
|
||||
// usage: log('inside coolFunc', this, arguments);
|
||||
// paulirish.com/2009/log-a-lightweight-wrapper-for-consolelog/
|
||||
window.log = function f(){ log.history = log.history || []; log.history.push(arguments); if(this.console) { var args = arguments, newarr; try { args.callee = f.caller } catch(e) {}; newarr = [].slice.call(args); if (typeof console.log === 'object') log.apply.call(console.log, console, newarr); else console.log.apply(console, newarr);}};
|
||||
|
||||
// make it safe to use console.log always
|
||||
(function(a){function b(){}for(var c="assert,count,debug,dir,dirxml,error,exception,group,groupCollapsed,groupEnd,info,log,markTimeline,profile,profileEnd,time,timeEnd,trace,warn".split(","),d;!!(d=c.pop());){a[d]=a[d]||b;}})
|
||||
(function(){try{console.log();return window.console;}catch(a){return (window.console={});}}());
|
||||
|
||||
|
||||
// place any jQuery/helper plugins in here, instead of separate, slower script files.
|
||||
|
||||
// Serendipity backend functions - used in
|
||||
// - serendipity_plugins_admin.inc.php::serendipity_plugin_config() function
|
||||
// - templates/default/admin/default_staticpage_backend.tpl
|
||||
|
||||
|
||||
// Collapse/expand one config group
|
||||
function showConfig(id) {
|
||||
if (document.getElementById) {
|
||||
plugbox = document.getElementById(id);
|
||||
if (plugbox.style.display == 'none') {
|
||||
document.getElementById('option' + id).src = img_minus;
|
||||
plugbox.style.display = '';
|
||||
} else {
|
||||
document.getElementById('option' + id).src = img_plus;
|
||||
plugbox.style.display = 'none';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Collapse/expand all config groups
|
||||
var state='';
|
||||
|
||||
function showConfigAll(count) {
|
||||
if (document.getElementById) {
|
||||
for (i = 1; i <= count; i++) {
|
||||
document.getElementById('el' + i).style.display = state;
|
||||
document.getElementById('optionel' + i).src = (state == '' ? img_minus : img_plus);
|
||||
}
|
||||
|
||||
if (state == '') {
|
||||
document.getElementById('optionall').src = img_minus;
|
||||
state = 'none';
|
||||
} else {
|
||||
document.getElementById('optionall').src = img_plus;
|
||||
state = '';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Seems to check all (checkbox) elements of a given form
|
||||
// NOTE: doesn't seem to be used anywhere?
|
||||
function chkAll(frm, arr, mark) {
|
||||
for (i = 0; i <= frm.elements.length; i++) {
|
||||
try {
|
||||
if(frm.elements[i].name == arr) {
|
||||
frm.elements[i].checked = mark;
|
||||
}
|
||||
} catch (err) {}
|
||||
}
|
||||
}
|
||||
|
||||
// Inverts a selection of checkboxes
|
||||
// NOTE: also used in serendipity_event_karma
|
||||
function invertSelection() {
|
||||
var f = document.formMultiDelete;
|
||||
|
||||
for (var i = 0; i < f.elements.length; i++) {
|
||||
if (f.elements[i].type == 'checkbox') {
|
||||
f.elements[i].checked = !(f.elements[i].checked);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Show (extended) filters in media db
|
||||
// NOTE: since we (will) use this in various sections of the backend, we
|
||||
// probably want a more generic function for this
|
||||
function showFilters() {
|
||||
s = document.getElementById('moreFilter').style;
|
||||
|
||||
if (s.display == 'none') {
|
||||
s.display = 'block';
|
||||
} else {
|
||||
s.display = 'none';
|
||||
}
|
||||
}
|
||||
|
||||
// Add another (image) keyword
|
||||
function AddKeyword(keyword) {
|
||||
s = document.getElementById('keyword_input').value;
|
||||
document.getElementById('keyword_input').value = (s != '' ? s + ';' : '') + keyword;
|
||||
}
|
35
templates/2k11/admin/header_spawn.js
Normal file
35
templates/2k11/admin/header_spawn.js
Normal file
@ -0,0 +1,35 @@
|
||||
// I have no idea what this does. Anybody?
|
||||
function spawn() {
|
||||
if (self.Spawnextended) {
|
||||
Spawnextended();
|
||||
}
|
||||
|
||||
if (self.Spawnbody) {
|
||||
Spawnbody();
|
||||
}
|
||||
|
||||
if (self.Spawnnugget) {
|
||||
Spawnnugget();
|
||||
}
|
||||
}
|
||||
|
||||
// Generic function to set cookies. Duh.
|
||||
function SetCookie(name, value) {
|
||||
var today = new Date();
|
||||
var expire = new Date();
|
||||
expire.setTime(today.getTime() + (60*60*24*30*1000));
|
||||
document.cookie = 'serendipity[' + name + ']='+escape(value) + ';expires=' + expire.toGMTString();
|
||||
}
|
||||
|
||||
// Some sort of onload wrapper? @onli says jQuery can help with this
|
||||
function addLoadEvent(func) {
|
||||
var oldonload = window.onload;
|
||||
if (typeof window.onload != 'function') {
|
||||
window.onload = func;
|
||||
} else {
|
||||
window.onload = function() {
|
||||
oldonload();
|
||||
func();
|
||||
}
|
||||
}
|
||||
}
|
13
templates/2k11/admin/image_selector.js
Normal file
13
templates/2k11/admin/image_selector.js
Normal file
@ -0,0 +1,13 @@
|
||||
// Switches preview of image selected from media db
|
||||
function change_preview(id) {
|
||||
var text_box = document.getElementById('serendipity[template][' + id + ']');
|
||||
var image_box = document.getElementById(id + '_preview');
|
||||
var filename = text_box.value;
|
||||
image_box.style.backgroundImage = 'url(' + filename + ')';
|
||||
image_box.style.backgroundRepeat = 'no-repeat';
|
||||
}
|
||||
|
||||
// Opens media db image selection in new window
|
||||
function choose_media(id) {
|
||||
window.open('serendipity_admin_image_selector.php?serendipity[htmltarget]=' + id + '&serendipity[filename_only]=true', 'ImageSel', 'width=800,height=600,toolbar=no,scrollbars=1,scrollbars,resize=1,resizable=1');
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user