Version 3.4.5

This commit is contained in:
Neo committed 2025-12-19 00:38:12 -08:00
1 parent fb6b5baabc
commit e4478369d8
1360 files changed
+228921 -179445

No files matched your search

+586 -16
View File
@@ -1,23 +1,580 @@
var ips = (function($){
function init(){
// Hide menus
$(".acp-menu").hide();
// Set up modal
$("#modal").css( { height: ( $(window).height() - parseInt( $("#header").height() ) ) } );
$(window).resize( function(e){
// ************************************ //
// jQuery ACP Functions //
// ************************************ //
/**
* IPS namespace
*/
var ips = {};
!function($, window, document, _undefined)
{
$.extend(ips,
{
/**
* Binds all registered functions to elements within the DOM
*/
init: function()
{
Debug.write('Initialising ips jQuery object');
/* Hide menus */
$(".acp-menu").hide();
/* Set up the modal */
$("#modal").css( { height: ( $(window).height() - parseInt( $("#header").height() ) ) } );
});
$(window).resize( function(e)
{
$("#modal").css( { height: ( $(window).height() - parseInt( $("#header").height() ) ) } );
} );
/* Bindings */
if ( $('#edit_tabs').length )
{
$('#edit_tabs').on( 'click', function(e) {
window.location = ips.acpUrl + '&app=core&module=mycp&section=tabs';
} );
}
Debug.write("All jQueried up in here");
},
/**
* POSTs and always expects JSON
*
* @param string url to GET
* @param object hash to POST
* @param function Method to run
* @param object Options
*
* @return XMLHttpRequest
*/
ajax: function( url, data, success, options )
{
url = url.replace( /&/g, '&' );
var ajaxOptions = $.extend(true,
{
data: data,
url: url,
success: function( data, textStatus, jqXHR )
{
success( data, textStatus, jqXHR );
},
type: 'POST',
dataType: 'json',
error: function(xhr, textStatus, errorThrown)
{
try
{
/* If its JSON, run it anyway */
success.call(null, $.parseJSON(xhr.responseText), textStatus);
}
catch (e)
{
/* Throw error */
console.error( xhr.responseText );
}
},
timeout: 30000
}, options);
return $.ajax(ajaxOptions);
},
/**
* Loads CSS
* @param url
*/
loadCss: function( url )
{
if ( url )
{
$('<link rel="stylesheet" type="text/css" media="screen,print" href="' + url + '" />').appendTo( $('head') );
}
},
/**
* Loads JS
* @param url
*/
loadJs: function( url )
{
if ( url && ( this.loadedJs.indexOf( url ) == -1 ) )
{
$('<script/>', { src: url, type: 'text/javascript' } ).appendTo('head');
this.loadedJs.push( url );
}
},
/**
* Get url param by name
*/
getQueryStringParamByName: function( name )
{
name = name.replace(/[\[]/, "\\\[").replace(/[\]]/, "\\\]");
var regexS = "[\\?&]" + name + "=([^&#]*)";
var regex = new RegExp(regexS);
var results = regex.exec(window.location.search);
if ( results == null )
{
return "";
}
else
{
return decodeURIComponent( results[1].replace(/\+/g, " ") );
}
},
/**
* User object
*/
member: {},
/**
* Url
*/
publicUrl: '',
/**
* Public image URL
*/
publicImageUrl: '',
/**
* ACP Image URL
*/
acpImageUrl: '',
/**
* Root URL
*/
rootUrl: '',
/**
* Public URL
*/
publicUrl: '',
/**
* ACP URL
*/
acpUrl: '',
/**
* Loaded JS
*/
loadedJs: [],
/**
* St value
*/
stVal: 0,
/**
* Bookmarks JSON
*/
bookmarksJSON: {},
/**
* Others
*/
formToken: '',
_popUpId: 0,
GLOBALS: {}
} );
/* Is JSON */
$.isJson = function(str)
{
if ($.trim(str) == '') return false;
str = str.replace(/\\./g, '@').replace(/"[^"\\\n\r]*"/g, '');
return (/^[,:{}\[\]0-9.\-+Eaeflnr-u \n\r\t]*$/).test(str);
},
/* stripTags */
$.stripTags = function(input, allowed)
{
allowed = (((allowed || "") + "").toLowerCase().match(/<[a-z][a-z0-9]*>/g) || []).join(''); // making sure the allowed arg is a string containing only tags in lowercase (<a><b><c>)
var tags = /<\/?([a-z][a-z0-9]*)\b[^>]*>/gi,
commentsAndPhpTags = /<!--[\s\S]*?-->|<\?(?:php)?[\s\S]*?\?>/gi;
return input.replace(commentsAndPhpTags, '').replace( tags, function ($0, $1)
{
return allowed.indexOf('<' + $1.toLowerCase() + '>') > -1 ? $0 : '';
} );
};
/**
* Use jQuery to initialize the system
*/
$(document).ready( ips.init );
}(jQuery, this, document);
/**
* Bookmark JS
*/
!function($, window, document, _undefined)
{
ips.Bookmarks = {};
/**
* Handle CKEditor
*/
ips.Bookmarks = function() { this.__construct(); };
ips.Bookmarks.prototype =
{
/**
* Construct object
*/
__construct: function()
{
this._buildBookmarkList();
$('#bookmarks_button').show();
$(document).on( 'click', '._closeIt', $.proxy( function(e)
{
ips.GLOBALS['bookPop'].hide();
return false;
}, this ) );
$('#bookmarks_button').on( 'click', $.proxy( function(e)
{
return this.addBookmark(e);
}, this ) );
$('#bookmarks_items').on( 'click', '#manageBookmark', $.proxy( function(e)
{
return this.manageBookmarks(e);
}, this ) );
$('#bookmarks_items').on( 'click', '#addBookmark', $.proxy( function(e)
{
return this.addBookmark(e);
}, this ) );
$('#bookmarks_items').on( 'click', '[data-url]', $.proxy( function(e)
{
return this.clickBookmark(e);
}, this ) );
/* Manage */
$(document).on( 'click', 'input[data-cboxid]', $.proxy( function(e)
{
var cbox = $(e.target);
$('input[data-cboxid]').each( function( idx )
{
if ( $(this).attr('data-cboxid') != $(cbox).attr('data-cboxid') )
{
$(this).removeAttr('checked');
}
} );
}, this ) );
$(document).on( 'click', 'img[data-deleteid]', $.proxy( function(e)
{
this.removeBookmark(e);
}, this ) );
$(document).on( 'click', '#saveBookmarksManage', $.proxy( function(e)
{
this.saveBookmarks(e);
}, this ) );
},
/**
* Bookmark clicked
*/
saveBookmarks: function(e)
{
var names = {};
var home = 0;
$('input[data-inputname]').each( function(idx)
{
var id = parseInt( $(this).attr('data-inputname') );
names[id] = $(this).val();
} );
if ( $('input[data-cboxid]:checked') )
{
home = $('input[data-cboxid]:checked').val();
}
var url = ips.acpUrl + 'secure_key=' + ips.formToken + '&app=core&module=ajax&section=bookmarks&do=save&' + $("#sortable").sortable('serialize');
var data = { home: home,
names: names };
ips.ajax( url, data, $.proxy( function( json )
{
if ( json.status == 'ok' )
{
ips.GLOBALS['bookManagePop'].hide();
/* Update JSON */
ips.bookmarksJSON = json.json;
this._buildBookmarkList();
}
else
{
if ( json.msg )
{
alert( json.msg );
}
}
}, this ) );
return false;
},
/**
* Bookmark clicked
*/
removeBookmark: function(e)
{
var elem = $(e.target);
var id = $(elem).attr('data-deleteid');
var url = ips.acpUrl + 'secure_key=' + ips.formToken + '&app=core&module=ajax&section=bookmarks&do=delete';
var data = { id: id };
if ( confirm( ipb.lang['ok_to_delete'] ) )
{
ips.ajax( url, data, $.proxy( function( json )
{
if ( json.status == 'ok' )
{
/* Remove row */
$('li[data-rowid=' + id + ']').fadeOut();
/* Update JSON */
ips.bookmarksJSON = json.json;
this._buildBookmarkList();
}
else
{
if ( json.msg )
{
alert( json.msg );
}
}
}, this ) );
}
return false;
},
/**
* Bookmark clicked
*/
clickBookmark: function(e)
{
var elem = $(e.target).closest('[data-url]');
var url = elem.attr('data-url');
var ok = true;
/* Check for partially completed values */
// @link http://community.invisionpower.com/resources/bugs.html/_/ip-board/bookmark-prompt-to-leave-page-r39989
// Only checking for bookmarks makes the functionality relatively useless and causes confusion
/*$.each( $('body').find('input[type=text]'), function( idx )
{
if ( ! $(this).hasClass('inactive') && $(this).val().length )
{
ok = false;
return false;
}
} );
$.each( $('body').find('textarea'), function( idx )
{
if ( $(this).val().length )
{
ok = false;
return false;
}
} );*/
if ( ok !== true )
{
if ( ! confirm( ipb.lang['go_bookmark_warn'] ) )
{
return false;
}
}
window.location.href = ips.acpUrl + '&' + url;
},
/**
* Manage bookmarks
*/
manageBookmarks: function(e)
{
if ( typeof( ips.GLOBALS['bookManagePop'] ) != 'undefined' )
{
ips.GLOBALS['bookManagePop'].kill();
}
var url = ips.acpUrl + 'secure_key=' + ips.formToken + '&app=core&module=ajax&section=bookmarks&do=managePane';
/* Show modal (eew Prototype)*/
ips.GLOBALS['bookManagePop'] = new ipb.Popup( 'bookManagePop', { type: 'modal',
ajaxURL: url,
hideAtStart: false,
modal: true,
w: '800px',
h: 450} );
$('#bookpPop_popup').off( 'click', '.realbutton' );
$('#bookpPop_popup').on( 'click', '.realbutton', $.proxy( function(e)
{
return this.doAddBookmark(e);
}, this ) );
return false;
},
/**
* Add a bookmark dialog
*/
addBookmark: function(e)
{
if ( typeof( ips.GLOBALS['bookPop'] ) != 'undefined' )
{
ips.GLOBALS['bookPop'].kill();
}
var _title = $('title').html();
var _can = $('body').attr('data-bookmarkable');
var _has = $('body').attr('data-bookmarked');
/* Got a url? */
var _url = this._getUrl();
/* Prep data */
_data = { 'title': _title };
/* Show modal (eew Prototype)*/
ips.GLOBALS['bookPop'] = new ipb.Popup( 'bookpPop', { type: 'modal',
initial: ipb.templates['acp_bookmark_add'].evaluate( _data ),
hideAtStart: false,
modal: true,
w: '600px',
h: 250} );
/* Test */
if ( _has == 'true' )
{
$('#bmcontent').html( ipb.lang['already_bookmark'] );
$('#bmcontent').append( $('<a/>', { 'class': 'mini_button _closeIt', href: '#' } ).html( ipb.lang['close_bookmark'] ) );
}
else if ( _can != 'true' )
{
$('#bmcontent').html( ipb.lang['cannot_bookmark'] );
}
$('#bookpPop_popup').off( 'click', '.realbutton' );
$('#bookpPop_popup').on( 'click', '.realbutton', $.proxy( function(e)
{
return this.doAddBookmark(e);
}, this ) );
return false;
},
/**
* Add the actual bookmark itself
*/
doAddBookmark: function(e)
{
var url = ips.acpUrl + 'secure_key=' + ips.formToken + '&app=core&module=ajax&section=bookmarks&do=add';
var data = { title: $('input[name=bookmarkTitle]').val(),
home : ( $('input[name=homePage]').attr('checked') == 'checked' ) ? 1 : 0,
url: this._getUrl() };
ips.ajax( url, data, $.proxy( function( json )
{
if ( json.status == 'ok' )
{
ips.GLOBALS['bookPop'].hide();
/* Update JSON */
ips.bookmarksJSON = json.json;
this._buildBookmarkList();
}
else
{
if ( json.msg )
{
$('#bmcontent').html( json.msg );
}
}
}, this ) );
return false;
},
/**
* Get the current URL
*/
_getUrl: function()
{
if ( $('body').attr('data-bookmarkurl').length > 0 )
{
return $('body').attr('data-bookmarkurl');
}
return window.location.toString().replace( /^(.+?)adsess=([\d\w]{32})(&amp;|&)(.*)/, '$4' );
},
/**
* Build up the bookmarks list
*/
_buildBookmarkList: function()
{
$('#bookmarks_items').html('');
if ( typeof( ips.bookmarksJSON ) != 'undefined' )
{
$.each( ips.bookmarksJSON, function( idx )
{
$('<a/>', { href: '#', 'data-url': this.url } ).html( this.title ).appendTo( $('<li/>').appendTo( $('#bookmarks_items') ) );
} );
}
$('<li/>', { style: 'text-align: center; min-width:200px', id: 'bookmarkAddRow' } ).appendTo( $('#bookmarks_items') );
$('<a/>', { id: 'addBookmark', 'class': 'mini_button secondary', style: 'margin: 5px 0px' } ).html( ipb.lang['add_bookmark'] ).appendTo('#bookmarkAddRow');
$('<a/>', { id: 'manageBookmark', 'class': 'mini_button secondary' } ).html( ipb.lang['manage_bookmark'] ).appendTo('#bookmarkAddRow');
}
}
return {
init: init
};
})(jQuery);
$(document).ready( function() { ipb.Bookmarks = new ips.Bookmarks(); } );
}(jQuery, this, document);
jQ(document).ready(function() {
ips.init();
//ips.init();
jQ("#app_menu").ipsMultiMenu( { keyboardTrigger: 77 } );
sidebar.init();
livesearch.init();
@@ -553,19 +1110,32 @@ var livesearch = {}, sidebar = {};
positionSubmenu = function( menu ){
var w = ( $(menu).outerWidth() - 5 ),
children = $(menu).children('ul:first'),
docSize = $(window).width();
docSize = $(window).width(),
docHeight = $(window).height();
children.css('left', w).css('top', -5);
// jQuery can't get offset from hidden elements, so show, measure, then hide.
children.show();
var childW = children.outerWidth();
var childH = children.outerHeight();
var realLeft = children.offset().left + childW + 5;
var realBottom = children.offset().top + childH + 5;
var realTop = children.offset().top + 5;
children.hide();
if( realLeft >= docSize ){
children.css('left', 5 - childW );
}
// 37916: Try to show the menu going up if it will go off the bottom of the screen, but
// only if that won't make it go off the top of the screen
if( realBottom >= docHeight ){
if( realTop - childH > 0 )
{
children.css('top', 35 - childH );
}
}
},
//----------------------------------------------