working on image types editor
This commit is contained in:
parent
b1db6deb7b
commit
8954eec144
@ -79,6 +79,7 @@ class ComicPressAdmin {
|
|||||||
if ($plugin_page == 'comicpress/render_admin') {
|
if ($plugin_page == 'comicpress/render_admin') {
|
||||||
wp_enqueue_style('cp-admin', get_template_directory_uri() . '/css/cp-admin.css');
|
wp_enqueue_style('cp-admin', get_template_directory_uri() . '/css/cp-admin.css');
|
||||||
wp_enqueue_script('cp-admin', get_template_directory_uri() . '/js/Storyline.js', array('prototype', 'scriptaculous'));
|
wp_enqueue_script('cp-admin', get_template_directory_uri() . '/js/Storyline.js', array('prototype', 'scriptaculous'));
|
||||||
|
add_action('admin_footer', array(&$this, 'admin_footer'));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (strpos($pagenow, "-upload") !== false) {
|
if (strpos($pagenow, "-upload") !== false) {
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
<div class="image-type-holder">
|
<div class="image-type-holder">
|
||||||
<a class="delete-image-type">X</a>
|
<a class="delete-image-type" href="#">X</a>
|
||||||
<table cellspacing="0">
|
<table cellspacing="0">
|
||||||
<tr class="image-type-editor-name">
|
<tr class="image-type-editor-name">
|
||||||
<th scope="row" width="30%">Name:</th>
|
<th scope="row" width="30%">Name:</th>
|
||||||
@ -11,7 +11,12 @@
|
|||||||
</tr>
|
</tr>
|
||||||
<tr class="image-type-editor-default">
|
<tr class="image-type-editor-default">
|
||||||
<th scope="row">Default image type?</th>
|
<th scope="row">Default image type?</th>
|
||||||
<td><input type="checkbox" name="cp[image_types][<?php echo $type ?>][default]" value="yes" <?php echo (!empty($info['default'])) ? 'checked="checked"' : '' ?> /></td>
|
<td>
|
||||||
|
<label>
|
||||||
|
<input type="checkbox" name="cp[image_types][<?php echo $type ?>][default]" value="yes" <?php echo (!empty($info['default'])) ? 'checked="checked"' : '' ?> />
|
||||||
|
<em>(<?php _e('When using a ComicPress tag without specifying a type, this one will be used', 'comicpress') ?>)</em>
|
||||||
|
</label>
|
||||||
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr class="image-type-editor-dimensions">
|
<tr class="image-type-editor-dimensions">
|
||||||
<th scope="row">Dimensions</th>
|
<th scope="row">Dimensions</th>
|
||||||
@ -19,6 +24,8 @@
|
|||||||
<?php list($width, $height) = explode("x", $info['dimensions']) ?>
|
<?php list($width, $height) = explode("x", $info['dimensions']) ?>
|
||||||
<input type="text" name="cp[image_types][<?php echo $type ?>][dimensions][width]" value="<?php echo $width ?>" size="5" /> x
|
<input type="text" name="cp[image_types][<?php echo $type ?>][dimensions][width]" value="<?php echo $width ?>" size="5" /> x
|
||||||
<input type="text" name="cp[image_types][<?php echo $type ?>][dimensions][height]" value="<?php echo $height ?>" size="5" />
|
<input type="text" name="cp[image_types][<?php echo $type ?>][dimensions][height]" value="<?php echo $height ?>" size="5" />
|
||||||
|
<br />
|
||||||
|
<em>(<?php _e('Leave a dimension blank to allow WordPress to calculate that dimension while scaling', 'comicpress') ?>)</em>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<?php do_action('comicpress_image_type_holder') ?>
|
<?php do_action('comicpress_image_type_holder') ?>
|
||||||
|
@ -25,57 +25,11 @@
|
|||||||
<?php include('_image-type-editor.inc'); ?>
|
<?php include('_image-type-editor.inc'); ?>
|
||||||
<?php } ?>
|
<?php } ?>
|
||||||
</div>
|
</div>
|
||||||
<a id="add-new-image-type">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>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
<h3><?php _e('Admin Options', 'comicpress') ?></h3>
|
|
||||||
<table class="widefat fixed">
|
|
||||||
<tr>
|
|
||||||
<th scope="row"><?php _e('Enable editing helpers', 'comicpress') ?></th>
|
|
||||||
<td>
|
|
||||||
<?php
|
|
||||||
foreach (array(
|
|
||||||
"show_inline_comic_ordering" => __('Show inline comic ordering', 'comicpress')
|
|
||||||
) as $key => $label) { ?>
|
|
||||||
<label>
|
|
||||||
<input type="checkbox"
|
|
||||||
name="cp[helpers][<?php echo $key ?>]"
|
|
||||||
value="yes"
|
|
||||||
<?php echo (($this->comicpress->comicpress_options['helpers'][$key] === true) ? 'checked="checked"' : '') ?> />
|
|
||||||
<?php echo $label ?>
|
|
||||||
</label>
|
|
||||||
<br />
|
|
||||||
<?php }
|
|
||||||
?>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
<?php if (is_array($this->all_addons)) { ?>
|
|
||||||
<tr>
|
|
||||||
<th scope="row"><?php _e('Enable addons', 'comicpress') ?></th>
|
|
||||||
<td>
|
|
||||||
<?php
|
|
||||||
foreach ($this->all_addons as $addon) {
|
|
||||||
if (!empty($addon->name)) {
|
|
||||||
$enabled = ($addon->is_addon_manager !== true);
|
|
||||||
$checked = $enabled && $this->comicpress->comicpress_options['addons'][$addon->name];
|
|
||||||
?>
|
|
||||||
|
|
||||||
<label>
|
|
||||||
<input type="checkbox"
|
|
||||||
name="cp[addons][<?php echo $addon->name ?>]"
|
|
||||||
value="yes"
|
|
||||||
<?php echo !$enabled ? 'disabled="disabled"' : '' ?>
|
|
||||||
<?php echo $checked ? 'checked="checked"' : '' ?> />
|
|
||||||
<?php echo $addon->name ?>
|
|
||||||
</label><br />
|
|
||||||
<?php }
|
|
||||||
}
|
|
||||||
?>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
<?php } ?>
|
|
||||||
</table>
|
|
||||||
<input class="button" type="submit" value="<?php _e('Submit Changes', 'comicpress') ?>" />
|
<input class="button" type="submit" value="<?php _e('Submit Changes', 'comicpress') ?>" />
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
|
102
js/Storyline.js
102
js/Storyline.js
@ -1,34 +1,78 @@
|
|||||||
var Storyline = {};
|
var Storyline = {};
|
||||||
|
var ComicImageTypes = {};
|
||||||
|
|
||||||
Storyline.get_order = function() {
|
(function() {
|
||||||
var order = []
|
Storyline.get_order = function() {
|
||||||
$$('#storyline-sorter .cp-category-info').each(function(info) {
|
var order = []
|
||||||
var matches = info.id.match(/category_([0-9\/]+)/);
|
$$('#storyline-sorter .cp-category-info').each(function(info) {
|
||||||
if (matches) { order.push(matches[1]); }
|
var matches = info.id.match(/category_([0-9\/]+)/);
|
||||||
});
|
if (matches) { order.push(matches[1]); }
|
||||||
$$('input[name*=storyline_order]').pop().value = order.join(',');
|
});
|
||||||
};
|
$$('input[name*=storyline_order]').pop().value = order.join(',');
|
||||||
|
};
|
||||||
|
|
||||||
Storyline.setup = function() {
|
Storyline.setup = function() {
|
||||||
var i = 0;
|
var i = 0;
|
||||||
var depths = {};
|
var depths = {};
|
||||||
$$('.cp-children').each(function(ch) {
|
$$('.cp-children').each(function(ch) {
|
||||||
ch.id = 'children-' + i;
|
ch.id = 'children-' + i;
|
||||||
var depth = ch.ancestors().length;
|
var depth = ch.ancestors().length;
|
||||||
if (!depths[depth]) { depths[depth] = []; }
|
if (!depths[depth]) { depths[depth] = []; }
|
||||||
depths[depth].push(ch);
|
depths[depth].push(ch);
|
||||||
++i;
|
++i;
|
||||||
});
|
});
|
||||||
|
|
||||||
depths = $H(depths);
|
depths = $H(depths);
|
||||||
|
|
||||||
depths.keys().sort(function(a,b) { return b - a; }).each(function(depth) {
|
depths.keys().sort(function(a,b) { return b - a; }).each(function(depth) {
|
||||||
depths.get(depth).each(function(ch) {
|
depths.get(depth).each(function(ch) {
|
||||||
Sortable.create(ch.id, {
|
Sortable.create(ch.id, {
|
||||||
tag: 'div',
|
tag: 'div',
|
||||||
handle: 'span',
|
handle: 'span',
|
||||||
onUpdate: Storyline.get_order
|
onUpdate: Storyline.get_order
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
ComicImageTypes.setup = function() {
|
||||||
|
$$('.image-type-holder').each(function(ith) {
|
||||||
|
var closer = ith.select('.delete-image-type').pop();
|
||||||
|
if (closer) {
|
||||||
|
closer.observe('click', function(e) {
|
||||||
|
Event.stop(e);
|
||||||
|
if (confirm('Are you sure? Your templates may break after deleting this image type')) {
|
||||||
|
new Effect.Fade(ith, {
|
||||||
|
from: 1,
|
||||||
|
to: 0,
|
||||||
|
afterFinish: function() {
|
||||||
|
ith.parentNode.removeChild(ith);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
var checkboxes = $$('input[name*=default][name*=image_types]');
|
||||||
|
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) {
|
||||||
|
Event.stop(e);
|
||||||
|
new Ajax.Updater('image-type-container', ComicPressAdmin.ajax_uri, {
|
||||||
|
method: 'get',
|
||||||
|
parameters: {
|
||||||
|
'cp[_nonce]': ComicPressAdmin.nonce,
|
||||||
|
'cp[
|
||||||
|
},
|
||||||
|
insertion: 'bottom'
|
||||||
|
});
|
||||||
|
});
|
||||||
|
};
|
||||||
|
}())
|
||||||
|
Loading…
Reference in New Issue
Block a user