1(function() { 2 var mediaDownloadIntroduce = { 3 link_el: undefined, 4 link: undefined, 5 isFullLinkFormat: undefined, 6 smiName: undefined, 7 smiNameSession: undefined, 8 form: undefined, 9 10 init: function () { 11 var self = this; 12 13 self.getCookies(); 14 self.eventBinding(); 15 }, 16 eventBinding: function () { 17 var self = this; 18 19 $(document).on('click', '[data-js*="mediaDownloadIntroduce"]', function(e) { 20 var el = $(this), 21 ev = e; 22 23 if (el.data('dtype')) { 24 $('.media-download-introduce-form__download_type').val(parseInt(el.data('dtype'))); 25 } else { 26 $('.media-download-introduce-form__download_type').val(0); 27 } 28 if (el.data('dplace')) { 29 $('.media-download-introduce-form__download_place').val(parseInt(el.data('dplace'))); 30 } else { 31 $('.media-download-introduce-form__download_place').val(0); 32 } 33 if (el.data('dmaterial')) { 34 $('.media-download-introduce-form__material_id').val(parseInt(el.data('dmaterial'))); 35 } else { 36 $('.media-download-introduce-form__material_id').val(0); 37 } 38 if (el.data('dfile')) { 39 $('.media-download-introduce-form__file_id').val(parseInt(el.data('dfile'))); 40 } else { 41 $('.media-download-introduce-form__file_id').val(0); 42 } 43 44 if(self.smiNameSession == undefined) { 45 self.onClick(ev, el); 46 return false; 47 } else { 48 self.onHideClick(ev, el); 49 return false; 50 } 51 }); 52 $(document).on('submit', '.media-download-introduce-form form', function (e) { 53 e.preventDefault(); 54 var name = $('.media-download-introduce-form__smi-name').val(); 55 56 if( name == '') { 57 var error = '<div>Ðоле обÑзаÑелÑно Ð´Ð»Ñ Ð·Ð°Ð¿Ð¾Ð»Ð½ÐµÐ½Ð¸Ñ!</div>'; 58 $('.media-download-introduce-form__errors *').remove(); 59 $('.media-download-introduce-form__errors').append(error); 60 } else { 61 var popup; 62 // Создаем попап Ð´Ð¾Ð»Ñ ÑÑаÑÑÑ Ð±ÑаÑзеÑов 63 if(typeof document.createElement("a").download === 'undefined') { 64 popup = window.open('about:blank','download'); 65 } 66 $(this).ajaxSubmit({ 67 url: '/file_download', 68 type: 'post', 69 beforeSend: function() { 70 $('.media-download-introduce-form__errors > *').remove(); 71 }, 72 success: function(data) { 73 $('#fancybox-close').click(); 74 self.download(popup); 75 }, 76 error: function () { 77 var error = '<div>ÐÑибка ÑоединениÑ, попÑобÑйÑе позднее!</div>'; 78 $('.media-download-introduce-form__errors').append(error); 79 } 80 }); 81 } 82 }); 83 $(document).on('click', '.media-download-introduce-form__ok', function () { 84 self.setCookies(); 85 $('.media-download-introduce-form form').submit(); 86 }); 87 $(document).on('click', '.media-download-introduce-form__skip', function () { 88 self.setCookies(); 89 $('.media-download-introduce-form form').submit(); 90 }); 91 }, 92 getCookies: function () { 93 var self = this; 94 95 var cookieSmiName = $.cookie('smiName'); 96 var cookieSmiNameSession = $.cookie('smiNameSession'); 97 98 if(cookieSmiName) { 99 self.smiName = cookieSmiName; 100 } 101 102 if(cookieSmiNameSession) { 103 self.smiNameSession = cookieSmiNameSession; 104 } 105 },
106 setCookies: function () { 107 var self = this, 108 name = $('.media-download-introduce-form__smi-name').val(); 109 110 111 if(name != '') { 112 self.smiName = name; 113 self.smiNameSession = name; 114 115 $.cookie('smiName', self.smiName, { expires: 365, path: '/'}); 116 $.cookie('smiNameSession', self.smiNameSession, {path: '/'}); 117 } 118 }, 119 onClick: function (e, el) { 120 var self = this; 121 122 self.link_el = el; 123 self.link = el.attr('href'); 124 125 self.form = $('.media-download-introduce-form').clone(); 126 $('.media-download-introduce-form').remove(); 127 128 $.fancybox({ 129 'content': self.form, 130 'onClosed': function () { 131 $('.media-download-introduce-form-wrp').append(self.form); 132 } 133 }); 134 135 if(self.smiName) { 136 $('.media-download-introduce-form__smi-name').val(self.smiName); 137 } 138 }, 139 onHideClick: function (e, el) { 140 var self = this; 141 142 self.link_el = el; 143 self.link = el.attr('href'); 144 $('.media-download-introduce-form__smi-name').val(self.smiNameSession); 145 $('.media-download-introduce-form form').submit(); 146 }, 147 getLinkFormat: function () { 148 var self = this, 149 format; 150 151 console.log('getLinkFormat'); 152 format = self.link.match(/https:\/\//); 153 if(format == null) { 154 self.isFullLinkFormat = false; 155 } else { 156 self.isFullLinkFormat = true; 157 } 158 }, 159 download: function (popup) { 160 var self = this; 161 162 var win = window; 163 if(window.self !== window.top) { 164 win = window.top; 165 } 166 var full_link; 167 168 self.getLinkFormat(); 169 170 if(self.isFullLinkFormat == true) { 171 full_link = self.link; 172 } 173 if(self.isFullLinkFormat == false) { 174 full_link = win.location.origin + '/' + self.link; 175 } 176 177 var a = document.createElement("a"); 178 var iframe = document.createElement("iframe"); 179 if (typeof a.download === 'undefined') { 180 popup.location = full_link; 181 } else { 182 if(navigator.userAgent.toLowerCase().indexOf('firefox')) { 183 iframe.src = full_link; 184 iframe.style = "display: none;"; 185 win.document.body.appendChild(iframe); 186 } else { 187 a.href = full_link; 188 a.download = 'download.att'; 189 win.document.body.appendChild(a); 190 a.click(); 191 } 192 } 193 } 194 }; 195 196 window.mediaDownloadIntroduce = mediaDownloadIntroduce; 197 198 $(function () { 199 mediaDownloadIntroduce.init(); 200 }); 201}());
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.