diff --git a/app/classes/controller.php b/app/classes/controller.php index 6972490..84dd925 100644 --- a/app/classes/controller.php +++ b/app/classes/controller.php @@ -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(); } diff --git a/app/config/routes.php b/app/config/routes.php index adcd071..0e42238 100644 --- a/app/config/routes.php +++ b/app/config/routes.php @@ -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 \ No newline at end of file diff --git a/app/modules/meta/controllers/category.php b/app/modules/meta/controllers/category.php index 4a05575..f461ae5 100644 --- a/app/modules/meta/controllers/category.php +++ b/app/modules/meta/controllers/category.php @@ -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) { diff --git a/app/modules/meta/controllers/genre.php b/app/modules/meta/controllers/genre.php index 144460e..ba35019 100644 --- a/app/modules/meta/controllers/genre.php +++ b/app/modules/meta/controllers/genre.php @@ -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) { diff --git a/app/modules/meta/controllers/section.php b/app/modules/meta/controllers/section.php index f13a59d..ec7dc8d 100644 --- a/app/modules/meta/controllers/section.php +++ b/app/modules/meta/controllers/section.php @@ -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) diff --git a/app/modules/meta/controllers/welcome.php b/app/modules/meta/controllers/welcome.php index 6370827..e3619ee 100644 --- a/app/modules/meta/controllers/welcome.php +++ b/app/modules/meta/controllers/welcome.php @@ -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); } } diff --git a/app/modules/meta/models/model.php b/app/modules/meta/models/data_model.php similarity index 91% rename from app/modules/meta/models/model.php rename to app/modules/meta/models/data_model.php index 1c868c2..0d8041c 100644 --- a/app/modules/meta/models/model.php +++ b/app/modules/meta/models/data_model.php @@ -20,7 +20,7 @@ namespace meta; * * @package meta */ -class model extends \miniMVC\Model { +class data_model extends \miniMVC\Model { /** * Reference to database connection @@ -56,11 +56,21 @@ class model extends \miniMVC\Model { * * @param string $type * @param int $id + * @return bool */ public function delete($type, $id) { - $this->db->where('id', (int) $id) - ->delete($type); + 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", "
", $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", "
", $row['value']); + $d_array[$row['section_id']][$row['key']] = $row['value']; } } @@ -594,11 +638,11 @@ class model extends \miniMVC\Model { return $return; } - + // -------------------------------------------------------------------------- // ! Miscellaneous methods // -------------------------------------------------------------------------- - + /** * Check if a valid type for editing * @@ -610,10 +654,10 @@ class model extends \miniMVC\Model { $valid = array( 'genre','category','section','data' ); - - return in_array(str_to_lower($str), $valid); + + return in_array(strtolower($str), $valid); } } -// End of model.php \ No newline at end of file +// End of data_model.php \ No newline at end of file diff --git a/app/modules/meta/views/category_detail.php b/app/modules/meta/views/category_detail.php index 2415262..e44b3bc 100644 --- a/app/modules/meta/views/category_detail.php +++ b/app/modules/meta/views/category_detail.php @@ -36,7 +36,6 @@
-
diff --git a/app/modules/meta/views/edit_form.php b/app/modules/meta/views/edit_form.php index 827117e..31c8ed0 100644 --- a/app/modules/meta/views/edit_form.php +++ b/app/modules/meta/views/edit_form.php @@ -1,19 +1,22 @@ -
+
Edit
-
-
+
+
-
+
-
+
-
-
+
+ + +
+
\ No newline at end of file diff --git a/app/modules/meta/views/outline.php b/app/modules/meta/views/outline.php index 432da7b..fb8f939 100644 --- a/app/modules/meta/views/outline.php +++ b/app/modules/meta/views/outline.php @@ -1,5 +1,18 @@

Outline

+
+
Genre
+
+ +
+
+
$genre_array): ?> diff --git a/app/modules/meta/views/section_detail.php b/app/modules/meta/views/section_detail.php index 17c13aa..5007bf2 100644 --- a/app/modules/meta/views/section_detail.php +++ b/app/modules/meta/views/section_detail.php @@ -26,12 +26,18 @@ - + $d): ?> $v): ?> ") !== FALSE) ? 'multiline' : 'pair' ?>
-
+
+ + + + + +
diff --git a/app/views/footer.php b/app/views/footer.php index 2db2403..e72198f 100644 --- a/app/views/footer.php +++ b/app/views/footer.php @@ -1,4 +1,8 @@ - +
+
+ diff --git a/app/views/header.php b/app/views/header.php index 4e663f5..33226c1 100644 --- a/app/views/header.php +++ b/app/views/header.php @@ -9,4 +9,5 @@ > -

Meta

\ No newline at end of file +

Meta

