Editing now working

This commit is contained in:
Timothy Warren 2012-09-12 14:36:43 +00:00
parent 55e69c2628
commit bb6d8ce624
27 changed files with 2181 additions and 602 deletions

View File

@ -28,7 +28,7 @@ abstract class Controller extends \miniMVC\Controller {
public function __construct()
{
parent::__construct();
$this->load_model('meta\model');
$this->load_model('meta\data_model');
$this->load_model('meta\user_model');
$this->session =& \miniMVC\Session::get_instance();
@ -58,7 +58,7 @@ abstract class Controller extends \miniMVC\Controller {
*/
public function __destruct()
{
$this->page->set_foot_js_group('js');
$this->page->set_foot_js_group('js', TRUE);
$this->page->build_footer();
}

View File

@ -29,10 +29,12 @@
// --------------------------------------------------------------------------
return [
return array(
// Default Paths
'default_controller' => 'welcome',
'default_module' => 'meta',
'delete' => 'meta/welcome/delete',
'update' => 'meta/welcome/update_item',
'genre' => 'meta/genre/index',
'genre/add' => 'meta/genre/add',
'genre/add_category' => 'meta/genre/add_category',
@ -41,6 +43,6 @@ return [
'section' => 'meta/section/index',
'section/add_data' => 'meta/section/add_data',
'404_route' => '',
];
);
// End of routes.php

View File

@ -44,9 +44,9 @@ class category extends meta\controller {
}
$data = array(
'category' => $this->model->get_category_by_id($id),
'sections' => $this->model->get_category_outline_data($id),
'genre' => $this->model->get_genre_by_category($id),
'category' => $this->data_model->get_category_by_id($id),
'sections' => $this->data_model->get_category_outline_data($id),
'genre' => $this->data_model->get_genre_by_category($id),
'category_id' => $id
);
@ -63,7 +63,7 @@ class category extends meta\controller {
$id = (int) $_POST['category_id'];
// Make sure the name doesn't already exist. If it does, show an error.
$res = $this->model->add_section($name, $id);
$res = $this->data_model->add_section($name, $id);
if ($res === TRUE)
{

View File

@ -44,7 +44,7 @@ class genre extends meta\controller {
{
// Otherwise, display list of genres
$data = array();
$data['genres'] = $this->model->get_genres();
$data['genres'] = $this->data_model->get_genres();
$this->load_view('genres', $data);
@ -63,7 +63,7 @@ class genre extends meta\controller {
$name = strip_tags($_POST['genre']);
// Make sure the name doesn't already exist. If it does, show an error.
$res = $this->model->add_genre($name);
$res = $this->data_model->add_genre($name);
if ($res === TRUE)
{
@ -85,8 +85,8 @@ class genre extends meta\controller {
*/
public function detail($id)
{
$genre = $this->model->get_genre_by_id($id);
$categories = $this->model->get_categories($id);
$genre = $this->data_model->get_genre_by_id($id);
$categories = $this->data_model->get_categories($id);
$data = array(
'genre' => $genre,
@ -107,7 +107,7 @@ class genre extends meta\controller {
$id = (int) $_POST['genre_id'];
// Make sure the name doesn't already exist. If it does, show an error.
$res = $this->model->add_category($name, $id);
$res = $this->data_model->add_category($name, $id);
if ($res === TRUE)
{

View File

@ -44,9 +44,9 @@ class section extends meta\controller {
}
$data = array(
'section' => $this->model->get_section_by_id($id),
'sdata' => $this->model->get_data($id),
'p' => $this->model->get_path_by_section($id),
'section' => $this->data_model->get_section_by_id($id),
'sdata' => $this->data_model->get_data($id),
'p' => $this->data_model->get_path_by_section($id),
'section_id' => $id
);
@ -70,7 +70,7 @@ class section extends meta\controller {
$data = array_combine($keys, $vals);
$res = $this->model->add_data($section_id, $data);
$res = $this->data_model->add_data($section_id, $data);
($res)

View File

@ -40,9 +40,9 @@ class welcome extends \meta\controller {
public function index()
{
$data = array();
$data['genres'] = $this->model->get_genres();
$data['genres'] = $this->data_model->get_genres();
$this->page->render('genres', $data);
$this->load_view('genres', $data);
}
// --------------------------------------------------------------------------
@ -52,7 +52,7 @@ class welcome extends \meta\controller {
*/
public function login()
{
$this->page->render('login');
$this->load_view('login');
}
// --------------------------------------------------------------------------
@ -72,8 +72,95 @@ class welcome extends \meta\controller {
*/
public function outline()
{
$outline_data = $this->model->get_outline_data();
$this->page->render('outline', array('outline' => $outline_data));
$outline_data = $this->data_model->get_outline_data();
$this->load_view('outline', array('outline' => $outline_data));
}
// --------------------------------------------------------------------------
/**
* Get a message for ajax insertion
*/
public function message()
{
$type = strip_tags($_GET['type']);
$message = $_GET['message'];
$this->page->set_output(
$this->page->set_message($type, $message, TRUE)
);
}
// --------------------------------------------------------------------------
public function delete()
{
$type = strip_tags($_POST['type']);
switch($type)
{
case "genre":
case "category":
case "section":
case "data":
$res = (int) $this->data_model->delete($type, (int) $_POST['id']);
break;
default:
$res = 0;
break;
}
die(trim($res));
}
// --------------------------------------------------------------------------
public function edit()
{
$type = strip_tags($_GET['type']);
$id = (int) $_GET['id'];
if ($this->data_model->is_valid_type($type))
{
$data = call_user_func(array($this->data_model, "get_{$type}_by_id"), $id);
$form_array = array(
'name' => is_array($data) ? $data['key'] : "",
'val' => is_array($data) ? $data['value'] : $data,
'type' => $type,
'id' => $id
);
exit($this->load_view('edit_form', $form_array, TRUE));
}
}
// --------------------------------------------------------------------------
public function update_item()
{
$id = (int) $_POST['id'];
$type = strip_tags($_POST['type']);
$name = strip_tags($_POST['name']);
$val = (isset($_POST['val'])) ? $_POST['val'] : NULL;
if ($this->data_model->is_valid_type($type))
{
if ($type != 'data')
{
$res = $this->data_model->update($type, $id, $name);
}
else
{
$res = $this->data_model->update_data($id, $name, $val);
}
$res = (int) $res;
exit(trim($res));
}
exit(0);
}
}

View File

@ -20,7 +20,7 @@ namespace meta;
*
* @package meta
*/
class model extends \miniMVC\Model {
class data_model extends \miniMVC\Model {
/**
* Reference to database connection
@ -56,12 +56,22 @@ class model extends \miniMVC\Model {
*
* @param string $type
* @param int $id
* @return bool
*/
public function delete($type, $id)
{
try
{
$this->db->where('id', (int) $id)
->delete($type);
}
catch (\PDOException $e)
{
return FALSE;
}
return TRUE;
}
// --------------------------------------------------------------------------
@ -89,6 +99,54 @@ class model extends \miniMVC\Model {
// --------------------------------------------------------------------------
/**
* Rename a genre/category/section
*
* @param string
* @param int
* @param string
* @return bool
*/
public function update($type, $id, $name)
{
$query = $this->db->set($type, $name)
->where('id', (int) $id)
->update($type);
return ( ! empty($query)) ;
}
// --------------------------------------------------------------------------
/**
* Update the data
*
* @param int
* @param string
* @param string
* @return bool
*/
public function update_data($data_id, $key, $val)
{
try{
// Save the data
$this->db->set('key', $key)
->set('value', $val)
->where('id', (int) $data_id)
->update('data');
}
catch(\PDOException $e)
{
return FALSE;
}
return TRUE;
}
// --------------------------------------------------------------------------
// ! Adding data
// --------------------------------------------------------------------------
/**
* Add genre
*
@ -216,41 +274,7 @@ class model extends \miniMVC\Model {
return TRUE;
}
// --------------------------------------------------------------------------
/**
* Rename a genre/category/section
*
* @param string
* @param int
* @param string
*/
public function update($type, $id, $name)
{
$this->db->set($type, $name)
->where('id', (int) $id)
->update($type);
}
// --------------------------------------------------------------------------
/**
* Update the data
*
* @param int
* @param string
* @param string
*/
public function update_data($data_id, $key, $val)
{
// Save the data
$this->db->set('key', $key)
->set('value', $val)
->where('id', (int) $data_id)
->update('data');
}
// --------------------------------------------------------------------------
// ! Data Retrieval
@ -401,6 +425,26 @@ class model extends \miniMVC\Model {
// --------------------------------------------------------------------------
/**
* Gets the data for the specified id
*
* @param int $id
* @return array
*/
public function get_data_by_id($id)
{
$query = $this->db->select('key, value')
->from('data')
->where('id', (int) $id)
->get();
$row = $query->fetch(\PDO::FETCH_ASSOC);
return $row;
}
// --------------------------------------------------------------------------
/**
* Get the categories for the specified genre
*
@ -468,7 +512,7 @@ class model extends \miniMVC\Model {
while($row = $query->fetch(\PDO::FETCH_ASSOC))
{
$data[$row['id']] = array($row['key'] => str_replace("\n", "<br />", $row['value']));
$data[$row['id']] = array($row['key'] => $row['value']);
}
return $data;
@ -507,7 +551,7 @@ class model extends \miniMVC\Model {
while($row = $d_query->fetch(\PDO::FETCH_ASSOC))
{
$d_array[$row['section_id']][$row['key']] = str_replace("\n", "<br />", $row['value']);
$d_array[$row['section_id']][$row['key']] = $row['value'];
}
}
@ -611,9 +655,9 @@ class model extends \miniMVC\Model {
'genre','category','section','data'
);
return in_array(str_to_lower($str), $valid);
return in_array(strtolower($str), $valid);
}
}
// End of model.php
// End of data_model.php

View File

@ -36,7 +36,6 @@
<dt>
<?= $k ?>
</dt>
<dd><?= $v ?></dd>

View File

@ -1,19 +1,22 @@
<form method="post" action="<?= $action ?>">
<form method="post" action="javascript:meta.update_item()" id="edit_form">
<fieldset>
<legend>Edit <?= ucfirst($type) ?></legend>
<dl>
<?php if ($type != 'data'): ?>
<dt><label for="<?= $field_name ?>"><?= $type ?></label></dt>
<dd><input type="text" value="<?= $field_val ?>" name="<?= $field_name ?>" id="<?= $field_name ?>" /></dd>
<dt><label for="name"><?= ucfirst($type) ?></label></dt>
<dd><input type="text" value="<?= $val ?>" name="name" id="name" /></dd>
<?php else: ?>
<dt><label for="key">Name:</label></dt>
<dt><label for="name">Name:</label></dt>
<dd><input type="text" value="<?= $name ?>" id="name" name="name" /></dd>
<dt><label for="val">Value:</label></dt>
<dd><textarea name="val" rows="5" cols="40"><?= $val ?></textarea></dd>
<dd><textarea id="val" name="val" rows="5" cols="40"><?= $val ?></textarea></dd>
<?php endif ?>
<dt><input type="hidden" name="<?= $type ?>_id" value="<?= $field_id ?>" /></dt>
<dd><button type="submit">Save Changes</button></dd>
<dt>
<input type="hidden" id="id" name="id" value="<?= $id ?>" />
<input type="hidden" id="type" name="type" value="<?= $type ?>" />
</dt>
<dd><button type="submit" class="save">Save Changes</button></dd>
</dl>
</fieldset>
</form>

View File

@ -1,5 +1,18 @@
<h2>Outline</h2>
<dl>
<dt>Genre</dt>
<dd>
<ul>
<li>Category
<ul>
<li>Section</li>
</ul>
</li>
</ul>
</dd>
</dl>
<hr />
<dl class="outline">
<?php if (isset($outline)): ?>
<?php foreach($outline as $genre_id => $genre_array): ?>

View File

@ -26,12 +26,18 @@
<?php if ( ! empty($sdata)): ?>
<?php foreach($sdata as $d): ?>
<?php foreach($sdata as $d_id => $d): ?>
<?php foreach($d as $k => $v): ?>
<?php $class = (strpos($v, "<br />") !== FALSE) ? 'multiline' : 'pair' ?>
<dl class="<?= $class ?>">
<dt><?= $k ?></dt>
<dt>
<?= $k ?>
<span class="modify" id="data_<?=$d_id ?>">
<button class="edit">Edit</button>
<button class="delete">Delete</button>
</span>
</dt>
<dd><?= $v ?></dd>
</dl>

View File

@ -1,4 +1,8 @@
<div id="overlay_bg"></div>
<div id="overlay"></div>
<script type="text/javascript">
var APP_URL = '<?= \miniMVC\site_url(); ?>';
</script>
<?php if ($foot_js != ""): ?>
<?= $foot_js ?>
<?php endif ?>

View File

@ -10,3 +10,4 @@
</head>
<body<?= (!empty($body_class)) ? "class=\"" . $body_class . "\"" : ""; ?><?= (!empty($body_id)) ? " id=\"" . $body_id . "\"" : ""; ?>>
<h1><a href="<?= miniMVC\site_url('') ?>">Meta</a></h1>
[<a href="<?= miniMVC\site_url('outline')?>">Data Outline</a>]<br />

View File

@ -1,5 +1,5 @@
<div class="message <?= $stat_class ?>">
<span class="icon"></span>
<?= $message ?>
<span class="close" onclick="this.parentElement.style.display='none'"></span>
<span class="close" onclick="this.parentElement.style.display='none'">x</span>
</div>

View File

@ -27,7 +27,7 @@ return array(
*/
'js' => array(
'kis-lite-dom-min.js',
'kis-lite-dom.js',
'tinyeditor.js',
'meta.js'
),

View File

@ -8,10 +8,16 @@
.message .close{
width:1em;
height:1em;
border:1px solid #000;
position:absolute;
right:0.5em;
top:0.5em;
text-align:center;
vertical-align:middle;
line-height:1em;
}
.message .close:hover {
cursor:pointer;
}
.message .icon{

View File

@ -30,8 +30,6 @@ audio,
canvas,
video {
display: inline-block;
*display: inline;
*zoom: 1;
}
/*
@ -83,14 +81,6 @@ textarea {
font-family: sans-serif;
}
/*
* Addresses margins handled incorrectly in IE6/7
*/
body {
margin: 0;
}
/* =============================================================================
Links
@ -192,15 +182,6 @@ mark {
color: #000;
}
/*
* Addresses margins set differently in IE6/7
*/
p,
pre {
margin: 1em 0;
}
/*
* Corrects font family set oddly in IE6, S4/5, Chrome
* en.wikipedia.org/wiki/User:Davidgothberg/Test59
@ -211,7 +192,6 @@ code,
kbd,
samp {
font-family: monospace, serif;
_font-family: 'courier new', monospace;
font-size: 1em;
}
@ -226,18 +206,8 @@ pre {
}
/*
* 1. Addresses CSS quotes not supported in IE6/7
* 2. Addresses quote property not supported in S4
* Addresses quote property not supported in S4
*/
/* 1 */
q {
quotes: none;
}
/* 2 */
q:before,
q:after {
content: '';
@ -270,59 +240,16 @@ sub {
}
/* =============================================================================
Lists
========================================================================== */
/*
* Addresses margins set differently in IE6/7
*/
dl,
menu,
ol,
ul {
margin: 1em 0;
}
dd {
margin: 0 0 0 40px;
}
/*
* Addresses paddings set differently in IE6/7
*/
menu,
ol,
ul {
padding: 0 0 0 40px;
}
/*
* Corrects list images handled incorrectly in IE7
*/
nav ul,
nav ol {
list-style: none;
list-style-image: none;
}
/* =============================================================================
Embedded content
========================================================================== */
/*
* 1. Removes border when inside 'a' element in IE6/7/8/9, FF3
* 2. Improves image quality when scaled in IE7
* code.flickr.com/blog/2008/11/12/on-ui-quality-the-little-things-client-side-image-resizing/
* Removes border when inside 'a' element in IE6/7/8/9, FF3
*/
img {
border: 0; /* 1 */
-ms-interpolation-mode: bicubic; /* 2 */
border: 0;
}
/*
@ -351,14 +278,6 @@ figure {
Forms
========================================================================== */
/*
* Corrects margin displayed oddly in IE6/7
*/
form {
margin: 0;
}
/*
* Define consistent border, margin, and padding
*/
@ -372,14 +291,12 @@ fieldset {
/*
* 1. Corrects color not being inherited in IE6/7/8/9
* 2. Corrects text not wrapping in FF3
* 3. Corrects alignment displayed oddly in IE6/7
*/
legend {
border: 0; /* 1 */
padding: 0;
white-space: normal; /* 2 */
*margin-left: -7px; /* 3 */
}
/*
@ -395,7 +312,6 @@ textarea {
font-size: 100%; /* 1 */
margin: 0; /* 2 */
vertical-align: baseline; /* 3 */
*vertical-align: middle; /* 3 */
}
/*
@ -420,7 +336,6 @@ input[type="reset"],
input[type="submit"] {
cursor: pointer; /* 1 */
-webkit-appearance: button; /* 2 */
*overflow: visible; /* 3 */
}
/*
@ -435,16 +350,12 @@ input[disabled] {
/*
* 1. Addresses box sizing set to content-box in IE8/9
* 2. Removes excess padding in IE8/9
* 3. Removes excess padding in IE7
Known issue: excess padding remains in IE6
*/
input[type="checkbox"],
input[type="radio"] {
box-sizing: border-box; /* 1 */
padding: 0; /* 2 */
*height: 13px; /* 3 */
*width: 13px; /* 3 */
}
/*

View File

@ -1,6 +1,10 @@
/* ---------------- */
/* ! General Styles */
/* ---------------- */
* {
vertical-align:middle;
}
html, body {
font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
font-weight:200;
@ -11,10 +15,12 @@ html, body {
button {
color:#312;
padding:5px;
border:1px solid #555;
padding:0.25em;
border:1px solid #888;
border-radius:5px;
box-shadow:1px 1px #a98;
box-shadow:1px 1px #aaa;
min-width:65px;
vertical-align:middle;
}
a {
@ -39,11 +45,26 @@ h1,h2 {
width:25%;
}
/* Hide forms by default */
fieldset dl {
display:none;
ul {
/*padding:auto;*/
padding-left:2.5em;
margin:0;
}
li {
padding:0.5em 0;
}
dd {
/*margin:auto;*/
margin-left:0.5em;
}
/* Hide forms by default */
/*fieldset dl {
display:none;
}*/
/* form styles */
form dt, form dd {
display:inline-block;
@ -68,32 +89,62 @@ form dd {
position:absolute;
display:none;
margin-left:1em;
vertical-align:middle;
}
li:hover .modify, dt:hover .modify {
li:hover > .modify, dt:hover > .modify {
display:inline-block;
vertical-align:middle;
}
button.save {
background:#797;
color:#eee;
background:-o-linear-gradient(#797, #595);
background:-moz-linear-gradient(#797, #595);
background:-webkit-linear-gradient(#797, #595);
background:linear-gradient(#797, #595);
color:#fff;
}
button.save:hover {
background:#595;
background:-o-linear-gradient(#595, #797);
background:-moz-linear-gradient(#595, #797);
background:-webkit-linear-gradient(#595, #797);
background:linear-gradient(#595, #797);
}
button.edit {
background:#fff;
background:-o-linear-gradient(#fff, #ddd);
background:-moz-linear-gradient(#fff, #ddd);
background:-webkit-linear-gradient(#fff, #ddd);
background:linear-gradient(#fff, #ddd);
}
button.edit:hover {
background:#ddd;
background:-o-linear-gradient(#ddd, #fff);
background:-moz-linear-gradient(#ddd, #fff);
background:-webkit-linear-gradient(#ddd, #fff);
background:linear-gradient(#ddd, #fff);
}
button.delete {
background:#977;
color:#eee;
background:-o-linear-gradient(#977, #955);
background:-moz-linear-gradient(#977, #955);
background:-webkit-linear-gradient(#977, #955);
background:linear-gradient(#977, #955);
color:#fff;
}
button.delete:hover {
background:#955;
background:-o-linear-gradient(#955, #977);
background:-moz-linear-gradient(#955, #977);
background:-webkit-linear-gradient(#955, #977);
background:linear-gradient(#955, #977);
}
/* ! Outline styles */
@ -106,6 +157,14 @@ button.delete:hover {
margin-left:0.5em;
}
dl.outline {
border-bottom:1px dotted #555;
}
dl.outline dt {
display:list-item;
list-style:square inside;
}
.list li {
list-style:none;
}
@ -146,5 +205,33 @@ dl.pair dd {
padding-left:0;
}
/* ! Form overlay styles */
#overlay_bg {
background:#777;
background:rgba(105,105,220,0.85);
position:fixed;
display:none;
width:900%;
height:900%;
z-index:5;
left:0;
top:0;
}
#overlay {
position:absolute;
background:#ddd;
/*background:rgba(255,255,255,0.85);
top:25%;
left:25%;
width:600px;
height:auto;*/
min-width:700px;
padding:0.5em;
border-radius:5px;
display:none;
z-index:25;
}

View File

@ -49,7 +49,7 @@ function get_files()
foreach ($groups[$_GET['g']] as $file)
{
$new_file = realpath($js_root.$file);
$js .= file_get_contents($new_file);
$js .= file_get_contents($new_file)."\n";
}
return $js;

75
assets/js/cache/js vendored
View File

@ -1,34 +1,41 @@
(function(){if("undefined"!==typeof document.querySelector){var f,e,d,c;f=function(a){c="undefined"===typeof a?"undefined"!==typeof f.el?f.el:document.documentElement:"object"!==typeof a?e(a):a;f.prototype.el=c;var a=d(f),b;for(b in a)"object"===typeof a[b]&&(a[b].el=c);a.el=c;return a};e=function(a,b){var c;if("string"!=typeof a||"undefined"===typeof a)return a;c=null!=b&&1===b.nodeType?b:document;if(a.match(/^#([\w\-]+$)/))return document.getElementById(a.split("#")[1]);c=c.querySelectorAll(a);
return 1===c.length?c[0]:c};d=function(a){var b;if("undefined"!==typeof a){if("undefined"!==typeof Object.create)return Object.create(a);b=typeof a;if(!("object"!==b&&"function"!==b))return b=function(){},b.prototype=a,new b}};f.ext=function(a,b){b.el=c;f[a]=b};f.ext("each",function(a){if("undefined"!==typeof c.length&&c!==window)if("undefined"!==typeof Array.prototype.forEach)[].forEach.call(c,a);else{var b=c.length;if(0!==b)for(var d,e=0;e<b;e++)d=c.item(e)?c.item(e):c[e],a.call(d,d)}else a.call(c,
c)});f.type=function(a){return function(){return a&&a!==this}.call(a)?(typeof a).toLowerCase():{}.toString.call(a).match(/\s([a-z|A-Z]+)/)[1].toLowerCase()};f=window.$_=window.$_||f;f.$=e}})();"undefined"===typeof String.prototype.trim&&(String.prototype.trim=function(){return this.replace(/^[\s\uFEFF]+|[\s\uFEFF]+$/g,"")});
"undefined"===typeof Event.preventDefault&&"undefined"!==typeof window.event&&(Event.prototype.preventDefault=function(){window.event.returnValue=!1},Event.prototype.stopPropagation=function(){window.event.cancelBubble=!0});"undefined"===typeof Array.isArray&&(Array.isArray=function(f){return"[object Array]"===Object.prototype.toString.apply(f)});
(function(){if("undefined"!==typeof window.XMLHttpRequest){var f={_do:function(e,d,c,a,b){var l=new XMLHttpRequest;"undefined"===typeof c&&(c=function(){});b=b?"POST":"GET";e+="GET"===b?"?"+this._serialize(d):"";l.open(b,e);l.onreadystatechange=function(){4===l.readyState&&(200===l.status?c.call(l.responseText,l.responseText):"undefined"!==typeof a&&a.call(l.status,l.status))};"POST"===b?(l.setRequestHeader("Content-Type","application/x-www-form-urlencoded"),l.send(this._serialize(d))):l.send(null)},
_serialize:function(e){var d,c,a=[];for(d in e)e.hasOwnProperty(d)&&"function"!==typeof e[d]&&(c=e[d].toString(),d=encodeURIComponent(d),c=encodeURIComponent(c),a.push(d+"="+c));return a.join("&")}};$_.ext("get",function(e,d,c,a){f._do(e,d,c,a,!1)});$_.ext("post",function(e,d,c,a){f._do(e,d,c,a,!0)});$_.ext("sse",function(e,d){var c;"undefined"!==typeof EventSource&&(c=new EventSource(e),c.onmessage=function(a){d.call(a.data,a.data)})})}})();
(function(){var f,e,d,c;"undefined"!==typeof document.addEventListener?(f=function(a,b,c){"undefined"!==typeof a.addEventListener&&a.addEventListener(b,c,!1)},e=function(a,b,c){"undefined"!==typeof a.removeEventListener&&a.removeEventListener(b,c,!1)}):"undefined"!==typeof document.attachEvent&&(f=function(a,b,c){function d(a){c.apply(a)}"undefined"!==typeof a.attachEvent&&(e(b,c),a.attachEvent("on"+b,d),a=a.KIS_0_6_0=a.KIS_0_6_0||{},a.listeners=a.listeners||{},a.listeners[b]=a.listeners[b]||[],a.listeners[b].push({callback:c,
_listener:d}))},e=function(a,b,c){if("undefined"!==typeof a.detachEvent){var d=a.KIS_0_6_0;if(d&&d.listeners&&d.listeners[b])for(var e=d.listeners[b],f=e.length,g=0;g<f;g++)if(e[g].callback===c){a.detachEvent("on"+b,e[g]._listener);e.splice(g,1);0===e.length&&delete d.listeners[b];break}}});d=function(a,b,c,i){var j,o;if(typeof a==="undefined")return null;if(b.match(/^([\w\-]+)$/))i===true?f(a,b,c):e(a,b,c);else{b=b.split(" ");o=b.length;for(j=0;j<o;j++)d(a,b[j],c,i)}};c=function(a,b,c,e){d(a,c,function(c){var d,
g,f,c=c||window.event;g=$_.$(b,a);for(d in g){f=c.target||c.srcElement;if(f==g[d]){e.call(g[d],c);c.stopPropagation()}}},true)};$_.ext("event",{add:function(a,b){$_.each(function(c){d(c,a,b,true)})},remove:function(a,b){$_.each(function(c){d(c,a,b,false)})},live:function(a,b,d){c(document.documentElement,a,b,d)},delegate:function(a,b,d){$_.each(function(e){c(e,a,b,d)})}})})();
"undefined"!==typeof document&&!("classList"in document.createElement("a"))&&function(f){var f=(f.HTMLElement||f.Element).prototype,e=Object,d=String.prototype.trim||function(){return this.replace(/^\s+|\s+$/g,"")},c=Array.prototype.indexOf||function(a){for(var b=0,c=this.length;b<c;b++)if(b in this&&this[b]===a)return b;return-1},a=function(a,b){this.name=a;this.code=DOMException[a];this.message=b},b=function(b,d){if(""===d)throw new a("SYNTAX_ERR","An invalid or illegal string was specified");if(/\s/.test(d))throw new a("INVALID_CHARACTER_ERR",
"String contains an invalid character");return c.call(b,d)},l=function(a){for(var b=d.call(a.className),b=b?b.split(/\s+/):[],c=0,e=b.length;c<e;c++)this.push(b[c]);this._updateClassName=function(){a.className=this.toString()}},i=l.prototype=[],j=function(){return new l(this)};a.prototype=Error.prototype;i.item=function(a){return this[a]||null};i.contains=function(a){return-1!==b(this,a+"")};i.add=function(a){a+="";-1===b(this,a)&&(this.push(a),this._updateClassName())};i.remove=function(a){a=b(this,
a+"");-1!==a&&(this.splice(a,1),this._updateClassName())};i.toggle=function(a){a+="";-1===b(this,a)?this.add(a):this.remove(a)};i.toString=function(){return this.join(" ")};if(e.defineProperty){i={get:j,enumerable:!0,configurable:!0};try{e.defineProperty(f,"classList",i)}catch(o){-2146823252===o.number&&(i.enumerable=!1,e.defineProperty(f,"classList",i))}}else e.prototype.__defineGetter__&&f.__defineGetter__("classList",j)}(self);
(function(){function f(d,c,a){var b,e;"undefined"!==typeof d.hasAttribute?(d.hasAttribute(c)&&(b=d.getAttribute(c)),e=!0):"undefined"!==typeof d[c]?(b=d[c],e=!1):"class"===c&&"undefined"!==typeof d.className&&(c="className",b=d.className,e=!1);if("undefined"===typeof b&&("undefined"===typeof a||null===a))return null;if("undefined"===typeof a)return b;"undefined"!==typeof a&&null!==a?!0===e?d.setAttribute(c,a):d[c]=a:null===a&&(!0===e?d.removeAttribute(c):delete d[c]);return"undefined"!==typeof a?
a:b}function e(d,c,a){var b,c=c.replace(/(\-[a-z])/g,function(a){return a.toUpperCase().replace("-","")});b={outerHeight:"offsetHeight",outerWidth:"offsetWidth",top:"posTop"};if("undefined"===typeof a&&"undefined"!==d.style[c])return d.style[c];if("undefined"===typeof a&&"undefined"!==d.style[b[c]])return d.style[b[c]];if("undefined"!==typeof d.style[c])return d.style[c]=a,null;if(d.style[b[c]])return d.style[b[c]]=a,null}$_.ext("dom",{addClass:function(d){$_.each(function(c){c.classList.add(d)})},
removeClass:function(d){$_.each(function(c){c.classList.remove(d)})},hide:function(){this.css("display","none")},show:function(d){"undefined"===typeof d&&(d="block");this.css("display",d)},attr:function(d,c){var a=this.el;if(1<a.length&&"undefined"===typeof c)return null;if(1<a.length&&"undefined"!==typeof c)$_.each(function(a){return f(a,d,c)});else return f(a,d,c)},text:function(d){var c,a,b;b=this.el;a="undefined"!==typeof b.textContent?"textContent":"undefined"!==typeof b.innerText?"innerText":
"innerHTML";c=b[a];return"undefined"!==typeof d?b[a]=d:c},css:function(d,c){if("undefined"===typeof c)return e(this.el,d);$_.each(function(a){e(a,d,c)})},append:function(d){"undefined"!==typeof document.insertAdjacentHTML?this.el.insertAdjacentHTML("beforeend",d):this.el.innerHTML+=d},prepend:function(d){"undefined"!==typeof document.insertAdjacentHTML?this.el.insertAdjacentHTML("afterbegin",d):this.el.innerHTML=d+this.el.innerHTML},html:function(d){"undefined"!==typeof d&&(this.el.innerHTML=d);return this.el.innerHTML}})})();
var TINY={};function T$(f){return document.getElementById(f)}function T$$$(){return document.all?1:0}
TINY.editor=function(){function f(c,a){this.n=c;window[c]=this;this.t=T$(a.id);this.obj=a;this.xhtml=a.xhtml;var b=document.createElement("div"),f=document.createElement("div"),i=document.createElement("div"),j=a.controls.length,o=0;this.i=document.createElement("iframe");this.i.frameBorder=0;this.i.width=a.width||"500";this.i.height=a.height||"250";this.ie=T$$$();i.className=a.rowclass||"teheader";b.className=a.cssclass||"te";b.style.width=this.i.width+"px";b.appendChild(i);for(o;o<j;o++){var g=
a.controls[o];if("n"==g)i=document.createElement("div"),i.className=a.rowclass||"teheader",b.appendChild(i);else if("|"==g){var h=document.createElement("div");h.className=a.dividerclass||"tedivider";i.appendChild(h)}else if("font"==g){var g=document.createElement("select"),k=a.fonts||["Verdana","Arial","Georgia"],m=k.length,h=0;g.className="tefont";g.onchange=new Function(this.n+'.ddaction(this,"fontname")');g.options[0]=new Option("Font","");for(h;h<m;h++){var n=k[h];g.options[h+1]=new Option(n,
n)}i.appendChild(g)}else if("size"==g){g=document.createElement("select");m=a.sizes||[1,2,3,4,5,6,7];k=m.length;h=0;g.className="tesize";g.onchange=new Function(this.n+'.ddaction(this,"fontsize")');for(h;h<k;h++)n=m[h],g.options[h]=new Option(n,n);i.appendChild(g)}else if("style"==g){g=document.createElement("select");m=a.styles||[["Style",""],["Paragraph","<p>"],["Header 1","<h1>"],["Header 2","<h2>"],["Header 3","<h3>"],["Header 4","<h4>"],["Header 5","<h5>"],["Header 6","<h6>"]];k=m.length;h=0;
g.className="testyle";g.onchange=new Function(this.n+'.ddaction(this,"formatblock")');for(h;h<k;h++)n=m[h],g.options[h]=new Option(n[0],n[1]);i.appendChild(g)}else e[g]&&(k=document.createElement("div"),h=e[g],n=h[2],m=h[0]*d,k.className=a.controlclass,k.style.backgroundPosition="0px "+m+"px",k.title=h[1],h="a"==n?'.action("'+h[3]+'",0,'+(h[4]||0)+")":'.insert("'+h[4]+'","'+h[5]+'","'+h[3]+'")',k.onclick=new Function(this.n+("print"==g?".print()":h)),k.onmouseover=new Function(this.n+".hover(this,"+
m+",1)"),k.onmouseout=new Function(this.n+".hover(this,"+m+",0)"),i.appendChild(k),this.ie&&(k.unselectable="on"))}this.t.parentNode.insertBefore(b,this.t);this.t.style.width=this.i.width+"px";f.appendChild(this.t);f.appendChild(this.i);b.appendChild(f);this.t.style.display="none";a.footer&&(f=document.createElement("div"),f.className=a.footerclass||"tefooter",a.toggle&&(i=a.toggle,j=document.createElement("div"),j.className=i.cssclass||"toggle",j.innerHTML=a.toggletext||"source",j.onclick=new Function(this.n+
".toggle(0,this);return false"),f.appendChild(j)),a.resize&&(i=a.resize,j=document.createElement("div"),j.className=i.cssclass||"resize",j.onmousedown=new Function("event",this.n+".resize(event);return false"),j.onselectstart=function(){return false},f.appendChild(j)),b.appendChild(f));this.e=this.i.contentWindow.document;this.e.open();b="<html><head>";f=a.bodyid?' id="'+a.bodyid+'"':"";a.cssfile&&(b+='<link rel="stylesheet" href="'+a.cssfile+'" />');a.css&&(b+='<style type="text/css">'+a.css+"</style>");
b+="</head><body"+f+">"+(a.content||this.t.value);this.e.write(b+"</body></html>");this.e.close();this.e.designMode="on";this.d=1;if(this.xhtml)try{this.e.execCommand("styleWithCSS",0,0)}catch(p){try{this.e.execCommand("useCSS",0,1)}catch(q){}}}var e=[],d=-30;e.cut=[1,"Cut","a","cut",1];e.copy=[2,"Copy","a","copy",1];e.paste=[3,"Paste","a","paste",1];e.bold=[4,"Bold","a","bold"];e.italic=[5,"Italic","a","italic"];e.underline=[6,"Underline","a","underline"];e.strikethrough=[7,"Strikethrough","a","strikethrough"];
e.subscript=[8,"Subscript","a","subscript"];e.superscript=[9,"Superscript","a","superscript"];e.orderedlist=[10,"Insert Ordered List","a","insertorderedlist"];e.unorderedlist=[11,"Insert Unordered List","a","insertunorderedlist"];e.outdent=[12,"Outdent","a","outdent"];e.indent=[13,"Indent","a","indent"];e.leftalign=[14,"Left Align","a","justifyleft"];e.centeralign=[15,"Center Align","a","justifycenter"];e.rightalign=[16,"Right Align","a","justifyright"];e.blockjustify=[17,"Block Justify","a","justifyfull"];
e.undo=[18,"Undo","a","undo"];e.redo=[19,"Redo","a","redo"];e.image=[20,"Insert Image","i","insertimage","Enter Image URL:","http://"];e.hr=[21,"Insert Horizontal Rule","a","inserthorizontalrule"];e.link=[22,"Insert Hyperlink","i","createlink","Enter URL:","http://"];e.unlink=[23,"Remove Hyperlink","a","unlink"];e.unformat=[24,"Remove Formatting","a","removeformat"];e.print=[25,"Print","a","print"];f.prototype.print=function(){this.i.contentWindow.print()};f.prototype.hover=function(c,a,b){c.style.backgroundPosition=
(b?"34px ":"0px ")+a+"px"};f.prototype.ddaction=function(c,a){this.action(a,c.options[c.selectedIndex].value)};f.prototype.action=function(c,a,b){b&&!this.ie?alert("Your browser does not support this function."):this.e.execCommand(c,0,a||null)};f.prototype.insert=function(c,a,b){c=prompt(c,a);null!=c&&""!=c&&this.e.execCommand(b,0,c)};f.prototype.setfont=function(){execCommand("formatblock",0,hType)};f.prototype.resize=function(c){this.mv&&this.freeze();this.i.bcs=TINY.cursor.top(c);this.mv=new Function("event",
this.n+".move(event)");this.sr=new Function(this.n+".freeze()");this.ie?(document.attachEvent("onmousemove",this.mv),document.attachEvent("onmouseup",this.sr)):(document.addEventListener("mousemove",this.mv,1),document.addEventListener("mouseup",this.sr,1))};f.prototype.move=function(c){c=TINY.cursor.top(c);this.i.height=parseInt(this.i.height)+c-this.i.bcs;this.i.bcs=c};f.prototype.freeze=function(){this.ie?(document.detachEvent("onmousemove",this.mv),document.detachEvent("onmouseup",this.sr)):(document.removeEventListener("mousemove",
this.mv,1),document.removeEventListener("mouseup",this.sr,1))};f.prototype.toggle=function(c,a){if(this.d){if(b=this.e.body.innerHTML,this.xhtml&&(b=b.replace(/<span class="apple-style-span">(.*)<\/span>/gi,"$1"),b=b.replace(/ class="apple-style-span"/gi,""),b=b.replace(/<span style="">/gi,""),b=b.replace(/<br>/gi,"<br />"),b=b.replace(/<br ?\/?>$/gi,""),b=b.replace(/^<br ?\/?>/gi,""),b=b.replace(/(<img [^>]+[^\/])>/gi,"$1 />"),b=b.replace(/<b\b[^>]*>(.*?)<\/b[^>]*>/gi,"<strong>$1</strong>"),b=b.replace(/<i\b[^>]*>(.*?)<\/i[^>]*>/gi,
"<em>$1</em>"),b=b.replace(/<u\b[^>]*>(.*?)<\/u[^>]*>/gi,'<span style="text-decoration:underline">$1</span>'),b=b.replace(/<(b|strong|em|i|u) style="font-weight: normal;?">(.*)<\/(b|strong|em|i|u)>/gi,"$2"),b=b.replace(/<(b|strong|em|i|u) style="(.*)">(.*)<\/(b|strong|em|i|u)>/gi,'<span style="$2"><$4>$3</$4></span>'),b=b.replace(/<span style="font-weight: normal;?">(.*)<\/span>/gi,"$1"),b=b.replace(/<span style="font-weight: bold;?">(.*)<\/span>/gi,"<strong>$1</strong>"),b=b.replace(/<span style="font-style: italic;?">(.*)<\/span>/gi,
"<em>$1</em>"),b=b.replace(/<span style="font-weight: bold;?">(.*)<\/span>|<b\b[^>]*>(.*?)<\/b[^>]*>/gi,"<strong>$1</strong>")),a&&(a.innerHTML=this.obj.toggletext||"wysiwyg"),this.t.value=b,!c)this.t.style.height=this.i.height+"px",this.i.style.display="none",this.t.style.display="block",this.d=0}else{var b=this.t.value;a&&(a.innerHTML=this.obj.toggletext||"source");this.xhtml&&!this.ie&&(b=b.replace(/<strong>(.*)<\/strong>/gi,'<span style="font-weight: bold;">$1</span>'),b=b.replace(/<em>(.*)<\/em>/gi,
'<span style="font-weight: italic;">$1</span>'));this.e.body.innerHTML=b;this.t.style.display="none";this.i.style.display="block";this.d=1}};f.prototype.post=function(){this.d&&this.toggle(1)};return{edit:f}}();TINY.cursor=function(){return{top:function(f){return T$$$()?window.event.clientY+document.documentElement.scrollTop+document.body.scrollTop:f.clientY+window.scrollY}}}();
(function(){$_("fieldset dl").dom.hide();$_("fieldset legend").event.add("click",function(){var f=$_("fieldset dl").dom;"none"==f.css("display").trim()?f.show():f.hide()});$_("button.delete").event.add("click",function(){var f=this.parentNode.id,f=f.split("_");confirm("Are you sure you want to delete this "+f[0]+"? Deleting this item will delete all items under it. There is no undo.")});new TINY.editor.edit("editor",{id:"input",width:450,height:175,cssclass:"te",controlclass:"tecontrol",rowclass:"teheader",
dividerclass:"tedivider",controls:"bold italic underline | subscript superscript | orderedlist unorderedlist | leftalign centeralign rightalign | unformat | undo redo n image hr link unlink | cut copy paste print".split(" "),footer:!0,xhtml:!0,cssfile:"//github.timshomepage.net/meta/assets/css.php/g/css",bodyid:"editor",footerclass:"tefooter",toggle:{text:"source",activetext:"wysiwyg",cssclass:"toggle"},resize:{cssclass:"resize"}})})();
(function(){if("undefined"!==typeof document.querySelector){var g,e,d,f;g=function(a){f="undefined"===typeof a?"undefined"!==typeof g.el?g.el:document.documentElement:"object"!==typeof a?e(a):a;g.prototype.el=f;var a=d(g),c;for(c in a)"object"===typeof a[c]&&(a[c].el=f);a.el=f;return a};e=function(a,c){var b;if("string"!=typeof a||"undefined"===typeof a)return a;b=null!=c&&1===c.nodeType?c:document;if(a.match(/^#([\w\-]+$)/))return document.getElementById(a.split("#")[1]);b=b.querySelectorAll(a);
return 1===b.length?b[0]:b};d=function(a){var c;if("undefined"!==typeof a){if("undefined"!==typeof Object.create)return Object.create(a);c=typeof a;if(!("object"!==c&&"function"!==c))return c=function(){},c.prototype=a,new c}};g.ext=function(a,c){c.el=f;g[a]=c};g.ext("each",function(a){if("undefined"!==typeof f.length&&f!==window)if("undefined"!==typeof Array.prototype.forEach)[].forEach.call(f,a);else{var c=f.length;if(0!==c)for(var b,d=0;d<c;d++)b=f.item(d)?f.item(d):f[d],a.call(b,b)}else a.call(f,
f)});g.type=function(a){return function(){return a&&a!==this}.call(a)?(typeof a).toLowerCase():{}.toString.call(a).match(/\s([a-z|A-Z]+)/)[1].toLowerCase()};g=window.$_=window.$_||g;g.$=e}})();"undefined"===typeof String.prototype.trim&&(String.prototype.trim=function(){return this.replace(/^[\s\uFEFF]+|[\s\uFEFF]+$/g,"")});
"undefined"===typeof Event.preventDefault&&"undefined"!==typeof window.event&&(Event.prototype.preventDefault=function(){window.event.returnValue=false},Event.prototype.stopPropagation=function(){window.event.cancelBubble=true});"undefined"===typeof Array.isArray&&(Array.isArray=function(g){return Object.prototype.toString.apply(g)==="[object Array]"});
(function(){if(typeof window.XMLHttpRequest!=="undefined"){var g={_do:function(e,d,f,a,c){var b=new XMLHttpRequest;typeof f==="undefined"&&(f=function(){});c=c?"POST":"GET";e=e+(c==="GET"?"?"+this._serialize(d):"");b.open(c,e);b.onreadystatechange=function(){b.readyState===4&&(b.status===200?f.call(b.responseText,b.responseText):typeof a!=="undefined"&&a.call(b.status,b.status))};if(c==="POST"){b.setRequestHeader("Content-Type","application/x-www-form-urlencoded");b.send(this._serialize(d))}else b.send(null)},
_serialize:function(e){var d,f,a=[];for(d in e)if(e.hasOwnProperty(d)&&typeof e[d]!=="function"){f=e[d].toString();d=encodeURIComponent(d);f=encodeURIComponent(f);a.push(d+"="+f)}return a.join("&")}};$_.ext("get",function(e,d,f,a){g._do(e,d,f,a,false)});$_.ext("post",function(e,d,f,a){g._do(e,d,f,a,true)});$_.ext("sse",function(e,d){var f;if(typeof EventSource!=="undefined"){f=new EventSource(e);f.onmessage=function(a){d.call(a.data,a.data)}}})}})();
(function(){var g,e,d,f;if(typeof document.addEventListener!=="undefined"){g=function(a,c,b){typeof a.addEventListener!=="undefined"&&a.addEventListener(c,b,false)};e=function(a,c,b){typeof a.removeEventListener!=="undefined"&&a.removeEventListener(c,b,false)}}else if(typeof document.attachEvent!=="undefined"){g=function(a,c,b){function d(a){b.apply(a)}if(typeof a.attachEvent!=="undefined"){e(c,b);a.attachEvent("on"+c,d);a=a.KIS_0_6_0=a.KIS_0_6_0||{};a.listeners=a.listeners||{};a.listeners[c]=a.listeners[c]||
[];a.listeners[c].push({callback:b,_listener:d})}};e=function(a,c,b){if(typeof a.detachEvent!=="undefined"){var d=a.KIS_0_6_0;if(d&&d.listeners&&d.listeners[c])for(var f=d.listeners[c],e=f.length,g=0;g<e;g++)if(f[g].callback===b){a.detachEvent("on"+c,f[g]._listener);f.splice(g,1);f.length===0&&delete d.listeners[c];break}}}}d=function(a,c,b,f){var n,h;if(typeof a==="undefined")return null;if(c.match(/^([\w\-]+)$/))f===true?g(a,c,b):e(a,c,b);else{c=c.split(" ");h=c.length;for(n=0;n<h;n++)d(a,c[n],
b,f)}};f=function(a,c,b,f){d(a,b,function(b){var d,e,g,b=b||window.event;e=$_.$(c,a);for(d in e){g=b.target||b.srcElement;if(g==e[d]){f.call(e[d],b);b.stopPropagation()}}},true)};$_.ext("event",{add:function(a,c){$_.each(function(b){d(b,a,c,true)})},remove:function(a,c){$_.each(function(b){d(b,a,c,false)})},live:function(a,c,b){f(document.documentElement,a,c,b)},delegate:function(a,c,b){$_.each(function(d){f(d,a,c,b)})}})})();
"undefined"!==typeof document&&!("classList"in document.createElement("a"))&&function(g){var g=(g.HTMLElement||g.Element).prototype,e=Object,d=String.prototype.trim||function(){return this.replace(/^\s+|\s+$/g,"")},f=Array.prototype.indexOf||function(a){for(var b=0,c=this.length;b<c;b++)if(b in this&&this[b]===a)return b;return-1},a=function(a,b){this.name=a;this.code=DOMException[a];this.message=b},c=function(b,c){if(c==="")throw new a("SYNTAX_ERR","An invalid or illegal string was specified");if(/\s/.test(c))throw new a("INVALID_CHARACTER_ERR",
"String contains an invalid character");return f.call(b,c)},b=function(a){for(var b=d.call(a.className),b=b?b.split(/\s+/):[],c=0,f=b.length;c<f;c++)this.push(b[c]);this._updateClassName=function(){a.className=this.toString()}},k=b.prototype=[],n=function(){return new b(this)};a.prototype=Error.prototype;k.item=function(a){return this[a]||null};k.contains=function(a){return c(this,a+"")!==-1};k.add=function(a){a=a+"";if(c(this,a)===-1){this.push(a);this._updateClassName()}};k.remove=function(a){a=
c(this,a+"");if(a!==-1){this.splice(a,1);this._updateClassName()}};k.toggle=function(a){a=a+"";c(this,a)===-1?this.add(a):this.remove(a)};k.toString=function(){return this.join(" ")};if(e.defineProperty){k={get:n,enumerable:true,configurable:true};try{e.defineProperty(g,"classList",k)}catch(h){if(h.number===-2146823252){k.enumerable=false;e.defineProperty(g,"classList",k)}}}else e.prototype.__defineGetter__&&g.__defineGetter__("classList",n)}(self);
(function(){function g(d,f,a){var c,b;if(typeof d.hasAttribute!=="undefined"){d.hasAttribute(f)&&(c=d.getAttribute(f));b=true}else if(typeof d[f]!=="undefined"){c=d[f];b=false}else if(f==="class"&&typeof d.className!=="undefined"){f="className";c=d.className;b=false}if(typeof c==="undefined"&&(typeof a==="undefined"||a===null))return null;if(typeof a==="undefined")return c;typeof a!=="undefined"&&a!==null?b===true?d.setAttribute(f,a):d[f]=a:a===null&&(b===true?d.removeAttribute(f):delete d[f]);return typeof a!==
"undefined"?a:c}function e(d,f,a){var c,f=f.replace(/(\-[a-z])/g,function(a){return a.toUpperCase().replace("-","")});c={outerHeight:"offsetHeight",outerWidth:"offsetWidth",top:"posTop"};if(typeof a==="undefined"&&d.style[f]!=="undefined")return d.style[f];if(typeof a==="undefined"&&d.style[c[f]]!=="undefined")return d.style[c[f]];if(typeof d.style[f]!=="undefined"){d.style[f]=a;return null}if(d.style[c[f]]){d.style[c[f]]=a;return null}}$_.ext("dom",{addClass:function(d){$_.each(function(f){f.classList.add(d)})},
removeClass:function(d){$_.each(function(f){f.classList.remove(d)})},hide:function(){this.css("display","none")},show:function(d){typeof d==="undefined"&&(d="block");this.css("display",d)},attr:function(d,f){var a=this.el;if(a.length>1&&typeof f==="undefined")return null;if(a.length>1&&typeof f!=="undefined")$_.each(function(a){return g(a,d,f)});else return g(a,d,f)},text:function(d){var f,a,c;c=this.el;a=typeof c.textContent!=="undefined"?"textContent":typeof c.innerText!=="undefined"?"innerText":
"innerHTML";f=c[a];if(typeof d!=="undefined")return c[a]=d;return f},css:function(d,f){if(typeof f==="undefined")return e(this.el,d);$_.each(function(a){e(a,d,f)})},append:function(d){typeof document.insertAdjacentHTML!=="undefined"?this.el.insertAdjacentHTML("beforeend",d):this.el.innerHTML=this.el.innerHTML+d},prepend:function(d){typeof document.insertAdjacentHTML!=="undefined"?this.el.insertAdjacentHTML("afterbegin",d):this.el.innerHTML=d+this.el.innerHTML},html:function(d){if(typeof d!=="undefined")this.el.innerHTML=
d;return this.el.innerHTML}})})();
(function(){var g={};window.TINY=g;var e=function(a,c){var b,e,g;this.n=a;window[a]=this;this.t=document.getElementById(c.id);this.obj=c;this.xhtml=c.xhtml;var h=document.createElement("div"),l=document.createElement("div"),i=document.createElement("div"),j=c.controls.length,o=0;this.i=document.createElement("iframe");this.i.frameBorder=0;this.i.width=c.width||"500";this.i.height=c.height||"250";this.ie=document.all&&document.attachEvent?1:0;i.className=c.rowclass||"teheader";h.className=c.cssclass||
"te";h.style.width=this.i.width+"px";h.appendChild(i);for(o;o<j;o++){b=c.controls[o];if(b=="n"){i=document.createElement("div");i.className=c.rowclass||"teheader";h.appendChild(i)}else if(b=="|"){e=document.createElement("div");e.className=c.dividerclass||"tedivider";i.appendChild(e)}else if(b=="font"){b=document.createElement("select");fonts=c.fonts||["Verdana","Arial","Georgia"];fl=fonts.length;e=0;b.className="tefont";b.onchange=new Function(this.n+'.ddaction(this,"fontname")');b.options[0]=new Option("Font",
"");for(e;e<fl;e++){g=fonts[e];b.options[e+1]=new Option(g,g)}i.appendChild(b)}else if(b=="size"){b=document.createElement("select");sizes=c.sizes||[1,2,3,4,5,6,7];g=sizes.length;e=0;b.className="tesize";b.onchange=new Function(this.n+'.ddaction(this,"fontsize")');for(e;e<g;e++){var m=sizes[e];b.options[e]=new Option(m,m)}i.appendChild(b)}else if(b=="style"){b=document.createElement("select");styles=c.styles||[["Style",""],["Paragraph","<p>"],["Header 1","<h1>"],["Header 2","<h2>"],["Header 3","<h3>"],
["Header 4","<h4>"],["Header 5","<h5>"],["Header 6","<h6>"]];g=styles.length;e=0;b.className="testyle";b.onchange=new Function(this.n+'.ddaction(this,"formatblock")');for(e;e<g;e++){m=styles[e];b.options[e]=new Option(m[0],m[1])}i.appendChild(b)}else if(d[b]){e=d[b];g=document.createElement("div");var p=e[2],m=e[0]*f;g.className=c.controlclass;g.style.backgroundPosition="0px "+m+"px";g.title=e[1];e=p=="a"?'.action("'+e[3]+'",0,'+(e[4]||0)+")":'.insert("'+e[4]+'","'+e[5]+'","'+e[3]+'")';g.onclick=
new Function(this.n+(b=="print"?".print()":e));g.onmouseover=new Function(this.n+".hover(this,"+m+",1)");g.onmouseout=new Function(this.n+".hover(this,"+m+",0)");i.appendChild(g);if(this.ie)g.unselectable="on"}}this.t.parentNode.insertBefore(h,this.t);this.t.style.width=this.i.width+"px";l.appendChild(this.t);l.appendChild(this.i);h.appendChild(l);this.t.style.display="none";if(c.footer){l=document.createElement("div");l.className=c.footerclass||"tefooter";if(c.toggle){i=c.toggle;j=document.createElement("div");
j.className=i.cssclass||"toggle";j.innerHTML=c.toggletext||"source";j.onclick=new Function(this.n+".toggle(0,this);return false");l.appendChild(j)}if(c.resize){i=c.resize;j=document.createElement("div");j.className=i.cssclass||"resize";j.onmousedown=new Function("event",this.n+".resize(event);return false");j.onselectstart=function(){return false};l.appendChild(j)}h.appendChild(l)}this.e=this.i.contentWindow.document;this.e.open();h="<html><head>";l=c.bodyid?' id="'+c.bodyid+'"':"";c.cssfile&&(h=
h+('<link rel="stylesheet" href="'+c.cssfile+'" />'));c.css&&(h=h+('<style type="text/css">'+c.css+"</style>"));h=h+("</head><body"+l+">"+(c.content||this.t.value));this.e.write(h+"</body></html>");this.e.close();this.e.designMode="on";this.d=1;if(this.xhtml)try{this.e.execCommand("styleWithCSS",0,0)}catch(q){try{this.e.execCommand("useCSS",0,1)}catch(r){}}},d={},f=-30;d.cut=[1,"Cut","a","cut",1];d.copy=[2,"Copy","a","copy",1];d.paste=[3,"Paste","a","paste",1];d.bold=[4,"Bold","a","bold"];d.italic=
[5,"Italic","a","italic"];d.underline=[6,"Underline","a","underline"];d.strikethrough=[7,"Strikethrough","a","strikethrough"];d.subscript=[8,"Subscript","a","subscript"];d.superscript=[9,"Superscript","a","superscript"];d.orderedlist=[10,"Insert Ordered List","a","insertorderedlist"];d.unorderedlist=[11,"Insert Unordered List","a","insertunorderedlist"];d.outdent=[12,"Outdent","a","outdent"];d.indent=[13,"Indent","a","indent"];d.leftalign=[14,"Left Align","a","justifyleft"];d.centeralign=[15,"Center Align",
"a","justifycenter"];d.rightalign=[16,"Right Align","a","justifyright"];d.blockjustify=[17,"Block Justify","a","justifyfull"];d.undo=[18,"Undo","a","undo"];d.redo=[19,"Redo","a","redo"];d.image=[20,"Insert Image","i","insertimage","Enter Image URL:","http://"];d.hr=[21,"Insert Horizontal Rule","a","inserthorizontalrule"];d.link=[22,"Insert Hyperlink","i","createlink","Enter URL:","http://"];d.unlink=[23,"Remove Hyperlink","a","unlink"];d.unformat=[24,"Remove Formatting","a","removeformat"];d.print=
[25,"Print","a","print"];e.prototype.print=function(){this.i.contentWindow.print()};e.prototype.hover=function(a,c,b){a.style.backgroundPosition=(b?"34px ":"0px ")+c+"px"};e.prototype.ddaction=function(a,c){this.action(c,a.options[a.selectedIndex].value)};e.prototype.action=function(a,c,b){b&&!this.ie?alert("Your browser does not support this function."):this.e.execCommand(a,0,c||null)};e.prototype.insert=function(a,c,b){a=prompt(a,c);a!=null&&a!=""&&this.e.execCommand(b,0,a)};e.prototype.setfont=
function(){execCommand("formatblock",0,hType)};e.prototype.resize=function(a){this.mv&&this.freeze();this.i.bcs=g.cursor.top(a);this.mv=new Function("event",this.n+".move(event)");this.sr=new Function(this.n+".freeze()");if(this.ie){document.attachEvent("onmousemove",this.mv);document.attachEvent("onmouseup",this.sr)}else{document.addEventListener("mousemove",this.mv,1);document.addEventListener("mouseup",this.sr,1)}};e.prototype.move=function(a){a=g.cursor.top(a);this.i.height=parseInt(this.i.height,
10)+a-this.i.bcs;this.i.bcs=a};e.prototype.freeze=function(){if(this.ie){document.detachEvent("onmousemove",this.mv);document.detachEvent("onmouseup",this.sr)}else{document.removeEventListener("mousemove",this.mv,1);document.removeEventListener("mouseup",this.sr,1)}};e.prototype.toggle=function(a,c){var b;if(this.d){b=this.e.body.innerHTML;if(this.xhtml){b=b.replace(/<span class="apple-style-span">(.*)<\/span>/gi,"$1");b=b.replace(/ class="apple-style-span"/gi,"");b=b.replace(/<span style="">/gi,
"");b=b.replace(/<br>/gi,"<br />");b=b.replace(/<br ?\/?>$/gi,"");b=b.replace(/^<br ?\/?>/gi,"");b=b.replace(/(<img [^>]+[^\/])>/gi,"$1 />");b=b.replace(/<b\b[^>]*>(.*?)<\/b[^>]*>/gi,"<strong>$1</strong>");b=b.replace(/<i\b[^>]*>(.*?)<\/i[^>]*>/gi,"<em>$1</em>");b=b.replace(/<u\b[^>]*>(.*?)<\/u[^>]*>/gi,'<span style="text-decoration:underline">$1</span>');b=b.replace(/<(b|strong|em|i|u) style="font-weight: normal;?">(.*)<\/(b|strong|em|i|u)>/gi,"$2");b=b.replace(/<(b|strong|em|i|u) style="(.*)">(.*)<\/(b|strong|em|i|u)>/gi,
'<span style="$2"><$4>$3</$4></span>');b=b.replace(/<span style="font-weight: normal;?">(.*)<\/span>/gi,"$1");b=b.replace(/<span style="font-weight: bold;?">(.*)<\/span>/gi,"<strong>$1</strong>");b=b.replace(/<span style="font-style: italic;?">(.*)<\/span>/gi,"<em>$1</em>");b=b.replace(/<span style="font-weight: bold;?">(.*)<\/span>|<b\b[^>]*>(.*?)<\/b[^>]*>/gi,"<strong>$1</strong>")}if(c)c.innerHTML=this.obj.toggletext||"wysiwyg";this.t.value=b;if(!a){this.t.style.height=this.i.height+"px";this.i.style.display=
"none";this.t.style.display="block";this.d=0}}else{b=this.t.value;if(c)c.innerHTML=this.obj.toggletext||"source";if(this.xhtml&&!this.ie){b=b.replace(/<strong>(.*)<\/strong>/gi,'<span style="font-weight: bold;">$1</span>');b=b.replace(/<em>(.*)<\/em>/gi,'<span style="font-weight: italic;">$1</span>')}this.e.body.innerHTML=b;this.t.style.display="none";this.i.style.display="block";this.d=1}};e.prototype.post=function(){this.d&&this.toggle(1)};g.editor={edit:e};g.cursor={top:function(a){return document.all&&
document.attachEvent?window.event.clientY+document.documentElement.scrollTop+document.body.scrollTop:a.clientY+window.scrollY}};g.init=function(a){return new g.editor.edit("editor",a)}})();
$_.ext("center",function(g){g=this.el;if(typeof g!=="undefined"){var e,d,f,a,c;e=typeof g.outerHeight!=="undefined"?g.outerHeight:g.offsetHeight;d=typeof g.outerWidth!=="undefined"?g.outerWidth:g.offsetWidth;f=typeof window.pageXOffset!=="undefined"?window.pageXOffset:document.documentElement.scrollLeft;a=window.innerHeight?window.innerHeight:document.documentElement.offsetHeight;c=window.innerWidth?window.innerWidth:document.documentElement.offsetWidth;g.style.position="fixed";e=(a-e)/2;g.style.posTop?
g.style.posTop=e+"px":g.style.top=e+"px";g.style.left=(c-d)/2+f+"px"}});
(function(){var g=window.TINY||{},e=window.$_||{},d=APP_URL.replace("index.php/","")+"assets/";e("fieldset dl").dom.hide();e("fieldset legend").event.add("click",function(){var a=e("fieldset dl").dom;a.css("display").trim()=="none"?a.show():a.hide()});var f={};window.meta=f;f._delete=function(a){a==1?e.get(APP_URL+"message",{type:"success",message:"Item successfully deleted"},function(a){e("body").dom.prepend(a)}):e.get(APP_URL+"message",{type:"error",message:"There was an error deleting that item"},
function(a){e("body").dom.prepend(a)})};f.delete_item=function(){var a,c;a=this.parentNode.id;a=a.split("_");c=a[1];a=a[0];if(confirm("Are you sure you want to delete this "+a+"? Deleting this item will delete all items under it. There is no undo."))switch(a){case "genre":case "category":case "section":case "data":e.post(APP_URL+"delete",{id:c,type:a},f._delete)}};f.get_edit_form=function(){var a,c;a=this.parentNode.id;a=a.split("_");c=a[1];a=a[0];e("#overlay_bg, #overlay").dom.show();e.get(APP_URL+
"edit",{id:c,type:a},function(a){e("#overlay").dom.html(a);e("#overlay").center()})};f.update_item=function(a){var c,b={};console.log(arguments);b.id=e.$("#id").value;b.type=e.$("#type").value;b.name=e.$("#name").value;if(c=document.getElementById("val"))b.val=c.value;e.post(APP_URL+"update",b,function(a){e("#overlay_bg").dom.css("display","");e("#overlay").dom.html("");e("#overlay").dom.hide();a==1?e.get(APP_URL+"message",{type:"success",message:"Item successfully updated."},function(a){e("body").dom.prepend(a)}):
e.get(APP_URL+"message",{type:"error",message:"There was an error updating that item."},function(a){e("body").dom.prepend(a)})})};e("button.delete").event.add("click",f.delete_item);e("button.edit").event.add("click",f.get_edit_form);e("#overlay_bg").event.add("click",function(){e("#overlay_bg").dom.css("display","");e("#overlay").dom.html("");e("#overlay").dom.hide()});e.event.live("#edit_form","submit",f.update_item);e.$("textarea").length>0&&g.init({id:"input",width:450,height:175,cssclass:"te",
controlclass:"tecontrol",rowclass:"teheader",dividerclass:"tedivider",controls:["bold","italic","underline","strikethrough","|","subscript","superscript","|","orderedlist","unorderedlist","|","leftalign","centeralign","rightalign","blockjustify","|","unformat","n","undo","redo","|","image","hr","link","unlink","|"],footer:true,fonts:["Verdana","Arial","Georgia","Trebuchet MS"],xhtml:true,cssfile:d+"css.php/g/css",bodyid:"editor",footerclass:"tefooter",toggle:{text:"source",activetext:"wysiwyg",cssclass:"toggle"},
resize:{cssclass:"resize"}});if(window.editor)document.querySelector("form").onsubmit=function(){window.editor.toggle()}})();

View File

@ -1,17 +0,0 @@
(function(){if("undefined"!==typeof document.querySelector){var d,e,b,c;d=function(a){c="undefined"===typeof a?"undefined"!==typeof d.el?d.el:document.documentElement:"object"!==typeof a?e(a):a;d.prototype.el=c;var a=b(d),f;for(f in a)"object"===typeof a[f]&&(a[f].el=c);a.el=c;return a};e=function(a,f){var b;if("string"!=typeof a||"undefined"===typeof a)return a;b=null!=f&&1===f.nodeType?f:document;if(a.match(/^#([\w\-]+$)/))return document.getElementById(a.split("#")[1]);b=b.querySelectorAll(a);
return 1===b.length?b[0]:b};b=function(a){var f;if("undefined"!==typeof a){if("undefined"!==typeof Object.create)return Object.create(a);f=typeof a;if(!("object"!==f&&"function"!==f))return f=function(){},f.prototype=a,new f}};d.ext=function(a,f){f.el=c;d[a]=f};d.ext("each",function(a){if("undefined"!==typeof c.length&&c!==window)if("undefined"!==typeof Array.prototype.forEach)[].forEach.call(c,a);else{var f=c.length;if(0!==f)for(var b,h=0;h<f;h++)b=c.item(h)?c.item(h):c[h],a.call(b,b)}else a.call(c,
c)});d.type=function(a){return function(){return a&&a!==this}.call(a)?(typeof a).toLowerCase():{}.toString.call(a).match(/\s([a-z|A-Z]+)/)[1].toLowerCase()};d=window.$_=window.$_||d;d.$=e}})();"undefined"===typeof String.prototype.trim&&(String.prototype.trim=function(){return this.replace(/^[\s\uFEFF]+|[\s\uFEFF]+$/g,"")});
"undefined"===typeof Event.preventDefault&&"undefined"!==typeof window.event&&(Event.prototype.preventDefault=function(){window.event.returnValue=false},Event.prototype.stopPropagation=function(){window.event.cancelBubble=true});"undefined"===typeof Array.isArray&&(Array.isArray=function(d){return Object.prototype.toString.apply(d)==="[object Array]"});
(function(){if(typeof window.XMLHttpRequest!=="undefined"){var d={_do:function(d,b,c,a,f){var g=new XMLHttpRequest;typeof c==="undefined"&&(c=function(){});f=f?"POST":"GET";d=d+(f==="GET"?"?"+this._serialize(b):"");g.open(f,d);g.onreadystatechange=function(){g.readyState===4&&(g.status===200?c.call(g.responseText,g.responseText):typeof a!=="undefined"&&a.call(g.status,g.status))};if(f==="POST"){g.setRequestHeader("Content-Type","application/x-www-form-urlencoded");g.send(this._serialize(b))}else g.send(null)},
_serialize:function(d){var b,c,a=[];for(b in d)if(d.hasOwnProperty(b)&&typeof d[b]!=="function"){c=d[b].toString();b=encodeURIComponent(b);c=encodeURIComponent(c);a.push(b+"="+c)}return a.join("&")}};$_.ext("get",function(e,b,c,a){d._do(e,b,c,a,false)});$_.ext("post",function(e,b,c,a){d._do(e,b,c,a,true)});$_.ext("sse",function(d,b){var c;if(typeof EventSource!=="undefined"){c=new EventSource(d);c.onmessage=function(a){b.call(a.data,a.data)}}})}})();
(function(){var d,e,b,c;if(typeof document.addEventListener!=="undefined"){d=function(a,b,c){typeof a.addEventListener!=="undefined"&&a.addEventListener(b,c,false)};e=function(a,b,c){typeof a.removeEventListener!=="undefined"&&a.removeEventListener(b,c,false)}}else if(typeof document.attachEvent!=="undefined"){d=function(a,b,c){function d(a){c.apply(a)}if(typeof a.attachEvent!=="undefined"){e(b,c);a.attachEvent("on"+b,d);a=a.KIS_0_6_0=a.KIS_0_6_0||{};a.listeners=a.listeners||{};a.listeners[b]=a.listeners[b]||
[];a.listeners[b].push({callback:c,_listener:d})}};e=function(a,b,c){if(typeof a.detachEvent!=="undefined"){var d=a.KIS_0_6_0;if(d&&d.listeners&&d.listeners[b])for(var e=d.listeners[b],k=e.length,i=0;i<k;i++)if(e[i].callback===c){a.detachEvent("on"+b,e[i]._listener);e.splice(i,1);e.length===0&&delete d.listeners[b];break}}}}b=function(a,c,g,h){var j,k;if(typeof a==="undefined")return null;if(c.match(/^([\w\-]+)$/))h===true?d(a,c,g):e(a,c,g);else{c=c.split(" ");k=c.length;for(j=0;j<k;j++)b(a,c[j],
g,h)}};c=function(a,c,d,e){b(a,d,function(b){var d,i,g,b=b||window.event;i=$_.$(c,a);for(d in i){g=b.target||b.srcElement;if(g==i[d]){e.call(i[d],b);b.stopPropagation()}}},true)};$_.ext("event",{add:function(a,c){$_.each(function(d){b(d,a,c,true)})},remove:function(a,c){$_.each(function(d){b(d,a,c,false)})},live:function(a,b,d){c(document.documentElement,a,b,d)},delegate:function(a,b,d){$_.each(function(e){c(e,a,b,d)})}})})();
"undefined"!==typeof document&&!("classList"in document.createElement("a"))&&function(d){var d=(d.HTMLElement||d.Element).prototype,e=Object,b=String.prototype.trim||function(){return this.replace(/^\s+|\s+$/g,"")},c=Array.prototype.indexOf||function(a){for(var b=0,c=this.length;b<c;b++)if(b in this&&this[b]===a)return b;return-1},a=function(a,b){this.name=a;this.code=DOMException[a];this.message=b},f=function(b,d){if(d==="")throw new a("SYNTAX_ERR","An invalid or illegal string was specified");if(/\s/.test(d))throw new a("INVALID_CHARACTER_ERR",
"String contains an invalid character");return c.call(b,d)},g=function(a){for(var c=b.call(a.className),c=c?c.split(/\s+/):[],d=0,f=c.length;d<f;d++)this.push(c[d]);this._updateClassName=function(){a.className=this.toString()}},h=g.prototype=[],j=function(){return new g(this)};a.prototype=Error.prototype;h.item=function(a){return this[a]||null};h.contains=function(a){return f(this,a+"")!==-1};h.add=function(a){a=a+"";if(f(this,a)===-1){this.push(a);this._updateClassName()}};h.remove=function(a){a=
f(this,a+"");if(a!==-1){this.splice(a,1);this._updateClassName()}};h.toggle=function(a){a=a+"";f(this,a)===-1?this.add(a):this.remove(a)};h.toString=function(){return this.join(" ")};if(e.defineProperty){h={get:j,enumerable:true,configurable:true};try{e.defineProperty(d,"classList",h)}catch(k){if(k.number===-2146823252){h.enumerable=false;e.defineProperty(d,"classList",h)}}}else e.prototype.__defineGetter__&&d.__defineGetter__("classList",j)}(self);
(function(){function d(b,c,a){var d,e;if(typeof b.hasAttribute!=="undefined"){b.hasAttribute(c)&&(d=b.getAttribute(c));e=true}else if(typeof b[c]!=="undefined"){d=b[c];e=false}else if(c==="class"&&typeof b.className!=="undefined"){c="className";d=b.className;e=false}if(typeof d==="undefined"&&(typeof a==="undefined"||a===null))return null;if(typeof a==="undefined")return d;typeof a!=="undefined"&&a!==null?e===true?b.setAttribute(c,a):b[c]=a:a===null&&(e===true?b.removeAttribute(c):delete b[c]);return typeof a!==
"undefined"?a:d}function e(b,c,a){var d,c=c.replace(/(\-[a-z])/g,function(a){return a.toUpperCase().replace("-","")});d={outerHeight:"offsetHeight",outerWidth:"offsetWidth",top:"posTop"};if(typeof a==="undefined"&&b.style[c]!=="undefined")return b.style[c];if(typeof a==="undefined"&&b.style[d[c]]!=="undefined")return b.style[d[c]];if(typeof b.style[c]!=="undefined"){b.style[c]=a;return null}if(b.style[d[c]]){b.style[d[c]]=a;return null}}$_.ext("dom",{addClass:function(b){$_.each(function(c){c.classList.add(b)})},
removeClass:function(b){$_.each(function(c){c.classList.remove(b)})},hide:function(){this.css("display","none")},show:function(b){typeof b==="undefined"&&(b="block");this.css("display",b)},attr:function(b,c){var a=this.el;if(a.length>1&&typeof c==="undefined")return null;if(a.length>1&&typeof c!=="undefined")$_.each(function(a){return d(a,b,c)});else return d(a,b,c)},text:function(b){var c,a,d;d=this.el;a=typeof d.textContent!=="undefined"?"textContent":typeof d.innerText!=="undefined"?"innerText":
"innerHTML";c=d[a];if(typeof b!=="undefined")return d[a]=b;return c},css:function(b,c){if(typeof c==="undefined")return e(this.el,b);$_.each(function(a){e(a,b,c)})},append:function(b){typeof document.insertAdjacentHTML!=="undefined"?this.el.insertAdjacentHTML("beforeend",b):this.el.innerHTML=this.el.innerHTML+b},prepend:function(b){typeof document.insertAdjacentHTML!=="undefined"?this.el.insertAdjacentHTML("afterbegin",b):this.el.innerHTML=b+this.el.innerHTML},html:function(b){if(typeof b!=="undefined")this.el.innerHTML=
b;return this.el.innerHTML}})})();

1211
assets/js/kis-lite-dom.js Executable file

File diff suppressed because it is too large Load Diff

View File

@ -1,7 +1,63 @@
/**
* Extends kis-js to allow centering of absolutely-positioned containers
*/
$_.ext('center', function (sel){
sel = this.el;
if (typeof sel === "undefined") return;
var contHeight,
contWidth,
xOffset,
inH,
inW,
top,
left;
contHeight = (typeof sel.outerHeight !== "undefined")
? sel.outerHeight
: sel.offsetHeight;
contWidth = (typeof sel.outerWidth !== "undefined")
? sel.outerWidth
: sel.offsetWidth;
xOffset = (typeof window.pageXOffset !== "undefined")
? window.pageXOffset
: document.documentElement.scrollLeft;
inH = (window.innerHeight)
? window.innerHeight
: document.documentElement.offsetHeight;
inW = (window.innerWidth)
? window.innerWidth
: document.documentElement.offsetWidth;
sel.style.position = "fixed";
top = (inH - contHeight) / 2;
left = (inW - contWidth) / 2 + xOffset;
if (sel.style.posTop)
{
sel.style.posTop = top + "px";
}
else
{
sel.style.top = top + "px";
}
sel.style.left = left + "px";
});
(function() {
"use strict";
var TINY = window.TINY || {};
var $_ = window.$_ || {};
var ASSET_URL = APP_URL.replace('index.php/', '') + 'assets/';
// ! Show/hide forms based on use
$_("fieldset dl").dom.hide();
$_("fieldset legend").event.add('click', function(e){
@ -13,39 +69,170 @@
});
var meta = {};
window.meta = meta;
/**
* Ajax callback for deletion of an item
*/
meta._delete = function(res){
if (res == 1)
{
$_.get(APP_URL+'message', {
type: 'success',
message: 'Item successfully deleted'
}, function(h) {
$_('body').dom.prepend(h);
});
}
else
{
$_.get(APP_URL+'message', {
type: 'error',
message: 'There was an error deleting that item'
}, function(h) {
$_('body').dom.prepend(h);
});
}
};
/**
* Deletes a genre/category/section/data item
* based on the current page context
*/
meta.delete_item = function(e) {
var item_id, id, type;
// Get the type/id of the item
var item_id = this.parentNode.id;
item_id = this.parentNode.id;
item_id = item_id.split('_');
var id = item_id[1];
var type = item_id[0];
id = item_id[1];
type = item_id[0];
// Confirm deletion
var confirm_string = "Are you sure you want to delete this "+type+"? Deleting this item will delete all items under it. There is no undo.";
var do_delete = confirm(confirm_string);
var status = false;
if (do_delete)
{
// Call the appropriate deletion method
switch(type)
{
case "genre":
case "category":
case "section":
case "data":
$_.post(APP_URL+'delete', {'id':id, 'type':type}, meta._delete);
break;
default:
break;
}
}
};
// Show status message
/**
* Gets the edit form and displays the overlay for the item
* being edited
*/
meta.get_edit_form = function(e) {
var item_id, id, type;
// Get the type/id of the item
item_id = this.parentNode.id;
item_id = item_id.split('_');
id = item_id[1];
type = item_id[0];
$_('#overlay_bg, #overlay').dom.show();
//Get the form for the current item
$_.get(APP_URL+'edit', {'id':id, 'type':type}, function(res){
$_('#overlay').dom.html(res);
// Center the form
$_('#overlay').center();
});
};
/**
* Submit the update form via javascript
*/
meta.update_item = function(e) {
var id, type, name, val, txt, data={};
console.log(arguments);
// Get the form values
data.id = $_.$('#id').value;
data.type = $_.$('#type').value;
data.name = $_.$('#name').value;
txt = document.getElementById('val');
if (txt)
{
data.val = txt.value;
}
// Submit the form
$_.post(APP_URL+'update', data, function(res) {
// Hide the overlay and form
$_('#overlay_bg').dom.css('display', '');
$_('#overlay').dom.html('');
$_('#overlay').dom.hide();
// Show the appropriate status message
if (res == 1)
{
$_.get(APP_URL+'message', {
type: 'success',
message: 'Item successfully updated.'
}, function(h) {
$_('body').dom.prepend(h);
});
}
else
{
$_.get(APP_URL+'message', {
type: 'error',
message: 'There was an error updating that item.'
}, function(h) {
$_('body').dom.prepend(h);
});
}
});
};
// -------------------------------------------------
// ! Event binding
// -------------------------------------------------
// Delete Button functionality
$_("button.delete").event.add('click', meta.delete_item);
// Edit Button functionality
$_("button.edit").event.add('click', meta.get_edit_form);
// Overlay close
$_("#overlay_bg").event.add('click', function(e) {
$_('#overlay_bg').dom.css('display', '');
$_('#overlay').dom.html('');
$_('#overlay').dom.hide();
});
// Edit form submission
$_.event.live('#edit_form', 'submit', meta.update_item);
// WYSIWYG
new TINY.editor.edit('editor',{
if ($_.$('textarea').length > 0)
{
TINY.init({
id:'input',
width:450,
height:175,
@ -53,18 +240,28 @@
controlclass:'tecontrol',
rowclass:'teheader',
dividerclass:'tedivider',
controls:['bold','italic','underline','|','subscript','superscript','|',
controls:['bold','italic','underline','strikethrough','|','subscript','superscript','|',
'orderedlist','unorderedlist','|','leftalign',
'centeralign','rightalign','|','unformat','|','undo','redo','n',
'image','hr','link','unlink','|','cut','copy','paste','print'],
'centeralign','rightalign','blockjustify','|','unformat','n','undo','redo','|',
'image','hr','link','unlink','|'],
footer:true,
//fonts:['Verdana','Arial','Georgia','Trebuchet MS'],
fonts:['Verdana','Arial','Georgia','Trebuchet MS'],
xhtml:true,
cssfile:'//github.timshomepage.net/meta/assets/css.php/g/css',
cssfile:ASSET_URL+'css.php/g/css',
bodyid:'editor',
footerclass:'tefooter',
toggle:{text:'source',activetext:'wysiwyg',cssclass:'toggle'},
resize:{cssclass:'resize'}
});
}
// Make sure the WYSIWYG submits the text
// This just copies the text from the WYSIWYG into the textbox
if (window.editor)
{
document.querySelector('form').onsubmit = function(e) {
window.editor.toggle();
};
}
}());

View File

@ -1,47 +1,56 @@
// @todo Replace 'new Function' calls with non-evaling calls
(function() {
"use strict";
var TINY = {};
function T$(i)
{
return document.getElementById(i)
}
window.TINY = TINY;
function T$$$()
var T$ = function(i)
{
return document.all ? 1 : 0
}
return document.getElementById(i);
};
var T$$$ = function()
{
return (document.all && document.attachEvent) ? 1 : 0;
};
TINY.editor = function ()
{
var c = [],
var c = {},
offset = -30;
c['cut'] = [1, 'Cut', 'a', 'cut', 1];
c['copy'] = [2, 'Copy', 'a', 'copy', 1];
c['paste'] = [3, 'Paste', 'a', 'paste', 1];
c['bold'] = [4, 'Bold', 'a', 'bold'];
c['italic'] = [5, 'Italic', 'a', 'italic'];
c['underline'] = [6, 'Underline', 'a', 'underline'];
c['strikethrough'] = [7, 'Strikethrough', 'a', 'strikethrough'];
c['subscript'] = [8, 'Subscript', 'a', 'subscript'];
c['superscript'] = [9, 'Superscript', 'a', 'superscript'];
c['orderedlist'] = [10, 'Insert Ordered List', 'a', 'insertorderedlist'];
c['unorderedlist'] = [11, 'Insert Unordered List', 'a', 'insertunorderedlist'];
c['outdent'] = [12, 'Outdent', 'a', 'outdent'];
c['indent'] = [13, 'Indent', 'a', 'indent'];
c['leftalign'] = [14, 'Left Align', 'a', 'justifyleft'];
c['centeralign'] = [15, 'Center Align', 'a', 'justifycenter'];
c['rightalign'] = [16, 'Right Align', 'a', 'justifyright'];
c['blockjustify'] = [17, 'Block Justify', 'a', 'justifyfull'];
c['undo'] = [18, 'Undo', 'a', 'undo'];
c['redo'] = [19, 'Redo', 'a', 'redo'];
c['image'] = [20, 'Insert Image', 'i', 'insertimage', 'Enter Image URL:', 'http://'];
c['hr'] = [21, 'Insert Horizontal Rule', 'a', 'inserthorizontalrule'];
c['link'] = [22, 'Insert Hyperlink', 'i', 'createlink', 'Enter URL:', 'http://'];
c['unlink'] = [23, 'Remove Hyperlink', 'a', 'unlink'];
c['unformat'] = [24, 'Remove Formatting', 'a', 'removeformat'];
c['print'] = [25, 'Print', 'a', 'print'];
c.cut = [1, 'Cut', 'a', 'cut', 1];
c.copy = [2, 'Copy', 'a', 'copy', 1];
c.paste = [3, 'Paste', 'a', 'paste', 1];
c.bold = [4, 'Bold', 'a', 'bold'];
c.italic = [5, 'Italic', 'a', 'italic'];
c.underline = [6, 'Underline', 'a', 'underline'];
c.strikethrough = [7, 'Strikethrough', 'a', 'strikethrough'];
c.subscript = [8, 'Subscript', 'a', 'subscript'];
c.superscript = [9, 'Superscript', 'a', 'superscript'];
c.orderedlist = [10, 'Insert Ordered List', 'a', 'insertorderedlist'];
c.unorderedlist = [11, 'Insert Unordered List', 'a', 'insertunorderedlist'];
c.outdent = [12, 'Outdent', 'a', 'outdent'];
c.indent = [13, 'Indent', 'a', 'indent'];
c.leftalign = [14, 'Left Align', 'a', 'justifyleft'];
c.centeralign = [15, 'Center Align', 'a', 'justifycenter'];
c.rightalign = [16, 'Right Align', 'a', 'justifyright'];
c.blockjustify = [17, 'Block Justify', 'a', 'justifyfull'];
c.undo = [18, 'Undo', 'a', 'undo'];
c.redo = [19, 'Redo', 'a', 'redo'];
c.image = [20, 'Insert Image', 'i', 'insertimage', 'Enter Image URL:', 'http://'];
c.hr = [21, 'Insert Horizontal Rule', 'a', 'inserthorizontalrule'];
c.link = [22, 'Insert Hyperlink', 'i', 'createlink', 'Enter URL:', 'http://'];
c.unlink = [23, 'Remove Hyperlink', 'a', 'unlink'];
c.unformat = [24, 'Remove Formatting', 'a', 'removeformat'];
c.print = [25, 'Print', 'a', 'print'];
function edit(n, obj)
{
var sel, x, sl;
this.n = n;
window[n] = this;
this.t = T$(obj.id);
@ -68,17 +77,17 @@ TINY.editor = function ()
{
h = document.createElement('div');
h.className = obj.rowclass || 'teheader';
p.appendChild(h)
p.appendChild(h);
}
else if (id == '|')
{
var d = document.createElement('div');
d.className = obj.dividerclass || 'tedivider';
h.appendChild(d)
h.appendChild(d);
}
else if (id == 'font')
{
var sel = document.createElement('select'),
sel = document.createElement('select'),
fonts = obj.fonts || ['Verdana', 'Arial', 'Georgia'],
fl = fonts.length,
x = 0;
@ -88,13 +97,13 @@ TINY.editor = function ()
for (x; x < fl; x++)
{
var font = fonts[x];
sel.options[x + 1] = new Option(font, font)
sel.options[x + 1] = new Option(font, font);
}
h.appendChild(sel)
h.appendChild(sel);
}
else if (id == 'size')
{
var sel = document.createElement('select'),
sel = document.createElement('select'),
sizes = obj.sizes || [1, 2, 3, 4, 5, 6, 7],
sl = sizes.length,
x = 0;
@ -103,13 +112,13 @@ TINY.editor = function ()
for (x; x < sl; x++)
{
var size = sizes[x];
sel.options[x] = new Option(size, size)
sel.options[x] = new Option(size, size);
}
h.appendChild(sel)
h.appendChild(sel);
}
else if (id == 'style')
{
var sel = document.createElement('select'),
sel = document.createElement('select'),
styles = obj.styles || [
['Style', ''],
['Paragraph', '<p>'],
@ -127,14 +136,14 @@ TINY.editor = function ()
for (x; x < sl; x++)
{
var style = styles[x];
sel.options[x] = new Option(style[0], style[1])
sel.options[x] = new Option(style[0], style[1]);
}
h.appendChild(sel)
h.appendChild(sel);
}
else if (c[id])
{
x = c[id];
var div = document.createElement('div'),
x = c[id],
func = x[2],
ex, pos = x[0] * offset;
div.className = obj.controlclass;
@ -147,7 +156,7 @@ TINY.editor = function ()
h.appendChild(div);
if (this.ie)
{
div.unselectable = 'on'
div.unselectable = 'on';
}
}
}
@ -168,7 +177,7 @@ TINY.editor = function ()
ts.className = to.cssclass || 'toggle';
ts.innerHTML = obj.toggletext || 'source';
ts.onclick = new Function(this.n + '.toggle(0,this);return false');
f.appendChild(ts)
f.appendChild(ts);
}
if (obj.resize)
{
@ -178,11 +187,11 @@ TINY.editor = function ()
rs.onmousedown = new Function('event', this.n + '.resize(event);return false');
rs.onselectstart = function ()
{
return false
return false;
};
f.appendChild(rs)
f.appendChild(rs);
}
p.appendChild(f)
p.appendChild(f);
}
this.e = this.i.contentWindow.document;
this.e.open();
@ -190,11 +199,11 @@ TINY.editor = function ()
bodyid = obj.bodyid ? " id=\"" + obj.bodyid + "\"" : "";
if (obj.cssfile)
{
m += '<link rel="stylesheet" href="' + obj.cssfile + '" />'
m += '<link rel="stylesheet" href="' + obj.cssfile + '" />';
}
if (obj.css)
{
m += '<style type="text/css">' + obj.css + '</style>'
m += '<style type="text/css">' + obj.css + '</style>';
}
m += '</head><body' + bodyid + '>' + (obj.content || this.t.value);
m += '</body></html>';
@ -206,42 +215,42 @@ TINY.editor = function ()
{
try
{
this.e.execCommand("styleWithCSS", 0, 0)
this.e.execCommand("styleWithCSS", 0, 0);
}
catch (e)
{
try
{
this.e.execCommand("useCSS", 0, 1)
this.e.execCommand("useCSS", 0, 1);
}
catch (e)
{}
}
}
};
}
edit.prototype.print = function ()
{
this.i.contentWindow.print()
this.i.contentWindow.print();
},
edit.prototype.hover = function (div, pos, dir)
{
div.style.backgroundPosition = (dir ? '34px ' : '0px ') + (pos) + 'px'
div.style.backgroundPosition = (dir ? '34px ' : '0px ') + (pos) + 'px';
},
edit.prototype.ddaction = function (dd, a)
{
var i = dd.selectedIndex,
v = dd.options[i].value;
this.action(a, v)
this.action(a, v);
},
edit.prototype.action = function (cmd, val, ie)
{
if (ie && !this.ie)
{
alert('Your browser does not support this function.')
alert('Your browser does not support this function.');
}
else
{
this.e.execCommand(cmd, 0, val || null)
this.e.execCommand(cmd, 0, val || null);
}
},
edit.prototype.insert = function (pro, msg, cmd)
@ -249,18 +258,18 @@ TINY.editor = function ()
var val = prompt(pro, msg);
if (val != null && val != '')
{
this.e.execCommand(cmd, 0, val)
this.e.execCommand(cmd, 0, val);
}
},
edit.prototype.setfont = function ()
{
execCommand('formatblock', 0, hType)
execCommand('formatblock', 0, hType);
},
edit.prototype.resize = function (e)
{
if (this.mv)
{
this.freeze()
this.freeze();
}
this.i.bcs = TINY.cursor.top(e);
this.mv = new Function('event', this.n + '.move(event)');
@ -268,55 +277,57 @@ TINY.editor = function ()
if (this.ie)
{
document.attachEvent('onmousemove', this.mv);
document.attachEvent('onmouseup', this.sr)
document.attachEvent('onmouseup', this.sr);
}
else
{
document.addEventListener('mousemove', this.mv, 1);
document.addEventListener('mouseup', this.sr, 1)
document.addEventListener('mouseup', this.sr, 1);
}
},
edit.prototype.move = function (e)
{
var pos = TINY.cursor.top(e);
this.i.height = parseInt(this.i.height) + pos - this.i.bcs;
this.i.bcs = pos
this.i.height = parseInt(this.i.height, 10) + pos - this.i.bcs;
this.i.bcs = pos;
},
edit.prototype.freeze = function ()
{
if (this.ie)
{
document.detachEvent('onmousemove', this.mv);
document.detachEvent('onmouseup', this.sr)
document.detachEvent('onmouseup', this.sr);
}
else
{
document.removeEventListener('mousemove', this.mv, 1);
document.removeEventListener('mouseup', this.sr, 1)
document.removeEventListener('mouseup', this.sr, 1);
}
},
edit.prototype.toggle = function (post, div)
{
var v;
if (!this.d)
{
var v = this.t.value;
v = this.t.value;
if (div)
{
div.innerHTML = this.obj.toggletext || 'source'
div.innerHTML = this.obj.toggletext || 'source';
}
if (this.xhtml && !this.ie)
{
v = v.replace(/<strong>(.*)<\/strong>/gi, '<span style="font-weight: bold;">$1</span>');
v = v.replace(/<em>(.*)<\/em>/gi, '<span style="font-weight: italic;">$1</span>')
v = v.replace(/<em>(.*)<\/em>/gi, '<span style="font-weight: italic;">$1</span>');
}
this.e.body.innerHTML = v;
this.t.style.display = 'none';
this.i.style.display = 'block';
this.d = 1
this.d = 1;
}
else
{
var v = this.e.body.innerHTML;
v = this.e.body.innerHTML;
if (this.xhtml)
{
v = v.replace(/<span class="apple-style-span">(.*)<\/span>/gi, '$1');
@ -334,11 +345,11 @@ TINY.editor = function ()
v = v.replace(/<span style="font-weight: normal;?">(.*)<\/span>/gi, '$1');
v = v.replace(/<span style="font-weight: bold;?">(.*)<\/span>/gi, '<strong>$1</strong>');
v = v.replace(/<span style="font-style: italic;?">(.*)<\/span>/gi, '<em>$1</em>');
v = v.replace(/<span style="font-weight: bold;?">(.*)<\/span>|<b\b[^>]*>(.*?)<\/b[^>]*>/gi, '<strong>$1</strong>')
v = v.replace(/<span style="font-weight: bold;?">(.*)<\/span>|<b\b[^>]*>(.*?)<\/b[^>]*>/gi, '<strong>$1</strong>');
}
if (div)
{
div.innerHTML = this.obj.toggletext || 'wysiwyg'
div.innerHTML = this.obj.toggletext || 'wysiwyg';
}
this.t.value = v;
if (!post)
@ -346,7 +357,7 @@ TINY.editor = function ()
this.t.style.height = this.i.height + 'px';
this.i.style.display = 'none';
this.t.style.display = 'block';
this.d = 0
this.d = 0;
}
}
},
@ -354,12 +365,12 @@ TINY.editor = function ()
{
if (this.d)
{
this.toggle(1)
this.toggle(1);
}
};
return {
edit: edit
}
};
}();
TINY.cursor = function ()
@ -367,7 +378,15 @@ TINY.cursor = function ()
return {
top: function (e)
{
return T$$$() ? window.event.clientY + document.documentElement.scrollTop + document.body.scrollTop : e.clientY + window.scrollY
}
return T$$$()
? window.event.clientY + document.documentElement.scrollTop + document.body.scrollTop
: e.clientY + window.scrollY;
}
};
}();
TINY.init = function (obj) {
return new TINY.editor.edit('editor',obj);
};
}());

View File

@ -230,7 +230,7 @@ function controller_methods($controller)
* @param string $segment
* @return string
*/
function site_url($segment)
function site_url($segment='')
{
return $url = BASE_URL . URL_INDEX_FILE . $segment;
}

2
sys/db

@ -1 +1 @@
Subproject commit 4c546ed3e90aa371053290ed4842fd9cad7f175c
Subproject commit 92c989e6f87cbba1c51c55dd42bb44c2176b0ba2

View File

@ -1 +0,0 @@
<?php phpinfo();