Changeset 770


Ignore:
Timestamp:
01/22/13 03:00:08 (2 years ago)
Author:
ofer
Message:

Allow jQueryUI version to be overriden, start of context sensetive help in admin pages

Location:
trunk/WordPress/plugin/transposh
Files:
1 added
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/WordPress/plugin/transposh/js/admin/languages.js

    r753 r770  
    1 /*  Copyright © 2009-2010 Transposh Team (website : http://transposh.org) 
     1/*  Copyright © 2009-2013 Transposh Team (website : http://transposh.org) 
    22 * 
    33 *      This program is free software; you can redistribute it and/or modify 
  • trunk/WordPress/plugin/transposh/js/admin/utils.js

    r755 r770  
    1 /*  
    2  * To change this template, choose Tools | Templates 
    3  * and open the template in the editor. 
    4  */ 
    5  
    6  
    71(function ($) { // closure 
    82    $(function() { 
  • trunk/WordPress/plugin/transposh/js/transposh.js

    r750 r770  
    3333    loadingmsn = 0 
    3434    ; 
    35  
    36     // set base uri for jQueryUI 
    37     t_jp.jQueryUI = 'http://ajax.googleapis.com/ajax/libs/jqueryui/1.9.2/'; 
    3835 
    3936    // This function fixes the page, it gets a token and translation and fixes this, 
     
    348345 
    349346    $(function () { 
    350             // set a global binglang (if needed) 
    351             if (t_jp.msn) { 
    352                 t_jp.binglang = t_jp.lang; 
    353                 if (t_jp.binglang === 'zh') { 
    354                     t_jp.binglang = 'zh-chs'; 
    355                 } else if (t_jp.binglang === 'zh-tw') { 
    356                     t_jp.binglang = 'zh-cht'; 
    357                 } else if (t_jp.binglang === 'mw') { 
    358                     t_jp.binglang = 'mww'; 
    359                 } 
    360             } 
    361  
    362             // this is the set_default_language function 
    363             // attach a function to the set_default_language link if its there 
    364             $('.' + t_jp_prefix + 'setdeflang').click(function () { 
    365                 $.ajax({ 
    366                     url: t_jp.ajaxurl, 
    367                     data: { 
    368                         action: 'tp_cookie' 
    369                     }, 
    370                     cache: false 
    371                 } );               
    372                 $('.' + t_jp_prefix + 'setdeflang').hide("slow"); 
    373                 return false; 
    374             }); 
    375  
    376             // how many phrases are yet untranslated 
    377             possibly_translateable = $("." + t_jp_prefix + '[data-source=""]').size(); 
    378  
    379             //now = new Date(); 
    380             // we make sure script sub loaded are cached 
    381             $.ajaxSetup({ 
    382                 cache: true 
    383             }); 
    384             // was: we'll only auto-translate and load the stuff if we either have more than 5 candidate translations, or more than one at 4am, and this language is supported... 
    385             // we'll translate if there's any candidate...? 
    386             if // ((possibly_translateable > 5 || (now.getHours() === 4 && possibly_translateable > 0)) && 
    387             (possibly_translateable && !t_jp.noauto && (t_jp.google || t_jp.msn || t_jp.apertium)) { 
    388                 // if we have a progress bar, we need to load the jqueryui before the auto translate, after the google was loaded, otherwise we can just go ahead 
    389                 if (t_jp.progress) { 
    390                     test_for_jqueryui(function () { 
    391                         create_progress_bar(); 
    392                         do_auto_translate(); 
    393                     }); 
    394                 } else { 
     347        // set a global binglang (if needed) 
     348        if (t_jp.msn) { 
     349            t_jp.binglang = t_jp.lang; 
     350            if (t_jp.binglang === 'zh') { 
     351                t_jp.binglang = 'zh-chs'; 
     352            } else if (t_jp.binglang === 'zh-tw') { 
     353                t_jp.binglang = 'zh-cht'; 
     354            } else if (t_jp.binglang === 'mw') { 
     355                t_jp.binglang = 'mww'; 
     356            } 
     357        } 
     358 
     359        // this is the set_default_language function 
     360        // attach a function to the set_default_language link if its there 
     361        $('.' + t_jp_prefix + 'setdeflang').click(function () { 
     362            $.ajax({ 
     363                url: t_jp.ajaxurl, 
     364                data: { 
     365                    action: 'tp_cookie' 
     366                }, 
     367                cache: false 
     368            } );               
     369            $('.' + t_jp_prefix + 'setdeflang').hide("slow"); 
     370            return false; 
     371        }); 
     372 
     373        // how many phrases are yet untranslated 
     374        possibly_translateable = $("." + t_jp_prefix + '[data-source=""]').size(); 
     375 
     376        //now = new Date(); 
     377        // we make sure script sub loaded are cached 
     378        $.ajaxSetup({ 
     379            cache: true 
     380        }); 
     381        // was: we'll only auto-translate and load the stuff if we either have more than 5 candidate translations, or more than one at 4am, and this language is supported... 
     382        // we'll translate if there's any candidate...? 
     383        if // ((possibly_translateable > 5 || (now.getHours() === 4 && possibly_translateable > 0)) && 
     384        (possibly_translateable && !t_jp.noauto && (t_jp.google || t_jp.msn || t_jp.apertium)) { 
     385            // if we have a progress bar, we need to load the jqueryui before the auto translate, after the google was loaded, otherwise we can just go ahead 
     386            if (t_jp.progress) { 
     387                test_for_jqueryui(function () { 
     388                    create_progress_bar(); 
    395389                    do_auto_translate(); 
    396                 } 
    397             } 
    398  
    399             // this is the part when we have editor support 
    400             if (t_jp.edit) { 
    401                 $.getScript(t_jp.plugin_url + '/js/transposhedit.js'); 
    402             } 
    403         }); 
     390                }); 
     391            } else { 
     392                do_auto_translate(); 
     393            } 
     394        } 
     395 
     396        // this is the part when we have editor support 
     397        if (t_jp.edit) { 
     398            $.getScript(t_jp.plugin_url + '/js/transposhedit.js'); 
     399        } 
     400    }); 
    404401}(jQuery)); // end of closure 
  • trunk/WordPress/plugin/transposh/transposh.php

    r768 r770  
    148148                tp_logger(preg_replace('|^' . preg_quote(WP_PLUGIN_DIR, '|') . '/|', '', __FILE__), 4); // includes transposh dir and php 
    149149 
     150             
    150151// TODO: get_class_methods to replace said mess, other way? 
    151152        add_filter('plugin_action_links_' . preg_replace('|^' . preg_quote(WP_PLUGIN_DIR, '|') . '/|', '', __FILE__), array(&$this, 'plugin_action_links')); 
     
    769770        if ($this->options->widget_progressbar || $this->edit_mode) { 
    770771            $script_params['theme'] = $this->options->widget_theme; 
     772            if ($this->options->jqueryui_override) { 
     773                $script_params['jQueryUI'] = 'http://ajax.googleapis.com/ajax/libs/jqueryui/' . $this->options->jqueryui_override . '/'; 
     774            } else { 
     775                $script_params['jQueryUI'] = 'http://ajax.googleapis.com/ajax/libs/jqueryui/' . JQUERYUI_VER . '/'; 
     776            } 
    771777        } 
    772778 
  • trunk/WordPress/plugin/transposh/wp/transposh_admin.php

    r766 r770  
    150150            case "tp_advanced": 
    151151                $this->transposh->options->enable_url_translate = TP_FROM_POST; 
     152                $this->transposh->options->jqueryui_override = TP_FROM_POST; 
    152153                $this->transposh->options->parser_dont_break_puncts = TP_FROM_POST; 
    153154                $this->transposh->options->parser_dont_break_numbers = TP_FROM_POST; 
     
    260261                wp_localize_script("transposh_backend", "t_be", $script_params); 
    261262        } 
     263        wp_enqueue_script('transposh_context_help', $this->transposh->transposh_plugin_url . '/' . TRANSPOSH_DIR_JS . '/admin/contexthelp.js', array('jquery'), TRANSPOSH_PLUGIN_VER, true); 
    262264        wp_enqueue_style('transposh_admin', $this->transposh->transposh_plugin_url . '/' . TRANSPOSH_DIR_CSS . '/admin.css'); ///, array('transposh'), TRANSPOSH_PLUGIN_VER, true) 
    263265    } 
     
    279281            // retrieve the function output and set it as tab content 
    280282            'content' => $this->on_contextual_help())); 
     283        $screen->add_help_tab(array( 
     284            'id' => 'keys', // This should be unique for the screen. 
     285            'title' => __('Engine keys', TRANSPOSH_TEXT_DOMAIN), 
     286            // retrieve the function output and set it as tab content 
     287            'content' => __('Will write something about keys...', TRANSPOSH_TEXT_DOMAIN))); 
    281288        if ($this->page == 'tp_main') { 
    282289            add_screen_option('layout_columns', array('max' => 4, 'default' => 2)); 
     
    464471        $this->textinput($this->transposh->options->msn_key_o 
    465472                , array('bingicon.png', __('MSN API key', TRANSPOSH_TEXT_DOMAIN)) 
    466                 , __('API Key', TRANSPOSH_TEXT_DOMAIN)); 
     473                , __('API Key', TRANSPOSH_TEXT_DOMAIN), 35, 'keys'); 
    467474        $this->textinput($this->transposh->options->google_key_o 
    468475                , array('googleicon.png', __('Google API key', TRANSPOSH_TEXT_DOMAIN)) 
     
    517524    function tp_advanced() { 
    518525        $this->checkbox($this->transposh->options->enable_url_translate_o, __('Enable url translation', TRANSPOSH_TEXT_DOMAIN) . ' (' . __('experimental', TRANSPOSH_TEXT_DOMAIN) . ')', __('Allow translation of permalinks and urls', TRANSPOSH_TEXT_DOMAIN)); 
    519  
     526        $this->textinput($this->transposh->options->jqueryui_override_o, __('Override jQueryUI version', TRANSPOSH_TEXT_DOMAIN), __('Version', TRANSPOSH_TEXT_DOMAIN)); 
    520527        $this->section(__('Parser related settings', TRANSPOSH_TEXT_DOMAIN) 
    521528                , __('This is extremely dangerous, will break your current translations, and might cause severe hickups, only proceed if you really know what you are doing.', TRANSPOSH_TEXT_DOMAIN)); 
     
    586593 
    587594        $this->sectionstop(); 
     595/* 
     596        require_once("pomo_upgrader.php"); 
     597 
     598        $upgrader = new POMO_Upgrader(); 
     599        $upgrader->run(array('package' => 'http://svn.automattic.com/wordpress-i18n/he_IL/tags/3.5/messages/he_IL.mo', 
     600            'destination' => '/tmp/', //WP_PLUGIN_DIR . '/themes', 
     601            'clear_destination' => false, //Do not overwrite files. 
     602            'clear_working' => false));*/ 
    588603    } 
    589604 
     
    686701    } 
    687702 
    688     private function header($head) { 
     703    private function header($head, $help='') { 
    689704        if (!isset($head)) return; 
     705        if ($help) { 
     706            $help = ' <a class="tp_help" href="#" rel="'.$help.'">[?]</a>'; 
     707        } 
    690708        if (is_array($head)) { 
    691             echo "<h3><img width=\"16\" height=\"16\" src=\"{$this->transposh->transposh_plugin_url}/img/{$head[0]}\"> {$head[1]}</h3>"; 
     709            echo "<h3><img width=\"16\" height=\"16\" src=\"{$this->transposh->transposh_plugin_url}/img/{$head[0]}\"> {$head[1]}$help</h3>"; 
    692710        } else { 
    693             echo '<h3>' . $head . '</h3>'; 
     711            echo "<h3> $head $help</h3>"; 
    694712        } 
    695713    } 
     
    724742    } 
    725743 
    726     private function textinput($tpo, $head, $label, $length = 35) { 
    727         $this->header($head); 
     744    private function textinput($tpo, $head, $label, $length = 35, $help='') { 
     745        $this->header($head, $help); 
    728746        echo $label . ': <input type="text" size="' . $length . '" class="regular-text" ' . $tpo->post_value_id_name() . '/>'; 
    729747    } 
  • trunk/WordPress/plugin/transposh/wp/transposh_options.php

    r759 r770  
    135135 * @property boolean          $enable_url_translate          Option to enable/disable url translation @since 0.5.3 
    136136 * @property transposh_option $enable_url_translate_o 
     137 * @property string           $jqueryui_override             Option to override the jQueryUI version @since 0.9.1 
     138 * @property transposh_option $jqueryui_override_o 
    137139 * @property boolean          $parser_dont_break_puncts      Option to allow punctuations such as , . ( not to break @since 0.9.0 
    138140 * @property transposh_option $parser_dont_break_puncts_o 
     
    244246 
    245247        $this->register_option('enable_url_translate', TP_OPT_BOOLEAN, 0); 
     248        $this->register_option('jqueryui_override', TP_OPT_STRING); 
    246249        $this->register_option('parser_dont_break_puncts', TP_OPT_BOOLEAN, 0); 
    247250        $this->register_option('parser_dont_break_numbers', TP_OPT_BOOLEAN, 0); 
Note: See TracChangeset for help on using the changeset viewer.