Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Admin functions, including custom CSS and JavaScript. JavaScript file…

…s includes a method to switch which boxes are visible per selected template.
  • Loading branch information...
commit 5b47a0c6b4394cd932ccb2f74e1c47fbbd4cffec 1 parent cbaa103
Trevor authored
View
12 themes/surface/css/admin.css
@@ -0,0 +1,12 @@
+body.js #secondary_column {
+ display: none;
+}
+
+div.postbox .tmce-active iframe {
+ background-color: #fff;
+}
+#post_top_story .checkbox,
+#featured .checkbox,
+#homepage_sidebar .checkbox {
+ background-color: transparent;
+}
View
58 themes/surface/functions.admin.php
@@ -0,0 +1,58 @@
+<?php
+
+/*
+Component: Admin
+Description: WordPress functions for the admin area
+Author: Surface / Trevor Morris
+Author URI: http://www.madebysurface.co.uk
+Version: 0.0.1
+*/
+
+/**
+ * admin_custom_js_css
+ * @desc Adds custom CSS and JavaScript to the CMS
+ */
+function admin_custom_js_css() {
+ // custom JS and CSS
+ wp_enqueue_script('app', get_stylesheet_directory_uri() . '/js/app.js', array('jquery'), null, true);
+ wp_enqueue_script('custom-admin-js', get_stylesheet_directory_uri() . '/js/site.admin.js', array('jquery', 'app'), null, true);
+ wp_enqueue_style('custom-admin-css', get_stylesheet_directory_uri() . '/css/admin.css', array(), null);
+}
+add_action('admin_init', 'admin_custom_js_css');
+
+/**
+ * base_admin_body_class
+ * @see http://www.kevinleary.net/customizing-wordpress-admin-css-javascript/
+ * @param string $classes
+ * @return string
+ */
+function base_admin_body_class($classes) {
+ if(is_admin()) {
+ // Current action
+ if(isset($_GET['action']) ) {
+ $classes .= ' action-' . $_GET['action'];
+ }
+ // Current post ID
+ if(isset($_GET['post']) ) {
+ $classes .= ' post-' . $_GET['post'];
+ }
+ // New post type & listing page
+ if(isset($_GET['post_type'])) {
+ $classes .= ' post-type-' . $_GET['post_type'];
+ }
+
+ // Editting a post type
+ $post_query = $_GET['post'];
+ if(isset($post_query)) {
+ $current_post_edit = get_post($post_query);
+ $current_post_type = $current_post_edit->post_type;
+ if(!empty($current_post_type)) {
+ $classes .= ' ';
+ $classes .= 'post-type-'.$current_post_type;
+ }
+ }
+ }
+ // Return the $classes array
+ return $classes;
+}
+add_filter('admin_body_class', 'base_admin_body_class');
View
76 themes/surface/js/site.admin.js
@@ -0,0 +1,76 @@
+'use strict';
+
+/*global window, document, console, jQuery, App:true, google, _gaq */
+
+/**
+ * @desc Specific application options
+ */
+App = (function (App, $) {
+
+ App.options = $.extend({}, App.options, {
+ timeout: [],
+ className: {
+ active: 'active'
+ }
+ });
+
+ return App;
+
+}(typeof App === 'object' ? App : {}, jQuery));
+
+/**
+ * @desc Specific application page autoload methods
+ */
+App = (function (App, $) {
+
+ App.routes = $.extend({}, App.routes, {
+ common: {
+ initialize: function () {},
+ finalize: function () {
+ var elements = {
+ show: {
+ 'page-two-column.php': $('#secondary_column')
+ },
+ hide: {
+ 'front-page.php': $('#postexcerpt'),
+ 'page-parent.php': $('#subtitle, #postimagediv, #postdivrich, #postexcerpt')
+ }
+ }
+
+ $('#page_template').bind('change', function (event) {
+ var $select = $(event.target).closest('select'),
+ value = $select.val();
+
+ $.each(elements.show, function (i, element) {
+ $(element).hide();
+ });
+ $.each(elements.hide, function (i, element) {
+ $(element).show();
+ });
+
+ if (typeof elements.show[value] !== 'undefined') {
+ elements.show[value].show();
+ }
+ if (typeof elements.hide[value] !== 'undefined') {
+ elements.hide[value].hide();
+ }
+
+ }).trigger('change');
+ }
+ }
+ });
+
+ return App;
+
+}(typeof App === 'object' ? App : {}, jQuery));
+
+/**
+ * @desc Start the application
+ */
+if (typeof jQuery !== 'undefined') {
+ (function (App, $) {
+ $(document).ready(function () {
+ App.util.route.start(App.routes);
+ });
+ }(typeof App === 'object' ? App : {}, jQuery));
+}
Please sign in to comment.
Something went wrong with that request. Please try again.