1import Helpers from './helpers.class.js'; 2 3$(document).ready(function () { 4 5 const helpers = new Helpers(); 6 7 var storyTimeline; 8 var totalCountStories = 0; 9 var indexStory = 1; 10 var openStoriesId = 0; 11 const timeout = 300; 12 let idTimeout; 13 var forward = true; 14 15 $(document).on('click','.actionChangeAddStory', function (e) { 16 17 $(".storyAttachMediaInput").remove(); 18 19 $("body").append('<input type="file" '+helpers.config("stories_accept_upload_formats")+' style="display: none;" class="storyAttachMediaInput">'); 20 21 $(".storyAttachMediaInput").click(); 22 23 e.preventDefault(); 24 25 }); 26 27 $(document).on('change','.storyAttachMediaInput', function (e) { 28 29 $('.actionChangeAddStory').prop('disabled', true); 30 $('.actionChangeAddStory .widget-stories-item-process-load').css("visibility", "visible"); 31 32 var formData = new FormData(); 33 34 formData.append('attach_files', $(this)[0].files[0]); 35 36 var size = $(this)[0].files.item(0).size; 37 var type = $(this)[0].files.item(0).type; 38 39 if(type.split("/")[0] == "image"){ 40 41 if(size > helpers.config("stories_max_size_image")*1024*1024){ 42 helpers.showNoticeAnswer(helpers.translate.content("tr_da64c3d2aebe085e37b81de2b8f291d6")+' '+helpers.config("stories_max_size_image")+' '+helpers.translate.content("tr_505c12388f06a422b00aa0ac07de72c5")); 43 } 44 45 }else if(type.split("/")[0] == "video"){ 46 47 if(size > helpers.config("stories_max_size_video")*1024*1024){ 48 helpers.showNoticeAnswer(helpers.translate.content("tr_9ae516c38adb35538122d6c0ac3d98f0")+' '+helpers.config("stories_max_size_video")+' '+helpers.translate.content("tr_505c12388f06a422b00aa0ac07de72c5")); 49 } 50 51 }else{ 52 53 if(size > helpers.config("stories_max_size_image")*1024*1024){ 54 helpers.showNoticeAnswer(helpers.translate.content("tr_da64c3d2aebe085e37b81de2b8f291d6")+' '+helpers.config("stories_max_size_image")+' '+helpers.translate.content("tr_505c12388f06a422b00aa0ac07de72c5")); 55 } 56 57 } 58 59 helpers.request({url:"stories-upload-attach", data: formData, contentType: false, processData: false}, function(data) { 60 61 $('.actionChangeAddStory').prop('disabled', false); 62 $('.actionChangeAddStory .widget-stories-item-process-load').css("visibility", "hidden"); 63 64 if(data["status"] == true){ 65 66 if($(".user-stories-modal").length){ 67 $(".user-stories-modal").remove(); 68 } 69 70 $("body").css("overflow", "hidden"); 71 $("body").append(data["content"]); 72 73 $('.user-stories-modal-container-item[data-index="1"]').show(); 74 75 } 76 77 }); 78 79 e.preventDefault(); 80 81 }); 82 83 $(document).on('click','.actionCloseModalStories', function (e) { 84 85 closeModalStories(); 86 87 }); 88 89 function closeModalStories(){ 90 91 $('.user-stories-modal').fadeOut(200, function(){ 92 $('.user-stories-modal').remove(); 93 }); 94 95 var hashes = window.location.href.split('#'); 96 97 history.pushState("", "", hashes[0]); 98 99 $("body").css("overflow", "auto"); 100 101 if($('.story-video').length){ 102 $(".story-video")[0].pause(); 103 } 104 105 } 106 107 function loadStories(id, category_id){ 108 109 openStoriesId = id; 110 111 helpers.request({url:"stories-load", data: {id: id, category_id: category_id}}, function(data) { 112 113 $('.actionOpenModalUserStories[data-id="'+id+'"]').find(".stories-border-no-view").removeClass("stories-border-no-view"); 114 115 indexStory = 1; 116 totalCountStories = parseInt($('.user-stories-modal-container-item').length); 117 118 if($(".user-stories-modal").length){ 119 $(".user-stories-modal").remove(); 120 } 121 122 $("body").css("overflow", "hidden"); 123 $("body").append(data["content"]); 124 125 $('.user-stories-modal-container-item[data-index="'+indexStory+'"]').show(); 126 127 if($('.user-stories-modal-container-item[data-index="'+indexStory+'"] .story-video').length){ 128 $('.user-stories-modal-container-item[data-index="'+indexStory+'"] .story-video')[0].currentTime = 0; 129 $('.user-stories-modal-container-item[data-index="'+indexStory+'"] .story-video')[0].play(); 130 } 131 132 timeline(indexStory); 133 134 }); 135 136 } 137 138 function timeline(index=1){ 139 140 var duration = $('.user-stories-modal-container-item[data-index="'+index+'"]').data("duration") ? $('.user-stories-modal-container-item[data-index="'+index+'"]').data("duration") : '10'; 141 142 $('.user-stories-modal-container-header-timeline>div[data-index="'+index+'"]').html(""); 143 $('.user-stories-modal-container-header-timeline>div[data-index="'+index+'"]').append('<span class="animation" ></span>'); 144 145 storyTimeline = $('.user-stories-modal-container-header-timeline>div[data-index="'+index+'"] span'); 146 147 storyTimeline.css("animation-duration", duration+"s"); 148 149 storyTimeline.on('animationend', function () { 150 nextStory(); 151 }); 152 153 storyTimeline.css("animation-play-state", "running"); 154 155 } 156 157 $(document).on('click','.actionPublicationStory', function (e) { 158 159 helpers.startProcessLoadButton($('.actionPublicationStory')); 160 161 helpers.request({url:"stories-publication", data: {name: $(this).data("name"), type: $(this).data("type")}}, function(data) { 162 163 if(data["status"] == true){ 164 closeModalStories(); 165 helpers.showNoticeAnswer(data["answer"]); 166 }else{ 167 helpers.showNoticeAnswer(data["answer"]); 168 helpers.endProcessLoadButton($('.actionPublicationStory')); 169 } 170 171 }); 172 173 e.preventDefault(); 174 175 }); 176 177 $(document).on('click','.actionDeleteStory', function (e) { 178 179 helpers.deleteByAlert("stories-delete",{id:$(this).data("id")}); 180 181 e.preventDefault(); 182 183 }); 184 185 $(document).on('click','.actionOpenModalUserStories', function (e) { 186 187 loadStories($(this).data("id"), $(this).data("category-id")); 188 189 e.preventDefault(); 190 191 }); 192 193 $(document).on('click','.actionPrevLoadStory', function (e) { 194 195 prevStory(); 196 197 e.preventDefault(); 198 199 }); 200 201 $(document).on('mousedown','.actionNextLoadStory', function (e) { 202 203 idTimeout = setTimeout(function() { 204 205 forward = false; 206 storyTimeline.css("animation-play-state", "paused"); 207 if($('.story-video').length){ 208 $(".story-video")[0].pause(); 209 } 210 211 }, timeout); 212 213 }); 214 215 $(document).on('mouseup','.actionNextLoadStory', function (e) { 216 217 storyTimeline.css("animation-play-state", "running"); 218 if($('.user-stories-modal-container-item[data-index="'+indexStory+'"] .story-video').length){ 219 $('.user-stories-modal-container-item[data-index="'+indexStory+'"] .story-video')[0].play(); 220 } 221 222 clearTimeout(idTimeout); 223 224 if(forward){ 225 nextStory(); 226 } 227 228 forward = true; 229 230 }); 231 232 function nextStory(){ 233 234 let i = 1; 235 236 if($('.story-video').length){ 237 $('.story-video')[0].pause(); 238 } 239 240 indexStory = indexStory + 1; 241 242 if($('.user-stories-modal-container-item[data-index="'+indexStory+'"]').length){ 243 244 $('.user-stories-modal-container-item').hide(); 245 $('.user-stories-modal-container-item[data-index="'+indexStory+'"]').show(); 246 247 while (i < indexStory) { 248 $('.user-stories-modal-container-header-timeline>div[data-index="'+i+'"]').html(""); 249 $('.user-stories-modal-container-header-timeline>div[data-index="'+i+'"]').append('<span class="end" ></span>'); 250 i++; 251 } 252 253 $('.user-stories-modal-container-header-timeline>div[data-index="'+indexStory+'"]').html(""); 254 $('.user-stories-modal-container-header-timeline>div[data-index="'+indexStory+'"]').append('<span class="start" ></span>'); 255 256 if($('.user-stories-modal-container-item[data-index="'+indexStory+'"] .story-video').length){ 257 $('.user-stories-modal-container-item[data-index="'+indexStory+'"] .story-video')[0].currentTime = 0; 258 $('.user-stories-modal-container-item[data-index="'+indexStory+'"] .story-video')[0].play(); 259 } 260 261 timeline(indexStory); 262 263 }else{ 264 265 if($('.actionOpenModalUserStories[data-id="'+openStoriesId+'"]').next().data("id") != undefined){ 266 loadStories($('.actionOpenModalUserStories[data-id="'+openStoriesId+'"]').next().data("id"), $('.actionOpenModalUserStories[data-id="'+openStoriesId+'"]').next().data("category-id")); 267 }else{ 268 closeModalStories(); 269 } 270 271 } 272 273 } 274 275 function prevStory(){ 276 277 let i = 1; 278 279 if($('.story-video').length){ 280 $('.story-video')[0].pause(); 281 } 282 283 indexStory = indexStory - 1; 284 285 if($('.user-stories-modal-container-item[data-index="'+indexStory+'"]').length){ 286 287 $('.user-stories-modal-container-item').hide(); 288 $('.user-stories-modal-container-item[data-index="'+indexStory+'"]').show(); 289 290 $('.user-stories-modal-container-header-timeline>div').html(""); 291 $('.user-stories-modal-container-header-timeline>div').append('<span class="start" ></span>'); 292 293 while (i < indexStory) { 294 $('.user-stories-modal-container-header-timeline>div[data-index="'+i+'"]').html(""); 295 $('.user-stories-modal-container-header-timeline>div[data-index="'+i+'"]').append('<span class="end" ></span>'); 296 i++; 297 } 298 299 if($('.user-stories-modal-container-item[data-index="'+indexStory+'"] .story-video').length){ 300 $('.user-stories-modal-container-item[data-index="'+indexStory+'"] .story-video')[0].currentTime = 0; 301 $('.user-stories-modal-container-item[data-index="'+indexStory+'"] .story-video')[0].play(); 302 } 303 304 timeline(indexStory); 305 306 }else{ 307 308 if($('.actionOpenModalUserStories[data-id="'+openStoriesId+'"]').prev().data("id") != undefined){ 309 loadStories($('.actionOpenModalUserStories[data-id="'+openStoriesId+'"]').prev().data("id"), $('.actionOpenModalUserStories[data-id="'+openStoriesId+'"]').next().data("category-id")); 310 }else{ 311 closeModalStories(); 312 } 313 314 } 315 316 } 317 318});
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.