- Timestamp:
- Jul 14, 2013, 6:43:22 PM (11 years ago)
- Location:
- trunk/admin
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/admin/include/photos_add_direct_prepare.inc.php
r22135 r23944 161 161 // we need to know the category in which the last photo was added 162 162 $selected_category = array(); 163 $selected_parent = array();164 163 165 164 $query = ' 166 SELECT 167 category_id, 168 id_uppercat 165 SELECT category_id 169 166 FROM '.IMAGES_TABLE.' AS i 170 167 JOIN '.IMAGE_CATEGORY_TABLE.' AS ic ON image_id = i.id … … 179 176 180 177 $selected_category = array($row['category_id']); 181 182 if (!empty($row['id_uppercat']))183 {184 $selected_parent = array($row['id_uppercat']);185 }186 178 } 187 179 … … 196 188 $selected_category, 197 189 'category_options' 198 );199 200 // new category201 display_select_cat_wrapper(202 $query,203 $selected_parent,204 'category_parent_options'205 190 ); 206 191 -
trunk/admin/themes/default/template/include/add_album.inc.tpl
r17007 r23944 1 1 {footer_script}{literal} 2 2 jQuery(document).ready(function(){ 3 function fillCategoryListbox(selectId, selectedValue) {4 jQuery.getJSON(5 "ws.php?format=json&method=pwg.categories.getList",6 {7 recursive: true,8 fullname: true,9 format: "json",10 },11 function(data) {12 jQuery.each(13 data.result.categories,14 function(i,category) {15 var selected = null;16 if (category.id == selectedValue) {17 selected = "selected";18 }19 20 jQuery("<option/>")21 .attr("value", category.id)22 .attr("selected", selected)23 .text(category.name)24 .appendTo("#"+selectId)25 ;26 }27 );28 }29 );30 }31 32 3 jQuery(".addAlbumOpen").colorbox({ 33 inline: true,34 href: "#addAlbumForm",35 onComplete: function(){4 inline: true, 5 href: "#addAlbumForm", 6 onComplete: function() { 36 7 jQuery("input[name=category_name]").focus(); 8 9 jQuery("#category_parent").html('<option value="0">------------</option>') 10 .append(jQuery("#albumSelect").html()) 11 .val(jQuery("#albumSelect").val()); 37 12 } 38 13 }); 39 14 40 jQuery("#addAlbumForm form").submit(function() {15 jQuery("#addAlbumForm form").submit(function() { 41 16 jQuery("#categoryNameError").text(""); 17 18 var parent_id = jQuery("select[name=category_parent] option:selected").val(), 19 name = jQuery("input[name=category_name]").val(); 42 20 43 21 jQuery.ajax({ 44 url: "ws.php?format=json&method=pwg.categories.add", 22 url: "ws.php", 23 dataType: 'json', 45 24 data: { 46 parent: jQuery("select[name=category_parent] option:selected").val(), 47 name: jQuery("input[name=category_name]").val(), 25 format: 'json', 26 method: 'pwg.categories.add', 27 parent: parent_id, 28 name: name 48 29 }, 49 30 beforeSend: function() { 50 31 jQuery("#albumCreationLoading").show(); 51 32 }, 52 success: function(html) {33 success: function(data) { 53 34 jQuery("#albumCreationLoading").hide(); 54 55 var newAlbum = jQuery.parseJSON(html).result.id;56 35 jQuery(".addAlbumOpen").colorbox.close(); 57 36 58 jQuery("#albumSelect").find("option").remove(); 59 fillCategoryListbox("albumSelect", newAlbum); 60 61 /* we refresh the album creation form, in case the user wants to create another album */ 62 jQuery("#category_parent").find("option").remove(); 63 64 jQuery("<option/>") 65 .attr("value", 0) 66 .text("------------") 67 .appendTo("#category_parent") 68 ; 69 70 fillCategoryListbox("category_parent", newAlbum); 37 var newAlbum = data.result.id, 38 newAlbum_name = ''; 39 40 if (parent_id!=0) { 41 newAlbum_name = jQuery("#category_parent").find("option[value="+ parent_id +"]").text() +' / '; 42 } 43 newAlbum_name+= name; 44 45 var new_option = jQuery("<option/>") 46 .attr("value", newAlbum) 47 .attr("selected", "selected") 48 .text(newAlbum_name); 49 50 jQuery("#albumSelect").find("option").removeAttr('selected'); 51 52 if (parent_id==0) { 53 jQuery("#albumSelect").append(new_option); 54 } 55 else { 56 jQuery("#albumSelect").find("option[value="+ parent_id +"]").after(new_option); 57 } 71 58 72 59 jQuery("#addAlbumForm form input[name=category_name]").val(''); 73 74 60 jQuery("#albumSelection").show(); 75 61 76 62 return true; 77 63 }, 78 error: function(XMLHttpRequest, textStatus, errorThrows) {64 error: function(XMLHttpRequest, textStatus, errorThrows) { 79 65 jQuery("#albumCreationLoading").hide(); 80 66 jQuery("#categoryNameError").text(errorThrows).css("color", "red"); … … 91 77 <form> 92 78 {'Parent album'|@translate}<br> 93 <select id ="category_parent" name="category_parent"> 94 <option value="0">------------</option> 95 {html_options options=$category_parent_options selected=$category_parent_options_selected} 79 <select id="category_parent" name="category_parent"> 96 80 </select> 97 98 <br><br>{'Album name'|@translate}<br><input name="category_name" type="text" maxlength="255"> <span id="categoryNameError"></span> 99 <br><br><br><input type="submit" value="{'Create'|@translate}"> <span id="albumCreationLoading" style="display:none"><img src="themes/default/images/ajax-loader-small.gif"></span> 81 <br><br> 82 83 {'Album name'|@translate}<br> 84 <input name="category_name" type="text" maxlength="255"> <span id="categoryNameError"></span> 85 <br><br><br> 86 87 <input type="submit" value="{'Create'|@translate}"> 88 <span id="albumCreationLoading" style="display:none"><img src="themes/default/images/ajax-loader-small.gif"></span> 100 89 </form> 101 90 </div>
Note: See TracChangeset
for help on using the changeset viewer.