To participate you must create an account on apostrophenow.org. If you have already done so, click Login.

Changeset 2167

Show
Ignore:
Timestamp:
09/09/10 14:44:56 (17 months ago)
Author:
johnnyoffline
Message:

1. Fixed a bug with the apostrophe.menuToggle calls in _area.php
2. Enhanced apostrophe.menuToggle to fail gracefully if the toggle button is undefined
3. Fixed the cancel button for menu toggles so that they work even in the form was added later with ajax.

Location:
plugins/apostrophePlugin/trunk
Files:
7 modified

Legend:

Unmodified
Added
Removed
  • plugins/apostrophePlugin/trunk/modules/a/templates/_area.php

    r2164 r2167  
    1111  $slots = isset($slots) ? $sf_data->getRaw('slots') : null; 
    1212?> 
    13 <?php use_helper('a', 'jQuery', 'I18N') ?> 
     13 
     14<?php use_helper('a') ?> 
    1415 
    1516<?php slot('a-history-controls') ?> 
     
    172173        }); 
    173174</script> 
    174 <?php a_js_call('apostrophe.areaUpdateMoveButtons(?, ?, ?)', url_for('a/moveSlot'), $pageid, $name) ?> 
    175 <?php a_js_call('apostrophe.menuToggle(?)', array('button' => '#a-add-slot-'.$pageid.'-'.$name, 'classname' => 'a-options-open', 'overlay' => false)) ?> 
     175 
     176<?php if ($infinite): ?> 
     177        <?php a_js_call('apostrophe.areaUpdateMoveButtons(?, ?, ?)', url_for('a/moveSlot'), $pageid, $name) ?> 
     178        <?php a_js_call('apostrophe.menuToggle(?)', array('button' => '#a-add-slot-'.$pageid.'-'.$name, 'classname' => 'a-options-open', 'overlay' => false)) ?>         
    176179<?php endif ?> 
     180 
     181<?php endif ?> 
  • plugins/apostrophePlugin/trunk/modules/a/templates/_createPage.php

    r2160 r2167  
    33  $form = isset($form) ? $sf_data->getRaw('form') : null; 
    44?> 
    5 <?php use_helper('I18N') ?> 
    65 
    7 <a href="#" class="a-btn icon a-add a-create-page" id="a-create-page-button" onclick="return false;"><span class="icon"></span><?php echo __("Add Page", null, 'apostrophe') ?></a> 
     6<?php use_helper('a') ?> 
     7 
     8<a href="#add-page" class="a-btn icon a-add a-create-page" id="a-create-page-button" onclick="return false;"><span class="icon"></span><?php echo __("Add Page", null, 'apostrophe') ?></a> 
    89 
    910<form method="POST" action="<?php echo url_for('a/create') ?>" id="a-create-page-form" class="a-ui a-options a-page-form a-create-page-form dropshadow"> 
  • plugins/apostrophePlugin/trunk/modules/a/templates/_globalTools.php

    r2135 r2167  
    1 <?php use_helper('I18N') ?> 
     1<?php use_helper('a') ?> 
    22 
    33<?php $buttons = aTools::getGlobalButtons() ?> 
  • plugins/apostrophePlugin/trunk/modules/a/templates/_simpleEditWithVariants.php

    r2139 r2167  
    1616 
    1717<?php include_partial('a/simpleEditButton', array('pageid' => $pageid, 'slot' => $slot, 'name' => $name, 'permid' => $permid, 'controlsSlot' => false)) ?> 
    18  
    1918<?php include_partial('a/variant', array('pageid' => $pageid, 'name' => $name, 'permid' => $permid, 'slot' => $slot)) ?> 
    2019 
  • plugins/apostrophePlugin/trunk/modules/a/templates/_slot.php

    r2164 r2167  
    1717  $validationData = isset($validationData) ? $sf_data->getRaw('validationData') : null; 
    1818?> 
    19 <?php use_helper('jQuery', 'I18N') ?> 
     19<?php use_helper('a') ?> 
    2020 
    2121<?php // We now render the edit view only when it is AJAXed into place on demand. This saves us the ?> 
  • plugins/apostrophePlugin/trunk/modules/a/templates/_variant.php

    r2160 r2167  
    66  $slot = isset($slot) ? $sf_data->getRaw('slot') : null; 
    77?> 
    8 <?php use_helper('I18N') ?> 
     8 
     9<?php use_helper('a') ?> 
     10 
    911<?php $options = $sf_user->getAttribute("slot-options-$pageid-$name-$permid", null, 'apostrophe') ?> 
    1012<?php $variants = aTools::getVariantsForSlotType($slot->type, $options) ?> 
     
    4850    </ul> 
    4951  </li> 
     52 
     53        <?php if (!$slot->isNew()): ?> 
     54                <?php a_js_call('apostrophe.menuToggle(?)', array('button' => '#a-'.$pageid.'-'.$name.'-'.$permid.'-variant-options-toggle', 'classname' => 'a-options-open', 'overlay' => false)) ?>    
     55        <?php endif ?> 
     56 
    5057<?php endif ?> 
    51  
    52 <?php a_js_call('apostrophe.menuToggle(?)', array('button' => '#a-'.$pageid.'-'.$name.'-'.$permid.'-variant-options-toggle', 'classname' => 'a-options-open', 'overlay' => false)) ?> 
  • plugins/apostrophePlugin/trunk/web/js/a.js

    r2162 r2167  
    469469                var aPageSettingsButton = $('#a-page-settings-button');          
    470470 
    471                 _menuToggle('#a-page-settings-button', '', true); 
    472  
     471                apostrophe.menuToggle({"button":"#a-page-settings-button","classname":"","overlay":true}) 
     472                 
    473473                aPageSettingsButton.click(function() { 
    474474                 $.ajax({ 
     
    638638                var classname = options['classname']; 
    639639                var overlay = options['overlay']; 
    640                 _menuToggle(button, classname, overlay); 
    641         } 
    642  
    643  
    644         function _menuToggle(button, classname, overlay) 
     640 
     641                if (typeof(button) == "undefined") { 
     642                        apostrophe.log('[Apostrophe] menuToggle button is undefined'); 
     643                } 
     644                else 
     645                { 
     646                        if (typeof button == "string") { button = $(button); } /* button that toggles the menu open & closed */ 
     647                        if (typeof classname == "undefined" || classname == '') { classname = "show-options";   } /* optional classname override to use for toggle & styling */ 
     648                        if (typeof overlay != "undefined" && overlay) { overlay = $('.a-page-overlay'); } /* optional full overlay */  
     649 
     650                        // Use the parent of the button as the menu container            
     651                        var menu = $(button).parent();  
     652                        if (typeof(menu) == "object") { 
     653                                _menuToggle(button, menu, classname, overlay);                   
     654                        };       
     655                }; 
     656        } 
     657 
     658        function _menuToggle(button, menu, classname, overlay) 
    645659        {        
    646                 /* Usage: aMenuToggle(Object|ID Selector, Object|ID Selector, Undefined|String, Undefined|True|False) */ 
    647  
    648                 if (typeof button == "string") { button = $(button); } /* button that toggles the menu open & closed */ 
    649                 if (typeof classname == "undefined" || classname == '') { classname = "show-options";   } /* optional classname override to use for toggle & styling */ 
    650                 if (typeof overlay != "undefined" && overlay) { overlay = $('.a-page-overlay'); } /* optional full overlay */  
    651                 var menu = $(button).parent(); // Use the parent of the button as the menu container 
    652  
    653                 // We need an ID for the menu. If the menu doesn't have one, we create it by appending 'menu' to the Button ID           
    654                 if (menu.attr('id') == '') { 
     660                // Menu must have an ID.  
     661                // If the menu doesn't have one, we create it by appending 'menu' to the Button ID               
     662                if (menu.attr('id') == '')  
     663                { 
    655664                        newID = button.attr('id')+'-menu'; 
    656665                        menu.attr('id', newID).addClass('a-options-container'); 
     
    667676                                menu.trigger('toggleClosed'); 
    668677                        } 
    669                 }); 
     678                }).addClass('a-options-button'); 
    670679 
    671680                // Open Menu, Create Listener 
     
    674683                        menu.addClass(classname);                        
    675684                        if (overlay) { overlay.stop().show(); } 
    676                         $(document).click(function(e){ 
    677                                 var target = $(e.target); 
     685                        $(document).click(function(event){ 
     686                                var target = $(event.target); 
    678687                                if (target.hasClass('.a-page-overlay') || target.hasClass('.a-cancel'))  
    679688                                { 
     
    691700                        button.removeClass('aActiveMenu'); 
    692701                        menu.removeClass(classname); 
    693                         if (overlay) { overlay.fadeOut(); } 
     702                        if (overlay) { overlay.fadeOut(); }; 
    694703                        $(document).unbind('click'); // Clear out click event            
    695704                }); 
    696705 
    697                 $('.a-options-cancel').live('click', function(){ 
    698                         // console.log(menu); 
    699                         $(this).closest(menu).trigger('toggleClosed'); 
     706                menu.click(function(event){ 
     707                        target = $(event.target); 
     708                        if (target.hasClass('a-options-cancel'))  
     709                        { 
     710                                menu.trigger('toggleClosed'); 
     711                        };                       
    700712                }); 
    701713