Plugin Directory

Changeset 737277


Ignore:
Timestamp:
07/07/2013 07:34:43 AM (13 years ago)
Author:
rewish
Message:

WP Emmet 0.2 Released

Location:
wp-emmet/trunk
Files:
46 added
3 deleted
8 edited

Legend:

Unmodified
Added
Removed
  • wp-emmet/trunk

    • Property svn:ignore
      •  

        old new  
        33.DS_Store
        44Thumbs.db
         5.idea
  • wp-emmet/trunk/WP/Emmet.php

    r705984 r737277  
    66require_once dirname(__FILE__) . '/Emmet/Lang.php';
    77require_once dirname(__FILE__) . '/Emmet/Options.php';
     8require_once dirname(__FILE__) . '/Emmet/FormHelper.php';
     9require_once dirname(__FILE__) . '/Emmet/Migration.php';
     10require_once dirname(__FILE__) . '/Emmet/CodeMirror.php';
    811
    912class WP_Emmet {
     
    1215     * @var WP_Emmet_Options
    1316     */
    14     protected $Options;
     17    public $Options;
    1518
    1619    /**
     
    2124
    2225    /**
     26     * CodeMirror instance
     27     * @var WP_Emmet_CodeMirror
     28     */
     29    public $CodeMirror;
     30
     31    /**
     32     * Get the Asset URL
     33     *
     34     * @param $name
     35     * @return string
     36     */
     37    public static function assetURL($name) {
     38        return plugin_dir_url(WP_EMMET_FILE) . "assets/$name";
     39    }
     40
     41    /**
     42     * Get the Asset path
     43     *
     44     * @param $name
     45     * @return string
     46     */
     47    public static function assetPath($name) {
     48        return plugin_dir_path(WP_EMMET_FILE) . "assets/$name";
     49    }
     50
     51    /**
     52     * Register style
     53     *
     54     * @param $domain
     55     * @param $src
     56     * @param array $options
     57     */
     58    public static function registerStyle($domain, $src, Array $options = array()) {
     59        $options += array('deps' => array(), 'ver' => false, 'media' => 'all');
     60        wp_register_style($domain, $src, $options['deps'], $options['ver'], $options['media']);
     61    }
     62
     63    /**
     64     * Register script
     65     *
     66     * @param $domain
     67     * @param $src
     68     * @param array $options
     69     */
     70    public static function registerScript($domain, $src, Array $options = array()) {
     71        $options += array('deps' => array(), 'ver' => false, 'in_footer' => true);
     72        wp_register_script($domain, $src, $options['deps'], $options['ver'], $options['in_footer']);
     73    }
     74
     75    /**
    2376     * Constructor
    2477     */
    2578    public function __construct() {
     79        $this->setupActions();
     80    }
     81
     82    /**
     83     * Initialize
     84     */
     85    public function init() {
    2686        $this->Lang = new WP_Emmet_Lang();
    2787        $this->Options = new WP_Emmet_Options();
     88        $this->CodeMirror = new WP_Emmet_CodeMirror();
     89        $this->migrate();
     90    }
    2891
    29         $this->setupActions();
     92    /**
     93     * Migrate
     94     */
     95    public function migrate() {
     96        WP_Emmet_Migration::migrate($this);
    3097    }
    3198
     
    34101     */
    35102    public function setupActions() {
    36         add_action('admin_enqueue_scripts', array($this, 'enqueueEmmet'));
    37         add_action('admin_print_footer_scripts', array($this, 'applyEmmet'));
     103        add_action('init', array($this, 'init'));
     104        add_action('admin_print_styles', array($this, 'printStyles'));
     105        add_action('admin_enqueue_scripts', array($this, 'enqueueScripts'));
     106        add_action('admin_print_footer_scripts', array($this, 'applyScripts'), 1);
    38107    }
    39108
    40109    /**
    41      * Enqueue the Emmet
     110     * Print styles
    42111     */
    43     public function enqueueEmmet() {
    44         wp_enqueue_script(WP_EMMET_DOMAIN, $this->getEmmetURL(), array('underscore'), false, true);
     112    public function printStyles() {
     113        if ($this->isCodeMirrorMode()) {
     114            $this->CodeMirror->enqueueStyle();
     115            $this->CodeMirror->enqueueStyle($this->Options->get('codemirror.theme'));
     116        }
     117        wp_enqueue_style('wp_emmet', self::assetURL('css/wp_emmet.css'));
    45118    }
    46119
    47120    /**
    48      * Apply the Emmet
     121     * Enqueue scripts
    49122     */
    50     public function applyEmmet() {
    51         $shortcuts = $this->Options->get('shortcuts');
    52         require_once WP_EMMET_VIEW_DIR . DIRECTORY_SEPARATOR . 'apply_emmet.php';
     123    public function enqueueScripts() {
     124        $type = $this->editorType();
     125        if ($this->isCodeMirrorMode()) {
     126            $this->CodeMirror->enqueueAllScripts();
     127        }
     128        wp_enqueue_script('wp_wmmet', self::assetURL("js/wp_emmet.js"));
     129        wp_enqueue_script('emmet', self::assetURL("js/{$type}/emmet.js"), array('underscore'), false, true);
    53130    }
    54131
    55132    /**
    56      * Get the Emmet URL
     133     * Apply scripts
     134     */
     135    public function applyScripts() {
     136        $shortcuts = $this->Options->get('shortcuts');
     137        $type = $this->editorType();
     138        require_once WP_EMMET_VIEW_DIR . DIRECTORY_SEPARATOR . "apply_for_{$type}.php";
     139    }
     140
     141    /**
     142     * Editor type
    57143     *
    58144     * @return string
    59145     */
    60     public function getEmmetURL() {
    61         return plugin_dir_url(WP_EMMET_FILE) . 'js/emmet.js';
     146    protected function editorType() {
     147        return $this->isCodeMirrorMode() ? 'codemirror' : 'textarea';
    62148    }
    63149
    64150    /**
    65      * Get option
     151     * Is CodeMirror mode
    66152     *
    67      * @param string $key
    68      * @return mixed
     153     * @return bool
    69154     */
    70     public function getOption($key) {
    71         return $this->Options->get($key);
     155    protected function isCodeMirrorMode() {
     156        return $this->Options->get('use_codemirror') === '1';
    72157    }
    73158}
  • wp-emmet/trunk/WP/Emmet/Options.php

    r705273 r737277  
    1717
    1818    /**
     19     * Normalized options
     20     * @var array
     21     */
     22    protected $normalizedOptions;
     23
     24    /**
    1925     * Constructor
    2026     *
     
    2329    public function __construct($name = WP_EMMET_DOMAIN) {
    2430        $this->name = $name;
    25         $this->setupOptions();
     31        $this->options = $this->load();
    2632        $this->addAdminMenu();
    2733    }
    2834
    2935    /**
    30      * Setup options
    31      */
    32     public function setupOptions() {
    33         $this->options = array_merge(array(
    34             'variables' => array(
    35                 'indentation' => "\t"
     36     * Load options
     37     */
     38    public function load() {
     39        return array_merge(array(
     40            'use_codemirror' => '1',
     41
     42            'profile' => 'html',
     43
     44            'textarea' => array(
     45                'variables' => array(
     46                    'indentation' => "\t"
     47                ),
     48
     49                'options' => array(
     50                    'syntax' => 'html',
     51                    'use_tab' => '1',
     52                    'pretty_break' => '1'
     53                ),
    3654            ),
    3755
    38             'options' => array(
    39                 'profile' => 'xhtml',
    40                 'syntax' => 'html',
    41                 'use_tab' => true,
    42                 'pretty_break' => true
     56            'codemirror' => array(
     57                'theme' => 'default',
     58
     59                'indentWithTabs' => '1',
     60                'indentUnit' => '2',
     61                'tabSize' => '4',
     62                'smartIndent' => '1',
     63
     64                'lineWrapping' => '',
     65                'lineNumbers' => '1'
    4366            ),
    4467
     
    4972                'Match Pair Outward'       => 'Meta+D',
    5073                'Match Pair Inward'        => 'Shift+Meta+D',
     74                'Matching Pair'            => 'Meta+T',
    5175                'Wrap with Abbreviation'   => 'Shift+Meta+A',
    5276                'Next Edit Point'          => 'Ctrl+Alt+Right',
     
    6690                'Decrement number by 10'  => 'Ctrl+Alt+Down',
    6791
    68                 'Select Next Item'     => 'Meta+.',
    69                 'Select Previous Item' => 'Meta+,',
    70                 'Reflect CSS Value'    => 'Meta+Shift+B'
     92                'Select Next Item'     => 'Shift+Meta+.',
     93                'Select Previous Item' => 'Shift+Meta+,',
     94                'Reflect CSS Value'    => 'Meta+B'
    7195            )
    7296        ), get_option($this->name, array()));
     
    7498
    7599    /**
     100     * Save options
     101     *
     102     * @param array $options
     103     */
     104    public function save(Array $options) {
     105        $this->options = $options;
     106        update_option($this->name, $options);
     107    }
     108
     109    /**
     110     * Set option
     111     *
     112     * @param string $key
     113     * @param mixed $value
     114     * @param boolean $andSave
     115     */
     116    public function set($key, $value, $andSave = true) {
     117        $k = explode('.', $key);
     118        $o = $this->options;
     119
     120        switch (count($k)) {
     121            case 1: $o[$k[0]] = $value; break;
     122            case 2: $o[$k[0]][$k[1]] = $value; break;
     123        }
     124
     125        $andSave && $this->save($o);
     126    }
     127
     128    /**
    76129     * Get option
    77130     *
    78131     * @param string $key
    79      */
    80     public function get($key = null) {
     132     * @param boolean $normalize
     133     */
     134    public function get($key = null, $normalize = false) {
     135        $options = $normalize ? $this->normalizedOptions() : $this->options;
     136
    81137        if (empty($key)) {
    82             return $this->options;
     138            return $options;
    83139        }
    84140
    85141        $keys = explode('.', $key);
    86         $option = $this->options;
     142        $option = $options;
    87143
    88144        do {
     
    103159     * @param string $key
    104160     */
    105     public function toJSON($key) {
    106         return json_encode($this->get($key));
     161    public function toJSON($key = null) {
     162        return json_encode($this->get($key, true));
    107163    }
    108164
     
    125181     */
    126182    public function pageOptions() {
     183        global $wp_emmet;
    127184        $domain = WP_EMMET_DOMAIN;
     185        $form = new WP_Emmet_FormHelper($this->name, $this->options);
     186        $themes = $wp_emmet->CodeMirror->themes;
    128187        require_once WP_EMMET_VIEW_DIR . DIRECTORY_SEPARATOR . 'options.php';
    129188    }
     189
     190    /**
     191     * Normalized options
     192     *
     193     * @return array
     194     */
     195    public function normalizedOptions() {
     196        if ($this->normalizedOptions) {
     197            return $this->normalizedOptions;
     198        }
     199
     200        if ($this->options['use_codemirror']) {
     201            $this->normalizedOptions = $this->normalizedOptionsForCodeMirror();
     202        } else {
     203            $this->normalizedOptions = $this->normalizedOptionsForTextarea();
     204        }
     205
     206        return $this->normalizedOptions;
     207    }
     208
     209    /**
     210     * Normalized options for Textarea
     211     *
     212     * @return array
     213     */
     214    protected function normalizedOptionsForTextarea() {
     215        $options = $this->options;
     216
     217        // Boolean
     218        foreach (array('use_tab' , 'pretty_break') as $key) {
     219            $options['textarea']['options'][$key] = $options['textarea']['options'][$key] === '1';
     220        }
     221
     222        unset($options['codemirror']);
     223
     224        return $options;
     225    }
     226
     227    /**
     228     * Normalized options for CodeMirror
     229     *
     230     * @return array
     231     */
     232    protected function normalizedOptionsForCodeMirror() {
     233        $options = $this->options;
     234
     235        // Boolean
     236        foreach (array('indentWithTabs', 'smartIndent', 'lineWrapping' , 'lineNumbers') as $key) {
     237            $options['codemirror'][$key] = $options['codemirror'][$key] === '1';
     238        }
     239
     240        // Integer
     241        foreach (array('indentUnit', 'tabSize') as $key) {
     242            $options['codemirror'][$key] = (int)$options['codemirror'][$key];
     243        }
     244
     245        // Indent
     246        if ($options['codemirror']['indentWithTabs']) {
     247            $options['codemirror']['indentUnit'] = $options['codemirror']['tabSize'];
     248        }
     249
     250        // Shortcuts
     251        foreach ($options['shortcuts'] as $type => $shortcutKey) {
     252            $options['shortcuts'][$type] = str_replace(
     253                array('+', 'Meta', 'Cmd-Shift'),
     254                array('-', 'Cmd', 'Shift-Cmd'),
     255                $shortcutKey
     256            );
     257        }
     258
     259        unset($options['textarea']);
     260
     261        return $options;
     262    }
    130263}
  • wp-emmet/trunk/langs/ja.po

    r659993 r737277  
    22msgstr ""
    33"Project-Id-Version: WP Emmet\n"
    4 "POT-Creation-Date: 2013-01-27 17:53+0900\n"
    5 "PO-Revision-Date: 2013-01-27 18:51+0900\n"
     4"POT-Creation-Date: 2013-07-03 00:59+0900\n"
     5"PO-Revision-Date: 2013-07-03 00:59+0900\n"
    66"Last-Translator: rewish <rewish.org@gmail.com>\n"
    77"Language-Team: \n"
     
    1010"Content-Type: text/plain; charset=UTF-8\n"
    1111"Content-Transfer-Encoding: 8bit\n"
    12 "X-Generator: Poedit 1.5.4\n"
     12"X-Generator: Poedit 1.5.5\n"
     13"X-Poedit-KeywordsList: __;_e\n"
     14"X-Poedit-Basepath: ../\n"
     15"X-Poedit-SearchPath-0: .\n"
    1316
    14 #: wp-emmet/views/options.php:12
    15 msgid "Options"
    16 msgstr "オプション"
     17#: views/options.php:12
     18msgid "Editor"
     19msgstr "エディタ"
    1720
    18 #: wp-emmet/views/options.php:16
     21#: views/options.php:16
     22msgid "Code Coloring"
     23msgstr "コードカラーリング"
     24
     25#: views/options.php:19
     26msgid "Enable"
     27msgstr "有効化"
     28
     29#: views/options.php:23
    1930msgid "Profile"
    2031msgstr "プロファイル"
    2132
    22 #: wp-emmet/views/options.php:25
     33#: views/options.php:28
    2334msgid "Use tab key"
    2435msgstr "Tabキーを使用"
    2536
    26 #: wp-emmet/views/options.php:29 wp-emmet/views/options.php:37
     37#: views/options.php:31 views/options.php:38
    2738msgid "Use"
    2839msgstr "使用"
    2940
    30 #: wp-emmet/views/options.php:33
     41#: views/options.php:35
    3142msgid "Auto indent"
    32 msgstr "オートインデント"
     43msgstr "自動インデント"
    3344
    34 #: wp-emmet/views/options.php:41
     45#: views/options.php:42
    3546msgid "Indent character"
    36 msgstr "インデント文字"
     47msgstr "タブ文字を使用"
    3748
    38 #: wp-emmet/views/options.php:49
     49#: views/options.php:50
    3950msgid "Use hard tabs"
    4051msgstr "ハードタブを使用"
    4152
    42 #: wp-emmet/views/options.php:67
     53#: views/options.php:55
     54msgid "Theme"
     55msgstr "テーマ"
     56
     57#: views/options.php:59
     58msgid "Tabs and Indents"
     59msgstr "タブとインデント"
     60
     61#: views/options.php:62
     62msgid "Use tab character"
     63msgstr "タブ文字を使用"
     64
     65#: views/options.php:67
     66msgid "Smart indent"
     67msgstr "スマートインデント"
     68
     69#: views/options.php:71
     70msgid "Tab size"
     71msgstr "タブサイズ"
     72
     73#: views/options.php:76
     74msgid "Indent unit"
     75msgstr "インデント幅"
     76
     77#: views/options.php:81
     78msgid "Appearance"
     79msgstr "外観"
     80
     81#: views/options.php:84
     82msgid "Show line numbers"
     83msgstr "行ナンバーを表示"
     84
     85#: views/options.php:89
     86msgid "Line wrapping"
     87msgstr "行を折り返す"
     88
     89#: views/options.php:95
    4390msgid "Shortcuts"
    4491msgstr "ショートカット"
    4592
    46 #: wp-emmet/views/options.php:70
     93#: views/options.php:98
    4794msgid "Override shortcuts"
    48 msgstr "ショートカットを上書きする"
     95msgstr "ショートカットを上書き"
    4996
    50 #: wp-emmet/views/options.php:97
     97#: views/options.php:112
    5198msgid "Save option"
    5299msgstr "オプションを保存"
    53100
    54 #: wp-emmet/views/options.php:101
     101#: views/options.php:116
    55102msgid "Test the Emmet"
    56103msgstr "Emmetをテスト"
    57104
    58 #: wp-emmet/views/options.php:118
     105#: views/options.php:160
    59106msgid "Expand Abbreviation"
    60107msgstr "省略コードの展開"
    61108
    62 #: wp-emmet/views/options.php:119
     109#: views/options.php:161
    63110msgid "Match Pair Outward"
    64111msgstr "タグの外側を選択"
    65112
    66 #: wp-emmet/views/options.php:120
     113#: views/options.php:162
    67114msgid "Match Pair Inward"
    68115msgstr "タグの内側を選択"
    69116
    70 #: wp-emmet/views/options.php:121
     117#: views/options.php:163
    71118msgid "Wrap with Abbreviation"
    72119msgstr "省略コードで包括"
    73120
    74 #: wp-emmet/views/options.php:122
     121#: views/options.php:164
    75122msgid "Next Edit Point"
    76123msgstr "次の編集箇所へ"
    77124
    78 #: wp-emmet/views/options.php:123
     125#: views/options.php:165
    79126msgid "Prev Edit Point"
    80127msgstr "前の編集箇所へ"
    81128
    82 #: wp-emmet/views/options.php:124
     129#: views/options.php:166
    83130msgid "Select Line"
    84131msgstr "行を選択"
    85132
    86 #: wp-emmet/views/options.php:125
     133#: views/options.php:167
    87134msgid "Merge Lines"
    88135msgstr "要素を1行に結合"
    89136
    90 #: wp-emmet/views/options.php:126
     137#: views/options.php:168
    91138msgid "Toggle Comment"
    92139msgstr "コメントアウトの実行/解除"
    93140
    94 #: wp-emmet/views/options.php:127
     141#: views/options.php:169
    95142msgid "Split/Join Tag"
    96143msgstr "タグの結合/分解"
    97144
    98 #: wp-emmet/views/options.php:128
     145#: views/options.php:170
    99146msgid "Remove Tag"
    100147msgstr "タグを削除"
    101148
    102 #: wp-emmet/views/options.php:129
     149#: views/options.php:171
    103150msgid "Evaluate Math Expression"
    104151msgstr "数式を評価"
    105152
    106 #: wp-emmet/views/options.php:130
     153#: views/options.php:172
    107154msgid "Increment number by 1"
    108155msgstr "数値を1増加"
    109156
    110 #: wp-emmet/views/options.php:131
     157#: views/options.php:173
    111158msgid "Decrement number by 1"
    112159msgstr "数値を1減少"
    113160
    114 #: wp-emmet/views/options.php:132
     161#: views/options.php:174
    115162msgid "Increment number by 0.1"
    116163msgstr "数値を0.1増加"
    117164
    118 #: wp-emmet/views/options.php:133
     165#: views/options.php:175
    119166msgid "Decrement number by 0.1"
    120167msgstr "数値を0.1減少"
    121168
    122 #: wp-emmet/views/options.php:134
     169#: views/options.php:176
    123170msgid "Increment number by 10"
    124171msgstr "数値を10増加"
    125172
    126 #: wp-emmet/views/options.php:135
     173#: views/options.php:177
    127174msgid "Decrement number by 10"
    128175msgstr "数値を10減少"
    129176
    130 #: wp-emmet/views/options.php:136
     177#: views/options.php:178
    131178msgid "Select Next Item"
    132179msgstr "次の項目を選択"
    133180
    134 #: wp-emmet/views/options.php:137
     181#: views/options.php:179
    135182msgid "Select Previous Item"
    136183msgstr "前の項目を選択"
    137184
    138 #: wp-emmet/views/options.php:138
     185#: views/options.php:180
    139186msgid "Reflect CSS Value"
    140187msgstr "CSSの値を反映"
     188
     189#, fuzzy
     190#~ msgid "Can be used in Post editor, Theme editor, Plugin editor"
     191#~ msgstr "記事編集、テーマ編集、プラグイン編集で使用できます"
     192
     193#~ msgid "Options"
     194#~ msgstr "オプション"
  • wp-emmet/trunk/readme.txt

    r705984 r737277  
    33Tags: emmet, zen-coding, editor, post, plugin, coding
    44Requires at least: 3.5
    5 Tested up to: 3.5.1
     5Tested up to: 3.5.2
    66Stable tag: trunk
    77License: GPLv2 or later
     
    1212== Description ==
    1313
    14 You can use the [Emmet](http://emmet.io/) in post editor.
     14You can use the [Emmet](http://emmet.io/) in admin page.
     15
     16Support the Code coloring by CodeMirror.
     17
     18Try it!
    1519
    1620[Fork me on GitHub](https://github.com/rewish/wp-emmet) :)
     
    2832== Changelog ==
    2933
     34= 0.2 =
     35* Support the Code coloring by CodeMirror
     36
    3037= 0.1.2 =
    3138* Fix "Add Media" button doesn't works
  • wp-emmet/trunk/views/options.php

    r659993 r737277  
    1 <div class="wrap">
     1<div class="wrap" data-use-editor-type="<?php echo $this->options['use_codemirror'] ? 'codemirror' : 'textarea'; ?>">
    22    <div id="icon-options-general" class="icon32"><br></div>
    33    <h2>Emmet</h2>
     
    1010        </div>
    1111
    12         <h3><?php _e('Options', $domain); ?></h3>
     12        <h3><?php _e('Editor', $domain); ?></h3>
    1313        <table class="form-table">
    1414            <tbody>
    1515                <tr>
    16                     <th><?php _e('Profile', $domain); ?></th>
     16                    <th><?php _e('Code Coloring', $domain); ?></th>
    1717                    <td>
    18                         <select name="<?php echo $this->name; ?>[options][profile]">
    19 <?php                   foreach (array('xhtml', 'html', 'xml', 'plain', 'line') as $profile): ?>
    20                             <option<?php if ($this->options['options']['profile'] === $profile) echo ' selected="selected"'; ?>><?php echo $profile; ?></option>
    21 <?php                   endforeach; ?>
    22                         </select>
    23                 </tr>
    24                 <tr>
    25                     <th><?php _e('Use tab key', $domain); ?></th>
    26                     <td>
    27                         <input type="hidden" name="<?php echo $this->name; ?>[options][use_tab]" value="0">
    28                         <input id="<?php echo $this->name; ?>_op_use_tab" type="checkbox" name="<?php echo $this->name; ?>[options][use_tab]" value="1"<?php if ($this->options['options']['use_tab']) echo ' checked="checked"'; ?>>
    29                         <label for="<?php echo $this->name; ?>_op_use_tab"><?php _e('Use', $domain); ?></label>
     18                        <?php echo $form->checkBoolean('use_codemirror'); ?>
     19                        <?php echo $form->label('use_codemirror', __('Enable', $domain)); ?>
    3020                    </td>
    3121                </tr>
    3222                <tr>
     23                    <th><?php _e('Profile', $domain); ?></th>
     24                    <td><?php echo $form->select('profile', 'xhtml,html,xml,plain,line'); ?></td>
     25                </tr>
     26
     27                <tr data-editor-type="textarea">
     28                    <th><?php _e('Use tab key', $domain); ?></th>
     29                    <td>
     30                        <?php echo $form->checkBoolean('textarea.options.use_tab'); ?>
     31                        <?php echo $form->label('textarea.options.use_tab', __('Use', $domain)); ?>
     32                    </td>
     33                </tr>
     34                <tr data-editor-type="textarea">
    3335                    <th><?php _e('Auto indent', $domain); ?></th>
    3436                    <td>
    35                         <input type="hidden" name="<?php echo $this->name; ?>[options][pretty_break]" value="0">
    36                         <input id="<?php echo $this->name; ?>_op_pretty_break" type="checkbox" name="<?php echo $this->name; ?>[options][pretty_break]" value="1"<?php if ($this->options['options']['pretty_break']) echo ' checked="checked"'; ?>>
    37                         <label for="<?php echo $this->name; ?>_op_pretty_break"><?php _e('Use', $domain); ?></label>
     37                        <?php echo $form->checkBoolean('textarea.options.pretty_break'); ?>
     38                        <?php echo $form->label('textarea.options.pretty_break', __('Use', $domain)); ?>
    3839                    </td>
    3940                </tr>
    40                 <tr>
     41                <tr data-editor-type="textarea">
    4142                    <th><?php _e('Indent character', $domain); ?></th>
    4243                    <td>
    43 <?php               if ($this->options['variables']['indentation'] === "\t"): ?>
    44                         <input type="text" id="<?php echo $this->name; ?>_var_indentation_text" name="<?php echo $this->name; ?>[variables][indentation]" value="" disabled="disabled"  class="small-text">
     44<?php               if ($this->options['textarea']['variables']['indentation'] === "\t"): ?>
     45                            <input type="text" id="<?php echo $this->name; ?>_var_indentation_text" name="<?php echo $this->name; ?>[textarea][variables][indentation]" value="" disabled="disabled"  class="small-text">
    4546<?php               else: ?>
    46                         <input type="text" id="<?php echo $this->name; ?>_var_indentation_text" name="<?php echo $this->name; ?>[variables][indentation]" value="<?php echo $this->options['variables']['indentation']; ?>" class="small-text">
     47                            <input type="text" id="<?php echo $this->name; ?>_var_indentation_text" name="<?php echo $this->name; ?>[textarea][variables][indentation]" value="<?php echo $this->options['textarea']['variables']['indentation']; ?>" class="small-text">
    4748<?php               endif; ?>
    48                         <input type="checkbox" id="<?php echo $this->name; ?>_var_indentation" name="<?php echo $this->name; ?>[variables][indentation]" value="<?php echo "\t"; ?>"<?php if ($this->options['variables']['indentation'] === "\t") echo ' checked="checked"'; ?>>
     49                        <input type="checkbox" id="<?php echo $this->name; ?>_var_indentation" name="<?php echo $this->name; ?>[textarea][variables][indentation]" value="<?php echo "\t"; ?>"<?php if ($this->options['textarea']['variables']['indentation'] === "\t") echo ' checked="checked"'; ?>>
    4950                        <label for="<?php echo $this->name; ?>_var_indentation"><?php _e('Use hard tabs', $domain); ?></label>
     51                    </td>
     52                </tr>
     53
     54                <tr data-editor-type="codemirror">
     55                    <th><?php _e('Theme', $domain); ?></th>
     56                    <td><?php echo $form->select('codemirror.theme', $themes); ?></td>
     57                </tr>
     58                <tr data-editor-type="codemirror">
     59                    <th><?php _e('Tabs and Indents', $domain); ?></th>
     60                    <td>
     61                        <?php echo $form->checkBoolean('codemirror.indentWithTabs'); ?>
     62                        <?php echo $form->label('codemirror.indentWithTabs', __('Use tab character', $domain)); ?>
     63
     64                        <br>
     65
     66                        <?php echo $form->checkBoolean('codemirror.smartIndent'); ?>
     67                        <?php echo $form->label('codemirror.smartIndent', __('Smart indent', $domain)); ?>
     68
     69                        <br>
     70
     71                        <?php echo $form->label('codemirror.tabSize', __('Tab size', $domain)); ?>
     72                        <?php echo $form->numberField('codemirror.tabSize'); ?>
     73
     74                        <br>
     75
     76                        <?php echo $form->label('codemirror.indentUnit', __('Indent unit', $domain)); ?>
     77                        <?php echo $form->numberField('codemirror.indentUnit'); ?>
     78                    </td>
     79                </tr>
     80                <tr data-editor-type="codemirror">
     81                    <th><?php _e('Appearance'); ?></th>
     82                    <td>
     83                        <?php echo $form->checkBoolean('codemirror.lineNumbers'); ?>
     84                        <?php echo $form->label('codemirror.lineNumbers', __('Show line numbers', $domain)); ?>
     85
     86                        <br>
     87
     88                        <?php echo $form->checkBoolean('codemirror.lineWrapping'); ?>
     89                        <?php echo $form->label('codemirror.lineWrapping', __('Line wrapping', $domain)); ?>
    5090                    </td>
    5191                </tr>
     
    91131<script>
    92132jQuery(function($) {
    93     var $shortcuts = $('.<?php echo $this->name; ?>_shortcuts'),
    94         shortcut = emmet.require('shortcut');
     133    var $shortcuts = $('.<?php echo $this->name; ?>_shortcuts');
     134
     135    $('#<?php echo $form->id('use_codemirror'); ?>').on('click', function() {
     136        $('[data-use-editor-type]').attr('data-use-editor-type', this.checked ? 'codemirror' : 'textarea');
     137    });
    95138
    96139    $('#<?php echo $this->name; ?>_var_indentation').click(function() {
     
    109152            $shortcuts.hide();
    110153        }
    111     });
    112 
    113     $shortcuts.find('input[type="text"]').each(function() {
    114         var $self = $(this),
    115             $kbd = $(document.createElement('kbd'));
    116         $kbd.text(shortcut.format($self.val()));
    117         $self.after($kbd);
    118154    });
    119155});
  • wp-emmet/trunk/wp-emmet.php

    r705957 r737277  
    44Plugin URI: https://github.com/rewish/wp-emmet
    55Description: Emmet (ex-Zen Coding) for WordPress.
    6 Version: 0.1.2
     6Version: 0.2
    77Author: rewish
    88Author URI: https://github.com/rewish
Note: See TracChangeset for help on using the changeset viewer.