Changeset 2144
- Timestamp:
- 09/07/10 17:08:36 (17 months ago)
- Location:
- plugins/apostrophePlugin/trunk
- Files:
-
- 4 modified
-
lib/action/BaseaSlotActions.class.php (modified) (1 diff)
-
modules/a/templates/_ajaxUpdateSlot.php (modified) (2 diffs)
-
modules/a/templates/_area.php (modified) (2 diffs)
-
web/js/a.js (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
plugins/apostrophePlugin/trunk/lib/action/BaseaSlotActions.class.php
r2139 r2144 161 161 // a newly saved slot with an edit view 162 162 "variant" => $variant, 163 // Having the actual slot makes it possible to check if it's new and 164 // shut off a-new-slot 165 "slot" => $this->slot, 163 166 "validationData" => $this->validationData)); 164 167 } -
plugins/apostrophePlugin/trunk/modules/a/templates/_ajaxUpdateSlot.php
r1964 r2144 9 9 $validationData = isset($validationData) ? $sf_data->getRaw('validationData') : null; 10 10 $variant = isset($variant) ? $sf_data->getRaw('variant') : null; 11 $slot = isset($slot) ? $sf_data->getRaw('slot') : null; 11 12 ?> 12 13 <?php // 1.3 and up don't do this automatically (no common filter) ?> … … 18 19 <?php use_helper('a') ?> 19 20 <?php a_slot_body($name, $type, $permid, $options, $validationData, $editorOpen, true) ?> 21 <?php if (!$slot->isNew()): ?> 22 <?php a_js_call('apostrophe.slotNotNew(?, ?, ?)', $pageid, $name, $permid) ?> 23 <?php endif ?> 24 <?php a_js_call('apostrophe.areaUpdateMoveButtons(?, ?, ?)', url_for('a/moveSlot'), $pageid, $name) ?> 20 25 <?php a_include_js_calls() ?> 21 26 <?php if (isset($variant)): ?> -
plugins/apostrophePlugin/trunk/modules/a/templates/_area.php
r2090 r2144 86 86 <!-- START SLOT --> 87 87 <div class="a-slot <?php echo $slot->getEffectiveVariant($slotOptions) ?> <?php echo $slot->type ?><?php echo ($slot->isNew())? ' a-new-slot':'' ?> clearfix" id="a-slot-<?php echo "$pageid-$name-$permid" ?>"> 88 <?php // Make the slot aware of its permid for simpler JS later ?> 89 <?php a_js_call('$(?).data(?, ?)', "#a-slot-$pageid-$name-$permid", 'a-permid', $permid) ?> 88 90 <?php // Slot Controls ?> 89 91 <?php if ($editable): ?> 90 92 <ul class="a-ui a-controls a-slot-controls clearfix"> 91 93 <?php if ($infinite): ?> 92 <?php if ($i > 0): ?> 93 <li> 94 <?php echo jq_link_to_remote('<span class="icon"></span>'.__('Move', null, 'apostrophe'), array( 95 "url" => "a/moveSlot?" .http_build_query(array( 96 "id" => $page->id, 97 "name" => $name, 98 "up" => 1, 99 "permid" => $permid)), 100 "update" => "a-slots-$pageid-$name", 101 'complete' => 'aUI()'), 102 array( 103 'class' => 'a-btn icon a-arrow-up no-label', 104 'title' => __('Move Up', null, 'apostrophe'), 105 )) ?> 106 </li> 107 <?php endif ?> 108 <?php if (($i + 1) < count($slots)): ?> 109 <li> 110 <?php echo jq_link_to_remote('<span class="icon"></span>'.__('Move', null, 'apostrophe'), array( 111 "url" => "a/moveSlot?" .http_build_query(array( 112 "id" => $page->id, 113 "name" => $name, 114 "permid" => $permid)), 115 "update" => "a-slots-$pageid-$name", 116 'complete' => 'aUI()'), 117 array( 118 'class' => 'a-btn icon a-arrow-down no-label', 119 'title' => __('Move Down', null, 'apostrophe'), 120 )) ?> 121 </li> 122 <?php endif ?> 94 <li class="a-move"> 95 <a href="#" class="a-btn icon a-arrow-up no-label" title="<?php echo a_('Move Up') ?>"><span class="icon"></span><?php echo a_('Move Up') ?></a> 96 </li> 97 <li class="a-move"> 98 <a href="#" class="a-btn icon a-arrow-down no-label" title="<?php echo a_('Move Down') ?>"><span class="icon"></span><?php echo a_('Move Down') ?></a> 99 </li> 123 100 <?php endif ?> 124 101 … … 201 178 }); 202 179 </script> 180 <?php a_js_call('apostrophe.areaUpdateMoveButtons(?, ?, ?)', url_for('a/moveSlot'), $pageid, $name) ?> 203 181 <?php endif ?> -
plugins/apostrophePlugin/trunk/web/js/a.js
r2142 r2144 26 26 } 27 27 28 // Swap two DOM elements without cloning them 29 // http://blog.pengoworks.com/index.cfm/2008/9/24/A-quick-and-dirty-swap-method-for-jQuery 30 this.swapNodes = function(a, b) { 31 var t = a.parentNode.insertBefore(document.createTextNode(''), a); 32 b.parentNode.insertBefore(a, b); 33 t.parentNode.insertBefore(b, t); 34 t.parentNode.removeChild(t); 35 } 36 28 37 this.jsTree = function(options) 29 38 { … … 88 97 }); 89 98 } 99 90 100 91 101 this.slideshow = function(options) … … 463 473 aUI(editBtn.parents('.a-slot').attr('id')); // Refresh the UI scoped to this Slot 464 474 } 475 476 this.areaUpdateMoveButtons = function(updateAction, id, name) 477 { 478 var area = $('#a-area-' + id + '-' + name); 479 // Be precise - take care not to hoover up controls related to slots in nested areas, if there are any 480 var slots = area.children('.a-slots').children('.a-slot'); 481 var newSlots = area.children('.a-slots').children('.a-new-slot'); 482 if (newSlots.length) 483 { 484 // TODO: this is not sensitive enough to nested areas 485 486 // You have to save a new slot before you can do any reordering. 487 // TODO: with a little more finesse we could support saving it with 488 // a rank, but think about how messy that might get 489 slots.find('.a-arrow-up,.a-arrow-down').hide(); 490 return; 491 } 492 // I actually want a visible loop variable here 493 for (n = 0; (n < slots.length); n++) 494 { 495 var slot = slots[n]; 496 // We use a nested function here because 497 // a loop variable does *not* get captured 498 // in the closure at its current value otherwise 499 setButtons(slot, n, slots); 500 function setButtons(slot, n, slots) 501 { 502 if (n > 0) 503 { 504 // TODO: this is not sensitive enough to nested areas 505 $(slot).find('.a-arrow-up').show().unbind('click').click(function() { 506 // It would be nice to confirm success here in some way 507 $.get(updateAction, { id: id, name: name, permid: $(slot).data('a-permid'), up: 1 }); 508 apostrophe.swapNodes(slot, slots[n - 1]); 509 apostrophe.areaUpdateMoveButtons(updateAction, id, name); 510 return false; 511 }); 512 } 513 else 514 { 515 $(slot).find('.a-arrow-up').hide(); 516 } 517 if (n < (slots.length - 1)) 518 { 519 $(slot).find('.a-arrow-down').show().unbind('click').click(function() { 520 // It would be nice to confirm success here in some way 521 $.get(updateAction, { id: id, name: name, permid: $(slot).data('a-permid'), up: 0 }); 522 apostrophe.swapNodes(slot, slots[n + 1]); 523 apostrophe.areaUpdateMoveButtons(updateAction, id, name); 524 return false; 525 }); 526 } 527 else 528 { 529 $(slot).find('.a-arrow-down').hide(); 530 } 531 } 532 } 533 } 534 535 this.slotNotNew = function(pageid, name, permid) 536 { 537 $("#a-slot-" + pageid + "-" + name + "-" + permid).removeClass('a-new-slot'); 538 } 465 539 } 466 540

