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 this.removeSingleBtn = $(this.args.removeSingleBtn); 13 14 // Bind delete control 15 if(this.controls.length) { 16 this.controls.find('#btn_delete').on('click', function(){ 17 $this.removeSelected(); 18 }); 19 } 20 21 // Bind delete single control 22 if(this.removeSingleBtn.length) { 23 this.removeSingleBtn.on('click', function(e){ 24 $this.removeSingle(e); 25 }); 26 } 27 28 // Bind send control 29 if(this.sendForm.length) { 30 this.sendForm.on('submit', function (e) { 31 e.preventDefault(); 32 $this.sendSelected(); 33 }); 34 } 35 36 return this; 37 } 38 39 FavoriteList.prototype.removeSelected = function () { 40 var selectedIdentifiers = this.getSelectedIdentifiers(); 41 var articles = this.getSelectedArticles(); 42 var url = this.controls.attr('data-bulk-remove-url'); 43 44 if(selectedIdentifiers.length === 0) { 45 $("#alert_popin").foundation('open'); 46 } else { 47 $.each(articles, function() { 48 $(this).remove(); 49 }); 50 51 this.ajaxCall(url, {'tx_cimfavorite_manage' : {'favorites' : selectedIdentifiers}}); 52 } 53 54 return this; 55 }; 56 57 FavoriteList.prototype.removeSingle = function (e) { 58 59 var url = this.controls.attr('data-bulk-remove-url'); 60 61 var element =$(e.currentTarget).closest('article'); 62 63 this.ajaxCall(url, {'tx_cimfavorite_manage' : {'favorites' : [{'pid': element.attr('data-pid'), 'uid': element.attr('data-uid')}]}}); 64 65 element.remove(); 66 67 return this; 68 }; 69 70 FavoriteList.prototype.sendSelected = function () { 71 console.log('Favorite list sendSelected call'); 72 var selectedIdentifiers = this.getSelectedIdentifiers(); 73 var url = this.sendForm.attr('action'); 74 var data = this.sendForm.serializeArray(); 75 76 $.each(selectedIdentifiers, function (index, selected) { 77 data.push({name: 'tx_cimfavorite_manage[favorites]['+ index +'][uid]', value: selected.uid}); 78 data.push({name: 'tx_cimfavorite_manage[favorites]['+ index +'][pid]', value: selected.pid}); 79 }); 80 81 this.ajaxCall(url, data); 82 83 $('#popin_bloc_note_send').foundation('close'); 84 $('#popin_bloc_note_send_confirmation').foundation('open'); 85 86 }; 87 88 FavoriteList.prototype.getSelectedIdentifiers = function () { 89 console.log('Favorite list getSelected call'); 90 var selected = []; 91 92 var articles = this.getSelectedArticles(); 93 94 $.each(articles, function(index, article){ 95 selected.push({'pid': article.attr('data-pid'), 'uid': article.attr('data-uid')}); 96 }); 97 98 return selected; 99 }; 100 101 FavoriteList.prototype.getSelectedArticles = function () { 102 var selected = []; 103 104 var selectedArticles = $('.btn_bloc_note_selection.btn_act'); 105 106 $.each(selectedArticles, function(){ 107 var article = $(this).closest('article'); 108 selected.push(article); 109 }); 110 111 return selected; 112 }; 113 114 FavoriteList.prototype.ajaxCall = function (url, data) { 115 $.ajax({
116 method: 'POST', 117 url: url, 118 data: data, 119 cache: false, 120 success: function (result) { 121 console.log(result); 122 }, 123 error: function (jqXHR, textStatus, errorThrow) { 124 console.log(jqXHR, textStatus, errorThrow); 125 } 126 }); 127 }; 128 129 var favoriteList = function (args) { 130 return new FavoriteList(args); 131 }; 132 133 global.favoriteList = favoriteList; 134 135})(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.