1 2//change by n.lashgari @ 3-9-93 3//Khodaei: 1392-09-05 modified 4function TopNews(flag, topPId, topModuleId, objRoot, viewMode, newsCountPerPage, viewSubtitle, Interval, moduleWidth, pictureHeight, autoSetPicHeight, pnlContainerClientID) { 5 //Khodaei: 1392-09-05 end of modified 6 this._topModuleId = topModuleId; 7 this._topPortalId = topPId; //+++ 8 this._root = objRoot; 9 this._currPageIndex = 0; 10 this._currNewsIndex = 0; 11 this._slideShowInterval = Interval; 12 this.nextNewsIntervalId = 0; 13 this._viewMode = viewMode; 14 this._newsCountPerPage = newsCountPerPage; 15 this._viewSubtitle = viewSubtitle; 16 this.news = new Array(); 17 this.baseHeight = 0; 18 this._state = 'play'; 19 this._newsDescState = 'normal'; 20 this._pagerFlag = true; 21 this._flag = flag; 22 this._moduleWidth = moduleWidth; 23 //Khodaei: 1392-09-05 added 24 this._pictureHeight = pictureHeight; 25 this._autoSetPicHeight = autoSetPicHeight; 26 //Khodaei: 1392-09-05 end of added 27 this.newsModules = new Array(); 28 this._pnlContainerCID = pnlContainerClientID; 29 if (this._viewMode != 'selectModules') 30 this.fetchAllNews(); 31 else { 32 this.selectModules(); 33 } 34} 35 36TopNews.prototype = { 37 //call asp.net page method asynchronous (send and recives data in JSON format) 38 PageMethod: function (fn, paramArray, successFn, errorFn, newsModuleListID) { 39 let pagePath = window.location; //.pathname; 40 let qString = pagePath.href.split('?')[1]; 41 let that = this; 42 //Khodaei: 1397-01-26, added for using from handler 43 let nmlID = ""; 44 if (newsModuleListID != null) 45 nmlID = "&nmlID=" + newsModuleListID; 46 else 47 nmlID = ""; 48 //Call the page method 49 $.ajax({
50 type: "POST", 51 //url: pagePath + "¤tMId=" + that._topModuleId + "&Callback=" + fn + "&pID=" + that._topPortalId + "&mode=" + that._viewMode, 52 url: "/DesktopModules/TopNews/TopNewsHandler.ashx?" + qString + "¤tMId=" + that._topModuleId + "&Callback=" + fn + "&pID=" + that._topPortalId + "&mode=" + that._viewMode + nmlID, 53 contentType: "application/json; charset=utf-8", 54 data: paramArray, 55 dataType: "json", 56 success: function (res) { successFn(res, that) }, 57 error: errorFn 58 }); 59 }, 60 usesNewsModules: function (response, that) { 61 let refresh = new Function(response.refresh); 62 refresh(); 63 }, 64 setNewsModules: function (newsModuleListID) { 65 let str = JSON.stringify(this.newsModules) 66 let pattern, s; 67 pattern = new RegExp('\\['); 68 s = str.replace(pattern, '{'); 69 pattern = /\]/; 70 s = s.replace(pattern, '}'); 71 this.PageMethod('setNewsModules', str, this.usesNewsModules, this.FailSetModules, newsModuleListID); 72 }, 73 //override jquery selector to ensure selected DOM objects be unique in multiple instanse of module 74 getElement: function (domElement) { 75 return $(this._root).find(domElement); 76 }, 77 ToggleDesc: function (itm) { 78 let ht = this.getElement('.main_news').find('.block').height() - $(itm).parent().height(); 79 if ($(itm).find('div').attr('class') == 'ContractButton') { 80 this.getElement('.main_news .block').animate({ marginBottom: -ht }, 250, function () { $(itm).find('div').removeClass('ContractButton').addClass('ExpandButton'); }); 81 this._newsDescState = 'minimized'; 82 } 83 else { 84 this.getElement('.main_news .block').animate({ marginBottom: "0" }, 250, function () { $(itm).find('div').removeClass('ExpandButton').addClass('ContractButton'); }); 85 this._newsDescState = 'normal'; 86 } 87 }, 88 initUI: function (firstRun) { 89 let that = this; 90 $('.TNContainer').parent().parent().css('padding', 0); 91 switch (this._viewMode) { 92 // janani 93 case 'CustomMode': 94 95 96 if (this.getElement('.main_news .logo').text() == '') { 97 this.getElement('.main_news .logo').css('display', 'none'); 98 } 99 else { 100 this.getElement('.main_news .logo').animate({ opacity: 0.60 }, 1, function () { 101 if (navigator.userAgent.match(/edg/gi)) { 102 this.style.removeAttribute('filter'); 103 } 104 }); 105 } 106 that.getElement('.toolbar ul').empty(); 107 for (let i = 0; i < this.getElement('.news_thumb div.active ul li').length; i++) 108 this.getElement('.toolbar ul').append('<li> </li>'); 109 110 if (!this._viewSubtitle) { 111 this.getElement('.subtitlebar').hide(); 112 } 113 114 //add handlers 115 if (firstRun == 'true') { 116 this.getElement('#toggleDescIcon').click(function () { that.ToggleDesc(this); }); 117 this.getElement('.toolbar #btnPrev').click(function () { that.nextNews(that); }); 118 this.getElement('.toolbar #btnNext').click(function () { that.prevNews(); }); 119 this.getElement('.toolbar #btnPausePlay').click(function () { that.PausePlay(this); }); 120 } 121 122 this.getElement('.news_thumb ul li').click(function () { 123 if ($(this).is('.active')) { 124 return false; 125 } 126 else { 127 that.getElement('.news_thumb ul li').removeClass('active'); 128 $(this).addClass('active'); 129 that._currNewsIndex = (that._currPageIndex * that._newsCountPerPage) + $(this).prevAll('li').size(); 130 if (that._state == 'play') { 131 clearInterval(that.nextNewsIntervalId); 132 that.nextNewsIntervalId = setInterval(function () { that.nextNews(that); }, that._slideShowInterval); 133 } 134 that.setTopOne(); 135 } 136 return false; 137 }).hover(function () { 138 $(this).addClass('hover'); 139 }, function () { 140 $(this).removeClass('hover'); 141 }); 142 143 this.getElement('.pagerbar ul li').click(function () { 144 if (!that._pagerFlag) 145 return; 146 if ($(this).is('.active')) { 147 return false; 148 } 149 else { 150 that._pagerFlag = false; 151 that.getElement('.pagerbar ul li').removeClass('active'); 152 $(this).addClass('active'); 153 154 let selectedPageIndex = $(this).prevAll('li').size(); 155 156 let ht = that.getElement('.news_thumb').height(); 157 158 if (selectedPageIndex > that._currPageIndex) { 159 let upStep = Math.abs(parseInt(that.getElement('.news_thumb > div:first').css('margin-top'))) + ht; 160 that.getElement('.news_thumb > div:first').animate({ marginTop: -upStep }, 1000, function () { 161 that._currPageIndex = selectedPageIndex; 162 that.BindTextNews(); 163 164 that.setSubtitle(); 165 that.initUI('false'); 166 167 that.getElement('.news_thumb ul li:first').removeClass('active'); 168 that.getElement('.news_thumb ul li:first').click(); 169 170 that._pagerFlag = true; 171 }); 172 } 173 else { 174 //changed by Janani 19-12-1392 add - before downstep 175 let downStep = parseInt(that.getElement('.news_thumb > div:first').css('margin-top')) + ht; 176 that.getElement('.news_thumb > div:first').animate({ marginTop: -downStep }, 1000, function () { 177 that._currPageIndex = selectedPageIndex; 178 that.BindTextNews(); 179 180 that.setSubtitle(); 181 that.initUI('false'); 182 183 that.getElement('.news_thumb ul li:first').removeClass('active'); 184 that.getElement('.news_thumb ul li:first').click(); 185 186 that._pagerFlag = true; 187 }); 188 } 189 } 190 }).hover(function () { 191 $(this).addClass('hover'); 192 }, function () { 193 $(this).removeClass('hover'); 194 }); 195 196 break; 197 198 case 'TextMode': 199 let minHeight = this.getElement('.news_thumb > div > ul:first').height(); //this.baseHeight ? this.getElement('.news_thumb > div:first').height() : this.baseHeight; 200 //this.getElement('.news_thumb').css({ 'height': minHeight + 'px', 'min-height': minHeight + 'px' }); 201 //this.getElement('.news_thumb').width(this._moduleWidth);
202 this.getElement('.news_thumb ul li .block p').hide(); 203 204 this.getElement('.news_thumb ul li').click(function () { 205 $('.news_thumb ul li.active .block p').cycle('pause').hide(); 206 let locale = new String(); 207 locale = "fa-ir"; 208 if (queryString("Lang") != "false") 209 locale = queryString("Lang") 210 else if (queryString("lang") != "false") 211 locale = queryString("lang") 212 locale = locale.toLowerCase(); 213 if (locale == "fa-ir") 214 $(this).find('.block p').show().cycle({ fx: 'scrollRight', cleartype: 0, sync: 1, delay: -10000, continuous: 0, speed: 12000 }); //.hide().cycle('pause') 215 else 216 $(this).find('.block p').show().cycle({ fx: 'scrollLeft', cleartype: 0, sync: 1, delay: -10000, continuous: 0, speed: 12000 }); //.hide().cycle('pause') 217 that.getElement('.news_thumb ul li').removeClass('active'); 218 $(this).addClass('active'); 219 clearInterval(that.nextNewsIntervalId); 220 that.nextNewsIntervalId = setInterval(function () { that.nextNews(that); }, that._slideShowInterval); 221 that._currNewsIndex = (that._currPageIndex * that._newsCountPerPage) + $(this).prevAll('li').size(); 222 }).hover(function () { 223 $(this).addClass('hover'); 224 }, function () { 225 $(this).removeClass('hover'); 226 }); 227 228 this.getElement('.pagerbar ul li').click(function () { 229 if (!that._pagerFlag) 230 return; 231 if ($(this).is('.active')) { 232 return false; 233 } 234 else { 235 that._pagerFlag = false; 236 that.getElement('.pagerbar ul li').removeClass('active'); 237 $(this).addClass('active'); 238 239 let selectedPageIndex = $(this).prevAll('li').size(); 240 let ht = that.getElement('.news_thumb').height(); 241 242 if (selectedPageIndex > that._currPageIndex) { 243 let upStep = Math.abs(parseInt(that.getElement('.news_thumb > div:first').css('margin-top'))) + ht; 244 that.getElement('.news_thumb > div:first').animate({ marginTop: -upStep }, 1000, function () { 245 that._currPageIndex = selectedPageIndex; 246 that.BindTextNews(); 247 248 that._currNewsIndex = 0; 249 250 that.initUI('false'); 251 252 that._pagerFlag = true; 253 }); 254 } 255 else { 256 let downStep = parseInt(that.getElement('.news_thumb > div:first').css('margin-top')) + ht; 257 that.getElement('.news_thumb > div:first').animate({ marginTop: downStep }, 1000, function () { 258 that._currPageIndex = selectedPageIndex; 259 that.BindTextNews(); 260 261 that._currNewsIndex = 0; 262 263 that.initUI('false'); 264 265 that._pagerFlag = true; 266 }); 267 } 268 } 269 }).hover(function () { 270 $(this).addClass('hover'); 271 }, function () { 272 $(this).removeClass('hover'); 273 }); 274 275 break; 276 case 'PictureMode': 277 278 //this.getElement('.main_news').width(this._moduleWidth);
279 //Khodaei: 1392-09-05 modified as 280 //this.getElement('.main_news').height(this.getElement('.main_news').width() / 1.6); 281 this.getElement('.main_news').height("auto"); 282 if (this._autoSetPicHeight) { 283 this.getElement('.main_news').height("auto"); 284 } 285 else { 286 this.getElement('.main_news').height(this._pictureHeight); 287 } 288 //Khodaei: 1392-09-05 end of modified as 289 this.getElement('.main_news').siblings().width(this.getElement('.main_news').width()); 290 if (this.getElement('.main_news .logo').text() == '') { 291 292 this.getElement('.main_news .logo').animate({ opacity: 0 }, 1, function () { 293 this.getElement('.main_news .logo').css('display', 'none'); 294 }); 295 } 296 else 297 this.getElement('.main_news .logo').animate({ opacity: 0.60 }, 1, function () { 298 if (navigator.userAgent.match(/edg/gi)) { 299 this.style.removeAttribute('filter'); 300 } 301 }); 302 that.getElement('.toolbar ul').empty(); 303 for (let i = 0; i < this.news.length; i++) 304 this.getElement('.toolbar ul').append('<li> </li>'); 305 //add handlers 306 if (firstRun == 'true') { 307 this.getElement('#toggleDescIcon').click(function () { that.ToggleDesc(this); }); 308 this.getElement('.toolbar #btnPrev').click(function () { that.nextNews(that); }); 309 this.getElement('.toolbar #btnNext').click(function () { that.prevNews(); }); 310 this.getElement('.toolbar #btnPausePlay').click(function () { that.PausePlay(this); }); 311 } 312 break; 313 case 'FullMode': 314 //this.getElement('.main_news').width(this._moduleWidth);
315 //this.getElement('.main_news').siblings().width(this.getElement('.main_news').width()); 316 if (this.getElement('.main_news .logo').text() == '') { 317 this.getElement('.main_news .logo').css('display', 'none'); 318 } 319 else { 320 this.getElement('.main_news .logo').animate({ opacity: 0.60 }, 1, function () { 321 if (navigator.userAgent.match(/edg/gi)) { 322 this.style.removeAttribute('filter'); 323 } 324 }); 325 } 326 that.getElement('.toolbar ul').empty(); 327 for (let i = 0; i < this.getElement('.news_thumb div.active ul li').length; i++) 328 this.getElement('.toolbar ul').append('<li> </li>'); 329 330 if (!this._viewSubtitle) { 331 this.getElement('.subtitlebar').hide(); 332 } 333 //add handlers 334 if (firstRun == 'true') { 335 this.getElement('#toggleDescIcon').click(function () { that.ToggleDesc(this); }); 336 this.getElement('.toolbar #btnPrev').click(function () { that.nextNews(that); }); 337 this.getElement('.toolbar #btnNext').click(function () { that.prevNews(); }); 338 this.getElement('.toolbar #btnPausePlay').click(function () { that.PausePlay(this); }); 339 } 340 this.getElement('.news_thumb ul li').click(function () { 341 if ($(this).is('.active')) { 342 return false; 343 } 344 else { 345 that.getElement('.news_thumb ul li').removeClass('active'); 346 $(this).addClass('active'); 347 that._currNewsIndex = (that._currPageIndex * that._newsCountPerPage) + $(this).prevAll('li').size(); 348 if (that._state == 'play') { 349 clearInterval(that.nextNewsIntervalId); 350 that.nextNewsIntervalId = setInterval(function () { that.nextNews(that); }, that._slideShowInterval); 351 } 352 that.setTopOne(); 353 } 354 return false; 355 }).hover(function () { 356 $(this).addClass('hover'); 357 }, function () { 358 $(this).removeClass('hover'); 359 }); 360 361 this.getElement('.pagerbar ul li').click(function () { 362 if (!that._pagerFlag) 363 return; 364 if ($(this).is('.active')) { 365 return false; 366 } 367 else { 368 that._pagerFlag = false; 369 that.getElement('.pagerbar ul li').removeClass('active'); 370 $(this).addClass('active'); 371 372 let selectedPageIndex = $(this).prevAll('li').size(); 373 374 let ht = that.getElement('.news_thumb').height(); 375 376 if (selectedPageIndex > that._currPageIndex) { 377 let upStep = Math.abs(parseInt(that.getElement('.news_thumb > div:first').css('margin-top'))) + ht; 378 that.getElement('.news_thumb > div:first').animate({ marginTop: -upStep }, 1000, function () { 379 that._currPageIndex = selectedPageIndex; 380 that.BindTextNews(); 381 382 that.setSubtitle(); 383 that.initUI('false'); 384 385 that.getElement('.news_thumb ul li:first').removeClass('active'); 386 that.getElement('.news_thumb ul li:first').click(); 387 388 that._pagerFlag = true; 389 }); 390 } 391 else { 392 let downStep = parseInt(that.getElement('.news_thumb > div:first').css('margin-top')) + ht; 393 that.getElement('.news_thumb > div:first').animate({ marginTop: -downStep }, 1000, function () { 394 that._currPageIndex = selectedPageIndex; 395 that.BindTextNews(); 396 397 that.setSubtitle(); 398 that.initUI('false'); 399 400 that.getElement('.news_thumb ul li:first').removeClass('active'); 401 that.getElement('.news_thumb ul li:first').click(); 402 403 that._pagerFlag = true; 404 }); 405 } 406 } 407 }).hover(function () { 408 $(this).addClass('hover'); 409 }, function () { 410 $(this).removeClass('hover'); 411 }); 412 413 break; 414 } 415 }, 416 setTopOne: function () { 417 //set letiables 418 let that = this; 419 let imgSrc = this.news[this._currNewsIndex].imgSrc; 420 let imgAlt = this.news[this._currNewsIndex].imgAlt; 421 let newsTitle = this.news[this._currNewsIndex].Title; 422 let newsSubTitle = this.news[this._currNewsIndex].SubTitle; 423 let newsPreTitle = this.news[this._currNewsIndex].PreTitle; 424 let picWidth = this.news[this._currNewsIndex].picWidth; 425 let newsDesc = this.news[this._currNewsIndex].Summary; 426 let newsDate = this.news[this._currNewsIndex].newsDate; 427 let newsUrl = this.news[this._currNewsIndex].newsUrl; 428 let newsDescHeight = this.getElement('.main_news').find('.block').height(); 429 let animateFunc = { opacity: 0, marginBottom: -newsDescHeight }; 430 if (that._newsDescState != 'normal') { 431 animateFunc = { opacity: 0.60 }; 432 } 433 //lashgari 434 if (String(this._flag) == "True") { 435 this.getElement('.main_news .desc').show(); 436 } 437 else { 438 this.getElement('.main_news .desc').hide(); 439 } 440 441 this.getElement('.main_news .block').animate(animateFunc, 250, function () { 442 that.getElement('a').attr('href', newsUrl); 443 that.getElement('.main_news .block h2 a').text(newsTitle); 444 that.getElement('.main_news .block .SubTitle').text(newsSubTitle); 445 that.getElement('.main_news .block .PreTitle').text(newsPreTitle); 446 that.getElement('.main_news .block small').text(newsDate); 447 that.getElement('.main_news .block small').html(newsDate); 448 that.getElement('p').text(newsDesc); 449 //Khodaei: 1397-01-27, modified 450 //add by janani 12-12-92 451 //$('#paragraph').append(' ').append($('<a></a>').text('ادا٠Ù...').attr('href', newsUrl).attr('target', '_blank')); 452 $(that._root + ' #paragraph').append(' ').append($('<a></a>').text('ادا٠Ù...').attr('href', newsUrl).attr('target', '_blank')); 453 //end of add by janani 12-12-92 454 if (that._newsDescState == 'normal') 455 that.getElement('.main_news .block').animate({ opacity: 0.60, marginBottom: 0 }, 250, function () { 456 that.getElement('.main_news .block #toggleDescIcon').html('<div class="ContractButton"> </div>'); 457 }); 458 else 459 that.getElement('.main_news .block').animate({ opacity: 0.60, marginBottom: -1 * (that.getElement('.main_news .block').height() - that.getElement('.main_news .block h2').parent().height()) }, 0, function () { 460 461 }); 462 that.getElement('.main_news #imgMain').attr('src', imgSrc); 463 that.getElement('.main_news #imgMain').attr('alt', imgAlt); 464 that.getElement('.main_news #imgMain').parent().attr('href', newsUrl); 465 466 //Khodaei: 1392-09-05 modified 467 if (that._autoSetPicHeight) { 468 that.getElement('.main_news #imgMain').css({ 'min-height': $('div #imgMain').width() / 1.6, 'width': picWidth }); 469 } 470 else { 471 that.getElement('.main_news #imgMain').css({ 'height': that._pictureHeight, 'width': that._moduleWidth }); 472 } 473 //Khodaei: 1392-09-05 end of modified 474 }); 475 476 this.getElement('.toolbar ul li').removeClass('active'); 477 switch (that._viewMode) { 478 case 'CustomMode': 479 this.getElement('.toolbar ul li:eq(' + (this._currNewsIndex % this._newsCountPerPage) + ')').addClass('active'); 480 break; 481 case 'FullMode': 482 this.getElement('.toolbar ul li:eq(' + (this._currNewsIndex % this._newsCountPerPage) + ')').addClass('active'); 483 break; 484 case 'PictureMode': 485 this.getElement('.toolbar ul li:eq(' + this._currNewsIndex + ')').addClass('active'); 486 break; 487 } 488 }, 489 BindPager: function () { 490 this.getElement('.pagerbar div:eq(1) ul').empty(); 491 for (let index = 0; index < this.news.length; index++) { 492 if (index % this._newsCountPerPage == 0) { 493 this.getElement('.pagerbar div:eq(1) ul').append($('<li></li>').text(Math.floor(index / this._newsCountPerPage) + 1)); 494 } 495 } 496 }, 497 BindTextNews: function () { 498 this.getElement('.news_thumb').empty(); 499 500 for (let index = (this._currPageIndex * this._newsCountPerPage); index < (this._currPageIndex + 1) * this._newsCountPerPage; index++) { 501 if (index >= this.news.length) break; 502 if (index % this._newsCountPerPage == 0) { 503 $('<div><ul></ul></div>').appendTo(this.getElement('.news_thumb')); 504 } 505 switch (this._viewMode) { 506 /* custom mode */ 507 /* DOM has edited for responsive top news on custom mode - 1396-12-23 n.ghelichkhani */ 508 case 'CustomMode': 509 $('<li class=\'uk-clearfix\'></li>').append( 510 $('<div data-responsiveChild=\'\'></div>').addClass("dp-TNCustom small-img") 511 .append($('<a></a>').attr('target', '_blank').attr('href', this.news[index].newsUrl) 512 .append($('<img style=\'display:' + this.news[index].Display + ';\' />').attr('alt', this.news[index].imgAlt).attr('src', this.news[index].imgThumbSrc)))) 513 .append($('<div data-responsiveChild=\'\'></div>').addClass("dp-TNCustom detail") 514 .append($('<div></div>').addClass('block') 515 .append($('<h2 class=\'dpTNCustom title\'></h2>').text(this.news[index].Title)) 516 ) 517 ).appendTo(this.getElement('.news_thumb ul:last')); 518 break; 519 /* full mode */ 520 /* DOM has edited for responsive top news on full mode - 1396-12-23 n.ghelichkhani */ 521 case 'FullMode': 522 $('<li></li>').append($('<h3 class=\'PreTitle\'></h3>').text(this.news[index].PreTitle)).append($('<h2 class=\'dp-TNFull title\'></h2>').text(this.news[index].Title)).append($('<h3 class=\'SubTitle\'></h3>').text(this.news[index].SubTitle)).appendTo(this.getElement('.news_thumb div:last ul'));
523 break; 524 /* text mode */ 525 /* DOM has edited for responsive top news on text mode - 1396-12-23 n.ghelichkhani */ 526 case 'TextMode': 527 $('<li></li>').append( 528 $($('<div></div>').addClass('dp-TNText box').append( 529 $('<div data-responsiveChild=\'\' data-responsive-center=\'\'></div>').addClass('dp-TNText image') 530 .append($('<a></a>').attr('target', '_blank').attr('href', this.news[index].newsUrl) 531 .append($('<img style=\'display:' + this.news[index].Display + ';\' />').attr('alt', this.news[index].imgAlt).attr('src', this.news[index].imgThumbSrc)))) 532 .append($('<div></div>').addClass('dp-TNText detail') 533 .append($('<h4 class=\'dp-TNText PreTitle\'></h4>').text(this.news[index].PreTitle)) 534 .append($('<a></a>').attr('target', '_blank').attr('href', this.news[index].newsUrl) 535 .append($('<h2 class=\'dp-TNText title\'></h2>').text(this.news[index].Title))) 536 .append($('<h3 class=\'dp-TNText SubTitle\'></h3>').text(this.news[index].SubTitle)) 537 .append($('<p class=\'dp-TNText date\'></p>').html(this.news[index].newsDate)) 538 .append($('<section class=\'dp-TNText abstract\'></section>') 539 .append($('<p></p>').text(this.news[index].Summary)) 540 .append('<span> </span>') 541 ) 542 ) 543 ) 544 ).appendTo(this.getElement('.news_thumb ul:last')); 545 break; 546 } 547 } 548 549 this.getElement('.news_thumb > div:first').addClass('active'); 550 this.getElement('.news_thumb ul li:first').addClass('active'); 551 this.getElement('.pagerbar div:eq(' + (this._currPageIndex + 1) + ') ul li:first').addClass('active'); 552 }, 553 setSubtitle: function () { 554 if (this._viewSubtitle) { 555 this.getElement('.subtitlebar').show(); 556 this.getElement('.subtitlebar').empty(); 557 let startIndex = (this._currPageIndex + 1) * this._newsCountPerPage; 558 for (let index = startIndex; index < this.news.length; index++) { 559 this.getElement('.subtitlebar') 560 .append($('<span></span>').text(this.news[index].Title)) 561 } 562 this.getElement('.subtitlebar').cycle({ fx: 'scrollUp', cleartype: 0, timeout: 6000 }); 563 } 564 }, 565 nextNews: function (that) { 566 switch (that._viewMode) { 567 case 'CustomMode': 568 case 'TextMode': 569 case 'FullMode': 570 that.getElement('.news_thumb div.active ul li:eq(' + (((that._currNewsIndex + 1) % that._newsCountPerPage) % that.getElement('.news_thumb div.active ul li').length) + ')').click(); 571 break; 572 573 case 'PictureMode': 574 that._currNewsIndex = that._currNewsIndex + 1; 575 if (that._currNewsIndex >= that.news.length) 576 that._currNewsIndex = 0; 577 if (that._state == 'play') { 578 clearInterval(that.nextNewsIntervalId); 579 that.nextNewsIntervalId = setInterval(function () { that.nextNews(that); }, that._slideShowInterval); 580 } 581 that.setTopOne(); 582 break; 583 } 584 }, 585 prevNews: function () { 586 switch (this._viewMode) { 587 case 'CustomMode': 588 case 'TextMode': 589 case 'FullMode': 590 if (this._currNewsIndex % this._newsCountPerPage == 0) 591 this.getElement('.news_thumb div.active ul li:eq(' + (this.getElement('.news_thumb div.active ul li').length - 1) + ')').click(); 592 else 593 this.getElement('.news_thumb div.active ul li:eq(' + ((this._currNewsIndex - 1) % this._newsCountPerPage) % this.getElement('.news_thumb div.active ul li').length + ')').click(); 594 break; 595 case 'PictureMode': 596 this._currNewsIndex = this._currNewsIndex - 1; 597 if (this._currNewsIndex < 0) 598 this._currNewsIndex = this.news.length - 1; 599 if (this._state == 'play') { 600 clearInterval(this.nextNewsIntervalId); 601 this.nextNewsIntervalId = setInterval(function () { this.prevNews(); }, this._slideShowInterval); 602 } 603 this.setTopOne(); 604 break; 605 } 606 }, 607 PausePlay: function (itm) { 608 let str = new String($(itm).attr('src')); 609 let pattern, s; 610 if (str.toLowerCase().search('pause.png') != -1) { 611 pattern = new RegExp('(Pause.png)', 'gi'); 612 s = $(itm).attr('src').replace(pattern, 'play.png'); 613 $(itm).attr('src', s); 614 clearInterval(this.nextNewsIntervalId); 615 this._state = 'pause'; 616 } 617 else { 618 pattern = new RegExp('(play.png)', 'gi'); 619 s = $(itm).attr('src').replace(pattern, 'Pause.png'); 620 $(itm).attr('src', s); 621 let that = this; 622 this.nextNewsIntervalId = setInterval(function () { that.nextNews(that); }, this._slideShowInterval); 623 this._state = 'play'; 624 } 625 }, 626 BindNews: function () { 627 let that = this; 628 switch (this._viewMode) { 629 case 'CustomMode': 630 this.BindPager(); 631 this.BindTextNews(); 632 this.setSubtitle(); 633 this.initUI('true'); 634 this.getElement('.news_thumb ul li:first').removeClass('active'); 635 this.getElement('.news_thumb ul li:first').click(); 636 break; 637 case 'TextMode': 638 this.getElement('.news_thumb').css('margin-left', 'auto'); 639 this.BindPager(); 640 this.BindTextNews(); 641 this.initUI('true'); 642 this.getElement('.news_thumb ul li:first').removeClass('active'); 643 this.getElement('.news_thumb ul li:first').click(); 644 break; 645 case 'PictureMode': 646 this.initUI('true'); 647 this.setTopOne(); 648 this.nextNewsIntervalId = setInterval(function () { that.nextNews(that); }, this._slideShowInterval); 649 break; 650 case 'FullMode': 651 this.BindPager(); 652 this.BindTextNews(); 653 this.setSubtitle(); 654 this.initUI('true'); 655 this.getElement('.news_thumb ul li:first').removeClass('active'); 656 this.getElement('.news_thumb ul li:first').click(); 657 break; 658 } 659 }, 660 SuccessFetchNews: function (response, that) { 661 if (response.noitem != undefined) 662 $(that._root).empty().html(response.noitem); 663 $(that._root).find('div:first').show(); 664 that.news = response; 665 if (response.length == undefined) 666 that.news = new Array(response); 667 that.BindNews(); 668 }, 669 670 FailFetchNews: function (err) { 671 }, 672 673 fetchAllNews: function () { 674 this.PageMethod('fetchAllNews', '{}', this.SuccessFetchNews, this.FailFetchNews); 675 }, 676 SuccessselectModules: function (response, that) { 677 that.newsModules = response; 678 if (response.length == undefined) 679 that.newsModules = new Array(response); 680 let query = new jsinq.Query('\ 681 from portal in $0 \ 682 select portal \ 683 '); 684 query.setValue(0, new jsinq.Enumerable(response)); 685 let result = query.execute(); 686 let enumerator = result.groupBy(function (a) { return a.portalID }).getEnumerator(); 687 that.getElement('#portals').empty(); 688 while (enumerator.moveNext()) { 689 that.getElement('#portals').append($('<option></option>').text(enumerator.current().first().portalAlias).val(enumerator.current().first().portalID)); 690 } 691 enumerator = result.where(function (a) { return a.selected == true; }).getEnumerator(); 692 that.getElement('#SelectedNews').empty(); 693 while (enumerator.moveNext()) { 694 that.getElement('#SelectedNews').append($('<option></option>').text(enumerator.current().moduleTitle).val(enumerator.current().moduleID)); 695 } 696 697 let bindModules = function (index) { 698 that.getElement('#portals option[value="' + index + '"]').attr('selected', true); 699 that.getElement('#nominatedNews').empty(); 700 enumerator = result.where(function (a) { return a.portalID == index; }).getEnumerator(); 701 while (enumerator.moveNext()) { 702 if (!enumerator.current().selected) 703 that.getElement('#nominatedNews').append($('<option></option>').text(enumerator.current().moduleTitle).val(enumerator.current().moduleID)); 704 } 705 }; 706 //Khodaei: 1397-01-26, changed for the module list was empty in subPortals. 707 //bindModules(0); 708 bindModules(that.getElement('#portals option')[0].value); 709 that.getElement('#portals').unbind('change'); 710 that.getElement('#portals').change(function (event) { 711 bindModules(event.target.value); 712 }); 713 that.getElement('#modSelect').unbind('click'); 714 that.getElement('#modSelect').click(function () { 715 that.getElement('#nominatedNews option').each(function (i, item) { 716 if ($(item).is(':selected')) { 717 result.where(function (a) { return a.moduleID == $(item).attr('value') }).first().selected = true; 718 that.getElement('#SelectedNews').append($(item)); 719 } 720 }); 721 }); 722 that.getElement('#modUnselect').unbind('click'); 723 that.getElement('#modUnselect').click(function () { 724 that.getElement('#SelectedNews option').each(function (i, item) { 725 if ($(item).is(':selected')) { 726 enumerator = result.where(function (a) { return a.moduleID == $(item).attr('value') }); 727 enumerator.first().selected = false; 728 $(item).remove(); 729 bindModules(enumerator.first().portalID); 730 } 731 }); 732 }); 733 }, 734 FailselectModules: function (err) { 735 }, 736 FailSetModules: function (err) { 737 738 }, 739 selectModules: function () { 740 this.PageMethod('selectModules', '{}', this.SuccessselectModules, this.FailselectModules); 741 }, 742 pausecomp: function (millis) { 743 let date = new Date(); 744 let curDate = null; 745 746 do { curDate = new Date(); } 747 while (curDate - date < millis); 748 } 749}
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.