d1ad09ed995f28e546d4c2a2554ad39794e20e28
[atutor.git] / mods / job_board / include / html / admin / jb_categories.tmpl.php
1 <div>
2         <div class="input-form">
3                 <p><?php echo _AT('jb_admin_add_category_blub'); ?></p>
4                 <form action="" method="post">
5                         <div class="row">
6                                 <label for="jb_category_name"><?php echo _AT('name'); ?></label>
7                                 <input type="text" name="category_name" id="jb_category_name" />
8                                 <input type="hidden" name="action" value="add" />
9                                 <input class="button" type="submit" name="submit" value="<?php echo _AT("save"); ?>" />
10                         </div>
11                 </form>
12         </div>
13
14         <div class="admin_categories_container" id="admin_categories_container">
15         <p><?php echo _AT('jb_admin_edit_categories_blub'); ?></p>
16         <?php if(!empty($this->categories)): ?>
17         <?php foreach($this->categories as $category): ?>
18                 <div class="admin_categories">
19                         <div class="left">
20                                 <div class="flc-inlineEditable"><span class="flc-inlineEdit-text" id="<?php echo $category['id'];?>"><?php echo $category['name']; ?></span></div>
21                         </div>
22                         <div class="right"><a href="<?php echo AT_JB_BASENAME;?>admin/categories.php?submit=delete<?php echo SEP; ?>action=delete<?php echo SEP;?>cid=<?php echo $category['id']; ?>" ><?php echo _AT('delete'); ?></a></div>
23                 </div>
24         <?php endforeach; ?>
25         <?php else: ?>
26         <div class="admin_categories">
27                 <div class="left"><?php echo _AT('jb_no_category'); ?></div>
28         </div>
29         <?php endif; ?>
30         </div>
31 </div>
32
33
34 <script type="text/javascript">
35 jQuery(document).ready(function () {
36         //the ATutor undo function
37         var undo = function (that, targetContainer) {
38                                         var markup = "<span class='flc-undo' aria-live='polite' aria-relevant='all'>" +
39                                           "<span class='flc-undo-undoContainer'>[<a href='#' class='flc-undo-undoControl'><?php echo _AT('pa_undo'); ?></a>]</span>" +
40                                           "<span class='flc-undo-redoContainer'>[<a href='#' class='flc-undo-redoControl'><?php echo _AT('pa_redo'); ?></a>]</span>" +
41                                         "</span>";
42                                         var markupNode = jQuery(markup);
43                                         targetContainer.append(markupNode);
44                                         return markupNode;
45                                 };
46         var click_here_to_edit = '<?php echo _AT("pa_click_here_to_edit"); ?>';
47         var click_item_to_edit = '<?php echo _AT("pa_click_item_to_edit"); ?>';
48
49         /* inline edit for photo panel description */
50     fluid.inlineEdits("#admin_categories_container", {
51                 componentDecorators: {
52                         type: "fluid.undoDecorator",
53                         options: {
54                                 renderer: undo
55                         }
56                 },              
57                 defaultViewText: click_here_to_edit,
58                 useTooltip: true,
59                 tooltipText: click_item_to_edit, 
60                 listeners: {
61                         modelChanged: function(model, oldModel, source){
62                                 /* for undo/redo model change */
63                                 if (model != oldModel && source != undefined){
64                                         viewNode = source.component.container.children('.flc-inlineEdit-text')[0];
65                                         rtn = jQuery.post("<?php echo $_base_path. AT_JB_BASENAME.'admin/categories.php';?>", 
66                                                 {"submit":"ajax",
67                                                  "action":"edit",
68                                                  "cid":viewNode.id, 
69                                                  "category_name":model.value},
70                                                   function(data){}, 
71                                                   "json");
72                                 }
73                         },
74                         afterFinishEdit : function (newValue, oldValue, editNode, viewNode) {
75                                 if (newValue != oldValue){
76                                         rtn = jQuery.post("<?php echo $_base_path. AT_JB_BASENAME.'admin/categories.php';?>", 
77                                                         {"submit":"ajax",
78                                                          "action":"edit",
79                                                          "cid":viewNode.id, 
80                                                          "category_name":newValue},
81                                                           function(data){}, 
82                                                           "json");
83                                 }
84                         }
85                 }
86         });
87 });
88 </script>