var act = new Object();
jQuery(function(){
jQuery('input.generic-record-search').each(function(){
var self = this;
jQuery( self ).autocomplete({
serviceUrl: ajaxurl + '?action=search¶ms=' + jQuery( self ).parent().children('input.generic-params').val(),
minChars:2,
delimiter: /(,|;)\s*/,
maxHeight:400,
width:300,
zIndex: 9999,
deferRequestBy: 0,
noCache: false,
onSelect: function( value , data){
jQuery(function(){
jQuery( self ).parent().children('input.generic-value').val( data );
});
}
});
});
});
act.search = function( self , selector ){
jQuery(function(){
if( jQuery( self ).val().length > 0 ){
if( selector != '-' ){
jQuery( selector ).show();
}
}else{
if( selector != '-' ){
jQuery( selector ).hide();
}
jQuery( self ).parent().children('input.generic-value').val('');
}
});
}
act.my_likes = function( post_id , data , type ){
jQuery(function(){
if( !(jQuery( 'div#content div.front-page img#loading' ).length) ){
jQuery( 'div#content div.front-page' ).append( '
' );
}
jQuery.post( ajaxurl , {'action' : 'my_likes' , 'post_id' : post_id , 'data' : data , 'type' : type } , function( result ){
if( result.substr( 0 , 1 ) == '{' ){
var opt = eval("(" + result + ')');
act.my_likes( opt.post_id , opt.data , type );
}else{
jQuery( 'div#content div.front-page img#loading' ).remove();
jQuery( 'div.clearfix.get-more' ).remove();
jQuery( 'div.loop-container-view div.last').removeClass('last');
if( type == 1 ){
jQuery( 'div#content div.front-page' ).append( result );
if( jQuery('div.clearfix.get-more p a').length > 0 ){
jQuery( 'span.list-grid a' ).attr( 'index' , jQuery('div.clearfix.get-more p a').attr( 'index') );
}
}else{
jQuery( 'div#content div.front-page div.loop-container-view' ).append( result );
}
return 0;
}
});
});
}
act.min_likes = function( nr , page ){
jQuery(function(){
if( page == 1 ){
jQuery( 'span.digit-btn.result' ).html( 'update ..' );
}
jQuery.post( ajaxurl , {'action' : 'min_likes' , 'page' : page , 'new_limit' : nr} , function( result ){
if( result > 0 ){
var n = (( parseInt( result ) - 1 ) * 150 );
jQuery( 'span.digit-btn.result' ).html( n + ' posts updated .. ' );
act.min_likes( nr , result );
}else{
jQuery( 'span.digit-btn.result' ).html( '' );
return 0;
}
} );
});
}
act.sim_likes = function( page ){
jQuery(function(){
if( page == 1 ){
jQuery( 'span.btn.result' ).html( 'update ..' );
}
jQuery.post( ajaxurl , {'action' : 'sim_likes' , 'page' : page} , function( result ){
if( result > 0 ){
var n = (( parseInt( result ) - 1 ) * 150 );
jQuery( 'span.btn.result' ).html( n + ' posts updated .. ' );
act.sim_likes( result );
}else{
jQuery( 'span.btn.result' ).html( '' );
return 0;
}
});
});
}
act.select = function( selector , args , type ){
jQuery(document).ready(function( ){
jQuery( 'option' , jQuery( 'select' + selector ) ).each(function(i){
if( type == 'hs' ){
if( jQuery(this).is(':selected') ){
for (var key in args) {
if ( args.hasOwnProperty( key ) ) {
if( jQuery( this ).val().trim() == key ){
jQuery( args[ key ] ).hide();
}else{
jQuery( args[ key ] ).show();
}
}
}
}
}
if( type == 'sh' ){
if( jQuery(this).is(':selected') ){
for (var key in args) {
if ( args.hasOwnProperty( key ) ) {
if( jQuery( this ).val().trim() == key ){
jQuery( args[ key ] ).show();
}else{
jQuery( args[ key ] ).hide();
}
}
}
}
}
if( type == 'sh_' ){
var show = '';
var show_ = '';
if( jQuery(this).is(':selected') ){
for (var key in args) {
if ( args.hasOwnProperty( key ) ) {
if( jQuery( this ).val().trim() == key ){
show = args[ key ];
}else{
if( key == 'else' ){
show_ = args[ key ];
}
jQuery( args[ key ] ).hide();
}
}
}
if( show == '' ){
jQuery( show_ ).show();
}else{
jQuery( show ).show();
}
}
}
if( type == 'hs_' ){
var hide = '';
if( jQuery(this).is(':selected') ){
for (var key in args) {
if ( args.hasOwnProperty( key ) ) {
if( jQuery( this ).val().trim() == key ){
hide = args[ key ];
}else{
jQuery( args[ key ] ).show();
}
}
}
jQuery( hide ).hide();
}
}
if( type == 's' ){
if( jQuery(this).is(':selected') ){
for (var key in args) {
if ( args.hasOwnProperty( key ) ) {
if( jQuery( this ).val().trim() == key ){
jQuery( args[ key ] ).show();
}
}
}
}
}
if( type == 'h' ){
if( jQuery(this).is(':selected') ){
for (var key in args) {
if ( args.hasOwnProperty( key ) ) {
if( jQuery( this ).val().trim() == key ){
jQuery( args[ key ] ).hide();
}
}
}
}
}
if( type == 'ns' ){
if( jQuery(this).is(':selected') ){
for (var key in args) {
if ( args.hasOwnProperty( key ) ) {
if( jQuery( this ).val().trim() == key ){
}else{
jQuery( args[ key ] ).show();
}
}
}
}
}
if( type == 'nh' ){
if( jQuery(this).is(':selected') ){
for (var key in args) {
if ( args.hasOwnProperty( key ) ) {
if( jQuery( this ).val().trim() == key ){
}else{
jQuery( args[ key ] ).hide();
}
}
}
}
}
});
});
}
act.mcheck = function( selectors ){
var result = true;
jQuery(document).ready(function( ){
for( var i = 0 ; i < selectors.length; i++ ){
if( jQuery( selectors[ i ] ).is(':checked') ){
if( jQuery( selectors[ i ] ).val().trim() == 'yes' ){
result = result && true;
}else{
result = result && false;
}
}else{
result = result && false;
}
}
});
if( result ){
jQuery( '.g_l_register' ).show();
}else{
jQuery( '.g_l_register' ).hide();
}
}
act.check = function( selector , args , type ){
jQuery(document).ready(function( ){
if( type == 'hs' ){
if( jQuery( selector ).is(':checked') ){
for (var key in args) {
if ( args.hasOwnProperty( key ) ) {
if( jQuery( selector ).val().trim() == key ){
jQuery( args[ key ] ).hide();
}else{
jQuery( args[ key ] ).show();
}
}
}
}
}
if( type == 'sh' ){
if( jQuery( selector ).is(':checked') ){
for (var key in args) {
if ( args.hasOwnProperty( key ) ) {
if( jQuery( selector ).val().trim() == key ){
jQuery( args[ key ] ).show();
}else{
jQuery( args[ key ] ).hide();
}
}
}
}
}
if( type == 'sh_' ){
var show = '';
var show_ = '';
if( jQuery( selector ).is(':checked') ){
for (var key in args) {
if ( args.hasOwnProperty( key ) ) {
if( jQuery( this ).val().trim() == key ){
show = args[ key ];
}else{
if( key == 'else' ){
show_ = args[ key ];
}
jQuery( args[ key ] ).hide();
}
}
}
if( show == '' ){
jQuery( show_ ).show();
}else{
jQuery( show ).show();
}
}
}
if( type == 'hs_' ){
var hide = '';
if( jQuery( selector ).is(':checked') ){
for (var key in args) {
if ( args.hasOwnProperty( key ) ) {
if( jQuery( this ).val().trim() == key ){
hide = args[ key ];
}else{
jQuery( args[ key ] ).show();
}
}
}
jQuery( hide ).hide();
}
}
if( type == 's' ){
if( jQuery( selector ).is(':checked') ){
for (var key in args) {
if ( args.hasOwnProperty( key ) ) {
if( jQuery( selector ).val().trim() == key ){
jQuery( args[ key ] ).show();
}
}
}
}
}
if( type == 'h' ){
if( jQuery( selector ).is(':checked') ){
for (var key in args) {
if ( args.hasOwnProperty( key ) ) {
if( jQuery( selector ).val().trim() == key ){
jQuery( args[ key ] ).hide();
}
}
}
}
}
if( type == 'ns' ){
if( jQuery( selector ).is(':checked') ){
for (var key in args) {
if ( args.hasOwnProperty( key ) ) {
if( jQuery( selector ).val().trim() == key ){
}else{
jQuery( args[ key ] ).show();
}
}
}
}
}
if( type == 'nh' ){
if( jQuery( selector ).is(':checked') ){
for (var key in args) {
if ( args.hasOwnProperty( key ) ) {
if( jQuery( selector ).val().trim() == key ){
}else{
jQuery( args[ key ] ).hide();
}
}
}
}
}
});
}
act.show = function( selector ){
jQuery(document).ready(function( ){
jQuery( selector ).show();
});
}
act.hide = function( selector ){
jQuery(document).ready(function( ){
jQuery( selector ).hide();
});
}
act.link = function( selector , args , type ){
jQuery(document).ready(function( ){
var id = jQuery( selector ).attr('id');
if( type == 'hs' ){
for (var key in args) {
if ( args.hasOwnProperty( key ) ) {
if( id.trim() == key ){
jQuery( args[ key ] ).hide();
}else{
jQuery( args[ key ] ).show();
}
}
}
}
if( type == 'sh' ){
for (var key in args) {
if ( args.hasOwnProperty( key ) ) {
if( id.trim() == key ){
jQuery( args[ key ] ).show();
}else{
jQuery( args[ key ] ).hide();
}
}
}
}
if( type == 's' ){
for (var key in args) {
if ( args.hasOwnProperty( key ) ) {
if( id.trim() == key ){
jQuery( args[ key ] ).show();
}
}
}
}
if( type == 'h' ){
for (var key in args) {
if ( args.hasOwnProperty( key ) ) {
if( id.trim() == key ){
jQuery( args[ key ] ).hide();
}
}
}
}
if( type == 'ns' ){
for (var key in args) {
if ( args.hasOwnProperty( key ) ) {
if( id.val().trim() == key ){
}else{
jQuery( args[ key ] ).show();
}
}
}
}
if( type == 'nh' ){
for (var key in args) {
if ( args.hasOwnProperty( key ) ) {
if( id.val().trim() == key ){
}else{
jQuery( args[ key ] ).hide();
}
}
}
}
});
}
act.extern_upload_id = function( group , name , id, upload_url ){
if( upload_url == ""){
tb_show_url = 'media-upload.php?post_id=-1&type=image&TB_iframe=true';
}else{
tb_show_url = upload_url;
}
/*deleteUserSetting('uploader');
setUserSetting('uploader', '1');*/
jQuery(document).ready(function() {
(function(){
var tb_show_temp = window.tb_show;
window.tb_show = function(){
tb_show_temp.apply(null, arguments);
jQuery('#TB_iframeContent').load(function(){
if( jQuery( this ).contents().find('p.upload-html-bypass').length ){
jQuery( this ).contents().find('p.upload-html-bypass').remove();
}
jQuery( this ).contents().find('div#html-upload-ui').show();
jQuery( this ).contents().find('ul#sidemenu li#tab-type_url , ul#sidemenu li#tab-library').hide();
jQuery( this ).contents().find('thead tr td p input.button').hide();
jQuery( this ).contents().find('tr.image_alt').hide();
jQuery( this ).contents().find('tr.post_content').hide();
jQuery( this ).contents().find('tr.url').hide();
jQuery( this ).contents().find('tr.align').hide();
jQuery( this ).contents().find('tr.image-size').hide();
jQuery( this ).contents().find('p.savebutton.ml-submit').hide();
$container = jQuery( this ).contents().find('tr.submit td.savesend');
var sid = '';
$container.find('div.del-attachment').each(function(){
var $div = jQuery(this);
sid = $div.attr('id').toString();
if( typeof sid != "undefined" ){
sid = sid.replace(/del_attachment_/gi , "" );
jQuery(this).parent('td.savesend').html('');
}else{
var $submit = $container.find('input[type="submit"]');
sid = $submit.attr('name');
if( typeof sid != "undefined" ){
sid = sid.replace(/send\[/gi , "" );
sid = sid.replace(/\]/gi , "" );
$container.html('');
}
}
});
$container.find('input[type="submit"]').click(function(){
$my_submit = jQuery( this );
sid = $my_submit.attr('name');
if( typeof sid != "undefined" ){
sid = sid.replace(/send\[/gi , "" );
sid = sid.replace(/\]/gi , "" );
}else{
sid = 0;
}
var html = $my_submit.parent('td').parent('tr').parent('tbody').parent('table').html();
window.send_to_editor = function() {
var attach_url = jQuery('input[name="attachments['+sid+'][url]"]',html).val();
jQuery( 'input#' + group + '_' + name + id ).val( attach_url );
jQuery( 'input#' + group + '_' + name + '_id' + id ).val( sid );
if( id.length > 0 ){
jQuery( 'img#attach_' + group + '_' + name + id).attr( "src" , attach_url );
}
tb_remove();
}
});
});
}})()
formfield = jQuery( 'input#' + group + '_' + name + id ).attr('name');
tb_show('', tb_show_url);
return false;
});
}
act.upload_id = function( group , name , id, upload_url ){
if( upload_url == ""){
tb_show_url = 'media-upload.php?post_id=-1&type=image&TB_iframe=true&flash=0';
}else{
tb_show_url = upload_url;
}
deleteUserSetting('uploader');
setUserSetting('uploader', '1');
jQuery(document).ready(function() {
(function(){
var tb_show_temp = window.tb_show;
window.tb_show = function(){
tb_show_temp.apply(null, arguments);
jQuery('#TB_iframeContent').load(function(){
if( jQuery( this ).contents().find('p.upload-html-bypass').length ){
jQuery( this ).contents().find('p.upload-html-bypass').remove();
}
jQuery( this ).contents().find('div#html-upload-ui').show();
$container = jQuery( this ).contents().find('tr.submit td.savesend');
var sid = '';
$container.find('div.del-attachment').each(function(){
var $div = jQuery(this);
sid = $div.attr('id').toString();
if( typeof sid != "undefined" ){
sid = sid.replace(/del_attachment_/gi , "" );
jQuery(this).parent('td.savesend').html('');
}else{
var $submit = $container.find('input[type="submit"]');
sid = $submit.attr('name');
if( typeof sid != "undefined" ){
sid = sid.replace(/send\[/gi , "" );
sid = sid.replace(/\]/gi , "" );
$container.html('');
}
}
});
$container.find('input[type="submit"]').click(function(){
$my_submit = jQuery( this );
sid = $my_submit.attr('name');
if( typeof sid != "undefined" ){
sid = sid.replace(/send\[/gi , "" );
sid = sid.replace(/\]/gi , "" );
}else{
sid = 0;
}
var html = $my_submit.parent('td').parent('tr').parent('tbody').parent('table').html();
window.send_to_editor = function() {
var attach_url = jQuery('input[name="attachments['+sid+'][url]"]',html).val();
jQuery( 'input#' + group + '_' + name + id ).val( attach_url );
jQuery( 'input#' + group + '_' + name + '_id' + id ).val( sid );
if( id.length > 0 ){
jQuery( 'img#attach_' + group + '_' + name + id).attr( "src" , attach_url );
}
tb_remove();
}
});
});
}})()
formfield = jQuery( 'input#' + group + '_' + name + id ).attr('name');
tb_show('', tb_show_url);
return false;
});
}
act.upload = function( selector ){
deleteUserSetting('uploader');
setUserSetting('uploader', '1');
jQuery(document).ready(function() {
(function(){
var tb_show_temp = window.tb_show;
window.tb_show = function(){
tb_show_temp.apply( null , arguments);
jQuery('#TB_iframeContent').load(function(){
jQuery( this ).contents().find('p.upload-html-bypass').remove();
jQuery( this ).contents().find('div#html-upload-ui').show();
$container = jQuery( this ).contents().find('tr.submit td.savesend');
var sid = '';
$container.find('div.del-attachment').each(function(){
var $div = jQuery(this);
sid = $div.attr('id').toString();
if( typeof sid != "undefined" ){
sid = sid.replace(/del_attachment_/gi , "" );
jQuery(this).parent('td.savesend').html('');
}else{
var $submit = $container.find('input[type="submit"]');
sid = $submit.attr('name');
if( typeof sid != "undefined" ){
sid = sid.replace(/send\[/gi , "" );
sid = sid.replace(/\]/gi , "" );
$container.html('');
}
}
});
$container.find('input[type="submit"]').click(function(){
$my_submit = jQuery( this );
sid = $my_submit.attr('name');
if( typeof sid != "undefined" ){
sid = sid.replace(/send\[/gi , "" );
sid = sid.replace(/\]/gi , "" );
}else{
sid = 0;
}
var html = $my_submit.parent('td').parent('tr').parent('tbody').parent('table').html();
window.send_to_editor = function() {
var attach_url = jQuery('input[name="attachments['+sid+'][url]"]',html).val();
jQuery( selector ).val( attach_url );
tb_remove();
}
});
});
}})()
formfield = jQuery( selector ).attr('name');
tb_show('', 'media-upload.php?post_id=-1&type=image&TB_iframe=true');
return false;
});
}
act.generate = function( action ){
jQuery(function(){
jQuery( 'body' ).append( '