Plugin Directory

Changeset 566940


Ignore:
Timestamp:
07/03/2012 03:26:56 PM (14 years ago)
Author:
lpointet
Message:

Refactored pointers processing to be more concise in JS #WebPerf

Location:
wordpress-gps/trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • wordpress-gps/trunk/gb_gps.php

    r564572 r566940  
    44Plugin URI: http://www.globalis-ms.com
    55Description: This plugin Provide an admin screen to WordPress users in which they will choose one scenario to play. That scenario will help them through the WordPress administration thanks to WP-Pointers API
    6 Version: 1.0.8
     6Version: 1.0.9
    77Author: Lionel POINTET, GLOBALIS media systems
    88Author URI: http://www.globalis-ms.com
  • wordpress-gps/trunk/include/gb_gps_pointer.php

    r562378 r566940  
    2727
    2828    /**
    29      * Include the needed JavaScript to show the pointer
     29     * Return the args needed by the javascript: selector, content & position
    3030     */
    31     public function show() {
    32         $args = array(
     31    protected function args() {
     32        return array(
     33            'selector' => $this->selector,
    3334            'content' => $this->content,
    3435            'position' => $this->position,
    3536        );
     37    }
     38
     39    /**
     40     * Include the needed JavaScript to show the pointer(s)
     41     */
     42    public static function process($pointers) {
    3643        $nonce = wp_create_nonce('gb_gps_ajax_nonce');
     44
     45        $args = array();
     46        foreach($pointers as $pointer) {
     47            $args[] = $pointer->args();
     48        }
     49
    3750        ?>
    38         <script type="text/javascript">
    39         //<![CDATA[
    40         (function($){
    41             var options = <?php echo json_encode( $args ); ?>, setup;
    42 
    43             if ( ! options )
    44                 return;
    45 
    46             options = $.extend( options, {
    47                 close: function() {
     51        <script type="text/javascript">
     52        //<![CDATA[
     53        (function($){
     54            var options = <?php echo json_encode( $args ); ?>,
     55                close = function() {
    4856                    $.get(
    4957                        ajaxurl,
    5058                        {action : 'gb_gps_stop_scenario', nonce : '<?php echo esc_js($nonce); ?>'}
    5159                    );
    52                 }
    53             });
     60                };
    5461
    55             setup = function() {
    56                 $('<?php echo $this->selector; ?>').pointer( options ).pointer('open');
    57             };
     62            if ( ! options )
     63                return;
    5864
    59             if ( options.position && options.position.defer_loading )
    60                 $(window).bind( 'load.wp-pointers', setup );
    61             else
    62                 $(document).ready( setup );
     65            var setup = function() {
     66                    for(var i = 0, l = options.length; i < l; i++) {
     67                        if(options[i].position && options[i].position.defer_loading)
     68                            continue;
    6369
    64         })( jQuery );
    65         //]]>
    66         </script>
    67         <?php
     70                        var option = $.extend( options[i], {
     71                            close: close
     72                        });
     73                        $(option.selector).pointer( option ).pointer('open');
     74                    }
     75                },
     76                setup_defer = function() {
     77                    for(var i = 0, l = options.length; i < l; i++) {
     78                        if(options[i].position && options[i].position.defer_loading) {
     79                            var option = $.extend( options[i], {
     80                                close: close
     81                            });
     82                            $(option.selector).pointer( option ).pointer('open');
     83                        }
     84                    }
     85                };
     86
     87            $(window).bind( 'load.wp-pointers', setup_defer );
     88            $(document).ready( setup );
     89        })( jQuery );
     90        //]]>
     91        </script>
     92        <?php
    6893    }
    6994}
  • wordpress-gps/trunk/include/gb_gps_scenario.php

    r562381 r566940  
    3535
    3636        if(!empty($this->pointers[$hook])) {
    37             foreach($this->pointers[$hook] as $k => $pointer) {
    38                 $pointer->show();
    39             }
     37            GBGPS_Pointer::process($this->pointers[$hook]);
    4038        }
    4139
  • wordpress-gps/trunk/readme.txt

    r564572 r566940  
    44Requires at least: 3.3.0
    55Tested up to: 3.4
    6 Stable tag: 1.0.8
     6Stable tag: 1.0.9
    77License: GPLv2 or later
    88License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    4646
    4747== Changelog ==
     48
     49= 1.0.9 =
     50* Refactored pointers processing to be more concise in JS #WebPerf
    4851
    4952= 1.0.8 =
Note: See TracChangeset for help on using the changeset viewer.