- Timestamp:
- Jun 2, 2014, 5:26:14 PM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
extensions/UserCollections/template/thumbnails_css_js.tpl
r27747 r28593 6 6 var $cdm = jQuery('#collectionsDropdown'); 7 7 8 {if not $IN_PICTURE}9 8 $cdm.on('mouseleave', function() { 10 9 $cdm.hide(); 11 10 }); 12 {/if}13 11 14 12 // click on "create collection" button … … 39 37 return; 40 38 } 39 40 var first = $cdm.children('.noCollecMsg').length > 0; 41 41 42 42 jQuery.ajax({ … … 51 51 success: function(data) { 52 52 if (data.stat == 'ok') { 53 var col = data.result; 54 var html = '<span>★</span> <a class="add" data-id="'+ col.id +'">'+ col.name +'</a> ' 53 var col = data.result, 54 html = 55 '<span>★</span> <a class="add" data-id="'+ col.id +'">'+ col.name +'</a> ' 55 56 +'<span class="menuInfoCat">[<span class="nbImagesCollec-'+ col.id +'">'+ col.nb_images +'</span>]</span> ' 56 57 +'<a class="remove" data-id="'+ col.id +'">{'(remove)'|translate|escape:javscript}</a>' … … 58 59 59 60 $cdm.children('.switchBoxFooter').before(html); 60 $cdm.children('.noCollecMsg').remove(); 61 62 if (first) { 63 $cdm.children('.noCollecMsg').remove(); 64 $cdm.children('.add').trigger('click'); 65 } 61 66 } 62 67 else { … … 77 82 // add and remove links (delegate for new collections) 78 83 $cdm.on('click', '.add, .remove', function(e) { 79 var img_id = $cdm.data('img_id') ;80 var col_id = jQuery(this).data('id');81 varmethod = jQuery(this).hasClass('add') ? 'pwg.collections.addImages' : 'pwg.collections.removeImages';84 var img_id = $cdm.data('img_id'), 85 col_id = jQuery(this).data('id'), 86 method = jQuery(this).hasClass('add') ? 'pwg.collections.addImages' : 'pwg.collections.removeImages'; 82 87 83 88 jQuery.ajax({ … … 97 102 98 103 // update item datas 99 var $target = jQuery('.addCollection[data-id="'+ img_id +'"]'); 100 var col_ids = $target.data('cols'); 104 var $target = jQuery('.addCollection[data-id="'+ img_id +'"]'), 105 col_ids = $target.data('cols'); 106 101 107 if (method == 'pwg.collections.addImages' && col_ids.indexOf(col_id) == -1) { 102 108 col_ids[ col_ids.length ] = col_id; … … 121 127 122 128 // main button, open the menu 123 jQuery( '#thumbnails').on('click', '.addCollection', function(e) {124 var img_id = jQuery(this).data('id') ;125 varcol_ids = jQuery(this).data('cols');129 jQuery(document).on('click', '.addCollection', function(e) { 130 var img_id = jQuery(this).data('id'), 131 col_ids = jQuery(this).data('cols'); 126 132 127 133 $cdm.data('img_id', img_id); 128 134 129 135 $cdm.children('.add').each(function() { 130 if (col_ids.indexOf( $(this).data('id')) != -1) {131 $(this).css('font-weight', 'bold').next().next().show();136 if (col_ids.indexOf(jQuery(this).data('id')) != -1) { 137 jQuery(this).css('font-weight', 'bold').next().next().show(); 132 138 } 133 139 else { 134 $(this).css('font-weight', 'normal').next().next().hide();135 } 136 }); 137 138 {if not$IN_PICTURE}140 jQuery(this).css('font-weight', 'normal').next().next().hide(); 141 } 142 }); 143 144 {if $IN_PICTURE} 139 145 $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) 142 }); 143 $cdm.show(); 146 'left': Math.min(jQuery(this).offset().left, jQuery(window).width()-$cdm.outerWidth(true)-5), 147 'top': jQuery(this).offset().top + jQuery(this).outerHeight(true) 148 }); 149 {else} 150 $cdm.css({ 151 'left': Math.min(e.pageX-jQuery(window).scrollLeft()-20, jQuery(window).width()-$cdm.outerWidth(true)-5), 152 'top': e.pageY-5-$(window).scrollTop() 153 }); 144 154 {/if} 155 $cdm.toggle(); 145 156 146 157 e.preventDefault(); … … 173 184 {footer_script require='jquery'} 174 185 jQuery('#thumbnails').on('click', '.addCollection', function(e) { 175 var $trigger = jQuery(this) ;176 var img_id = jQuery(this).data('id');177 varcol_id = {$collection.ID};186 var $trigger = jQuery(this), 187 img_id = jQuery(this).data('id'), 188 col_id = {$collection.ID}; 178 189 179 190 jQuery.ajax({
Note: See TracChangeset
for help on using the changeset viewer.