MediaWiki:RecentChangesMultiple/core.js

// // // // // "				+ " "				+ " "			+ " "			+ " ";			+ " ";			if(!this.singleWiki) {				this.infoNode.querySelector(".banner-notification .close").addEventListener("click", this.closeInfo.bind(this));			}		}	}	RCMWikiPanel.prototype.closeInfo = function {		// $(infoBanner).hide(500, "linear", function {		$(this.infoNode.querySelector(".banner-notification")).animate({ height: "toggle", opacity: "toggle" }, 200, function{			$(this).remove;		});	}	RCMWikiPanel.prototype.goToAndOpenInfo = function(e) {		// console.log(e, e.currentTarget);		// console.log(e.currentTarget.dataset.infoid);		var btn = document.querySelector("#"+e.currentTarget.dataset.infoid);		if(btn) {			if(!Utils.elemIsVisible(btn)) {				var tScrollOffset = mw.config.get("skin") == "oasis" ? -46 : 0;				// $('html, body').animate({ scrollTop: $(btn).offset.top }, 0);				$('html, body').scrollTop( $(btn).offset.top + tScrollOffset - 6 ); }			btn.click; }	}	return RCMWikiPanel; })(window.jQuery, document, window.mediaWiki, window.dev.RecentChangesMultiple, window.dev.RecentChangesMultiple.Utils, window.dev.RecentChangesMultiple.i18n); // // "					+' '				+' ';				var tModule = $.showCustomModal(tTitle, ajaxform, {					id: 'rcm-diff-viewer',					width: 1000,					buttons: tButtons,					callbackBefore: function {						/* Disable page scrolling */						if ($(document).height > $(window).height) {							$('html').addClass('rcm-noscroll');						}					},					onAfterClose: RCData.onModalClosed,				});			},		});		// While we are waiting for results, open diff window to acknowledge user's input		if ($('#rcm-DiffView').length == 0) {			var ajaxform = ''			+''				+''					+"  "				+' '			+' ';			$.showCustomModal(tTitle, ajaxform, { id: 'rcm-diff-viewer', width: 1000, buttons: tButtons });		}	}	// STATIC - https://www.mediawiki.org/wiki/API:Imageinfo	RCData.previewImages = function(pAjaxUrl, pImageNames, pArticlePath) {		var tImagesInLog = pImageNames.slice;		var size = 210; // (1000-~40[for internal wrapper width]) / 4 - (15 * 2 [padding])		pAjaxUrl += "&iiurlwidth="+size+"&iiurlheight="+size;		var tCurAjaxUrl = pAjaxUrl + "&titles="+tImagesInLog.splice(0, 50).join("|");		if(module.debug) { console.log("http:"+tCurAjaxUrl.replace("&format=json", "&format=jsonfm"), pImageNames); }		var tTitle = i18n("awc-metrics-images");		// Need to push separately since undo link -may- not exist (Wikia style forums sometimes).		var tButtons = [			{				defaultButton: false,				message: i18n('flags-edit-modal-close-button-text'),				handler: RCData.closeModal			}		];		var tGetGalleryItem = function (pPage) {			var tPage = pPage, tPageTitleNoNS = null, tImage = null, tInvalidImage = null; if(tPage.imageinfo) { tImage = tPage.imageinfo[0]; } tPageTitleNoNS = tPage.title.indexOf(":") > -1 ? tPage.title.split(":")[1] : tPage.title; tInvalidImage = false; if(tPage.missing == "") { tInvalidImage = { thumbHref: pArticlePath+Utils.escapeCharactersLink(tPage.title), thumbText: i18n('filedelete-success', tPage.title), caption: tPageTitleNoNS };			} else if(tImage == null) { tInvalidImage = { thumbHref: pArticlePath+Utils.escapeCharactersLink(tPage.title), thumbText: i18n('shared_help_was_redirect', tPage.title), caption: tPageTitleNoNS };			} else if(Utils.isFileAudio(tPage.title)) { tInvalidImage = { thumbHref: tImage.url, thumbText: ' '+tPage.title, caption: tPageTitleNoNS };			} else if(tImage.thumburl == "" || (tImage.width == 0 && tImage.height == 0)) { tInvalidImage = { thumbHref: tImage.url, thumbText: tPage.title, caption: tPageTitleNoNS };			}			if(tInvalidImage !== false) { // Display text instead of image return ' ' +' '					+' '					+'' +tInvalidImage.thumbText +'' +' '					+' '					+' '						+tInvalidImage.caption +' '				+' ';			} else { tImage = tPage.imageinfo[0]; var tOffsetY = size/2 - tImage.thumbheight/2;//0; // if(tImage.height < tImage.width || tImage.height < size) { // 	tOffsetY = size/2 - (tImage.height > size ? tImage.height/2*(size/tImage.width) : tImage.height/2); // }				var tScaledWidth = tImage.thumbwidth;//size; // if(tImage.width < tImage.height && tImage.height > size) { // 	tScaledWidth = tImage.width * (size / tImage.height); // } else if(tImage.width < size) { // 	tScaledWidth = tImage.width; // }				return ' '//style="width:'+size+'px;" +' ' // style="height:'+size+'px;" +'' +'' +'' +'' +' '					+' '					+' '						+''+tPageTitleNoNS+'' +' '				+' ';			}		}		var tAddLoadMoreButton = function { if(tImagesInLog.length > 0) { if(module.debug) { console.log("Over 50 images to display; Extra images must be loaded later."); } var tModal = document.querySelector("#rcm-DiffView"); var tCont = Utils.newElement("center", { style:'margin-bottom: 8px;' }, tModal); var tButton = Utils.newElement("button", { innerHTML:i18n('specialvideos-btn-load-more') }, tCont); tButton.addEventListener("click", function{					tCurAjaxUrl = pAjaxUrl + "&titles="+tImagesInLog.splice(0, 50).join("|");					if(module.debug) { console.log("http:"+tCurAjaxUrl.replace("&format=json", "&format=jsonfm")); }					tCont.innerHTML = "";					$.ajax({ type: 'GET', dataType: 'jsonp', data: {}, url: tCurAjaxUrl, success: function(pData){ Utils.removeElement(tCont); for(var key in pData.query.pages) { tModal.innerHTML += tGetGalleryItem(pData.query.pages[key]); }							tAddLoadMoreButton; },					});				});			}		}		// Retrieve the diff table. // TODO - error support? $.ajax({ type: 'GET', dataType: 'jsonp', data: {}, url: tCurAjaxUrl,			success: function(pData){				// Re-open modal so that it gets re-positioned based on new content size.				RCData.closeModal;				var ajaxform = ''				+' '					+'#rcm-diff-viewer .thumbimage { max-width: '+size+'px; max-height: '+size+'px; width: auto; height: auto; }'					+'#rcm-diff-viewer .wikia-gallery-item { width: '+size+'px; }'					// +'#rcm-diff-viewer .wikia-gallery-item .lightbox { width: '+size+'px; }'					+'#rcm-diff-viewer .thumb { height: '+size+'px; }'					+'.image-no-lightbox { width: '+size+'px; }'				+' '				+''					+''; var tPage = null, tPageTitleNoNS = null, tImage = null, tInvalidImage = null; for(var key in pData.query.pages) { ajaxform += tGetGalleryItem(pData.query.pages[key]); }				ajaxform += '' +' '				+' ';				var tModule = $.showCustomModal(tTitle, ajaxform, {					id: 'rcm-diff-viewer',					width: 1000,					buttons: tButtons,					callbackBefore: function {						/* Disable page scrolling */						if ($(document).height > $(window).height) {							$('html').addClass('rcm-noscroll');						}					},					onAfterClose: RCData.onModalClosed,				}); setTimeout(function{ tAddLoadMoreButton; }, 100); },		});		// While we are waiting for results, open diff window to acknowledge user's input		if ($('#rcm-DiffView').length == 0) {			var ajaxform = ''			+''				+'<div id="rcm-DiffView" style="max-height:'+(($(window).height - 220) + "px")+';">'					+" <img src='"+module.LOADER_IMG+"'> "				+' '			+' ';			$.showCustomModal(tTitle, ajaxform, { id: 'rcm-diff-viewer', width: 1000, buttons: tButtons });		}	}	RCData.closeModal = function {		if($('#rcm-DiffView').length != 0) {			$('#rcm-diff-viewer').closeModal;		}	}	RCData.onModalClosed = function {		$("html").removeClass("rcm-noscroll");	}	return RCData; })(window.jQuery, document, window.mediaWiki, window.dev.RecentChangesMultiple, window.dev.RecentChangesMultiple.Utils, window.dev.RecentChangesMultiple.i18n); // // // //