- Timestamp:
- Nov 24, 2013, 6:09:57 PM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
extensions/UserCollections/template/thumbnails_css_js.tpl
r25674 r25678 4 4 {if not $UC_IN_EDIT} 5 5 {footer_script require='jquery'} 6 var $cdm = jQuery( "#collectionsDropdown");6 var $cdm = jQuery('#collectionsDropdown'); 7 7 8 8 {if not $IN_PICTURE} 9 $cdm.on( "mouseleave", function() {ldelim}9 $cdm.on('mouseleave', function() { 10 10 $cdm.hide(); 11 11 }); … … 13 13 14 14 // click on "create collection" button 15 $cdm.find( "a.new").on("click", function(event) {ldelim}15 $cdm.find('a.new').on('click', function(e) { 16 16 jQuery(this).hide().next().show().focus(); 17 e vent.stopPropagation();18 return false;17 e.stopPropagation(); 18 e.preventDefault(); 19 19 }); 20 20 21 21 // events on "new collection" input 22 $cdm.find( "input.new").on({ldelim}22 $cdm.find('input.new').on({ 23 23 // ENTER or ESC pressed 24 "keyup": function(event) {ldelim}25 if (e vent.which == 27) {ldelim}24 keyup: function(e) { 25 if (e.which == 27) { 26 26 jQuery(this).val('').hide().prev().show(); 27 27 return; 28 28 } 29 30 if (event.which != 13) return; 31 29 30 if (e.which != 13) { 31 return; 32 } 33 32 34 jQuery(this).hide().prev().show(); 33 35 var name = jQuery(this).val(); 34 36 jQuery(this).val(''); 35 36 if (name == "" || name == null) return; 37 38 jQuery.ajax({ldelim} 39 type: "GET", 40 dataType: "json", 41 url: "{$ROOT_URL}ws.php", 42 data: {ldelim} 43 format: "json", 44 method: "pwg.collections.create", 37 38 if (name == '' || name == null) { 39 return; 40 } 41 42 jQuery.ajax({ 43 type: 'GET', 44 dataType: 'json', 45 url: '{$ROOT_URL}ws.php', 46 data: { 47 format: 'json', 48 method: 'pwg.collections.create', 45 49 name: name, 46 50 }, 47 success: function(data) { ldelim}48 if (data.stat == 'ok') { ldelim}51 success: function(data) { 52 if (data.stat == 'ok') { 49 53 var col = data.result; 50 54 var html = '<span>★</span> <a class="add" data-id="'+ col.id +'">'+ col.name +'</a> ' 51 55 +'<span class="menuInfoCat">[<span class="nbImagesCollec-'+ col.id +'">'+ col.nb_images +'</span>]</span> ' 52 +'<a class="remove" data-id="'+ col.id +'">{'(remove)'| @translate}</a>'56 +'<a class="remove" data-id="'+ col.id +'">{'(remove)'|translate|escape:javscript}</a>' 53 57 +'<br>'; 54 55 $cdm.children( ".switchBoxFooter").before(html);56 $cdm.children( ".noCollecMsg").remove();57 } 58 else { ldelim}58 59 $cdm.children('.switchBoxFooter').before(html); 60 $cdm.children('.noCollecMsg').remove(); 61 } 62 else { 59 63 alert(data.message); 60 64 } 61 65 }, 62 error: function() { ldelim}63 alert( "{'An unknown error occured'|@translate}");66 error: function() { 67 alert('{'An unknown error occured'|translate|escape:javascript}'); 64 68 } 65 69 }); 66 67 return false;68 70 }, 69 71 // prevent click propagation 70 "click": function(event) {ldelim}71 e vent.stopPropagation();72 click: function(e) { 73 e.stopPropagation(); 72 74 } 73 75 }); 74 76 75 77 // add and remove links (delegate for new collections) 76 $cdm.on( "click", ".add, .remove", function() {ldelim}77 var img_id = $cdm.data( "img_id");78 var col_id = jQuery(this).data( "id");79 var method = jQuery(this).hasClass( "add") ? "pwg.collections.addImages" : "pwg.collections.removeImages";80 81 jQuery.ajax({ ldelim}82 type: "GET",83 dataType: "json",84 url: "{$ROOT_URL}ws.php",85 data: { ldelim}86 format: "json",78 $cdm.on('click', '.add, .remove', function(e) { 79 var img_id = $cdm.data('img_id'); 80 var col_id = jQuery(this).data('id'); 81 var method = jQuery(this).hasClass('add') ? 'pwg.collections.addImages' : 'pwg.collections.removeImages'; 82 83 jQuery.ajax({ 84 type: 'GET', 85 dataType: 'json', 86 url: '{$ROOT_URL}ws.php', 87 data: { 88 format: 'json', 87 89 method: method, 88 90 col_id: col_id, 89 91 image_ids: img_id 90 92 }, 91 success: function(data) { ldelim}92 if (data.stat == 'ok') { ldelim}93 success: function(data) { 94 if (data.stat == 'ok') { 93 95 // update col counters 94 jQuery( ".nbImagesCollec-"+col_id).html(data.result.nb_images);95 96 jQuery('.nbImagesCollec-'+ col_id).html(data.result.nb_images); 97 96 98 // update item datas 97 var $target = jQuery( ".addCollection[data-id='"+ img_id +"']");98 var col_ids = $target.data( "cols");99 if (method == "pwg.collections.addImages" && col_ids.indexOf(col_id) == -1)99 var $target = jQuery('.addCollection[data-id="'+ img_id +'"]'); 100 var col_ids = $target.data('cols'); 101 if (method == 'pwg.collections.addImages' && col_ids.indexOf(col_id) == -1) { 100 102 col_ids[ col_ids.length ] = col_id; 101 else if (method == "pwg.collections.removeImages") 103 } 104 else if (method == 'pwg.collections.removeImages') { 102 105 col_ids.splice(col_ids.indexOf(col_id), 1); 103 $target.data("col", col_ids); 104 } 105 else {ldelim} 106 } 107 $target.data('col', col_ids); 108 } 109 else { 106 110 alert(data.message); 107 111 } 108 112 }, 109 error: function() { ldelim}110 alert( "{'An unknown error occured'|@translate}");111 } 112 }); 113 113 error: function() { 114 alert('{'An unknown error occured'|translate|escape:javascript}'); 115 } 116 }); 117 114 118 $cdm.hide(); 115 return false;119 e.preventDefault(); 116 120 }); 117 121 118 122 // main button, open the menu 119 jQuery( ".addCollection").on("click", function(event) {ldelim}120 var img_id = jQuery(this).data( "id");121 var col_ids = jQuery(this).data( "cols");122 123 $cdm.data( "img_id", img_id);124 125 $cdm.children( ".add").each(function() {ldelim}126 if (col_ids.indexOf($(this).data( "id")) != -1) {ldelim}127 $(this).css( "font-weight", "bold").next().next().show();128 } 129 else { ldelim}130 $(this).css( "font-weight", "normal").next().next().hide();131 } 132 }); 133 123 jQuery('.addCollection').on('click', function(e) { 124 var img_id = jQuery(this).data('id'); 125 var col_ids = jQuery(this).data('cols'); 126 127 $cdm.data('img_id', img_id); 128 129 $cdm.children('.add').each(function() { 130 if (col_ids.indexOf($(this).data('id')) != -1) { 131 $(this).css('font-weight', 'bold').next().next().show(); 132 } 133 else { 134 $(this).css('font-weight', 'normal').next().next().hide(); 135 } 136 }); 137 134 138 {if not $IN_PICTURE} 135 $cdm.css({ ldelim}136 "top": event.pageY-5-$(window).scrollTop(),137 "left": Math.min(event.pageX-jQuery(window).scrollLeft()-20, jQuery(window).width()-$cdm.outerWidth(true)-5)139 $cdm.css({ 140 'top': e.pageY-5-$(window).scrollTop(), 141 'left': Math.min(e.pageX-jQuery(window).scrollLeft()-20, jQuery(window).width()-$cdm.outerWidth(true)-5) 138 142 }); 139 143 $cdm.show(); 140 144 {/if} 141 142 return false;145 146 e.preventDefault(); 143 147 }); 144 148 145 149 // try to respect theme colors 146 $cdm.children( ".switchBoxFooter").css("border-top-color", $cdm.children(".switchBoxTitle").css("border-bottom-color"));150 $cdm.children('.switchBoxFooter').css('border-top-color', $cdm.children('.switchBoxTitle').css('border-bottom-color')); 147 151 {/footer_script} 148 152 149 153 <div id="collectionsDropdown" class="switchBox"> 150 <div class="switchBoxTitle">{'Collections'| @translate}</div>151 154 <div class="switchBoxTitle">{'Collections'|translate}</div> 155 152 156 {foreach from=$COLLECTIONS item=col} 153 157 <span>★</span> <a class="add" data-id="{$col.id}">{$col.name}</a> 154 158 <span class="menuInfoCat">[<span class="nbImagesCollec-{$col.id}">{$col.nb_images}</span>]</span> 155 <a class="remove" data-id="{$col.id}">{'(remove)'| @translate}</a>159 <a class="remove" data-id="{$col.id}">{'(remove)'|translate}</a> 156 160 <br> 157 161 {foreachelse} 158 <span class="noCollecMsg">{'You have no collection'| @translate}</span>162 <span class="noCollecMsg">{'You have no collection'|translate}</span> 159 163 {/foreach} 160 164 161 165 <div class="switchBoxFooter"> 162 <span>✚</span> <a class="new">{'Create a new collection'| @translate}</a>163 <input type="text" class="new" placeholder="{'Name'| @translate}" size="25"/>166 <span>✚</span> <a class="new">{'Create a new collection'|translate}</a> 167 <input type="text" class="new" placeholder="{'Name'|translate}" size="25"/> 164 168 </div> 165 169 </div> … … 168 172 {else} 169 173 {footer_script require='jquery'} 170 jQuery( ".addCollection").on("click", function(event) {ldelim}174 jQuery('.addCollection').on('click', function(e) { 171 175 var $trigger = jQuery(this); 172 var img_id = jQuery(this).data( "id");176 var img_id = jQuery(this).data('id'); 173 177 var col_id = {$collection.ID}; 174 175 jQuery.ajax({ ldelim}176 type: "GET",177 dataType: "json",178 url: "{$ROOT_URL}ws.php",179 data: { ldelim}180 format: "json",181 method: "pwg.collections.removeImages",178 179 jQuery.ajax({ 180 type: 'GET', 181 dataType: 'json', 182 url: '{$ROOT_URL}ws.php', 183 data: { 184 format: 'json', 185 method: 'pwg.collections.removeImages', 182 186 col_id: col_id, 183 187 image_ids: img_id 184 188 }, 185 success: function(data) { ldelim}186 if (data.stat == 'ok') { ldelim}187 $trigger.parent( "li").hide("fast", function() {ldelim}189 success: function(data) { 190 if (data.stat == 'ok') { 191 $trigger.parent('li').hide('fast', function() { 188 192 jQuery(this).remove(); 189 if (typeof GThumb != "undefined") GThumb.build(); 193 if (typeof GThumb != 'undefined') { 194 GThumb.build(); 195 } 190 196 }); 191 192 jQuery(".nbImagesCollec-"+col_id).html(data.result.nb_images); 193 if (typeof batchdown_count != 'undefined') batchdown_count = data.result.nb_images; 194 } 195 else {ldelim} 197 198 jQuery('.nbImagesCollec-'+ col_id).html(data.result.nb_images); 199 if (typeof batchdown_count != 'undefined') { 200 batchdown_count = data.result.nb_images; 201 } 202 } 203 else { 196 204 alert(data.message); 197 205 } 198 206 }, 199 error: function() {ldelim} 200 alert("{'An unknown error occured'|@translate}"); 201 } 202 }); 203 204 event.stopPropagation(); 205 event.preventDefault(); 206 return false; 207 error: function() { 208 alert('{'An unknown error occured'|translate|escape:javascript}'); 209 } 210 }); 211 212 e.stopPropagation(); 213 e.preventDefault(); 207 214 }); 208 215 {/footer_script}
Note: See TracChangeset
for help on using the changeset viewer.