Browse files

make .less and .coffee editable in Editor

  • Loading branch information...
1 parent 8fb2777 commit 7a5793925c26ea10e048cd7a7f9fa054a6a558ca @WraithKenny WraithKenny committed May 18, 2012
Showing with 21 additions and 13 deletions.
  1. +6 −0 includes/class.SnS_Admin_Code_Editor.php
  2. +2 −0 js/code-editor.js
  3. +13 −13 scripts-n-styles.php
View
6 includes/class.SnS_Admin_Code_Editor.php
@@ -11,7 +11,13 @@ class SnS_Admin_Code_Editor
function init() {
add_action( 'admin_head-theme-editor.php', array( __CLASS__, 'styles' ) );
add_action( 'admin_head-plugin-editor.php', array( __CLASS__, 'styles' ) );
+ add_filter( 'editable_extensions', array( __CLASS__, 'extend' ) );
+ }
+ function extend( $editable_extensions ) {
+ $editable_extensions[] = 'less';
+ $editable_extensions[] = 'coffee';
+ return $editable_extensions;
}
function styles() {
View
2 js/code-editor.js
@@ -27,6 +27,8 @@ jQuery( document ).ready( function( $ ) {
config.mode = "css";
else if ( "less" == fileType )
config.mode = "less";
+ else if ( "coffee" == fileType )
+ config.mode = "coffeescript";
else if ( "html" == fileType || "htm" == fileType )
config.mode = "html";
else if ( "php" == fileType )
View
26 scripts-n-styles.php
@@ -209,17 +209,17 @@ function register() {
wp_register_script( 'chosen', $chosen_dir . 'chosen.jquery.min.js', array( 'jquery' ), $chosen_version, true );
wp_register_style( 'chosen', $chosen_dir . 'chosen.css', array(), $chosen_version );
- wp_register_script( 'codemirror', $cm_dir . 'lib/codemirror.js', array(), $cm_version );
- wp_register_script( 'codemirror-css', $cm_dir . 'mode/css/css.js', array( 'codemirror' ), $cm_version );
- wp_register_script( 'codemirror-coffee', $cm_dir . 'mode/coffeescript/coffeescript.js', array( 'codemirror' ), $cm_version );
- wp_register_script( 'codemirror-less', $cm_dir . 'mode/less/less.js', array( 'codemirror' ), $cm_version );
- wp_register_script( 'codemirror-javascript', $cm_dir . 'mode/javascript/javascript.js', array( 'codemirror' ), $cm_version );
- wp_register_script( 'codemirror-xml', $cm_dir . 'mode/xml/xml.js', array( 'codemirror' ), $cm_version );
- wp_register_script( 'codemirror-clike', $cm_dir . 'mode/clike/clike.js', array( 'codemirror' ), $cm_version );
- wp_register_script( 'codemirror-markdown', $cm_dir . 'mode/markdown/markdown.js', array( 'codemirror-xml' ), $cm_version );
- wp_register_script( 'codemirror-gfm', $cm_dir . 'mode/gfm/gfm.js', array( 'codemirror-php', 'codemirror-htmlmixed' ), $cm_version );
- wp_register_script( 'codemirror-htmlmixed', $cm_dir . 'mode/htmlmixed/htmlmixed.js', array( 'codemirror-xml', 'codemirror-css', 'codemirror-javascript' ), $cm_version );
- wp_register_script( 'codemirror-php', $cm_dir . 'mode/php/php.js', array( 'codemirror-xml', 'codemirror-css', 'codemirror-javascript', 'codemirror-clike' ), $cm_version );
+ wp_register_script( 'codemirror', $cm_dir . 'lib/codemirror.js', array(), $cm_version );
+ wp_register_script( 'codemirror-css', $cm_dir . 'mode/css/css.js', array( 'codemirror' ), $cm_version );
+ wp_register_script( 'codemirror-coffeescript', $cm_dir . 'mode/coffeescript/coffeescript.js', array( 'codemirror' ), $cm_version );
+ wp_register_script( 'codemirror-less', $cm_dir . 'mode/less/less.js', array( 'codemirror' ), $cm_version );
+ wp_register_script( 'codemirror-javascript', $cm_dir . 'mode/javascript/javascript.js', array( 'codemirror' ), $cm_version );
+ wp_register_script( 'codemirror-xml', $cm_dir . 'mode/xml/xml.js', array( 'codemirror' ), $cm_version );
+ wp_register_script( 'codemirror-clike', $cm_dir . 'mode/clike/clike.js', array( 'codemirror' ), $cm_version );
+ wp_register_script( 'codemirror-markdown', $cm_dir . 'mode/markdown/markdown.js', array( 'codemirror-xml' ), $cm_version );
+ wp_register_script( 'codemirror-gfm', $cm_dir . 'mode/gfm/gfm.js', array( 'codemirror-php', 'codemirror-htmlmixed' ), $cm_version );
+ wp_register_script( 'codemirror-htmlmixed', $cm_dir . 'mode/htmlmixed/htmlmixed.js', array( 'codemirror-xml', 'codemirror-css', 'codemirror-javascript' ), $cm_version );
+ wp_register_script( 'codemirror-php', $cm_dir . 'mode/php/php.js', array( 'codemirror-xml', 'codemirror-css', 'codemirror-javascript', 'codemirror-clike' ), $cm_version );
wp_register_style( 'codemirror-default', $cm_dir . 'lib/codemirror.css', array(), $cm_version );
foreach ( self::$cm_themes as $theme ) if ( 'default' !== $theme )
@@ -231,12 +231,12 @@ function register() {
wp_register_style( 'codemirror-theme', $cm_dir . "theme/$cm_theme.css", array( 'codemirror-default' ), $cm_version );
wp_register_style( 'sns-options', $css . 'options-styles.css', array(), self::VERSION );
- wp_register_script( 'sns-global-page', $js . 'global-page.js', array( 'jquery', 'codemirror-less', 'codemirror-css', 'codemirror-javascript', 'less.js', 'chosen' ), self::VERSION, true );
+ wp_register_script( 'sns-global-page', $js . 'global-page.js', array( 'jquery', 'codemirror-less', 'codemirror-coffeescript', 'codemirror-css', 'codemirror-javascript', 'less.js', 'coffeescript', 'chosen' ), self::VERSION, true );
wp_register_script( 'sns-settings-page', $js . 'settings-page.js', array( 'jquery', 'codemirror-php' ), self::VERSION, true );
wp_register_style( 'sns-meta-box', $css . 'meta-box.css', array( 'codemirror-theme' ), self::VERSION );
wp_register_script( 'sns-meta-box', $js . 'meta-box.js', array( 'editor', 'jquery-ui-tabs', 'codemirror-less', 'codemirror-htmlmixed', 'chosen' ), self::VERSION, true );
wp_register_style( 'sns-code-editor', $css . 'code-editor.css', array( 'codemirror-theme' ), self::VERSION );
- wp_register_script( 'sns-code-editor', $js . 'code-editor.js', array( 'editor', 'jquery-ui-tabs', 'codemirror-less', 'codemirror-htmlmixed', 'codemirror-php', 'codemirror-markdown' ), self::VERSION, true );
+ wp_register_script( 'sns-code-editor', $js . 'code-editor.js', array( 'editor', 'jquery-ui-tabs', 'codemirror-less', 'codemirror-coffeescript', 'codemirror-htmlmixed', 'codemirror-php', 'codemirror-markdown' ), self::VERSION, true );
}
/**

0 comments on commit 7a57939

Please sign in to comment.