1(function (global) { 2 3 function FavoriteList(args) { 4 console.log('Favorite list constructor'); 5 var $this = this; 6 this.args = args; 7 8 this.selected = []; 9 10 this.controls = $(this.args.selectorControls); 11 this.sendForm = $(this.args.selectorSendForm); 12 13 // Bind delete control 14 this.controls.find('.btn_delete > button').on('click', function(){ 15 $this.removeSelected(); 16 }); 17 18 // Bind send control 19 this.sendForm.on('submit', function(e) { 20 e.preventDefault(); 21 $this.sendSelected(); 22 }); 23 24 return this; 25 } 26 27 FavoriteList.prototype.removeSelected = function () { 28 var selectedIdentifiers = this.getSelectedIdentifiers(); 29 var articles = this.getSelectedArticles(); 30 var url = this.controls.attr('data-bulk-remove-url'); 31 32 if(selectedIdentifiers.length == 0) { 33 $("#alert_popin").foundation('open'); 34 } else { 35 $.each(articles, function() { 36 $(this).remove(); 37 }); 38 39 this.ajaxCall(url, {'tx_cimfavorite_manage' : {'favorites' : selectedIdentifiers}}); 40 } 41 42 return this; 43 }; 44 45 FavoriteList.prototype.sendSelected = function () { 46 console.log('Favorite list sendSelected call'); 47 var selectedIdentifiers = this.getSelectedIdentifiers(); 48 var url = this.sendForm.attr('action'); 49 var data = this.sendForm.serializeArray(); 50 51 $.each(selectedIdentifiers, function (index, selected) { 52 data.push({name: 'tx_cimfavorite_manage[favorites]['+ index +'][uid]', value: selected.uid}); 53 data.push({name: 'tx_cimfavorite_manage[favorites]['+ index +'][pid]', value: selected.pid}); 54 }); 55 56 this.ajaxCall(url, data); 57 58 $('#send_popin').foundation('close'); 59 $('#envoi_favori').foundation('open'); 60 61 }; 62 63 FavoriteList.prototype.getSelectedIdentifiers = function () { 64 console.log('Favorite list getSelected call'); 65 var selected = []; 66 67 var articles = this.getSelectedArticles(); 68 69 $.each(articles, function(index, article){ 70 selected.push({'pid': article.attr('data-pid'), 'uid': article.attr('data-uid')}); 71 }); 72 73 return selected; 74 }; 75 76 FavoriteList.prototype.getSelectedArticles = function () { 77 var selected = []; 78 79 var selectedArticles = $('.btn_add_selection.btn_act'); 80 81 $.each(selectedArticles, function(){ 82 var article = $(this).closest('article'); 83 selected.push(article); 84 }); 85 86 return selected; 87 }; 88 89 FavoriteList.prototype.ajaxCall = function (url, data) { 90 $.ajax({
91 method: 'POST', 92 url: url, 93 data: data, 94 cache: false, 95 success: function (result) { 96 console.log(result); 97 }, 98 error: function (jqXHR, textStatus, errorThrow) { 99 console.log(jqXHR, textStatus, errorThrow); 100 } 101 }); 102 }; 103 104 var favoriteList = function (args) { 105 return new FavoriteList(args); 106 }; 107 108 global.favoriteList = favoriteList; 109 110})(this);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.