diff --git a/admin.inc b/admin.inc new file mode 100644 index 0000000..401c6cd --- /dev/null +++ b/admin.inc @@ -0,0 +1,158 @@ +
+ messages) > 0) { ?> +
+ messages as $message) { ?> +

+ +
+ +

+ +
+
+

Keyboard Navigation Version %s', 'keyboard-navigation'), $plugin_data['Version']) ?>

+ +

John Bintz |

+ +

+ +
    +
  • +
+
+ +
+ + + + fields as $field => $name) { ?> + + + + + + + + + + + +
+
+ +
+ +
+
+
+ +

+

+ Keyboard Navigation uses CSS Selectors to find the hyperlinks on the page that define the previous and next links on the page,', 'keyboard-navigation') ?> + + +

+ +
+ <?php _e('Firebug display of a simple targeting procedure', 'keyboard-navigation') ?> +
+

+ +

+ +
+ a#next-link +
+ +

+ +

+ +
+ div.nav div#next-link-holder a +
+
+
+
+ +

+ Keyboard Navigation extends this slightly so that, if the target element is not a <a href> tag,', 'keyboard-navigation') ?> + +

+ +
+ <?php _e('Firebug display of a more complicated targeting procedure', 'keyboard-navigation') ?> +
+

+ +

+
    +
  • + nth-child:', 'keyboard-navigation') ?> +
    + div#menunav a:nth-child(2) +
    +
  • +
  • + Keyboard Navigation will move up through the DOM tree until it finds <a href="next-page">:', 'keyboard-navigation') ?> +
    + div#menunav a span.next +
    +
  • +
+
+
+
+ +

+ Keyboard Navigation requires that the visitor have JavaScript enabled. This plugin uses', 'keyboard-navigation') ?> + + load their own copies of the Prototype library, both plugins will break.', 'keyboard-navigation') ?> +