+[Data Outline]
\ No newline at end of file diff --git a/app/views/message.php b/app/views/message.php index 8f1fbd0..f77682f 100644 --- a/app/views/message.php +++ b/app/views/message.php @@ -1,5 +1,5 @@
- + x
\ No newline at end of file diff --git a/assets/config/js_groups.php b/assets/config/js_groups.php index 663235a..19b7c29 100755 --- a/assets/config/js_groups.php +++ b/assets/config/js_groups.php @@ -25,9 +25,9 @@ return array( 'path/to/css/file2.css' ), */ - + 'js' => array( - 'kis-lite-dom-min.js', + 'kis-lite-dom.js', 'tinyeditor.js', 'meta.js' ), diff --git a/assets/css/message.css b/assets/css/message.css index 9eb6977..774b6cb 100644 --- a/assets/css/message.css +++ b/assets/css/message.css @@ -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{ diff --git a/assets/css/normalize.css b/assets/css/normalize.css index 4474dee..f7bb8a4 100644 --- a/assets/css/normalize.css +++ b/assets/css/normalize.css @@ -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 */ } /* diff --git a/assets/css/theme.css b/assets/css/theme.css index 5722b0d..ecd50e9 100644 --- a/assets/css/theme.css +++ b/assets/css/theme.css @@ -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; +} + diff --git a/assets/js.php b/assets/js.php index 5bda3bd..caf3a5b 100755 --- a/assets/js.php +++ b/assets/js.php @@ -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; @@ -73,10 +73,10 @@ function google_min($new_file) //curl_setopt($ch, CURLOPT_HEADER, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, 'output_info=compiled_code&output_format=text&compilation_level=SIMPLE_OPTIMIZATIONS&js_code=' . urlencode($new_file)); $output = curl_exec($ch); - + //die(curl_getinfo($ch, CURLINFO_HTTP_CODE)); curl_close($ch); - + return $output; } diff --git a/assets/js/cache/js b/assets/js/cache/js index f61d7b4..124373f 100644 --- a/assets/js/cache/js +++ b/assets/js/cache/js @@ -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"],["Header 1","

"],["Header 2","

"],["Header 3","

"],["Header 4","

"],["Header 5","

"],["Header 6","
"]];k=m.length;h=0; -g.className="testyle";g.onchange=new Function(this.n+'.ddaction(this,"formatblock")');for(h;h";f=a.bodyid?' id="'+a.bodyid+'"':"";a.cssfile&&(b+='');a.css&&(b+='"); -b+=""+(a.content||this.t.value);this.e.write(b+"");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>/gi,"$1"),b=b.replace(/ class="apple-style-span"/gi,""),b=b.replace(//gi,""),b=b.replace(/
/gi,"
"),b=b.replace(/
$/gi,""),b=b.replace(/^
/gi,""),b=b.replace(/(]+[^\/])>/gi,"$1 />"),b=b.replace(/]*>(.*?)<\/b[^>]*>/gi,"$1"),b=b.replace(/]*>(.*?)<\/i[^>]*>/gi, -"$1"),b=b.replace(/]*>(.*?)<\/u[^>]*>/gi,'$1'),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,'<$4>$3'),b=b.replace(/(.*)<\/span>/gi,"$1"),b=b.replace(/(.*)<\/span>/gi,"$1"),b=b.replace(/(.*)<\/span>/gi, -"$1"),b=b.replace(/(.*)<\/span>|]*>(.*?)<\/b[^>]*>/gi,"$1")),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>/gi,'$1'),b=b.replace(/(.*)<\/em>/gi, -'$1'));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;d1&&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"],["Header 1","

"],["Header 2","

"],["Header 3","

"], +["Header 4","

"],["Header 5","

"],["Header 6","
"]];g=styles.length;e=0;b.className="testyle";b.onchange=new Function(this.n+'.ddaction(this,"formatblock")');for(e;e";l=c.bodyid?' id="'+c.bodyid+'"':"";c.cssfile&&(h= +h+(''));c.css&&(h=h+('"));h=h+(""+(c.content||this.t.value));this.e.write(h+"");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>/gi,"$1");b=b.replace(/ class="apple-style-span"/gi,"");b=b.replace(//gi, +"");b=b.replace(/
/gi,"
");b=b.replace(/
$/gi,"");b=b.replace(/^
/gi,"");b=b.replace(/(]+[^\/])>/gi,"$1 />");b=b.replace(/]*>(.*?)<\/b[^>]*>/gi,"$1");b=b.replace(/]*>(.*?)<\/i[^>]*>/gi,"$1");b=b.replace(/]*>(.*?)<\/u[^>]*>/gi,'$1');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, +'<$4>$3');b=b.replace(/(.*)<\/span>/gi,"$1");b=b.replace(/(.*)<\/span>/gi,"$1");b=b.replace(/(.*)<\/span>/gi,"$1");b=b.replace(/(.*)<\/span>|]*>(.*?)<\/b[^>]*>/gi,"$1")}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>/gi,'$1');b=b.replace(/(.*)<\/em>/gi,'$1')}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()}})(); diff --git a/assets/js/kis-lite-dom-min.js b/assets/js/kis-lite-dom-min.js deleted file mode 100755 index 3931671..0000000 --- a/assets/js/kis-lite-dom-min.js +++ /dev/null @@ -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;h1&&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}})})(); diff --git a/assets/js/kis-lite-dom.js b/assets/js/kis-lite-dom.js new file mode 100755 index 0000000..29205a1 --- /dev/null +++ b/assets/js/kis-lite-dom.js @@ -0,0 +1,1211 @@ +/** + Kis JS Keep It Simple JS Library + Copyright Timothy J. Warren + License Public Domain + Version 0.6.0 + */ +(function (){ + + "use strict"; + + // Most functions rely on a string selector + // which returns html elements. This requires + // document.querySelectorAll or a custom + // selector engine. I choose to just use the + // browser feature, since it is present in + // IE 8+, and all other major browsers + if (typeof document.querySelector === "undefined") + { + return; + } + + var $_, $, dcopy, sel; + + + /** + * $_ + * + * Constructor function + * + * @constuctor + * @namespace + * @param string selector + * @return object + */ + $_ = function(s) + { + // Have documentElement be default selector, just in case + if (typeof s === "undefined") + { + // Defines a "global" selector for that instance + sel = (typeof $_.el !== "undefined") + ? $_.el + : document.documentElement; + } + else + { + sel = (typeof s !== "object") ? $(s) : s; + } + + // Add the selector to the prototype + $_.prototype.el = sel; + + // Use the $_ object as it's own prototype + var self = dcopy($_); + + // Give sel to each extension. + for(var i in self) + { + if(typeof self[i] === "object") + { + self[i].el = sel; + } + } + + self.el = sel; + + return self; + }; + + /** + * Simple DOM selector function + * + * @memberOf $_ + * @param string selector + * @param object context + * @return object + * @type object + */ + $ = function (a, context) + { + var x, c; + + if (typeof a != "string" || typeof a === "undefined"){ return a;} + + //Check for a context of a specific element, otherwise, just run on the document + c = (context != null && context.nodeType === 1) + ? context + : document; + + //Pick the quickest method for each kind of selector + if (a.match(/^#([\w\-]+$)/)) + { + return document.getElementById(a.split('#')[1]); + } + else + { + x = c.querySelectorAll(a); + } + + //Return the single object if applicable + return (x.length === 1) ? x[0] : x; + }; + + /** + * Deep copy/prototypical constructor function + * + * @param object obj + * @private + * @return object + * @type object + */ + dcopy = function(obj) + { + var type, F; + + if(typeof obj === "undefined") + { + return; + } + + if(typeof Object.create !== "undefined") + { + return Object.create(obj); + } + + type = typeof obj; + + if(type !== "object" && type !== "function") + { + return; + } + + /** + * @private + */ + F = function(){}; + + F.prototype = obj; + + return new F(); + + }; + + /** + * Adds the property `obj` to the $_ object, calling it `name` + * + * @param string name + * @param object obj + */ + $_.ext = function(name, obj) + { + obj.el = sel; + $_[name] = obj; + }; + + /** + * Iterates over a $_ object, applying a callback to each item + * + * @name $_.each + * @function + * @param function callback + */ + $_.ext('each', function (callback) + { + if(typeof sel.length !== "undefined" && sel !== window) + { + // Use the native method, if it exists + if(typeof Array.prototype.forEach !== 'undefined') + { + [].forEach.call(sel, callback); + return; + } + + // Otherwise, fall back to a for loop + var len = sel.length; + + if (len === 0) + { + return; + } + + var selx; + for (var x = 0; x < len; x++) + { + selx = (sel.item(x)) ? sel.item(x) : sel[x]; + callback.call(selx, selx); + } + } + else + { + callback.call(sel, sel); + } + }); + + /** + * Retrieves the type of the passed variable + * + * @param mixed obj + * @return string + * @type string + */ + $_.type = function(obj) + { + if((function() {return obj && (obj !== this)}).call(obj)) + { + //fallback on 'typeof' for truthy primitive values + return (typeof obj).toLowerCase(); + } + + //Strip x from [object x] and return + return ({}).toString.call(obj).match(/\s([a-z|A-Z]+)/)[1].toLowerCase(); + }; + + //Set global variables + $_ = window.$_ = window.$_ || $_; + $_.$ = $; + +}()); + +// -------------------------------------------------------------------------- + +/** + * A module of various browser polyfills + * @file polyfill.js + */ + +/** + * String trim function polyfill + */ +if(typeof String.prototype.trim === "undefined") +{ + /** + * @private + */ + String.prototype.trim = function() + { + return this.replace(/^[\s\uFEFF]+|[\s\uFEFF]+$/g, ""); + }; +} + +// -------------------------------------------------------------------------- + +/** + * event.preventDefault/e.stopPropagation polyfill + * @private + */ +if(typeof Event.preventDefault === "undefined" && typeof window.event !== "undefined") +{ + Event.prototype.preventDefault = function() + { + window.event.returnValue = false; + }, + Event.prototype.stopPropagation = function() + { + window.event.cancelBubble = true; + } +} + +// -------------------------------------------------------------------------- + +/** + * Array.isArray polyfill + */ +if (typeof Array.isArray === "undefined") +{ + Array.isArray = function(v) + { + return Object.prototype.toString.apply(v) === '[object Array]'; + } +} + +// -------------------------------------------------------------------------- + +/** + * Ajax + * + * Module for making ajax requests + */ +(function (){ + + "use strict"; + + // Don't bother even defining the object if the XMLHttpRequest isn't available + if(typeof window.XMLHttpRequest === "undefined") + { + return; + } + + var ajax = { + _do: function (url, data, success_callback, error_callback, isPost) + { + var type, + request = new XMLHttpRequest(); + + if (typeof success_callback === "undefined") + { + /** + * @private + */ + success_callback = function (){}; + } + + type = (isPost) ? "POST" : "GET"; + + url += (type === "GET") ? "?" + this._serialize(data) : ''; + + request.open(type, url); + + request.onreadystatechange = function () + { + if (request.readyState === 4) + { + if (request.status === 200) + { + success_callback.call(request.responseText, request.responseText); + } + else + { + if (typeof error_callback !== 'undefined') + { + error_callback.call(request.status, request.status); + } + } + + } + }; + + if (type === "POST") + { + request.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); + request.send(this._serialize(data)); + } + else + { + request.send(null); + } + }, + _serialize: function (data) + { + var name, + value, + pairs = []; + + for (name in data) + { + if (!data.hasOwnProperty(name)) + { + continue; + } + if (typeof data[name] === "function") + { + continue; + } + + value = data[name].toString(); + + name = encodeURIComponent(name); + value = encodeURIComponent(value); + + pairs.push(name + "=" + value); + } + + return pairs.join("&"); + } + }; + + /** + * Sends a GET type ajax request + * + * @name get + * @function + * @memberOf $_ + * @param string url + * @param object data + * @param function success_callback + * @param function error_callback + */ + $_.ext('get', function (url, data, success_callback, error_callback){ + ajax._do(url, data, success_callback, error_callback, false); + }); + + /** + * Sends a POST type ajax request + * + * @name post + * @function + * @memberOf $_ + * @param string url + * @param object data + * @param function success_callback + * @param function error_callback + */ + $_.ext('post', function (url, data, success_callback, error_callback){ + ajax._do(url, data, success_callback, error_callback, true); + }); + + /** + * Watches for server-sent events and applies a callback on message + * + * @name sse + * @function + * @memberOf $_ + * @param string url + * @param function callback + */ + $_.ext('sse', function(url, callback, poll_rate){ + + var source; + + // Check for server-sent event support + if (typeof EventSource !== 'undefined') + { + source = new EventSource(url); + + // Apply the callback + source.onmessage = function(event){ + callback.call(event.data, event.data); + }; + } + }); + +}()); + +// -------------------------------------------------------------------------- + +/** + * Event + * + * Event api wrapper + * @todo Add method for triggering events + */ +(function (){ + + "use strict"; + + // Property name for expandos on DOM objects + var kis_expando = "KIS_0_6_0"; + + var _attach, _remove, _add_remove, e, _attach_delegate; + + // Define the proper _attach and _remove functions + // based on browser support + if(typeof document.addEventListener !== "undefined") + { + /** + * @private + */ + _attach = function (sel, event, callback) + { + if(typeof sel.addEventListener !== "undefined") + { + // Duplicated events are dropped, per the specification + sel.addEventListener(event, callback, false); + } + }; + /** + * @private + */ + _remove = function (sel, event, callback) + { + if(typeof sel.removeEventListener !== "undefined") + { + sel.removeEventListener(event, callback, false); + } + }; + } + // typeof function doesn't work in IE where attachEvent is available: brute force it + else if(typeof document.attachEvent !== "undefined") + { + /** + * @private + */ + _attach = function (sel, event, callback) + { + function _listener () { + // Internet Explorer fails to correctly set the 'this' object + // for event listeners, so we need to set it ourselves. + callback.apply(arguments[0]); + } + + if (typeof sel.attachEvent !== "undefined") + { + _remove(event, callback); // Make sure we don't have duplicate listeners + + sel.attachEvent("on" + event, _listener); + // Store our listener so we can remove it later + var expando = sel[kis_expando] = sel[kis_expando] || {}; + expando.listeners = expando.listeners || {}; + expando.listeners[event] = expando.listeners[event] || []; + expando.listeners[event].push({ + callback: callback, + _listener: _listener + }); + } + }; + /** + * @private + */ + _remove = function (sel, event, callback) + { + if(typeof sel.detachEvent !== "undefined") + { + var expando = sel[kis_expando]; + if (expando && expando.listeners + && expando.listeners[event]) + { + var listeners = expando.listeners[event]; + var len = listeners.length; + for (var i=0; i 1 && typeof value === "undefined") + { + return null; + } + else if (sel.length > 1 && typeof value !== "undefined") //You can set a bunch, though + { + $_.each(function (e){ + return _attr(e, name, value); + }); + } + else //Normal behavior + { + return _attr(sel, name, value); + } + }, + /** + * Sets or retrieves the text content of the element + * specified by the current selector. If a value is + * passed, it will set that value on the current element, + * otherwise it will return the value of the current element + * + * @name text + * @memberOf $_.dom + * @function + * @param [string] value + * @return string + * @type string + */ + text: function (value) + { + var oldValue, set, type, sel; + + sel = this.el; + + set = (typeof value !== "undefined") ? true : false; + + type = (typeof sel.textContent !== "undefined") + ? "textContent" + : (typeof sel.innerText !== "undefined") + ? "innerText" + : "innerHTML"; + + oldValue = sel[type]; + + if(set) + { + sel[type] = value; + return value; + } + else + { + return oldValue; + } + }, + /** + * Sets or retrieves a css property of the element + * specified by the current selector. If a value is + * passed, it will set that value on the current element, + * otherwise it will return the value of the css property + * on the current element + * + * @name css + * @memberOf $_.dom + * @function + * @param string property + * @param [string] value + * @return string + * @type string + */ + css: function (prop, val) + { + //Return the current value if a value is not set + if(typeof val === "undefined") + { + return _css(this.el, prop); + } + + $_.each(function (e){ + _css(e, prop, val); + }); + }, + /** + * Adds to the innerHTML of the current element, after the last child. + * + * @example $_("ul").dom.append("<li></li>") adds an li element to the end of the selected ul element + * @name append + * @memberOf $_.dom + * @function + * @param string htm + */ + append: function(htm) + { + if(typeof document.insertAdjacentHTML !== "undefined") + { + this.el.insertAdjacentHTML('beforeend', htm); + } + else + { + this.el.innerHTML += htm; + } + }, + /** + * Adds to the innerHTML of the selected element, before the current children + * + * @name prepend + * @memberOf $_.dom + * @function + * @param string htm + */ + prepend: function(htm) + { + if(typeof document.insertAdjacentHTML !== "undefined") + { + this.el.insertAdjacentHTML('afterbegin', htm); + } + else + { + this.el.innerHTML = htm + this.el.innerHTML; + } + }, + /** + * Sets or gets the innerHTML propery of the element(s) passed + * + * @name html + * @memberOf $_.dom + * @function + * @param [string] htm + * @return string + * @type string + */ + html: function(htm) + { + + if(typeof htm !== "undefined") + { + this.el.innerHTML = htm; + } + + //If the parameter is undefined, just return the current value + return this.el.innerHTML; + } + }; + + $_.ext('dom', d); + +}()); \ No newline at end of file diff --git a/assets/js/meta.js b/assets/js/meta.js index fd2441e..8d5a80e 100644 --- a/assets/js/meta.js +++ b/assets/js/meta.js @@ -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,58 +69,199 @@ }); 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); - // Call the appropriate deletion method + 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; - // Show status message + default: + break; + } + } + }; + + /** + * 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); - // WYSIWYG - 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'], - footer:true, - //fonts:['Verdana','Arial','Georgia','Trebuchet MS'], - xhtml:true, - cssfile:'//github.timshomepage.net/meta/assets/css.php/g/css', - bodyid:'editor', - footerclass:'tefooter', - toggle:{text:'source',activetext:'wysiwyg',cssclass:'toggle'}, - resize:{cssclass:'resize'} + // 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 + if ($_.$('textarea').length > 0) + { + TINY.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: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(); + }; + } + }()); \ No newline at end of file diff --git a/assets/js/tinyeditor.js b/assets/js/tinyeditor.js index d8d7f9a..c60a8ad 100755 --- a/assets/js/tinyeditor.js +++ b/assets/js/tinyeditor.js @@ -1,373 +1,392 @@ -var TINY = {}; +// @todo Replace 'new Function' calls with non-evaling calls +(function() { -function T$(i) -{ - return document.getElementById(i) -} + "use strict"; -function T$$$() -{ - return document.all ? 1 : 0 -} + var TINY = {}; -TINY.editor = function () -{ - 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']; + window.TINY = TINY; - function edit(n, obj) + var T$ = function(i) { - this.n = n; - window[n] = this; - this.t = T$(obj.id); - this.obj = obj; - this.xhtml = obj.xhtml; - var p = document.createElement('div'), - w = document.createElement('div'), - h = document.createElement('div'), - l = obj.controls.length, - i = 0; - this.i = document.createElement('iframe'); - this.i.frameBorder = 0; - this.i.width = obj.width || '500'; - this.i.height = obj.height || '250'; - this.ie = T$$$(); - h.className = obj.rowclass || 'teheader'; - p.className = obj.cssclass || 'te'; - p.style.width = this.i.width + 'px'; - p.appendChild(h); - for (i; i < l; i++) + return document.getElementById(i); + }; + + var T$$$ = function() + { + return (document.all && document.attachEvent) ? 1 : 0; + }; + + TINY.editor = function () + { + 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']; + + function edit(n, obj) { - var id = obj.controls[i]; - if (id == 'n') + var sel, x, sl; + + this.n = n; + window[n] = this; + this.t = T$(obj.id); + this.obj = obj; + this.xhtml = obj.xhtml; + var p = document.createElement('div'), + w = document.createElement('div'), + h = document.createElement('div'), + l = obj.controls.length, + i = 0; + this.i = document.createElement('iframe'); + this.i.frameBorder = 0; + this.i.width = obj.width || '500'; + this.i.height = obj.height || '250'; + this.ie = T$$$(); + h.className = obj.rowclass || 'teheader'; + p.className = obj.cssclass || 'te'; + p.style.width = this.i.width + 'px'; + p.appendChild(h); + for (i; i < l; i++) { - h = document.createElement('div'); - h.className = obj.rowclass || 'teheader'; - p.appendChild(h) - } - else if (id == '|') - { - var d = document.createElement('div'); - d.className = obj.dividerclass || 'tedivider'; - h.appendChild(d) - } - else if (id == 'font') - { - var sel = document.createElement('select'), - fonts = obj.fonts || ['Verdana', 'Arial', 'Georgia'], - fl = fonts.length, - x = 0; - sel.className = 'tefont'; - sel.onchange = new Function(this.n + '.ddaction(this,"fontname")'); - sel.options[0] = new Option('Font', ''); - for (x; x < fl; x++) + var id = obj.controls[i]; + if (id == 'n') { - var font = fonts[x]; - sel.options[x + 1] = new Option(font, font) + h = document.createElement('div'); + h.className = obj.rowclass || 'teheader'; + p.appendChild(h); } - h.appendChild(sel) - } - else if (id == 'size') - { - var sel = document.createElement('select'), - sizes = obj.sizes || [1, 2, 3, 4, 5, 6, 7], - sl = sizes.length, - x = 0; - sel.className = 'tesize'; - sel.onchange = new Function(this.n + '.ddaction(this,"fontsize")'); - for (x; x < sl; x++) + else if (id == '|') { - var size = sizes[x]; - sel.options[x] = new Option(size, size) + var d = document.createElement('div'); + d.className = obj.dividerclass || 'tedivider'; + h.appendChild(d); } - h.appendChild(sel) - } - else if (id == 'style') - { - var sel = document.createElement('select'), - styles = obj.styles || [ - ['Style', ''], - ['Paragraph', '

'], - ['Header 1', '

'], - ['Header 2', '

'], - ['Header 3', '

'], - ['Header 4', '

'], - ['Header 5', '

'], - ['Header 6', '
'] - ], - sl = styles.length, - x = 0; - sel.className = 'testyle'; - sel.onchange = new Function(this.n + '.ddaction(this,"formatblock")'); - for (x; x < sl; x++) + else if (id == 'font') { - var style = styles[x]; - sel.options[x] = new Option(style[0], style[1]) + sel = document.createElement('select'), + fonts = obj.fonts || ['Verdana', 'Arial', 'Georgia'], + fl = fonts.length, + x = 0; + sel.className = 'tefont'; + sel.onchange = new Function(this.n + '.ddaction(this,"fontname")'); + sel.options[0] = new Option('Font', ''); + for (x; x < fl; x++) + { + var font = fonts[x]; + sel.options[x + 1] = new Option(font, font); + } + h.appendChild(sel); } - h.appendChild(sel) - } - else if (c[id]) - { - var div = document.createElement('div'), - x = c[id], - func = x[2], - ex, pos = x[0] * offset; - div.className = obj.controlclass; - div.style.backgroundPosition = '0px ' + pos + 'px'; - div.title = x[1]; - ex = func == 'a' ? '.action("' + x[3] + '",0,' + (x[4] || 0) + ')' : '.insert("' + x[4] + '","' + x[5] + '","' + x[3] + '")'; - div.onclick = new Function(this.n + (id == 'print' ? '.print()' : ex)); - div.onmouseover = new Function(this.n + '.hover(this,' + pos + ',1)'); - div.onmouseout = new Function(this.n + '.hover(this,' + pos + ',0)'); - h.appendChild(div); - if (this.ie) + else if (id == 'size') { - div.unselectable = 'on' + sel = document.createElement('select'), + sizes = obj.sizes || [1, 2, 3, 4, 5, 6, 7], + sl = sizes.length, + x = 0; + sel.className = 'tesize'; + sel.onchange = new Function(this.n + '.ddaction(this,"fontsize")'); + for (x; x < sl; x++) + { + var size = sizes[x]; + sel.options[x] = new Option(size, size); + } + h.appendChild(sel); + } + else if (id == 'style') + { + sel = document.createElement('select'), + styles = obj.styles || [ + ['Style', ''], + ['Paragraph', '

'], + ['Header 1', '

'], + ['Header 2', '

'], + ['Header 3', '

'], + ['Header 4', '

'], + ['Header 5', '

'], + ['Header 6', '
'] + ], + sl = styles.length, + x = 0; + sel.className = 'testyle'; + sel.onchange = new Function(this.n + '.ddaction(this,"formatblock")'); + for (x; x < sl; x++) + { + var style = styles[x]; + sel.options[x] = new Option(style[0], style[1]); + } + h.appendChild(sel); + } + else if (c[id]) + { + x = c[id]; + var div = document.createElement('div'), + func = x[2], + ex, pos = x[0] * offset; + div.className = obj.controlclass; + div.style.backgroundPosition = '0px ' + pos + 'px'; + div.title = x[1]; + ex = func == 'a' ? '.action("' + x[3] + '",0,' + (x[4] || 0) + ')' : '.insert("' + x[4] + '","' + x[5] + '","' + x[3] + '")'; + div.onclick = new Function(this.n + (id == 'print' ? '.print()' : ex)); + div.onmouseover = new Function(this.n + '.hover(this,' + pos + ',1)'); + div.onmouseout = new Function(this.n + '.hover(this,' + pos + ',0)'); + h.appendChild(div); + if (this.ie) + { + div.unselectable = 'on'; + } } } - } - this.t.parentNode.insertBefore(p, this.t); - this.t.style.width = this.i.width + 'px'; - w.appendChild(this.t); - w.appendChild(this.i); - p.appendChild(w); - this.t.style.display = 'none'; - if (obj.footer) - { - var f = document.createElement('div'); - f.className = obj.footerclass || 'tefooter'; - if (obj.toggle) + this.t.parentNode.insertBefore(p, this.t); + this.t.style.width = this.i.width + 'px'; + w.appendChild(this.t); + w.appendChild(this.i); + p.appendChild(w); + this.t.style.display = 'none'; + if (obj.footer) { - var to = obj.toggle, - ts = document.createElement('div'); - ts.className = to.cssclass || 'toggle'; - ts.innerHTML = obj.toggletext || 'source'; - ts.onclick = new Function(this.n + '.toggle(0,this);return false'); - f.appendChild(ts) - } - if (obj.resize) - { - var ro = obj.resize, - rs = document.createElement('div'); - rs.className = ro.cssclass || 'resize'; - rs.onmousedown = new Function('event', this.n + '.resize(event);return false'); - rs.onselectstart = function () + var f = document.createElement('div'); + f.className = obj.footerclass || 'tefooter'; + if (obj.toggle) { - return false - }; - f.appendChild(rs) + var to = obj.toggle, + ts = document.createElement('div'); + ts.className = to.cssclass || 'toggle'; + ts.innerHTML = obj.toggletext || 'source'; + ts.onclick = new Function(this.n + '.toggle(0,this);return false'); + f.appendChild(ts); + } + if (obj.resize) + { + var ro = obj.resize, + rs = document.createElement('div'); + rs.className = ro.cssclass || 'resize'; + rs.onmousedown = new Function('event', this.n + '.resize(event);return false'); + rs.onselectstart = function () + { + return false; + }; + f.appendChild(rs); + } + p.appendChild(f); } - p.appendChild(f) - } - this.e = this.i.contentWindow.document; - this.e.open(); - var m = '', - bodyid = obj.bodyid ? " id=\"" + obj.bodyid + "\"" : ""; - if (obj.cssfile) - { - m += '' - } - if (obj.css) - { - m += '' - } - m += '' + (obj.content || this.t.value); - m += ''; - this.e.write(m); - this.e.close(); - this.e.designMode = 'on'; - this.d = 1; - if (this.xhtml) - { - try + this.e = this.i.contentWindow.document; + this.e.open(); + var m = '', + bodyid = obj.bodyid ? " id=\"" + obj.bodyid + "\"" : ""; + if (obj.cssfile) { - this.e.execCommand("styleWithCSS", 0, 0) + m += ''; } - catch (e) + if (obj.css) + { + m += ''; + } + m += '' + (obj.content || this.t.value); + m += ''; + this.e.write(m); + this.e.close(); + this.e.designMode = 'on'; + this.d = 1; + if (this.xhtml) { try { - this.e.execCommand("useCSS", 0, 1) + this.e.execCommand("styleWithCSS", 0, 0); } catch (e) - {} + { + try + { + this.e.execCommand("useCSS", 0, 1); + } + catch (e) + {} + } } } - }; - edit.prototype.print = function () - { - this.i.contentWindow.print() - }, - edit.prototype.hover = function (div, pos, dir) - { - 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) - }, - edit.prototype.action = function (cmd, val, ie) - { - if (ie && !this.ie) + edit.prototype.print = function () { - alert('Your browser does not support this function.') - } - else + this.i.contentWindow.print(); + }, + edit.prototype.hover = function (div, pos, dir) { - this.e.execCommand(cmd, 0, val || null) - } - }, - edit.prototype.insert = function (pro, msg, cmd) - { - var val = prompt(pro, msg); - if (val != null && val != '') + div.style.backgroundPosition = (dir ? '34px ' : '0px ') + (pos) + 'px'; + }, + edit.prototype.ddaction = function (dd, a) { - this.e.execCommand(cmd, 0, val) - } - }, - edit.prototype.setfont = function () - { - execCommand('formatblock', 0, hType) - }, - edit.prototype.resize = function (e) - { - if (this.mv) + var i = dd.selectedIndex, + v = dd.options[i].value; + this.action(a, v); + }, + edit.prototype.action = function (cmd, val, ie) { - this.freeze() - } - this.i.bcs = TINY.cursor.top(e); - 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) - } - }, - 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 - }, - edit.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) - } - }, - edit.prototype.toggle = function (post, div) - { - if (!this.d) - { - var v = this.t.value; - if (div) + if (ie && !this.ie) { - div.innerHTML = this.obj.toggletext || 'source' + alert('Your browser does not support this function.'); } - if (this.xhtml && !this.ie) + else { - v = v.replace(/(.*)<\/strong>/gi, '$1'); - v = v.replace(/(.*)<\/em>/gi, '$1') + this.e.execCommand(cmd, 0, val || null); } - this.e.body.innerHTML = v; - this.t.style.display = 'none'; - this.i.style.display = 'block'; - this.d = 1 - } - else + }, + edit.prototype.insert = function (pro, msg, cmd) { - var v = this.e.body.innerHTML; - if (this.xhtml) + var val = prompt(pro, msg); + if (val != null && val != '') { - v = v.replace(/(.*)<\/span>/gi, '$1'); - v = v.replace(/ class="apple-style-span"/gi, ''); - v = v.replace(//gi, ''); - v = v.replace(/
/gi, '
'); - v = v.replace(/
$/gi, ''); - v = v.replace(/^
/gi, ''); - v = v.replace(/(]+[^\/])>/gi, '$1 />'); - v = v.replace(/]*>(.*?)<\/b[^>]*>/gi, '$1'); - v = v.replace(/]*>(.*?)<\/i[^>]*>/gi, '$1'); - v = v.replace(/]*>(.*?)<\/u[^>]*>/gi, '$1'); - v = v.replace(/<(b|strong|em|i|u) style="font-weight: normal;?">(.*)<\/(b|strong|em|i|u)>/gi, '$2'); - v = v.replace(/<(b|strong|em|i|u) style="(.*)">(.*)<\/(b|strong|em|i|u)>/gi, '<$4>$3'); - v = v.replace(/(.*)<\/span>/gi, '$1'); - v = v.replace(/(.*)<\/span>/gi, '$1'); - v = v.replace(/(.*)<\/span>/gi, '$1'); - v = v.replace(/(.*)<\/span>|]*>(.*?)<\/b[^>]*>/gi, '$1') + this.e.execCommand(cmd, 0, val); } - if (div) - { - div.innerHTML = this.obj.toggletext || 'wysiwyg' - } - this.t.value = v; - if (!post) - { - this.t.style.height = this.i.height + 'px'; - this.i.style.display = 'none'; - this.t.style.display = 'block'; - this.d = 0 - } - } - }, - edit.prototype.post = function () - { - if (this.d) + }, + edit.prototype.setfont = function () { - this.toggle(1) - } - }; - return { - edit: edit - } -}(); + execCommand('formatblock', 0, hType); + }, + edit.prototype.resize = function (e) + { + if (this.mv) + { + this.freeze(); + } + this.i.bcs = TINY.cursor.top(e); + 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); + } + }, + edit.prototype.move = function (e) + { + var pos = TINY.cursor.top(e); + 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); + } + else + { + document.removeEventListener('mousemove', this.mv, 1); + document.removeEventListener('mouseup', this.sr, 1); + } + }, + edit.prototype.toggle = function (post, div) + { + var v; -TINY.cursor = function () -{ - return { - top: function (e) + if (!this.d) + { + v = this.t.value; + if (div) + { + div.innerHTML = this.obj.toggletext || 'source'; + } + if (this.xhtml && !this.ie) + { + v = v.replace(/(.*)<\/strong>/gi, '$1'); + v = v.replace(/(.*)<\/em>/gi, '$1'); + } + this.e.body.innerHTML = v; + this.t.style.display = 'none'; + this.i.style.display = 'block'; + this.d = 1; + } + else + { + v = this.e.body.innerHTML; + if (this.xhtml) + { + v = v.replace(/(.*)<\/span>/gi, '$1'); + v = v.replace(/ class="apple-style-span"/gi, ''); + v = v.replace(//gi, ''); + v = v.replace(/
/gi, '
'); + v = v.replace(/
$/gi, ''); + v = v.replace(/^
/gi, ''); + v = v.replace(/(]+[^\/])>/gi, '$1 />'); + v = v.replace(/]*>(.*?)<\/b[^>]*>/gi, '$1'); + v = v.replace(/]*>(.*?)<\/i[^>]*>/gi, '$1'); + v = v.replace(/]*>(.*?)<\/u[^>]*>/gi, '$1'); + v = v.replace(/<(b|strong|em|i|u) style="font-weight: normal;?">(.*)<\/(b|strong|em|i|u)>/gi, '$2'); + v = v.replace(/<(b|strong|em|i|u) style="(.*)">(.*)<\/(b|strong|em|i|u)>/gi, '<$4>$3'); + v = v.replace(/(.*)<\/span>/gi, '$1'); + v = v.replace(/(.*)<\/span>/gi, '$1'); + v = v.replace(/(.*)<\/span>/gi, '$1'); + v = v.replace(/(.*)<\/span>|]*>(.*?)<\/b[^>]*>/gi, '$1'); + } + if (div) + { + div.innerHTML = this.obj.toggletext || 'wysiwyg'; + } + this.t.value = v; + if (!post) + { + this.t.style.height = this.i.height + 'px'; + this.i.style.display = 'none'; + this.t.style.display = 'block'; + this.d = 0; + } + } + }, + edit.prototype.post = function () { - return T$$$() ? window.event.clientY + document.documentElement.scrollTop + document.body.scrollTop : e.clientY + window.scrollY - } - } -}(); \ No newline at end of file + if (this.d) + { + this.toggle(1); + } + }; + return { + edit: edit + }; + }(); + + TINY.cursor = function () + { + return { + top: function (e) + { + 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); + }; + +}()); \ No newline at end of file diff --git a/sys/common.php b/sys/common.php index 4a3a060..4f4f412 100644 --- a/sys/common.php +++ b/sys/common.php @@ -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; } @@ -461,7 +461,7 @@ function route() } run($module, $controller, $func); - + return; } @@ -482,19 +482,19 @@ function run($module, $controller, $func, $args = array()) if (is_file($path)) { require_once($path); - + // Get the list of valid methods for that controller $methods = controller_methods($controller); if (in_array($func, $methods)) { - + // Define the name of the current module for file loading if ( ! defined('MM_MOD')) { define('MM_MOD', $module); } - + if (class_exists($controller)) { $class = new $controller(); @@ -503,7 +503,7 @@ function run($module, $controller, $func, $args = array()) //show_error(to_string(get_declared_classes())); return call_user_func_array(array($class, $func), $args); } - + show_404(); } diff --git a/sys/db b/sys/db index 4c546ed..92c989e 160000 --- a/sys/db +++ b/sys/db @@ -1 +1 @@ -Subproject commit 4c546ed3e90aa371053290ed4842fd9cad7f175c +Subproject commit 92c989e6f87cbba1c51c55dd42bb44c2176b0ba2 diff --git a/test.php b/test.php deleted file mode 100644 index e974c40..0000000 --- a/test.php +++ /dev/null @@ -1 +0,0 @@ -