| 25 | | <?php echo jq_link_to_function(isset($label) ? __($label, null, 'apostrophe') : __("edit", null, 'apostrophe'), "", |
| | 25 | <?php // We want to eliminate jQuery helpers, but writing this link as raw HTML is tricky because ?> |
| | 26 | <?php // of the need to quote the title option right. And link_to doesn't like '#' as a URL. So we use ?> |
| | 27 | <?php // content_tag, Symfony's lower-level helper for outputting any tag and its content programmatically ?> |
| | 28 | <?php echo content_tag('a', isset($label) ? a_($label) : a_("edit"), |
| 32 | | <script type="text/javascript" charset="utf-8"> |
| 33 | | <?php // TODO: Rewrite this as a button class scoped to ALL edit buttons so there's only a single instance of this Javascript ?> |
| 34 | | $(document).ready(function() { |
| 35 | | <?php // This is now AJAX code to load the edit view on demand ?> |
| 36 | | var editBtn = $('#a-slot-edit-<?php echo "$pageid-$name-$permid" ?>'); |
| 37 | | var editSlot = $('#a-slot-<?php echo "$pageid-$name-$permid" ?>'); |
| 38 | | editBtn.click(function(event){ |
| 39 | | if (!editSlot.children('.a-slot-content').children('.a-slot-form').length) |
| 40 | | { |
| 41 | | $.get(<?php echo json_encode(url_for($slot->type . 'Slot/ajaxEditView') . '?' . http_build_query(array('id' => $pageid, 'slot' => $name, 'permid' => $permid))) ?>, { }, function(data) { |
| 42 | | editSlot.children('.a-slot-content').html(data); |
| 43 | | apostrophe.slotShowEditView(editBtn, editSlot); |
| 44 | | }); |
| 45 | | } |
| 46 | | else |
| 47 | | { |
| 48 | | // Reuse edit view |
| 49 | | apostrophe.slotShowEditView(editBtn, editSlot); |
| 50 | | } |
| 51 | | return false; |
| 52 | | }); |
| 53 | | }); |
| 54 | | </script> |
| | 36 | <?php a_js_call('apostrophe.slotEnableEditButton(?, ?, ?, ?)', $pageid, $name, $permid, url_for($slot->type . 'Slot/ajaxEditView')) ?> |