comicpress options working

This commit is contained in:
John Bintz 2009-11-13 14:45:28 -05:00
parent 8954eec144
commit 722c495f0c
4 changed files with 64 additions and 33 deletions

View File

@ -135,11 +135,11 @@ class ComicPressAdmin {
function _render_admin_storyline_tree($node, $parent_id = "0") { function _render_admin_storyline_tree($node, $parent_id = "0") {
foreach ($node as $category_id => $children) { foreach ($node as $category_id => $children) {
$category = get_category($category_id); $category = get_category($category_id);
echo '<div id="category_' . $parent_id . '/' . $category_id . '" class="cp-category-info">'; echo '<div id="category_' . $parent_id . '-' . $category_id . '" class="cp-category-info">';
echo '<span>' . $category->name . '</span>'; echo '<span>' . $category->name . '</span>';
if (is_array($children)) { if (is_array($children)) {
echo '<div class="cp-children">'; echo '<div class="cp-children">';
$this->_render_admin_storyline_tree($children, $parent_id . '/' . $category_id); $this->_render_admin_storyline_tree($children, $parent_id . '-' . $category_id);
echo '</div>'; echo '</div>';
} }
echo '</div>'; echo '</div>';
@ -235,9 +235,6 @@ class ComicPressAdmin {
* Update ComicPress options. * Update ComicPress options.
*/ */
function handle_update_comicpress_options($info) { function handle_update_comicpress_options($info) {
foreach (array('helpers') as $type) {
$this->comicpress->comicpress_options[$type] = array();
}
foreach ($this->comicpress->comicpress_options as $option => $value) { foreach ($this->comicpress->comicpress_options as $option => $value) {
if (isset($info[$option])) { if (isset($info[$option])) {
switch ($option) { switch ($option) {
@ -281,11 +278,6 @@ class ComicPressAdmin {
} }
break; break;
// @codeCoverageIgnoreStart // @codeCoverageIgnoreStart
case 'helpers':
foreach ($info[$option] as $type => $set) {
$this->comicpress->comicpress_options[$option][$type] = true;
}
break;
case 'storyline_order': case 'storyline_order':
$storyline = new ComicPressStoryline(); $storyline = new ComicPressStoryline();
$storyline->normalize($info[$option]); $storyline->normalize($info[$option]);
@ -328,6 +320,18 @@ class ComicPressAdmin {
} }
} }
function handle_update_get_new_image_type_editor($info) {
$type = substr(md5(rand()), 0, 6);
$info = array(
'dimensions' => '100x100',
'default' => false,
'name' => 'New Type'
);
require_once('partials/_image-type-editor.inc');
exit(0);
}
/** /**
* Update the zoom slider info. * Update the zoom slider info.
* @param $info The browser input. * @param $info The browser input.

View File

@ -1,18 +1,20 @@
<div class="wrap"> <div class="wrap">
<h2><?php _e('ComicPress Config', 'comicpress') ?></h2> <h2><?php _e('ComicPress Config', 'comicpress') ?></h2>
<form method="post"> <form method="post" action="">
<input type="hidden" name="cp[_nonce]" value="<?php echo $nonce ?>" /> <input type="hidden" name="cp[_nonce]" value="<?php echo $nonce ?>" />
<h3><?php _e('Global Options', 'comicpress') ?></h3> <h3><?php _e('Global Options', 'comicpress') ?></h3>
<table class="widefat fixed"> <table class="widefat fixed">
<tr> <tr>
<th width="25%" scope="row" valign="top"><?php _e("Arrange storyline category order", 'comicpress') ?></th> <th width="25%" scope="row" valign="top"><?php _e("Arrange storyline category order", 'comicpress') ?></th>
<td width="75%"> <td width="75%">
<input type="hidden" name="cp[storyline_order]" /> <input type="hidden" name="cp[storyline_order]" value="" />
<div id="storyline-sorter" class="cp-children"> <div id="storyline-sorter">
<div class="cp-children">
<?php <?php
$this->_render_admin_storyline_tree(reset($storyline->get_simple_storyline())) $this->_render_admin_storyline_tree(reset($storyline->get_simple_storyline()))
?> ?>
</div> </div>
</div>
<script type="text/javascript">Storyline.setup()</script> <script type="text/javascript">Storyline.setup()</script>
<p><em><?php _e('(drag and drop desired order. categories can be modified on the Posts -> Categories page)', 'comicpress') ?></em></p> <p><em><?php _e('(drag and drop desired order. categories can be modified on the Posts -> Categories page)', 'comicpress') ?></em></p>
</td> </td>
@ -25,11 +27,13 @@
<?php include('_image-type-editor.inc'); ?> <?php include('_image-type-editor.inc'); ?>
<?php } ?> <?php } ?>
</div> </div>
<a id="add-new-image-type" href="#">Add a new image type</a> <a id="add-new-image-type" href="#">[+] Add a new image type</a>
<script type="text/javascript">ComicImageTypes.setup()</script> <script type="text/javascript">ComicImageTypes.setup()</script>
</td> </td>
</tr> </tr>
</table> </table>
<input class="button" type="submit" value="<?php _e('Submit Changes', 'comicpress') ?>" /> <div style="text-align: center; margin-top: 10px;">
<input class="button" type="submit" value="<?php _e('Submit Updated ComicPress Options', 'comicpress') ?>" />
</div>
</form> </form>
</div> </div>

View File

@ -8,7 +8,13 @@
.cp-category-info span { .cp-category-info span {
cursor: move; cursor: move;
color: #004 color: #33a;
font-size: 18px;
line-height: 22px
}
.cp-category-info span:hover {
color: #46d;
} }
#ordering-zoom-slider-holder { #ordering-zoom-slider-holder {
@ -94,3 +100,10 @@
font-weight: bold; font-weight: bold;
color: #aaa color: #aaa
} }
#add-new-image-type {
font-size: 16px;
line-height: 16px;
display: block;
margin-bottom: 10px;
}

View File

@ -3,10 +3,10 @@ var ComicImageTypes = {};
(function() { (function() {
Storyline.get_order = function() { Storyline.get_order = function() {
var order = [] var order = [];
$$('#storyline-sorter .cp-category-info').each(function(info) { $$('#storyline-sorter .cp-category-info').each(function(info) {
var matches = info.id.match(/category_([0-9\/]+)/); var matches = info.id.match(/category_([0-9\-]+)/);
if (matches) { order.push(matches[1]); } if (matches) { order.push(matches[1].replace(/\-/g,'/')); }
}); });
$$('input[name*=storyline_order]').pop().value = order.join(','); $$('input[name*=storyline_order]').pop().value = order.join(',');
}; };
@ -33,6 +33,20 @@ var ComicImageTypes = {};
}); });
}); });
}); });
Storyline.get_order();
};
ComicImageTypes.setup_checkboxes = function() {
var checkboxes = $$('input[name*=default][name*=image_types]');
checkboxes.each(function(c) {
c.stopObserving('change');
c.observe('change', function(e) {
checkboxes.each(function(ch) {
if (e.target != ch) { ch.checked = false; }
});
});
});
}; };
ComicImageTypes.setup = function() { ComicImageTypes.setup = function() {
@ -41,7 +55,7 @@ var ComicImageTypes = {};
if (closer) { if (closer) {
closer.observe('click', function(e) { closer.observe('click', function(e) {
Event.stop(e); Event.stop(e);
if (confirm('Are you sure? Your templates may break after deleting this image type')) { if (confirm('Are you sure? Your templates may break after deleting this image type.')) {
new Effect.Fade(ith, { new Effect.Fade(ith, {
from: 1, from: 1,
to: 0, to: 0,
@ -54,14 +68,7 @@ var ComicImageTypes = {};
} }
}); });
var checkboxes = $$('input[name*=default][name*=image_types]'); ComicImageTypes.setup_checkboxes();
checkboxes.each(function(c) {
c.observe('change', function(e) {
checkboxes.each(function(ch) {
if (e.target != ch) { ch.checked = false; }
});
});
});
$('add-new-image-type').observe('click', function(e) { $('add-new-image-type').observe('click', function(e) {
Event.stop(e); Event.stop(e);
@ -69,9 +76,12 @@ var ComicImageTypes = {};
method: 'get', method: 'get',
parameters: { parameters: {
'cp[_nonce]': ComicPressAdmin.nonce, 'cp[_nonce]': ComicPressAdmin.nonce,
'cp[ 'cp[action]': 'get-new-image-type-editor'
}, },
insertion: 'bottom' insertion: 'bottom',
onComplete: function() {
ComicImageTypes.setup_checkboxes();
}
}); });
}); });
}; };