+
diff --git a/keyboard_navigation.js b/keyboard-navigation.js similarity index 100% rename from keyboard_navigation.js rename to keyboard-navigation.js diff --git a/keyboard-navigation.php b/keyboard-navigation.php new file mode 100644 index 0000000..e095f50 --- /dev/null +++ b/keyboard-navigation.php @@ -0,0 +1,119 @@ +messages = array(); + $this->fields = array( + 'previous' => __("Previous [Left arrow]", 'keyboard-navigation'), + 'next' => __("Next [Right arrow]", 'keyboard-navigation'), + 'first' => __("First [Shift-Left arrow]", 'keyboard-navigation'), + 'last' => __("Last [Shift-Right arrow]", 'keyboard-navigation'), + ); + + if (isset($_POST['kbnav'])) { + if (is_array($_POST['kbnav'])) { + if (isset($_POST['kbnav']['_nonce'])) { + if (wp_verify_nonce($_POST['kbnav']['_nonce'], 'keyboard-navigation')) { + if (isset($_POST['kbnav']['module'])) { + $method = "handle_update_" . $_POST['kbnav']['module']; + if (method_exists($this, $method)) { $this->{$method}($_POST['kbnav']); } + } + } + } + } + } + } + + function handle_update_options($info) { + $options = array(); + + foreach (array('selectors', 'highlight') as $field) { + if (isset($info[$field])) { $options[$field] = $info[$field]; } + } + + update_option('keyboard-navigation-options', $options); + + $this->messages[] = __('Options updated.', 'keyboard-navigation'); + } + + function KeyboardNavigation() {} + + function footer() { + $plugin_url_root = pathfinding_get_admin_url() . '/' . pathfinding_get_plugin_path(); ?> + + + '; + } + } + + function link_editor() { + $plugin_dir_url = plugin_dir_url(__FILE__); + $nonce = wp_create_nonce('keyboard-navigation'); + $options = get_option('keyboard-navigation-options'); + if (!is_array($options)) { $options = array(); } + + $plugin_data = get_plugin_data(__FILE__); + + include(dirname(__FILE__) . '/admin.inc'); + } +} + +$keyboard_navigation = new KeyboardNavigation(); +add_action('init', array(&$keyboard_navigation, 'init')); + +?> \ No newline at end of file diff --git a/keyboard_navigation.php b/keyboard_navigation.php deleted file mode 100644 index 080930e..0000000 --- a/keyboard_navigation.php +++ /dev/null @@ -1,220 +0,0 @@ -messages = array(); - $this->fields = array( - 'previous' => __("Previous [Left arrow]", 'keyboard-navigation'), - 'next' => __("Next [Right arrow]", 'keyboard-navigation'), - 'first' => __("First [Shift-Left arrow]", 'keyboard-navigation'), - 'last' => __("Last [Shift-Right arrow]", 'keyboard-navigation'), - ); - - if (isset($_POST['action'])) { - if ($_POST['action'] == "update-fields") { - $any_updated = false; - foreach (array_keys($this->fields) as $field) { - if (isset($_POST["selector-${field}"])) { - update_option("keyboard-navigation-selector-${field}", $_POST["selector-${field}"]); - $any_updated = true; - } - } - update_option("keyboard-navigation-highlight-selected-elements", ($_POST['highlight-selected-elements'] ? "1" : "0")); - if ($any_updated) { $this->messages[] = "Selectors updated."; } - } - } - } - - function footer() { - $plugin_url_root = pathfinding_get_admin_url() . '/' . pathfinding_get_plugin_path(); ?> - - - - -
- messages) > 0) { ?> -
- messages as $message) { ?> -

- -
- -

- -
-
- - - fields as $field => $name) { ?> - - - - - - - - - - - -
- " />
Highlight selected elements on theme? - /> - (overlay yellow boxes on selected theme elements, and show missing selector alerts in Firebug console or in alert dialogs) -
- -
-
- -
-

Keyboard Navigation Version 0.2

- -

Copyright © 2008 John Bintz | - Released under the GNU GPL

- -

Need some sane defaults for your theme? Click one of the links below to populate the selectors on the left:

- - - -

Are you a theme author? Send your theme's navigation defaults to John Bintz and get them included!

-
-
- -

How does this work?

-

Keyboard Navigation uses CSS3 Selectors to find the hyperlinks on the page that define the previous and next links on the page, and then uses JavaScript to assign the act of hitting the left and right arrow keys on the keyboard to clicking those links. This is exactly the same approach that you would use to style a specific element on the page:

- -
- Firebug display of a simple targeting procedure -
-

Targeting the <a href="next-page"> on this page is quite easy — provide the CSS selector for the id of the element:

- -
- a#next-link -
- -

If the <a href> does not have an id, but does have a class, or is the only child of a particular element, you can use syntax like:

- -
- div.nav div#next-link-holder a -
-
-
- -

Keyboard Navigation extends this slightly so that, if the target element is not a <a href> tag, Keyboard Navigation will move up through the tree from the found element until an <a href> is found:

- -
- Firebug display of a more complicated targeting procedure -
-

You have two approaches for identifying the <a href="next-page"> tag:

-
    -
  • Using CSS3 selectors, you can use nth-child: -
    - div#menunav a:nth-child(2) -
    -
  • -
  • Using more familiar CSS syntax, target the <span class="next"> element, and Keyboard Navigation will move up through the DOM tree until it finds <a href="next-page">: -
    - div#menunav a span.next -
    -
  • -
-
-
- -

Keyboard Navigation requires that the visitor have JavaScript enabled. This plugin uses - the Prototype JavaScript library, and including it will increase the size of your total site download. Additionally, - if other plugins load their own copies of the Prototype library, both plugins will break.

-
- \ No newline at end of file diff --git a/styles.css b/styles.css index 08fc114..0e2102d 100644 --- a/styles.css +++ b/styles.css @@ -7,10 +7,8 @@ div.image-holder { overflow: hidden } -div.image-holder div { - float: left; - display: inline; - width: 440px; +div.image-holder div p { + margin-top: 0 } div.image-holder img { @@ -24,30 +22,32 @@ div#top-holder { } div#top-holder form { - float: left; - display: inline; - width: 650px; + margin-right: 300px +} + +div#top-holder th { + padding-left: 0 } div#top-holder form input[type="text"] { - width: 440px + width: 100% } -div#top-holder form input[type="submit"] { - width: 250px -} - -div#top-holder div { - float: left; +div#top-information { + float: right; display: inline; - width: 295px; + width: 270px; border: solid #ddd 1px; - margin-left: 10px; - margin-top: 10px; padding: 10px; background: #dfe } div#top-holder div p { margin-top: 0 -} \ No newline at end of file +} + +div#top-holder .form-table { + clear: none +} + +.clear { clear: both } \ No newline at end of file diff --git a/wordpress_pathfinding.php b/wordpress_pathfinding.php deleted file mode 100644 index 69eb990..0000000 --- a/wordpress_pathfinding.php +++ /dev/null @@ -1,24 +0,0 @@ -domain . $site->path); - } else { - return get_option('home'); - } -} - -function pathfinding_get_admin_url() { - if (function_exists('get_current_site')) { // WPMU - return cpm_get_home_url(); - } else { - return get_option('siteurl'); - } -} - -function pathfinding_get_plugin_path() { - return (defined("MUPLUGINDIR") ? MUPLUGINDIR : PLUGINDIR) . '/' . preg_replace('#^.*/([^\/]*)#', '\\1', dirname(plugin_basename(__FILE__))); -} - -?> \ No newline at end of file